:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series: #2a78d6;
  --up: #006300;
  --down: #d03b3b;
  --hover: rgba(11, 11, 11, 0.04);
  --accent-wash: #cde2fb;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series: #3987e5;
    --up: #0ca30c;
    --down: #e66767;
    --hover: rgba(255, 255, 255, 0.05);
    --accent-wash: #184f95;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  padding: 16px 20px 40px;
  background: var(--page);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 14px; margin: 20px 0 8px; color: var(--text-2); }
.muted { color: var(--muted); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.up { color: var(--up); }
.down { color: var(--down); }

.btn {
  font: inherit;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { background: var(--hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn.active { background: var(--accent-wash); }
.pill { font-size: 11px; color: var(--text-2); }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.top-right { display: flex; align-items: center; gap: 12px; }
.toggle { font-size: 13px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }

.indices { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.card:hover { background: var(--hover); }
.card .label { font-size: 12px; color: var(--text-2); display: flex; justify-content: space-between; }
.card .value { font-size: 18px; font-weight: 600; margin-top: 2px; }
.card .delta { font-size: 12px; }
.card svg { display: block; margin-top: 6px; width: 100%; height: 28px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.search { position: relative; flex: 1; }
.search input {
  width: 100%;
  font: inherit;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.search-results {
  position: absolute;
  z-index: 20;
  left: 0; right: 0; top: 100%;
  margin: 4px 0 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.search-results li { padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.search-results li:hover, .search-results li.sel { background: var(--hover); }

.market { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 16px; overflow-x: auto; }
.market-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--grid); }
.market-head h2 { font-size: 15px; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--border); color: var(--text-2); }
.badge::before { content: "\25CF  "; }
.badge.open::before { color: var(--up); }
.badge.closed::before { color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th { font-weight: 500; font-size: 12px; color: var(--muted); text-align: left; padding: 6px 14px; }
th.num { text-align: right; }
td { padding: 8px 14px; border-top: 1px solid var(--grid); vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--hover); }
.sym { font-weight: 600; }
.name { font-size: 12px; color: var(--text-2); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aud { display: block; font-size: 11px; color: var(--muted); }
.spark { width: 110px; height: 30px; display: block; }
.range52 { width: 120px; }
.range52 .bar { position: relative; height: 4px; border-radius: 2px; background: var(--grid); margin: 4px 0; }
.range52 .dot { position: absolute; top: -3px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--series); border: 2px solid var(--surface); }
.range52 .ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.err { color: var(--down); font-size: 12px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(680px, 100%);
  overflow-y: auto;
  z-index: 30;
  padding: 18px 22px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.15);
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hero { font-size: 30px; font-weight: 600; margin: 12px 0 4px; }
.hero .delta { font-size: 15px; font-weight: 500; margin-left: 8px; }
.ranges { display: flex; gap: 4px; margin: 10px 0; }
.chart { position: relative; height: 280px; }
.chart svg { width: 100%; height: 100%; display: block; }
.tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 16px; margin: 14px 0 0; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; }
.alert-form { display: flex; gap: 8px; flex-wrap: wrap; }
.alert-form select, .alert-form input {
  font: inherit; padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.alert-form input { width: 120px; }
.alert-list { list-style: none; padding: 0; margin: 10px 0; }
.alert-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--grid); }
.alert-list .fired { color: var(--muted); }

.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); }
footer { margin-top: 24px; text-align: center; }

.title-nav { display: flex; align-items: center; gap: 16px; }
.tabs { display: flex; gap: 4px; }
.top-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.top-head .ranges { margin: 0; }
.drawer.wide { width: min(820px, 100%); }
.section { margin-top: 22px; }
.section h3 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.section .sub { margin: 0 0 10px; }
.summary { color: var(--text-2); font-size: 13px; max-height: 5.6em; overflow: hidden; margin: 10px 0 0; }
.summary.open { max-height: none; }
.link { background: none; border: 0; padding: 0; color: var(--series); cursor: pointer; font: inherit; font-size: 12px; }

/* analyst rating distribution: diverging blue (buy) -> gray (hold) -> red (sell) */
:root { --r-sb: #1c5cab; --r-b: #6da7ec; --r-h: #c3c2b7; --r-s: #f0a3a2; --r-ss: #d03b3b; --series-2: #eb6834; }
@media (prefers-color-scheme: dark) { :root { --r-sb: #3987e5; --r-b: #184f95; --r-h: #52514e; --r-s: #8f3434; --r-ss: #e66767; --series-2: #d95926; } }
.dist { display: flex; gap: 2px; height: 10px; border-radius: 3px; overflow: hidden; min-width: 80px; }
.dist span { display: block; height: 100%; }
.dist.big { height: 22px; }
.dist.big span { display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff; font-weight: 600; }
.dist.big span.dk { color: #0b0b0b; }
@media (prefers-color-scheme: dark) { .dist.big span.dk { color: #fff; } }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.trend-row { display: grid; grid-template-columns: 80px 1fr 40px; gap: 10px; align-items: center; font-size: 12px; color: var(--text-2); margin: 4px 0; }
.rating { font-weight: 600; }
.target { position: relative; height: 34px; margin: 18px 8px 26px; }
.target .line { position: absolute; top: 16px; left: 0; right: 0; height: 2px; background: var(--axis); }
.target .mk { position: absolute; top: 10px; width: 2px; height: 14px; margin-left: -1px; background: var(--muted); }
.target .mk.mean { background: var(--series); width: 3px; }
.target .mk.now { background: var(--text); height: 20px; top: 7px; }
.target .lab { position: absolute; font-size: 11px; color: var(--text-2); transform: translateX(-50%); white-space: nowrap; }
.target .lab.top { top: -10px; }
.target .lab.bot { top: 28px; }
.target .lab.lo { transform: none; }
.target .lab.hi { transform: translateX(-100%); }
.bars { position: relative; height: 220px; }
.bars svg { width: 100%; height: 100%; display: block; }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px 20px; }
.metrics h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.metrics div.kv { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 2px 0; }
.metrics div.kv span:last-child { font-variant-numeric: tabular-nums; }
.eps td, .eps th { padding: 4px 10px; font-size: 12px; }

@media (max-width: 700px) {
  .hide-sm { display: none; }
  td, th { padding: 8px; }
}
