:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --line: #e2e0da;
  --grid: #ebe9e4;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --good: #0ca30c; --critical: #d03b3b; --warning: #b77a00;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #2f2f2c; --grid: #262624;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #8e8d86; --accent: #3987e5; --accent-ink: #86b6ef;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --warning: #fab219; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #2f2f2c; --grid: #262624;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8e8d86; --accent: #3987e5; --accent-ink: #86b6ef;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --warning: #fab219; --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.muted { color: var(--muted); }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
a { color: var(--accent-ink); }
button, input, select { font: inherit; color: inherit; }

/* header */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 28px; height: 28px; fill: none; stroke: var(--accent); stroke-width: 2.6; }
.brand svg .dot { fill: var(--s2); stroke: none; }
.brand b { display: block; font-size: 15px; letter-spacing: .02em; }
.brand span { display: block; font-size: 12px; }
nav { display: flex; gap: 4px; margin-left: auto; }
nav a {
  text-decoration: none; color: var(--text-2); padding: 6px 12px; border-radius: 8px;
}
nav a:hover { background: var(--surface-2); }
nav a.on { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 16px; height: 16px; fill: var(--text-2); }

main { max-width: 1240px; margin: 0 auto; padding: 20px 24px 64px; }

/* panels */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; box-shadow: var(--shadow); min-width: 0;
}
.panel > header { margin-bottom: 10px; }
.panel > header p { margin: 2px 0 0; font-size: 12px; }
.panel.flush { padding: 0; overflow: hidden; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 .wide { grid-column: 1 / -1; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .v { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .s { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* legend + charts */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); margin: 0 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.dot-solid { border-radius: 50%; background: var(--s1); }
.sw.dot-hollow { border-radius: 50%; border: 2px solid var(--s1); background: transparent; }
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-2); font-size: 12px; }
.chart .lbl { fill: var(--text); font-size: 12.5px; }
.chart .val { fill: var(--text); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .axis { stroke: var(--line); }
.chart .gridl { stroke: var(--grid); }
.chart .row { cursor: pointer; }
.chart .row:hover .hit { fill: var(--surface-2); }
.chart .quad { fill: var(--muted); font-size: 11px; }
.chart .pt { cursor: pointer; }

.tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 280px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.14);
}
.tip b { display: block; margin-bottom: 2px; }
.tip .r { display: flex; justify-content: space-between; gap: 12px; color: var(--text-2); }
.tip .r span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }

/* seed rank */
.srow { display: grid; grid-template-columns: 1fr 120px 40px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--grid); cursor: pointer; }
.srow:last-child { border-bottom: 0; }
.srow .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* badges & chips */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 7px; border-radius: 99px; border: 1px solid currentColor; line-height: 18px; white-space: nowrap; }
.badge.good { color: var(--good); }
.badge.risk { color: var(--critical); }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); margin: 2px 4px 2px 0; }
.lvl { font-variant-numeric: tabular-nums; }
.lvl.l0, .lvl.l1 { color: var(--good); }
.lvl.l2 { color: var(--warning); }
.lvl.l3 { color: var(--critical); }

/* filters + table */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 12px; }
.filters input[type=search], .filters select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
.filters input[type=search] { width: 260px; }
.filters label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }
.filters .range b { min-width: 20px; font-variant-numeric: tabular-nums; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; white-space: nowrap; }
.tbl th.sorted::after { content: " ↓"; }
.tbl th.sorted.asc::after { content: " ↑"; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .sc { display: flex; align-items: center; gap: 8px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tbl .sc .meter { width: 54px; }
.tbl .one { color: var(--text-2); font-size: 13px; max-width: 380px; }
.tbl .nm { font-weight: 600; }

/* seed cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.card h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card .top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card .big { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.card p { margin: 8px 0; color: var(--text-2); font-size: 13px; }
.card .stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.card .stats b { color: var(--text); font-weight: 600; }
.card .links { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.card .links button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px; padding: 2px 8px; font-size: 12px; cursor: pointer; }

/* drawer */
.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer-bg { position: absolute; inset: 0; background: rgba(0,0,0,.32); }
.drawer-body {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(680px, 100%);
  background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; padding: 22px 24px 48px;
}
.drawer .close { position: absolute; top: 14px; right: 14px; font-size: 14px; color: var(--text-2); }
.d-head { padding-right: 40px; }
.d-head .seed { font-size: 12px; color: var(--muted); }
.d-head h2 { font-size: 20px; margin: 2px 0 6px; }
.d-head .one { color: var(--text-2); margin: 0; }
.d-score { display: flex; align-items: baseline; gap: 10px; margin: 14px 0 4px; flex-wrap: wrap; }
.d-score .big { font-size: 36px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.d-sec { margin-top: 20px; }
.d-sec h3 { font-size: 12px; color: var(--muted); font-weight: 600; margin: 0 0 8px; letter-spacing: .04em; }
.dim { display: grid; grid-template-columns: 76px 1fr 54px; gap: 10px; align-items: center; font-size: 13px; margin: 5px 0; }
.dim .meter { height: 10px; }
.dim .num { font-weight: 500; font-size: 12px; color: var(--text-2); }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.fact { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.fact .l { font-size: 11px; color: var(--muted); }
.fact .v { font-weight: 600; }
ul.plain { margin: 0; padding-left: 18px; }
ul.plain li { margin: 5px 0; }
.ev { color: var(--muted); font-size: 12px; }
.note { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--text-2); }
.note.risk { color: var(--critical); }

/* method page */
.prose { max-width: 820px; }
.prose h2 { font-size: 17px; margin: 18px 0 8px; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--text-2); }
.prose table { border-collapse: collapse; width: 100%; font-size: 13px; }
.prose td, .prose th { border-bottom: 1px solid var(--grid); padding: 7px 8px; text-align: left; vertical-align: top; }
.prose th { color: var(--muted); font-weight: 500; }
.flow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.flow span { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.flow i { color: var(--muted); font-style: normal; }

/* login */
.login { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: grid; place-items: center; padding: 16px; }
.login form { width: min(340px, 100%); display: grid; gap: 10px; }
.login input { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 9px 12px; }
.login button { border: 0; background: var(--accent); color: #fff; border-radius: 8px; padding: 9px; font-weight: 600; cursor: pointer; }
.err { color: var(--critical); margin: 0; min-height: 1em; font-size: 13px; }

.empty { padding: 40px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpis .kpi:last-child { grid-column: 1 / -1; }
  .grid2 { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  nav { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  #theme { margin-left: auto; }
  main { padding: 14px 16px 48px; }
  .hide-s { display: none; }
  .filters input[type=search] { width: 100%; }
  .cards { grid-template-columns: 1fr; }
  .drawer-body { padding: 18px 16px 40px; }
}
.show-s { display: none; }
@media (max-width: 640px) { .show-s { display: block; } }
