/* ============================================================================
   Conduit — design system
   Hand-written in the shadcn/ui visual language (zinc neutrals, 0.625rem radii,
   ring-offset focus, subtle elevation). Ports 1:1 to Tailwind tokens at V1.
   ========================================================================== */

/* ── Tokens ───────────────────────────────────────────────────────────────── */
:root {
    --bg:               #ffffff;
    --fg:               #09090b;
    --card:             #ffffff;
    --card-fg:          #09090b;
    --muted:            #f4f4f5;
    --muted-fg:         #71717a;
    --subtle:           #fafafa;
    --border:           #e4e4e7;
    --border-strong:    #d4d4d8;
    --input:            #ffffff;
    --ring:             #6366f1;

    --brand:            #4f46e5;
    --brand-fg:         #ffffff;
    --brand-soft:       #eef2ff;
    --brand-border:     #c7d2fe;

    --ok:               #059669;
    --ok-soft:          #ecfdf5;
    --ok-border:        #a7f3d0;
    --warn:             #b45309;
    --warn-soft:        #fffbeb;
    --warn-border:      #fde68a;
    --bad:              #dc2626;
    --bad-soft:         #fef2f2;
    --bad-border:       #fecaca;
    --info:             #0284c7;
    --info-soft:        #f0f9ff;
    --info-border:      #bae6fd;

    --shadow-sm:  0 1px 2px 0 rgb(0 0 0 / .05);
    --shadow:     0 1px 3px 0 rgb(0 0 0 / .08), 0 1px 2px -1px rgb(0 0 0 / .08);
    --shadow-md:  0 4px 12px -2px rgb(0 0 0 / .10), 0 2px 6px -2px rgb(0 0 0 / .06);
    --shadow-lg:  0 16px 40px -12px rgb(0 0 0 / .22), 0 4px 10px -4px rgb(0 0 0 / .10);

    --r-sm: 6px;
    --r:    9px;
    --r-lg: 13px;
    --r-xl: 18px;

    --sidebar-w: 250px;
    --topbar-h: 56px;

    --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
    --bg:               #09090b;
    --fg:               #fafafa;
    --card:             #101013;
    --card-fg:          #fafafa;
    --muted:            #18181b;
    --muted-fg:         #a1a1aa;
    --subtle:           #131316;
    --border:           #26262b;
    --border-strong:    #3f3f46;
    --input:            #141417;
    --ring:             #818cf8;

    --brand:            #6366f1;
    --brand-fg:         #ffffff;
    --brand-soft:       #1e1b4b;
    --brand-border:     #3730a3;

    --ok:               #34d399;
    --ok-soft:          #052e22;
    --ok-border:        #115e46;
    --warn:             #fbbf24;
    --warn-soft:        #2c1e05;
    --warn-border:      #78430f;
    --bad:              #f87171;
    --bad-soft:         #300f0f;
    --bad-border:       #7f1d1d;
    --info:             #38bdf8;
    --info-soft:        #082f43;
    --info-border:      #075985;

    --shadow-lg:  0 16px 40px -12px rgb(0 0 0 / .7), 0 4px 10px -4px rgb(0 0 0 / .5);
    --shadow-md:  0 4px 12px -2px rgb(0 0 0 / .5);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body { height: 100%; }
/* Any author `display` beats the UA stylesheet's [hidden] rule, so overlays
   declaring display:grid would stay on screen while marked hidden. */
[hidden] { display: none !important; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-feature-settings: "cv02","cv03","cv04","cv11";
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
svg { display: block; }
h1,h2,h3,h4 { font-weight: 600; line-height: 1.25; letter-spacing: -0.015em; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: color-mix(in srgb, var(--brand) 28%, transparent); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid var(--bg); }

/* ── Boot splash ──────────────────────────────────────────────────────────── */
.boot {
    position: fixed; inset: 0; z-index: 300;
    display: grid; place-items: center;
    background: var(--bg);
    transition: opacity .35s ease;
}
.boot.gone { opacity: 0; pointer-events: none; }
.boot-inner { display: grid; justify-items: center; gap: 14px; }
.boot-mark { width: 44px; height: 44px; color: var(--brand); animation: bootpulse 1.6s ease-in-out infinite; }
.boot-mark svg { width: 100%; height: 100%; }
.boot-name { font-size: 19px; font-weight: 700; letter-spacing: -0.03em; }
.boot-bar { width: 168px; height: 3px; border-radius: 99px; background: var(--muted); overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 40%; border-radius: 99px; background: var(--brand); animation: bootslide 1.15s ease-in-out infinite; }
.boot-hint { font-size: 12px; color: var(--muted-fg); }
@keyframes bootslide { 0% { transform: translateX(-110%); } 100% { transform: translateX(320%); } }
@keyframes bootpulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ── App frame ────────────────────────────────────────────────────────────── */
.app { display: flex; height: 100%; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.content { flex: 1; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.content:focus { outline: none; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    background: var(--subtle);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    height: 100%;
}
.sidebar-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 4px; border-radius: var(--r); }
.brand:hover { background: var(--muted); }
.brand-mark {
    width: 30px; height: 30px; flex: none; border-radius: 8px;
    background: var(--brand); color: var(--brand-fg);
    display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-text { display: grid; min-width: 0; }
.brand-text strong { font-size: 14.5px; letter-spacing: -0.02em; }
.brand-text small { font-size: 11.5px; color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.palette-trigger {
    margin: 0 12px 12px; padding: 7px 9px;
    display: flex; align-items: center; gap: 8px;
    border: 1px solid var(--border); border-radius: var(--r);
    background: var(--input); color: var(--muted-fg);
    font-size: 12.5px; box-shadow: var(--shadow-sm);
    transition: border-color .15s, color .15s;
}
.palette-trigger:hover { border-color: var(--border-strong); color: var(--fg); }
.palette-trigger span:nth-child(2) { flex: 1; text-align: left; }
.palette-trigger .pt-icon svg { width: 14px; height: 14px; }

.nav { flex: 1; overflow-y: auto; padding: 0 10px 12px; display: grid; gap: 1px; align-content: start; }
.nav-section { font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted-fg); padding: 14px 8px 5px; }
.nav a {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 8px; border-radius: var(--r-sm);
    font-size: 13.5px; font-weight: 500; color: var(--muted-fg);
    transition: background .12s, color .12s;
}
.nav a svg { width: 16px; height: 16px; flex: none; opacity: .9; }
.nav a span.label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a:hover { background: var(--muted); color: var(--fg); }
.nav a.active { background: var(--card); color: var(--fg); font-weight: 600; box-shadow: var(--shadow-sm); border: 1px solid var(--border); padding: 6px 7px; }
html[data-theme="dark"] .nav a.active { background: var(--muted); border-color: var(--border); }
.nav-count {
    font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
    min-width: 19px; text-align: center; padding: 1px 5px; border-radius: 99px;
    background: var(--muted); color: var(--muted-fg); border: 1px solid var(--border);
}
.nav a.active .nav-count { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-border); }
.nav-count.hot { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-border); }

.sidebar-foot { padding: 10px 14px 14px; border-top: 1px solid var(--border); }
.storage-note { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted-fg); }
.sn-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--ok); flex: none; transition: background .2s; }
.storage-note.saving .sn-dot { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.scrim { display: none; }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h); flex: none;
    display: flex; align-items: center; gap: 10px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 20;
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; min-width: 0; flex: 1; }
.crumbs a, .crumbs span { color: var(--muted-fg); white-space: nowrap; }
.crumbs a:hover { color: var(--fg); }
.crumbs .sep { opacity: .5; }
.crumbs .current { color: var(--fg); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
/* Specificity has to beat .btn / .icon-btn, which are declared further down. */
.btn.topbar-search { display: none; }
.icon-btn.sidebar-open, .icon-btn.sidebar-close { display: none; }

.role-switch { display: flex; align-items: center; gap: 2px; padding: 2px; background: var(--muted); border-radius: var(--r); border: 1px solid var(--border); }
.role-switch button {
    font-size: 11.5px; font-weight: 500; padding: 3px 9px; border-radius: var(--r-sm);
    color: var(--muted-fg); text-transform: capitalize; transition: all .12s;
}
.role-switch button:hover { color: var(--fg); }
.role-switch button.on { background: var(--card); color: var(--fg); font-weight: 600; box-shadow: var(--shadow-sm); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 34px; padding: 0 13px; border-radius: var(--r-sm);
    font-size: 13px; font-weight: 500; white-space: nowrap;
    border: 1px solid transparent; transition: all .13s ease;
    box-shadow: var(--shadow-sm);
}
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--brand); color: var(--brand-fg); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn-default { background: var(--card); color: var(--fg); border-color: var(--border); }
.btn-default:hover { background: var(--muted); border-color: var(--border-strong); }
.btn-ghost { background: transparent; box-shadow: none; color: var(--muted-fg); }
.btn-ghost:hover { background: var(--muted); color: var(--fg); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-sm { height: 29px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-sm svg { width: 13px; height: 13px; }
.btn-xs { height: 25px; padding: 0 8px; font-size: 12px; }
.btn-xs svg { width: 12px; height: 12px; }
.btn-block { width: 100%; }

.icon-btn {
    width: 34px; height: 34px; flex: none; border-radius: var(--r-sm);
    display: grid; place-items: center; color: var(--muted-fg);
    border: 1px solid transparent; transition: all .13s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--muted); color: var(--fg); }

kbd {
    font-family: var(--font); font-size: 10.5px; font-weight: 500;
    padding: 2px 5px; border-radius: 5px; color: var(--muted-fg);
    background: var(--muted); border: 1px solid var(--border);
    line-height: 1.3; white-space: nowrap;
}

/* ── Page scaffolding ─────────────────────────────────────────────────────── */
.page { padding: 22px 26px 60px; max-width: 1500px; margin: 0 auto; animation: fadein .22s ease; }
.page-wide { max-width: none; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }

.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; letter-spacing: -0.03em; }
.page-head p { color: var(--muted-fg); font-size: 13.5px; margin-top: 3px; max-width: 70ch; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.section-head { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; }
.section-head h2 { font-size: 15px; }
.section-head .actions { margin-left: auto; display: flex; gap: 7px; }
.section-head p { color: var(--muted-fg); font-size: 12.5px; }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card-head h3 { font-size: 14px; }
.card-head p { font-size: 12.5px; color: var(--muted-fg); margin-top: 2px; }
.card-head .actions { margin-left: auto; display: flex; gap: 7px; align-items: center; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; background: var(--subtle); border-radius: 0 0 var(--r-lg) var(--r-lg); }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.g-1-2 { grid-template-columns: minmax(0,1fr) minmax(0,2fr); }

/* ── KPI tiles ────────────────────────────────────────────────────────────── */
.kpi {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
    padding: 14px 16px; box-shadow: var(--shadow-sm);
    display: grid; gap: 6px; align-content: start;
    position: relative; overflow: hidden;
    transition: border-color .15s, transform .15s;
}
a.kpi:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.kpi-label { font-size: 12px; color: var(--muted-fg); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi-label svg { width: 14px; height: 14px; opacity: .8; }
.kpi-value { font-size: 25px; font-weight: 650; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-value.sm { font-size: 20px; }
.kpi-sub { font-size: 12px; color: var(--muted-fg); display: flex; align-items: center; gap: 5px; }
.kpi-sub svg { width: 13px; height: 13px; }
.kpi-sub.ok { color: var(--ok); } .kpi-sub.bad { color: var(--bad); } .kpi-sub.warn { color: var(--warn); }
.kpi-spark { margin-top: 2px; height: 30px; }
.kpi-spark svg { width: 100%; height: 100%; overflow: visible; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--r-lg) var(--r-lg); }
table.tbl { font-size: 13px; }
.tbl thead th {
    text-align: left; font-weight: 500; font-size: 11.5px; letter-spacing: .03em;
    text-transform: uppercase; color: var(--muted-fg);
    padding: 9px 14px; border-bottom: 1px solid var(--border);
    background: var(--subtle); white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.tbl tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr.clickable { cursor: pointer; transition: background .1s; }
.tbl tbody tr.clickable:hover { background: var(--muted); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .mono { font-family: var(--mono); font-size: 12px; }
.tbl th.num { text-align: right; }
.tbl .shrink { width: 1%; white-space: nowrap; }
.cell-title { font-weight: 500; }
.cell-sub { font-size: 12px; color: var(--muted-fg); margin-top: 1px; }
.tbl tfoot td { padding: 10px 14px; border-top: 1px solid var(--border); font-weight: 600; background: var(--subtle); }

/* ── Badges & pills ───────────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 99px;
    border: 1px solid var(--border); background: var(--muted); color: var(--muted-fg);
    white-space: nowrap; line-height: 1.45;
}
.badge svg { width: 11px; height: 11px; }
.badge.ok   { background: var(--ok-soft);   color: var(--ok);   border-color: var(--ok-border); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.badge.bad  { background: var(--bad-soft);  color: var(--bad);  border-color: var(--bad-border); }
.badge.info { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.badge.brand{ background: var(--brand-soft);color: var(--brand);border-color: var(--brand-border); }
.badge.solid{ background: var(--fg); color: var(--bg); border-color: var(--fg); }

.dot { width: 7px; height: 7px; border-radius: 99px; display: inline-block; flex: none; background: var(--muted-fg); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); } .dot.info { background: var(--info); }

.chip {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
    padding: 3px 9px; border-radius: var(--r-sm); border: 1px solid var(--border);
    background: var(--card); color: var(--muted-fg);
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.field { display: grid; gap: 5px; }
.field > label, .lbl { font-size: 12.5px; font-weight: 500; }
.field .hint { font-size: 11.5px; color: var(--muted-fg); }
.field .err { font-size: 11.5px; color: var(--bad); }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=search], select, textarea {
    width: 100%; height: 34px; padding: 0 10px;
    background: var(--input); color: var(--fg);
    border: 1px solid var(--border); border-radius: var(--r-sm);
    transition: border-color .13s, box-shadow .13s;
    font-size: 13px;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 68px; line-height: 1.5; }
select { cursor: pointer; appearance: none; padding-right: 28px;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted-fg) 50%), linear-gradient(135deg, var(--muted-fg) 50%, transparent 50%);
    background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
    background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 18%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--muted-fg); opacity: .75; }
input[type=number] { font-variant-numeric: tabular-nums; }
input.num { text-align: right; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-grid .span2 { grid-column: 1 / -1; }
.inline-fields { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 36px; height: 20px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .16s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 99px; background: #fff; transition: transform .16s; box-shadow: var(--shadow-sm); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent); }

/* Toolbar above tables */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .search-box { position: relative; flex: 1; min-width: 190px; max-width: 340px; }
.toolbar .search-box input { padding-left: 32px; }
.toolbar .search-box .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted-fg); pointer-events: none; }
.toolbar .search-box .i svg { width: 14px; height: 14px; }
.toolbar select { width: auto; min-width: 130px; }
.toolbar .spacer { flex: 1; }
.result-count { font-size: 12.5px; color: var(--muted-fg); white-space: nowrap; }

/* Segmented control */
.segmented { display: inline-flex; padding: 2px; gap: 2px; background: var(--muted); border: 1px solid var(--border); border-radius: var(--r); }
.segmented button { font-size: 12.5px; font-weight: 500; padding: 4px 11px; border-radius: var(--r-sm); color: var(--muted-fg); transition: all .12s; }
.segmented button:hover { color: var(--fg); }
.segmented button.on { background: var(--card); color: var(--fg); font-weight: 600; box-shadow: var(--shadow-sm); }

/* ── Empty / skeleton / loading ───────────────────────────────────────────── */
.empty { display: grid; justify-items: center; text-align: center; padding: 52px 24px; gap: 5px; }
.empty .ei {
    width: 42px; height: 42px; border-radius: var(--r-lg); display: grid; place-items: center;
    background: var(--muted); color: var(--muted-fg); border: 1px solid var(--border); margin-bottom: 7px;
}
.empty .ei svg { width: 20px; height: 20px; }
.empty h3 { font-size: 14.5px; }
.empty p { font-size: 13px; color: var(--muted-fg); max-width: 44ch; }
.empty .btn { margin-top: 10px; }

.skel { background: var(--muted); border-radius: var(--r-sm); position: relative; overflow: hidden; }
.skel::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--fg) 6%, transparent), transparent);
    animation: shimmer 1.35s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skel-line { height: 11px; }
.skel-row { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }

/* ── Sheet (right drawer) ─────────────────────────────────────────────────── */
.sheet-root { position: fixed; inset: 0; z-index: 120; }
.sheet-scrim { position: absolute; inset: 0; background: rgb(0 0 0 / .45); animation: fadein .18s ease; backdrop-filter: blur(1px); }
.sheet {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: min(620px, 100%); background: var(--bg);
    border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    animation: slidein .24s cubic-bezier(.32,.72,0,1);
}
.sheet.wide { width: min(860px, 100%); }
@keyframes slidein { from { transform: translateX(24px); opacity: .4; } }
.sheet-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 12px; flex: none; }
.sheet-head h2 { font-size: 16.5px; letter-spacing: -0.02em; }
.sheet-head .sub { font-size: 12.5px; color: var(--muted-fg); margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sheet-head .icon-btn { margin-left: auto; }
.sheet-body { flex: 1; overflow-y: auto; padding: 18px 20px 28px; }
.sheet-foot { flex: none; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--subtle); display: flex; gap: 8px; justify-content: flex-end; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: -4px 0 16px; overflow-x: auto; }
.tabs button {
    font-size: 13px; font-weight: 500; padding: 8px 11px; color: var(--muted-fg);
    border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .12s;
}
.tabs button:hover { color: var(--fg); }
.tabs button.on { color: var(--fg); font-weight: 600; border-bottom-color: var(--brand); }

/* Definition rows */
.dl { display: grid; grid-template-columns: minmax(110px, 30%) 1fr; gap: 1px 14px; font-size: 13px; }
.dl dt { color: var(--muted-fg); padding: 6px 0; }
.dl dd { padding: 6px 0; text-align: right; font-variant-numeric: tabular-nums; }
.dl.rows dt, .dl.rows dd { border-bottom: 1px dashed var(--border); }
.dl.rows dt:last-of-type, .dl.rows dd:last-of-type { border-bottom: none; }

.stat-row { display: flex; gap: 18px; flex-wrap: wrap; }
.stat { display: grid; gap: 2px; }
.stat .k { font-size: 11.5px; color: var(--muted-fg); }
.stat .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-root { position: fixed; inset: 0; z-index: 140; display: grid; place-items: center; padding: 20px; }
.modal-scrim { position: absolute; inset: 0; background: rgb(0 0 0 / .5); animation: fadein .18s ease; }
.modal {
    position: relative; width: min(560px, 100%); max-height: 86vh;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
    animation: modalin .2s cubic-bezier(.32,.72,0,1);
}
.modal.lg { width: min(880px, 100%); }
@keyframes modalin { from { transform: scale(.97) translateY(8px); opacity: 0; } }
.modal-head { padding: 18px 20px 12px; }
.modal-head h2 { font-size: 16px; }
.modal-head p { font-size: 13px; color: var(--muted-fg); margin-top: 4px; }
.modal-body { padding: 4px 20px 18px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--subtle); border-radius: 0 0 var(--r-xl) var(--r-xl); }

/* ── Command palette ──────────────────────────────────────────────────────── */
.palette-root { position: fixed; inset: 0; z-index: 160; display: grid; place-items: start center; padding: 12vh 16px 16px; }
.palette-scrim { position: absolute; inset: 0; background: rgb(0 0 0 / .5); animation: fadein .15s ease; }
.palette {
    position: relative; width: min(620px, 100%);
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg); overflow: hidden; animation: modalin .18s cubic-bezier(.32,.72,0,1);
}
.palette-input { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.palette-input .i { color: var(--muted-fg); } .palette-input .i svg { width: 17px; height: 17px; }
.palette-input input { border: none; background: none; height: auto; padding: 0; font-size: 14.5px; }
.palette-input input:focus { outline: none; box-shadow: none; }
.palette-list { max-height: min(420px, 52vh); overflow-y: auto; padding: 6px; }
.palette-group { font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted-fg); padding: 10px 10px 5px; }
.palette-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border-radius: var(--r-sm); font-size: 13.5px; text-align: left;
}
.palette-item svg { width: 15px; height: 15px; color: var(--muted-fg); flex: none; }
.palette-item .pi-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .pi-meta { font-size: 11.5px; color: var(--muted-fg); flex: none; }
.palette-item.on { background: var(--muted); }
.palette-item.on svg { color: var(--fg); }
.palette-foot { display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--border); background: var(--subtle); font-size: 11.5px; color: var(--muted-fg); }
.palette-foot kbd { margin-right: 3px; }
.palette-empty { padding: 30px; text-align: center; color: var(--muted-fg); font-size: 13px; }

/* ── Toasts ───────────────────────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: grid; gap: 8px; justify-items: end; pointer-events: none; }
.toast {
    display: flex; align-items: flex-start; gap: 10px; pointer-events: auto;
    min-width: 260px; max-width: 380px; padding: 12px 14px;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg); animation: toastin .22s cubic-bezier(.32,.72,0,1);
}
.toast.out { animation: toastout .18s ease forwards; }
@keyframes toastin { from { transform: translateY(10px) scale(.97); opacity: 0; } }
@keyframes toastout { to { transform: translateX(12px); opacity: 0; } }
.toast .ti { flex: none; margin-top: 1px; } .toast .ti svg { width: 16px; height: 16px; }
.toast.ok .ti { color: var(--ok); } .toast.bad .ti { color: var(--bad); }
.toast.warn .ti { color: var(--warn); } .toast.info .ti { color: var(--info); }
.toast .tt { font-size: 13px; font-weight: 500; }
.toast .td { font-size: 12.5px; color: var(--muted-fg); margin-top: 2px; }
.toast .tx { margin-left: auto; color: var(--muted-fg); }

/* ── Line-item editor (keyboard-first data entry) ─────────────────────────── */
.lines { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.lines table { font-size: 13px; }
.lines thead th { background: var(--subtle); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-fg); font-weight: 500; padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.lines tbody td { padding: 5px 6px; border-bottom: 1px solid var(--border); }
.lines tbody tr:last-child td { border-bottom: none; }
.lines input, .lines select { height: 30px; border-color: transparent; background: transparent; }
.lines input:hover, .lines select:hover { border-color: var(--border); }
.lines input:focus, .lines select:focus { background: var(--input); border-color: var(--ring); }
.lines .line-total { font-variant-numeric: tabular-nums; text-align: right; padding-right: 12px; white-space: nowrap; }
.lines tfoot td { background: var(--subtle); padding: 8px 10px; border-top: 1px solid var(--border); }
.line-add { display: flex; gap: 8px; align-items: center; padding: 8px; background: var(--subtle); border-top: 1px solid var(--border); }
.kbd-hint { font-size: 11.5px; color: var(--muted-fg); display: flex; gap: 6px; align-items: center; }

/* ── Supply map ───────────────────────────────────────────────────────────── */
.map-shell {
    position: relative; border: 1px solid var(--border); border-radius: var(--r-lg);
    background:
        radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0) 0 0 / 22px 22px,
        var(--subtle);
    overflow: hidden; height: calc(100vh - var(--topbar-h) - 132px); min-height: 480px;
}
.map-canvas { width: 100%; height: 100%; cursor: grab; touch-action: none; }
.map-canvas.dragging { cursor: grabbing; }
.map-overlay { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; flex-wrap: wrap; z-index: 2; }
.map-controls { position: absolute; bottom: 12px; right: 12px; display: grid; gap: 6px; z-index: 2; }
.map-controls .icon-btn { background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow); }
.map-legend {
    position: absolute; bottom: 12px; left: 12px; z-index: 2;
    background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(6px);
    border: 1px solid var(--border); border-radius: var(--r); padding: 9px 11px;
    display: grid; gap: 5px; font-size: 11.5px; color: var(--muted-fg); box-shadow: var(--shadow);
}
.map-legend .lg-row { display: flex; align-items: center; gap: 7px; }
.map-legend .lg-line { width: 20px; height: 0; border-top: 2px solid var(--muted-fg); }
.map-legend .lg-line.flow { border-top-style: dashed; border-color: var(--brand); }
.map-legend .lg-line.late { border-color: var(--bad); }

.node-card { cursor: pointer; }
.node-card .nc-bg { fill: var(--card); stroke: var(--border); stroke-width: 1; }
.node-card:hover .nc-bg { stroke: var(--border-strong); }
.node-card.selected .nc-bg { stroke: var(--brand); stroke-width: 2; }
.node-card .nc-title { fill: var(--fg); font-size: 12.5px; font-weight: 600; }
.node-card .nc-sub { fill: var(--muted-fg); font-size: 10.5px; }
.node-card .nc-stat { fill: var(--fg); font-size: 12px; font-weight: 600; }
.node-card .nc-statlbl { fill: var(--muted-fg); font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase; }
.node-card .nc-icon { fill: none; stroke: var(--muted-fg); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.node-card .nc-ring-ok { fill: var(--ok); } .node-card .nc-ring-warn { fill: var(--warn); }
.node-card .nc-ring-bad { fill: var(--bad); } .node-card .nc-ring-idle { fill: var(--muted-fg); opacity: .4; }
.node-card.dim { opacity: .32; }

.map-edge { fill: none; stroke: var(--border-strong); stroke-width: 1.5; transition: stroke .2s; }
.map-edge.flowing { stroke: var(--brand); stroke-dasharray: 7 6; animation: dash 1.1s linear infinite; }
.map-edge.late { stroke: var(--bad); }
.map-edge.hot { stroke-width: 3; }
.map-edge.dim { opacity: .18; }
.map-edge-hit { fill: none; stroke: transparent; stroke-width: 16px; cursor: pointer; }
.map-edge-label { fill: var(--muted-fg); font-size: 10px; font-variant-numeric: tabular-nums; }
.map-edge-label-bg { fill: var(--subtle); stroke: var(--border); }
@keyframes dash { to { stroke-dashoffset: -26; } }
.map-col-label { fill: var(--muted-fg); font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
    .map-edge.flowing { animation: none; }
    .boot-bar span, .boot-mark, .skel::after { animation: none; }
    * { scroll-behavior: auto !important; }
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.muted { color: var(--muted-fg); }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.text-ok { color: var(--ok); } .text-bad { color: var(--bad); }
.text-warn { color: var(--warn); } .text-brand { color: var(--brand); }
.strong { font-weight: 600; }
.xs { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt { margin-top: 12px; } .mt-lg { margin-top: 22px; } .mb { margin-bottom: 12px; }
.hr { height: 1px; background: var(--border); margin: 16px 0; border: 0; }

.banner {
    display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px;
    border: 1px solid var(--border); background: var(--muted); border-radius: var(--r);
    font-size: 12.5px; color: var(--muted-fg);
}
.banner svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.banner.info { background: var(--info-soft); border-color: var(--info-border); color: var(--info); }
.banner.warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }
.banner.bad  { background: var(--bad-soft);  border-color: var(--bad-border);  color: var(--bad); }
.banner strong { color: inherit; }
.banner .banner-actions { margin-left: auto; display: flex; gap: 6px; }

.progress { height: 5px; border-radius: 99px; background: var(--muted); overflow: hidden; min-width: 60px; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.progress.ok > span { background: var(--ok); }

.avatar {
    width: 26px; height: 26px; border-radius: 99px; flex: none;
    display: grid; place-items: center; font-size: 10.5px; font-weight: 600;
    background: var(--brand-soft); color: var(--brand); border: 1px solid var(--brand-border);
}
.avatar.lg { width: 34px; height: 34px; font-size: 12.5px; }

.timeline { display: grid; gap: 0; }
.tl-item { display: grid; grid-template-columns: 22px 1fr; gap: 10px; }
.tl-rail { display: grid; justify-items: center; }
.tl-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--border-strong); margin-top: 6px; flex: none; }
.tl-dot.on { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tl-line { width: 1px; flex: 1; background: var(--border); min-height: 14px; }
.tl-body { padding-bottom: 14px; }
.tl-body .t { font-size: 13px; font-weight: 500; }
.tl-body .d { font-size: 12px; color: var(--muted-fg); }

/* Simple bar/spark charts */
.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 27%) 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-track { height: 8px; background: var(--muted); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 99px; }
.bar-row .bv { font-variant-numeric: tabular-nums; color: var(--muted-fg); white-space: nowrap; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
    .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .g-2-1, .g-1-2, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 110;
        transform: translateX(-100%); transition: transform .24s cubic-bezier(.32,.72,0,1);
        box-shadow: var(--shadow-lg);
    }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 100; background: rgb(0 0 0 / .45); }
    .icon-btn.sidebar-open, .icon-btn.sidebar-close { display: grid; }
    .btn.topbar-search { display: inline-flex; }
    .page { padding: 16px 14px 60px; }
    .g2, .g4 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .map-shell { height: calc(100vh - var(--topbar-h) - 180px); }
    .role-switch { display: none; }
}
@media (max-width: 560px) {
    .hide-sm { display: none; }
    .page-head .actions { width: 100%; }
    .sheet-head { padding: 14px; } .sheet-body { padding: 14px; }
}

/* Printing a document sheet should look like a document */
@media print {
    .sidebar, .topbar, .toasts, .sheet-foot, .palette-root { display: none !important; }
    .sheet-root { position: static; } .sheet-scrim { display: none; }
    .sheet { position: static; width: auto; border: none; box-shadow: none; animation: none; }
}
