/* ============================================================================
   sctools — "Hangar Telemetry" design system
   Dark, technical, schematic. Amber = powered/active, teal = stock/links,
   violet = UNKNOWN (never reads as empty or ok). Corner-tick framing evokes
   targeting reticles and engineering drawings.
   ========================================================================== */

:root {
    --bg:          #0b0f14;
    --bg-grid:     rgba(120, 150, 170, 0.035);
    --surface:     #121820;
    --surface-2:   #172029;
    --surface-3:   #1e2833;
    --line:        #263542;
    --line-bright: #3a4a58;

    --ink:         #dfe7ee;
    --ink-dim:     #93a3b1;
    --ink-faint:   #61707d;

    --accent:      #ffb23f;   /* amber — primary action, "powered" */
    --accent-ink:  #1a1206;
    --accent-cool: #47d3c4;   /* teal — links, stock markers */

    --ok:      #58d18b;
    --warn:    #ffce5b;
    --danger:  #ff6f6f;
    --unknown: #a48cff;       /* violet — UNKNOWN, deliberately not ok/empty */
    --modified:#ffb23f;
    --empty:   #6b7a88;

    --radius:   3px;
    --radius-lg:5px;
    --tick:     10px;         /* corner-tick length */

    --font-display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
    --font-body:    "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    --font-mono:    "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

    --shadow:  0 1px 0 rgba(255,255,255,0.02), 0 8px 24px -12px rgba(0,0,0,0.6);
    --maxw:    1680px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background:
        linear-gradient(var(--bg-grid) 1px, transparent 1px) 0 0 / 100% 34px,
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px) 0 0 / 34px 100%,
        radial-gradient(1200px 600px at 78% -10%, rgba(255, 178, 63, 0.06), transparent 60%),
        var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.15;
    margin: 0 0 .5em;
}
h1 { font-size: clamp(1.6rem, 1.1rem + 1.6vw, 2.4rem); font-weight: 700; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }

a { color: var(--accent-cool); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

p { margin: 0 0 1em; }
::selection { background: rgba(255, 178, 63, 0.28); }

.mono { font-family: var(--font-mono); }
.dim  { color: var(--ink-dim); }
.faint{ color: var(--ink-faint); }
.nowrap { white-space: nowrap; }

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

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(16px, 3vw, 40px); }
.wrap--wide { max-width: 1880px; }

.site-header {
    position: sticky; top: 0; z-index: 40;
    background: rgba(11, 15, 20, 0.86);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.site-header__inner {
    display: flex; align-items: center; gap: 28px;
    height: 58px;
}
.brand {
    display: flex; align-items: baseline; gap: 8px;
    font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
    color: var(--ink); text-transform: uppercase; letter-spacing: 0.14em;
}
.brand:hover { text-decoration: none; }
.brand b { color: var(--accent); }
.brand::before {
    content: ""; width: 10px; height: 10px; align-self: center;
    background: var(--accent);
    clip-path: polygon(0 0, 100% 0, 100% 70%, 70% 100%, 0 100%);
}
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a {
    color: var(--ink-dim); font-family: var(--font-display); font-size: .82rem;
    text-transform: uppercase; letter-spacing: 0.1em;
    padding: 8px 14px; border-radius: var(--radius);
}
.nav a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.nav a.is-active { color: var(--accent); }
.patch-chip {
    font-family: var(--font-mono); font-size: .72rem; color: var(--ink-dim);
    border: 1px solid var(--line); padding: 3px 8px; border-radius: 999px;
}
.patch-chip b { color: var(--accent-cool); font-weight: 500; }

main { padding: clamp(24px, 4vw, 52px) 0 80px; }

.site-footer {
    border-top: 1px solid var(--line); padding: 28px 0 44px;
    color: var(--ink-faint); font-size: .82rem;
}
.site-footer a { color: var(--ink-dim); }

/* ---- panels with corner ticks ----------------------------------------- */

.panel {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.panel--pad { padding: 20px 22px; }
.panel__tick, .panel::before, .panel::after {
    position: absolute; width: var(--tick); height: var(--tick);
    border-color: var(--line-bright); pointer-events: none;
}
.panel::before {
    content: ""; top: -1px; left: -1px;
    border-top: 2px solid; border-left: 2px solid;
}
.panel::after {
    content: ""; bottom: -1px; right: -1px;
    border-bottom: 2px solid; border-right: 2px solid;
}

.eyebrow {
    font-family: var(--font-display); text-transform: uppercase;
    letter-spacing: 0.16em; font-size: .72rem; font-weight: 600;
    color: var(--ink-faint);
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px;
}
.eyebrow::after { content: ""; flex: 1; height: 1px; background: var(--line); }

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

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: var(--font-display); font-weight: 600; font-size: .82rem;
    text-transform: uppercase; letter-spacing: 0.08em;
    padding: 9px 16px; border-radius: var(--radius);
    border: 1px solid var(--line-bright); background: var(--surface-2);
    color: var(--ink); cursor: pointer;
    transition: border-color .12s, background .12s, transform .06s;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary {
    background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.btn--primary:hover { background: #ffc063; }
.btn--ghost { background: transparent; }
.btn--sm { padding: 6px 10px; font-size: .74rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---- status badges (never colour alone) ---------------------------- */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-family: var(--font-mono); font-size: .68rem; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 2px 7px; border-radius: 999px;
    border: 1px solid currentColor;
}
.badge::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.badge--stock    { color: var(--accent-cool); }
.badge--stock::before { border-radius: 999px; }
.badge--modified { color: var(--modified); }
.badge--modified::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); background: none; border: 4px solid currentColor; border-top: 0; }
.badge--empty    { color: var(--empty); }
.badge--empty::before { background: none; border: 1px solid currentColor; }
.badge--unknown  { color: var(--unknown); }
.badge--unknown::before { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }

.size-badge {
    font-family: var(--font-mono); font-size: .68rem; font-weight: 600;
    color: var(--ink-dim); border: 1px solid var(--line-bright);
    padding: 1px 5px; border-radius: 2px; white-space: nowrap;
}
.grade-badge {
    font-family: var(--font-mono); font-size: .68rem; font-weight: 700;
    padding: 1px 5px; border-radius: 2px; border: 1px solid var(--line-bright);
    color: var(--ink);
}
.grade-A { border-color: #4a8; color: #7ed6b0; }
.grade-B { border-color: #58a; color: #8fc0e6; }
.grade-C { border-color: #a86; color: #e0b78c; }
.grade-D { border-color: #a55; color: #e69090; }

/* ---- data tables -------------------------------------------------- */

.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th {
    text-align: left; font-family: var(--font-display); font-weight: 600;
    font-size: .72rem; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--ink-faint); padding: 10px 12px;
    border-bottom: 1px solid var(--line-bright); position: sticky; top: 58px;
    background: var(--bg);
}
.data-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table td.num, .data-table th.num { text-align: right; font-family: var(--font-mono); }
.data-table a { color: var(--ink); font-weight: 500; }
.data-table a:hover { color: var(--accent-cool); }
.u { color: var(--ink-faint); font-size: .82em; margin-left: 2px; }
.unknown-dash {
    color: var(--unknown); font-family: var(--font-mono); font-size: .74rem;
    border-bottom: 1px dotted var(--unknown); cursor: help;
}

/* ---- filter bar -------------------------------------------------- */

.filters {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
    padding: 14px 16px; margin-bottom: 18px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
    font-family: var(--font-display); font-size: .68rem; text-transform: uppercase;
    letter-spacing: 0.1em; color: var(--ink-faint);
}
.field input, .field select {
    background: var(--bg); border: 1px solid var(--line-bright); color: var(--ink);
    font: inherit; font-size: .86rem; padding: 7px 9px; border-radius: var(--radius);
    min-width: 150px;
}
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; }
.field--grow { flex: 1; min-width: 200px; }
.field--grow input { width: 100%; }

.result-meta { color: var(--ink-dim); font-size: .84rem; margin: 0 4px 12px; font-family: var(--font-mono); }

/* ---- pagination ------------------------------------------------- */
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 24px; }
.pager a, .pager span {
    font-family: var(--font-mono); font-size: .82rem; padding: 6px 11px;
    border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink-dim);
}
.pager a:hover { border-color: var(--accent); color: var(--ink); text-decoration: none; }
.pager .is-current { background: var(--surface-3); color: var(--accent); border-color: var(--line-bright); }

/* ---- home ------------------------------------------------------ */

.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: center; margin-bottom: 56px; }
.hero__title { text-wrap: balance; }
.hero__title b { color: var(--accent); }
.hero__lede { font-size: 1.08rem; color: var(--ink-dim); max-width: 46ch; }
.hero__cta { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.hero__stats { display: flex; gap: 28px; margin-top: 30px; }
.hero__stat .n { font-family: var(--font-mono); font-size: 1.7rem; color: var(--ink); display: block; }
.hero__stat .l { font-size: .74rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); }

.hero__panel { padding: 4px; }
.hero__panel img { width: 100%; display: block; border-radius: 2px; filter: saturate(0.9) contrast(1.05); }
.schematic-frame { position: relative; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.ship-card {
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    transition: border-color .14s, transform .1s;
}
.ship-card:hover { border-color: var(--line-bright); transform: translateY(-2px); text-decoration: none; }
.ship-card__img { aspect-ratio: 16/9; background: var(--surface-3) center/cover; }
.ship-card__body { padding: 12px 14px; }
.ship-card__name { font-family: var(--font-display); font-weight: 600; color: var(--ink); }
.ship-card__meta { font-size: .74rem; color: var(--ink-faint); font-family: var(--font-mono); margin-top: 3px; }
.ship-card__bar { height: 3px; background: var(--surface-3); margin-top: 10px; }
.ship-card__bar i { display: block; height: 100%; background: var(--accent-cool); }

/* ---- ship detail --------------------------------------------- */

.ship-hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 36px; margin-bottom: 34px; }
.ship-hero__img { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ship-hero__img img { width: 100%; display: block; }
.ship-hero__meta { display: flex; align-items: center; gap: 10px; color: var(--ink-dim); font-family: var(--font-mono); font-size: .82rem; margin-bottom: 6px; }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.spec {
    background: var(--surface); padding: 12px 14px;
}
.spec dt { font-size: .68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); font-family: var(--font-display); }
.spec dd { margin: 3px 0 0; font-family: var(--font-mono); font-size: 1.02rem; color: var(--ink); }

.hardpoint-tree { font-family: var(--font-mono); font-size: .84rem; }
.hp-node { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: baseline; }
.hp-node__key { color: var(--ink-dim); min-width: 220px; }
.hp-node__fitting { color: var(--ink); }
.hp-children { margin-left: 22px; border-left: 1px solid var(--line); padding-left: 14px; }

/* ---- provenance popover ------------------------------------- */
.prov { border-bottom: 1px dotted var(--ink-faint); cursor: help; }
details.prov-box { margin-top: 20px; font-size: .84rem; }
details.prov-box summary { cursor: pointer; color: var(--ink-dim); font-family: var(--font-display); text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; }
.prov-table td { padding: 4px 10px; border-bottom: 1px solid var(--line); font-family: var(--font-mono); font-size: .8rem; }


/* ============================================================================
   FITTING CONSOLE — ship deck, system modules, interactive slot cards,
   docked inspector rail, telemetry, identical-slot stacks, comparison picker.
   A dense engineering workstation, not a stacked form.
   ========================================================================== */

/* ---- ship deck ----------------------------------------------------------- */

.deck {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr) minmax(230px, auto);
    gap: 0;
    background: linear-gradient(105deg, var(--surface-2), var(--surface) 58%);
    border: 1px solid var(--line-bright);
    border-radius: var(--radius-lg);
    margin-bottom: 14px;
    overflow: hidden;
    position: relative;
}
.deck::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    border: 1px solid rgba(255, 178, 63, .07);
}
.deck:not(:has(.deck__img)) { grid-template-columns: minmax(0, 1fr) minmax(230px, auto); }

.deck__img { display: block; background: var(--surface-3); border-right: 1px solid var(--line); }
.deck__img img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(.9) contrast(1.05); }

.deck__id { padding: 16px 20px; min-width: 0; }
.deck__crumb { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: .76rem; color: var(--ink-dim); margin: 0 0 6px; }
.deck__crumb .dot { color: var(--ink-faint); }
.deck__namerow { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.deck__namerow h1 { margin: 0; font-size: clamp(1.5rem, 1.1rem + 1.3vw, 2rem); }
.ship-switch {
    font-family: var(--font-display); font-size: .68rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .08em;
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--surface-3); border: 1px solid var(--line-bright); color: var(--ink-dim);
    padding: 4px 10px; border-radius: 999px; cursor: pointer;
}
.ship-switch:hover { border-color: var(--accent); color: var(--accent); }

.deck__tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 9px 0 10px; }
.deck__specs { display: flex; flex-wrap: wrap; gap: 2px 0; margin: 0; }
.deck__specs > div { padding: 2px 14px 2px 0; margin-right: 14px; border-right: 1px solid var(--line); }
.deck__specs > div:last-child { border-right: 0; }
.deck__specs dt { font-size: .6rem; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-faint); font-family: var(--font-display); }
.deck__specs dd { margin: 1px 0 0; font-family: var(--font-mono); font-size: .9rem; color: var(--ink); }

.deck__ops {
    display: grid; align-content: space-between; gap: 12px;
    padding: 16px 20px; border-left: 1px solid var(--line); background: rgba(0,0,0,.12);
}
.deck__actions { display: grid; grid-template-columns: auto 1fr 1fr; gap: 6px; }
.deck__actions .btn { justify-content: center; }
.deck__modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mode-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    font-family: var(--font-display); font-size: .64rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em;
    background: var(--surface-2); border: 1px solid var(--line-bright); color: var(--ink-dim);
    padding: 5px 8px; border-radius: var(--radius); cursor: pointer;
}
.mode-toggle__dot { width: 7px; height: 7px; border-radius: 2px; border: 1px solid currentColor; }
.mode-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: rgba(255,178,63,.08); }
.mode-toggle[aria-pressed="true"] .mode-toggle__dot { background: currentColor; }

.fit-health { display: flex; gap: 11px; align-items: center; }
.fit-health__ring-wrap { position: relative; width: 52px; height: 52px; flex: 0 0 52px; }
.fit-health__ring { width: 52px; height: 52px; transform: rotate(-90deg); }
.fit-health__track { fill: none; stroke: var(--surface-3); stroke-width: 3.2; }
.fit-health__fill { fill: none; stroke-width: 3.2; stroke-linecap: round; transition: stroke-dasharray .5s ease; }
.fit-health--ok  .fit-health__fill { stroke: var(--ok); }
.fit-health--warn .fit-health__fill { stroke: var(--warn); }
.fit-health--low .fit-health__fill { stroke: var(--unknown); }
.fit-health__pct {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-weight: 600; font-size: .84rem; color: var(--ink); pointer-events: none;
}
.fit-health__pct small { font-size: .56rem; color: var(--ink-dim); }
.fit-health__label { font-family: var(--font-mono); font-size: .68rem; color: var(--ink-dim); line-height: 1.45; }
.fit-health__label b { color: var(--ink); }
.fit-health__label .is-unknown b { color: var(--unknown); }

/* ---- ship jump dialog -------------------------------------------------- */

dialog.ship-jump {
    width: min(520px, 94vw); max-height: 74vh; padding: 0; margin-top: 8vh;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line-bright); border-radius: var(--radius-lg);
    box-shadow: 0 24px 80px -20px rgba(0,0,0,.75);
}
dialog.ship-jump::backdrop { background: rgba(4,7,10,.66); backdrop-filter: blur(2px); }
.ship-jump__head { display: flex; padding: 12px 14px; border-bottom: 1px solid var(--line); gap: 8px; }
.ship-jump__head input { flex: 1; background: var(--bg); border: 1px solid var(--line-bright); color: var(--ink); font: inherit; padding: 8px 12px; border-radius: var(--radius); }
.ship-jump__head input:focus { border-color: var(--accent); outline: none; }
.ship-jump__list { overflow-y: auto; max-height: 60vh; padding: 4px; }
.ship-jump__row {
    display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left;
    background: transparent; border: 0; border-radius: var(--radius); color: var(--ink);
    font: inherit; padding: 8px 10px; cursor: pointer;
}
.ship-jump__row:hover, .ship-jump__row.is-active { background: var(--surface-2); }
.ship-jump__row[aria-current="true"] { color: var(--accent); }
.ship-jump__row .nm { font-weight: 600; }
.ship-jump__row .mf { font-family: var(--font-mono); font-size: .74rem; color: var(--ink-faint); margin-left: auto; }

/* ---- change ribbon --------------------------------------------------- */

#ribbon-mount:empty, #ribbon-mount:has(.ribbon.is-stock) { display: none; }
#ribbon-mount { margin-bottom: 12px; }
.ribbon {
    position: sticky; top: 58px; z-index: 25;
    background: var(--surface-2); border: 1px solid var(--line-bright);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.ribbon.is-stock { display: none; }
.ribbon__bar { display: flex; align-items: center; gap: 16px; padding: 8px 14px; flex-wrap: wrap; }
.ribbon__toggle {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: var(--font-display); font-weight: 600; font-size: .76rem;
    text-transform: uppercase; letter-spacing: .06em;
    background: transparent; border: 0; color: var(--ink); cursor: pointer; padding: 0;
}
.ribbon__count { font-family: var(--font-mono); background: var(--accent); color: var(--accent-ink); padding: 1px 8px; border-radius: 999px; font-size: .8rem; }
.ribbon__chev { transition: transform .16s; color: var(--ink-dim); }
.ribbon__toggle[aria-expanded="true"] .ribbon__chev { transform: rotate(180deg); }
.ribbon__metrics { display: flex; gap: 4px 16px; flex-wrap: wrap; flex: 1; }
.ribbon__metric { display: inline-flex; align-items: baseline; gap: 6px; font-family: var(--font-mono); font-size: .82rem; }
.ribbon__metric .k { color: var(--ink-dim); font-size: .66rem; text-transform: uppercase; letter-spacing: .04em; }
.ribbon__metric .d { font-weight: 600; }
.ribbon__metric.is-up .d { color: var(--ok); }
.ribbon__metric.is-down .d { color: var(--danger); }
.ribbon__spend { display: flex; align-items: baseline; gap: 10px; margin-left: auto; font-family: var(--font-mono); font-size: .82rem; }
.ribbon__spend-v { color: var(--ink); font-weight: 600; }
.ribbon__spend-v .u { color: var(--ink-faint); font-size: .82em; }
.ribbon__detail { border-top: 1px solid var(--line); padding: 6px; display: grid; gap: 3px; max-height: 44vh; overflow-y: auto; }
.ribbon__item {
    display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
    background: transparent; border: 0; border-left: 3px solid var(--line-bright);
    color: var(--ink); font: inherit; padding: 6px 10px; cursor: pointer; border-radius: 2px;
}
.ribbon__item:hover { background: var(--surface-3); }
.ribbon__item-slot { font-family: var(--font-display); font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-dim); min-width: 150px; }
.ribbon__item-swap { font-family: var(--font-mono); font-size: .8rem; }
.ribbon__item-swap .from { color: var(--ink-faint); text-decoration: line-through; }
.ribbon__item-swap .arr { color: var(--accent); margin: 0 5px; }
.hs-offense { --dc: #ff8f6b; } .hs-defense { --dc: var(--accent-cool); }
.hs-power { --dc: #ffd25b; } .hs-cooling { --dc: #7fc7ff; } .hs-quantum { --dc: #a48cff; } .hs-other { --dc: var(--ink-dim); }
.ribbon__item-slot[class*="hs-"] { color: var(--dc); }

/* ---- console grid -------------------------------------------------- */

.console {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(320px, 23vw, 384px);
    gap: 18px;
    align-items: start;
}

/* ---- workbench: an auto-packing board of system modules. A masonry-style
   grid so short systems sit side by side and fill the row; a system with many
   cards is promoted to full width (`.sys--wide`, decided server-side from card
   count so it never flips during candidate preview) and lays its own cards out
   in a grid, staying short instead of growing into one tall narrow ribbon. --- */

.workbench {
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
    grid-auto-flow: row dense;
    align-items: start;
    gap: 12px;
}
.workbench > .notice { grid-column: 1 / -1; }

.sys {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.sys--wide { grid-column: 1 / -1; }
.sys--wide > .sys__body > .slot-grid {
    grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
}

.sys__head {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 12px; border-bottom: 1px solid var(--line);
    background: linear-gradient(var(--surface-2), var(--surface));
}
.sys__toggle {
    display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0;
    background: transparent; border: 0; color: var(--ink); cursor: pointer; padding: 0; font: inherit;
}
.sys__icon { color: var(--accent); flex: 0 0 auto; }
.sys__label { font-family: var(--font-display); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys__count {
    font-family: var(--font-mono); font-size: .7rem; color: var(--ink-dim);
    background: var(--surface-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px;
}
.sys__mod {
    font-family: var(--font-mono); font-size: .66rem; color: var(--accent-ink);
    background: var(--modified); border-radius: 999px; padding: 1px 7px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
}
.sys__chev { color: var(--ink-dim); margin-left: auto; transition: transform .16s; flex: 0 0 auto; }
.sys.is-collapsed .sys__chev { transform: rotate(-90deg); }
.sys__restore {
    font-family: var(--font-display); font-size: .64rem; text-transform: uppercase; letter-spacing: .06em;
    background: transparent; border: 1px solid var(--line-bright); color: var(--ink-dim);
    border-radius: var(--radius); padding: 4px 8px; cursor: pointer; flex: 0 0 auto;
}
.sys__restore:hover { border-color: var(--accent); color: var(--accent); }
.sys__body { padding: 10px; }
.sys.is-collapsed .sys__body { display: none; }

.slot-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; align-items: start; }

/* ---- slot card -------------------------------------------------- */

.slot {
    position: relative; display: grid; gap: 3px; min-width: 0;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px 11px 8px 13px;
    cursor: pointer;
    transition: border-color .12s, background .12s, box-shadow .12s, padding-right .12s;
}
/* make room for the quick-action rail so it never covers meter read-outs */
.slot:hover, .slot:focus-within, .slot.is-selected { padding-right: 74px; }
.slot--compact:hover, .slot--compact:focus-within, .slot--compact.is-selected { padding-right: 11px; }
.slot:hover { border-color: var(--line-bright); background: var(--surface-3); }
.slot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.slot.is-selected { border-color: var(--accent); background: var(--surface-3); box-shadow: 0 0 0 1px var(--accent) inset; }
.slot.is-kin { border-color: var(--accent-cool); border-style: dashed; }

/* the card is the control — a quick-action rail slides over the right edge
   on hover / focus / selection so the resting card stays clean */
.slot__quick {
    position: absolute; top: 0; right: 0; bottom: 0; width: 66px;
    display: grid; grid-template-columns: 24px 24px; gap: 4px; place-content: center;
    border-left: 1px solid var(--line); border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--surface-3);
    opacity: 0; transition: opacity .1s; z-index: 3; pointer-events: none;
}
.slot:hover .slot__quick, .slot:focus-within .slot__quick, .slot.is-selected .slot__quick {
    opacity: 1; pointer-events: auto;
}
.slot__quick button, .slot__quick a {
    display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
    background: var(--surface); border: 1px solid var(--line-bright); border-radius: var(--radius);
    color: var(--ink-dim); cursor: pointer; font-size: .82rem; line-height: 1; text-decoration: none;
}
.slot__quick button:hover, .slot__quick a:hover { border-color: var(--accent); color: var(--accent); background: var(--surface-3); }
.slot__quick button[data-action="clear-slot"]:hover { border-color: var(--danger); color: var(--danger); }
.slot__accent { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: var(--radius) 0 0 var(--radius); background: var(--line-bright); }
.slot.st-stock    .slot__accent { background: var(--accent-cool); }
.slot.st-modified .slot__accent { background: var(--modified); box-shadow: 0 0 9px -1px var(--modified); }
.slot.st-empty    .slot__accent { background: var(--empty); }
.slot.st-unknown  .slot__accent { background: repeating-linear-gradient(180deg, var(--unknown) 0 4px, transparent 4px 8px); }
.slot.st-modified { background: linear-gradient(105deg, rgba(255,178,63,.10), var(--surface-2) 52%); }
.slot.st-unknown  { background: linear-gradient(105deg, rgba(164,140,255,.11), var(--surface-2) 52%); }

.slot__top { display: flex; align-items: center; gap: 6px; }
.slot__size {
    font-family: var(--font-mono); font-weight: 700; font-size: .72rem; color: var(--ink-dim);
    border: 1px solid var(--line-bright); border-radius: 2px; padding: 0 5px; line-height: 1.55;
}
.slot__type { font-family: var(--font-display); font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot__grade { font-family: var(--font-mono); font-size: .64rem; font-weight: 700; padding: 0 4px; border-radius: 2px; border: 1px solid var(--line-bright); }
.slot__label { font-family: var(--font-mono); font-size: .66rem; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot__body { display: grid; gap: 1px; }
.slot__name { font-weight: 600; color: var(--ink); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.slot__name.is-empty { color: var(--empty); font-style: italic; font-weight: 400; }
.slot__name.is-unknown { color: var(--unknown); }
.slot__mfr { font-family: var(--font-mono); font-size: .68rem; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.st-unknown .slot__mfr { color: var(--unknown); opacity: .85; white-space: normal; line-height: 1.35; }
.slot__stats { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-dim); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 0 12px; }
.slot__stats b { color: var(--ink); font-weight: 600; }

/* ---- reactive card instruments ------------------------------------------
   Stable DOM so JS can retarget --w / text and CSS animates the change.
   Teal = fitted value · amber = live candidate preview · red = worse-critical */
.slot__inst { display: grid; gap: 4px; margin-top: 6px; }
/* strict grid: fixed label | flexible track | fixed value — every row aligns */
.mtr {
    display: grid; grid-template-columns: 44px minmax(0, 1fr) 52px;
    align-items: center; column-gap: 8px; font-family: var(--font-mono);
}
.mtr__k { font-size: .6rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); }
.mtr__v { font-size: .76rem; color: var(--ink); font-weight: 600; text-align: right; transition: color .2s; }
.mtr__v b { font-weight: 600; }
.slot.is-previewing .mtr.is-up .mtr__v { color: var(--ok); }
.slot.is-previewing .mtr.is-down .mtr__v { color: var(--danger); }
.mtr__bar { position: relative; height: 4px; background: var(--surface-3); border-radius: 2px; }
.mtr__bar > i {
    display: block; height: 100%; border-radius: 2px; background: var(--accent-cool);
    transition: width .4s cubic-bezier(.2,.8,.2,1), background-color .2s;
}
/* factory-reference marker — distinct from the fill: taller, ink-dim, notched both sides */
.mtr__bar.has-notch::after {
    content: ""; position: absolute; top: -3px; bottom: -3px; left: var(--notch, 0%);
    width: 2px; margin-left: -1px; background: var(--ink-dim); border-radius: 1px;
}
.slot.is-changed .mtr__bar > i { background: var(--modified); }
.slot.is-previewing .mtr__bar > i { background: var(--accent); }

/* power-plant segment strip — 1 segment = 1 unit of generated power */
.slot__pp { margin-top: 6px; }
.slot__pp-n { font-family: var(--font-mono); font-size: .74rem; color: var(--ink-dim); }
.slot__pp-n b { color: var(--ink); font-weight: 700; font-size: .9rem; }
.slot__pp-n span { font-size: .6rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.pp-strip { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 4px; }
.pp-strip > i {
    width: 6px; height: 11px; border-radius: 1px; background: var(--accent-cool);
    transition: background-color .2s, opacity .2s;
}
.slot.is-changed .pp-strip > i { background: var(--modified); }
.slot.is-previewing .pp-strip > i { background: var(--accent); }
.pp-strip > i.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line-bright); }

/* cooler ring */
.slot__ring { display: flex; align-items: center; gap: 9px; margin-top: 6px; }
.slot__ring svg { width: 42px; height: 42px; flex: 0 0 42px; transform: rotate(-90deg); }
.slot__ring .ring-trk { fill: none; stroke: var(--surface-3); stroke-width: 4; }
.slot__ring .ring-fil {
    fill: none; stroke: var(--accent-cool); stroke-width: 4; stroke-linecap: round;
    stroke-dasharray: 100.5; stroke-dashoffset: calc(100.5 - 100.5 * var(--p, 0) / 100);
    transition: stroke-dashoffset .45s cubic-bezier(.2,.8,.2,1), stroke .2s;
}
.slot.is-changed .slot__ring .ring-fil { stroke: var(--modified); }
.slot.is-previewing .slot__ring .ring-fil { stroke: var(--accent); }
.slot__ring-v { font-family: var(--font-mono); display: grid; }
.slot__ring-v b { color: var(--ink); font-weight: 700; font-size: 1rem; line-height: 1; }
.slot__ring-v span { font-size: .58rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }

.slot.is-previewing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.slot__cand-tag {
    position: absolute; left: 13px; bottom: -8px; z-index: 4;
    font-family: var(--font-display); font-size: .56rem; text-transform: uppercase; letter-spacing: .06em;
    background: var(--accent); color: var(--accent-ink); padding: 1px 6px; border-radius: 999px; font-weight: 700;
}

/* rack ordnance load-out strip */
.rack__ord { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); }
.rack__ord-dots { display: flex; gap: 2px; flex-wrap: wrap; }
.rack__ord-dots > i { width: 5px; height: 8px; border-radius: 1px; box-shadow: inset 0 0 0 1px var(--line-bright); }
.rack__ord-dots > i.on { background: var(--accent-cool); box-shadow: none; }
.rack__ord-n { font-size: .68rem; color: var(--ink-faint); }
.rack__ord-n b { color: var(--ink); }

.slot--compact { padding: 6px 9px 6px 11px; background: var(--surface); }
.slot--compact .slot__label, .slot--compact .slot__type { display: none; }
.slot--compact .slot__name { font-size: .8rem; }

.rack { display: grid; gap: 6px; align-content: start; min-width: 0; }
.rack__payload-toggle {
    justify-self: start; font-family: var(--font-mono); font-size: .7rem; color: var(--ink-dim);
    background: transparent; border: 1px dashed var(--line-bright); border-radius: var(--radius); padding: 3px 9px; cursor: pointer;
}
.rack__payload-toggle:hover { border-color: var(--accent); color: var(--accent); }
.rack__payload { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; padding: 4px 0 4px 12px; border-left: 1px dashed var(--line-bright); }

/* ---- identical-slot stack --------------------------------------- */

.slot-stack { min-width: 0; }
.slot-stack__summary {
    position: relative; display: grid; gap: 3px; min-width: 0;
    background: var(--surface-2); border: 1px solid var(--line-bright); border-radius: var(--radius);
    padding: 9px 12px 9px 14px;
}
.slot-stack__summary .slot__accent { background: var(--accent-cool); }
.slot-stack__summary.st-unknown .slot__accent { background: repeating-linear-gradient(180deg, var(--unknown) 0 4px, transparent 4px 8px); }
.slot-stack__summary.st-empty .slot__accent { background: var(--empty); }
.slot-stack__summary.st-modified .slot__accent { background: var(--modified); box-shadow: 0 0 9px -1px var(--modified); }
.slot-stack__summary.st-modified { background: linear-gradient(105deg, rgba(255,178,63,.10), var(--surface-2) 52%); }
.slot-stack__combined { color: var(--accent-cool); }
.slot-stack__combined b { color: var(--accent-cool); }
.slot-stack__head { display: flex; align-items: center; gap: 7px; }
.slot-stack__x { font-family: var(--font-mono); font-weight: 700; color: var(--accent); }
.slot-stack__name { font-weight: 600; font-size: .92rem; }
.slot-stack__actions { display: flex; gap: 6px; margin-top: 6px; }
.slot-stack .slot__stats { display: flex; flex-wrap: wrap; gap: 0 12px; font-family: var(--font-mono); font-size: .72rem; color: var(--ink-dim); }
.slot-stack .slot__stats b { color: var(--ink); }

/* ---- rail: docked inspector + telemetry + shopping ------------- */

.rail {
    position: sticky; top: 66px;
    display: grid; gap: 12px; align-content: start;
    max-height: calc(100vh - 78px); overflow-y: auto; scrollbar-width: thin;
    padding-right: 2px;
}

.rail__inspector { }
.insp {
    background: var(--surface); border: 1px solid var(--line-bright); border-radius: var(--radius);
    padding: 12px 14px;
}
.insp:not(.insp--overview) { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(255,178,63,.25); }
.insp__head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.insp__badge { }
.insp__slot { font-family: var(--font-display); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); flex: 1; min-width: 0; }
.insp--overview .insp__slot { color: var(--ink-faint); }
.insp__close {
    background: transparent; border: 1px solid var(--line-bright); color: var(--ink-dim);
    width: 22px; height: 22px; border-radius: var(--radius); cursor: pointer; font-size: .7rem; line-height: 1;
}
.insp__close:hover { border-color: var(--danger); color: var(--danger); }

.insp__cols { display: grid; gap: 10px; }
.ic {
    display: grid; gap: 2px; padding-left: 10px; border-left: 2px solid var(--line-bright);
}
.ic--stock { border-left-color: var(--accent-cool); }
.ic__label { font-family: var(--font-display); font-size: .6rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.ic__name { font-weight: 600; color: var(--ink); font-size: .9rem; }
.ic__name.is-empty { color: var(--empty); font-style: italic; font-weight: 400; }
.ic__name.is-unknown { color: var(--unknown); }
.ic__sub { font-family: var(--font-mono); font-size: .7rem; color: var(--ink-faint); }
.ic__stats { display: flex; flex-wrap: wrap; gap: 1px 12px; font-family: var(--font-mono); font-size: .76rem; color: var(--ink-dim); margin-top: 2px; }
.ic__stats b { color: var(--ink); }

.insp__preview {
    margin-top: 10px; padding: 9px 11px; background: var(--surface-3);
    border: 1px solid var(--accent); border-radius: var(--radius);
}
.insp__preview .ic__label { color: var(--accent); }
.insp__delta { display: flex; flex-wrap: wrap; gap: 1px 12px; font-family: var(--font-mono); font-size: .76rem; margin-top: 3px; }
.insp__delta .up { color: var(--ok); } .insp__delta .down { color: var(--danger); }
.insp__cost { font-family: var(--font-mono); font-size: .74rem; color: var(--ink-dim); margin-top: 4px; display: block; }
.insp__cost b { color: var(--ink); }
.insp__global { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line-bright); }
.insp__global .ic__label { color: var(--ink-faint); }
.insp__global .insp__delta i { font-style: normal; color: var(--ink-faint); }

.insp__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }

.insp-ov { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.insp-ov__stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.insp-ov__n { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 600; color: var(--ink); display: block; line-height: 1.1; }
.insp-ov__n small { font-size: .8rem; color: var(--ink-faint); }
.insp-ov__l { font-size: .64rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); font-family: var(--font-display); }
.insp-ov__note { font-size: .74rem; color: var(--ink-dim); line-height: 1.5; margin: 8px 0; display: flex; gap: 6px; align-items: flex-start; }
.insp-ov__note .badge { flex: 0 0 auto; margin-top: 1px; }
.insp-ov__hint { font-size: .76rem; color: var(--ink-faint); margin: 8px 0 10px; }

/* ---- telemetry stat blocks --------------------------------- */

.rail__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-block[data-domain="power"], .stat-block[data-domain="quantum"] { grid-column: 1 / -1; }

.side-card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 11px 13px;
}
.side-card h3 {
    margin: 0 0 6px; font-size: .68rem; text-transform: uppercase;
    letter-spacing: .1em; color: var(--ink-faint); font-family: var(--font-display);
}
.stat-block__hero { display: flex; align-items: baseline; gap: 6px; margin-bottom: 7px; }
.stat-block__n { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 600; color: var(--ink); line-height: 1; transition: color .25s; }
.stat-block__n.is-partial { color: var(--unknown); }
.stat-block__n i { color: var(--unknown); font-style: normal; font-size: .5em; margin-left: 2px; }
.stat-block__u { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); font-family: var(--font-display); }

/* ---- instrument gauges: value read-out over a scaled fill bar ---------- */
.gauge { margin: 6px 0 0; font-family: var(--font-mono); }
.gauge__row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.gauge__k { color: var(--ink-dim); font-size: .72rem; }
.gauge__v { color: var(--ink); font-size: .84rem; font-weight: 600; text-align: right; }
.gauge__v i { color: var(--ink-faint); font-style: normal; font-size: .78em; font-weight: 400; }
.gauge__d { margin-left: 5px; font-size: .72em; font-weight: 700; }
.gauge__d.up { color: var(--ok); } .gauge__d.down { color: var(--danger); }
.gauge__track {
    position: relative; height: 4px; margin-top: 3px;
    background: var(--surface-3); border-radius: 2px; overflow: hidden;
}
.gauge__track > i {
    display: block; height: 100%; width: var(--fill, 0%); border-radius: 2px;
    background: var(--accent-cool);
    transition: width .42s cubic-bezier(.2, .8, .2, 1), background-color .25s;
}
.gauge.tone-warn .gauge__track > i { background: var(--warn); }
.gauge.tone-cool .gauge__track > i { background: #7fc7ff; }
.gauge__track.has-notch { overflow: visible; }
.gauge__track.has-notch::after {
    content: ""; position: absolute; top: -2px; bottom: -2px; left: var(--notch, 0%);
    width: 1px; background: var(--ink-dim); opacity: .8;
}

/* ---- power management: interactive ship power console ----------------
   Discrete vertical segment stacks are the centrepiece. 1 segment ≈ 1 raw
   power unit (a "pip"); a subsystem column is exactly as tall as its fitted
   parts' combined full draw. Filled = allocated now, hollow = a slot this
   subsystem could still take, absent = no such slot. AUTO computes the
   distribution; MANUAL makes the segments clickable. See power.js. */
.powercore.is-deficit { border-color: var(--danger); }

.pcore__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 9px; }
.pcore__pool { font-family: var(--font-mono); display: flex; flex-direction: column; gap: 2px; }
.pcore__pool b { font-size: 1.5rem; font-weight: 700; color: var(--accent-cool); line-height: 1; transition: color .2s; }
.pcore__pool.is-deficit b { color: var(--danger); }
.pcore__pool span { font-size: .62rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); }
.pcore__pool .q { color: var(--unknown); font-style: normal; }

/* AUTO|MANUAL and SCM|NAV segmented toggles */
.pm__modes { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.pm__seg-toggle { display: inline-flex; border: 1px solid var(--line-bright); border-radius: 5px; overflow: hidden; }
.pm__seg-toggle button {
    font-family: var(--font-mono); font-size: .6rem; font-weight: 700; letter-spacing: .05em;
    padding: 3px 9px; background: var(--surface-2); color: var(--ink-faint); border: 0; cursor: pointer;
    transition: background .15s, color .15s;
}
.pm__seg-toggle button + button { border-left: 1px solid var(--line-bright); }
.pm__seg-toggle button:hover { color: var(--ink); }
.pm__seg-toggle button.is-active { background: var(--accent); color: #05080b; }

/* horizontal status bar (cooling capacity) */
.pstat { display: grid; grid-template-columns: 52px minmax(0,1fr) 46px; align-items: center; column-gap: 8px; margin: 7px 0; font-family: var(--font-mono); }
.pstat__k { font-size: .6rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.pstat__bar { height: 5px; background: var(--surface-3); border-radius: 3px; }
.pstat__bar > i { display: block; height: 100%; border-radius: 3px; background: #7fc7ff; transition: width .4s cubic-bezier(.2,.8,.2,1); }
.pstat__v { font-size: .76rem; color: var(--ink); font-weight: 600; text-align: right; }

/* distribution — the centrepiece */
.pcore__dist {
    display: flex; gap: 4px; align-items: flex-end; justify-content: space-between;
    padding: 12px 2px 8px; margin: 6px -3px 2px;
    border-top: 1px solid var(--line-bright); border-bottom: 1px solid var(--line-bright);
}
.psys { display: grid; justify-items: center; gap: 5px; flex: 1; min-width: 0; }
.psys__n {
    font-family: var(--font-mono); font-size: 1.05rem; font-weight: 700; color: var(--ink); line-height: 1;
    transition: color .2s;
}
.psys__max { font-size: .62rem; font-weight: 600; color: var(--ink-faint); }
.psys--free .psys__n, .psys--parked .psys__n { color: var(--ink-dim); }
.psys--deficit .psys__n { color: var(--danger); }
.psys.is-brown .psys__n { color: var(--danger); }
.psys--parked { opacity: .55; }
.psys--parked .psys__l::after { content: " · off"; color: var(--ink-faint); }
.psys__stack {
    display: flex; flex-flow: column-reverse wrap-reverse; align-content: flex-start; justify-content: flex-start;
    gap: 3px; min-height: 62px; max-height: 120px; direction: rtl; border-radius: 2px;
}
.psys__stack > i {
    width: 15px; height: 8px; border-radius: 1px;
    background: transparent; box-shadow: inset 0 0 0 1px var(--line-bright);
    animation: segIn .3s ease backwards;
}
.psys__stack > i.is-on { background: var(--accent); box-shadow: 0 0 5px -1px var(--accent); }
.psys__stack > i.is-minmark { box-shadow: inset 0 0 0 1px var(--warn); }
.psys__stack > i.is-on.is-minmark { box-shadow: 0 0 5px -1px var(--accent), inset 0 0 0 1px var(--warn); }
.psys__stack > i.is-void { visibility: hidden; }
.psys--free .psys__stack > i.is-on { background: var(--ink-dim); box-shadow: none; }
.psys--deficit .psys__stack > i.is-on { background: var(--danger); box-shadow: 0 0 5px -1px var(--danger); }
.psys.is-brown .psys__stack > i.is-on { background: var(--danger); box-shadow: 0 0 5px -1px var(--danger); }
@keyframes segIn { from { opacity: 0; transform: scaleY(.25); } }

/* MANUAL: segments and nudge buttons become interactive */
.pm--manual .psys.is-editable .psys__stack { cursor: pointer; box-shadow: inset 0 0 0 1px var(--line); }
.pm--manual .psys.is-editable .psys__stack:hover { box-shadow: inset 0 0 0 1px var(--accent-cool); }
.pm--manual .psys.is-editable .psys__stack:focus-visible { outline: 2px solid var(--accent-cool); outline-offset: 2px; }
.psys__pm { display: inline-flex; gap: 3px; }
.psys__pm button {
    font-family: var(--font-mono); font-size: .7rem; line-height: 1; width: 16px; height: 16px;
    border: 1px solid var(--line-bright); border-radius: 3px; background: var(--surface-2);
    color: var(--ink-dim); cursor: pointer;
}
.psys__pm button:hover { color: var(--ink); border-color: var(--accent-cool); }

.psys__i { color: var(--ink-dim); margin-top: 2px; }
.psys--deficit .psys__i, .psys.is-brown .psys__i { color: var(--danger); }
.psys__l { font-family: var(--font-display); font-size: .56rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); white-space: nowrap; }
#rail-stats.is-previewing .psys--used .psys__stack > i.is-on { background: var(--warn); box-shadow: 0 0 5px -1px var(--warn); }

.pcore__legend {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2px 8px;
    margin-top: 8px; font-family: var(--font-mono); font-size: .72rem; color: var(--ink-dim);
}
.pcore__legend b { color: var(--ink); }
.pcore__legend .q { color: var(--unknown); font-style: normal; }
.pcore__legend .is-neg b { color: var(--danger); }
.pcore__legend .is-pos b { color: var(--ok); }
.pm__note { margin: 7px 0 0; font-size: .72rem; color: var(--warn); font-family: var(--font-mono); }

@media (prefers-reduced-motion: reduce) {
    .psys__stack > i { animation: none; }
    .pstat__bar > i { transition: none; }
}

.qdrive { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-family: var(--font-mono); font-size: .8rem; }
.qdrive__k { color: var(--ink-dim); font-size: .72rem; }
.qdrive__v { color: var(--ink); font-weight: 600; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qdrive__v.is-partial { color: var(--unknown); }

.stat-note { font-size: .72rem; color: var(--ink-dim); line-height: 1.45; margin: 6px 0 2px; display: flex; gap: 5px; align-items: flex-start; }
.stat-note.is-warn { color: var(--danger); }
.stat-note .badge { flex: 0 0 auto; }

.stat-block.flash { animation: flash .48s ease; }
@keyframes flash { from { background: rgba(255,178,63,.16); } }

.srow { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); font-family: var(--font-mono); font-size: .8rem; }
.srow:last-child { border-bottom: 0; }
.srow__k { color: var(--ink-dim); font-size: .74rem; }
.srow__v { color: var(--ink); font-size: .88rem; font-weight: 500; text-align: right; }
.srow__v i { color: var(--ink-faint); font-style: normal; font-size: .8em; }
.srow__v.is-partial { color: var(--unknown); }

/* ---- preview mode: widgets show the candidate build, not the fitted one ---- */
#rail-stats.is-previewing .stat-block { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(255,178,63,.22); }
#rail-stats.is-previewing .gauge__track > i { background: var(--accent); }
.rail__preview-tag {
    display: flex; align-items: center; gap: 7px; margin: 8px 0 0; padding: 6px 10px;
    background: rgba(255,178,63,.12); border: 1px solid var(--accent); border-radius: var(--radius);
    font-family: var(--font-display); font-size: .64rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent);
}
.rail__preview-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---- full shopping + route ------------------------------- */

.shop-full { margin-top: 16px; }
.shop-table { margin-top: 4px; }
.shop-table tfoot th { border-top: 1px solid var(--line-bright); color: var(--ink); font-family: var(--font-mono); }
.shop-row--unavailable td { opacity: .7; }
.route-line { display: grid; gap: 8px; margin-top: 8px; }
.route-stop { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); }
.route-stop__head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.route-stop__n { font-family: var(--font-mono); background: var(--surface-3); border: 1px solid var(--line-bright); color: var(--accent); font-weight: 700; border-radius: 3px; padding: 0 6px; }
.route-stop__leg { font-family: var(--font-mono); font-size: .74rem; color: var(--ink-faint); }
.route-stop ul { margin: 6px 0 0; padding-left: 16px; font-size: .82rem; color: var(--ink-dim); }

/* ---- comparison picker ----------------------------------- */

/* right-side docked drawer: aligns with the workbench, stable width, full
   viewport height, header + footer fixed while the candidate list scrolls */
dialog.picker {
    position: fixed;
    inset: 0 0 0 auto;
    width: clamp(400px, 33vw, 620px);
    height: auto; max-height: none;
    margin: 0; padding: 0;
    background: var(--surface); color: var(--ink);
    border: 0; border-left: 1px solid var(--line-bright); border-radius: 0;
    box-shadow: -30px 0 90px -24px rgba(0,0,0,.75);
    --pcols: minmax(150px, 1.5fr) 40px 90px minmax(110px, 1fr);
}
dialog.picker[open] { display: flex; flex-direction: column; }
dialog.picker::backdrop { background: rgba(4, 7, 10, 0.32); }

/* while the drawer is open the page reflows into the space to its left — it
   uses the full viewport width up to the panel, so the workbench just gets
   narrower and nothing is hidden behind or stranded beside the panel */
@media (min-width: 1201px) {
    body:has(dialog.picker[open]) main > .wrap {
        max-width: none;
        padding-right: calc(clamp(400px, 33vw, 620px) + clamp(16px, 3vw, 40px));
    }
}
@media (max-width: 1200px) {
    dialog.picker { inset: 0; width: 100%; border-left: 0; }
    dialog.picker::backdrop { background: rgba(4, 7, 10, 0.72); backdrop-filter: blur(3px); }
}
.picker__head { padding: 13px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; }
.picker__head-main { min-width: 0; flex: 1; }
.picker__head h2 { margin: 0; font-size: 1rem; }
.picker__sub { font-size: .72rem; color: var(--ink-faint); font-family: var(--font-mono); margin: 2px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker__search { flex: 1 1 100%; order: 3; background: var(--bg); border: 1px solid var(--line-bright); color: var(--ink); font: inherit; padding: 8px 12px; border-radius: var(--radius); min-width: 120px; }
.picker__search:focus { border-color: var(--accent); outline: none; }
.picker__x { background: transparent; border: 1px solid var(--line-bright); color: var(--ink-dim); width: 28px; height: 28px; border-radius: var(--radius); cursor: pointer; flex: 0 0 auto; }
.picker__x:hover { border-color: var(--danger); color: var(--danger); }
.picker__recent { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 7px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.picker__recent-label { font-family: var(--font-display); font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.recent-chip { font-family: var(--font-mono); font-size: .72rem; padding: 3px 9px; background: var(--surface-3); border: 1px solid var(--line-bright); color: var(--ink); border-radius: 999px; cursor: pointer; }
.recent-chip:hover { border-color: var(--accent); color: var(--accent); }
.picker__filters { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 18px; border-bottom: 1px solid var(--line); }
.picker__filters button {
    font-family: var(--font-mono); font-size: .71rem; padding: 3px 9px;
    background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-dim); border-radius: 999px; cursor: pointer;
}
.picker__filters button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: rgba(255,178,63,.08); }
.picker__filters .picker__filters-group { display: flex; gap: 6px; flex-wrap: wrap; padding-right: 8px; margin-right: 2px; border-right: 1px solid var(--line); }

.picker__table { flex: 1; overflow-y: auto; min-height: 0; }
.picker__thead {
    display: grid; grid-template-columns: var(--pcols); gap: 0 12px;
    position: sticky; top: 0; z-index: 2; background: var(--bg);
    border-bottom: 1px solid var(--line-bright); padding: 7px 18px;
}
.picker__th {
    font-family: var(--font-display); font-size: .62rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-faint); background: transparent; border: 0; cursor: pointer; padding: 0;
    display: flex; align-items: center; gap: 3px; white-space: nowrap;
}
.picker__th:not(:first-child) { justify-content: flex-end; }
.picker__th:hover { color: var(--ink); }
.picker__th.is-sorted { color: var(--accent); }
.picker__th .ar { font-size: .8em; }

.picker__rows { }
.picker-row {
    display: grid; grid-template-columns: var(--pcols); gap: 0 12px; align-items: center; width: 100%;
    padding: 8px 18px; border: 0; border-bottom: 1px solid var(--line); border-left: 3px solid transparent;
    background: transparent; color: var(--ink); text-align: left; cursor: pointer; font: inherit;
}
.picker-row:hover, .picker-row.is-active { background: var(--surface-2); }
.picker-row.is-active { border-left-color: var(--accent); }
.picker-row__id { min-width: 0; display: grid; gap: 1px; }
.picker-row__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-row__name .tag-mini {
    font-family: var(--font-mono); font-size: .58rem; color: var(--ink-faint);
    border: 1px solid var(--line); border-radius: 2px; padding: 0 3px; margin-left: 6px; text-transform: uppercase;
}
.picker-row.is-stock .picker-row__name::after { content: "STOCK"; font-family: var(--font-mono); font-size: .56rem; color: var(--accent-cool); border: 1px solid currentColor; padding: 0 3px; border-radius: 2px; margin-left: 6px; }
.picker-row.is-current .picker-row__name::after { content: "FITTED"; font-family: var(--font-mono); font-size: .56rem; color: var(--accent); border: 1px solid currentColor; padding: 0 3px; border-radius: 2px; margin-left: 6px; }
.picker-row__mfr { font-size: .7rem; color: var(--ink-faint); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-row__cell { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-dim); text-align: right; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.picker-row__cell b { color: var(--ink); font-weight: 600; }
.picker-row__cell.is-sorted b { color: var(--accent); }
.picker-row__cell.dim { color: var(--ink-faint); }
.picker-row__delta-col { white-space: normal; font-size: .66rem; line-height: 1.3; color: var(--ink-faint); }
.picker-row__delta-col .up { color: var(--ok); } .picker-row__delta-col .down { color: var(--danger); }
.picker__size { justify-self: center; text-align: center; }
.picker__foot { padding: 9px 18px; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; font-size: .78rem; color: var(--ink-faint); flex-wrap: wrap; }
.picker__count { font-family: var(--font-mono); }
.picker__spacer { flex: 1; }
.picker__delta { font-family: var(--font-mono); font-size: .78rem; display: flex; gap: 10px; color: var(--ink-dim); flex-wrap: wrap; }
.picker__delta .up { color: var(--ok); } .picker__delta .down { color: var(--danger); }
.picker__global {
    font-family: var(--font-mono); font-size: .74rem; color: var(--ink-dim);
    padding-left: 12px; border-left: 1px solid var(--line-bright); flex-wrap: wrap; display: flex; gap: 2px 8px;
}
.picker__global b { color: var(--ink); }
.picker__global .up { color: var(--ok); } .picker__global .down { color: var(--danger); }

/* ---- diff / modified-only modes ------------------------------ */

.console.mode-diff .slot:not(.is-changed):not(.is-selected),
.console.mode-diff .slot-stack:not(:has(.st-modified)) { opacity: .34; filter: saturate(.4); }
.console.mode-diff .slot.is-changed,
.console.mode-diff .slot-stack:has(.st-modified) .slot-stack__summary { box-shadow: 0 0 0 1px var(--modified) inset; }
.console.mode-diff .sys[data-modified="0"] .sys__body { opacity: .4; }

.console.mode-modified .slot:not(.is-changed):not(.is-selected) { display: none; }
.console.mode-modified .slot-stack:not(:has(.st-modified)) { display: none; }
.console.mode-modified .sys[data-modified="0"] { display: none; }
.console.mode-modified .rack:not(:has(.is-changed)) { display: none; }

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

@media (max-width: 1200px) {
    .console { grid-template-columns: 1fr; }
    .workbench { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
    .rail { position: static; max-height: none; overflow: visible; }
    .rail__stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
    .stat-block[data-domain="power"], .stat-block[data-domain="quantum"] { grid-column: auto; }
    .deck { grid-template-columns: 180px minmax(0, 1fr); }
    .deck:not(:has(.deck__img)) { grid-template-columns: 1fr; }
    .deck__ops { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
    .deck__ops > * { margin: 0; }
    .deck__actions, .deck__modes { display: flex; }
    .fit-health { margin-left: auto; }
}
@media (max-width: 820px) {
    .nav { display: none; }
    .deck { grid-template-columns: 1fr; }
    .deck__img { max-height: 150px; border-right: 0; border-bottom: 1px solid var(--line); }
    .deck__actions, .deck__modes { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
    .fit-health { margin-left: 0; }
    .workbench { grid-template-columns: 1fr; }
    .sys--wide > .sys__body > .slot-grid { grid-template-columns: minmax(0, 1fr); }
    .rail__stats { grid-template-columns: 1fr 1fr; }
    .ribbon__spend { margin-left: 0; width: 100%; }
    dialog.picker { --pcols: minmax(120px, 1.6fr) 34px 76px 84px; }
    .picker-row__delta-col { display: none; }
}

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