/* ============================================================
   FiberSlice — design tokens + shell + component primitives
   Loaded by layout.html and every standalone template.
   Hue-50 (signal orange) as single brand accent. All palette
   values in OKLCH so dark/light tuning is one knob per variable.
   ============================================================ */

   :root {
    /* Surfaces — warm-tinted dark */
    --fs-surface-0: oklch(0.155 0.008 50);
    --fs-surface-1: oklch(0.195 0.010 50);
    --fs-surface-2: oklch(0.240 0.012 50);
    --fs-surface-3: oklch(0.295 0.014 50);
    --fs-surface-4: oklch(0.360 0.016 50);

    /* Borders */
    --fs-border-subtle:  oklch(0.275 0.012 50);
    --fs-border-default: oklch(0.355 0.014 50);
    --fs-border-strong:  oklch(0.455 0.016 50);

    /* Text */
    --fs-text-strong: oklch(0.965 0.005 50);
    --fs-text:        oklch(0.860 0.008 50);
    --fs-text-muted:  oklch(0.650 0.012 50);
    --fs-text-faint:  oklch(0.485 0.014 50);

    /* Brand — single warm signal orange */
    --fs-accent-h:      50;
    --fs-accent:        oklch(0.74 0.165 var(--fs-accent-h));
    --fs-accent-strong: oklch(0.80 0.175 var(--fs-accent-h));
    --fs-accent-dim:    oklch(0.62 0.14  var(--fs-accent-h));
    --fs-accent-tint:   oklch(0.74 0.165 var(--fs-accent-h) / 0.14);
    --fs-accent-ring:   oklch(0.74 0.165 var(--fs-accent-h) / 0.32);
    --fs-accent-ink:    oklch(0.16 0.02  var(--fs-accent-h));

    /* Status */
    --fs-alarm:   oklch(0.66 0.20 25);
    --fs-warning: oklch(0.80 0.16 88);
    --fs-ok:      oklch(0.70 0.14 145);
    --fs-info:    oklch(0.72 0.10 235);

    /* Tints (for pill backgrounds etc.) */
    --fs-alarm-tint:   oklch(0.66 0.20 25  / 0.14);
    --fs-warning-tint: oklch(0.80 0.16 88  / 0.14);
    --fs-ok-tint:      oklch(0.70 0.14 145 / 0.14);
    --fs-info-tint:    oklch(0.72 0.10 235 / 0.14);

    /* Type */
    --fs-font-body: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --fs-font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    /* Radii */
    --fs-radius-sm: 4px;
    --fs-radius-md: 6px;
    --fs-radius-lg: 8px;

    /* Shadows */
    --fs-shadow-sm: 0 1px 2px rgba(0,0,0,0.30);
    --fs-shadow-md: 0 6px 16px rgba(0,0,0,0.40);
    --fs-shadow-lg: 0 16px 40px rgba(0,0,0,0.55);

    /* Chrome */
    --fs-strip-h: 38px;
    --fs-rail-w:  214px;
}

/* Base ─────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body {
    font-family: var(--fs-font-body);
    background: var(--fs-surface-0);
    color: var(--fs-text);
    -webkit-font-smoothing: antialiased;
    margin: 0;
    font-size: 13px;
}

a { color: var(--fs-accent); text-decoration: none; }
a:hover { color: var(--fs-accent-strong); }

h1, h2, h3, h4 { color: var(--fs-text-strong); letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 600; }

code, kbd, pre, .mono {
    font-family: var(--fs-font-mono);
    font-feature-settings: "tnum" 1, "calt" 0;
}
hr { border: 0; border-top: 1px solid var(--fs-border-subtle); margin: 16px 0; }

/* ──────────────────────────────────────────────────────────── */
/*  APP SHELL — strip + rail + main                             */
/* ──────────────────────────────────────────────────────────── */

body.fs-shell {
    /* NB: shell pages get grid layout. Standalone pages (map, TV) bypass by not using layout.html. */
    display: grid;
    grid-template-columns: var(--fs-rail-w) 1fr;
    grid-template-rows: var(--fs-strip-h) 1fr;
    grid-template-areas: "strip strip" "rail main";
    min-height: 100vh;
    overflow: hidden;
}

/* ─── STATUS STRIP ─── */
.strip {
    grid-area: strip;
    background: var(--fs-surface-1);
    border-bottom: 1px solid var(--fs-border-subtle);
    display: flex;
    align-items: center;
    font-family: var(--fs-font-mono);
    font-size: 11px;
    color: var(--fs-text-muted);
    z-index: 5;
}
.strip .brand {
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    border-right: 1px solid var(--fs-border-subtle);
    color: var(--fs-text-strong);
    font-weight: 700;
    letter-spacing: 0.02em;
    font-family: var(--fs-font-body);
    font-size: 13px;
    text-decoration: none;
}
.strip .brand:hover { color: var(--fs-text-strong); }
.strip .brand .logo {
    width: 20px; height: 20px;
    border-radius: 3px;
    background:
        linear-gradient(90deg, transparent 45%, var(--fs-accent) 45%, var(--fs-accent) 55%, transparent 55%),
        linear-gradient(0deg, transparent 45%, var(--fs-accent) 45%, var(--fs-accent) 55%, transparent 55%),
        var(--fs-surface-3);
    position: relative;
    flex-shrink: 0;
}
.strip .brand .logo::after {
    content: ''; position: absolute; inset: 3px;
    border: 1px solid var(--fs-accent); border-radius: 1px;
}
.strip .cell {
    padding: 0 14px;
    height: 100%;
    display: flex; align-items: center; gap: 6px;
    border-right: 1px solid var(--fs-border-subtle);
    white-space: nowrap;
    background: transparent;
    border-top: none; border-bottom: none; border-left: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
}
.strip .cell.cell-btn { cursor: pointer; }
.strip .cell.cell-btn:hover { background: var(--fs-surface-2); color: var(--fs-text-strong); }
.strip .cell .lbl { color: var(--fs-text-faint); font-size: 10px; }
.strip .cell .val { color: var(--fs-text-strong); font-weight: 600; }
.strip .cell .k { margin-left: 2px; letter-spacing: 0.03em; }
.strip .cell.ok .val    { color: var(--fs-ok); }
.strip .cell.warn .val  { color: var(--fs-warning); }
.strip .cell.alarm .val { color: var(--fs-text-muted); } /* dim when zero */
.strip .cell.alarm.alarm-active .val { color: var(--fs-alarm); font-weight: 700; }
.strip .spacer { flex: 1; }
.strip .right { display: flex; height: 100%; }
.strip .right .cell:last-child { border-right: none; }

/* Pulse */
.pulse {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--fs-ok);
    box-shadow: 0 0 0 0 var(--fs-ok);
    animation: fs-pulse 2s infinite;
    flex-shrink: 0;
}
@keyframes fs-pulse {
    0%   { box-shadow: 0 0 0 0 oklch(0.70 0.14 145 / 0.5); }
    70%  { box-shadow: 0 0 0 6px oklch(0.70 0.14 145 / 0); }
    100% { box-shadow: 0 0 0 0 oklch(0.70 0.14 145 / 0); }
}
.pulse.alarm { background: var(--fs-alarm); animation: fs-pulse-alarm 1.4s infinite; }
@keyframes fs-pulse-alarm {
    0%   { box-shadow: 0 0 0 0 oklch(0.66 0.20 25 / 0.6); }
    70%  { box-shadow: 0 0 0 6px oklch(0.66 0.20 25 / 0); }
    100% { box-shadow: 0 0 0 0 oklch(0.66 0.20 25 / 0); }
}

/* ─── LEFT RAIL ─── */
.rail {
    grid-area: rail;
    background: var(--fs-surface-1);
    border-right: 1px solid var(--fs-border-subtle);
    display: flex; flex-direction: column;
    overflow-y: auto;
    min-height: 0;
}
.rail .search {
    padding: 12px 12px 8px;
    border-bottom: 1px solid var(--fs-border-subtle);
}
.rail .search .kbd-bar {
    display: flex; align-items: center; gap: 8px;
    background: var(--fs-surface-2);
    border: 1px solid var(--fs-border-subtle);
    border-radius: var(--fs-radius-sm);
    padding: 6px 8px;
    font-size: 12px;
    color: var(--fs-text-muted);
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s;
    width: 100%;
    font-family: inherit;
}
.rail .search .kbd-bar:hover { border-color: var(--fs-border-default); color: var(--fs-text); background: var(--fs-surface-2); }
.rail .search .kbd-bar .k {
    margin-left: auto;
    font-family: var(--fs-font-mono);
    font-size: 10px;
    color: var(--fs-text-faint);
    background: var(--fs-surface-0);
    border: 1px solid var(--fs-border-subtle);
    border-radius: 3px;
    padding: 1px 5px;
}
.rail nav { padding: 10px 0; flex: 1; }
.rail .group { padding: 0 12px; margin-top: 6px; }
.rail .group-label {
    font-family: var(--fs-font-mono);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fs-text-faint);
    padding: 8px 4px 4px;
}
.rail .nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 6px 8px;
    border-radius: var(--fs-radius-sm);
    color: var(--fs-text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    position: relative;
}
.rail .nav-item:hover { background: var(--fs-surface-2); color: var(--fs-text-strong); text-decoration: none; }
.rail .nav-item.active {
    background: var(--fs-accent-tint);
    color: var(--fs-accent-strong);
}
.rail .nav-item.active::before {
    content: ''; position: absolute; left: -12px; top: 4px; bottom: 4px; width: 2px;
    background: var(--fs-accent); border-radius: 0 2px 2px 0;
}
.rail .nav-item svg { flex-shrink: 0; opacity: 0.85; }
.rail .nav-item.active svg { opacity: 1; }
.rail .nav-item .count {
    margin-left: auto;
    font-family: var(--fs-font-mono);
    font-size: 10px;
    color: var(--fs-text-faint);
    min-width: 18px;
    text-align: right;
}
.rail .nav-item.alarm .count { color: var(--fs-alarm); font-weight: 700; }

.rail .rail-footer {
    padding: 12px;
    border-top: 1px solid var(--fs-border-subtle);
    display: flex; align-items: center; gap: 10px;
}
.rail .avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--fs-surface-3); color: var(--fs-text-strong);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 11px;
    font-family: var(--fs-font-mono);
    border: 1px solid var(--fs-border-default);
    flex-shrink: 0;
}
.rail .who { flex: 1; min-width: 0; }
.rail .who .name { font-size: 12px; font-weight: 600; color: var(--fs-text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail .who .role { font-size: 10px; color: var(--fs-text-faint); font-family: var(--fs-font-mono); text-transform: uppercase; }
.rail .logout-btn {
    padding: 5px; color: var(--fs-text-faint); border-radius: var(--fs-radius-sm);
    display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.rail .logout-btn:hover { color: var(--fs-alarm); background: var(--fs-surface-2); }

/* ─── MAIN ─── */
.fs-main {
    grid-area: main;
    overflow-y: auto;
    background: var(--fs-surface-0);
    min-height: 0;
}
.page { padding: 20px 28px; max-width: 1600px; }
.page.page-wide { max-width: none; }
.page.page-flush { padding: 0; }

/* Breadcrumb */
.crumb {
    display: flex; align-items: center; gap: 8px;
    font-family: var(--fs-font-mono);
    font-size: 11px;
    color: var(--fs-text-faint);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.crumb a { color: var(--fs-text-faint); }
.crumb a:hover { color: var(--fs-text); }
.crumb .sep { opacity: 0.5; }
.crumb .here { color: var(--fs-text-muted); }

/* Page head */
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 24px; margin-bottom: 20px;
}
.page-head h1 { font-size: 22px; font-weight: 700; color: var(--fs-text-strong); letter-spacing: -0.01em; }
.page-head h1 .muted { color: var(--fs-text-muted); font-weight: 400; }
.page-head .sub { font-size: 12px; color: var(--fs-text-muted); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ──────────────────────────────────────────────────────────── */
/*  COMPONENTS                                                  */
/* ──────────────────────────────────────────────────────────── */

/* Cards */
.card {
    background: var(--fs-surface-1);
    border: 1px solid var(--fs-border-subtle);
    border-radius: var(--fs-radius-md);
    padding: 16px;
    box-shadow: var(--fs-shadow-sm);
    color: var(--fs-text);
}
.card.flush { padding: 0; overflow: hidden; }
.card-hd {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.card-title {
    font-family: var(--fs-font-mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fs-text-faint);
    display: flex; align-items: center; gap: 6px;
}

/* Tables (scoped to .tbl so existing bare tables aren't disturbed) */
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th {
    text-align: left;
    padding: 8px 10px;
    font-family: var(--fs-font-mono);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fs-text-faint);
    border-bottom: 1px solid var(--fs-border-default);
    white-space: nowrap;
    background: transparent;
}
.tbl th.num, .tbl td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: var(--fs-font-mono);
}
.tbl td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--fs-border-subtle);
    color: var(--fs-text);
    vertical-align: middle;
}
.tbl tbody tr { cursor: pointer; transition: background 0.08s; }
.tbl tbody tr:hover td { background: var(--fs-surface-2); }
.tbl tbody tr.selected td { background: var(--fs-accent-tint); }
.tbl td a, .tbl td .link {
    color: var(--fs-text-strong); font-weight: 500;
    border-bottom: 1px dashed var(--fs-border-strong);
    text-decoration: none;
}
.tbl td a:hover, .tbl td .link:hover { color: var(--fs-accent); border-bottom-color: var(--fs-accent); }
.tbl .id { font-family: var(--fs-font-mono); color: var(--fs-text-muted); font-size: 11px; }

/* Legacy table (untagged <table>) — inherits old look */
table { width: 100%; border-collapse: collapse; color: var(--fs-text); }
table th {
    text-align: left; padding: 10px 8px;
    border-bottom: 1px solid var(--fs-border-default);
    font-family: var(--fs-font-mono); font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--fs-text-faint); background: transparent;
}
table td { padding: 10px 8px; border-bottom: 1px solid var(--fs-border-subtle); font-size: 13px; color: var(--fs-text); }
table tbody tr:hover td { background: var(--fs-surface-2); }

/* Pills */
.pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 1px 7px;
    font-family: var(--fs-font-mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 3px;
    background: var(--fs-surface-3);
    color: var(--fs-text);
    white-space: nowrap;
}
.pill.ok     { background: var(--fs-ok-tint);      color: var(--fs-ok); }
.pill.warn   { background: var(--fs-warning-tint); color: var(--fs-warning); }
.pill.alarm  { background: var(--fs-alarm-tint);   color: var(--fs-alarm); }
.pill.info   { background: var(--fs-info-tint);    color: var(--fs-info); }
.pill.accent { background: var(--fs-accent-tint);  color: var(--fs-accent-strong); }

/* Legacy .badge aliases pill */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--fs-radius-sm);
    font-family: var(--fs-font-mono);
    font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
    background: var(--fs-surface-3); color: var(--fs-text);
}
.badge.ok      { background: var(--fs-ok-tint);      color: var(--fs-ok); }
.badge.warning { background: var(--fs-warning-tint); color: var(--fs-warning); }
.badge.alarm   { background: var(--fs-alarm-tint);   color: var(--fs-alarm); }
.badge.info    { background: var(--fs-info-tint);    color: var(--fs-info); }
.badge.accent  { background: var(--fs-accent-tint);  color: var(--fs-accent); }

/* KPI tiles */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.kpi {
    background: var(--fs-surface-1);
    border: 1px solid var(--fs-border-subtle);
    border-radius: var(--fs-radius-md);
    padding: 14px 16px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.15s;
}
.kpi:hover { border-color: var(--fs-border-default); }
.kpi .lbl {
    font-family: var(--fs-font-mono);
    font-size: 10px;
    color: var(--fs-text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex; align-items: center; gap: 6px;
}
.kpi .val {
    font-family: var(--fs-font-mono);
    font-size: 28px;
    font-weight: 600;
    color: var(--fs-text-strong);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
}
.kpi .val .unit { font-size: 14px; color: var(--fs-text-muted); margin-left: 2px; font-weight: 400; }
.kpi .delta {
    font-family: var(--fs-font-mono);
    font-size: 11px; margin-top: 4px;
    display: flex; align-items: center; gap: 4px;
}
.kpi .delta.up   { color: var(--fs-ok); }
.kpi .delta.down { color: var(--fs-alarm); }
.kpi .delta.flat { color: var(--fs-text-muted); }
.kpi .accent-rail {
    position: absolute; top: 0; bottom: 0; left: 0; width: 2px;
    background: var(--kpi-c, var(--fs-accent));
}
.kpi .spark { margin-top: 8px; height: 28px; }
.spark-bars { display: flex; align-items: flex-end; gap: 2px; height: 100%; }
.spark-bars span { flex: 1; background: var(--fs-accent); opacity: 0.75; border-radius: 1px 1px 0 0; min-height: 2px; }

/* Fill-bar — cable / closure capacity */
.fill-bar {
    display: inline-flex; align-items: center; gap: 8px;
    min-width: 140px;
}
.fill-bar .track {
    flex: 1; height: 6px;
    background: var(--fs-surface-3);
    border-radius: 3px; overflow: hidden;
    position: relative;
}
.fill-bar .fill { height: 100%; background: var(--fs-ok); border-radius: 3px; }
.fill-bar .fill.mid { background: var(--fs-warning); }
.fill-bar .fill.hi  { background: var(--fs-alarm); }
.fill-bar .pct {
    font-family: var(--fs-font-mono);
    font-size: 11px; color: var(--fs-text-strong);
    width: 34px; text-align: right;
}

/* Tube-stack — compact TIA-598 fiber color chip */
.tube-stack {
    display: flex; gap: 1px;
    border-radius: 2px; overflow: hidden;
    width: 48px; height: 14px;
    border: 1px solid var(--fs-border-subtle);
}
.tube-stack span { flex: 1; }

/* TIA-598 fiber palette (utility classes) */
.fc-1  { background: #2563eb; } /* blå */
.fc-2  { background: #f97316; } /* oransje */
.fc-3  { background: #16a34a; } /* grønn */
.fc-4  { background: #92400e; } /* brun */
.fc-5  { background: #94a3b8; } /* grå */
.fc-6  { background: #f5f5f4; } /* hvit */
.fc-7  { background: #dc2626; } /* rød */
.fc-8  { background: #1c1917; box-shadow: inset 0 0 0 1px var(--fs-border-default); } /* sort */
.fc-9  { background: #facc15; } /* gul */
.fc-10 { background: #a21caf; } /* fiolett */
.fc-11 { background: #f472b6; } /* rosa */
.fc-12 { background: #06b6d4; } /* turkis */
.fc-dot {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    vertical-align: middle;
    border: 1px solid var(--fs-border-subtle);
}

/* Feed rows — live event log */
.feed { max-height: 360px; overflow-y: auto; }
.feed-row {
    display: grid;
    grid-template-columns: 78px 14px 1fr auto;
    gap: 10px; align-items: center;
    padding: 6px 4px;
    border-bottom: 1px solid var(--fs-border-subtle);
    font-size: 12px;
}
.feed-row:last-child { border-bottom: none; }
.feed-row .t   { font-family: var(--fs-font-mono); font-size: 10px; color: var(--fs-text-faint); }
.feed-row .d   { width: 6px; height: 6px; border-radius: 50%; margin-left: 2px; }
.feed-row.ok    .d { background: var(--fs-ok); }
.feed-row.warn  .d { background: var(--fs-warning); }
.feed-row.alarm .d { background: var(--fs-alarm); }
.feed-row.info  .d { background: var(--fs-info); }
.feed-row .m   { color: var(--fs-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-row .m b { color: var(--fs-text-strong); font-weight: 600; }
.feed-row .who { font-family: var(--fs-font-mono); font-size: 10px; color: var(--fs-text-faint); }

/* Tech / breakdown rows (progress lines) */
.tech-row { display: grid; grid-template-columns: minmax(80px, auto) 1fr 50px; align-items: center; gap: 10px; padding: 5px 0; }
.tech-row .n { font-size: 12px; color: var(--fs-text); font-weight: 500; }
.tech-row .b { height: 8px; background: var(--fs-surface-3); border-radius: 4px; overflow: hidden; }
.tech-row .b > div { height: 100%; border-radius: 4px; transition: width 0.6s cubic-bezier(0.16,1,0.3,1); background: var(--fs-accent); }
.tech-row .v { font-family: var(--fs-font-mono); font-size: 12px; text-align: right; color: var(--fs-text-strong); }

/* Dashboard grids */
.dash-grid   { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 12px; }
.dash-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
@media (max-width: 1100px) {
    .dash-grid, .dash-grid-3 { grid-template-columns: 1fr; }
}

/* Summary chip row (small KPI-ish cards in a row) */
.chip-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.chip {
    background: var(--fs-surface-1);
    border: 1px solid var(--fs-border-subtle);
    border-radius: var(--fs-radius-md);
    padding: 10px 14px; flex: 0 0 auto;
}
.chip .chip-lbl {
    font-family: var(--fs-font-mono); font-size: 10px;
    color: var(--fs-text-faint); text-transform: uppercase; letter-spacing: 0.06em;
}
.chip .chip-val {
    font-family: var(--fs-font-mono); font-size: 20px;
    color: var(--fs-text-strong); margin-top: 2px;
}
.chip.ok    .chip-val { color: var(--fs-ok); }
.chip.warn  .chip-val { color: var(--fs-warning); }
.chip.alarm .chip-val { color: var(--fs-alarm); }

/* Forms */
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=search], input[type=tel],
input[type=url], input[type=date], input[type=datetime-local],
select, textarea {
    background: var(--fs-surface-2);
    color: var(--fs-text-strong);
    border: 1px solid var(--fs-border-default);
    border-radius: var(--fs-radius-sm);
    padding: 8px 12px;
    font-family: var(--fs-font-body);
    font-size: 13px;
    outline: none;
    transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--fs-accent);
    box-shadow: 0 0 0 3px var(--fs-accent-ring);
}
input::placeholder, textarea::placeholder { color: var(--fs-text-faint); }
label { font-size: 12px; color: var(--fs-text-muted); font-weight: 500; }

/* Buttons */
button, .btn {
    background: var(--fs-surface-2);
    color: var(--fs-text-strong);
    border: 1px solid var(--fs-border-default);
    border-radius: var(--fs-radius-sm);
    padding: 6px 12px;
    font-family: var(--fs-font-body);
    font-size: 12px; font-weight: 500;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
    text-decoration: none;
}
button:hover, .btn:hover {
    background: var(--fs-surface-3);
    border-color: var(--fs-border-strong);
    color: var(--fs-text-strong);
    text-decoration: none;
}
button.primary, .btn.primary {
    background: var(--fs-accent);
    color: var(--fs-accent-ink);
    border-color: var(--fs-accent);
    font-weight: 600;
}
button.primary:hover, .btn.primary:hover {
    background: var(--fs-accent-strong);
    border-color: var(--fs-accent-strong);
    color: var(--fs-accent-ink);
}
button.ghost, .btn.ghost {
    background: transparent;
    border-color: var(--fs-border-subtle);
    color: var(--fs-text-muted);
}
button.ghost:hover, .btn.ghost:hover {
    background: var(--fs-surface-2);
    color: var(--fs-text-strong);
    border-color: var(--fs-border-default);
}
button.sm, .btn.sm { padding: 4px 8px; font-size: 11px; }
button.icon, .btn.icon { padding: 5px; }
button:disabled, .btn:disabled { opacity: 0.4; cursor: not-allowed; }
.link { color: var(--fs-accent); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; color: var(--fs-accent-strong); }

/* Dialog */
.dlg-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.60);
    backdrop-filter: blur(2px);
    z-index: 10000;
    display: flex; align-items: center; justify-content: center;
}
.dlg-box {
    background: var(--fs-surface-1);
    border: 1px solid var(--fs-border-default);
    border-radius: var(--fs-radius-md);
    width: 460px; max-width: 92vw;
    box-shadow: var(--fs-shadow-lg);
    overflow: hidden;
    color: var(--fs-text);
}
.dlg-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--fs-border-subtle);
    background: var(--fs-surface-2);
    font-weight: 600; font-size: 14px;
    color: var(--fs-text-strong);
}
.dlg-body { padding: 16px 20px; }
.dlg-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--fs-border-subtle);
    background: var(--fs-surface-2);
    display: flex; justify-content: flex-end; gap: 8px;
}
.dlg-row  { margin-bottom: 12px; }
.dlg-row label { display: block; margin-bottom: 4px; }
.dlg-row input, .dlg-row select { width: 100%; box-sizing: border-box; }
.dlg-row2 { display: flex; gap: 12px; margin-bottom: 12px; }
.dlg-row2 > div { flex: 1; }

/* ─── COMMAND PALETTE ─── */
.cmdk-bg {
    position: fixed; inset: 0;
    background: oklch(0.10 0.01 50 / 0.65);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 15vh;
}
.cmdk-bg[hidden] { display: none !important; }
.cmdk {
    width: 580px; max-width: 92vw;
    background: var(--fs-surface-1);
    border: 1px solid var(--fs-border-default);
    border-radius: var(--fs-radius-lg);
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
    overflow: hidden;
}
.cmdk .q {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--fs-border-subtle);
    color: var(--fs-text-muted);
}
.cmdk .q input {
    flex: 1; background: transparent; border: none; outline: none;
    color: var(--fs-text-strong);
    font-family: var(--fs-font-body); font-size: 15px;
    padding: 0;
}
.cmdk .q input::placeholder { color: var(--fs-text-faint); }
.cmdk .q .esc {
    font-family: var(--fs-font-mono); font-size: 10px; color: var(--fs-text-faint);
    border: 1px solid var(--fs-border-default); padding: 2px 6px; border-radius: 3px;
}
.cmdk .list { max-height: 380px; overflow-y: auto; padding: 6px; }
.cmdk .sec {
    font-family: var(--fs-font-mono); font-size: 9px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--fs-text-faint); padding: 8px 10px 4px;
}
.cmdk .it {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--fs-radius-sm);
    font-size: 13px; color: var(--fs-text);
    cursor: pointer; text-decoration: none;
}
.cmdk .it:hover, .cmdk .it.on {
    background: var(--fs-accent-tint);
    color: var(--fs-accent-strong);
    text-decoration: none;
}
.cmdk .it .kk {
    margin-left: auto;
    font-family: var(--fs-font-mono); font-size: 10px;
    color: var(--fs-text-faint);
}

/* Expired session overlay */
.fs-expired {
    position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.fs-expired-box {
    background: var(--fs-surface-1);
    border: 1px solid var(--fs-alarm);
    border-radius: var(--fs-radius-lg);
    padding: 40px 56px; text-align: center;
    box-shadow: var(--fs-shadow-lg);
}
.fs-expired-icon { font-size: 40px; margin-bottom: 14px; }
.fs-expired-title { color: var(--fs-alarm); font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.fs-expired-sub { color: var(--fs-text-muted); font-size: 13px; margin-bottom: 22px; }

/* Focus, scrollbars, motion */
:focus-visible {
    outline: 2px solid var(--fs-accent);
    outline-offset: 1px;
    border-radius: var(--fs-radius-sm);
}
*::-webkit-scrollbar        { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb  { background: var(--fs-border-default); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--fs-border-strong); }
*::-webkit-scrollbar-track  { background: transparent; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Utility helpers */
.mono         { font-family: var(--fs-font-mono); font-variant-numeric: tabular-nums; }
.text-muted   { color: var(--fs-text-muted); }
.text-faint   { color: var(--fs-text-faint); }
.text-strong  { color: var(--fs-text-strong); }
.text-accent  { color: var(--fs-accent); }
.text-alarm   { color: var(--fs-alarm); }
.text-warning { color: var(--fs-warning); }
.text-ok      { color: var(--fs-ok); }
.text-info    { color: var(--fs-info); }
.bg-surface-1 { background: var(--fs-surface-1); }
.bg-surface-2 { background: var(--fs-surface-2); }
.bg-surface-3 { background: var(--fs-surface-3); }

/* Fiber swatch (single dot) */
.fiber-color {
    display: inline-block;
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 1px solid var(--fs-border-default);
    vertical-align: middle;
}

/* Responsive rail collapse (tablet) */
@media (max-width: 900px) {
    :root { --fs-rail-w: 56px; }
    .rail .search, .rail .group-label, .rail .nav-item span:not(.count), .rail .who { display: none; }
    .rail .nav-item { justify-content: center; }
    .rail .nav-item .count { position: absolute; top: 2px; right: 2px; background: var(--fs-alarm); color: white; border-radius: 8px; padding: 0 4px; min-width: 14px; font-size: 9px; }
    .rail .rail-footer { justify-content: center; }
    .rail .rail-footer .logout-btn { display: none; }
    .strip .cell:nth-child(n+3):not(:last-child):not(:nth-last-child(2)):not(:nth-last-child(3)) { display: none; }
}