/* Trader desk — design tokens first, then layout, then components. Single-class selectors keep specificity flat. */
:root {
  --font-ui: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ed: "Newsreader", Georgia, "Times New Roman", serif;
  --ink: #0f1720;        /* page */
  --panel: #15202b;      /* raised surfaces */
  --raised: #1d2b39;     /* hover, inputs-on-panel */
  --line: #2b3b4c;
  --line-soft: #223242;
  --text: #e8eef4;
  --muted: #93a5b6;
  --faint: #64788b;
  --accent: #f0b44c;     /* chinook amber: focus, active, AI */
  --accent-soft: rgba(240, 180, 76, .13);
  --accent-ink: #1b1303;
  --info: #84bdea;
  --gain: #4ad69c;
  --gain-soft: rgba(74, 214, 156, .13);
  --loss: #ff7a76;
  --loss-soft: rgba(255, 122, 118, .13);
  --shadow: 0 24px 60px rgba(2, 8, 14, .55);
}
html[data-theme="light"] {
  --ink: #f2f5f8; --panel: #ffffff; --raised: #e9eef3; --line: #d1dbe4; --line-soft: #e2e8ee;
  --text: #14202b; --muted: #50647a; --faint: #7a8d9f;
  --accent: #9a5d00; --accent-soft: rgba(154, 93, 0, .1); --accent-ink: #fff;
  --info: #1d6fb0; --gain: #0b7a51; --gain-soft: rgba(11, 122, 81, .1);
  --loss: #c0313b; --loss-soft: rgba(192, 49, 59, .09);
  --shadow: 0 24px 60px rgba(20, 32, 43, .18);
}

* { box-sizing: border-box; margin: 0; }
html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }
body { background: var(--ink); color: var(--text); font: 400 15px/1.5 var(--font-ui);
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.num { text-align: right; white-space: nowrap; }
.scroll { overflow-x: auto; }

/* ── shell ── */
.shell { display: grid; grid-template-columns: 84px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 14px 8px; border-right: 1px solid var(--line-soft); background: var(--panel); }
.rail-brand { font: italic 500 26px/1 var(--font-ed); color: var(--accent); text-align: center; padding: 8px 0 18px; }
.nav-link { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px;
  border-radius: 12px; text-decoration: none; color: var(--muted); font-size: 12px; text-align: center; }
.nav-link:hover { background: var(--raised); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.main { min-width: 0; }
.deskbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 32px;
  background: color-mix(in srgb, var(--ink) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft); }
.deskbar-gap { flex: 1; }
.market { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot-on { background: var(--gain); }
.dot-warn { background: var(--accent); }
.dot-off { background: var(--loss); }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border: 1px solid var(--line);
  border-radius: 999px; background: transparent; font-size: 13px; }
button.pill:hover { background: var(--raised); }
.jump { position: relative; }
.jump svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.jump input { width: 190px; padding: 8px 12px 8px 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent; background: none; color: var(--muted); }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.view { max-width: 1200px; margin: 0 auto; padding: 36px 32px 96px; }

/* ── type & page structure ── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 8px; }
.page-title { font: 400 clamp(30px, 4vw, 42px)/1.1 var(--font-ed); letter-spacing: -.012em; }
.page-sub { color: var(--muted); max-width: 62ch; margin-top: 8px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-title { font: 400 clamp(32px, 5vw, 56px)/1.07 var(--font-ed); letter-spacing: -.015em; max-width: 20ch; text-wrap: balance; }
.hero-sub { color: var(--muted); margin-top: 12px; max-width: 60ch; }
.figures { display: flex; flex-wrap: wrap; gap: 14px 46px; margin-top: 26px; }
.fig-label { color: var(--muted); font-size: 13px; }
.fig-value { font: 500 27px/1.2 var(--font-ed); }
.sec { margin-top: 48px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.sec-title { font: 500 24px/1.2 var(--font-ed); }
.sec-note { color: var(--muted); font-size: 14px; }
.empty { padding: 28px 0; color: var(--muted); }
.help { color: var(--muted); font-size: 13.5px; max-width: 70ch; }

/* ── controls ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 7px 15px;
  border-radius: 10px; border: 1px solid var(--line); background: transparent; font-weight: 500; text-decoration: none; }
.btn:hover { background: var(--raised); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.07); }
.btn-quiet { border-color: transparent; color: var(--muted); }
.btn-sell { color: var(--loss); border-color: color-mix(in srgb, var(--loss) 45%, var(--line)); }
.btn-buy { color: var(--gain); border-color: color-mix(in srgb, var(--gain) 45%, var(--line)); }
.btn-sm { min-height: 32px; padding: 4px 11px; font-size: 14px; border-radius: 8px; }
.input, .select, .textarea { min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); width: 100%; }
.textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
.input-narrow { width: 130px; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 22px 0 6px; }
.filters .input { width: 230px; }
.filters .select { width: auto; min-width: 140px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.chip { padding: 5px 13px; border-radius: 999px; border: 1px solid var(--line); background: none; font-size: 14px; color: var(--muted); }
.chip:hover { color: var(--text); background: var(--raised); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.switch { position: relative; width: 44px; height: 26px; display: inline-block; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .switch-track { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--accent); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 14px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ── tags, tables ── */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tag-buy { color: var(--gain); background: var(--gain-soft); }
.tag-sell { color: var(--loss); background: var(--loss-soft); }
.tag-hold { color: var(--muted); background: var(--raised); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 500; font-size: 13px; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl td { padding: 13px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--raised) 55%, transparent); }
.row-link { cursor: pointer; }
.sym { font: 600 18px/1.2 var(--font-ed); }
.sym-sub { display: block; color: var(--muted); font: 400 13px/1.3 var(--font-ui); max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { display: inline-block; vertical-align: middle; width: 70px; height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }

/* ── decision queue ── */
.queue { border-top: 1px solid var(--line); }
.q-item { display: grid; grid-template-columns: 84px 130px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 4px; border-bottom: 1px solid var(--line-soft); }
.q-sym { font: 600 22px/1.1 var(--font-ed); }
.q-why { color: var(--muted); max-width: 66ch; }
.q-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ── news ── */
.news-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 56px; align-items: start; }
.n-item { padding: 18px 0; border-bottom: 1px solid var(--line-soft); max-width: 78ch; }
.n-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--muted); font-size: 13px; }
.n-src { color: var(--text); font-weight: 600; }
.n-title { display: block; margin: 6px 0 4px; font: 500 20px/1.3 var(--font-ed); text-decoration: none; }
.n-title:hover { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.n-sum { color: var(--muted); font-size: 14.5px; }
.n-compact .n-title { font-size: 17px; }
.side-block { position: sticky; top: 76px; border-left: 1px solid var(--line-soft); padding-left: 22px; }
.side-block h2 { font: 500 18px/1.2 var(--font-ed); margin-bottom: 8px; }
.side-block p { color: var(--muted); font-size: 14px; margin-bottom: 10px; }

/* ── ai ── */
.ai { padding: 6px 0 0; }
.verdict { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.verdict-word { font: 400 46px/1 var(--font-ed); letter-spacing: -.01em; }
.verdict-BUY { color: var(--gain); }
.verdict-SELL, .verdict-AVOID { color: var(--loss); }
.ai-sum { font: 400 19px/1.5 var(--font-ed); max-width: 64ch; margin: 14px 0; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 36px; }
.ai h3 { font: 600 15px/1.3 var(--font-ui); margin: 18px 0 6px; }
.ai ul { padding-left: 18px; color: var(--muted); }
.ai li { margin: 3px 0; max-width: 62ch; }
.disclaimer { margin-top: 18px; color: var(--faint); font-size: 13px; max-width: 64ch; }
.notice { padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.notice-accent { border-color: var(--accent); background: var(--accent-soft); }

/* ── settings ── */
.set-block { margin-top: 44px; }
.set-row { display: grid; grid-template-columns: minmax(0, 330px) minmax(0, 1fr); gap: 10px 44px; padding: 18px 0; border-bottom: 1px solid var(--line-soft); }
.set-row:first-of-type { border-top: 1px solid var(--line); }
.set-label { font-weight: 600; }
.set-help { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.mp { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); margin-top: 10px; overflow: hidden; }
.mp-top { padding: 10px; border-bottom: 1px solid var(--line-soft); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mp-list { max-height: 270px; overflow: auto; }
.mp-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 14px; width: 100%; text-align: left; padding: 9px 14px; background: none; border: 0; border-bottom: 1px solid var(--line-soft); }
.mp-row:hover { background: var(--raised); }
.mp-row[aria-selected="true"] { background: var(--accent-soft); }
.mp-id { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-price { color: var(--muted); font-size: 13px; text-align: right; }

/* ── drawer + dialog ── */
.dr-wrap { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.dr-backdrop { position: absolute; inset: 0; background: rgba(5, 10, 16, .5); opacity: 0; transition: opacity .2s; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: var(--shadow); overflow-y: auto; transform: translateX(100%); transition: transform .22s ease; }
.dr-wrap.open { pointer-events: auto; }
.dr-wrap.open .dr-backdrop { opacity: 1; }
.dr-wrap.open .drawer { transform: none; }
.dr-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px 12px; background: var(--panel); }
.dr-title { font: 500 32px/1.1 var(--font-ed); }
.dr-body { padding: 0 24px 40px; }
.dr-block { margin-top: 26px; }
.dr-block h3 { font: 500 19px/1.2 var(--font-ed); margin-bottom: 8px; }
.levels { display: flex; gap: 28px; flex-wrap: wrap; margin: 12px 0 6px; }
.levels dt { color: var(--muted); font-size: 13px; }
.levels dd { margin: 0; font: 500 19px/1.3 var(--font-ed); }
.ind { display: grid; grid-template-columns: 128px 76px minmax(0, 1fr); gap: 4px 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.ind-why { color: var(--muted); }
.pips { letter-spacing: 2px; color: var(--accent); font-size: 11px; }
.chart { width: 100%; height: auto; display: block; margin-top: 10px; }
.ch-axis { stroke: var(--line-soft); stroke-width: 1; }
.ch-label { fill: var(--faint); font-size: 11px; }
.ch-close { fill: none; stroke: var(--text); stroke-width: 1.8; }
.ch-ema9 { fill: none; stroke: var(--accent); stroke-width: 1.2; }
.ch-ema21 { fill: none; stroke: var(--info); stroke-width: 1.2; }
.ch-band { fill: var(--info); opacity: .1; }
.legend { display: flex; gap: 18px; font-size: 13px; color: var(--muted); margin-top: 4px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.dlg { margin: auto; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); padding: 0; width: min(480px, 92vw); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(5, 10, 16, .6); }
.dlg-body { padding: 24px; display: grid; gap: 14px; }
.dlg h2 { font: 500 26px/1.2 var(--font-ed); }
.dlg label { display: grid; gap: 5px; font-size: 14px; color: var(--muted); }
.dlg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.summary-box { padding: 12px 14px; border-radius: 12px; background: var(--raised); font-size: 14px; display: grid; gap: 3px; }

/* ── feedback ── */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: min(440px, 92vw); }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow); }
.toast-bad { border-color: var(--loss); }
.toast-good { border-color: var(--gain); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── login ── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); }
.login-mark { font: italic 500 30px/1 var(--font-ed); color: var(--accent); margin-bottom: 18px; }
.login h1 { font: 400 38px/1.1 var(--font-ed); letter-spacing: -.01em; margin-bottom: 8px; }
.login form { display: grid; gap: 14px; margin-top: 26px; }
.login label { display: grid; gap: 5px; color: var(--muted); font-size: 14px; }
.login-error { color: var(--loss); font-size: 14px; }

/* ── responsive ── */
@media (max-width: 980px) {
  .news-layout { grid-template-columns: 1fr; gap: 24px; }
  .side-block { position: static; border-left: 0; padding-left: 0; }
  .set-row { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; justify-content: space-around; z-index: 30;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); }
  .rail-brand { display: none; }
  .nav-link { flex: 1; font-size: 11px; padding: 6px 2px; }
  .deskbar { padding: 8px 16px; flex-wrap: wrap; }
  .jump input { width: 150px; }
  .view { padding: 24px 16px 120px; }
  .q-item { grid-template-columns: 1fr auto; }
  .q-why { grid-column: 1 / -1; }
  .q-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── additions: review tag, alerts, badges, linkish buttons ── */
.tag-review { background: var(--accent-soft); color: var(--accent); }
.notice-sell { border-color: var(--loss); }
.q-new { background: var(--accent-soft); margin: 0 -8px; padding-left: 12px; padding-right: 12px; border-radius: 8px; }
.linkish { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-align: left; }
.sym.linkish { font: 600 18px/1.2 var(--font-ed); }
.q-sym.linkish { font: 600 22px/1.1 var(--font-ed); }
.view:focus { outline: none; }
.linkish:hover { color: var(--accent); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; margin-left: 4px; position: absolute; top: 6px; right: 10px; }
.nav-link { position: relative; }
@media (max-width: 720px) { .badge { top: 2px; right: 6px; } }

/* ── AI layer: events, stances, briefs, chat, check points ── */
.ev { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); align-items: start; }
.ev-top { display: flex; gap: 10px; font-size: 13px; margin-bottom: 2px; }
.ai-stance { font-size: 13px; }
.ai-agree { color: var(--gain); } .ai-disagree { color: var(--loss); } .ai-unsure { color: var(--muted); }
.q-ai { display: block; margin-top: 4px; }
.brief { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 14px; padding: 18px 22px; background: var(--panel); }
.brief-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.brief-kind { font: 500 20px/1.2 var(--font-ed); }
.brief-lead { font: 500 20px/1.35 var(--font-ed); margin: 0 0 12px; max-width: 70ch; }
.brief-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 24px; font-size: 14px; margin-bottom: 10px; }
.chat-log { display: grid; gap: 12px; max-height: calc(100vh - 330px); overflow: auto; padding: 4px 2px; margin: 10px 0 14px; }
.msg { max-width: 76ch; }
.msg-me { justify-self: end; }
.msg-body { white-space: pre-wrap; padding: 12px 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); line-height: 1.5; }
.msg-me .msg-body { background: var(--accent-soft); border-color: transparent; }
.msg-ai .msg-body { font-family: var(--font-ed); font-size: 17px; }
.msg-meta { font-size: 12px; color: var(--muted); margin: 4px 6px 0; }
.chat-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; position: sticky; bottom: 0; background: var(--ink); padding: 8px 0 12px; }
.chat-input { min-height: 56px; }
.check-points { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.cp-risk { color: var(--loss); } .cp-ok { color: var(--gain); }
@media (max-width: 720px) { .chat-log { max-height: none; } .brief { padding: 14px 16px; } }
