:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #efeeea;
  --border: #e0dfd9;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7d7c76;
  --accent: #2a78d6;
  --accent-soft: #e4eefb;
  --series-2: #eb6834;
  --good: #0ca30c;
  --good-text: #006300;
  --good-soft: #e3f4e3;
  --critical: #d03b3b;
  --critical-text: #b02a2a;
  --critical-soft: #fbe9e9;
  --warning: #fab219;
  --warning-text: #7a5200;
  --warning-soft: #fdf1d3;
  --div-1: #1c5cab;
  --div-2: #6da7ec;
  --div-mid: #c9c8c2;
  --div-4: #ec9a9a;
  --div-5: #d03b3b;
  --track: #e6e5e0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: #32322f;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --text-3: #8f8e85;
    --accent: #3987e5;
    --accent-soft: #17293f;
    --series-2: #d95926;
    --good-text: #4cc94c;
    --good-soft: #12301a;
    --critical-text: #f08080;
    --critical-soft: #3a1818;
    --warning-text: #fac450;
    --warning-soft: #3a2c0a;
    --div-1: #6da7ec;
    --div-2: #256abf;
    --div-mid: #4a4a46;
    --div-4: #a04545;
    --div-5: #e66767;
    --track: #2d2d2a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.up { color: var(--good-text); }
.down { color: var(--critical-text); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.search { position: relative; display: flex; flex: 1 1 320px; max-width: 460px; }
.search input {
  flex: 1; min-width: 0; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--border); border-right: 0; border-radius: 8px 0 0 8px; outline: none;
}
.search input:focus { border-color: var(--accent); }
.search button { padding: 8px 14px; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 0 8px 8px 0; cursor: pointer; font-weight: 600; white-space: nowrap; }
.suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  margin: 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.18);
}
.suggest li { display: flex; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.suggest li b { min-width: 58px; }
.suggest li span { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest li.active, .suggest li:hover { background: var(--accent-soft); }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 7px 12px; border-radius: 8px; color: var(--text-2); font-weight: 550; white-space: nowrap; }
.tabs a:hover { background: var(--surface-2); text-decoration: none; }
.tabs a.active { background: var(--surface-2); color: var(--text); }
.count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--critical); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.scan-ctl { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.status { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.status.down { color: var(--critical-text); font-weight: 600; }
button.primary { padding: 8px 14px; border: 0; border-radius: 8px; background: var(--text); color: var(--bg); font-weight: 600; cursor: pointer; white-space: nowrap; }
button.primary:disabled { opacity: 0.5; cursor: default; }
button.ghost { padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
button.ghost:hover { background: var(--surface-2); }

main { max-width: 1440px; margin: 0 auto; padding: 20px; outline: none; min-height: 70vh; }
.foot { max-width: 1440px; margin: 0 auto; padding: 8px 20px 32px; color: var(--text-3); font-size: 12px; }

/* ---------- shared pieces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.card > h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); margin-bottom: 12px; font-weight: 600; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.section { margin-top: 14px; }
.empty { padding: 48px 20px; text-align: center; color: var(--text-2); }
.empty h2 { font-size: 18px; margin-bottom: 6px; color: var(--text); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 650; white-space: nowrap; border: 1px solid transparent; }
.badge.r-strong-buy { background: #0a7d0a; color: #fff; }
.badge.r-buy { background: var(--good-soft); color: var(--good-text); }
.badge.r-moderate-buy { border-color: var(--good); color: var(--good-text); }
.badge.r-hold { background: var(--surface-2); color: var(--text-2); }
.badge.r-neutral { border-color: var(--border); color: var(--text-2); }
.badge.r-sell { background: var(--critical-soft); color: var(--critical-text); }
.badge.big { font-size: 20px; padding: 6px 16px; border-radius: 9px; }
.flag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.03em; }

.bar { position: relative; height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--accent); }
.scorecell { display: grid; grid-template-columns: 30px 64px; align-items: center; gap: 8px; }

/* ---------- scanner ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .k { color: var(--text-2); font-size: 12px; }
.tile .v { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.tile .s { color: var(--text-3); font-size: 12px; }
.tile.hl { border-color: var(--accent); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.chip { padding: 5px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 13px; color: var(--text-2); }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { opacity: 0.6; margin-left: 4px; font-variant-numeric: tabular-nums; }
.filters select, .filters input[type="search"] { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.filters .spacer { flex: 1; }

.tablewrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: auto; max-height: calc(100vh - 150px); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text-2); cursor: pointer; user-select: none; }
th.r, td.r { text-align: right; }
th.sorted { color: var(--text); }
th.sorted::after { content: " ▾"; }
th.sorted.asc::after { content: " ▴"; }
tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.co { max-width: 230px; }
td.co b { display: block; }
td.co span { display: block; color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
td.cat { max-width: 320px; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); font-size: 13px; }
table.plain th { position: static; cursor: default; }
table.plain td, table.plain th { padding: 7px 8px; white-space: normal; }
table.plain tbody tr { cursor: default; }
table.plain tbody tr:hover { background: none; }

/* ---------- report ---------- */
.rhead { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 24px; margin-bottom: 16px; }
.rhead h1 { font-size: 26px; }
.rhead .sub { color: var(--text-2); }
.rhead .px { margin-left: auto; text-align: right; }
.rhead .px b { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; }
.back { display: inline-block; margin-bottom: 10px; color: var(--text-2); }

.verdict .hero { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.verdict .hero .sc { font-size: 34px; font-weight: 650; letter-spacing: -0.03em; line-height: 1; }
.verdict .hero .sc small { font-size: 14px; color: var(--text-3); font-weight: 500; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.kv .lab { color: var(--text-2); }
.kv .lab small { color: var(--text-3); }
.sig { display: grid; grid-template-columns: 96px 1fr 30px; gap: 10px; align-items: center; margin: 7px 0; }
.sig span:first-child { color: var(--text-2); }
.sig span:last-child { text-align: right; font-weight: 600; }

.buynow { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 4px; }
.checks { list-style: none; margin: 10px 0 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 20px 1fr; gap: 6px; padding: 5px 0; border-top: 1px solid var(--border); }
.checks li:first-child { border-top: 0; }
.checks .ic { font-weight: 700; }
.checks small { display: block; color: var(--text-3); }

.target .val { font-size: 34px; font-weight: 650; letter-spacing: -0.03em; line-height: 1; }
.target .val small { font-size: 15px; font-weight: 600; margin-left: 8px; letter-spacing: 0; }
.range { position: relative; height: 34px; margin: 18px 0 22px; }
.range .line { position: absolute; top: 15px; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--track); }
.range .pin { position: absolute; top: 9px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; border: 2px solid var(--surface); }
.range .pin.now { background: var(--text-2); }
.range .pin.est { background: var(--accent); }
.range .lbl { position: absolute; top: 30px; transform: translateX(-50%); font-size: 11px; color: var(--text-2); white-space: nowrap; }
.range .end { position: absolute; top: -6px; font-size: 11px; color: var(--text-3); }

.factor { display: flex; flex-direction: column; gap: 10px; }
.factor .top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.factor .top b { font-size: 15px; }
.factor .top .s { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.factor .top .s small { font-size: 12px; color: var(--text-3); font-weight: 500; }
.factor .bar { height: 8px; border-radius: 4px; }
.factor .note { color: var(--text-3); font-size: 12px; }
.factor .kv { font-size: 13px; }
.factor .kv .val { font-weight: 600; text-align: right; }
.factor .kv .peer { display: block; font-weight: 400; font-size: 11px; color: var(--text-3); }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart text.val { fill: var(--text-2); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.stack { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; }
.stack i { display: block; min-width: 3px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: grid; grid-template-columns: 18px 82px 1fr; gap: 8px; padding: 7px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list .d { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 12px; padding-top: 2px; }
.list a { color: var(--text); }
.list a:hover { color: var(--accent); }
.list .dim a, .list .dim { color: var(--text-3); }
code { padding: 1px 5px; border-radius: 4px; background: var(--surface-2); font-size: 13px; }
.tag { display: inline-block; padding: 0 6px; margin-left: 6px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); font-size: 11px; }
.flags { margin: 0; padding: 0; list-style: none; }
.flags li { padding: 8px 10px; margin-bottom: 6px; border-radius: 8px; background: var(--critical-soft); color: var(--critical-text); font-weight: 550; }
.flags li::before { content: "⚠ "; }
.about { color: var(--text-2); max-width: 90ch; }

/* ---------- alerts ---------- */
.alert { display: grid; grid-template-columns: 6px 1fr auto; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.alert:last-child { border-bottom: 0; }
.alert:hover { background: var(--surface-2); }
.alert .sev { border-radius: 3px; background: var(--border); }
.alert.high .sev { background: var(--accent); }
.alert .t { font-weight: 650; }
.alert.lapsed .t, .alert.lapsed .dt { color: var(--text-3); }
.alert.lapsed .dt { text-decoration: line-through; }
.alert .note { margin-top: 4px; font-size: 12px; color: var(--warning-text); }
.tag.warn { background: var(--warning-soft); color: var(--warning-text); }
.alert .t .sym { margin-right: 8px; }
.alert .dt { color: var(--text-2); margin-top: 2px; }
.alert time { color: var(--text-3); font-size: 12px; white-space: nowrap; text-align: right; }
.alert time b { display: block; color: var(--text-2); font-weight: 600; }
.alert time span { display: block; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.toast { padding: 12px 14px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); cursor: pointer; }
.toast b { display: block; }
.tooltip { position: fixed; z-index: 60; pointer-events: none; padding: 6px 9px; border-radius: 7px; background: var(--text); color: var(--bg); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.method p, .method li { color: var(--text-2); max-width: 85ch; }
.method h2 { font-size: 16px; margin: 4px 0 8px; }
.progress { height: 3px; background: var(--track); border-radius: 2px; overflow: hidden; margin-bottom: 14px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width 0.4s; }

/* ---------- sign-in ---------- */
.login { display: grid; place-items: center; min-height: 100vh; }
.login form { display: grid; gap: 10px; width: min(340px, 100%); padding: 24px; }
.login .brand { margin-bottom: 8px; }
.login label { color: var(--text-2); font-size: 13px; }
.login input { padding: 9px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font-size: 16px; }
.login input:focus { outline: none; border-color: var(--accent); }
.login-error { margin: 0; color: var(--critical-text); font-size: 13px; }
.foot form { display: inline; margin-left: 8px; }
.foot button { padding: 0; border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12px; }
.foot button:hover { text-decoration: underline; }

@media (max-width: 720px) {
  main { padding: 12px; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .scan-ctl { margin-left: 0; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .rhead .px { margin-left: 0; text-align: left; }
}
