/* Charul Studio Console — blueprint / drawing-set inspired ERP shell */

:root {
    --ink: #1c2430;
    --paper: #f6f4ef;
    --paper-raised: #fffefb;
    --navy: #16233b;
    --navy-2: #1f3355;
    --navy-line: #2a3a56;
    --blue: #3d6fb4;
    --blue-dim: #2b4c7e;
    --rust: #c1592f;
    --rust-dim: #a34a26;
    --line: #dad5c8;
    --muted: #6b7280;
    --success: #3e7a4f;
    --radius: 3px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    background: var(--paper);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
}

h1, h2, h3 {
    font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
    margin: 0;
}

a { color: var(--blue-dim); }

.mono { font-family: "IBM Plex Mono", monospace; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

@media (prefers-reduced-motion: no-preference) {
    .btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .nav-link, .tile {
        transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
    }
}

/* ---------- shell layout ---------- */

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    flex: none;
    background: var(--navy);
    color: #cdd6e6;
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 24px 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 20px;
    border-bottom: 1px solid var(--navy-line);
    margin-bottom: 16px;
}

.brand-mark {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: var(--navy);
    background: var(--blue);
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.brand-text { display: flex; flex-direction: column; }

.brand-name {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    font-size: 17px;
    color: #fff;
    letter-spacing: 0.02em;
}

.brand-sub {
    font-family: "IBM Plex Mono", monospace;
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7f8fac;
}

.nav-eyebrow {
    font-family: "IBM Plex Mono", monospace;
    font-size: 10.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #5c6c8a;
    padding: 0 8px;
    margin-bottom: 8px;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px;
    border-radius: var(--radius);
    color: #b7c2d6;
    text-decoration: none;
    border-left: 2px solid transparent;
}

.nav-link:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }

.nav-link.is-active {
    background: var(--navy-2);
    color: #fff;
    border-left-color: var(--blue);
}

.nav-icon {
    width: 17px;
    height: 17px;
    flex: none;
    color: #e4e8f1;
}

.nav-link.is-active .nav-icon { color: #fff; }

.nav-label { font-size: 13.5px; }

.sidebar-foot {
    border-top: 1px solid var(--navy-line);
    padding-top: 14px;
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: #cdd6e6;
}

.user-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    flex: none;
}

.btn-ghost {
    width: 100%;
    background: transparent;
    border: 1px solid var(--navy-line);
    color: #cdd6e6;
    padding: 7px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    font-size: 12.5px;
}

.btn-ghost:hover { border-color: var(--blue); color: #fff; }

/* ---------- main / topbar ---------- */

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 28px;
    border-bottom: 1px solid var(--line);
    background: var(--paper-raised);
    min-width: 0;
}

.topbar-crumb { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-meta { flex: none; }

.topbar-crumb, .topbar-meta {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11.5px;
    letter-spacing: 0.04em;
    color: var(--muted);
    text-transform: uppercase;
}

.content {
    flex: 1;
    min-width: 0;
    padding: 28px;
    width: 100%;
}

/* ---------- page head ---------- */

.page-head { margin-bottom: 20px; }

.page-eyebrow {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--blue-dim);
    margin-bottom: 6px;
}

.page-title { font-size: 26px; font-weight: 700; color: var(--ink); }

.page-lede { color: var(--muted); margin: 8px 0 0; max-width: 56ch; }

.page-head-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* ---------- sheet card (title-block motif) ---------- */

.sheet {
    position: relative;
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.sheet::before, .sheet::after,
.tile::before, .tile::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    pointer-events: none;
}

.sheet::before { top: -1px; left: -1px; border-top: 2px solid var(--blue); border-left: 2px solid var(--blue); }
.sheet::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--blue); border-right: 2px solid var(--blue); }

.sheet-danger::before, .sheet-danger::after { border-color: var(--rust); }

.sheet-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    background: #fbfaf6;
}

.sheet-bar-title { font-weight: 600; font-size: 14.5px; }

.sheet-bar-code {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11.5px;
    color: var(--muted);
}

.sheet-bar-danger .sheet-bar-code { color: var(--rust-dim); }

.sheet-body { padding: 18px; }
.sheet-body p { margin: 0 0 16px; color: var(--ink); max-width: 60ch; }

/* ---------- table ---------- */

.search-row { display: flex; gap: 8px; padding: 14px 18px 0; }

.search-row input {
    flex: 1;
    max-width: 320px;
}

.table-scroll { overflow-x: auto; padding: 14px 18px 18px; }

.table { width: 100%; border-collapse: collapse; }

.table th {
    text-align: left;
    font-family: "IBM Plex Mono", monospace;
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.table tbody tr:hover { background: #f1f5fb; }

.col-actions { white-space: nowrap; }
.col-actions a { margin-right: 12px; font-size: 13px; }
.link-danger { color: var(--rust-dim); }

.empty-row { color: var(--muted); text-align: left; padding: 20px 10px; }

/* ---------- forms ---------- */

.spec-form { padding: 18px; }

.spec-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
}

.field { display: flex; flex-direction: column; gap: 5px; }

.field-inline { flex-direction: row; align-items: center; }

.field label {
    font-family: "IBM Plex Mono", monospace;
    font-size: 10.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.field-input, .field-file,
input[type="text"], input[type="password"], input[type="email"],
input[type="url"], input[type="number"], textarea, select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper-raised);
    color: var(--ink);
}

.field-input:focus, .field-file:focus,
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(61, 111, 180, 0.16);
}

textarea { resize: vertical; min-height: 90px; }

.field-help { font-size: 12px; color: var(--muted); margin: 0; }

.field-errors { color: var(--rust-dim); margin: 0; padding-left: 16px; font-size: 12.5px; }

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 0 18px 18px;
}

.spec-form .form-actions { padding: 0; margin-top: 22px; }

/* ---------- buttons ---------- */

.btn-primary, .btn-secondary, .btn-danger {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dim); }

.btn-secondary { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue-dim); }

.btn-danger { background: var(--rust); color: #fff; }
.btn-danger:hover { background: var(--rust-dim); }

.btn-block { width: 100%; }

/* ---------- messages ---------- */

.messages { list-style: none; padding: 0; margin: 0 0 18px; }

.message {
    padding: 9px 14px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 13px;
    border-left: 3px solid var(--muted);
    background: #fff;
}

.message.success { border-left-color: var(--success); color: #256029; background: #eef7ef; }
.message.error { border-left-color: var(--rust); color: #8a3a1f; background: #fbeee7; }

/* ---------- dashboard tiles ---------- */

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}

.tile {
    position: relative;
    min-width: 0;
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    text-decoration: none;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tile-code, .tile-label { overflow-wrap: break-word; }

.tile::before { top: -1px; left: -1px; border-top: 2px solid var(--blue); border-left: 2px solid var(--blue); }
.tile::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--blue); border-right: 2px solid var(--blue); }

.tile:hover { border-color: var(--blue); transform: translateY(-1px); }

.tile-code {
    font-family: "IBM Plex Mono", monospace;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.tile-count {
    font-family: "IBM Plex Mono", monospace;
    font-size: 30px;
    font-weight: 500;
    color: var(--blue-dim);
}

.tile-label { font-size: 13px; color: var(--ink); }

/* ---------- login ---------- */

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 28px 28px;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--paper-raised);
    border-radius: var(--radius);
    padding: 28px 28px 20px;
    position: relative;
}

.login-card::before, .login-card::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
}

.login-card::before { top: -1px; left: -1px; border-top: 2px solid var(--blue); border-left: 2px solid var(--blue); }
.login-card::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--blue); border-right: 2px solid var(--blue); }

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
}

.login-brand .brand-name { color: var(--ink); }
.login-brand .brand-sub { color: var(--muted); }

.login-eyebrow {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 16px;
}

.login-form .field { margin-bottom: 14px; }

.login-foot {
    font-family: "IBM Plex Mono", monospace;
    font-size: 10.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: center;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

/* ---------- focus ---------- */

a:focus-visible, button:focus-visible, input:focus-visible, .tile:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
    .shell { flex-direction: column; }

    .sidebar {
        width: auto;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
        padding: 12px;
    }

    .brand { border-bottom: none; margin-bottom: 0; padding: 0 12px 0 0; }
    .nav-eyebrow { display: none; }
    .nav-list { display: flex; flex: none; gap: 4px; }
    .sidebar-foot { flex-direction: row; border-top: none; margin: 0 0 0 12px; padding: 0; }
    .user-chip { display: none; }

    .content { padding: 18px; }
    .spec-grid { grid-template-columns: 1fr; }
    .topbar { padding: 10px 18px; }
    .topbar-meta { display: none; }
    .topbar-crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 480px) {
    .tile-grid { grid-template-columns: 1fr 1fr; }
}
