@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 400 800; font-stretch: 62% 125%; font-display: swap; src: url(fonts/archivo-latin.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/jbmono-latin.woff2) format('woff2'); }
:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.8125rem);
  --text-sm: clamp(0.8125rem, 0.78rem + 0.2vw, 0.9375rem);
  --text-base: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
  --text-lg: clamp(1.0625rem, 1rem + 0.4vw, 1.25rem);
  --text-xl: clamp(1.375rem, 1.2rem + 0.8vw, 1.875rem);

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;

  --bg: #121417;
  --surface: #1a1d21;
  --surface-2: #22262b;
  --surface-3: #2b3036;
  --line: #31363d;
  --line-2: #40464e;
  --text: #e9e6df;
  --muted: #a3a59f;
  --faint: #757a80;

  --accent: #e9e6df;      /* reflective white — primary controls */
  --accent-ink: #121417;

  --ok: #56c487;
  --ok-bg: rgba(86, 196, 135, 0.13);
  --warn: #f0b43c;
  --warn-bg: rgba(240, 180, 60, 0.14);
  --over: #f2604f;
  --over-bg: rgba(242, 96, 79, 0.15);
  --info: #7fb2e6;

  --radius: 6px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Archivo', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: var(--text-base); line-height: 1.45;
  font-variation-settings: 'wdth' 100;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: var(--s3) var(--s6);
  background: rgba(18, 20, 23, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: var(--s3); min-width: 0; }
.brand-name {
  font-size: var(--text-lg); font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase;
  font-variation-settings: 'wdth' 75;
}
.brand-sub { color: var(--muted); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-status {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-2);
  font-weight: 700; font-size: var(--text-sm); letter-spacing: 0.06em; text-transform: uppercase;
  white-space: nowrap;
}
.top-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.top-status.ok { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.top-status.ok .dot { background: var(--ok); }
.top-status.warn { border-color: var(--warn); color: var(--warn); background: var(--warn-bg); }
.top-status.warn .dot { background: var(--warn); }
.top-status.over { border-color: var(--over); color: var(--over); background: var(--over-bg); }
.top-status.over .dot { background: var(--over); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); min-height: calc(100vh - 57px); }
.sidebar {
  border-right: 1px solid var(--line); background: var(--surface);
  padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3);
  position: sticky; top: 57px; height: calc(100vh - 57px); overflow-y: auto;
}
.main { padding: var(--s5) var(--s6) var(--s8); display: flex; flex-direction: column; gap: var(--s5); min-width: 0; }

/* ---------- Panels / fields ---------- */
.panel { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3) var(--s4); }
.panel-h {
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  cursor: default; list-style: none; display: flex; align-items: center; justify-content: space-between;
}
details > summary.panel-h { cursor: pointer; }
details > summary.panel-h::-webkit-details-marker { display: none; }
details > summary.panel-h::after { content: '+'; font-family: var(--mono); font-size: var(--text-sm); color: var(--faint); }
details[open] > summary.panel-h::after { content: '−'; }
details[open] > summary.panel-h { margin-bottom: var(--s3); }
section.panel .panel-h { margin-bottom: var(--s3); }

.fields { display: flex; flex-direction: column; gap: var(--s3); }
.f { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); font-size: var(--text-sm); }
.f > span:first-child { min-width: 0; }
.f em { display: block; font-style: normal; color: var(--faint); font-size: var(--text-xs); }
.f b { font-family: var(--mono); font-weight: 500; color: var(--text); float: right; font-size: var(--text-xs); }
.f-slider { flex-direction: column; align-items: stretch; gap: 6px; }
.f-slider > span:first-child { display: block; }
.f-check { justify-content: flex-start; align-items: flex-start; }
.f-check input { margin-top: 3px; accent-color: var(--warn); }
.fuel-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }

.in { display: inline-flex; align-items: center; background: var(--bg); border: 1px solid var(--line-2); border-radius: 4px; flex-shrink: 0; }
.in:focus-within { border-color: var(--text); }
.in input { width: 84px; padding: 6px 8px; background: transparent; border: 0; outline: 0; text-align: right; font-family: var(--mono); font-size: var(--text-sm); }
.in i { font-style: normal; color: var(--faint); font-size: var(--text-xs); padding-right: 8px; font-family: var(--mono); }
.fuel-row .in input { width: 56px; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; background: var(--line-2); border-radius: 2px; }
input[type=range]::-moz-range-track { height: 4px; background: var(--line-2); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--line-2); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
input[type=range]:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border: 1px solid var(--line-2); border-radius: 5px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 8px 4px; border-radius: 3px; cursor: pointer; font-size: var(--text-sm); font-weight: 600; color: var(--muted); }
.seg button:hover { color: var(--text); background: var(--surface-3); }
.seg button[aria-checked=true] { background: var(--accent); color: var(--accent-ink); }
.hint { margin: var(--s2) 0 0; font-size: var(--text-xs); color: var(--muted); line-height: 1.5; }
.disclaimer { font-size: var(--text-xs); color: var(--faint); margin: var(--s2) 2px 0; line-height: 1.5; }

.gauge { position: relative; height: 10px; border-radius: 5px; background: var(--bg); border: 1px solid var(--line-2); overflow: hidden; margin: -2px 0 10px; }
.gauge-fill { height: 100%; background: linear-gradient(90deg, var(--over), var(--warn) 25%, var(--ok) 55%); transition: width .2s; }
.gauge-e, .gauge-f { position: absolute; top: 12px; font-size: 10px; font-family: var(--mono); color: var(--faint); }
.gauge { overflow: visible; }
.gauge-e { left: 0; } .gauge-f { right: 0; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s3); }
.mcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s3) var(--s4) var(--s4); position: relative; overflow: hidden;
  border-top: 3px solid var(--line-2);
}
.mcard.ok { border-top-color: var(--ok); }
.mcard.warn { border-top-color: var(--warn); }
.mcard.over { border-top-color: var(--over); background: linear-gradient(180deg, var(--over-bg), var(--surface) 60%); }
.mcard .m-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); white-space: nowrap; }
.mcard .m-label > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.mcard .m-tag { font-family: var(--mono); letter-spacing: 0; text-transform: none; font-weight: 500; }
.mcard.ok .m-tag { color: var(--ok); } .mcard.warn .m-tag { color: var(--warn); } .mcard.over .m-tag { color: var(--over); }
.mcard .m-val { font-family: var(--mono); font-size: var(--text-xl); font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; line-height: 1.15; }
.mcard .m-val small { font-size: var(--text-xs); color: var(--faint); font-weight: 400; margin-left: 3px; }
.mcard .bar { height: 6px; background: var(--bg); border-radius: 3px; margin: var(--s3) 0 6px; position: relative; overflow: hidden; }
.mcard .bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 3px; transition: width .25s, background .25s; }
.mcard.ok .bar > span { background: var(--ok); } .mcard.warn .bar > span { background: var(--warn); } .mcard.over .bar > span { background: var(--over); }
.mcard .bar .tick { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--muted); opacity: .5; }
.mcard .m-sub { font-size: var(--text-xs); color: var(--muted); font-family: var(--mono); display: flex; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.mcard.info { border-top-color: var(--info); }
.mcard.info .bar > span { background: var(--info); }

.alerts { display: flex; flex-direction: column; gap: var(--s2); }
.alerts:empty { display: none; }
.alert { display: flex; gap: var(--s3); align-items: flex-start; padding: 10px var(--s4); border-radius: var(--radius); font-size: var(--text-sm); border: 1px solid; }
.alert.over { border-color: rgba(242,96,79,.45); background: var(--over-bg); }
.alert.warn { border-color: rgba(240,180,60,.4); background: var(--warn-bg); }
.alert.ok { border-color: rgba(86,196,135,.35); background: var(--ok-bg); }
.alert .a-k { font-weight: 800; font-size: var(--text-xs); letter-spacing: 0.1em; text-transform: uppercase; padding-top: 2px; flex-shrink: 0; min-width: 62px; }
.alert.over .a-k { color: var(--over); } .alert.warn .a-k { color: var(--warn); } .alert.ok .a-k { color: var(--ok); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4) var(--s5) var(--s5); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); flex-wrap: wrap; }
.card-h h2 { font-size: var(--text-lg); font-weight: 700; font-variation-settings: 'wdth' 85; letter-spacing: 0.01em; }
.legend { display: flex; gap: var(--s3); font-size: var(--text-xs); color: var(--muted); }
.lg::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.lg.ok::before { background: var(--ok); } .lg.warn::before { background: var(--warn); } .lg.over::before { background: var(--over); }
.chip { font-size: var(--text-xs); font-family: var(--mono); padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-2); }
.chip.ok { color: var(--ok); border-color: var(--ok); } .chip.warn { color: var(--warn); border-color: var(--warn); } .chip.over { color: var(--over); border-color: var(--over); }

.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); }

/* ---------- Rig SVG ---------- */
.rig-wrap { width: 100%; overflow-x: auto; }
#rig { width: 100%; min-width: 600px; height: auto; display: block; }
#rig text { font-family: var(--mono); }
#rig .lbl { font-family: var(--sans); }

/* ---------- Simulator ---------- */
.sim-stats { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: var(--text-xs); color: var(--muted); font-family: var(--mono); }
.sim-stats b { color: var(--text); font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.tb-group { display: flex; align-items: flex-end; gap: var(--s2); flex-wrap: wrap; }
.tb-label { font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; align-self: center; margin-right: 4px; }
.mini { display: flex; flex-direction: column; gap: 3px; font-size: var(--text-xs); color: var(--muted); }
.mini .in input { width: 70px; }
select { background: var(--bg); border: 1px solid var(--line-2); border-radius: 4px; padding: 6px 8px; font-size: var(--text-sm); height: 33px; }
.btn {
  height: 33px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--surface-2);
  font-size: var(--text-sm); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--over); border-color: rgba(242,96,79,.5); background: transparent; }
.btn:focus-visible, .seg button:focus-visible, select:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

.deck-scroll { overflow-x: auto; padding-bottom: 4px; }
.deck-outer { position: relative; min-width: 720px; padding-left: 0; }
.ruler { position: relative; height: 22px; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.ruler .rt { position: absolute; bottom: 0; width: 1px; background: var(--line-2); height: 6px; }
.ruler .rt.major { height: 10px; background: var(--faint); }
.ruler .rl { position: absolute; top: 0; transform: translateX(-50%); }
.deck {
  position: relative; border: 2px solid var(--line-2); border-radius: 3px;
  background:
    repeating-linear-gradient(90deg, transparent 0, transparent calc(var(--ft) * 1 - 1px), rgba(255,255,255,.035) calc(var(--ft) * 1 - 1px), rgba(255,255,255,.035) calc(var(--ft) * 1)),
    #191c20;
  touch-action: pan-x; user-select: none;
}
.deck.flatbed { background:
    repeating-linear-gradient(90deg, transparent 0, transparent calc(var(--ft) * 1 - 1px), rgba(0,0,0,.35) calc(var(--ft) * 1 - 1px), rgba(0,0,0,.35) calc(var(--ft) * 1)),
    #3a2f25; border-color: #5a4a3a; }
.deck .zone { position: absolute; top: 0; bottom: 0; pointer-events: none; }
.deck .zone.kp { width: 2px; background: var(--info); opacity: .8; z-index: 4; }
.deck .zone.tandem { background: rgba(127,178,230,.08); border-left: 1px dashed rgba(127,178,230,.5); border-right: 1px dashed rgba(127,178,230,.5); }
.deck .zone.unit { background: repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 4px, transparent 4px 8px); }
.deck .zlabel { position: absolute; top: 50%; transform: translateY(-50%); z-index: 7; font-size: 10px; font-family: var(--mono); color: var(--info); pointer-events: none; white-space: nowrap; background: #191c20; padding: 0 4px; border-radius: 2px; line-height: 14px; }
.deck.flatbed .zlabel { background: #3a2f25; }
.deck .cg { position: absolute; top: -9px; bottom: -9px; width: 0; border-left: 2px dashed var(--warn); pointer-events: none; z-index: 5; }
.deck .cg span { position: absolute; top: -16px; left: 4px; font-size: 10px; font-family: var(--mono); color: var(--warn); white-space: nowrap; }

.pallet {
  touch-action: none;
  position: absolute; border-radius: 3px; cursor: grab; z-index: 3;
  background: #8a6a45; border: 1px solid #b38c5d;
  box-shadow: inset 0 0 0 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  font-family: var(--mono); font-size: 11px; line-height: 1.1; color: #fff7ea; font-weight: 700;
  transition: box-shadow .12s, transform .12s;
  overflow: hidden; text-align: center;
}
.pallet small { font-weight: 400; opacity: .8; font-size: 10px; }
.pallet::before {
  content: ''; position: absolute; inset: 4px; border: 1px solid rgba(0,0,0,.18); border-radius: 2px; pointer-events: none;
}
.pallet.heavy { background: #9a5a3a; border-color: #c97c55; }
.pallet.light { background: #6f7b56; border-color: #95a374; }
.pallet:hover { box-shadow: inset 0 0 0 3px rgba(0,0,0,.12), 0 0 0 2px rgba(255,255,255,.35); }
.pallet.sel { box-shadow: 0 0 0 2px var(--accent), 0 0 0 5px rgba(233,230,223,.18); z-index: 6; }
.pallet.drag { cursor: grabbing; z-index: 10; transform: scale(1.03); box-shadow: 0 8px 18px rgba(0,0,0,.5), 0 0 0 2px var(--accent); transition: none; }
.pallet.bad { background: var(--over) !important; border-color: #ffb3a8 !important; }
.pallet:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.deck .empty-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: var(--text-sm); pointer-events: none; }

.wpf { position: relative; height: 54px; margin-top: 6px; border-bottom: 1px solid var(--line-2); }
.wpf .wb { position: absolute; bottom: 0; background: var(--muted); opacity: .55; border-radius: 1px 1px 0 0; }
.wpf .wb.hi { background: var(--warn); opacity: .9; }
.wpf-label { font-size: 11px; color: var(--faint); font-family: var(--mono); margin-top: 4px; }

.editor { margin-top: var(--s4); padding: var(--s3) var(--s4); border: 1px dashed var(--line-2); border-radius: var(--radius); min-height: 54px; display: flex; align-items: center; flex-wrap: wrap; gap: var(--s3); }
.editor-empty { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.editor .ed-title { font-weight: 700; font-size: var(--text-sm); margin-right: var(--s2); }
.editor .ed-meta { font-family: var(--mono); font-size: var(--text-xs); color: var(--muted); }
.editor .spacer { flex: 1; }

/* ---------- Bridge table ---------- */
.formula { font-family: var(--mono); font-size: var(--text-sm); color: var(--muted); margin: 0 0 var(--s3); }
.table-wrap { overflow-x: auto; }
table.bridge { width: 100%; border-collapse: collapse; font-size: var(--text-xs); font-family: var(--mono); }
table.bridge th { text-align: right; font-weight: 500; color: var(--faint); padding: 6px 8px; border-bottom: 1px solid var(--line-2); font-family: var(--sans); text-transform: uppercase; letter-spacing: .06em; font-size: 11px; white-space: nowrap; }
table.bridge th:first-child, table.bridge td:first-child { text-align: left; }
table.bridge td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.bridge tr.key td { color: var(--text); }
table.bridge tr:not(.key) td { color: var(--muted); }
table.bridge td.st { font-weight: 700; }
table.bridge td.st.ok { color: var(--ok); } table.bridge td.st.warn { color: var(--warn); } table.bridge td.st.over { color: var(--over); }
table.bridge tr.over td { background: var(--over-bg); }
table.bridge .grp-name { font-family: var(--sans); color: var(--faint); margin-left: 6px; }

/* ---------- Kingpin / advisor / ticket ---------- */
.split-bar { display: flex; height: 34px; border-radius: 4px; overflow: hidden; border: 1px solid var(--line-2); margin: var(--s2) 0 var(--s3); font-family: var(--mono); font-size: var(--text-xs); }
.split-bar > div { display: flex; align-items: center; justify-content: center; white-space: nowrap; overflow: hidden; transition: flex-basis .25s; }
.split-bar .s-kp { background: rgba(127,178,230,.28); color: var(--text); }
.split-bar .s-tt { background: rgba(233,230,223,.12); color: var(--text); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px var(--s4); font-size: var(--text-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); text-align: right; }
.kv .sep { grid-column: 1 / -1; height: 1px; background: var(--line); margin: 4px 0; }
.sub-h { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: var(--s4) 0 var(--s2); }

.adv-result { padding: var(--s3) var(--s4); border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--surface-2); margin-bottom: var(--s3); font-size: var(--text-sm); }
.adv-result.ok { border-color: rgba(86,196,135,.4); }
.adv-result.over { border-color: rgba(242,96,79,.45); }
.adv-result strong { display: block; font-size: var(--text-base); margin-bottom: 4px; }
.moves { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); margin: var(--s3) 0; }
.move { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: var(--s2) var(--s3); }
.move .mv-k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.move .mv-v { font-family: var(--mono); font-size: var(--text-base); font-weight: 700; }
.compare { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: var(--text-xs); margin-top: var(--s2); }
.compare th { font-family: var(--sans); color: var(--faint); font-weight: 500; text-align: right; padding: 4px 6px; text-transform: uppercase; font-size: 11px; letter-spacing: .06em; }
.compare td { text-align: right; padding: 5px 6px; border-top: 1px solid var(--line); }
.compare th:first-child, .compare td:first-child { text-align: left; }
.compare .up { color: var(--warn); } .compare .down { color: var(--ok); }
.compare td.ok { color: var(--ok); } .compare td.warn { color: var(--warn); } .compare td.over { color: var(--over); }

.ticket { display: flex; flex-direction: column; gap: var(--s3); }
.ticket-in { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--s3); }
.ticket-in .mini .in input { width: 100%; }
.ticket-in .mini .in { width: 100%; }
.delta.pos { color: var(--warn); } .delta.neg { color: var(--info); }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .main { padding: var(--s4); }
  .topbar { padding: var(--s3) var(--s4); }
}
@media (max-width: 560px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-sub { display: none; }
  .card { padding: var(--s3) var(--s4) var(--s4); }
  .moves { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .mcard .m-val { font-size: var(--text-lg); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ================= Tabs ================= */
.tabs { display: flex; gap: 3px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; padding: 3px; }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 4px; font-size: var(--text-sm); font-weight: 700; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected=true] { background: var(--accent); color: var(--accent-ink); }
.tabs button:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.planner-top { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.planner-top .brand-sub { white-space: normal; }
[hidden] { display: none !important; }

/* ================= Quick balance ================= */
.quick { max-width: 640px; margin: 0 auto; padding: var(--s4) var(--s4) var(--s8); }
.q-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.q-gross { font-size: var(--text-base); color: var(--muted); }
.q-gross b { font-family: var(--mono); }
.q-gross.ok { color: var(--ok); } .q-gross.warn { color: var(--warn); } .q-gross.over { color: var(--over); }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; font-size: 16px; }
.icon-btn:hover { background: var(--surface-3); }
.icon-btn.lg { width: 54px; height: 54px; border-radius: 8px; }
.icon-btn:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.q-truck { margin: var(--s2) -6px var(--s3); }
.q-truck svg { width: 100%; height: auto; display: block; }

.q-h { font-size: var(--text-xl); font-weight: 800; font-variation-settings: 'wdth' 85; margin: 0 0 var(--s3); }
.q-weights, .q-sums { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: var(--s2); }
.q-w { display: flex; flex-direction: column; background: var(--surface); border: 1.5px solid var(--line-2); border-radius: 8px; padding: 8px 12px 6px; cursor: text; }
.q-w:focus-within { border-color: var(--accent); background: var(--surface-2); }
.q-w span { font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.q-w input { width: 100%; border: 0; outline: 0; background: transparent; font-family: var(--mono); font-size: clamp(1.25rem, 1rem + 1.4vw, 1.6rem); font-weight: 700; padding: 2px 0; min-width: 0; }
.q-w input::placeholder { color: var(--line-2); }
.q-sums { margin-top: var(--s2); grid-template-columns: 1fr 1fr; }
.q-sums > div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); }
.q-sums > div.q-wide { grid-column: 1 / -1; }
.q-sums span { font-size: var(--text-xs); color: var(--faint); }
.q-sums b { font-family: var(--mono); font-size: var(--text-lg); color: var(--muted); }
.q-sums .q-wide b { color: var(--text); }

.q-rows { margin-top: var(--s5); border-top: 1px solid var(--line); }
.q-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: 10px 0; border-bottom: 1px solid var(--line); font-size: var(--text-base); }
.q-row select { min-width: 190px; height: 44px; font-size: var(--text-base); padding: 0 10px; }

.q-actions { display: flex; gap: var(--s2); margin-top: var(--s5); align-items: stretch; }
.q-go { flex: 1; height: 56px; border-radius: 8px; border: 0; background: var(--accent); color: var(--accent-ink); font-size: var(--text-lg); font-weight: 800; cursor: pointer; letter-spacing: .01em; }
.q-go:hover { background: #fff; }
.q-go:focus-visible, .q-back:focus-visible, .q-link:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.q-err { color: var(--over); font-size: var(--text-sm); min-height: 1em; margin: var(--s2) 0 0; }
.q-foot { color: var(--faint); font-size: var(--text-xs); text-align: center; margin-top: var(--s5); }

.q-big { font-size: var(--text-xl); font-weight: 800; font-variation-settings: 'wdth' 85; margin: var(--s2) 0 4px; line-height: 1.15; }
.q-sub { color: var(--muted); margin: 0; font-size: var(--text-sm); }
.q-hole { margin: var(--s3) 0 0; font-size: var(--text-lg); }
.q-hole b { font-family: var(--mono); font-size: 2.4rem; vertical-align: -4px; margin-left: 6px; }
.q-notes { margin-top: var(--s3); display: flex; flex-direction: column; gap: 6px; }
.q-note { margin: 0; padding: 8px 12px; border-radius: 6px; font-size: var(--text-sm); border: 1px solid; }
.q-note.ok { color: var(--ok); border-color: rgba(86,196,135,.35); background: var(--ok-bg); }
.q-note.over { color: #ffb0a6; border-color: rgba(242,96,79,.45); background: var(--over-bg); }
.q-details { margin-top: var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: var(--s3) var(--s4); }
.q-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: var(--text-sm); }
.q-table th { font-family: var(--sans); font-size: var(--text-xs); color: var(--faint); font-weight: 600; text-align: right; padding: 4px 6px; text-transform: uppercase; letter-spacing: .06em; }
.q-table td { text-align: right; padding: 7px 6px; border-top: 1px solid var(--line); }
.q-table th:first-child, .q-table td:first-child { text-align: left; font-family: var(--sans); }
.q-table td.ok { color: var(--ok); } .q-table td.warn { color: var(--warn); } .q-table td.over { color: var(--over); }
.q-dl { display: grid; grid-template-columns: 1fr auto; gap: 4px var(--s4); margin: var(--s3) 0 0; padding-top: var(--s3); border-top: 1px solid var(--line); font-size: var(--text-sm); }
.q-dl dt { color: var(--muted); } .q-dl dd { margin: 0; text-align: right; }
.q-back { flex: 1; height: 54px; border-radius: 8px; border: 1.5px solid var(--accent); background: transparent; color: var(--text); font-size: var(--text-lg); font-weight: 800; cursor: pointer; }
.q-back:hover { background: var(--surface-2); }
.q-link { display: none; }

/* settings sheet */
.sheet { border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); color: var(--text); padding: 0; width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 40px); }
.sheet::backdrop { background: rgba(0,0,0,.6); }
.sheet > form { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.sheet-h { display: flex; align-items: center; justify-content: space-between; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.sheet-h h2 { font-size: var(--text-lg); }
.sheet .fields { padding: var(--s4); overflow-y: auto; }
.sheet .sub-h { margin: var(--s3) 0 0; }
.sheet-f { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }
.sheet-f .q-go { width: 100%; height: 48px; font-size: var(--text-base); }

@media (max-width: 480px) {
  .q-row select { min-width: 0; width: 58%; }
  .tabs button { padding: 7px 10px; }
  .brand-name { font-size: var(--text-base); }
}

.q-truck { position: relative; }
.q-labels { position: relative; height: 54px; margin-top: 2px; }
.q-lab { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; line-height: 1.15; white-space: nowrap; }
.q-m { font-family: var(--mono); font-size: 15px; font-weight: 700; }
.q-m.ok { color: var(--ok); } .q-m.warn { color: var(--warn); } .q-m.over { color: var(--over); } .q-m.none { color: var(--faint); }
.q-v { font-family: var(--mono); font-size: clamp(1.1rem, 0.9rem + 1vw, 1.45rem); font-weight: 700; }

/* ================= Planner guide ================= */
.guide { margin: var(--s4) var(--s6) 0; background: var(--surface); border: 1px solid var(--line-2); border-left: 3px solid var(--info); border-radius: var(--radius); }
.guide-h { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: var(--s4); padding: var(--s3) var(--s5); }
.guide-h::-webkit-details-marker { display: none; }
.guide-h b { display: block; font-size: var(--text-lg); font-variation-settings: 'wdth' 85; }
.guide-h em { display: block; font-style: normal; color: var(--muted); font-size: var(--text-sm); margin-top: 2px; }
.guide-toggle { flex-shrink: 0; font-size: var(--text-sm); font-weight: 700; color: var(--text); border: 1px solid var(--line-2); border-radius: 4px; padding: 6px 12px; white-space: nowrap; }
.guide-toggle::after { content: 'Show steps'; }
.guide[open] .guide-toggle::after { content: 'Hide'; }
.guide-h:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.guide-body { padding: 0 var(--s5) var(--s4); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); counter-reset: step; }
.steps li { counter-increment: step; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3) var(--s4) var(--s3) 52px; position: relative; }
.steps li::before { content: counter(step); position: absolute; left: 14px; top: 12px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-family: var(--mono); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.steps h3 { font-size: var(--text-sm); font-weight: 700; margin: 2px 0 4px; }
.steps p { margin: 0; font-size: var(--text-xs); color: var(--muted); line-height: 1.5; }
.steps b { color: var(--text); font-weight: 600; }
.guide-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s3); margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); }
.legend-row { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: var(--text-xs); color: var(--muted); }
.guide-tips { margin: 0; font-size: var(--text-xs); color: var(--muted); }
.guide-tips b { color: var(--text); }
.linkish { background: none; border: 0; padding: 0; color: var(--info); font: inherit; text-decoration: underline; cursor: pointer; }
.card-help { margin: -4px 0 var(--s3); font-size: var(--text-xs); color: var(--muted); line-height: 1.5; max-width: 72ch; }
@media (max-width: 1280px) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .guide { margin: var(--s3) var(--s4) var(--s3); } }
@media (max-width: 560px) {
  .steps { grid-template-columns: 1fr; }
  .guide-h { padding: var(--s3) var(--s4); align-items: flex-start; }
  .guide-body { padding: 0 var(--s4) var(--s4); }
}

/* ================= Setups ================= */
.setup-chip { flex: 1; min-width: 0; display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border-radius: 21px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); cursor: pointer; font-size: var(--text-sm); font-weight: 700; max-width: 420px; }
.setup-chip:hover { background: var(--surface-3); }
.setup-chip:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.setup-chip svg { flex-shrink: 0; color: var(--muted); }
.setup-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-chip .chev { color: var(--muted); margin-left: auto; }
.setup-dirty { display: inline-block; font-size: 11px; font-weight: 700; color: var(--warn); border: 1px solid rgba(240,180,60,.5); border-radius: 999px; padding: 0 7px; line-height: 17px; flex-shrink: 0; }
.q-gross { margin-top: var(--s3); }
.setup-panel .setup-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); font-size: var(--text-sm); }
.setup-panel .setup-row b { word-break: break-word; }

.sheet-inner { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.sheet-body { padding: var(--s4); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s3); }
.cur-setup { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.cur-l { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.cur-k { width: 100%; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); font-weight: 700; }
.cur-l b { font-size: var(--text-base); }
.cur-s { width: 100%; font-size: var(--text-xs); color: var(--muted); font-family: var(--mono); }
.cur-a { display: flex; gap: var(--s2); flex-wrap: wrap; }
.save-new { display: flex; gap: var(--s2); align-items: flex-end; }
.mini.grow { flex: 1; min-width: 0; }
.save-new input, .rename-form input { width: 100%; height: 40px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 10px; font-size: var(--text-base); color: var(--text); }
.save-new input:focus, .rename-form input:focus { outline: 0; border-color: var(--accent); }
.save-new .btn { height: 40px; }
.setup-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.setup-item { border: 1px solid var(--line); border-radius: 8px; padding: var(--s3); display: flex; flex-direction: column; gap: var(--s2); background: var(--bg); }
.setup-item.on { border-color: var(--ok); }
.si-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.si-name { font-size: var(--text-base); word-break: break-word; }
.si-sum { font-size: var(--text-xs); color: var(--muted); font-family: var(--mono); }
.si-act { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.si-on { font-size: var(--text-xs); font-weight: 700; color: var(--ok); padding: 0 6px; }
.danger-txt { color: var(--over); }
.btn.confirm { background: var(--over); color: #fff; border-color: var(--over); }
.setup-empty { color: var(--muted); font-size: var(--text-sm); padding: var(--s3); border: 1px dashed var(--line-2); border-radius: 8px; }
.rename-form { display: flex; gap: var(--s2); }
.net { display: inline-block; font-size: var(--text-xs); }
.net:empty { display: none; }
.net.ready { color: var(--ok); }
.net.off { color: var(--warn); }
.q-foot .net { display: block; margin-bottom: 4px; }
.q-foot .net:empty { display: none; }
.net-line { margin: 0 0 var(--s2); text-align: center; }
.net-line:has(.net:empty) { display: none; }
