/* ============================================================================
   ui.css: design-system layer, loaded after style.css.
   One set of tokens (spacing, radius, shadow, type, colour aliases) and one shared look for buttons,
   inputs, cards, tables, dialogs, badges and navigation. Overrides only presentation; every class and id
   the scripts use is unchanged. Remove the <link> to roll back.
   ========================================================================== */
:root {
  /* spacing scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  /* radius */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-full: 999px;
  /* type scale */
  --fs-h1: 22px; --fs-h2: 16px; --fs-h3: 14px; --fs-h4: 13px; --fs-body: 14px; --fs-sm: 12px; --fs-xs: 11px;
  /* control sizes */
  --ctl-h: 32px; --ctl-h-sm: 26px; --ctl-h-touch: 38px;
  /* containers */
  --w-7xl: 1280px; --w-6xl: 1152px; --w-5xl: 1024px;
  /* colour aliases onto the existing theme variables (dark/light switch keeps working) */
  --primary: var(--acc); --secondary: var(--panel2); --success: var(--up); --warning: var(--warn); --danger: var(--dn);
  --background: var(--bg); --surface: var(--panel); --border: var(--line); --text-primary: var(--text); --text-secondary: var(--muted);
  --ring: color-mix(in srgb, var(--acc) 55%, transparent);
  /* shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.22);
  --shadow-md: 0 1px 2px rgba(0,0,0,.22), 0 6px 18px rgba(0,0,0,.16);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.25), 0 18px 48px rgba(0,0,0,.32);
  --shadow: var(--shadow-md);
  --ease: cubic-bezier(.2,.7,.2,1);
}
:root[data-theme="light"] { --shadow-sm: 0 1px 2px rgba(16,24,40,.06); --shadow-md: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.07); --shadow-lg: 0 4px 8px rgba(16,24,40,.06), 0 20px 48px rgba(16,24,40,.14); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --shadow-sm: 0 1px 2px rgba(16,24,40,.06); --shadow-md: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.07); --shadow-lg: 0 4px 8px rgba(16,24,40,.06), 0 20px 48px rgba(16,24,40,.14); }
}

/* elements the scripts hide with the hidden attribute must stay hidden even when a class sets display */
[hidden] { display: none !important; }
a.btn { display: inline-flex; text-decoration: none; }

/* ---------- base & typography ---------- */
body { font-size: var(--fs-body); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1 { font-size: var(--fs-h1); line-height: 1.25; font-weight: 700; letter-spacing: -.01em; margin: 0 0 var(--s-3); }
h2 { font-size: var(--fs-h2); line-height: 1.3; font-weight: 600; letter-spacing: -.005em; margin: 0 0 var(--s-3); }
h3 { font-size: var(--fs-h3); line-height: 1.35; font-weight: 600; margin: var(--s-4) 0 var(--s-2); }
h4 { font-size: var(--fs-h4); line-height: 1.4; font-weight: 600; margin: var(--s-3) 0 var(--s-2); }
.small { font-size: var(--fs-sm); }
.num, td.num, .kpi span { font-variant-numeric: tabular-nums; }
::selection { background: color-mix(in srgb, var(--acc) 30%, transparent); }

/* ---------- focus: visible for keyboard users everywhere (there was none) ---------- */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--r-sm); }
.btn:focus-visible, select:focus-visible, .inp:focus-visible, input:focus-visible, textarea:focus-visible { outline-offset: 1px; }
.nav a:focus-visible, .side .nav a:focus-visible { outline-offset: -2px; }
.skip-link { position: absolute; left: var(--s-2); top: -40px; z-index: 50; background: var(--acc); color: #fff; padding: var(--s-2) var(--s-3); border-radius: var(--r-md); text-decoration: none; }
.skip-link:focus { top: var(--s-2); }

/* ---------- layout rhythm ---------- */
main { gap: var(--s-4); padding: var(--s-4) var(--s-5) var(--s-7); }
.grid2, .grid3 { gap: var(--s-4); }

/* ---------- cards ---------- */
.card { padding: var(--s-4); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card > h2:first-child, .card > .row-between:first-child h2 { margin-bottom: var(--s-3); }
.kpi { border-radius: var(--r-lg); padding: var(--s-3) var(--s-3); box-shadow: var(--shadow-sm); }
.kpi b { font-size: var(--fs-xs); letter-spacing: .02em; }

/* ---------- buttons: one height, one hover, one disabled, one loading ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--ctl-h); padding: 0 var(--s-3);
  border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 500; line-height: 1; white-space: nowrap; vertical-align: middle;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .06s; }
.btn:hover:not([disabled]) { border-color: color-mix(in srgb, var(--acc) 60%, var(--line)); background: color-mix(in srgb, var(--acc) 7%, var(--panel2)); }
.btn:active:not([disabled]) { transform: translateY(1px); }
.btn.small { min-height: var(--ctl-h-sm); padding: 0 var(--s-2); font-size: var(--fs-xs); }
.btn.primary:hover:not([disabled]) { background: color-mix(in srgb, var(--acc) 88%, #000); border-color: transparent; }
.btn.buy:hover:not([disabled]) { background: color-mix(in srgb, var(--up) 88%, #000); }
.btn.sell:hover:not([disabled]) { background: color-mix(in srgb, var(--dn) 88%, #000); }
.btn[disabled], .btn.disabled { opacity: .45; cursor: not-allowed; }
.btn.big { min-height: 44px; font-size: 15px; }
.btn.icon, .btn.icon-always { min-width: var(--ctl-h); padding: 0 var(--s-2); }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); border-top-color: transparent; animation: ui-spin .7s linear infinite; }
@keyframes ui-spin { to { transform: rotate(360deg); } }
.dk-head .btn { min-height: 24px; }
.btn.fv-btn, .fv-btn { min-height: 0; }

/* ---------- form controls: same height, focus ring, placeholder ---------- */
select, .inp, input[type="text"], input[type="number"], input[type="search"], input[type="password"], input[type="date"], input[type="time"], textarea {
  border-radius: var(--r-md); font-size: var(--fs-sm); transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
select, .inp, .top #search { min-height: var(--ctl-h); }
select.small, .inp.small { min-height: var(--ctl-h-sm); }
select:hover, .inp:hover, #search:hover { border-color: color-mix(in srgb, var(--acc) 35%, var(--line)); }
select:focus, .inp:focus, #search:focus, textarea:focus { border-color: var(--acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 20%, transparent); }
::placeholder { color: var(--muted); opacity: .85; }
.inp[aria-invalid="true"], .inp.invalid { border-color: var(--dn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dn) 18%, transparent); }
label { line-height: 1.35; }

/* ---------- tables: one row height and type, sticky header inside scroll boxes ---------- */
table { font-size: 13px; font-variant-numeric: tabular-nums; }
th { font-size: var(--fs-xs); padding: var(--s-2) var(--s-2); vertical-align: bottom; }
td { padding: 7px var(--s-2); vertical-align: middle; }
tbody tr { transition: background-color .1s; }
tbody tr:hover { background: color-mix(in srgb, var(--panel2) 70%, transparent); }
.tbl-wrap thead th, [style*="max-height"] > table thead th, [style*="overflow"] > table thead th {
  position: sticky; top: 0; z-index: 1; background: var(--panel); box-shadow: inset 0 -1px 0 var(--line); }

/* ---------- dialogs: same spacing, entrance, backdrop ---------- */
dialog { padding: var(--s-4); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); }
dialog[open] { animation: ui-pop .16s var(--ease); }
dialog::backdrop { background: rgba(5,8,12,.55);  }
dialog:fullscreen, dialog.fs-fake { border-radius: 0; animation: none; }
@keyframes ui-pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }

/* ---------- badges / tags / pills ---------- */
.tag { border-radius: var(--r-sm); padding: 2px 6px; line-height: 1.4; vertical-align: middle; }
.pill { border-radius: var(--r-full); padding: 2px var(--s-2); font-size: var(--fs-xs); line-height: 1.5; }
.badge { border-radius: var(--r-full); font-weight: 600; }

/* ---------- navigation ---------- */
.side .nav a { padding: 7px 10px; border-radius: var(--r-md); transition: background-color .12s, color .12s; }
.side .nav .grp { font-size: 11px; font-weight: 600; padding: var(--s-4) 10px var(--s-1); }
.side-foot { font-size: var(--fs-xs); }
.top { min-height: 56px; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) { main { padding: var(--s-3) var(--s-4) var(--s-6); } }
@media (max-width: 800px) {
  /* comfortable touch targets */
  .btn { min-height: var(--ctl-h-touch); } .btn.small { min-height: 32px; }
  select, .inp, .top #search { min-height: var(--ctl-h-touch); font-size: 16px; } /* 16px stops iOS zooming into inputs */
  .card { padding: var(--s-3); }
  h1 { font-size: 19px; } h2 { font-size: 15px; }
  .row-between { align-items: center; }
  dialog { padding: var(--s-3); border-radius: var(--r-lg); }
}
@media (max-width: 600px) { main { padding: var(--s-3) var(--s-3) var(--s-6); gap: var(--s-3); } }

/* ---------- motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- fixes from the Playwright sweep ---------- */
/* OI Flow: its two tables ran ~93px past the screen at 1024px; scroll inside their box instead */
#o3-shifts, #o3-top { overflow-x: auto; max-width: 100%; }
/* B / S quick-trade buttons in table cells were 16x15px: too small to tap on phones and tablets */
@media (max-width: 800px) { .mini-trade button { min-width: 28px; min-height: 28px; font-size: 12px; } }
@media (pointer: coarse) { .mini-trade button { min-width: 28px; min-height: 28px; } }

/* =====================================================================
   Strict layout pass (360 / 390 / 768 / 1024 / 1440)
   ===================================================================== */
/* phones: 16px side gutter (was 12px, so cards touched within 12px of the edge) */
@media (max-width: 600px) { main { padding-left: var(--s-4); padding-right: var(--s-4); } }

@media (max-width: 800px) {
  /* every tap target at least 44x44 */
  .btn, .btn.small, .btn.icon, .btn.icon-always, select, .inp, .top #search, .chips button, .chips .inp { min-height: 44px; }
  .btn.icon, .btn.icon-always, #side-toggle, #theme-btn { min-width: 44px; }
  .chips button { padding: 0 var(--s-4); font-size: 14px; }
  input[type="range"] { min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; margin: 11px; }
  a.small, .mini a, .row-between > a, span > a.sym, td a, .muted > a { display: inline-flex; align-items: center; min-height: 44px; }
  .mini-trade button, td button { min-width: 44px; min-height: 44px; }
  .side .nav a { min-height: 44px; }
  /* "Full view" link: in normal flow above its graph instead of floating over the graph's own controls */
  .fv-anchor { height: auto; display: flex; justify-content: flex-end; margin-bottom: var(--s-1); }
  .fv-anchor .fv-btn { position: static; display: inline-grid; place-items: center; width: 44px; height: 44px; opacity: .8; }
  /* body text 16px on phones; captions and labels no smaller than 14px */
  body, .card p, li, .legend span, .brow span, .lesson, .kpi span { font-size: 16px; }
  .smmap-sub, .smmap-sub span, .smmap-live, .smmap-kicker, .smmap-legend { font-size: 14px; }
}

/* light theme: the SMC map's green kicker line was 2.2:1 on the light map; darker green is 5:1 */
.smmap-light .smmap-kicker { color: #15803d; }

/* ---- strict pass, round 2 ---- */
@media (max-width: 800px) {
  /* narrow controls: 44px wide as well as tall */
  .btn, .btn.small, a.small, .mini a, span > a.sym, td a.sym, .muted > a, .leg button { min-width: 44px; justify-content: center; }
  .leg button { min-height: 44px; }
  /* checkbox + its text form one 44px-tall target (the whole label is clickable) */
  label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { display: inline-flex; align-items: center; min-height: 44px; gap: 4px; }
  label > input[type="checkbox"], label > input[type="radio"] { margin: 0 6px 0 0; }
  /* remaining body-type text to 16px */
  .mini, .mini span, .mini a, .ev, .ev span, .gloss div, .quad > div, .dk-kv > span, span > a.sym, .o-pick > a.btn { font-size: 16px; }
  /* captions, legends and chart notes: 14px floor (they label data; 16px would crowd the charts) */
  .dk-cap, .o3-legend span, .o3-sum-h, .rb-legend span, .leg span, .row-between > span.cat, .sec > span, h2 > span#rp-at { font-size: 14px; }
}

/* light theme: the shared green (#15803d) was 4.46:1 on grey panels; #137636 is 5.0:1 on #eef2f6 and 5.6:1 on white */
:root[data-theme="light"] { --up: #137636; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --up: #137636; } }
/* SMC map sub-line uses inline bright green/red (2.2:1 on the light map) */
.smmap-light .smmap-sub span[style*="#22c55e"] { color: #137636 !important; }
.smmap-light .smmap-sub span[style*="#f43f5e"] { color: #be123c !important; }
/* heat-coloured table cells: green/red text on a green/red fill was 2.2:1; use the normal text colour on the fill */
td[style*="background:rgba(34,197,94"], td[style*="background:rgba(244,63,94"], td[style*="background:rgba(239,68,68"] { color: var(--text) !important; }
/* light map sub-lines: any inline-coloured count (buildup amber/sky/green/red) darkened to >= 4.5:1 on the light map */
.smmap-light .smmap-sub span[style*="color"] { filter: brightness(.6) saturate(1.3); }
/* narrow phones: with 44px buttons the "Sign in" button wrapped to a row of its own (top bar 160px tall);
   the market-status pill gives way and the coloured dot keeps the status (its tooltip says which) */
@media (max-width: 420px) { .top #stream { display: none; } .top .status { gap: 0; } }

/* =====================================================================
   Responsive layout pass: grids follow the space they really have
   (the 216px sidebar is part of the screen, so viewport breakpoints alone were wrong)
   ===================================================================== */
/* grid children may shrink below their content's natural width (stops inputs pushing cards apart) */
.grid2 > *, .grid3 > *, .form > *, .futures > *, .grid-st > *, .grid-of > *, .grid-fp > *, .calc-grid > *, .quad > *, .tk-grid > * { min-width: 0; }
.form .inp, .form select, .form input, .tk-grid .inp, .tk-grid select, .calc-grid .inp, .calc-grid select, .rb-grid .inp, .rb-grid select { width: 100%; min-width: 0; box-sizing: border-box; }

/* card grids: as many columns as fit, never narrower than readable, never wider than the screen */
.grid3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.futures { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.form { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.quad { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.calc-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
.learn-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.scan-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.stock-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); }
.gloss { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.feed { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.cards7 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)); }
/* side panel + main area layouts: stack while the content area is narrow (sidebar visible up to 1240px screen) */
@media (max-width: 1240px) {
  .grid-st, .grid-of, .grid-fp { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) { .cards7 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* wide tables: show that there is more to the side (shadow at the edge that still has columns) */
.tbl-wrap, [style*="overflow-x:auto"], [style*="overflow-x: auto"], #o3-shifts, #o3-top {
  background:
    linear-gradient(to right, var(--panel) 30%, transparent) left / 32px 100% no-repeat local,
    linear-gradient(to left, var(--panel) 30%, transparent) right / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.16), transparent) left / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.16), transparent) right / 12px 100% no-repeat scroll;
  -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
}
@media (max-width: 900px) {
  .page table { background:
    linear-gradient(to right, var(--panel) 30%, transparent) left / 32px 100% no-repeat local,
    linear-gradient(to left, var(--panel) 30%, transparent) right / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.16), transparent) left / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.16), transparent) right / 12px 100% no-repeat scroll; }
}
/* "waiting for data" / empty-state rows span the table: let them wrap instead of being cut off */
td[colspan] { white-space: normal; }

/* market maps: below 800px keep the drawing at a readable size and let it pan sideways */
@media (max-width: 800px) {
  :has(> svg.smmap-svg) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  svg.smmap-svg { min-width: 760px; }
  .fs-wrap:fullscreen svg.smmap-svg, .fs-wrap.fs-fake svg.smmap-svg { min-width: 0; }
}
/* phones: no sideways panning, the SMC Map fits the screen (tap a tile to open its chart) */
@media (max-width: 700px) {
  #sm-map:has(> svg.smmap-svg) { overflow-x: clip; }
  #sm-map svg.smmap-svg { min-width: 0; }
}

/* phones: the header scrolls away with the page instead of permanently covering a seventh of the screen */
@media (max-width: 600px) { .top { position: relative; } }
/* "Full view" link inside a flex or grid row (Desk panes): its own full-width line, not an extra column */
@media (max-width: 800px) {
  .fv-anchor { flex: 0 0 auto; grid-column: 1 / -1; width: 100%; }  /* auto, not 100%: in a column flex (SMC Map) 100% is a height */
  .dk-row { flex-wrap: wrap; }
}
/* Desk: 2- and 3-pane rows stack below 900px (each pane was ~330px wide on a tablet) */
@media (max-width: 900px) { .dk-row.c2, .dk-row.c3 { grid-template-columns: minmax(0, 1fr); } }

/* readable floor: <small> inside tables and stats never drops below 11px (Hedgewall's smallest is ~10.3px) */
small, td small, .stat small { font-size: max(11px, .85em); }
/* index strip under the top bar (every page): index futures + breadth; scrolls inside itself on phones, never the page */
.top { flex-wrap: wrap; row-gap: 6px; }
.idx-strip { order: 20; flex: 1 0 100%; display: flex; gap: 4px 18px; align-items: center; overflow-x: auto; scrollbar-width: none; margin: 0 -4px -4px; padding: 2px 4px; font-size: 12px; min-height: 22px; }
.idx-strip:empty { display: none; }
.idx-strip .idx { display: inline-flex; gap: 6px; align-items: baseline; white-space: nowrap; background: none; border: 0; padding: 0; color: var(--text); font: inherit; cursor: pointer; }
.idx-strip .idx b { font-weight: 600; color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.idx-strip .idx:hover b { color: var(--acc); } .idx-strip .idx-breadth { cursor: default; margin-left: auto; }
/* KPI / stat values: shrink a little on narrower cards; a value that still does not fit wraps instead of spilling out */
.stat span, .kpi span { font-size: clamp(14px, 1.25vw, 18px); overflow-wrap: anywhere; }
/* plain-language summary line under a KPI row (GEX, OI analysis) */
.v-line { font-size: 13px; color: var(--muted); padding: 8px 12px; border-left: 3px solid var(--line); background: var(--panel); border-radius: 0 var(--r-md) var(--r-md) 0; }
.v-line b { color: var(--text); margin-right: 4px; } .v-line.up { border-left-color: var(--up); } .v-line.up b { color: var(--up); } .v-line.dn { border-left-color: var(--dn); } .v-line.dn b { color: var(--dn); }
/* text size switch (Aa in the top bar) */
:root[data-textsize="compact"] main { zoom: .9; } :root[data-textsize="large"] main { zoom: 1.12; }
#size-btn { font-weight: 700; letter-spacing: -.02em; } #size-btn[data-size="compact"] { font-size: 11px; } #size-btn[data-size="large"] { font-size: 16px; }
/* per-card "updated" time */
.asof { font: 400 11px var(--mono); color: var(--muted); opacity: .75; margin-left: 8px; white-space: nowrap; }
.asof::before { content: "· "; }
/* research: long sections fold */
.rs-sec > summary { list-style: none; cursor: pointer; } .rs-sec > summary::-webkit-details-marker { display: none; }
.rs-sec > summary h3 { display: inline-flex; gap: 8px; align-items: baseline; } .rs-sec > summary h3::before { content: "▸"; color: var(--muted); transition: transform .15s; } .rs-sec[open] > summary h3::before { transform: rotate(90deg); }
/* sidebar: foldable groups, no sideways scrollbar */
.side { overflow-x: hidden; }
.side .nav .grp { cursor: pointer; user-select: none; display: flex; justify-content: space-between; align-items: center; }
.side .nav .grp::after { content: "▾"; font-size: 11px; opacity: .6; transition: transform .15s; } .side .nav .grp.shut::after { transform: rotate(-90deg); }
.side .nav .grp:hover { color: var(--text); }
.side .nav a.nav-hide { display: none; }
/* OI change chart summary line */
.oichg-sum { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 12px; color: var(--muted); margin: -4px 0 8px; }
.oichg-sum b:not(.up):not(.dn) { color: var(--text); }
/* full view: OI charts fill the tab instead of staying 260px tall */
#fv-slot .oi-chart { height: calc(100vh - 170px); min-height: 320px; }
/* OI analysis: all eight KPIs on one row on desktop; captioned history sub-charts */
#oi-kpis { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
.oi-sub + .oi-sub { margin-top: 10px; } .oi-sub .legend { margin: 0 0 4px; display: flex; gap: 6px 12px; align-items: baseline; flex-wrap: wrap; }
.oi-sub .svgbox { min-height: 0; }
/* OI flow: build-up type filter chips (the legend doubles as the filter) */
#o3-cls button { display: inline-flex; align-items: center; gap: 6px; font: inherit; color: inherit; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
#o3-cls button[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
#o3-cls button[aria-pressed="true"] { border-color: color-mix(in srgb, var(--acc) 50%, var(--line)); }
#o3-cls .o3-cls-all { color: var(--acc); }
#o3-cls { pointer-events: auto; }
/* OI flow: plain desk look (site panel colours, no gradient backdrop, no coloured headline) */
.o3-wrap, .o3-wrap .o3-legend, .o3-wrap .o3-summary, .o3-wrap #o3-canvas { background: var(--panel); color: var(--text); }
.o3-wrap .o3-legend, .o3-wrap .o3-summary { border-bottom: 1px solid var(--line); border-top: 0; }
.o3-wrap .o3-key-note, .o3-wrap .o3-status { color: var(--muted); }
.o3-wrap .o3-sum-h, .o3-wrap.o3-light .o3-sum-h { color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: 11px; }
.o3-wrap .o3-dot { border-radius: 2px; }
.o3-wrap .o3-dot-move { background: var(--muted); }
.o3-wrap .o3-tip { background: var(--panel2); color: var(--text); border-color: var(--line); border-radius: 6px; }
#o3-cls button { border-radius: 4px; }
/* chart forced dark on a light site: keep dark panel colours inside it */
:root[data-theme="light"] .o3-wrap:not(.o3-light) { --panel: #151a21; --panel2: #1c222b; --text: #d5dbe3; --muted: #8b95a3; --line: #2a313b; }
/* Desk workspaces: tabs along the bottom, manage dialog, selected row, fit to screen, 5 and 6 panel rows */
.dk-tabs { position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; gap: 6px; margin: 12px -4px 0; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
#dk-tabs-list { display: flex; gap: 2px; overflow-x: auto; min-width: 0; scrollbar-width: thin; }
#dk-tabs-list button { flex: none; background: none; border: 0; border-radius: 6px; padding: 6px 12px; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
#dk-tabs-list button:hover { color: var(--text); background: var(--panel2); }
#dk-tabs-list button[aria-selected="true"] { color: var(--text); background: var(--panel2); box-shadow: inset 0 -2px 0 var(--acc); font-weight: 600; }
.dk-tabs .grow { flex: 1; }
.dk-manage { width: min(640px, 94vw); border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); padding: 14px 16px; }
.dk-manage::backdrop { background: rgba(0,0,0,.35); }
.dk-manage h3 { margin: 0; }
#dk-manage-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; }
#dk-manage-list li { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 8px; border-radius: 6px; }
#dk-manage-list li.cur { background: var(--panel2); }
#dk-manage-list li > small { margin-left: auto; }
.dk-man-acts { display: flex; gap: 4px; flex-wrap: wrap; }
.dk-man-acts .danger { color: var(--dn); border-color: var(--dn); }
.dk-ren { display: flex; gap: 4px; }
.dk-rowbar { cursor: pointer; border-radius: 6px; padding: 2px 4px; }
.dk-rowbar.sel { box-shadow: inset 2px 0 0 var(--acc); }
.dk-rowbar.sel > span { color: var(--acc); }
.dk-shape[aria-pressed="true"] { border-color: var(--acc); color: var(--acc); }
.dk-pick h4 .inp { display: inline-block; width: auto; margin-left: 4px; text-transform: none; letter-spacing: 0; }
#dk-fit[aria-pressed="true"] { border-color: var(--acc); color: var(--acc); }
.dk-fit .dk-pane { height: var(--dk-h); min-height: 0; overflow: hidden; }
.dk-fit .dk-body { overflow: auto; }
.dk-fit .dk-body svg, .dk-fit .dk-body canvas { max-height: calc(var(--dk-h) - 70px); }
@media (max-width: 1400px) { .dk-row.c5, .dk-row.c6 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; } }
@media (max-width: 900px) { .dk-row.c5, .dk-row.c6 { grid-template-columns: minmax(0, 1fr) !important; } }
.dk-pick { max-height: calc(100vh - 150px); overflow-y: auto; }
/* Live pages (live.js): one animated chart per page, desk look shared with OI Flow Live */
.lv-wrap { position: relative; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.lv-kv { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.lv-kv b { display: block; font: 600 15px var(--mono); color: var(--text); }
.lv-kv b.up { color: var(--up); } .lv-kv b.dn { color: var(--dn); }
.lv-canvas { height: 62vh; min-height: 380px; }
.lv-canvas canvas { display: block; }
.lv-status { padding: 6px 14px; border-top: 1px solid var(--line); }
.lv-tip { position: absolute; pointer-events: none; z-index: 3; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; font-size: 12px; line-height: 1.45; white-space: nowrap; }
.lv-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.lv-h4 { margin: 12px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
@media (max-width: 700px) { .lv-canvas { height: 70vh; min-height: 420px; } }
/* desk on phones: the workspace tab bar scrolls inside itself instead of widening the page */
#page-desk > * { min-width: 0; max-width: 100%; }
.dk-tabs { min-width: 0; }
#dk-tabs-list { flex: 0 1 auto; }
@media (max-width: 700px) { #dk-tab-manage { font-size: 0; } #dk-tab-manage::after { content: "Manage"; font-size: 13px; } }
#page-desk { grid-template-columns: minmax(0, 1fr); }
/* live pages: keep the top numbers clear of the "Full view" link */
.lv-kv { padding-right: 104px; }
/* touch: filter chips, workspace tabs and fold-out toggles big enough to tap */
@media (pointer: coarse) { #o3-cls button, #dk-tabs-list button, details > summary { min-height: 40px; } #o3-cls button, #dk-tabs-list button { padding-inline: 12px; } }
.o3-wrap .o3-legend { padding-right: 104px; }
@media (max-width: 700px) { .o3-wrap .o3-status { position: static; order: 4; padding: 6px 12px; } }

/* ---------- embed mode (dashboard panels) ---------- */
html.embed body { display: block; }
html.embed .side, html.embed .top, html.embed .site-foot, html.embed .page > section.row-between h2 .muted { display: none !important; }
html.embed main { max-width: none; padding: 6px 8px; }

/* ---------- Dashboard ---------- */
.db-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.db-grid { display: grid; gap: 12px; grid-template-columns: repeat(var(--db-cols, 2), minmax(0, 1fr)); }
@media (max-width: 900px) { .db-grid { grid-template-columns: 1fr; } }
.db-panel { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.db-panel.wide { grid-column: 1 / -1; }
.db-head { display: flex; gap: 6px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.db-head b { flex: 1; }
.db-head select, .db-head .btn { font-size: 12px; padding: 2px 6px; }
.db-panel iframe { border: 0; width: 100%; display: block; background: var(--panel); }
