/* MTB Bot Hub. Design system: see hub/DESIGN.md.
   World: the exchange floor's order ticket and settlement ledger. An ink-indigo rail holds
   the shell, work sits on cool white paper ruled with hairlines, every figure is tabular,
   and trade proposals carry a price ladder (stop, entry, target to scale). */

:root {
  color-scheme: light;
  /* Shell */
  --rail: #1c1e3b; --rail-2: #282b52; --rail-line: #33366a;
  --rail-text: #c6c8e8; --rail-strong: #ffffff; --rail-muted: #9a9dc6;
  /* Work surface */
  --bg: #eef0f6; --surface: #ffffff; --surface-2: #f6f7fb; --surface-3: #eceef5;
  --line: #e0e3ed; --line-strong: #c9cddc;
  --text: #15172a; --text-2: #454a63; --text-3: #5d627b;
  /* Action */
  --accent: #4338ca; --accent-hover: #3830a8; --accent-text: #3b33b5; --accent-soft: #ebe9fc;
  --on-accent: #ffffff; --focus: #6d63f5;
  /* State */
  --pos: #0b7a43; --pos-soft: #e2f3e9; --neg: #b42318; --neg-soft: #fdecea;
  --warn: #8f5300; --warn-soft: #fbefd9; --warn-solid: #a85f00; --info-soft: #e9ecf7;
  /* Charts (hex: Chart.js cannot read oklch) */
  --chart-1: #4338ca; --chart-2: #7d8299; --chart-neg: #b42318; --chart-neg-fill: rgba(180, 35, 24, 0.12);
  --chart-grid: #e6e8f0; --chart-text: #5d627b;
  /* Type, space, shape */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 24px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px;
  --shadow: 0 1px 2px rgba(21, 23, 42, 0.05), 0 2px 8px rgba(21, 23, 42, 0.04);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --rail-w: 232px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --rail: #15163a; --rail-2: #23255a; --rail-line: #2c2f66;
    --rail-text: #c3c5ea; --rail-strong: #ffffff; --rail-muted: #9093c4;
    --bg: #0f1020; --surface: #171931; --surface-2: #1c1f3a; --surface-3: #232745;
    --line: #2a2d4b; --line-strong: #3a3e63;
    --text: #e9eaf5; --text-2: #b9bcd6; --text-3: #9a9eba;
    --accent: #5b51e8; --accent-hover: #6a61f0; --accent-text: #a9a3ff; --accent-soft: #24245a;
    --on-accent: #ffffff; --focus: #8f88ff;
    --pos: #4fcf8e; --pos-soft: #12301f; --neg: #ff8073; --neg-soft: #3a1715;
    --warn: #f3b552; --warn-soft: #36270d; --warn-solid: #c47a0a; --info-soft: #1f2242;
    --chart-1: #8f88ff; --chart-2: #8d91ad; --chart-neg: #ff8073; --chart-neg-fill: rgba(255, 128, 115, 0.14);
    --chart-grid: #262947; --chart-text: #9a9eba;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.18);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--fs-md)/1.5 var(--font); background: var(--bg); color: var(--text);
  font-variant-numeric: tabular-nums; caret-color: var(--accent); accent-color: var(--accent);
  scrollbar-color: var(--line-strong) transparent; }
::selection { background: var(--accent-soft); color: var(--text); }
a { color: var(--accent-text); text-decoration: none; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
h1 { font-size: var(--fs-2xl); line-height: 1.2; font-weight: 680; letter-spacing: -0.015em; }
h2 { font-size: var(--fs-lg); line-height: 1.3; font-weight: 650; letter-spacing: -0.005em; }
h3 { font-size: var(--fs-md); line-height: 1.35; font-weight: 650; margin: var(--s5) 0 var(--s2); }
p { margin: 0 0 var(--s3); text-wrap: pretty; max-width: 75ch; }
ul, ol { margin: 0 0 var(--s3); padding-left: 1.25em; }
li { margin: 2px 0; }
li::marker { color: var(--text-3); }
code, pre { font: 12.5px/1.5 var(--mono); }
code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--surface-2); border: 1px solid var(--line); padding: var(--s3) var(--s4); border-radius: var(--r-md);
  overflow-x: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }
pre code { background: none; padding: 0; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--text-3); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- Shell: rail + work area ---------- */
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: var(--s4) var(--s3); gap: var(--s5);
  scrollbar-color: var(--rail-line) transparent; overflow-y: auto; }
.rail ::selection { background: var(--rail-2); color: var(--rail-strong); }
.rail-brand { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s1) var(--s2); }
.brand { color: var(--rail-strong); font-weight: 720; font-size: 15px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.tag-paper { font-size: 11px; font-weight: 650; color: var(--rail-strong); border: 1px solid var(--rail-line);
  background: var(--rail-2); padding: 1px 7px; border-radius: 999px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-nav a { display: flex; align-items: center; gap: var(--s3); padding: 8px var(--s2); border-radius: var(--r-sm);
  color: var(--rail-text); font-weight: 500; transition: background-color 160ms var(--ease), color 160ms var(--ease); }
.rail-nav a .icon { color: var(--rail-muted); transition: color 160ms var(--ease); }
.rail-nav a:hover { background: var(--rail-2); color: var(--rail-strong); text-decoration: none; }
.rail-nav a:hover .icon { color: var(--rail-strong); }
.rail-nav a.active { background: var(--rail-2); color: var(--rail-strong); font-weight: 620;
  box-shadow: inset 0 0 0 1px var(--rail-line); }
.rail-nav a.active .icon { color: var(--rail-strong); }
.rail-nav :focus-visible { outline-color: var(--rail-strong); }
.badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--warn-solid);
  color: #fff; font-size: 11.5px; font-weight: 700; line-height: 20px; text-align: center; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s3); padding: 0 var(--s2);
  border-top: 1px solid var(--rail-line); padding-top: var(--s4); }
.rail-state { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); color: var(--rail-text); }
.rail-state .dot { width: 8px; height: 8px; border-radius: 50%; background: #4fcf8e; box-shadow: 0 0 0 3px rgba(79, 207, 142, 0.18); }
.rail-state.is-degraded .dot { background: #f3b552; box-shadow: 0 0 0 3px rgba(243, 181, 82, 0.2); }
.rail-state.is-paused .dot { background: #ff8073; box-shadow: 0 0 0 3px rgba(255, 128, 115, 0.22); }
.rail-user { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.rail-username { color: var(--rail-strong); font-weight: 600; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; }

.work { min-width: 0; display: flex; flex-direction: column; }
.notices { padding: var(--s4) var(--s6) 0; display: flex; flex-direction: column; gap: var(--s2); max-width: 1360px; width: 100%; margin: 0 auto; }
main { padding: var(--s5) var(--s6) var(--s7); max-width: 1360px; width: 100%; margin: 0 auto; }
.paper-line { display: flex; align-items: center; gap: var(--s2); margin: 0; color: var(--text-3); font-size: var(--fs-sm); max-width: none; }
.paper-line .icon { width: 16px; height: 16px; vertical-align: 0; align-self: flex-start; margin-top: 2px; }

/* ---------- Notices and inline messages ---------- */
.notice, .msg, .error { display: flex; align-items: flex-start; gap: var(--s3); padding: 10px var(--s4); border-radius: var(--r-md);
  font-weight: 550; border: 1px solid transparent; }
.notice .icon, .msg .icon, .error .icon { margin-top: 1px; }
.notice.crit { background: var(--neg-soft); color: var(--neg); border-color: color-mix(in srgb, var(--neg) 28%, transparent); }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.notice.warn a { color: inherit; text-decoration: underline; }
.msg { background: var(--info-soft); color: var(--text); font-weight: 500; margin-bottom: var(--s4); display: block; }
.error { background: var(--neg-soft); color: var(--neg); margin-bottom: var(--s4); display: block; }
.msg ul, .error ul { margin: var(--s1) 0 0; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head .lede { color: var(--text-2); margin: var(--s2) 0 0; }
.page-head .chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: var(--s2); }
.page-head .actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 2px; font-size: var(--fs-sm); margin-bottom: var(--s3); color: var(--text-3); }
.back .icon { width: 16px; height: 16px; vertical-align: 0; }

/* ---------- Layout ---------- */
.grid { display: grid; gap: var(--s4); align-items: start; }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.spacer { height: var(--s4); }
.section { margin-top: var(--s4); }

/* ---------- Panels (the one container; never nested) ---------- */
.panel, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: var(--s4) var(--s5) var(--s5); min-width: 0; }
.panel > h2:first-child, .card > h2:first-child, .panel-head { margin-bottom: var(--s3); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.panel .note, .card .note { color: var(--text-3); font-size: var(--fs-sm); margin: var(--s3) 0 0; }
.panel h2 + .muted, .card h2 + .muted { font-size: var(--fs-sm); }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > .panel-head, .panel.flush > h2 { padding: var(--s4) var(--s5) 0; margin-bottom: var(--s3); }
.panel.flush > .note, .panel.flush > p { padding: 0 var(--s5); }
.panel.flush > .note:last-child, .panel.flush > p:last-child { padding-bottom: var(--s4); }

/* Figures: one ruled strip of numbers, not a row of cards */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); margin-bottom: var(--s4); }
.figure { padding: var(--s4) var(--s5); min-width: 0; }
.figure + .figure { border-left: 1px solid var(--line); }
.figure .label { color: var(--text-2); font-size: var(--fs-sm); font-weight: 550; }
.figure .value { font-size: 26px; line-height: 1.2; font-weight: 680; letter-spacing: -0.02em; margin-top: 2px; overflow-wrap: anywhere; }
.figure .sub { color: var(--text-3); font-size: var(--fs-xs); margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
th { color: var(--text-2); font-weight: 600; font-size: var(--fs-xs); background: var(--surface-2); }
thead th, tr:first-child > th { border-bottom-color: var(--line-strong); }
tr:last-child > td { border-bottom: 0; }
tbody tr, table tr { transition: background-color 120ms var(--ease); }
table tr:has(td):hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
td .muted, td.muted { font-size: var(--fs-sm); }
td > div.muted { font-size: var(--fs-xs); margin-top: 1px; }
td.wrap, th.wrap { white-space: normal; }
td a { font-weight: 550; }
.panel table, .card table { margin: 0; }
.panel.flush table th:first-child, .panel.flush table td:first-child { padding-left: var(--s5); }
.panel.flush table th:last-child, .panel.flush table td:last-child { padding-right: var(--s5); }
/* key/value tables */
table.kv td:first-child { color: var(--text-2); }
table.kv td { padding: 7px 0; }
table.kv td + td { padding-left: var(--s3); }
table.kv tr:hover { background: none; }
.empty td, td.empty { color: var(--text-3); white-space: normal; padding: var(--s4) 10px; }
.w-icon { width: 28px; padding-right: 0; }

/* Gate checks */
.check { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; align-items: center; justify-content: center; }
.check .icon { width: 14px; height: 14px; stroke-width: 2.4; vertical-align: 0; }
.check-pass { background: var(--pos-soft); color: var(--pos); }
.check-fail { background: var(--neg-soft); color: var(--neg); }
.check-pending { color: var(--text-3); }
.check-pending .icon { width: 18px; height: 18px; stroke-width: 1.75; }
.verdict { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.verdict .icon { width: 15px; height: 15px; stroke-width: 2.2; vertical-align: 0; }

/* ---------- Chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: 999px; background: var(--surface-3);
  font-size: var(--fs-xs); font-weight: 550; color: var(--text-2); line-height: 20px; white-space: nowrap; vertical-align: 1px; }
.chip.running, .chip.unreachable, .chip.paused, .chip.stopped, .chip.critical, .chip.warning { padding-left: 8px; }
.chip.running::before, .chip.paused::before, .chip.stopped::before, .chip.unreachable::before, .chip.critical::before,
.chip.warning::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.running { background: var(--pos-soft); color: var(--pos); }
.chip.paused, .chip.stopped, .chip.warning { background: var(--warn-soft); color: var(--warn); }
.chip.unreachable, .chip.critical { background: var(--neg-soft); color: var(--neg); }
.chip.info { background: var(--info-soft); color: var(--text-2); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 14px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: var(--r-sm);
  cursor: pointer; font: inherit; font-weight: 600; line-height: 1.2; white-space: nowrap;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease), transform 80ms var(--ease); }
.btn:hover { border-color: var(--text-3); background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn .icon { width: 16px; height: 16px; vertical-align: 0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--neg) 86%, #000); }
.btn.warn { background: var(--warn-solid); border-color: var(--warn-solid); color: #fff; }
.btn.warn:hover:not(:disabled) { background: color-mix(in srgb, var(--warn-solid) 86%, #000); }
.btn.small { min-height: 28px; padding: 3px 10px; font-size: var(--fs-sm); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.on-rail { color: var(--rail-text); }
.btn.on-rail:hover { background: var(--rail-2); color: var(--rail-strong); border-color: transparent; }
.btn.on-rail:focus-visible { outline-color: var(--rail-strong); }
@media (prefers-color-scheme: dark) {
  .btn.danger { color: #1a0605; } .btn.warn { color: #1f1302; }
}
form.inline { display: inline; }
.row { display: flex; gap: var(--s2) var(--s3); align-items: center; flex-wrap: wrap; }
.row.end { align-items: flex-end; }
.row.between { justify-content: space-between; }
.actions-bar { display: flex; gap: var(--s2); flex-wrap: wrap; }

/* ---------- Forms ---------- */
label { display: block; font-size: var(--fs-sm); font-weight: 550; color: var(--text-2); margin: var(--s3) 0 var(--s1); }
label.check-label { display: flex; align-items: center; gap: var(--s2); font-weight: 500; color: var(--text); margin: var(--s3) 0; }
input, select, textarea { font: inherit; min-height: 34px; padding: 6px 10px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); max-width: 100%;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
input:user-invalid:not(:focus) { border-color: var(--neg); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; vertical-align: -3px; }
select[multiple] { padding: 4px; }
select[multiple] option { padding: 3px 6px; border-radius: 4px; }
textarea { width: 100%; min-height: 90px; line-height: 1.5; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 var(--s4); }
.field-row input, .field-row select { width: 100%; }
.form-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-top: var(--s4); }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices label { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 5px 10px; border: 1px solid var(--line-strong);
  border-radius: 999px; font-weight: 550; color: var(--text); cursor: pointer; background: var(--surface);
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease); }
.choices label:hover { border-color: var(--text-3); }
.choices label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.filters { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin-bottom: var(--s4); }
.danger-zone { border-top: 1px solid var(--line); margin-top: var(--s4); padding-top: var(--s3); }

/* ---------- Disclosure ---------- */
details > summary { cursor: pointer; color: var(--text-2); font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 7px; height: 7px; border-right: 1.75px solid currentColor; border-bottom: 1.75px solid currentColor;
  transform: rotate(-45deg); transition: transform 160ms var(--ease); margin-right: 2px; }
details[open] > summary::before { transform: rotate(45deg); }
details > summary:hover { color: var(--text); }
details.panel > summary, details.card > summary { color: var(--text); font-size: var(--fs-lg); }
details.panel[open] > summary { margin-bottom: var(--s3); }
details.review { border-top: 1px solid var(--line); padding: var(--s3) 0; }
details.review:first-of-type { border-top: 0; }
details.review[open] > summary { margin-bottom: var(--s2); }

/* ---------- Charts and images ---------- */
canvas { max-height: 300px; }
.chart-box { position: relative; height: 300px; }
.chart-box.small { height: 180px; }
.thumb { width: 100%; max-height: 220px; object-fit: contain; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface-2); }
.chart-img { width: 100%; border-radius: var(--r-md); border: 1px solid var(--line); }
.qr svg { width: 220px; height: 220px; background: #fff; padding: 10px; border-radius: var(--r-md); border: 1px solid var(--line); }

/* ---------- Dashboard: control panel (kill switch) ---------- */
.control { border-color: color-mix(in srgb, var(--neg) 35%, var(--line)); }
.control .panel-head .icon { color: var(--neg); }
.control-state { display: flex; align-items: center; gap: var(--s2); font-weight: 600; margin-bottom: var(--s2); }
.control-state .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pos); }
.control-state.is-paused .dot { background: var(--neg); }
.health { margin-top: var(--s5); }
table.alerts td { padding: 10px 0; }
.alert-text { margin-top: var(--s1); color: var(--text-2); font-size: var(--fs-sm); }
.health h2 { font-size: var(--fs-md); margin-bottom: var(--s1); }

/* ---------- Order ticket (approvals) ---------- */
.tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: var(--s4); }
.ticket { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.ticket-stub { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s5);
  background: var(--rail); color: var(--rail-strong); border-bottom: 1px dashed var(--rail-line); }
.ticket-stub h2 { font-size: var(--fs-lg); letter-spacing: 0.01em; }
/* Floor tickets: buy slips and sell slips are told apart by colour before they are read. */
.ticket-stub.side-sell, .ticket-stub.side-close { background: #6e1a14; border-bottom-color: #8f2d25; }
.ticket-stub.side-sell .expires, .ticket-stub.side-close .expires { background: #8f2d25; color: #fde3e0; }
.ticket-stub .expires { font-size: var(--fs-xs); font-weight: 600; color: var(--rail-text); background: var(--rail-2);
  padding: 2px 9px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ticket-body { padding: var(--s4) var(--s5); display: flex; flex-direction: column; gap: var(--s3); flex: 1; }
.ticket-meta { color: var(--text-3); font-size: var(--fs-sm); margin: 0; }
.ticket-body table.kv { font-size: var(--fs-md); }
.ticket-body .case p { margin: 0 0 var(--s1); }
.ticket-body .case strong { color: var(--text-2); font-weight: 650; }
.ticket-actions { padding: var(--s3) var(--s5) var(--s4); border-top: 1px solid var(--line); background: var(--surface-2);
  display: grid; gap: var(--s2); }
.ticket-actions form { display: grid; grid-template-columns: minmax(0, 1fr) 112px; gap: var(--s2); }
.ticket-actions .btn { min-width: 92px; }

/* Price ladder: the signature. Stop, entry and target to scale on one rail. */
.ladder { margin: var(--s1) 0 0; }
.ladder-track { position: relative; height: 10px; border-radius: 999px; background: var(--surface-3); margin: 8px 6px 10px; }
.ladder-risk, .ladder-reward { position: absolute; top: 0; bottom: 0; }
.ladder-risk { background: color-mix(in srgb, var(--neg) 55%, transparent); border-radius: 999px 0 0 999px; }
.ladder-reward { background: color-mix(in srgb, var(--pos) 55%, transparent); border-radius: 0 999px 999px 0; }
.ladder-tick { position: absolute; top: -5px; width: 3px; height: 20px; margin-left: -1.5px; border-radius: 2px; background: var(--text); }
.ladder-tick.is-stop { background: var(--neg); } .ladder-tick.is-target { background: var(--pos); }
.ladder-legend { display: flex; flex-wrap: wrap; gap: 2px var(--s4); font-size: var(--fs-sm); color: var(--text-2); }
.ladder-legend b { font-weight: 650; color: var(--text); }
.ladder-legend .neg b { color: var(--neg); } .ladder-legend .pos b { color: var(--pos); }
.ladder-rr { margin-left: auto; }

/* ---------- Auth (login, setup) ---------- */
body.no-shell { background: var(--rail); min-height: 100vh; }
main.solo { min-height: 100vh; display: grid; place-items: center; padding: var(--s6) var(--s4); max-width: none; }
.form-narrow { width: 100%; max-width: 400px; margin: 0; }
.form-narrow .auth-brand { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s5); color: var(--text-2); font-weight: 650; }
.form-narrow h1 { margin-bottom: var(--s2); }
.form-narrow input { width: 100%; }
.form-narrow .btn.primary { width: 100%; margin-top: var(--s5); min-height: 40px; }
.form-narrow .help { color: var(--text-3); font-size: var(--fs-sm); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .grid.k3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.main-side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: var(--s2) var(--s3); padding: var(--s2) var(--s4); overflow: visible; }
  .rail-brand { padding: 0; order: 1; }
  .rail-foot { order: 2; margin: 0 0 0 auto; flex-direction: row; align-items: center; border: 0; padding: 0; gap: var(--s3); }
  .rail-state { display: none; }
  .rail-username { display: none; }
  .rail-nav { order: 3; flex-direction: row; width: calc(100% + 2 * var(--s4)); margin: 0 calc(-1 * var(--s4)); padding: 0 var(--s4) var(--s1);
    overflow-x: auto; scrollbar-width: none; gap: 2px; }
  .rail-nav a { white-space: nowrap; padding: 6px 10px; }
  .rail-nav a .icon { display: none; }
  .badge { margin-left: 4px; }
  .notices { padding: var(--s3) var(--s4) 0; }
  main { padding: var(--s4) var(--s4) var(--s7); }
  .grid.k2, .grid.k3, .grid.k4 { grid-template-columns: minmax(0, 1fr); }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--line); }
  .tickets { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  h1 { font-size: var(--fs-xl); }
  .panel, .card { padding: var(--s4); }
  .figure { padding: var(--s3) var(--s4); }
  .figure .value { font-size: 21px; }
  .ticket-stub, .ticket-body, .ticket-actions { padding-left: var(--s4); padding-right: var(--s4); }
  .btn.on-rail span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
