/* PelosiTracker dashboard — single-layer stylesheet. ONE layer only: never
   append an override pass; change rules in place. Order: tokens, reset, shell,
   nav, primitives, components, responsive, motion. Invariants: every value
   from a token; nothing under 12px; uppercase only on table column headers;
   numerics in --font-mono with tabular-nums; --elevation is for popovers and
   dialogs only. */
/* THEME. Two token blocks, never two stylesheets and never an override pass:
   because only one colour literal existed outside this block, re-declaring the
   same names flips the entire interface with no component rule edits. Dark
   ("cyber") is the default; [data-theme="light"] further down restores the
   light editorial palette. */
:root {
  color-scheme: dark;
  /* Surfaces — near-black with a blue-violet cast, stepped far enough apart
     that a card, an inset well and a hover state stay distinguishable. */
  --page:          #08080d;
  --bg:            #0f0f17;
  --surface:       #16161f;
  --surface-sunk:  #1d1d29;
  --border:        #2b2b3b;
  --border-strong: #414157;

  /* Text. Never pure white on near-black — it vibrates and smears. */
  --text:           #eceef5;
  --text-secondary: #b6b8ca;
  /* Raised from #82859d, which sat at 4.9:1 — effectively on the AA floor. */
  --text-muted:     #9295ab;

  /* Accent — the Cyberpunk 2077 acid yellow. Alone among the neons here it
     works as both a fill and a text colour: 14.6:1 on --bg, and it takes
     near-black text at 13.5:1. */
  --accent:       #fcee0a;
  --accent-hover: #fff64d;
  --accent-wash:  #21200a;
  --accent-edge:  #5c5710;
  --on-accent:    #08080d;

  /* Semantic — neons, each re-derived for AA on --bg. The light theme's
     #0a7350 and #c02a1c sit near 2:1 here and would be unreadable. */
  --positive: #2ee6a0;
  --negative: #ff5f7e;
  --warning:  #ffb02e;
  --info:     #34e0f2;
  --positive-wash: #06231a;
  --negative-wash: #2a0c14;
  --warning-wash:  #241a05;
  --info-wash:     #052227;

  /* Theme-dependent values that would otherwise be literals inside a rule. */
  /* Reactive X-glyph field. The whole url() is the token because var() does
     not interpolate inside a data URI. Two tiles at different sizes, offset
     against each other, so the field scatters instead of gridding. */
  --xfield-red: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="46" height="46" viewBox="0 0 46 46"%3E%3Cg stroke="%23ff2d55" stroke-width="1.7" stroke-linecap="round" fill="none"%3E%3Cpath d="M7 7l9 9M16 7l-9 9"/%3E%3Cpath d="M30 27l9 9M39 27l-9 9"/%3E%3C/g%3E%3C/svg%3E');
  --xfield-teal: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="62" height="62" viewBox="0 0 62 62"%3E%3Cg stroke="%2334e0f2" stroke-width="1.7" stroke-linecap="round" fill="none"%3E%3Cpath d="M40 9l9 9M49 9l-9 9"/%3E%3Cpath d="M11 38l9 9M20 38l-9 9"/%3E%3C/g%3E%3C/svg%3E');
  /* Pointer position, in px, written by index.js. Starts off-screen so the
     bright field is hidden until the pointer actually enters the page. */
  --field-x: -9999px;
  --field-y: -9999px;
  --field-r: 320px;

  --backdrop: rgba(4, 4, 8, .74);
  /* Sign-in HUD only, never text. A hotter red than --negative, which is tuned
     for AA body copy and reads as muted maroon at instrument scale, plus the
     cyan used for the chromatic ghost. */
  /* Launcher-tile hues with no semantic equivalent to borrow. */
  --tile-violet: #8b7bff;
  --tile-mint:   #4ad6c0;
  --tile-pink:   #ff8ab0;
  --hud-red:   #ff2038;
  --hud-ghost: #2ad4ea;
  --hud-glow-ghost: rgba(42, 212, 234, .5);
  --hud-glow-red:   rgba(255, 32, 56, .5);
  --hud-bloom:      rgba(255, 32, 56, .32);
  --hud-node-glow:  rgba(255, 32, 56, .85);
  --hud-wash:       rgba(120, 12, 26, .3);
  --hud-cell-glow:  rgba(46, 230, 160, .45);
  /* Sign-in copy runs slightly warm so it belongs to the red instrumentation
     instead of reading as cold UI chrome dropped on top of it. */
  --hud-ink:       #f2e8ea;
  --hud-ink-dim:   #cbb2b7;
  --hud-red-hover: #ff4759;
  --select-chevron: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6"%3E%3Cpath d="M1 1l4 4 4-4" fill="none" stroke="%23a7a9bd" stroke-width="1.5" stroke-linecap="round"/%3E%3C/svg%3E');

  /* Type scale — 12px floor */
  --text-xs:   12px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;

  /* Spacing — 4px base */
  --sp-05: 2px;  /* stacked label/value pairs only */
  --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;  --sp-4: 16px;  --sp-5: 20px;
  --sp-6: 24px;  --sp-8: 32px;  --sp-12: 48px; --sp-16: 64px;
  /* Horizontal page gutter. The sticky bars bleed by exactly this much, so
     their background reaches the page edges while their content stays aligned
     with the panels below. Redefined per breakpoint further down. */
  --gutter: var(--sp-6);
  --sticky-offset: 104px;  /* clears the two sticky nav bars */
  /* Hard edges. Soft 18px cards read as friendly SaaS; this UI is meant to
     look like instrumentation. The light theme keeps the rounded values. */
  --radius:      2px;
  --radius-card: 3px;
  --radius-pill: 999px;

  /* One easing/duration for every state change, so hovers and selections feel
     like one object rather than six widgets. */
  --ease: cubic-bezier(.2, 0, .2, 1);
  --dur: 130ms;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  /* The only allowed elevation: popovers and dialogs. On near-black a plain
     drop shadow is invisible, so it carries a hairline to define the edge. */
  --elevation: 0 0 0 1px var(--border-strong), 0 16px 40px -12px rgba(0, 0, 0, .9);
  /* Selective neon: active/armed controls only, never a decorative surface. */
  --glow: 0 0 0 1px var(--accent-edge), 0 0 18px -4px rgba(252, 238, 10, .5);
  /* Hover bloom for controls that are not currently carrying the accent fill. */
  --glow-soft: 0 0 0 1px var(--border-strong), 0 0 18px -8px rgba(252, 238, 10, .55);
  /* A 1px top inner highlight reads as a lit edge and is what makes a control
     look raised rather than painted on. */
  --lift: inset 0 1px 0 rgba(255, 255, 255, .07);
  --focus: var(--accent);
}

/* Light editorial palette, kept intact and reachable via
   <html data-theme="light">. Same names, so nothing else changes. */
[data-theme="light"] {
  color-scheme: light;
  --page: #f0f0f4; --bg: #ffffff; --surface: #f6f6fa; --surface-sunk: #eeeef5;
  --border: #e4e4ee; --border-strong: #d2d2e0;
  --text: #14141b; --text-secondary: #55556a; --text-muted: #6a6a80;
  --accent: #5546e8; --accent-hover: #4436d4; --accent-wash: #f0eefe;
  --accent-edge: #c9c2fb; --on-accent: #ffffff;
  --positive: #0a7350; --negative: #c02a1c; --warning: #a8560b; --info: #3a3a52;
  --positive-wash: #e9faf2; --negative-wash: #fdf0ee;
  --warning-wash: #fdf6e8; --info-wash: #f3f3f8;
  --radius: 8px; --radius-card: 18px;
  --tile-violet: #6d5ce0;
  --tile-mint:   #0f9c86;
  --tile-pink:   #c8437a;
  --backdrop: rgba(26, 26, 26, .45);
  --hud-red: #c02a1c; --hud-ghost: #0e7090;
  --hud-glow-ghost: rgba(14, 112, 144, .3); --hud-glow-red: rgba(192, 42, 28, .3);
  --hud-bloom: rgba(192, 42, 28, .18); --hud-node-glow: rgba(192, 42, 28, .45);
  --hud-wash: rgba(192, 42, 28, .06); --hud-cell-glow: rgba(10, 115, 80, .25);
  --select-chevron: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6"%3E%3Cpath d="M1 1l4 4 4-4" fill="none" stroke="%2355556a" stroke-width="1.5" stroke-linecap="round"/%3E%3C/svg%3E');
  --elevation: 0 4px 12px rgba(0, 0, 0, .08);
  --glow: 0 0 0 3px var(--accent-wash);
  --glow-soft: 0 0 0 1px var(--border-strong), 0 0 14px -8px rgba(85, 70, 232, .5);
  --lift: inset 0 1px 0 rgba(255, 255, 255, .7);
  --focus: #14141b;
}

/* ---------------------------------------------------------------- reset --- */
*, *::before, *::after { box-sizing: border-box; }
/* The canvas colour lives on html so the two fixed field layers on body can
   sit above it without a negative z-index (which would drop them behind it). */
html { -webkit-text-size-adjust: 100%; background: var(--page); }
body {
  margin: 0; background: transparent; color: var(--text); font: var(--text-base)/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}

/* Reactive X-glyph field ---------------------------------------------------
   Two fixed layers behind the whole interface. ::before is the resting field,
   dim enough to read as texture; ::after is the same field at full strength,
   masked to a soft disc that follows the pointer, so the glyphs resolve only
   where you are looking. Both are pointer-events:none and sit at z-index 0,
   with the content raised to 1 — nothing is ever drawn over text, which is
   what made the old scanline overlay unusable.
   These are the only gradient functions in the stylesheet, and they are masks
   on a background layer, not fills on a component surface. */
body::before, body::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: var(--xfield-red), var(--xfield-teal);
  background-position: 0 0, 22px 14px;
}
/* Panels stay fully opaque on purpose. Making them translucent would let the
   glyph strokes under the text shift its effective contrast, which is exactly
   the readability problem this rebuild removed. The field lives in the gutters
   and margins instead. */
body::before { opacity: .14; }
/* The other half of the sign-in hand-off: the resting field arrives from a
   larger scale as the HUD disperses outward, so the glyphs appear to settle out
   of it. Set for one run by index.js and removed afterwards. */
@keyframes xfield-arrive { from { opacity: 0; transform: scale(1.4); } to { opacity: .14; transform: none; } }
body.is-entering::before { animation: xfield-arrive 1.15s var(--ease); }
body::after {
  opacity: .7;
  /* A disc at the pointer. transparent->black in a mask alpha-reveals. */
  -webkit-mask-image: radial-gradient(circle var(--field-r) at var(--field-x) var(--field-y), #000 0%, rgba(0,0,0,.55) 45%, transparent 72%);
  mask-image: radial-gradient(circle var(--field-r) at var(--field-x) var(--field-y), #000 0%, rgba(0,0,0,.55) 45%, transparent 72%);
}
/* The field belongs to the dark theme only; the light theme is editorial. */
[data-theme="light"] body::before, [data-theme="light"] body::after { display: none; }
/* Dashboard price tapes. Same layer as the glyph field: fixed, behind
   everything, pointer-inert. Panels are opaque, so these read only in the
   gutters — motion at the edge of vision, never under text. */
.bg-tapes {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  /* Same resting weight as the glyph field. Decoration must not compete with
     the interface; the tapes are meant to be noticed only peripherally. */
  opacity: .13;
}
/* No bloom on this layer: the glow haloed into the gutters beside panel edges. */
.bg-tapes .hud-tape { filter: none; opacity: 1; }
.bg-tapes svg { width: 100%; height: 100%; display: block; }
[data-theme="light"] .bg-tapes { display: none; }

/* Raise every top-level surface above the field. */
.wrap, #login-overlay, .app-dialog, .info-popover, .skip-link { position: relative; z-index: 1; }
#login-overlay { z-index: 1000; }

/* Headings get slight negative tracking; at these sizes default spacing reads
   loose and dated. Numerals stay lining so figures in headings still align. */
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; letter-spacing: -.011em; }
h1 { font-size: var(--text-xl); letter-spacing: -.018em; }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-base); }
p  { margin: 0 0 var(--sp-3); }
ul, ol { margin: 0 0 var(--sp-3); padding-left: var(--sp-6); }
code { font: var(--text-sm)/1.4 var(--font-mono); }
/* small/sub/sup default to a relative `smaller`, which lands below the 12px
   floor wherever they nest. Pin them to the token instead. */
small, sub, sup { font-size: var(--text-xs); }
a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--text-secondary); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* One transition for every interactive surface. Colour and border only, never
   layout, so nothing reflows on hover. */
a, button, input, select, textarea, summary,
.best-bet, .game, .event-jump, .research-section-link, .research-section-top,
.us-policy-handoff-link, .info-btn, .us-mode-switch span, tbody tr {
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
  color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--sp-05); }
/* A pressed control should feel like it took the click. */
button:active:not(:disabled) { transform: translateY(.5px); }

/* Numbers align in columns wherever they appear. */
.value, .us-performance-value, .score, .mtile .v, td, th,
.us-position span, .us-journal-metrics span { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- shell --- */
.skip-link {
  position: fixed; top: var(--sp-2); left: var(--sp-3); z-index: 1200; padding: var(--sp-2) var(--sp-3); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: var(--text-sm); transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
.wrap { max-width: 1200px; margin: 0 auto; padding: var(--sp-6) var(--gutter) var(--sp-16); }
.research-workstation .wrap { max-width: 1320px; }
header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding-bottom: var(--sp-4); margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); }
.brand h1 { font-size: var(--text-xl); letter-spacing: -.01em; }
.brand small { display: block; margin-top: var(--sp-05); color: var(--text-secondary); font-size: var(--text-sm); }
.dot { width: var(--sp-2); height: var(--sp-2); border-radius: 50%; background: var(--positive); flex: 0 0 auto; }
.header-brand { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--sp-2); }
.workstation-chip {
  padding: var(--sp-1) var(--sp-2); border: 1px solid var(--border-strong); border-radius: var(--radius-pill); color: var(--text-secondary);
  font-size: var(--text-xs); white-space: nowrap;
}
.config {
  padding: var(--sp-1) var(--sp-2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text-secondary); font: var(--text-xs)/1.4 var(--font-mono);
}
.section-gap { margin-bottom: var(--sp-6); }
.is-hidden { display: none; }

/* ----------------------------------------------------------- navigation --- */
.tab-carousel {
  position: sticky; top: 0; z-index: 40; display: flex; gap: var(--sp-1); margin: 0 calc(var(--gutter) * -1) var(--sp-6);
  padding: var(--sp-2) var(--gutter); background: var(--bg);
  border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none;
}
.tab-carousel::-webkit-scrollbar { display: none; }
.tab-carousel .pill {
  flex: 0 0 auto; min-height: 36px; padding: var(--sp-2) var(--sp-3); border: 1px solid transparent; border-radius: var(--radius);
  background: var(--surface); border-color: var(--border); box-shadow: var(--lift);
  color: var(--text-secondary); font-size: var(--text-sm); font-weight: 500; white-space: nowrap; cursor: pointer;
}
.tab-carousel .pill:hover { background: var(--surface-sunk); color: var(--text); box-shadow: var(--glow-soft), var(--lift); }
/* The selected workspace is the accent's permanent home, so the brand colour
   is present on every screen without being sprayed around. */
.tab-carousel .pill.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tab-carousel .pill.active:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
/* Selective neon: only the elements that already carry the accent as a fill,
   never a decorative surface. */
.tab-carousel .pill.active, .primary { box-shadow: var(--glow), var(--lift); }
/* Sticky bars sit on a translucent, blurred backdrop so long tables scrolling
   underneath stay legible without a shadow. */
.tab-carousel, .research-section-nav, .us-policy-rail, .us-policy-footer {
  background: color-mix(in srgb, var(--page) 86%, transparent); backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}
@supports not (backdrop-filter: blur(1px)) {
  .tab-carousel, .research-section-nav, .us-policy-rail, .us-policy-footer { background: var(--page); }
}

/* Workspace map. Phase 3 turns these into real view switches; the styling
   here already reads as a segmented control rather than a link list. */
.research-section-nav {
  position: sticky; top: 53px; z-index: 35; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3);
  margin: 0 calc(var(--gutter) * -1) var(--sp-6); padding: var(--sp-2) var(--gutter);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.research-section-nav-label { color: var(--text-muted); font-size: var(--text-xs); white-space: nowrap; }
.research-section-nav-scroll { display: flex; min-width: 0; gap: var(--sp-1); overflow-x: auto; scrollbar-width: none; }
.research-section-nav-scroll::-webkit-scrollbar { display: none; }
/* A resting surface and hairline, not bare text on the page: with a transparent
   background these read as a row of labels and gave no sign they were
   pressable until hovered. */
.research-section-link,
.research-section-top {
  display: inline-flex; flex: 0 0 auto; min-height: 32px; align-items: center; justify-content: center; padding: 0 var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--lift);
  color: var(--text-secondary); font-size: var(--text-sm); text-decoration: none;
  white-space: nowrap;
}
.research-section-link:hover,
.research-section-top:hover {
  background: var(--surface-sunk); color: var(--text); box-shadow: var(--glow-soft), var(--lift);
}
.research-section-link.active {
  background: var(--accent-wash); border-color: var(--accent-edge); color: var(--accent); font-weight: 600;
  box-shadow: var(--glow-soft), var(--lift);
}
.research-anchor, #us-activity { scroll-margin-top: var(--sticky-offset); }
.carousel { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-3); padding-bottom: var(--sp-1); overflow-x: auto; }
.carousel .pill {
  flex: 0 0 auto; min-height: 32px; padding: 0 var(--sp-3); border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--bg); color: var(--text-secondary); font-size: var(--text-sm); white-space: nowrap; cursor: pointer;
}
.carousel .pill:hover { border-color: var(--text-secondary); color: var(--text); }
.carousel .pill.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.discover-league-filter { margin: var(--sp-3) 0 var(--sp-1); }

/* ----------------------------------------------------------- primitives --- */
/* Data panels stay one flat surface with a hairline: tinting them would
   collapse the contrast against the wells, tables and forms inside. The
   tinted bento fill is used on the overview launcher, where nothing dense
   competes. */
.panel, .event, .empty {
  position: relative; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-card); min-width: 0;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
/* A short accent rule at the top-left of every panel, so a screenful of panels
   has a rhythm instead of reading as undifferentiated boxes. */
.panel::before {
  content: ""; position: absolute; top: -1px; left: -1px; width: 52px; height: 2px;
  background: var(--accent); border-radius: var(--radius-card) 0 0 0; opacity: .5;
}
.panel:hover { border-color: var(--border-strong); }
/* Views fade and lift in on a route change rather than snapping. */
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
[data-research-view]:not([hidden]) { animation: view-in .26s var(--ease); }
/* HUD corner brackets. Purely decorative, drawn with borders on pseudo
   elements — no clip-path, so nothing clips content, shadows or sticky
   children. Diagonally opposed so a panel reads as a framed instrument. */
.panel::before, .panel::after {
  content: ""; position: absolute; width: 10px; height: 10px; pointer-events: none;
  border-color: var(--accent-edge); border-style: solid; border-width: 0;
}
.panel::before { top: -1px; left: -1px; border-top-width: 1px; border-left-width: 1px; }
.panel::after { right: -1px; bottom: -1px; border-bottom-width: 1px; border-right-width: 1px; }
[data-theme="light"] .panel::before, [data-theme="light"] .panel::after { display: none; }
/* 20px, not 16: at 16 the panels read cramped against a 12px type floor. */
.pad { padding: var(--sp-5); }
.title { margin: 0 0 var(--sp-3); color: var(--text); font-size: var(--text-lg); font-weight: 600; }
/* Two-tone heading: the subject stays ink, the qualifying phrase drops to
   secondary at the same size. Reads as one sentence, scans as a label. */
.title > span, .bento-card h3 > span { color: var(--text-secondary); font-weight: 500; }

/* Bento launcher — white tiles on the grey canvas. */
.bento-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--sp-3); margin-top: var(--sp-4); }
.bento-card {
  position: relative; display: flex; flex-direction: column; gap: var(--sp-2); grid-column: span 2;
  padding: var(--sp-5); border: 1px solid var(--border); border-radius: var(--radius-card);
  background: var(--bg); color: var(--text); text-align: left; text-decoration: none; min-height: 148px; overflow: hidden;
}
.bento-card.is-wide { grid-column: span 3; }
/* Each tile owns a hue, set once here and inherited by its rule, arrow and
   glow. Colour-coding the launcher is what stops the overview reading as nine
   identical grey boxes, and it doubles as a recognition cue. */
.bento-card:nth-child(1) { --tile: var(--positive); }
.bento-card:nth-child(2) { --tile: var(--info); }
.bento-card:nth-child(3) { --tile: var(--accent); }
.bento-card:nth-child(4) { --tile: var(--tile-violet); }
.bento-card:nth-child(5) { --tile: var(--warning); }
.bento-card:nth-child(6) { --tile: var(--tile-mint); }
.bento-card:nth-child(7) { --tile: var(--tile-pink); }
.bento-card:nth-child(8) { --tile: var(--hud-ghost); }
/* Hairline of the tile's hue along the top edge. */
.bento-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--tile, var(--border-strong)); opacity: .4;
  transition: opacity var(--dur) var(--ease);
}
.bento-card:hover {
  border-color: var(--tile, var(--border-strong)); background: var(--surface);
  box-shadow: 0 0 0 1px var(--tile, transparent), 0 0 24px -10px var(--tile, transparent);
}
.bento-card:hover::before { opacity: 1; }
.bento-card:hover::after { background: var(--tile); color: var(--page); }
.bento-metric { color: var(--tile, var(--text)); }
.bento-card h3 { padding-right: var(--sp-8); font-size: var(--text-xl); line-height: 1.2; letter-spacing: -.018em; }
.bento-card p { margin: 0; color: var(--text-secondary); font-size: var(--text-sm); }
.bento-card .bento-metric { margin-top: auto; font: 600 var(--text-2xl)/1.1 var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.bento-card .bento-metric small { display: block; margin-top: var(--sp-1); color: var(--text-secondary); font-weight: 400; }
/* Corner affordance: a white pill holding an arrow, as on a Ramp tile. */
.bento-card::after {
  content: "↗"; position: absolute; top: var(--sp-4); right: var(--sp-4); display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%; background: var(--bg); color: var(--text); font-size: var(--text-sm); line-height: 1;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.bento-card:hover::after { background: var(--accent); color: var(--on-accent); }
.bento-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Hairline rules. One divider colour and one width everywhere, used to close
   off a heading from its content and to separate repeated rows. Borders rather
   than <hr> so nothing is added to the DOM and screen readers are unaffected. */
.browse-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3);
  margin-bottom: var(--sp-3); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border);
}
/* A stacked head (account panel, small screens) would otherwise put the rule
   between the title and its own actions. */
.us-account-panel .browse-head { padding-bottom: 0; border-bottom: 0; }
.browse-head .title { margin: 0; }

/* Forms ------------------------------------------------------------------- */
label { display: block; margin: 0 0 var(--sp-1); color: var(--text); font-size: var(--text-sm); font-weight: 500; }
.optional { color: var(--text-muted); font-weight: 400; }
input, select, textarea {
  width: 100%; min-height: 38px; padding: var(--sp-2) var(--sp-3); background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: var(--radius); color: var(--text); font-size: var(--text-sm);
}
input::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text); box-shadow: var(--glow); }
input:focus-visible, select:focus-visible { outline: none; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 16px; flex: 0 0 auto; accent-color: var(--text); }
input[type="file"] { padding: var(--sp-1); font-size: var(--text-sm); }
select {
  appearance: none;
  padding-right: var(--sp-8);
  /* Chevron as an inline SVG mark, not a surface gradient. The whole url()
     is the token: var() does not interpolate inside a data URI string. */
  background-image: var(--select-chevron);
  background-position: right var(--sp-3) center;
  background-repeat: no-repeat;
}
fieldset { margin: 0; padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); }
legend { padding: 0 var(--sp-1); color: var(--text); font-size: var(--text-sm); font-weight: 600; }

/* Buttons ---------------------------------------------------------------- */
button {
  min-height: 38px; padding: var(--sp-2) var(--sp-4); border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg);
  color: var(--text); font-size: var(--text-sm); font-weight: 500; cursor: pointer; box-shadow: var(--lift);
}
button:hover:not(:disabled) { background: var(--surface-sunk); box-shadow: var(--glow-soft), var(--lift); }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.ghost { background: var(--bg); }
.ghost:hover:not(:disabled) { background: var(--surface-sunk); }
.danger { background: var(--bg); border-color: var(--negative); color: var(--negative); }
.danger:hover:not(:disabled) { background: var(--negative-wash); }

/* Busy / removing / refreshing are live JS states, not decoration: index.js
   sets aria-busy and the is-* classes, so each needs a visible affordance. */
button[aria-busy="true"]::before,
.is-refreshing::before,
.is-removing::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: var(--sp-2); border: 1px solid currentColor;
  border-right-color: transparent; border-radius: 50%; vertical-align: -1px; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Row flash marks a newly scrolled-to card. */
.flash { animation: flash 1.4s ease-out; }
@keyframes flash {
  from { background: var(--accent-wash); }
  to   { background: transparent; }
}
.compact-button { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--text-sm); }
.compact-input  { width: auto; margin: 0; }
.compact-number { width: 78px; min-height: 32px; padding: var(--sp-1) var(--sp-2); }
.no-top-margin  { margin-top: 0; }
.align-right    { text-align: right; }
.search-gap     { margin-top: var(--sp-3); }
.full-row       { grid-column: 1 / -1; }

/* Disclosure ------------------------------------------------------------- */
details.advanced, details.why, details.us-exit-recovery-audit {
  margin-top: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
details.advanced > summary,
details.why > summary,
details.us-exit-recovery-audit > summary {
  padding: var(--sp-2) var(--sp-3); color: var(--text); font-size: var(--text-sm); font-weight: 500; cursor: pointer; list-style: none;
}
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before,
details.why > summary::before,
details.us-exit-recovery-audit > summary::before { content: "+"; display: inline-block; width: 1em; color: var(--text-muted); font-family: var(--font-mono); }
details.advanced[open] > summary::before,
details.why[open] > summary::before,
details.us-exit-recovery-audit[open] > summary::before { content: "\2212"; }
details.advanced > *:not(summary),
details.why > *:not(summary),
details.us-exit-recovery-audit > *:not(summary) { margin-left: var(--sp-3); margin-right: var(--sp-3); }
details.advanced > *:last-child,
details.why > *:last-child,
details.us-exit-recovery-audit > *:last-child { margin-bottom: var(--sp-3); }

/* Notes, notices, statuses ----------------------------------------------- */

/* Phase 2 moves these behind an info button. Until then they render as quiet
   one-line helper text rather than the four-line prose blocks they were. */
.field-note { margin-top: var(--sp-1); max-width: 84ch; color: var(--text-secondary); font-size: var(--text-xs); line-height: 1.5; }
.note { margin: var(--sp-4) 0 0; padding-top: var(--sp-3); border-top: 1px solid var(--border); color: var(--text-secondary); font-size: var(--text-sm); }
.notice {
  padding: var(--sp-3); margin-top: var(--sp-3); border: 1px solid var(--border); border-left: 3px solid var(--warning); border-radius: var(--radius);
  background: var(--warning-wash); color: var(--text); font-size: var(--text-sm);
}
.notice strong { color: var(--warning); }
.notice.price-only { border-left-color: var(--warning); }
.error {
  margin-bottom: var(--sp-3); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--negative); border-radius: var(--radius);
  background: var(--negative-wash); color: var(--negative); font-size: var(--text-sm);
}
.refresh-status { min-height: 18px; margin-top: var(--sp-2); color: var(--text-secondary); font-size: var(--text-xs); }
.refresh-status.is-success { color: var(--positive); }
.refresh-status.is-error   { color: var(--negative); }
.event-action-status, .bot-action-status, .us-liquidate-status {
  margin: var(--sp-2) 0; padding: var(--sp-2) var(--sp-3); border-left: 3px solid var(--info); border-radius: var(--radius);
  background: var(--info-wash); color: var(--text); font-size: var(--text-sm);
}
.event-action-status.is-success, .bot-action-status.is-success { border-left-color: var(--positive); background: var(--positive-wash); }
.event-action-status.is-error, .bot-action-status.is-error { border-left-color: var(--negative); background: var(--negative-wash); }
.us-liquidate-status:empty { display: none; }
.odds-api-status {
  margin: var(--sp-2) 0; padding: var(--sp-2) var(--sp-3); border-left: 3px solid var(--info); border-radius: var(--radius);
  background: var(--info-wash); font-size: var(--text-sm);
}
.odds-api-status.is-enabled  { border-left-color: var(--positive); background: var(--positive-wash); }
.odds-api-status.is-disabled { border-left-color: var(--warning);  background: var(--warning-wash); }
.odds-api-status.is-error    { border-left-color: var(--negative); background: var(--negative-wash); }
.metrics-empty, .discover-empty { padding: var(--sp-6) 0; color: var(--text-muted); font-size: var(--text-sm); text-align: center; }
.empty { padding: var(--sp-12) var(--sp-4); text-align: center; color: var(--text-secondary); }
.empty b { display: block; margin-bottom: var(--sp-1); color: var(--text); font-size: var(--text-lg); }
.pending { padding: var(--sp-4); color: var(--text-secondary); font-size: var(--text-sm); }

/* Chips, tags, badges ---------------------------------------------------- */
.tag, .line-badge, .us-venue-badge, .activity-status, .us-journal-status {
  display: inline-block; padding: var(--sp-05) var(--sp-2); border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--text-secondary); font-size: var(--text-xs); font-weight: 500; white-space: nowrap;
}
.entry, .hold, .activity-status.placed { border-color: var(--positive); background: var(--positive-wash); color: var(--positive); }
.wait, .monitor, .activity-status.rejected { border-color: var(--warning); background: var(--warning-wash); color: var(--warning); }
.cash, .exit { border-color: var(--negative); background: var(--negative-wash); color: var(--negative); }
.marketonly { color: var(--text-muted); }
.lt-ml { color: var(--info); }
.lt-sp { color: var(--warning); }
.lt-ou { color: var(--text-secondary); }
.positive, .mtile .v.good, .is-positive { color: var(--positive); }
.negative, .mtile .v.bad, .is-negative  { color: var(--negative); }
.risk { color: var(--warning) !important; }

/* Figures and tiles ----------------------------------------------------- */
.figs, .metric-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-2); margin-top: var(--sp-3); }
.fig, .mtile, .us-status-card { padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
/* Mono metadata labels over mono values: the instrument/HUD idiom, and it
   keeps each label visually paired with its figure. Deliberately not
   uppercase — tiny tracked-out caps is what made the old theme unreadable. */
.key, .mtile .k, .us-status-card span, .hint, .mtile .sub2, .us-state-chip span {
  display: block; color: var(--text-secondary); font: 500 var(--text-xs)/1.4 var(--font-mono); letter-spacing: .04em;
}
/* Rule between a tile's label and its value, so the pair reads as a labelled
   figure instead of two stacked lines of text. */
.value, .mtile .v, .us-status-card strong {
  display: block; margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border);
  font: 600 var(--text-lg)/1.2 var(--font-mono); letter-spacing: -.01em;
}
.hint, .mtile .sub2 { margin-top: var(--sp-05); color: var(--text-muted); }
.us-status-card { min-height: 72px; }

/* Tables ---------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  /* The only uppercase in the system, and only at --text-sm. */
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
td { padding: var(--sp-3); border-bottom: 1px solid var(--border); font-size: var(--text-sm); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface); }
/* Money and count columns line up on the decimal, the way a ledger should. */
.us-performance-table td:not(:last-child), .us-performance-table th:not(:first-child):not(:last-child) { text-align: right; }
.us-performance-table th:first-child, .us-performance-table td:first-child { text-align: left; }

/* Info popover — the "ⓘ" affordance. index.js moves every .field-note in
   here at boot, so the compliance prose is kept but out of the default view. */
.info-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; min-height: 18px; padding: 0; margin-left: var(--sp-1);
  border: 1px solid var(--border-strong); border-radius: 50%; background: var(--bg); color: var(--text-secondary);
  font: 600 var(--text-xs)/1 var(--font-mono); vertical-align: middle; flex: 0 0 auto; cursor: help;
}
.info-btn:hover { background: var(--surface-sunk); color: var(--text); }
.info-btn[aria-expanded="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
/* Comfortable touch target without disturbing inline layout. */
.info-btn::after { content: ""; position: absolute; inset: -11px; }
.info-btn { position: relative; }
.info-popover {
  /* Fixed and measured from the trigger by the controller, so no ancestor
     with overflow:hidden can clip it. */
  position: fixed; z-index: 200; width: max-content; max-width: min(380px, calc(100vw - var(--sp-4)));
  padding: var(--sp-3); border: 1px solid var(--border-strong); border-radius: var(--radius-card);
  background: var(--bg); box-shadow: var(--elevation); color: var(--text); font-size: var(--text-sm); line-height: 1.55;
}
.info-popover[hidden] { display: none !important; }
/* Keeps a label's text and its help button on one line inside the
   column-flex labels used by the policy form. */
/* flex-start, not center: a label long enough to wrap would otherwise centre
   the button against the whole text block instead of its first line. */
.info-label-row { display: flex; align-items: flex-start; gap: var(--sp-1); }
.info-label-row .info-btn { margin-top: 1px; }

/* ----------------------------------------------------------- components --- */

/* Login ----------------------------------------------------------------- */
#login-overlay {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: var(--sp-4);
  transition: opacity .4s ease, background-color .8s var(--ease); overflow: hidden;
  /* Atmospheric wash so the HUD sits in a lit volume instead of on flat black,
     which is what carries the reference's depth. A full-bleed backdrop layer,
     not a fill on a component surface. */
  background:
    radial-gradient(115% 85% at 50% 50%, var(--hud-wash) 0%, transparent 62%),
    var(--page);
}
/* Hand-off to the dashboard. The overlay itself is not faded as a whole any
   more: its backdrop clears while the HUD expands outward and the X-glyph field
   converges inward from a larger scale, so the instrumentation reads as
   dispersing into the background texture rather than cross-fading with it.
   `forwards` is safe on these three because the overlay is hidden immediately
   afterwards — unlike the entrance animations, nothing stays on screen
   depending on them. */
#login-overlay.dissolve { background: transparent; pointer-events: none; }
#login-overlay.dissolve .login-hud { animation: hud-disperse 1.05s var(--ease) forwards; }
#login-overlay.dissolve .login-box { animation: hud-card-out .45s var(--ease) forwards; }
@keyframes hud-disperse { from { opacity: .5; transform: none; } to { opacity: 0; transform: scale(2.1); } }
@keyframes hud-card-out { to { opacity: 0; transform: translateY(-8px) scale(.97); } }

/* Targeting HUD ---------------------------------------------------------
   Decorative. Sits behind the card, drawn in the semantic red so it reads as
   instrumentation rather than a third brand colour. Only opacity and transform
   are animated, both compositor-only, so an idle sign-in screen does not spin
   the CPU. */
.login-hud {
  position: absolute; inset: 0; pointer-events: none;
  color: var(--hud-red); opacity: .82;
}
/* Chromatic split plus bloom. Two zero-blur drop-shadows offset in opposite
   directions produce offset colour copies of the alpha silhouette, which is the
   RGB-split glitch, without duplicating any geometry — a <use> clone would not
   inherit the CSS animations and would sit frozen beside the live original. The
   third shadow is the halo. */
.login-hud svg {
  width: 100%; height: 100%; display: block;
  filter:
    drop-shadow(-2px 0 0 var(--hud-glow-ghost))
    drop-shadow(2px 0 0 var(--hud-glow-red))
    drop-shadow(0 0 7px var(--hud-bloom));
}
/* A rare, brief horizontal tear. Mostly idle so it reads as a glitch rather
   than a wobble, and it is transform-only. */
@keyframes hud-tear {
  0%, 92%, 100% { transform: none; }
  93% { transform: translateX(-5px) skewX(.6deg); }
  95% { transform: translateX(4px); }
  97% { transform: translateX(-2px) skewX(-.4deg); }
}
.login-hud svg { animation: hud-tear 9s steps(1, end) infinite; }
.login-hud path, .login-hud circle, .login-hud rect, .login-hud line { vector-effect: non-scaling-stroke; }

.hud-frames path { fill: none; stroke: currentColor; stroke-width: 1.5; opacity: .6; }
.hud-frames .hud-frame-inner { stroke-width: 1; opacity: .26; }
.hud-lines path { fill: none; stroke: currentColor; stroke-width: 1; opacity: .34; }
/* Tick strips read as light instrumentation against the red frame work. */
.hud-ticks { color: var(--text); opacity: .82; }
.hud-ticks-fine { opacity: .7; }
.hud-tick-rails path { fill: none; stroke: var(--text); stroke-width: 1; opacity: .45; }
.hud-scan rect { fill: var(--text); opacity: .4; filter: blur(2px); }
.hud-reticle circle { fill: none; stroke: currentColor; stroke-width: 1.5; }
.hud-ring-outer { opacity: .45; stroke-width: 2; }
/* Lens bracket and inner ring are light, matching the reference's white core. */
.hud-lens { fill: none; stroke: var(--text); stroke-width: 1.5; opacity: .55; }
.hud-core-ring { stroke: var(--text) !important; opacity: .8; }
/* transform-box declared so the rotation origin is read in viewBox units and
   the rings spin about the reticle centre rather than the SVG's own corner. */
.hud-ring-spin { stroke-dasharray: 34 16 8 16; opacity: .85; transform-box: view-box; transform-origin: 600px 400px; }
.hud-ring-spin-alt { stroke-dasharray: 4 22; opacity: .5; transform-box: view-box; transform-origin: 600px 400px; }
.hud-core { fill: var(--text) !important; stroke: none !important; opacity: .95; }
.hud-cross { fill: none; stroke: currentColor; stroke-width: 2; opacity: .5; }
/* Nodes carry their own tighter bloom, which is what makes them read as lit
   emitters rather than flat swatches. */
.hud-nodes rect { fill: currentColor; opacity: .95; filter: drop-shadow(0 0 5px var(--hud-node-glow)); }
/* Neon price tapes. Laser look comes from a tight bloom on a thin stroke; the
   round joins stop each turn reading as a hard corner. */
/* Mitred joins, not round: round joins blunted every turn, which is what made
   the peaks read as soft waves rather than price ticks. */
.hud-tape path {
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linejoin: miter; stroke-miterlimit: 6; stroke-linecap: butt;
  vector-effect: non-scaling-stroke;
}
.hud-tape { opacity: .85; }
.hud-tape-up   { color: var(--positive); filter: drop-shadow(0 0 7px var(--hud-cell-glow)); }
.hud-tape-down { color: var(--hud-red);  filter: drop-shadow(0 0 7px var(--hud-glow-red)); }
/* No CSS scroll animation: index.js owns the transform, because a keyframe can
   only replay a fixed path and the series is generated per step. */

/* Motion. Each keyframe touches opacity/transform only. */
@keyframes hud-spin { to { transform: rotate(360deg); } }
@keyframes hud-spin-back { to { transform: rotate(-360deg); } }
@keyframes hud-scan-sweep { from { transform: translateX(430px); } to { transform: translateX(770px); } }
@keyframes hud-node-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes hud-breathe { 0%, 100% { opacity: .32; } 50% { opacity: .5; } }
@keyframes hud-core-pulse { 0%, 100% { opacity: .55; transform: scale(1); } 50% { opacity: 1; transform: scale(1.12); } }
@keyframes hud-settle { from { opacity: 0; transform: scale(1.06); } to { opacity: .5; transform: none; } }

/* No fill mode anywhere in here on purpose. `both`/`backwards` would hold the
   0%-opacity frame whenever the animation is not advancing — a page opened in a
   background tab has its animation clock pinned at 0 — so the resting value in
   the rule above must be the visible one. */
.login-hud { animation: hud-settle 1.1s var(--ease); }
.hud-ring-spin { animation: hud-spin 26s linear infinite; }
.hud-ring-spin-alt { animation: hud-spin-back 18s linear infinite; }
.hud-ring-outer { animation: hud-breathe 5.5s ease-in-out infinite; }
.hud-core { transform-box: fill-box; transform-origin: center; animation: hud-core-pulse 3.4s ease-in-out infinite; }
.hud-scan rect { animation: hud-scan-sweep 4.8s var(--ease) infinite alternate; }
.hud-scan rect:nth-child(2) { animation-duration: 6.2s; animation-direction: alternate-reverse; }
/* Stagger all 16 nodes so the HUD never pulses in unison. The shorthand above
   sets no delay, so these longhand overrides are what offset each one. */
.hud-nodes rect { animation: hud-node-pulse 3s ease-in-out infinite; }
.hud-nodes rect:nth-child(2)  { animation-delay: .18s; }
.hud-nodes rect:nth-child(3)  { animation-delay: .36s; }
.hud-nodes rect:nth-child(4)  { animation-delay: .54s; }
.hud-nodes rect:nth-child(5)  { animation-delay: .72s; }
.hud-nodes rect:nth-child(6)  { animation-delay: .9s; }
.hud-nodes rect:nth-child(7)  { animation-delay: 1.08s; }
.hud-nodes rect:nth-child(8)  { animation-delay: 1.26s; }
.hud-nodes rect:nth-child(9)  { animation-delay: 1.44s; }
.hud-nodes rect:nth-child(10) { animation-delay: 1.62s; }
.hud-nodes rect:nth-child(11) { animation-delay: 1.8s; }
.hud-nodes rect:nth-child(12) { animation-delay: 1.98s; }
.hud-nodes rect:nth-child(13) { animation-delay: 2.16s; }
.hud-nodes rect:nth-child(14) { animation-delay: 2.34s; }
.hud-nodes rect:nth-child(15) { animation-delay: 2.52s; }
.hud-nodes rect:nth-child(16) { animation-delay: 2.7s; }

/* The sign-in controls are part of the HUD, not a panel on top of it: no card
   fill, no border, no shadow. Legibility instead comes from the HUD being
   cleared out of the centre (the tick strips sit at the top and bottom of the
   viewBox and the rings frame this area) plus a soft radial scrim that only
   deepens the ink directly behind the text. */
.login-box {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px; padding: var(--sp-8) var(--sp-6);
  animation: hud-card-in .45s var(--ease);
}
.login-box::before {
  content: ""; position: absolute; inset: -12% -18%; z-index: -1;
  background: radial-gradient(closest-side, var(--page) 58%, transparent 100%);
  opacity: .92; pointer-events: none;
}
/* Corner brackets stand in for the old border. */
.login-bracket { position: absolute; width: 18px; height: 18px; border: 1px solid var(--negative); opacity: .55; }
.login-bracket-tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.login-bracket-tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.login-bracket-bl { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.login-bracket-br { bottom: 0; right: 0; border-left: 0; border-top: 0; }

.login-status {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  margin: 0 0 var(--sp-2); color: var(--text-muted); font-size: var(--text-xs);
}
.login-status-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--positive);
  animation: hud-node-pulse 2.4s ease-in-out infinite;
}
/* Transform only, never opacity: the sign-in form must be readable even if the
   animation never runs. Nothing about being able to log in may depend on it. */
@keyframes hud-card-in { from { transform: translateY(10px); } }
.login-box h1 {
  margin-bottom: var(--sp-6); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border);
  font-size: var(--text-2xl); text-align: center;
}
.login-box h1 span { color: var(--hud-red); }

/* Field labels read as HUD captions. This is the second and last uppercase rule
   in the stylesheet, and it sits at --text-xs's larger sibling to stay legible. */
.login-box label {
  margin: var(--sp-4) 0 var(--sp-1); color: var(--hud-ink-dim);
  font-size: var(--text-sm); font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
}
/* Underlined instruments rather than boxed inputs, so the field belongs to the
   HUD instead of sitting in its own container. */
.login-box input {
  padding: var(--sp-2) 0; border: 0; border-bottom: 1px solid var(--border-strong); border-radius: 0;
  background: transparent; font-family: var(--font-mono); font-size: var(--text-base);
}
.login-box input:focus {
  border-bottom-color: var(--accent); box-shadow: 0 1px 0 0 var(--accent);
}
.login-box input:focus-visible { outline: none; }
/* The dashboard's yellow accent read as a foreign element on a red HUD, so the
   submit takes the HUD's own red. Near-black on --hud-red measures 5.2:1, which
   the reverse (light text on red, 3.8:1) would not. */
.login-box button {
  width: 100%; margin-top: var(--sp-8); border-radius: 0;
  background: var(--hud-red); border: 1px solid var(--hud-red); color: var(--page);
  font-weight: 600; letter-spacing: .08em;
  box-shadow: 0 0 18px -4px var(--hud-bloom);
}
.login-box button:hover:not(:disabled) { background: var(--hud-red-hover); border-color: var(--hud-red-hover); }
.login-box .error { border-radius: 0; }
/* Warm off-white rather than the cool --text, which looked cold beside the red. */
.login-box h1, .login-box input { color: var(--hud-ink); }
.login-box input::placeholder { color: var(--hud-ink-dim); opacity: .65; }
.login-status { color: var(--hud-ink-dim); }

/* Live radar: monitored events ------------------------------------------ */
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.event { overflow: hidden; scroll-margin-top: var(--sticky-offset); }
.event-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.name { font-size: var(--text-base); font-weight: 600; }
.meta { margin-top: var(--sp-05); color: var(--text-secondary); font-size: var(--text-xs); }
.event-actions { display: flex; align-items: center; gap: var(--sp-3); }
.score { font: 600 var(--text-xl)/1 var(--font-mono); white-space: nowrap; }
.sep { color: var(--text-muted); margin: 0 var(--sp-1); }
.event.is-removing { opacity: .55; pointer-events: none; }
.remove, .position-remove, .bot-remove {
  min-height: 30px; padding: 0 var(--sp-2); border-color: var(--negative); color: var(--negative); font-size: var(--text-xs);
}
.remove:hover, .position-remove:hover, .bot-remove:hover { background: var(--negative-wash); }
.remove.is-removing, .bot-remove.is-removing { border-color: var(--warning); color: var(--warning); }
.event-navigator {
  position: sticky; top: 53px; z-index: 12; margin-bottom: var(--sp-3); padding: var(--sp-3); background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.event-navigator-head {
  display: flex; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-2); color: var(--text-secondary); font-size: var(--text-xs);
}
.event-jump-list { display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: var(--sp-1); }
.event-jump { flex: 0 0 min(240px, 72vw); min-width: 170px; padding: var(--sp-2) var(--sp-3); text-align: left; background: var(--bg); }
.event-jump.active { border-color: var(--accent); background: var(--accent-wash); }
.event-jump-state { display: block; color: var(--warning); font-size: var(--text-xs); font-weight: 600; }
.event-jump-state.is-live { color: var(--negative); }
.event-jump-state.is-final { color: var(--text-muted); }
.event-jump-name {
  display: block; margin-top: var(--sp-05); overflow: hidden; font-size: var(--text-sm); font-weight: 600; text-overflow: ellipsis; white-space: nowrap;
}
.event-jump-meta { display: block; overflow: hidden; color: var(--text-secondary); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
.section-strip {
  padding: var(--sp-2) var(--sp-4); background: var(--surface-sunk); border-bottom: 1px solid var(--border); color: var(--text-secondary);
  font-size: var(--text-sm); font-weight: 600;
}
.market, .position { padding: var(--sp-4); border-bottom: 1px solid var(--border); }
.market:last-child, .position:last-child { border-bottom: 0; }
.market-top, .position-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.outcome { font-size: var(--text-base); font-weight: 600; }
.outcome small { display: block; margin-top: var(--sp-05); color: var(--text-secondary); font-size: var(--text-xs); font-weight: 400; }
.guide {
  margin-top: var(--sp-3); padding: var(--sp-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: var(--text-sm);
}
.why-no-entry {
  margin-top: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-left: 3px solid var(--warning); border-radius: var(--radius);
  background: var(--warning-wash); font-size: var(--text-sm);
}
.why { margin-top: var(--sp-3); }
.why ul { margin: var(--sp-2) 0 0; color: var(--text-secondary); font-size: var(--text-sm); }
.why li { margin: var(--sp-1) 0; }
.position-form {
  display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: var(--sp-2); margin-top: var(--sp-3); padding: var(--sp-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.position-form label { margin: 0 0 var(--sp-1); }
.portfolio { background: var(--surface); }
.pnl { font-weight: 600; }

/* Discovery ------------------------------------------------------------- */
.best-bets, .discover-list { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-3); }
.best-bet, .game {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); cursor: pointer;
}
.best-bet:hover, .game:hover { border-color: var(--border-strong); background: var(--surface); }
.best-bets > .best-bet { flex: 0 0 auto; }
.game[aria-disabled="true"] { opacity: .5; cursor: wait; }
.best-bet .bb-outcome { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); font-size: var(--text-base); font-weight: 600; }
.best-bet .bb-event { margin-top: var(--sp-05); color: var(--text-secondary); font-size: var(--text-xs); }
.best-bet .bb-figs { display: flex; align-items: center; gap: var(--sp-4); white-space: nowrap; }
.best-bet .bb-fig { text-align: right; }
.best-bet .bb-fig .value { font-size: var(--text-base); }
.best-bet .bb-fig .hint { color: var(--text-muted); font-size: var(--text-xs); }
.game .g-title { font-size: var(--text-base); font-weight: 500; line-height: 1.3; }
.game .g-league { margin-top: var(--sp-05); color: var(--text-secondary); font-size: var(--text-xs); }
.game .g-live { color: var(--negative); font-weight: 600; }
.game .g-started { color: var(--warning); font-weight: 600; }
.game .g-scheduled { color: var(--positive); font-weight: 600; }
.game .g-add { color: var(--text-secondary); font-size: var(--text-sm); white-space: nowrap; }
.inline-controls { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); }
.auto-monitor-label { display: flex; align-items: center; gap: var(--sp-2); margin: 0; font-weight: 400; cursor: pointer; }
.discover-batch-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-top: var(--sp-3); padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.discover-batch-copy { display: grid; min-width: 0; gap: var(--sp-05); font-size: var(--text-sm); }
.discover-batch-copy span { color: var(--text-secondary); font-size: var(--text-xs); }
.discover-batch-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); }
.discover-batch-status { min-height: 18px; }
.gameday-status:empty { display: none; }
.discover-game { display: grid; flex: 0 0 auto; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3); min-height: 52px; }
.discover-game-copy { display: block; min-width: 0; }
.discover-game .g-title, .discover-game .g-league { display: block; }
.discover-game-check { flex: 0 0 auto; }

/* US research: status, account ------------------------------------------ */
.us-research-hero { border-color: var(--border-strong); }
.us-status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); margin-bottom: var(--sp-3); }
/* One column. This was a 2fr/0.85fr split, but the charts panel spans 1/-1 and
   nothing else was ever placed in the second track, so the result was a dead
   right-hand column and three panels at two different widths (881/1272/881).
   Stacking them makes every panel the same width and gives the lane tally
   table enough room to stop overflowing horizontally. */
.us-overview-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); }
.us-overview-grid > .panel, .us-activity-grid > .panel { min-width: 0; }
.us-account-panel .browse-head { align-items: flex-start; flex-direction: column; }
.us-runtime-credentials form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-3); }
.us-runtime-credential-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.us-account-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-2); }
.us-json {
  max-height: 280px; overflow: auto; padding: var(--sp-3); background: var(--surface-sunk); border-radius: var(--radius);
  font: var(--text-xs)/1.5 var(--font-mono); white-space: pre-wrap;
}

/* US research: performance --------------------------------------------- */
.us-performance-actions, .model-lab-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); }
/* Three identical Dry run / Live / Combined cards are now one segmented
   table: the same nine figures line up in columns so lanes compare down a row.
   .us-performance-card is the <tr>; the head/hero/metrics grids are gone. */
.us-performance-summary { display: block; }
.us-performance-table th[scope="row"] { background: var(--surface); white-space: nowrap; text-transform: none; letter-spacing: normal; }
.us-performance-table td { white-space: nowrap; }
.us-performance-value { font-family: var(--font-mono); font-weight: 600; }
.us-performance-table .us-performance-note { min-width: 220px; color: var(--text-secondary); font-size: var(--text-xs); white-space: normal; }
.us-performance-table .us-performance-note.is-partial { color: var(--warning); }
.us-performance-footnote { margin-top: var(--sp-3); color: var(--text-secondary); font-size: var(--text-xs); }

/* Result charts. Full-width row inside the two-column overview grid. */
.us-performance-charts { grid-column: 1 / -1; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); margin-top: var(--sp-3); }
.chart-card-wide { grid-column: 1 / -1; }
.chart-card { min-width: 0; margin: 0; padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.chart-card figcaption { margin-bottom: var(--sp-2); color: var(--text); font-size: var(--text-sm); font-weight: 600; }
/* Chart.js needs a sized block to measure; the canvas itself is absolute. */
.chart-frame-sm { position: relative; width: 100%; height: 220px; }
.chart-card-wide .chart-frame-sm { height: 260px; }
/* No canvas rules on purpose. Chart.js sets the canvas width/height itself
   from this sized, position:relative parent; forcing dimensions here (worse,
   with !important) makes it re-measure in a loop and hangs the renderer. */
.chart-empty { color: var(--text-muted); font-size: var(--text-sm); text-align: center; padding: var(--sp-8) 0; }

/* US research: trade datasheet ----------------------------------------- */
.us-ledger-filters { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-3); }
.us-ledger-filters label { display: grid; gap: var(--sp-1); }
.us-ledger-settings-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--sp-2); }
.us-ledger-settings-group {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-1) var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); font-size: var(--text-sm);
}
.us-ledger-settings-group strong, .us-ledger-settings-group span { display: block; }
.us-ledger-settings-group small { grid-column: 1 / -1; color: var(--text-secondary); font-size: var(--text-xs); }
/* Horizontal only: 11 columns cannot fit, but a vertical inner scroll would
   trap the page scroll. The sticky header keeps the columns readable. */
.us-ledger-table-wrap { overflow-x: auto; overflow-y: visible; border: 1px solid var(--border); border-radius: var(--radius); }
.us-ledger-table { width: 100%; min-width: 1280px; }
.us-ledger-table th { position: sticky; top: 0; z-index: 1; }
.us-ledger-table td strong, .us-ledger-table td span { display: block; }
.us-ledger-table td span { color: var(--text-secondary); font-size: var(--text-xs); }
.us-ledger-table details { min-width: 240px; }
.us-ledger-table details span { white-space: normal; }

/* US research: advisor ------------------------------------------------- */
.us-policy-advisor-controls { display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-3); }
.us-advisor-market-types, .us-line-type-policy { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-6); margin-bottom: var(--sp-3); }
.us-advisor-market-types label, .us-line-type-policy label { display: flex; align-items: center; gap: var(--sp-2); margin: 0; font-weight: 400; }
.us-line-type-policy .field-note,
.us-line-type-policy .us-segment-live-approval { flex-basis: 100%; }
.us-segment-research-status { display: grid; flex-basis: 100%; gap: var(--sp-1); font-size: var(--text-xs); }
.us-policy-advisor-result { display: grid; gap: var(--sp-2); }
/* auto-fit, not a fixed 4, so the ledger's single "Filtered total" tile fills
   the row instead of sitting in a quarter-width box. */
.us-policy-advisor-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-2); }
.us-policy-advisor-summary > div, .us-policy-advisor-change {
  padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.us-policy-advisor-summary span, .us-policy-advisor-change span { display: block; color: var(--text-secondary); font-size: var(--text-xs); }
.us-policy-advisor-summary strong, .us-policy-advisor-change strong { display: block; font: 600 var(--text-base)/1.3 var(--font-mono); }
.us-policy-advisor-changes, .us-policy-advisor-sources,
.us-advisor-frontier, .us-policy-advisor-sessions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-2); }
.us-policy-advisor-sources article, .us-advisor-frontier article {
  display: grid; gap: var(--sp-1); min-width: 0; padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: var(--text-sm);
}
.us-policy-advisor-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-3); }
.us-policy-advisor-actions small { color: var(--text-secondary); font-size: var(--text-xs); }
.us-advisor-diagnostic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.us-advisor-diagnostic { min-width: 0; }
.us-advisor-field { display: grid; gap: var(--sp-05); }
.us-advisor-field-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2); }
/* Saved advisor sessions. These had no border, no padding and a transparent
   background, so consecutive entries ran together into one block of text with
   no boundary between a timestamp, its tallies and its outcome. Same card
   treatment as the frontier articles, with each line given its own role. */
.us-policy-session {
  display: grid; gap: var(--sp-1); min-width: 0; padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); font-size: var(--text-sm); color: var(--text-secondary);
}
.us-policy-session:hover { border-color: var(--border-strong); }
.us-policy-session strong {
  display: block; padding-bottom: var(--sp-1); border-bottom: 1px solid var(--border);
  color: var(--text); font-size: var(--text-xs); font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: .01em;
}
/* The tallies arrive as a bare text node between <strong> and <br>; the mono
   face is what separates the figures from the outcome line under them. */
.us-policy-session { font-variant-numeric: tabular-nums; }
.us-policy-session br { line-height: 0; }

/* US research: auto trader --------------------------------------------- */
.us-trading-lanes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); margin-bottom: var(--sp-3); }
.us-trading-lanes button { display: grid; gap: var(--sp-1); min-height: 64px; min-width: 0; padding: var(--sp-3); text-align: left; }
.us-trading-lanes button strong { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-1); font-size: var(--text-sm); }
.us-trading-lanes button span { color: var(--text-secondary); font-size: var(--text-xs); font-weight: 400; }
/* Selected, not accented: the primary action button below is the one thing on
   this screen allowed to be solid yellow. A selected card gets weight and an
   edge marker instead, so the two never compete. */
.us-trading-lanes button.is-active { border-color: var(--border-strong); background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }
/* A status bar, not a table. The server writes one <strong> plus a variable
   number of prose <span>s, so five rigid columns squeezed the long ones into a
   wall. Flex-wrap fits any content at any width, needing no override. */
.us-trading-status {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); font-size: var(--text-sm);
}
.us-trading-status > * { min-width: 0; }
.us-trading-status strong {
  display: inline-flex; align-items: center; gap: var(--sp-2); flex: 0 0 auto; font: 600 var(--text-base)/1.2 var(--font-mono); letter-spacing: -.01em;
}
/* State marker, so the headline state is scannable without colour alone. */
.us-trading-status strong::before { content: ""; width: var(--sp-2); height: var(--sp-2); border-radius: 50%; background: var(--text-muted); flex: 0 0 auto; }
.us-trading-status span { color: var(--text-secondary); }
/* Hairline separators between meta items instead of column gutters. */
.us-trading-status span + span { padding-left: var(--sp-3); border-left: 1px solid var(--border-strong); }
.us-execution-state { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); }
.us-execution-state-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-2); }
/* Stat tiles: a quiet label over a loud value. Without this split every tile
   was one flat 13px block, which is what made the whole screen read as a
   spreadsheet rather than a dashboard. */
.us-state-chip { display: grid; gap: var(--sp-1); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.us-state-chip span { color: var(--text-secondary); font-size: var(--text-xs); }
.us-state-chip strong {
  padding-top: var(--sp-1); border-top: 1px solid var(--border);
  font: 600 var(--text-base)/1.25 var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.us-execution-blockers:empty, .us-adaptive-recommendation-slot:empty { display: none; }
.us-adaptive-recommendation { display: grid; gap: var(--sp-1); font-size: var(--text-sm); }
.us-authorization-matrix-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-1); }
.us-authorization-row {
  display: grid; grid-template-columns: minmax(120px, .6fr) minmax(0, 1.6fr); gap: var(--sp-2); padding: var(--sp-1) var(--sp-2);
  font-size: var(--text-sm);
}
.us-lane-coordination-status { margin-top: var(--sp-3); color: var(--text-secondary); font-size: var(--text-sm); }
.us-lane-quick-control {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3); margin-top: var(--sp-3); padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.us-lane-quick-control > div { display: grid; min-width: 0; gap: var(--sp-05); }
.us-lane-quick-control span { color: var(--text-secondary); font-size: var(--text-xs); }
.us-lane-quick-control button { width: auto; min-width: 190px; }
.us-policy-save-status {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--sp-2) var(--sp-3); margin-top: var(--sp-3);
  padding: var(--sp-3); border: 1px solid var(--negative); border-radius: var(--radius); background: var(--negative-wash); font-size: var(--text-sm);
  scroll-margin-top: var(--sticky-offset);
}
.us-policy-save-status span { min-width: 0; }
.is-policy-error { scroll-margin-top: var(--sticky-offset); }
.us-policy-rail {
  position: sticky; top: 53px; z-index: 6; display: grid; gap: var(--sp-2); margin: var(--sp-4) 0 var(--sp-3); padding: var(--sp-3) 0;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.us-policy-rail-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-4); font-size: var(--text-sm); }
.us-policy-rail-summary span { color: var(--text-secondary); }
.us-rail-saved { color: var(--text-muted); font-size: var(--text-xs); }
.us-policy-steps { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.us-policy-steps button { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--text-sm); }
.us-policy-steps button.is-current { background: var(--text); border-color: var(--text); color: var(--bg); }
/* A step with an invalid field must be findable without opening all six. */
.us-policy-steps button.has-invalid { border-color: var(--negative); color: var(--negative); }
.us-policy-steps button.has-invalid::after { content: " !"; font-weight: 700; }
.us-policy-steps button.is-current.has-invalid { background: var(--negative); border-color: var(--negative); color: var(--bg); }
.us-trading-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.us-trading-panel .us-trading-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.us-trading-form label, .us-arm-row label { display: flex; flex-direction: column; gap: var(--sp-1); }
.us-trading-form .us-check, .us-check { flex-direction: row; align-items: center; gap: var(--sp-2); min-height: 38px; font-weight: 400; }
.us-check-wide { grid-column: 1 / -1; }
.us-policy-step { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.us-policy-step[hidden] { display: none; }
.us-advanced-grid, .us-line-profile-key, .us-line-profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.us-lane-select-field { grid-column: 1 / -1; }
.us-risk-preset-preview {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius); background: var(--surface);
  font-size: var(--text-sm);
}
.us-risk-preset-preview:empty { display: none; }
.us-risk-preset-preview strong { white-space: nowrap; }
.us-line-profile-actions, .us-engine-gate-actions, .us-trading-actions,
.us-adaptive-exit-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.us-line-profile-actions button, .us-engine-gate-actions button,
.us-trading-actions button { width: auto; }
.us-line-profile-list { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); font-size: var(--text-sm); }
.us-line-profile-chip {
  display: grid; grid-template-columns: minmax(150px, .7fr) minmax(0, 2fr); gap: var(--sp-2); padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.us-adaptive-exit-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-2); }
.us-adaptive-exit-status {
  display: grid; grid-template-columns: auto repeat(3, minmax(0, 1fr)); gap: var(--sp-2); margin-top: var(--sp-3); font-size: var(--text-sm);
}
.us-exit-recovery-list { display: grid; gap: var(--sp-1); }
.us-exit-recovery-row {
  display: grid; grid-template-columns: minmax(210px, 1.5fr) repeat(3, minmax(145px, 1fr)); gap: var(--sp-2); padding: var(--sp-2);
  border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-sm);
}
.us-exit-recovery-row > div { min-width: 0; }
.us-exit-recovery-row span, .us-exit-recovery-row strong { display: block; }
.us-adaptive-exit-actions { align-items: center; }
.us-adaptive-exit-actions button { flex: 0 0 auto; width: auto; }
.us-adaptive-exit-actions span { color: var(--text-secondary); font-size: var(--text-xs); }
.us-engine-gate-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-1); }
.us-engine-gate-grid label { display: flex; align-items: center; gap: var(--sp-2); min-height: 38px; min-width: 0; margin: 0; font-weight: 400; }
.us-always-enforced { margin-top: var(--sp-3); padding: var(--sp-3); border-radius: var(--radius); background: var(--surface-sunk); font-size: var(--text-sm); }
.us-engine-strict { font-weight: 500; }
.us-effective-policy-review { display: grid; gap: var(--sp-2); }
.us-effective-policy-review dl {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-1) var(--sp-3); margin: 0; font-size: var(--text-sm);
}
.us-effective-policy-review div { display: flex; justify-content: space-between; gap: var(--sp-2); }
.us-risk-session-control {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.us-risk-session-control > div:first-child { display: grid; gap: var(--sp-05); }
.us-risk-session-control span { color: var(--text-secondary); font-size: var(--text-sm); }
.us-risk-session-control small { color: var(--text-muted); font-size: var(--text-xs); }
.us-risk-session-control button { width: auto; white-space: nowrap; }
.us-risk-session-control .us-liquidate-status { grid-column: 1 / -1; }
.us-arm-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(140px, 180px) auto; align-items: end; gap: var(--sp-3); margin-top: var(--sp-4);
  padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.us-arm-row .us-approval-toggle { flex-direction: row; align-items: center; gap: var(--sp-2); min-height: 38px; font-weight: 400; }
.us-live-control-hint { margin-top: var(--sp-2); }

/* Handoff between the auto trader and the policy view. */
.us-policy-handoff {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-3); padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.us-policy-handoff > div { display: grid; min-width: 0; gap: var(--sp-05); }
.us-policy-handoff span { color: var(--text-secondary); font-size: var(--text-xs); }
.us-policy-handoff-link {
  flex: 0 0 auto; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-size: var(--text-sm); text-decoration: none; white-space: nowrap;
}
.us-policy-handoff-link:hover { background: var(--surface-sunk); }

/* Sticky save/step footer for the six-step policy form. */
.us-policy-footer {
  position: sticky; bottom: 0; z-index: 30; display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2);
  margin-top: var(--sp-4); padding: var(--sp-3) 0; background: var(--bg); border-top: 1px solid var(--border);
}
.us-policy-footer button { width: auto; }
#us-policy-step-indicator { flex: 1 1 auto; min-width: 0; color: var(--text-secondary); font-size: var(--text-sm); text-align: center; }
#us-policy-save { margin-left: auto; }

/* US research: positions and journal ----------------------------------- */
.us-activity-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(420px, 1fr); align-items: start; gap: var(--sp-4); }
.us-liquidate-controls {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .7fr); align-items: start; gap: var(--sp-3); margin-bottom: var(--sp-3);
  padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.us-liquidate-copy { grid-column: 1 / -1; }
.us-liquidate-copy strong, .us-liquidate-copy span { display: block; }
.us-liquidate-copy span { color: var(--text-secondary); font-size: var(--text-xs); }
.us-mode-switch { display: grid; grid-template-columns: 1fr 1fr; min-width: 0; gap: var(--sp-1); padding: var(--sp-2); }
.us-mode-switch label { display: block; min-width: 0; margin: 0; }
.us-mode-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.us-mode-switch span {
  display: flex; justify-content: space-between; gap: var(--sp-2); min-width: 0; padding: var(--sp-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--bg); font-size: var(--text-sm); cursor: pointer;
}
.us-mode-switch input:checked + span { border-color: var(--accent); background: var(--accent-wash); }
.us-mode-switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.us-mode-switch b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.us-liquidate-confirm { display: flex; flex-direction: row; align-items: center; gap: var(--sp-2); min-width: 0; font-weight: 400; }
#us-liquidate-submit { grid-column: 1 / -1; width: 100%; }
.us-liquidate-status { grid-column: 1 / -1; min-height: 16px; }
.us-position-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.us-position-filter { display: flex; min-width: 0; gap: var(--sp-1); overflow-x: auto; }
.us-position-filter button { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--text-sm); flex: 0 0 auto; }
.us-position-filter button.is-active { background: var(--text); border-color: var(--text); color: var(--bg); }
.us-position-toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); }
.us-position-toolbar .compact-button { flex: 0 0 auto; }
.us-venue-sync-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.us-venue-sync-bar strong, .us-venue-sync-bar span { display: block; }
.us-venue-sync-bar span { color: var(--text-secondary); font-size: var(--text-xs); }
.us-venue-sync-bar button { flex: 0 0 auto; width: auto; }
.us-venue-positions { display: flex; flex-direction: column; gap: var(--sp-1); }
.us-venue-position {
  display: grid; grid-template-columns: minmax(220px, 1.7fr) repeat(5, minmax(78px, .7fr)); align-items: center; gap: var(--sp-2); overflow: hidden;
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-sm);
}
.us-venue-position > *, .us-venue-position div { min-width: 0; }
.us-venue-position span, .us-venue-position strong { display: block; max-width: 100%; }
.us-venue-position span { color: var(--text-secondary); font-size: var(--text-xs); }
.us-venue-position strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* No inner scrollbar: an independent scroll region inside the page scroll was
   the most disorienting thing in the old journal panel. The journal is paged
   (25 rows) and positions are bounded, so the page scroll is enough. */
.us-managed-positions, .us-trading-journal { display: flex; flex-direction: column; gap: var(--sp-1); }
.us-managed-positions > .us-position,
.us-trading-journal > .us-journal-row { flex: 0 0 auto; }
.us-position {
  display: grid; grid-template-columns: minmax(190px, 1.5fr) repeat(4, minmax(74px, .8fr)); align-items: center; gap: var(--sp-2) var(--sp-3);
  overflow: hidden; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-sm);
}
.us-position > *, .us-position div { min-width: 0; }
.us-position div:first-child strong,
.us-position div:first-child span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.us-position div > span { display: block; color: var(--text-secondary); font-size: var(--text-xs); }
.us-position-reason { grid-column: 1 / -1; color: var(--text-secondary); font-size: var(--text-xs); }
.us-position-adaptive { display: block; }
.us-position-action { width: auto; min-width: 0; min-height: 30px; white-space: normal; }
.us-journal-controls { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.us-journal-kinds { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.us-journal-kinds button { min-height: 30px; padding: 0 var(--sp-2); font-size: var(--text-xs); }
.us-journal-kinds button.is-current { background: var(--text); border-color: var(--text); color: var(--bg); }
.us-journal-pager { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--text-sm); }
/* The first track used to resolve to exactly its 76px floor inside the ~483px
   journal column, while .us-journal-time laid the timestamp and the kind out
   side by side needing 123px. With overflow:hidden on the row the kind bled
   across the event name instead of wrapping. Track one is now sized to its
   content and the pair stacks, so nothing collides at any panel width. */
.us-journal-row {
  display: grid; grid-template-columns: minmax(84px, auto) minmax(110px, 1fr) minmax(0, 1.85fr);
  align-items: start; gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-sm);
}
.us-journal-row > div { min-width: 0; }
.us-journal-row strong, .us-journal-row span,
.us-journal-row em, .us-journal-row b { display: block; max-width: 100%; white-space: normal; }
/* Stack rather than sit side by side: the timestamp keeps a tabular figure
   width and the kind gets its own line instead of competing for 76px. */
.us-journal-time {
  display: grid; gap: var(--sp-05); min-width: 0;
  color: var(--text-secondary); font-size: var(--text-xs);
}
.us-journal-time > :first-child { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.us-journal-time > * { overflow-wrap: anywhere; }
.us-journal-decision { display: grid; gap: var(--sp-2); }
.us-journal-status { width: max-content; }
.us-journal-metrics { display: flex; min-width: 0; flex-wrap: wrap; gap: var(--sp-1); }
.us-journal-metrics span {
  display: inline-flex; width: auto; padding: var(--sp-05) var(--sp-2); border-radius: var(--radius); background: var(--surface-sunk);
  font-size: var(--text-xs);
}

/* US research: model lab ----------------------------------------------- */
.model-lab-targets, .model-lab-profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-2); margin-top: var(--sp-3); }
.model-lab-target, .model-lab-profile, .model-lab-segment {
  display: grid; gap: var(--sp-1); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  font-size: var(--text-sm);
}
.model-lab-profile > div, .model-lab-segment > div { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.mlb-blueprint-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-2); }
.mlb-blueprint-step strong, .mlb-blueprint-step span, .mlb-blueprint-step small { display: block; }
.model-lab-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .8fr); gap: var(--sp-4); margin-top: var(--sp-4); }
.model-lab-segments { display: grid; gap: var(--sp-2); }
.model-lab-fit-form { display: grid; gap: var(--sp-3); }
.model-lab-fit-result { display: grid; gap: var(--sp-1); margin-top: var(--sp-3); font-size: var(--text-sm); }
.model-lab-momentum { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); }
.model-lab-momentum article {
  display: grid; grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) minmax(180px, 1fr); gap: var(--sp-3); padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-sm);
}
.model-lab-momentum article > div { display: grid; gap: var(--sp-05); min-width: 0; }
.model-lab-archive-status:empty { display: none; }
.research-evidence-steps {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); margin: var(--sp-3) 0; padding: 0; list-style: none;
  counter-reset: step;
}
.research-evidence-steps li { min-width: 0; padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-sm); }
.research-evidence-steps strong, .research-evidence-steps span { display: block; }
.research-evidence-steps span { color: var(--text-secondary); font-size: var(--text-xs); }
.research-evidence-actions { display: grid; grid-template-columns: auto minmax(220px, 1fr) auto; align-items: center; gap: var(--sp-2); }
.research-evidence-actions input[type="file"] { min-width: 0; }

/* US market inventory -------------------------------------------------- */
.us-event-list { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-3); }
.us-event { padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius-card); }
/* Close the event header off from its markets, and rule between each market. */
.us-event-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
  margin-bottom: var(--sp-3); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border);
}
.us-market-grid { display: grid; gap: 0; }
.us-market {
  display: grid; grid-template-columns: minmax(180px, 1.4fr) minmax(135px, .8fr) minmax(145px, .8fr); align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-2); border-top: 1px solid var(--border); font-size: var(--text-sm);
}
/* The grid's own first row already sits under the header rule. */
.us-market:first-child { border-top: 0; padding-top: var(--sp-2); }
.us-market-more { margin-top: var(--sp-2); width: auto; }
.us-events-more { width: 100%; margin-top: var(--sp-3); }
.us-sides { display: flex; flex-direction: column; min-width: 0; }
/* Separate the long/short pair rather than letting the two prices stack flush. */
.us-side { display: flex; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-1) 0; }
.us-side + .us-side { border-top: 1px solid var(--border); }
.us-side span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Custom bots --------------------------------------------------------- */
.research-workstation #tab-bots { display: none !important; }
.bot-form { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.metrics-panel { padding: var(--sp-4); margin-bottom: var(--sp-6); }
.metrics-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-3); }
.metrics-head .title { margin: 0; }
.metrics-sub { color: var(--text-secondary); font-size: var(--text-sm); }
.accent-border { border-color: var(--border-strong); }
.accent-text, .dialog-title { color: var(--text); }
.leaderboard-panel { border-color: var(--border-strong); }
.bot-activity-panel { border-color: var(--border); }
.bot-policy {
  margin-top: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-left: 3px solid var(--warning); border-radius: var(--radius);
  background: var(--warning-wash); font-size: var(--text-sm);
}
.bot-policy.is-ready { border-left-color: var(--positive); background: var(--positive-wash); }
.bot-activity { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-3); }
.activity-row {
  display: grid; grid-template-columns: minmax(125px, .7fr) minmax(180px, 1.3fr) minmax(240px, 2fr); align-items: start; gap: var(--sp-3);
  padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-sm);
}
.activity-who, .activity-selection, .activity-reason { min-width: 0; }
.activity-bot { font-weight: 600; overflow-wrap: anywhere; }
.activity-time, .activity-meta { margin-top: var(--sp-05); color: var(--text-secondary); font-size: var(--text-xs); }
.activity-event { font-weight: 500; }
.activity-status { margin-bottom: var(--sp-1); }
.activity-reason { color: var(--text-secondary); }
.activity-engine-detail { margin-top: var(--sp-2); }
.activity-engine-detail summary { cursor: pointer; color: var(--text-secondary); font-size: var(--text-xs); }
.activity-engine-detail ul { margin: var(--sp-1) 0 0; font-size: var(--text-xs); }
.activity-section-title { margin: var(--sp-3) 0 var(--sp-1); color: var(--text-secondary); font-size: var(--text-sm); font-weight: 600; }
.activity-section-title:first-child { margin-top: 0; }
.activity-coverage { display: flex; gap: var(--sp-1); overflow-x: auto; margin: var(--sp-2) 0; padding-bottom: var(--sp-05); }
.activity-coverage span {
  flex: 0 0 auto; max-width: 230px; overflow: hidden; padding: var(--sp-05) var(--sp-2); border: 1px solid var(--border);
  border-radius: var(--radius-pill); background: var(--surface); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap;
}
.bot-name, .bot-scope { color: var(--text); font-weight: 600; }
.bot-count { margin-top: var(--sp-05); }
.mtile[data-bot] { cursor: pointer; }
.mtile.is-removing { opacity: .6; pointer-events: none; }
.bot-bet { flex-direction: column; align-items: flex-start; }
.bot-bet-head { display: flex; justify-content: space-between; width: 100%; }
.bot-bet-meta { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-1); color: var(--text-secondary); font-size: var(--text-xs); }
.cashout-label, .game-check { display: flex; align-items: center; gap: var(--sp-2); margin: 0; font-size: var(--text-sm); font-weight: 400; cursor: pointer; }
.cashout-create-row { padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.bot-cashout-label { margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border); }
.bot-card-actions {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-top: var(--sp-2); padding-top: var(--sp-2);
  border-top: 1px solid var(--border);
}
.bot-card-actions .bot-cashout-label { margin: 0; padding: 0; border: 0; }
.bot-submit-error { margin-bottom: var(--sp-3); color: var(--negative); font-size: var(--text-sm); }
.bot-games {
  display: flex; flex-direction: column; gap: var(--sp-1); max-height: 160px; overflow-y: auto; padding: var(--sp-2); border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
}
.game-check .g-league { margin-left: auto; color: var(--text-secondary); font-size: var(--text-xs); }
.reliability { display: flex; align-items: flex-end; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
.rbin { display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); }
.rtrack { position: relative; width: 26px; height: 58px; background: var(--surface-sunk); border: 1px solid var(--border); border-radius: var(--sp-05); }
.remp { position: absolute; left: 0; right: 0; bottom: 0; background: var(--info); }
.rpred { position: absolute; left: -1px; right: -1px; height: 2px; background: var(--negative); }
.rlabel { color: var(--text-muted); font-size: var(--text-xs); }
.reliability-meter { width: 100%; height: 36px; writing-mode: vertical-lr; direction: rtl; }

/* Dialogs ------------------------------------------------------------- */
dialog::backdrop { background: var(--backdrop); }
.app-dialog {
  position: fixed; top: 50%; left: 50%; z-index: 99; margin: auto; transform: translate(-50%, -50%); border: 1px solid var(--border-strong);
  border-radius: var(--radius-card); background: var(--bg); color: var(--text); box-shadow: var(--elevation);
}
.bot-dialog { width: 90%; max-width: 600px; max-height: 80vh; overflow-y: auto; }
.chart-dialog { width: 95%; max-width: 800px; }
.dialog-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.dialog-title { margin: 0; }
.dialog-close { min-height: 30px; padding: 0 var(--sp-2); width: auto; margin: 0; }
.dialog-content { display: flex; flex-direction: column; gap: var(--sp-2); }
.chart-frame { position: relative; width: 100%; height: 400px; }
.chart-button { width: auto; min-height: 30px; padding: 0 var(--sp-2); margin: 0; font-size: var(--text-xs); }

/* Scrollbars: quiet, no gradient. */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-pill); }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Guided setup ----------------------------------------------------------- */

.us-setup-cta {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  margin-top: var(--sp-3); padding: var(--sp-4);
  border: 1px solid var(--accent-edge); border-radius: var(--radius); background: var(--accent-wash);
}
.us-setup-cta > div { display: grid; gap: var(--sp-05); min-width: 0; }
.us-setup-cta strong { font-size: var(--text-base); }
.us-setup-cta span { color: var(--text-secondary); font-size: var(--text-sm); }
.us-setup-cta-button { flex: 0 0 auto; text-decoration: none; }
/* .primary is a <button> rule; the CTA is an <a>, so it needs the box too. */
a.us-setup-cta-button {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 var(--sp-4);
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent); font-size: var(--text-sm); font-weight: 600;
}
a.us-setup-cta-button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }

.us-setup-steps { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-bottom: var(--sp-4); }
.us-setup-step-chip { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--text-sm); }
.us-setup-step-chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.us-setup-step-chip.is-done { border-color: var(--positive); color: var(--positive); }
.us-setup-step[hidden] { display: none; }
.us-setup-body { min-height: 260px; }

.us-setup-choice { display: grid; gap: var(--sp-2); }
.us-setup-option {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: var(--sp-3);
  margin: 0; padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); font-weight: 400; cursor: pointer;
}
.us-setup-option:hover { border-color: var(--border-strong); }
.us-setup-option:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.us-setup-option:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.us-setup-option strong { display: block; font-size: var(--text-base); }
.us-setup-option small { display: block; margin-top: var(--sp-1); color: var(--text-secondary); line-height: 1.5; }

.us-setup-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  margin-bottom: var(--sp-3); padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.us-setup-row > div { display: grid; gap: var(--sp-05); min-width: 0; }
.us-setup-row span { color: var(--text-secondary); font-size: var(--text-sm); }
.us-setup-row button { flex: 0 0 auto; }
.us-setup-account-slot .us-runtime-credentials { margin-top: 0; }

.us-setup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.us-setup-grid label { display: grid; gap: var(--sp-1); }
.us-setup-derived, .us-setup-summary { margin-top: var(--sp-4); }
.us-setup-derived dl, .us-setup-summary dl {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-2); margin: 0;
}
.us-setup-derived div, .us-setup-summary div {
  display: grid; gap: var(--sp-05); padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.us-setup-derived span, .us-setup-summary span {
  color: var(--text-secondary); font: 500 var(--text-xs)/1.4 var(--font-mono); letter-spacing: .04em;
}
.us-setup-derived strong, .us-setup-summary strong {
  font: 600 var(--text-base)/1.25 var(--font-mono); font-variant-numeric: tabular-nums;
}

.us-setup-footer {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--sp-3);
  margin-top: var(--sp-4); padding: var(--sp-3) 0;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
@supports not (backdrop-filter: blur(1px)) { .us-setup-footer { background: var(--bg); } }
.us-setup-footer button { width: auto; }
.us-setup-progress { margin-left: auto; color: var(--text-secondary); font-size: var(--text-sm); }

/* Live state classes -----------------------------------------------------
   index.js toggles each of these; without a rule the state would be
   invisible, so they belong to the component section rather than a re-skin. */
.us-trading-lanes button.is-running strong::after {
  content: "RUNNING"; display: inline-block; padding: var(--sp-05) var(--sp-2); border-radius: var(--radius-pill); background: var(--positive);
  color: var(--bg); font-size: var(--text-xs); font-weight: 600;
}
.us-trading-lanes button[data-trading-lane="live"].is-running strong::after { background: var(--negative); }
.us-lane-coordination-status.is-both-running {
  padding: var(--sp-2) var(--sp-3); border-left: 3px solid var(--positive); border-radius: var(--radius); background: var(--positive-wash);
  color: var(--text);
}
.us-execution-blockers { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-sm); }
.us-execution-blockers.is-blocked { border-color: var(--warning); background: var(--warning-wash); }
.us-execution-blockers.is-clear { background: var(--surface); color: var(--text-secondary); }
.us-authorization-row.is-blocked { color: var(--text-muted); }
.us-rail-saved.is-dirty { color: var(--warning); font-weight: 500; }
.us-rail-saved.is-saved { color: var(--text-muted); }
.us-policy-advisor-result.is-stale { padding-left: var(--sp-3); border-left: 3px solid var(--warning); opacity: .7; }
.us-lane-quick-control span.is-working,
.us-liquidate-status.is-working,
.discover-batch-status.is-working { color: var(--warning); }
/* A derived field is still editable but its value came from the risk preset. */
.us-trading-form label.is-derived-risk input { background: var(--surface-sunk); }
.us-engine-strict.is-strict { font-weight: 600; }

/* Component internals that carry typography only ------------------------ */
.us-live-badge {
  display: inline-block; padding: var(--sp-05) var(--sp-2); border: 1px solid var(--negative); border-radius: var(--radius-pill);
  color: var(--negative); font-size: var(--text-xs); font-weight: 600;
}
.us-cold-start-warning { margin-top: var(--sp-2); color: var(--warning); font-size: var(--text-sm); }
.us-event-title { font-size: var(--text-base); font-weight: 600; }
.us-event-meta { margin-top: var(--sp-05); color: var(--text-secondary); font-size: var(--text-xs); }
.us-market-question { font-size: var(--text-sm); }
.us-market-type { margin-top: var(--sp-05); color: var(--text-secondary); font-size: var(--text-xs); font-weight: 600; }
.us-market-book { color: var(--text-secondary); font: var(--text-xs)/1.5 var(--font-mono); }
.us-market-book strong { color: var(--text); }
.us-account-view, .us-safety-note { margin-top: var(--sp-3); }
.bb-main { min-width: 0; }
.table-wrap { overflow-x: auto; }
.mlb-model-blueprint {
  margin-top: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text-secondary); font-size: var(--text-sm); overflow-wrap: anywhere;
}
.mlb-model-blueprint h3 { margin-bottom: var(--sp-1); color: var(--text); }
.mlb-model-blueprint > p { margin-bottom: var(--sp-2); }
.mlb-blueprint-references { margin-top: var(--sp-2); color: var(--text-muted); font-size: var(--text-xs); }
.us-advisor-analysis { margin-top: var(--sp-05); }
.us-advisor-field-basis { color: var(--text-muted); font-size: var(--text-xs); }
.us-advisor-field-caveat { color: var(--warning) !important; }
.us-advisor-field-group { margin-top: var(--sp-3); }
.us-advisor-field-group h4 { margin-bottom: var(--sp-1); color: var(--text-secondary); font-size: var(--text-sm); }
.us-policy-advisor-evidence { color: var(--text-secondary); font-size: var(--text-sm); overflow-wrap: anywhere; }
.gameday-bar { margin-top: var(--sp-2); }

/* ----------------------------------------------------------- responsive --- */
/* Three breakpoints only: 1280 (wide desks), 900 (tablet), 640 (phone). */
@media (max-width: 1280px) {
  .us-trading-panel .us-trading-form,
  .us-engine-gate-grid,
  .us-adaptive-exit-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .us-activity-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --gutter: var(--sp-4); }
  .wrap, .research-workstation .wrap { padding: var(--sp-4) var(--gutter) var(--sp-12); }
  .us-overview-grid,
  .model-lab-grid,
  .us-liquidate-controls,
  .us-risk-session-control,
  .us-lane-quick-control,
  .us-runtime-credentials form,
  .research-evidence-actions,
  .research-evidence-steps,
  .us-line-profile-chip,
  .model-lab-momentum article,
  .us-arm-row { grid-template-columns: 1fr; }
  .us-trading-form,
  .us-trading-panel .us-trading-form,
  .us-policy-step,
  .us-advanced-grid,
  .us-line-profile-key,
  .us-line-profile-grid,
  .us-ledger-filters,
  .us-policy-advisor-controls,
  .us-policy-advisor-summary,
  .us-engine-gate-grid,
  .us-adaptive-exit-grid,
  .us-adaptive-exit-status,
  .us-exit-recovery-row,
  .us-advisor-diagnostic-grid,
  .us-status-grid,
  .us-venue-position,
  .us-journal-row,
  .us-position,
  .bot-form,
  .activity-row,
  .us-market { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .us-runtime-credential-actions { grid-column: auto; }
  .bento-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bento-card, .bento-card.is-wide { grid-column: span 1; }
  .us-lane-quick-control button,
  .us-risk-session-control button { width: 100%; min-width: 0; }
  .us-policy-rail { position: static; }
  /* Sticky save/step footer instead of a long scroll back to the top. */
  .us-trading-actions {
    position: sticky; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: var(--sp-2) 0;
    background: var(--bg); border-top: 1px solid var(--border);
  }
  .us-trading-actions button { width: 100%; white-space: normal; }
  .us-position > div:first-child,
  .us-position-reason,
  .us-journal-decision,
  .us-check-wide { grid-column: 1 / -1; }
  .browse-head { align-items: flex-start; flex-direction: column; }
  .us-performance-actions, .model-lab-actions { width: 100%; justify-content: flex-start; }
}
@media (max-width: 640px) {
  :root { --gutter: var(--sp-3); }
  .wrap, .research-workstation .wrap { padding: var(--sp-3) var(--gutter) var(--sp-12); }
  header, .event-head, .us-position-toolbar, .us-venue-sync-bar,
  .discover-batch-bar { align-items: flex-start; flex-direction: column; }
  .header-brand, .config { width: 100%; }
  .header-brand { justify-content: flex-start; }
  .research-section-nav { grid-template-columns: minmax(0, 1fr) auto; }
  .research-section-nav-label { display: none; }
  .us-trading-form,
  .us-trading-panel .us-trading-form,
  .us-policy-step,
  .us-advanced-grid,
  .us-line-profile-key,
  .us-line-profile-grid,
  .us-ledger-filters,
  .us-policy-advisor-controls,
  .us-policy-advisor-summary,
  .us-engine-gate-grid,
  .us-adaptive-exit-grid,
  .us-adaptive-exit-status,
  .us-exit-recovery-row,
  .us-status-grid,
  .us-venue-position,
  .us-journal-row,
  .us-position,
  .us-trading-lanes,
  .bot-form,
  .activity-row,
  .position-form,
  .us-mode-switch,
  .chart-grid,
  .us-setup-grid,
  .us-market { grid-template-columns: 1fr; }
  .us-setup-cta { align-items: stretch; flex-direction: column; }
  a.us-setup-cta-button { justify-content: center; }
  .bento-grid { grid-template-columns: 1fr; }
  .bento-card, .bento-card.is-wide { grid-column: span 1; min-height: 0; }
  .chart-frame-sm, .chart-card-wide .chart-frame-sm { height: 200px; }
  .us-trading-actions { grid-template-columns: 1fr; }
  .best-bet { align-items: flex-start; flex-direction: column; }
  .best-bet .bb-figs { width: 100%; justify-content: space-between; gap: var(--sp-2); }
  .best-bet .bb-fig { text-align: left; }
  .discover-batch-actions { justify-content: flex-start; }
  .discover-game { grid-template-columns: auto minmax(0, 1fr); row-gap: var(--sp-1); }
  .discover-game-check { grid-column: 1; grid-row: 1; }
  .discover-game-copy { grid-column: 2; grid-row: 1; }
  .discover-game .g-add { grid-column: 2; grid-row: 2; }
  .refresh-status { text-align: left; }
  /* The status bar's separators divide a horizontal row; once the items stack
     they become stray left rules, so drop them and let the gap do the work. */
  .us-trading-status span + span { padding-left: 0; border-left: 0; }
  .event-actions { width: 100%; justify-content: space-between; }
  .us-position-toolbar-actions { justify-content: flex-start; flex-wrap: wrap; }

  /* The 11-column datasheet becomes a labelled card stack rather than a
     horizontal scroll on a phone. Column headers move into ::before. */
  .us-ledger-table-wrap { max-height: none; overflow: visible; border: 0; }
  .us-ledger-table { display: block; width: 100%; min-width: 0; }
  .us-ledger-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; white-space: nowrap; clip-path: inset(50%); }
  .us-ledger-table tbody { display: grid; gap: var(--sp-2); }
  .us-ledger-table tr { display: grid; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); }
  .us-ledger-table td {
    display: grid; grid-template-columns: minmax(78px, .36fr) minmax(0, 1fr); align-items: start; gap: var(--sp-2);
    border-bottom: 1px solid var(--border);
  }
  .us-ledger-table tr td:last-child { border-bottom: 0; }
  .us-ledger-table td details { min-width: 0; max-width: 100%; }
  .us-ledger-table .us-ledger-empty td { display: block; }
}

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