:root {
  color-scheme: light;
  --page: #f3f2ef; --surface: #fcfcfb; --surface-2: #f0efeb; --border: #dfddd6;
  --text: #0b0b0b; --text-2: #52514e; --text-3: #7c7a74; --grid: #ebe9e3;
  --hot: #eb6834; --cold: #2a78d6;          /* экстремум: перегрев / перепроданность */
  --up: #008300; --down: #e34948;           /* свечи и фон: за цену / против цены */
  --line-1: #6250d6; --line-2: #eda100; --line-3: #e87ba4; --neutral: #8a8880;
  --shadow: 0 1px 2px rgb(0 0 0 / .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #111110; --surface: #1a1a19; --surface-2: #232321; --border: #30302d;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #8f8d84; --grid: #262624;
    --hot: #d95926; --cold: #3987e5;
    --up: #0ca30c; --down: #e66767;
    --line-1: #9085e9; --line-2: #c98500; --line-3: #d55181; --neutral: #8f8d84;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--text); font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
.muted { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; }
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--text); color: var(--surface); border-color: var(--text); padding: 10px 16px; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }
.error { color: var(--down); }

/* ── вход ── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; display: grid; gap: 14px; }
.auth-card h1 { margin: 0; font-size: 20px; }
.auth-card p { margin: 0; }
.input { font: inherit; color: inherit; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; width: 100%; }

/* ── дашборд ── */
.dash { max-width: 1680px; margin: 0 auto; padding: 12px 16px 28px; display: grid; gap: 12px; }
.top { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.top h1 { font-size: 14px; margin: 0; font-weight: 600; color: var(--text-2); }
.price { font-size: 26px; font-weight: 650; letter-spacing: -.01em; }
.chg.up { color: var(--up); } .chg.down { color: var(--down); }
.top .spacer { flex: 1; }
.top .meta { color: var(--text-3); }
.top .actions { display: flex; gap: 8px; align-self: center; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; min-width: 0; }
.card h2 { font-size: 12px; font-weight: 600; margin: 0; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }

.heroes { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 12px; }
.hero-value { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 8px; }
.hero-value b { font-size: 32px; font-weight: 650; letter-spacing: -.02em; }
.hero-value span { font-size: 14px; font-weight: 600; }
.hero-sub { color: var(--text-3); margin-top: 8px; }
.hero-groups { display: grid; gap: 3px; margin-top: 10px; }
.hero-groups div { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--text-2); }
.verdict p { margin: 6px 0 0; font-size: 13.5px; line-height: 1.5; }
.verdict p.small { color: var(--text-3); font-size: 12px; }

/* шкала −2…+2 */
.meter { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); }
.meter i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.meter .mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--text-3); }
.meter .th { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--border); }
.meter-labels { display: flex; justify-content: space-between; color: var(--text-3); font-size: 11px; margin-top: 4px; }
.fill-hot { background: var(--hot); } .fill-cold { background: var(--cold); }
.fill-up { background: var(--up); } .fill-down { background: var(--down); }

.chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip .bar { position: relative; width: 46px; height: 6px; border-radius: 3px; background: var(--surface-2); }
.chip .bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.chip .bar::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--text-3); }
.chip b { font-weight: 600; min-width: 38px; text-align: right; }
.chip.none b { color: var(--text-3); font-weight: 400; }

/* ── график ── */
.chart-card { padding-bottom: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--text-2); margin-bottom: 6px; min-height: 18px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 0; border-top: 2px solid; display: inline-block; }
.legend i.dash { border-top-style: dashed; }
.legend i.box { height: 9px; width: 9px; border: 0; border-radius: 2px; }
.legend .date { color: var(--text-3); min-width: 78px; }
#chart { height: 430px; }

/* ── группы показателей ── */
.groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
table.metrics { width: 100%; border-collapse: collapse; }
table.metrics td { padding: 5px 0; border-top: 1px solid var(--grid); vertical-align: middle; }
table.metrics tr:first-child td { border-top: 0; }
td.name { color: var(--text); padding-right: 8px; }
td.name small { display: block; color: var(--text-3); font-size: 11px; }
td.name span[title] { cursor: help; }
td.val { text-align: right; white-space: nowrap; padding-right: 10px; font-weight: 600; }
td.val small { color: var(--text-3); font-weight: 400; margin-left: 3px; }
td.spark { width: 102px; padding: 5px 10px 5px 6px; }
td.sc { width: 96px; text-align: right; }
svg.sparkline { display: block; width: 96px; height: 24px; overflow: visible; }
svg.sparkline path { fill: none; stroke: var(--text-2); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
svg.sparkline circle { fill: var(--text); stroke: var(--surface); stroke-width: 2; }
svg.sparkline line { stroke: var(--border); stroke-width: 1; }
tr.stale td.val, tr.stale svg.sparkline { opacity: .55; }

.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--text); color: var(--surface); border-radius: 6px; padding: 4px 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -130%); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.list li { display: flex; justify-content: space-between; gap: 10px; }
.list li > span:last-child { white-space: nowrap; }
.list + .card-head { margin-top: 16px; }
.card > p.muted { margin: 0 0 4px; }
.card > p.muted + .card-head { margin-top: 16px; }
.list details summary { cursor: pointer; }
.list pre { white-space: pre-wrap; font: inherit; color: var(--text-2); margin: 6px 0 0; }
.st-ok { color: var(--up); } .st-bad { color: var(--down); } .st-off { color: var(--text-3); }

dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 20px; width: min(460px, 92vw); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h3 { margin: 0 0 12px; }
dialog .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--grid); }
dialog .foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }
dialog code { word-break: break-all; display: block; background: var(--surface-2); border-radius: 8px; padding: 8px; margin-top: 10px; }

@media (max-width: 1100px) { .heroes { grid-template-columns: 1fr 1fr; } .verdict { grid-column: 1 / -1; } .groups { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .heroes, .groups { grid-template-columns: 1fr; } #chart { height: 360px; } td.spark { display: none; } }
