/* ══════════════════════════════════════════════════════════════════════════
   CYCLICAL TRADER — instrument skin
   ══════════════════════════════════════════════════════════════════════════

   A private, single-operator dashboard. It is read far more often than it is
   clicked, and almost everything on it is a number, so the whole surface is
   built for reading numbers: dark ground, hairline rules, monospaced figures
   that align in a column, and one loud colour used only where something has
   actually happened.

   Palette, and why it is this one. Every other property in this portfolio is
   already spoken for -- near-black/teal, bone/orange-red, cool-white/lavender,
   navy/amber, near-black/gold, cool-grey/serif -- and navy/cream/gold is
   reserved for civic and food work. This is none of them. Carbon ground, acid
   chartreuse signal, rust and rose for the two kinds of bad news:

     acid  #C7F04B  condition met, active control, focus
     rust  #F0705A  AVOID, failure, danger
     rose  #E87AA6  unproven / caveat -- the flag this app wears most

   Acid vs rust is a hue AND lightness separation rather than the usual
   red-vs-green, which is the one pairing a red-green colour-blind reader
   cannot resolve. Every state that uses colour also carries a word.

   Contrast, measured against the three grounds (#0A0C0B / #101413 / #161C1A),
   lowest ratio of the three:
     ink   #E6EDE9  14.53:1      acid  #C7F04B  13.16:1
     dim   #9BA8A2   7.01:1      rust  #F0705A   5.90:1
     mute  #808E88   5.06:1      rose  #E87AA6   6.39:1
   All clear AA for body text (4.5:1). mute was lifted from #74827C, which
   measured 4.30 on the raised ground and would have failed there.

   Type is IBM Plex, served from /static/fonts -- not a CDN. That is a security
   choice before it is a taste one: it lets the Content-Security-Policy in
   web/auth.py name no external origin at all.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Fonts ───────────────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Plex Sans';
  src: url('/static/fonts/plex-sans-var.woff2') format('woff2');
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('/static/fonts/plex-mono-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('/static/fonts/plex-mono-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('/static/fonts/plex-mono-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ── Tokens ──────────────────────────────────────────────────────────────── */

:root {
  --ground:   #0A0C0B;
  --panel:    #101413;
  --raise:    #161C1A;
  --sunk:     #070908;
  --line:     #1F2624;
  --line-hi:  #2C3634;

  --ink:      #E6EDE9;
  --dim:      #9BA8A2;
  --mute:     #808E88;

  --acid:     #C7F04B;
  --acid-dim: #93B82F;
  --acid-wash: rgba(199, 240, 75, 0.09);
  --rust:     #F0705A;
  --rust-wash: rgba(240, 112, 90, 0.10);
  --rose:     #E87AA6;
  --rose-wash: rgba(232, 122, 166, 0.10);

  --mono: 'Plex Mono', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* One scale, used everywhere. 12px is the floor for anything a person has
     to read; the 10px step is for uppercase tracked labels only, which read
     larger than their size because they are all-caps and widely spaced. */
  --t-label: 0.625rem;
  --t-xs:    0.6875rem;
  --t-sm:    0.75rem;
  --t-base:  0.8125rem;
  --t-md:    0.875rem;
  --t-lg:    1.0625rem;
  --t-xl:    1.375rem;
  --t-2xl:   2rem;
  --t-slab:  3.25rem;

  --gap:    0.75rem;
  --pad:    1rem;
  --radius: 3px;   /* nearly square: an instrument, not a card deck */

  --shell-x: 2.25rem;

  /* ── Legacy token aliases ──────────────────────────────────────────────
     index.html carries roughly five hundred inline style attributes and
     template literals that name the old light-theme tokens. Re-pointing the
     NAMES at the new palette converts all of them in one place, which is both
     smaller and far more reviewable than five hundred hand edits -- and it
     means any inline style added later still lands inside the palette instead
     of punching a light-grey hole in it.

     The mapping is semantic, not literal. --green and --yellow were the old
     "good" and "caution"; here that is acid and rose. Nothing maps to a
     colour that would fail contrast on this ground. */
  --bg:            var(--ground);
  --surface:       var(--panel);
  --card:          var(--panel);
  --text:          var(--ink);
  --border:        var(--line);
  --gold:          var(--acid);
  --green:         var(--acid);
  --red:           var(--rust);
  --red-dim:       var(--rust-wash);
  --yellow:        var(--rose);
  --cyan:          var(--acid);
  --blue:          var(--dim);
  --purple:        var(--rose);
  --purple-bg:     var(--rose-wash);
  --purple-border: var(--rose);
}

/* Layout comfort, not decoration: at this width the dense tables stop being
   readable and everything needs more room per row. */
@media (max-width: 768px) {
  :root { --shell-x: 1rem; }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-base);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Every figure in the interface is tabular, so columns of numbers line up on
   the decimal point instead of wandering. */
.stat-value, .ps-value, .bt-stat-val, .metric-val, .field-val,
.clock-time, .price-badge, td, th, code, kbd, samp {
  font-variant-numeric: tabular-nums;
}

/* ── Focus ───────────────────────────────────────────────────────────────── */
/* One rule, applied to everything focusable, at 13:1 against every ground in
   the palette. Keyboard operation of this dashboard has to be visible without
   squinting -- the old skin relied on a 1px border colour change. */

:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
  border-radius: 1px;
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--acid); color: var(--ground); }

/* ── Skip link ───────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 400;
  background: var(--acid);
  color: var(--ground);
  padding: 0.6rem 1rem;
  font-family: var(--mono);
  font-size: var(--t-sm);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ── Standing disclosure strip ───────────────────────────────────────────── */
/* Fixed at the top of every page and never dismissible. The system returns
   AVOID roughly thirteen times in fourteen and none of its setups has cleared
   the edge gate; a verdict shown without that context is a claim the data does
   not support. Putting it in the chrome means it cannot be scrolled away from
   a screenshot. */

.disclosure {
  background: var(--sunk);
  border-bottom: 1px solid var(--line);
  padding: 0.4rem var(--shell-x);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  align-items: baseline;
  font-family: var(--mono);
  font-size: var(--t-label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mute);
}
.disclosure b {
  color: var(--rose);
  font-weight: 500;
  letter-spacing: 0.16em;
}
.disclosure .disclosure-sep { color: var(--line-hi); }

/* ── Header ──────────────────────────────────────────────────────────────── */

.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 1.35rem var(--shell-x) 0;
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

/* The wordmark: an acid tick, then the name in mono at a size that reads as a
   machine label rather than a masthead. */
.site-name-label {
  font-family: var(--mono);
  font-size: var(--t-label);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 0.4rem;
}
h1 {
  font-family: var(--mono);
  font-size: var(--t-xl);
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.1;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
h1::before {
  content: '';
  width: 0.5rem;
  height: 1.05rem;
  background: var(--acid);
  flex: none;
}
.subtitle {
  color: var(--dim);
  font-size: var(--t-xs);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-top: 0.45rem;
  font-family: var(--mono);
}

.header-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
}
.header-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  font-family: var(--mono);
}
.clock-city  { font-size: var(--t-label); letter-spacing: 0.22em; text-transform: uppercase; color: var(--mute); }
.clock-time  { font-size: var(--t-lg); color: var(--ink); letter-spacing: 0.02em; font-weight: 500; }
.clock-market { font-size: var(--t-label); letter-spacing: 0.18em; text-transform: uppercase; }
.clock-market.open   { color: var(--acid); }
.clock-market.closed { color: var(--mute); }

.logout-form { margin: 0; }
.logout-btn {
  background: none;
  border: 1px solid var(--line-hi);
  color: var(--mute);
  font-family: var(--mono);
  font-size: var(--t-label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.28rem 0.7rem;
  border-radius: var(--radius);
  cursor: pointer;
}
.logout-btn:hover { border-color: var(--rust); color: var(--rust); }

/* ── Tabs ────────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--line);
  margin-bottom: -1px;
}
.tab-btn {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--mute);
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
}
.tab-btn:hover:not(.active) { color: var(--ink); }
.tab-btn.active { color: var(--acid); border-bottom-color: var(--acid); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.shell { padding: 1.75rem var(--shell-x) 4rem; }

/* ── Panels ──────────────────────────────────────────────────────────────── */

.form-card,
.general-chat-card,
.history-wrap,
.queue-wrap,
.portfolio-summary-bar,
.chart-section,
.news-strip,
.suggestion-chips,
#tab-cyclical .cyc-table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.form-card { padding: 1.25rem; max-width: 560px; }
.form-row { display: flex; gap: var(--gap); flex-wrap: wrap; margin-bottom: var(--gap); }
.form-group { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; min-width: 140px; }

label,
.field-label,
.stat-label,
.ps-label,
.bt-stat-label,
.chart-label,
.news-strip-label,
.general-chat-title,
.consensus-bar-label,
.suggestion-chips-label,
.panel-header-title,
.role-card-title,
.section-title {
  font-family: var(--mono);
  font-size: var(--t-label);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 400;
}

input, select, textarea {
  background: var(--sunk);
  border: 1px solid var(--line-hi);
  color: var(--ink);
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  font-size: var(--t-base);
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.12s;
  max-width: 100%;
}
/* Full width only where the control owns a labelled column. A blanket
   width:100% stretched the bare selects on the Cyclical tab across the page. */
.form-group input, .form-group select, .form-group textarea,
.login-field input { width: 100%; }
input::placeholder { color: var(--mute); opacity: 1; }
input:hover, select:hover { border-color: var(--mute); }
select {
  appearance: none;
  /* Chevron drawn with gradients rather than a glyph: the Plex subset has no
     triangle, and a missing glyph renders as a tofu box. */
  background-image:
    linear-gradient(45deg, transparent 50%, var(--dim) 50%),
    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: right 0.85rem center, right 0.55rem center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 1.8rem;
}
select option { background: var(--panel); color: var(--ink); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.submit-btn {
  background: var(--acid);
  color: var(--ground);
  border: 0;
  padding: 0.62rem 1.6rem;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  width: 100%;
  margin-top: 0.4rem;
  transition: background 0.12s;
}
.submit-btn:hover:not(:disabled) { background: #DBFF6A; }
.submit-btn:disabled { background: var(--line-hi); color: var(--mute); cursor: not-allowed; }

.add-btn,
.clear-all-btn,
.queue-action-btn,
.round-tab-btn,
.bt-h-btn,
.role-btn,
.chat-quick-chip {
  background: var(--raise);
  border: 1px solid var(--line-hi);
  color: var(--dim);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.08em;
  padding: 0.3rem 0.75rem;
  transition: border-color 0.12s, color 0.12s;
}
.add-btn:hover, .clear-all-btn:hover, .queue-action-btn:hover,
.round-tab-btn:hover, .bt-h-btn:hover, .role-btn:hover, .chat-quick-chip:hover {
  border-color: var(--acid-dim);
  color: var(--ink);
}
.add-btn { border-style: dashed; margin-top: 0.4rem; }
.round-tab-btn.active, .bt-h-btn.active {
  border-color: var(--acid);
  color: var(--acid);
  background: var(--acid-wash);
}
.clear-all-btn:hover, .queue-action-btn.danger:hover { border-color: var(--rust); color: var(--rust); }

.remove-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--mute);
  cursor: pointer;
  font-size: var(--t-md);
  line-height: 1;
  padding: 0.25rem 0.45rem;
  border-radius: var(--radius);
}
.remove-btn:hover { color: var(--rust); border-color: var(--rust); }

.chat-send-btn {
  background: var(--acid);
  color: var(--ground);
  border: 0;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--mono);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chat-send-btn:hover:not(:disabled) { background: #DBFF6A; }
.chat-send-btn:disabled { background: var(--line-hi); color: var(--mute); cursor: not-allowed; }

.panel-close-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--mute);
  font-size: var(--t-lg);
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius);
}
.panel-close-btn:hover { color: var(--ink); border-color: var(--line-hi); }

/* ── Loader / errors ─────────────────────────────────────────────────────── */

.loader {
  display: none;
  align-items: center;
  gap: 0.65rem;
  color: var(--dim);
  margin-top: var(--gap);
  font-family: var(--mono);
  font-size: var(--t-sm);
  letter-spacing: 0.06em;
}
.loader.show { display: flex; }
.spinner {
  width: 13px; height: 13px;
  border: 1.5px solid var(--line-hi);
  border-top-color: var(--acid);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  display: none;
  background: var(--rust-wash);
  border: 1px solid var(--rust);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--rust);
  margin-top: var(--gap);
  font-family: var(--mono);
  font-size: var(--t-sm);
}

/* ── Results ─────────────────────────────────────────────────────────────── */

#results, #batch-results { display: none; margin-top: 1.75rem; }
.results-header {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.results-header h2 {
  font-family: var(--mono);
  font-size: var(--t-xl);
  font-weight: 500;
  letter-spacing: 0.04em;
}
.price-badge {
  background: var(--raise);
  border: 1px solid var(--line-hi);
  border-radius: var(--radius);
  padding: 0.2rem 0.6rem;
  font-size: var(--t-xs);
  color: var(--dim);
  font-family: var(--mono);
}

/* ── Verdict slab ────────────────────────────────────────────────────────── */
/* The verdict and its caveat are one component, not two. There is no markup
   here that renders BUY or AVOID without the ::after strip underneath it. */

.verdict-banner {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-hi);
  border-radius: var(--radius);
  margin: 0 0 1.75rem;
  padding: 1.35rem 1.5rem 0;
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  flex-wrap: wrap;
}
.verdict-banner.BUY   { border-left-color: var(--acid); }
.verdict-banner.AVOID { border-left-color: var(--rust); }
.verdict-banner.WAIT  { border-left-color: var(--rose); }
.verdict-banner::after {
  content: 'Paper only. No setup in this system has a demonstrated edge — treat this as a record of what the committee argued, not a recommendation.';
  order: 99;
  /* Full bleed to both card edges. width:100% resolves against the flex
     container's content box, so the negative margins would shift the strip
     left and leave a gap on the right; the calc puts the padding back. */
  width: calc(100% + 3rem);
  margin: 1.25rem -1.5rem 0;
  padding: 0.6rem 1.5rem;
  border-top: 1px solid var(--line);
  background: var(--sunk);
  color: var(--rose);
  font-family: var(--mono);
  font-size: var(--t-label);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  line-height: 1.7;
}
.verdict-label {
  font-family: var(--mono);
  font-size: var(--t-slab);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 0.95;
  color: var(--ink);
}
.BUY   .verdict-label { color: var(--acid); }
.AVOID .verdict-label { color: var(--rust); }
.WAIT  .verdict-label { color: var(--rose); }

.verdict-stats { display: flex; gap: 1.75rem; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 0.15rem; }
.stat-value { font-family: var(--mono); font-size: var(--t-lg); font-weight: 500; color: var(--ink); }
.verdict-rationale {
  color: var(--dim);
  font-size: var(--t-sm);
  flex: 1;
  min-width: 220px;
  line-height: 1.65;
}
.verdict-resolution {
  width: 100%;
  background: var(--raise);
  border-left: 2px solid var(--line-hi);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.55rem 0.9rem;
  font-size: var(--t-sm);
  color: var(--dim);
  margin-top: 0.4rem;
}
.verdict-resolution strong { color: var(--ink); font-weight: 500; }

/* ── Consensus row ───────────────────────────────────────────────────────── */

.consensus-bar { display: flex; align-items: center; gap: 0.4rem; margin-bottom: var(--gap); flex-wrap: wrap; }
.role-tag {
  font-family: var(--mono);
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius);
  font-size: var(--t-label);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  border: 1px solid;
}
.role-tag.bull    { background: var(--acid-wash); color: var(--acid); border-color: var(--acid-dim); }
.role-tag.bear    { background: var(--rust-wash); color: var(--rust); border-color: var(--rust); }
.role-tag.neutral { background: var(--raise);     color: var(--dim);  border-color: var(--line-hi); }

.debate-winner {
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-left: auto;
}
.debate-winner.bulls { color: var(--acid); }
.debate-winner.bears { color: var(--rust); }
.debate-winner.draw  { color: var(--dim); }

/* ── Disclosure rounds ───────────────────────────────────────────────────── */

details { margin-bottom: 0.6rem; }
details summary {
  cursor: pointer;
  padding: 0.55rem 0.9rem;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--dim);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
details summary::-webkit-details-marker { display: none; }
details summary:hover { color: var(--ink); }
/* Drawn, not typed: the self-hosted Plex subset has no U+25B6, and a glyph
   the font does not carry renders as a tofu box. */
details summary::before {
  content: '';
  width: 0; height: 0;
  border-left: 5px solid var(--acid);
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  transition: transform 0.15s;
  flex: none;
}
details[open] summary::before { transform: rotate(90deg); }
details[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; color: var(--ink); }

.round-content {
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1px;
  background: var(--line);
}

/* ── Role cards ──────────────────────────────────────────────────────────── */

.role-card {
  background: var(--panel);
  border: 0;
  padding: 1rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.role-card:hover { background: var(--raise); }
.role-card-number {
  font-family: var(--mono);
  font-size: var(--t-xl);
  font-weight: 600;
  color: var(--line-hi);
  line-height: 1;
  margin-bottom: 0.4rem;
  display: block;
}
.role-card-title { display: block; margin-bottom: 0.6rem; }
.role-card.value  .role-card-number, .role-card.fundamental .role-card-number { color: var(--acid-dim); }
.role-card.macro  .role-card-number { color: var(--dim); }
.role-card.risk   .role-card-number, .role-card.devil .role-card-number { color: var(--rust); }
.role-card.decision .role-card-number { color: var(--rose); }

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-sm);
}
.metric-row:last-of-type { border-bottom: none; }
.metric-key { color: var(--mute); }
.metric-val { font-family: var(--mono); font-size: var(--t-sm); color: var(--ink); text-align: right; }
.card-summary { color: var(--dim); font-size: var(--t-sm); margin-top: 0.55rem; line-height: 1.6; }

.revised-badge {
  display: inline-block;
  background: var(--acid-wash);
  color: var(--acid);
  border: 1px solid var(--acid-dim);
  font-family: var(--mono);
  font-size: var(--t-label);
  letter-spacing: 0.1em;
  padding: 0.05rem 0.35rem;
  border-radius: var(--radius);
  margin-left: 0.4rem;
  text-transform: uppercase;
}
.key-revision { font-size: var(--t-sm); color: var(--acid); margin-top: 0.45rem; }

/* ── Risks ───────────────────────────────────────────────────────────────── */

.risk-list { margin-top: 0.45rem; display: flex; flex-direction: column; gap: 0.3rem; }
.risk-item {
  background: var(--raise);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.4rem 0.6rem;
  border-left: 2px solid var(--line-hi);
}
.risk-item.low      { border-color: var(--acid-dim); }
.risk-item.medium   { border-color: var(--rose); }
.risk-item.high     { border-color: var(--rust); }
.risk-item.critical { border-color: var(--rust); background: var(--rust-wash); }
.risk-header { display: flex; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.15rem; }
.risk-type { font-family: var(--mono); font-size: var(--t-label); text-transform: uppercase; letter-spacing: 0.12em; color: var(--mute); }
.risk-sev  { font-family: var(--mono); font-size: var(--t-label); text-transform: uppercase; letter-spacing: 0.12em; }
.risk-sev.low { color: var(--acid); }
.risk-sev.medium { color: var(--rose); }
.risk-sev.high, .risk-sev.critical { color: var(--rust); }
.risk-desc { font-size: var(--t-sm); line-height: 1.5; color: var(--dim); }

/* ── Batch ───────────────────────────────────────────────────────────────── */

.batch-ticker-row { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 0.45rem; }
.batch-ticker-row input, .batch-ticker-row select { flex: 1; }

.portfolio-summary-bar {
  padding: 0.9rem 1.25rem;
  margin-bottom: var(--gap);
  display: flex;
  gap: 1.75rem;
  flex-wrap: wrap;
  align-items: center;
}
.ps-stat { display: flex; flex-direction: column; gap: 0.1rem; }
.ps-value { font-family: var(--mono); font-size: var(--t-xl); font-weight: 500; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
/* One table treatment for all six tables in the app. Header rows stick, so a
   long ledger keeps its column names while it scrolls. */

.alloc-table, .history-table, .queue-table, .bt-table, #tab-cyclical .cyc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
  font-family: var(--mono);
}
.alloc-table th, .history-table th, .queue-table th, .bt-table th,
#tab-cyclical .cyc-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 0.5rem 0.8rem;
  background: var(--raise);
  color: var(--mute);
  font-weight: 500;
  font-size: var(--t-label);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  border-bottom: 1px solid var(--line-hi);
  white-space: nowrap;
}
.alloc-table td, .history-table td, .queue-table td, .bt-table td,
#tab-cyclical .cyc-table td {
  padding: 0.45rem 0.8rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink);
}
.alloc-table tr:last-child td, .history-table tr:last-child td,
.queue-table tr:last-child td, .bt-table tr:last-child td,
#tab-cyclical .cyc-table tr:last-child td { border-bottom: none; }

.history-table tbody tr:hover td, .queue-table tbody tr:hover td,
.bt-table tbody tr:hover td, .alloc-table tbody tr:hover td,
#tab-cyclical .cyc-table tbody tr:hover td { background: var(--raise); }

.alloc-table { margin-top: var(--gap); }
.history-wrap, .queue-wrap { overflow: hidden; }
.history-empty, .queue-empty {
  padding: 2rem;
  text-align: center;
  color: var(--mute);
  font-family: var(--mono);
  font-size: var(--t-sm);
  letter-spacing: 0.06em;
}
.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: var(--raise);
}
.queue-header h3 {
  font-family: var(--mono);
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--dim);
}

.badge {
  display: inline-block;
  font-family: var(--mono);
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius);
  font-size: var(--t-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid;
}
.badge.BUY   { background: var(--acid-wash); color: var(--acid); border-color: var(--acid-dim); }
.badge.AVOID { background: var(--rust-wash); color: var(--rust); border-color: var(--rust); }
.badge.WAIT  { background: var(--rose-wash); color: var(--rose); border-color: var(--rose); }

.priority-badge, .chip {
  display: inline-block;
  font-family: var(--mono);
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius);
  font-size: var(--t-label);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  border: 1px solid;
}
.priority-badge.high,   .chip.high   { background: var(--rust-wash); color: var(--rust); border-color: var(--rust); }
.priority-badge.medium, .chip.medium { background: var(--rose-wash); color: var(--rose); border-color: var(--rose); }
.priority-badge.low,    .chip.low    { background: var(--raise);     color: var(--dim);  border-color: var(--line-hi); }
.chip { cursor: pointer; }
.chip:hover { border-color: var(--acid); color: var(--acid); }

.section-title { display: block; margin: 1.25rem 0 0.5rem; }

.count-badge {
  display: inline-block;
  background: var(--acid);
  color: var(--ground);
  font-family: var(--mono);
  font-size: var(--t-label);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.05rem 0.35rem;
  border-radius: var(--radius);
  margin-left: 0.3rem;
  vertical-align: 0.05em;
}

.suggestion-chips {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: var(--gap);
  padding: 0.55rem 0.85rem;
}

/* ── Inspector panel ─────────────────────────────────────────────────────── */

.role-panel {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: min(480px, 100vw);
  background: var(--panel);
  border-left: 1px solid var(--line-hi);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  z-index: 200;
  display: flex;
  flex-direction: column;
}
.role-panel.open { transform: translateX(0); }
.panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 4, 0.72);
  z-index: 199;
}
.panel-overlay.show { display: block; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--raise);
  flex-shrink: 0;
}
.round-tabs-bar {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.panel-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.panel-output { padding: 0.9rem 1rem; }
.full-field {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-sm);
}
.full-field:last-child { border-bottom: none; }
.field-label { flex-shrink: 0; }
.field-val {
  font-family: var(--mono);
  font-size: var(--t-sm);
  text-align: right;
  word-break: break-word;
  max-width: 62%;
  color: var(--ink);
}
.panel-chat-divider {
  font-family: var(--mono);
  font-size: var(--t-label);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--mute);
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--raise);
  flex-shrink: 0;
}
.panel-chat-thread-wrapper { padding: 0.5rem 1rem 1rem; }
.chat-bubble {
  max-width: 88%;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius);
  font-size: var(--t-sm);
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  border: 1px solid var(--line);
}
.chat-bubble.user      { background: var(--acid-wash); border-color: var(--acid-dim); color: var(--ink); align-self: flex-end; margin-left: auto; }
.chat-bubble.assistant { background: var(--raise);     color: var(--ink); align-self: flex-start; }
.panel-bottom { flex-shrink: 0; border-top: 1px solid var(--line); background: var(--panel); }
.chat-quick-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0.55rem 1rem 0.35rem; }
.chat-input-row { display: flex; gap: 0.45rem; padding: 0.6rem 1rem 0.8rem; }
.chat-input-row input { flex: 1; }

.general-chat-card { padding: 1.1rem 1.25rem; margin-bottom: var(--gap); }
.general-chat-title { display: block; margin-bottom: 0.75rem; }
.role-btn-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip-market { background: var(--rose-wash); border-color: var(--rose); color: var(--rose); }
.chip-market:hover, .chip-market.active { border-color: var(--rose); color: var(--rose); }

/* ── Chart + news ────────────────────────────────────────────────────────── */

.chart-section { padding: 0.7rem 0.7rem 0.4rem; margin: var(--gap) 0; }
.chart-label, .news-strip-label { display: block; margin-bottom: 0.45rem; }
.chart-section svg, .chart-section img, .chart-section canvas { max-width: 100%; height: auto; }
.news-strip { padding: 0.6rem 0.9rem; margin: var(--gap) 0; }
.news-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.32rem 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-sm);
}
.news-item:last-child { border-bottom: none; }
.news-item a { color: var(--ink); text-decoration: none; flex: 1; border-bottom: 1px solid transparent; }
.news-item a:hover { color: var(--acid); border-bottom-color: var(--acid-dim); }
.news-pub { color: var(--mute); font-family: var(--mono); font-size: var(--t-label); white-space: nowrap; letter-spacing: 0.06em; }

/* ── Backtest ────────────────────────────────────────────────────────────── */

.bt-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--gap); }
.bt-stat { display: flex; flex-direction: column; gap: 0.15rem; }
.bt-stat-val { font-family: var(--mono); font-size: var(--t-2xl); font-weight: 500; letter-spacing: -0.02em; }
.bt-table { margin-top: 0.5rem; }
.outcome-win  { color: var(--acid); }
.outcome-loss { color: var(--rust); }
.outcome-miss { color: var(--rose); }
.outcome-pend { color: var(--mute); }

/* ── Cyclical tab ────────────────────────────────────────────────────────── */

#tab-cyclical .cyc-section { margin-bottom: 2.25rem; }
#tab-cyclical .cyc-h2 {
  font-family: var(--mono);
  font-size: var(--t-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--dim);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
#tab-cyclical .cyc-h2::before {
  content: '';
  width: 0.4rem; height: 0.4rem;
  background: var(--acid);
  flex: none;
}
#tab-cyclical .cyc-table-wrap { overflow: auto; max-height: 70vh; }
#tab-cyclical .cyc-yes   { color: var(--acid); font-weight: 500; }
#tab-cyclical .cyc-no    { color: var(--mute); }
#tab-cyclical .cyc-fired { color: var(--rust); font-weight: 500; }
#tab-cyclical .cyc-held  { color: var(--rose); font-weight: 500; cursor: help; border-bottom: 1px dotted var(--rose); }
#tab-cyclical .cyc-loading {
  color: var(--dim); padding: 1rem 0.9rem;
  font-family: var(--mono); font-size: var(--t-sm); letter-spacing: 0.08em;
}
#tab-cyclical .cyc-err {
  color: var(--rust); padding: 1rem 0.9rem;
  font-family: var(--mono); font-size: var(--t-sm);
}

#cyc-stale-banner {
  display: none;
  background: var(--rust-wash);
  border: 1px solid var(--rust);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin-bottom: var(--gap);
  font-family: var(--mono);
  color: var(--rust);
}
#cyc-stale-banner.show { display: block; }
#cyc-stale-banner .cyc-headline {
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}
#cyc-stale-banner .cyc-detail { font-size: var(--t-xs); color: var(--dim); }

/* ── Generic prose inside tabs ───────────────────────────────────────────── */

.tab-content p  { color: var(--dim); font-size: var(--t-sm); line-height: 1.65; }
.tab-content h2 { font-family: var(--mono); font-size: var(--t-lg); font-weight: 500; letter-spacing: 0.03em; }
.tab-content h3 { font-family: var(--mono); font-size: var(--t-md); font-weight: 500; letter-spacing: 0.04em; }
.tab-content a  { color: var(--acid); }
strong, b { font-weight: 600; color: var(--ink); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }

/* ── Read-only marker ────────────────────────────────────────────────────── */

.ro-flag {
  display: inline-block;
  font-family: var(--mono);
  font-size: var(--t-label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rose);
  border: 1px solid var(--rose);
  background: var(--rose-wash);
  border-radius: var(--radius);
  padding: 0.1rem 0.45rem;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .header-top { gap: 0.9rem; }
  .header-side { align-items: flex-start; }
  .header-clock { align-items: flex-start; }
  .tab-btn { padding: 0.7rem 0.85rem; min-height: 44px; }
  .submit-btn, .chat-send-btn { min-height: 44px; }
  .form-card, .general-chat-card { max-width: 100%; }
  .round-content { grid-template-columns: 1fr; }
  .verdict-banner { padding: 1.1rem 1rem 0; gap: 1.1rem; }
  .verdict-banner::after { width: calc(100% + 2rem); margin: 1rem -1rem 0; padding: 0.6rem 1rem; }
  .verdict-label { font-size: var(--t-2xl); }
  .verdict-stats { gap: 1rem; }
  .history-wrap, .queue-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .history-table, .queue-table, .alloc-table, .bt-table { min-width: 520px; }
  .role-panel {
    width: 100%;
    height: 78vh;
    top: auto; left: 0; right: 0; bottom: 0;
    border-left: none;
    border-top: 1px solid var(--line-hi);
    border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(100%);
  }
  .role-panel.open { transform: translateY(0); }
  .panel-scroll { height: calc(78vh - 116px); }
}

/* ── Motion ──────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .spinner { border-top-color: var(--acid); }
}

/* ── Print ───────────────────────────────────────────────────────────────── */
/* A verdict printed or PDF'd without its caveat is the exact failure this
   design is guarding against, so the disclosure strip prints too. */

@media print {
  body { background: #fff; color: #000; }
  .site-header, .role-panel, .panel-overlay, .logout-form, .tabs { display: none !important; }
  .disclosure { display: block; color: #000; border-bottom: 1px solid #000; }
  .tab-content { display: block !important; }
}
