:root {
  --bg: #0b0f0e;
  --panel: #121917;
  --panel-2: #18211e;
  --line: #24302c;
  --text: #e6efec;
  --muted: #8a9a95;
  --mint: #34d399;
  --mint-dim: #1f6f55;
  --red: #f87171;
  --amber: #fbbf24;
  --blue: #60a5fa;
  --radius: 12px;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, sans-serif; }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--red); min-height: 1em; margin: 8px 0 0; }
.up { color: var(--mint); }
.down { color: var(--red); }

/* header */
.top { display: flex; align-items: center; gap: 24px; padding: 14px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(11, 15, 14, .92); backdrop-filter: blur(8px); z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand.big { font-size: 22px; justify-content: center; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--mint), #0ea5a4); box-shadow: 0 0 18px rgba(52, 211, 153, .35); }
.pill { font-size: 10px; letter-spacing: .1em; padding: 3px 7px; border-radius: 99px; font-weight: 700; }
.pill.paper { background: rgba(251, 191, 36, .14); color: var(--amber); border: 1px solid rgba(251, 191, 36, .35); }
.top-stats { display: flex; gap: 28px; margin-left: auto; }
.top-stats div { display: flex; flex-direction: column; }
.lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.tabs { display: flex; gap: 4px; padding: 10px 24px 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 10px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--mint); }

main { padding: 20px 24px 48px; max-width: 1400px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }
.grid { display: grid; gap: 16px; }
.grid.desk { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.grid.lab { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr); }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.tab > .card + .card { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

/* inputs */
input, select, textarea { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--mint-dim); box-shadow: 0 0 0 3px rgba(52, 211, 153, .12); }
textarea { width: 100%; font-family: var(--mono); font-size: 12px; resize: vertical; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.field > span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field.inline { margin: 0; }
.field b { padding: 9px 0; }
.search input { flex: 1; text-transform: uppercase; }
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: #3a4a45; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--mint); border-color: var(--mint); color: #04130d; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.danger { background: var(--red); border-color: var(--red); color: #1a0505; }
.btn.ghost { background: none; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.wide { width: 100%; padding: 12px; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; margin-bottom: 12px; }
.seg button { border: 0; background: none; padding: 6px 18px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button.active.buy { background: var(--mint); color: #04130d; }
.seg button.active.sell { background: var(--red); color: #1a0505; }

/* quote */
.quote { padding: 14px 2px 8px; }
.quote.empty, .empty { color: var(--muted); padding: 24px 4px; }
.q-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.q-sym { font-size: 22px; font-weight: 700; }
.q-name { color: var(--muted); }
.q-price { font-size: 32px; font-weight: 600; font-family: var(--mono); }
.q-chg { font-family: var(--mono); font-size: 15px; }
.q-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--muted); }
.q-meta b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.badge.open { color: var(--mint); border-color: var(--mint-dim); }
.range-btns { display: flex; gap: 4px; margin: 6px 0; }
.range-btns button { background: none; border: 1px solid transparent; color: var(--muted); padding: 3px 9px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; }
.range-btns button.active { border-color: var(--line); color: var(--text); background: var(--panel-2); }
.chart { height: 300px; }
.chart.small { height: 140px; margin-top: 12px; }
.chart.lab { height: 320px; }
.stats4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stats4 div { display: flex; flex-direction: column; }
.stats4 b { font-size: 16px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: right; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { text-align: right; padding: 8px 10px; border-bottom: 1px solid rgba(36, 48, 44, .6); font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
td.txt { font-family: inherit; }
tr:hover td { background: rgba(255, 255, 255, .015); }
tr.hl td { background: rgba(52, 211, 153, .07); }
tr.atm td { border-bottom: 1px solid var(--mint-dim); }
.sortable th { cursor: pointer; user-select: none; }
.sortable th:hover { color: var(--text); }
.sym-link { color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; font-family: Inter, sans-serif; }
.sym-link:hover { color: var(--mint); }
.empty-row td { text-align: center; color: var(--muted); font-family: inherit; padding: 20px; }

/* screener */
.scr-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.scr-form .field { margin: 0; }
.scr-form input#scrOtm { width: 100px; }

/* lab */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.preset { text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.preset b { display: block; font-size: 13px; }
.preset.active { border-color: var(--mint); box-shadow: inset 0 0 0 1px var(--mint); }
.preset-about { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.grade-row { display: flex; gap: 18px; align-items: center; margin-bottom: 12px; }
.grade { width: 72px; height: 72px; flex: none; border-radius: 16px; display: grid; place-items: center; font-size: 38px; font-weight: 800; border: 2px solid; }
.grade.A, .grade.B { color: var(--mint); border-color: var(--mint); background: rgba(52, 211, 153, .08); }
.grade.C { color: var(--amber); border-color: var(--amber); background: rgba(251, 191, 36, .08); }
.grade.D, .grade.F { color: var(--red); border-color: var(--red); background: rgba(248, 113, 113, .08); }
.grade.N { color: var(--muted); border-color: var(--line); }
.notes { margin: 0; padding-left: 18px; color: var(--text); }
.notes li { margin: 2px 0; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin: 8px 0; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.metrics td:first-child { font-family: Inter, sans-serif; color: var(--muted); }
.metrics th.grp { text-align: center; border-bottom: 0; color: var(--text); }

/* modal / toasts / login */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(440px, 100%); }
.modal-card h2 { margin: 0 0 10px; font-size: 18px; }
.modal-card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 12px 0 16px; }
.modal-card dt { color: var(--muted); }
.modal-card dd { margin: 0; text-align: right; font-family: var(--mono); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: calc(100% - 32px); }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--mint); border-radius: 8px; padding: 10px 14px; max-width: 420px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.toast.bad { border-left-color: var(--red); }
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 50% 30%, rgba(52, 211, 153, .08), transparent 60%), var(--bg); }
.login-card { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--mint); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 960px) {
  .grid.desk, .grid.lab { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .top { padding: 12px 16px; gap: 12px; }
  .top-stats { gap: 14px; }
  .hide-sm { display: none !important; }
  .tabs { padding: 6px 16px 0; }
  main { padding: 16px 16px 40px; }
  .stats4 { grid-template-columns: repeat(2, 1fr); }
  .q-price { font-size: 26px; }
  .chart { height: 240px; }
}

.foot { text-align: center; padding: 0 16px 24px; }
.foot a { color: var(--muted); }
.brand { white-space: nowrap; }
@media (max-width: 640px) { .top .pill.paper { font-size: 9px; padding: 2px 5px; } .brand { font-size: 15px; gap: 7px; } .top-stats b { font-size: 13px; } }
.badge.claude { color: #f0b38a; border-color: rgba(217, 119, 87, .5); background: rgba(217, 119, 87, .1); font-family: Inter, sans-serif; }
.presets-sub { grid-column: 1 / -1; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 6px; }
.preset span { display: block; margin-top: 2px; }
.asks { padding-left: 18px; margin: 0 0 12px; }
.asks li { margin: 6px 0; }
#mcpCmdBox { margin-top: 12px; }
#mcpCmdBox textarea { margin-bottom: 8px; }
