/* Stock Desk: MarketSurge-style light theme (dark variant follows the system). */
:root {
  --bg: #eef0f3;
  --panel: #ffffff;
  --panel-2: #f4f6f8;
  --line: #d9dee5;
  --line-2: #eceff3;
  --text: #1b2430;
  --muted: #515c6b;
  --brand: #1a8a3a;
  --brand-2: #157231;
  --accent: #1f5fd6;
  --up: #1d3fd6;      /* bar colours, MarketSurge style */
  --down: #e0218a;
  --up-text: #0f8a3c;   /* table +/− colours */
  --down-text: #d32f2f;
  --ma50: #e53935;
  --ma200: #222222;
  --ma21: #2e9e5b;
  --ma10: #f2a900;
  --sp: #7fa6e8;
  --rs: #1f3fbf;
  --warn-bg: #fff6d6;
  --row-hover: #f2f6fc;
  --row-sel: #dfe9fb;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --panel: #131922; --panel-2: #19212c; --line: #263141; --line-2: #1d2634;
    --text: #e6edf3; --muted: #a6b1bf; --brand: #2ec27e; --brand-2: #26a269; --accent: #4c9aff;
    --up: #4c7dff; --down: #ff4fa8; --up-text: #3fd08a; --down-text: #ff6b72;
    --ma200: #cfd8e3; --sp: #5b7fc7; --rs: #7ea0ff; --warn-bg: #3a3212;
    --row-hover: #1c2632; --row-sel: #20344f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: auto; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13px/1.4 var(--sans);
  display: grid; grid-template-rows: auto auto 1fr auto; min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.num, .grid td, .kv dd { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.up { color: var(--up-text); }
.down { color: var(--down-text); }
.err { color: var(--down-text); }
.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button { font: inherit; color: inherit; cursor: pointer; }
button svg, .browse svg, .rail svg { width: 16px; height: 16px; fill: currentColor; vertical-align: -3px; }
.tag { font: 600 9.5px var(--sans); letter-spacing: .3px; padding: 1px 6px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip { font: 600 10.5px var(--sans); padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge { display: inline-block; min-width: 16px; padding: 0 5px; border-radius: 999px; background: var(--brand); color: #fff; font: 700 10px/16px var(--sans); text-align: center; margin-left: 4px; }

/* ---------- top bar ---------- */
.top {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
  position: sticky; top: 0; z-index: 35;
}
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--text); line-height: 1; margin-right: 6px; }
.wordmark { font: 800 19px/1 var(--sans); letter-spacing: .5px; color: var(--brand); }
.wordmark em { font-style: normal; color: var(--text); }
.brand small { font-size: 9px; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; margin-top: 3px; }
.search { position: relative; flex: 0 1 260px; display: flex; align-items: center; }
.search .s-icon { position: absolute; left: 8px; width: 16px; height: 16px; fill: currentColor; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; padding: 7px 26px 7px 30px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: 600 13px var(--mono); text-transform: uppercase;
}
.search input::placeholder { font: 13px var(--sans); text-transform: none; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#search-clear { position: absolute; right: 4px; border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 6px; }
#search-results {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px 0;
  list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); max-height: 60vh; overflow: auto;
}
#search-results li { padding: 6px 10px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
#search-results li b { min-width: 60px; font-family: var(--mono); }
#search-results li .lookup { color: var(--accent); font-size: 11px; }
#search-results li[aria-selected="true"], #search-results li:hover { background: var(--row-sel); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--panel); }
.seg button { background: transparent; border: 0; padding: 5px 10px; color: var(--muted); font-size: 12px; font-weight: 600; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.datenav { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.datenav button { border: 0; background: none; font-size: 18px; line-height: 1; padding: 2px 8px; color: var(--muted); }
.datenav input { border: 0; background: none; color: var(--text); font: 12px var(--mono); padding: 3px 2px; width: 118px; }
.datenav input::-webkit-calendar-picker-indicator { opacity: .6; }
.btn-green { background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: 7px 12px; font-weight: 700; }
.btn-green:hover { background: var(--brand-2); }
.btn-plain { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.market { display: flex; gap: 14px; margin-left: auto; white-space: nowrap; }
.market .ix { display: flex; gap: 5px; align-items: baseline; }
.market .ix b { font-weight: 700; }
.logout { color: var(--muted); text-decoration: none; }
.banner { padding: 6px 12px; background: var(--warn-bg); border-bottom: 1px solid var(--line); font-size: 12px; }

/* ---------- frame: page + rail + drawer ---------- */
.frame { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; min-height: 0; }
.stockpage { min-width: 0; display: grid; grid-template-rows: auto minmax(480px, 66vh) 460px; gap: 8px; padding: 8px; }

/* ---------- header ---------- */
.head { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: flex-start; }
.head-id { flex: 1 1 220px; min-width: 200px; }
.head-desc { flex: 1 1 260px; min-width: 220px; }
.head-stats { flex: 0 1 auto; }
.head-price { flex: 0 0 auto; margin-left: auto; }
#q-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.head-name { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.head-name h1 { margin: 0; font: 800 19px var(--sans); line-height: 1.15; }
.flagbtn { background: none; border: 0; padding: 0 2px; color: var(--line); }
.flagbtn[aria-pressed="true"] { color: var(--brand); }
.flagbtn svg { width: 18px; height: 18px; }
.head-name .sym { font-size: 13px; font-weight: 700; color: var(--muted); }
.head-actions { display: flex; gap: 6px; margin-top: 6px; position: relative; }
.head-actions button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.head-actions button:hover { background: var(--panel-2); }
.menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.18); min-width: 220px; padding: 4px 0; }
.menu button { display: flex; width: 100%; justify-content: space-between; border: 0; background: none; border-radius: 0; padding: 7px 12px; text-align: left; }
.menu button:hover { background: var(--row-hover); }
.menu .on { color: var(--brand); font-weight: 700; }
.head-desc p { margin: 0 0 4px; }
.head-stats { display: grid; grid-template-columns: repeat(3, auto); gap: 0 22px; }
.head-stats dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 2px 10px; }
.head-stats dt { color: var(--muted); font-family: var(--sans); font-size: 11.5px; white-space: nowrap; }
.head-stats dd { margin: 0; text-align: right; font-weight: 600; white-space: nowrap; }
.head-price { text-align: right; min-width: 130px; }
.head-price .big { font-size: 24px; font-weight: 700; line-height: 1.1; }
.head-price .chg { font-weight: 600; margin-top: 2px; }

/* ---------- chart ---------- */
.chartpane { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; display: flex; flex-direction: column; min-height: 0; }
.chart-tools { display: flex; gap: 4px; align-items: center; padding: 5px 8px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.chart-tools button { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 2px 7px; font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.chart-tools button[aria-pressed="true"] { color: var(--text); background: var(--panel-2); border-color: var(--muted); }
.sw { display: inline-block; width: 12px; height: 2px; background: currentColor; }
.sw-50 { background: var(--ma50); } .sw-200 { background: var(--ma200); } .sw-21 { background: var(--ma21); } .sw-10 { background: var(--ma10); }
.ohlc { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ohlc b { color: var(--text); font-weight: 600; }
.chart-wrap { position: relative; flex: 1; min-height: 300px; }
#chart { position: absolute; inset: 0; }
#chart-empty { position: absolute; inset: 40% 0 auto; text-align: center; font-size: 14px; }
.databox {
  position: absolute; top: 8px; left: 8px; z-index: 3; display: flex; flex-direction: column; gap: 2px; max-width: calc(100% - 90px); max-height: calc(100% - 16px); overflow: auto;
  background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line);
  border-radius: 4px; padding: 4px 6px; font-size: 11px; line-height: 1.25; pointer-events: auto;
}
.databox-grid { display: flex; gap: 6px; align-items: flex-start; }
.databox-head { display: flex; justify-content: flex-start; }
.databox table { border-collapse: collapse; }
.databox .ratings-2 { display: none; }
.databox.full .ratings-2 { display: table; }
.zoom { display: inline-flex; gap: 2px; margin-left: 4px; }
.zoom button { min-width: 24px; justify-content: center; }
.databox th { font: 600 10.5px var(--sans); color: var(--muted); text-align: right; padding: 1px 5px; white-space: nowrap; }
.databox th:first-child { text-align: left; }
.databox td { padding: 1px 5px; text-align: right; white-space: nowrap; }
.databox td:first-child { text-align: left; }
.databox .ratings td:first-child { font-family: var(--sans); color: var(--text); }
.databox .ratings td:last-child { font-weight: 700; }
.databox .ratings { border-left: 1px solid var(--line); }
.databox .hi { color: var(--up-text); } .databox .lo { color: var(--down-text); }
.earnings { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border-top: 1px solid var(--line); font-size: 11.5px; }
.earnings .qtr.labels { grid-auto-columns: auto; flex: none; }
.qtr { padding: 4px 10px; border-right: 1px solid var(--line-2); }
.qtr-h { font: 700 11.5px var(--sans); background: var(--panel-2); margin: 0 -10px 3px; padding: 3px 10px; border-bottom: 1px solid var(--line-2); }
.qtr-row { display: flex; gap: 14px; justify-content: space-between; padding: 1px 0; }
.qtr.labels { text-align: right; font-family: var(--sans); font-weight: 600; border-right: 0; }
.qtr.labels .qtr-row { justify-content: flex-end; }

/* ---------- bottom lists ---------- */
.bottom { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; min-height: 0; }
.bottom-nav { background: var(--panel); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.tabs { display: flex; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 6px; font-weight: 700; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--brand); border-color: var(--brand); }
.browse-row { display: flex; align-items: center; gap: 6px; margin: 6px 8px; }
.browse { flex: 1; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; color: var(--muted); }
.newbtn { background: none; border: 0; color: var(--text); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.browse input { border: 0; background: none; color: var(--text); flex: 1; font: inherit; outline: none; }
.tree { overflow: auto; flex: 1; padding: 0 4px 8px; }
.tree .grp { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-weight: 700; cursor: pointer; border-radius: 4px; }
.tree .grp:hover { background: var(--row-hover); }
.tree .grp .n { margin-left: auto; color: var(--muted); font-weight: 500; }
.tree .grp .caret { transition: transform .15s; color: var(--muted); }
.tree .grp[aria-expanded="false"] .caret { transform: rotate(-90deg); }
.tree .grp[aria-expanded="false"] + .items { display: none; }
.tree .item { display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 26px; cursor: pointer; border-radius: 4px; }
.tree .item:hover { background: var(--row-hover); }
.tree .item[aria-current="true"] { background: var(--row-sel); font-weight: 700; }
.tree .item .n { margin-left: auto; color: var(--muted); }
.tree .item.off { color: var(--muted); cursor: default; }
.tree .item.off:hover { background: none; }
.tree .icon-m { width: 14px; height: 14px; border-radius: 3px; background: var(--brand); color: #fff; font: 700 9px/14px var(--sans); text-align: center; flex: none; }
.tree .icon-m.off { background: var(--line); color: var(--muted); }
.tree .new { margin: 8px 8px 0; }
.tree .new button, .tree .del { background: none; border: 1px dashed var(--line); border-radius: 4px; padding: 4px 8px; color: var(--muted); width: 100%; }
.tree .del { width: auto; border: 0; padding: 0 4px; font-size: 14px; }
.tree p.info { padding: 8px 10px; margin: 0; }
.bottom-table { background: var(--panel); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.table-head { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.table-head h2 { margin: 0; font: 800 15px var(--sans); }
.table-head .icon { background: none; border: 0; color: var(--muted); padding: 2px; }
.table-head .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
#btn-play { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 4px 10px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
#btn-play[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
#play-speed { border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--text); padding: 3px 4px; font: inherit; }
.table-scroll { overflow: auto; flex: 1; }
.grid { width: 100%; border-collapse: collapse; }
.grid th {
  position: sticky; top: 0; background: var(--panel-2); z-index: 1; cursor: pointer; user-select: none;
  font: 600 10.5px/1.2 var(--sans); color: var(--text); text-align: right; padding: 5px 7px; border-bottom: 1px solid var(--line); white-space: normal; vertical-align: bottom; min-width: 56px;
}
.grid th.l, .grid td.l { text-align: left; }
.grid th[aria-sort="ascending"]::after { content: " ▲"; color: var(--brand); }
.grid th[aria-sort="descending"]::after { content: " ▼"; color: var(--brand); }
.grid td { text-align: right; padding: 4px 7px; border-bottom: 1px solid var(--line-2); white-space: nowrap; font-size: 12px; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: var(--row-hover); }
.grid tbody tr[aria-selected="true"] { background: var(--row-sel); }
.grid td.sym { font-weight: 700; }
.grid td.name { font-family: var(--sans); max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.grid td.flag { padding: 2px 4px; color: var(--line); }
.grid td.flag svg { width: 14px; height: 14px; fill: currentColor; vertical-align: -2px; }
.grid td.flag.on { color: var(--brand); }
.grid td.idx { color: var(--muted); }
.empty { padding: 16px 12px; margin: 0; }

/* ---------- right rail + drawer ---------- */
.rail { display: flex; flex-direction: column; gap: 2px; padding: 8px 4px; background: var(--panel); border-left: 1px solid var(--line); position: sticky; top: 46px; align-self: start; max-height: calc(100dvh - 46px); }
.rail button { background: none; border: 0; border-radius: 6px; padding: 8px 4px; width: 64px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 600; }
.rail button svg { width: 20px; height: 20px; }
.rail button:hover, .rail button[aria-pressed="true"] { background: var(--row-sel); color: var(--accent); }
.drawer { width: 320px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font: 800 14px var(--sans); }
#drawer-close { background: none; border: 0; font-size: 20px; color: var(--muted); }
.drawer-sym { padding: 6px 12px 0; font-weight: 700; }
.drawer-body { overflow: auto; padding: 10px 12px; }
.drawer .sub { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding: 8px 0 4px; margin: 6px 0 4px; font: 700 12.5px var(--sans); }
.drawer .btn-wide { display: block; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px; font-weight: 600; margin: 6px 0; }
.drawer select.filter { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; background: var(--panel-2); color: var(--text); margin-bottom: 8px; }
.drawer .news-item { padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.drawer .news-item time { display: block; font: 600 10.5px var(--sans); color: var(--muted); }
.drawer-body h3 { margin: 12px 0 6px; font: 700 11px var(--sans); text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin: 0; }
.kv dt { color: var(--muted); white-space: nowrap; }
.kv dd { margin: 0; text-align: right; }
.check { list-style: none; margin: 0; padding: 0; }
.check li { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line-2); align-items: center; }
.check .st { width: 16px; height: 16px; border-radius: 50%; font: 700 11px/16px var(--sans); text-align: center; color: #fff; background: var(--line); }
.check .pass .st { background: var(--up-text); } .check .fail .st { background: var(--down-text); }
.check .v { font-family: var(--mono); color: var(--muted); }
.mas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.mas div { text-align: center; padding: 5px 0; border-radius: 6px; border: 1px solid var(--line); font-size: 11.5px; }
.mas div.above { background: color-mix(in srgb, var(--up-text) 14%, transparent); color: var(--up-text); }
.mas div.below { background: color-mix(in srgb, var(--down-text) 12%, transparent); color: var(--down-text); }
.note { margin: 8px 0 0; padding: 8px 10px; border-radius: 6px; background: var(--panel-2); border-left: 3px solid var(--accent); }
.drawer textarea { width: 100%; min-height: 220px; border: 1px solid var(--line); border-radius: 6px; padding: 8px; font: 13px/1.4 var(--sans); background: var(--panel-2); color: var(--text); resize: vertical; }
.drawer form { display: grid; gap: 6px; }
.drawer form input, .drawer form select { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; background: var(--panel-2); color: var(--text); }
.drawer form button { background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: 7px; font-weight: 700; }
.alert-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.alert-row button { background: none; border: 0; color: var(--muted); }
.foot { display: flex; justify-content: space-between; gap: 12px; padding: 6px 12px; border-top: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.tabbar { display: none; }

/* ---------- narrower desktops / tablets ---------- */
@media (max-width: 1280px) {
  .head { grid-template-columns: minmax(200px, 1fr) auto auto; }
  .head-desc { grid-column: 1 / -1; grid-row: 2; }
  .drawer { width: 280px; }
}
@media (max-width: 1000px) {
  .stockpage { grid-template-rows: auto max(420px, 60vh) 440px; }
  .bottom { grid-template-columns: 240px minmax(0, 1fr); }
  .head-stats { grid-template-columns: 1fr 1fr; }
  .drawer { position: fixed; right: 64px; top: 0; bottom: 0; z-index: 25; box-shadow: -8px 0 24px rgba(0,0,0,.15); }
}

/* ---------- phone ---------- */
@media (max-width: 760px) {
  body { font-size: 13.5px; display: block; padding-bottom: calc(54px + env(safe-area-inset-bottom)); }
  .top { gap: 8px; padding: 8px 10px; }
  .brand small, .datenav, .btn-green, .btn-plain, .logout { display: none; }
  .search { flex: 1 1 100%; order: 1; }
  .search input { font-size: 16px; }
  .periods, .ranges { order: 2; }
  .market { order: 3; width: 100%; margin: 0; font-size: 12px; }
  .frame { display: block; }
  .stockpage { display: block; padding: 0; }
  .head, .chartpane, .bottom, .drawer { display: none; border-radius: 0; border-left: 0; border-right: 0; }
  body[data-view="chart"] .head { display: grid; grid-template-columns: 1fr auto; }
  body[data-view="chart"] .head-desc, body[data-view="chart"] .head-stats { display: none; }
  body[data-view="chart"] .chartpane { display: flex; height: max(460px, calc(100dvh - 300px)); }
  body[data-view="lists"] .bottom { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 44% minmax(0, 1fr); height: calc(100dvh - 190px); width: 100%; overflow: hidden; }
  body[data-view="lists"] .bottom-nav { max-height: none; min-height: 0; }
  body[data-view="data"] .drawer { display: flex; position: static; width: auto; box-shadow: none; }
  .rail { display: none; }
  .databox { font-size: 10px; }
  .databox .annual { display: none; }
  .earnings { grid-template-columns: 1fr 1fr; }
  .qtr.labels { display: none; }
  .ohlc { flex: 1 1 100%; margin-left: 0; font-size: 10.5px; }
  .grid td { padding: 7px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: var(--panel);
    padding-bottom: env(safe-area-inset-bottom); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  }
  .tabbar button { background: none; border: 0; padding: 12px 0; color: var(--muted); font-weight: 700; }
  .tabbar button[aria-current="true"] { color: var(--brand); }
}

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; }
.login { width: min(320px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.login img { align-self: center; border-radius: 10px; }
.login h1 { margin: 0; font-size: 20px; }
.login p { margin: 0 0 6px; }
.login input { padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 16px; }
.login button { padding: 10px; border-radius: 8px; border: 0; background: var(--brand); color: #fff; font-weight: 700; }

/* ---------- Stock Ideas window ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; }
.modal-box { width: min(680px, 100%); max-height: 90vh; display: flex; flex-direction: column; background: var(--panel); border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font: 800 16px var(--sans); }
#ideas-close { background: none; border: 0; font-size: 22px; color: var(--muted); }
.modal-lead { margin: 0; padding: 10px 16px 4px; }
.modal-tabs { padding: 6px 16px; border-bottom: 0; }
.ideas-body { overflow: auto; padding: 4px 16px 16px; }
.ideas-body h3 { margin: 12px 0 4px; font: 700 12px var(--sans); }
.idea { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line-2); cursor: pointer; border-radius: 6px; }
.idea:hover { background: var(--row-hover); }
.idea.off { cursor: default; color: var(--muted); }
.idea svg { width: 28px; height: 28px; fill: none; stroke: var(--brand); stroke-width: 1.6; }
.idea.off svg { stroke: var(--line); }
.idea b { display: block; color: var(--accent); }
.idea.off b { color: var(--muted); }
.idea .n { font-family: var(--mono); color: var(--muted); }
@media (max-width: 760px) { .modal { padding: 8px; } .idea { grid-template-columns: 1fr auto; } .idea svg { display: none; } }

/* ---------- verdict ---------- */
.verdict { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 6px; padding: 6px 10px; border-radius: 6px; background: var(--panel-2); border-left: 4px solid var(--line); }
.verdict .v-label { font: 800 12px var(--sans); letter-spacing: .4px; white-space: nowrap; padding: 2px 8px; border-radius: 4px; color: #fff; background: var(--muted); }
.verdict ul { margin: 0; padding-left: 16px; font-size: 11.5px; }
.verdict[data-v="BUY CANDIDATE"] { border-left-color: var(--up-text); } .verdict[data-v="BUY CANDIDATE"] .v-label { background: var(--up-text); }
.verdict[data-v="WATCH"] { border-left-color: var(--ma10); } .verdict[data-v="WATCH"] .v-label { background: var(--ma10); color: #222; }
.verdict[data-v="HOLD LONG-TERM"] { border-left-color: var(--accent); } .verdict[data-v="HOLD LONG-TERM"] .v-label { background: var(--accent); }
.verdict[data-v="AVOID"] { border-left-color: var(--down-text); } .verdict[data-v="AVOID"] .v-label { background: var(--down-text); }
.grid td.verdict-cell { font-family: var(--sans); font-weight: 700; font-size: 11px; }
.grid td.verdict-cell.BUY { color: var(--up-text); } .grid td.verdict-cell.AVOID { color: var(--down-text); } .grid td.verdict-cell.HOLD { color: var(--accent); } .grid td.verdict-cell.WATCH { color: var(--ma10); }

.report { margin: 0; white-space: pre-wrap; font: 12.5px/1.5 var(--mono); color: var(--text); }

.market-call { border: 0; border-radius: 4px; padding: 4px 8px; font: 800 11px var(--sans); letter-spacing: .3px; color: #fff; background: var(--muted); white-space: nowrap; }
.market-call[data-v="uptrend"] { background: var(--up-text); } .market-call[data-v="under_pressure"] { background: var(--ma10); color: #222; } .market-call[data-v="correction"] { background: var(--down-text); }

.base-label { position: absolute; right: 70px; top: 8px; z-index: 3; background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--up-text); border-radius: 4px; padding: 3px 8px; font-size: 11px; }
.base-label b { color: var(--up-text); text-transform: capitalize; }
@media (max-width: 760px) { .base-label { right: 8px; top: auto; bottom: 8px; } }

.btn-plan { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 7px 12px; font-weight: 700; }
.plan { padding: 10px 14px; }
.plan h3 { margin: 12px 0 6px; font: 800 12px var(--sans); text-transform: uppercase; letter-spacing: .5px; }
.plan .note { margin: 0 0 6px; }
.plan table { width: 100%; border-collapse: collapse; }
.plan th { text-align: right; font: 600 10.5px var(--sans); color: var(--muted); padding: 4px 6px; border-bottom: 1px solid var(--line); }
.plan th.l, .plan td.l { text-align: left; }
.plan td { text-align: right; padding: 5px 6px; border-bottom: 1px solid var(--line-2); font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.plan td.l { font-family: var(--sans); white-space: normal; }
.plan tr.dim td { color: var(--muted); }
.plan tr[data-sym] { cursor: pointer; }
.plan .act { font: 700 11px var(--sans); }
.plan .act.buy { color: var(--up-text); } .plan .act.sell { color: var(--down-text); } .plan .act.trim { color: var(--ma10); } .plan .act.review { color: var(--accent); }
@media (max-width: 760px) { .btn-plan { display: inline-block; } .plan td, .plan th { padding: 4px; font-size: 11px; } }

#intraday-interval { border: 0; border-left: 1px solid var(--line); background: var(--brand); color: #fff; font: 600 12px var(--sans); padding: 0 4px; }

.databox-foot { font: 10.5px/1.35 var(--sans); color: var(--muted); max-width: 560px; padding-top: 3px; border-top: 1px solid var(--line-2); }
.databox-foot b { color: var(--text); font-weight: 600; }
.verdict { padding: 4px 8px; margin-bottom: 4px; }
.verdict ul { list-style: none; padding-left: 0; }
.verdict li.main { font-weight: 600; }
.linkbtn { background: none; border: 0; color: var(--accent); font: 600 11px var(--sans); padding: 0 4px; cursor: pointer; }
.sw-sp { background: var(--muted); height: 1px; } .sw-rs { background: var(--rs); }
.head-stats dt, .kv dt { color: var(--muted); }
@media (max-width: 1280px) { .head { flex-wrap: wrap; } }
@media (max-width: 1000px) { .stockpage { grid-template-rows: auto max(440px, 62vh) 440px; } }
