/* 能源 AI 模型 Leaderboard：样式。全部本地，无外部字体。 */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --border-strong: #c3c9d2;
  --text: #1b1f24;
  --text-2: #57606a;
  --text-3: #808a94;
  --accent: #1d4f91;
  --accent-soft: #e6eef9;
  --accent-text: #ffffff;
  --cited-bg: #fbf6ea;
  --cited-border: #d9b25c;
  --cited-text: #7a5512;
  --ok: #1f7a3a;
  --ok-soft: #e5f3e9;
  --warn-soft: #fdf3e1;
  --best-bg: #e6eef9;
  --grid: #e8ebef;
  --axis: #9aa3ad;
  --fam-foundation: #257de0;
  --fam-deep: #f47230;
  --fam-tree: #00b894;
  --fam-stat: #f2a600;
  --fam-naive: #9aa3ad;
  --fam-other: #6a4ce2;
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600;
  --s5: #ee7fac; --s6: #008a17; --s7: #6a4ce2; --s8: #ec4647;
  --shadow: 0 1px 2px rgba(20, 30, 45, .06), 0 1px 1px rgba(20, 30, 45, .04);
  --radius: 6px;
  --font: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121417; --surface: #1a1d21; --surface-2: #22262b; --border: #2e333a; --border-strong: #404750;
    --text: #e6e8eb; --text-2: #a4acb5; --text-3: #7d8690;
    --accent: #6ea4e8; --accent-soft: #1f2f45; --accent-text: #0e1520;
    --cited-bg: #2a2416; --cited-border: #9c7a2f; --cited-text: #e2c27a;
    --ok: #5cc27a; --ok-soft: #1a2e21; --warn-soft: #2d2717; --best-bg: #1f2f45;
    --grid: #2a2f35; --axis: #6b747e;
    --fam-foundation: #338ced; --fam-deep: #e76624; --fam-tree: #00a888; --fam-stat: #d28e05; --fam-naive: #6b747e; --fam-other: #9887ef;
    --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05; --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417; --surface: #1a1d21; --surface-2: #22262b; --border: #2e333a; --border-strong: #404750;
  --text: #e6e8eb; --text-2: #a4acb5; --text-3: #7d8690;
  --accent: #6ea4e8; --accent-soft: #1f2f45; --accent-text: #0e1520;
  --cited-bg: #2a2416; --cited-border: #9c7a2f; --cited-text: #e2c27a;
  --ok: #5cc27a; --ok-soft: #1a2e21; --warn-soft: #2d2717; --best-bg: #1f2f45;
  --grid: #2a2f35; --axis: #6b747e;
  --fam-foundation: #338ced; --fam-deep: #e76624; --fam-tree: #00a888; --fam-stat: #d28e05; --fam-naive: #6b747e; --fam-other: #9887ef;
  --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05; --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.35; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 14px; }
p { margin: 0 0 8px; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
th.num { font-family: var(--font); font-size: 12.5px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* 页头 */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1480px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 24px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 5px; background: var(--accent); display: grid; place-items: center; }
.brand-mark svg { display: block; }
.brand-title { font-weight: 600; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--text-3); margin-left: 2px; }
nav.main { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
nav.main a { color: var(--text-2); padding: 6px 11px; border-radius: 5px; font-size: 14px; white-space: nowrap; }
nav.main a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
nav.main a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
nav.main .sep { width: 1px; background: var(--border); margin: 6px 6px; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 5px; height: 30px; padding: 0 10px; cursor: pointer; font: inherit; font-size: 13px; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

.mock-banner { background: #b3261e; color: #fff; text-align: center; padding: 4px 12px; font-size: 13px; font-weight: 600; }

main { max-width: 1480px; margin: 0 auto; padding: 24px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .lead { color: var(--text-2); margin-top: 4px; max-width: 980px; }
.meta-line { color: var(--text-3); font-size: 12.5px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 20px; }
.panel-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.panel-body { padding: 14px 18px 18px; }
.section-gap { height: 20px; }

/* 首页 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); }
.stat .k { color: var(--text-2); font-size: 12.5px; }
.stat .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .v small { font-size: 13px; font-weight: 400; color: var(--text-3); margin-left: 4px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; color: var(--text); transition: border-color .15s; }
a.card:hover { border-color: var(--accent); text-decoration: none; }
.card-top { display: flex; justify-content: space-between; align-items: baseline; }
.card-title { font-size: 16px; font-weight: 600; }
.card-code { font-size: 12px; color: var(--text-3); font-family: var(--mono); }
.card-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 8px 0; }
.card-nums div { text-align: center; }
.card-nums .n { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card-nums .l { font-size: 12px; color: var(--text-2); }
.card-best { font-size: 13px; }
.card-best .lbl { color: var(--text-2); font-size: 12px; }
.card-best .row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.card-best .row .t { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-best .row .m { font-weight: 600; white-space: nowrap; }

.pending { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); background: var(--surface-2); border: 1px dashed var(--border-strong); padding: 3px 10px; border-radius: 4px; font-size: 13px; }
.pending::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--fam-stat); }
.pending-block { padding: 28px 18px; text-align: center; }

.machine { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px 20px; }
.machine .k { color: var(--text-2); font-size: 12.5px; }
.machine .v { font-weight: 500; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { padding: 7px 7px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.grid thead th { background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: 12.5px; position: sticky; top: 0; white-space: nowrap; border-bottom: 1px solid var(--border-strong); }
table.grid thead th.sortable { cursor: pointer; user-select: none; }
table.grid thead th.sortable:hover { color: var(--text); }
table.grid thead th .arrow { display: inline-block; width: 10px; color: var(--accent); margin-left: 2px; }
table.grid thead th.primary-col { color: var(--accent); }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid tbody tr.cited td { background: var(--cited-bg); font-style: italic; color: var(--text-2); }
table.grid tbody tr.cited td:first-child { box-shadow: inset 3px 0 0 var(--cited-border); }
table.grid tbody tr.cited:hover td { background: var(--cited-bg); filter: brightness(0.98); }
table.grid td.primary-col { font-weight: 600; }
table.grid td.best { background: var(--best-bg); }
table.grid td.rank { width: 46px; text-align: center; font-variant-numeric: tabular-nums; color: var(--text-2); }
table.grid td.rank.r1 { color: var(--accent); font-weight: 700; }
table.grid td.model { font-weight: 500; white-space: nowrap; }
table.grid td.model .mid { display: block; font-size: 11.5px; color: var(--text-3); font-family: var(--mono); font-weight: 400; font-style: normal; }
table.grid td.wrap { white-space: normal; min-width: 180px; }
table.compact th, table.compact td { padding: 5px 8px; }
.na { color: var(--text-3); }

.tag { display: inline-block; padding: 0 7px; border-radius: 3px; font-size: 12px; line-height: 20px; white-space: nowrap; border: 1px solid var(--border); color: var(--text-2); background: var(--surface); font-style: normal; }
.tag.fam { border: none; padding-left: 0; background: none; color: var(--text); }
.tag.fam::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; background: var(--c, var(--fam-other)); vertical-align: 0; }
.tag.cited { background: var(--cited-bg); border-color: var(--cited-border); color: var(--cited-text); cursor: pointer; font-style: normal; }
.tag.measured { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.tag.yes { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.tag.no { color: var(--text-3); }
.tag.in-lb { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* 工具条 */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 16px; }
.toolbar .lbl { color: var(--text-2); font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); padding: 3px 11px; border-radius: 14px; cursor: pointer; font: inherit; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip .dot { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.seg button { border: none; background: var(--surface); color: var(--text-2); padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent); color: var(--accent-text); }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }

/* 任务块 */
.task { margin-bottom: 28px; }
.task-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.task-head .tid { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.direction { font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); padding: 1px 8px; border-radius: 4px; white-space: nowrap; }
.direction b { color: var(--accent); }
.dsinfo { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 0 28px; padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: 13px; }
.dsinfo dl { display: grid; align-content: start; grid-template-columns: 88px 1fr; gap: 4px 12px; margin: 0; }
.dsinfo dt { color: var(--text-2); }
.dsinfo dd { margin: 0; word-break: break-word; }
.dsinfo .desc { grid-column: 1 / -1; margin-bottom: 10px; color: var(--text); }
.task-body { display: grid; grid-template-columns: minmax(0, 1fr); }
.chart-box { padding: 14px 18px 8px; border-top: 1px solid var(--border); }
.chart-title { font-size: 13px; color: var(--text-2); margin-bottom: 6px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--c); display: inline-block; }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; }
.legend i.hatch { background: repeating-linear-gradient(45deg, var(--cited-border) 0 2px, transparent 2px 5px); border: 1px solid var(--cited-border); }
svg.chart { display: block; max-width: 100%; height: auto; overflow: visible; }
svg.chart text { fill: var(--text-2); font-size: 12px; font-family: var(--font); }
svg.chart text.val { fill: var(--text); font-family: var(--mono); font-size: 11.5px; }
svg.chart .gridline { stroke: var(--grid); stroke-width: 1; }
svg.chart .axisline { stroke: var(--axis); stroke-width: 1; }
.weather-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(560px, 1fr)); gap: 0; border-top: 1px solid var(--border); }
.weather-grid > div { padding: 14px 18px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.tooltip { position: fixed; pointer-events: none; z-index: 50; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: 0 4px 14px rgba(0,0,0,.12); padding: 6px 10px; border-radius: 5px; font-size: 12.5px; color: var(--text); display: none; max-width: 340px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 16px; }
.tooltip .tt-row b { font-family: var(--mono); font-weight: 500; }

/* 矩阵 */
table.matrix td.cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.matrix td.cell.cited-cell { font-style: italic; color: var(--cited-text); }
table.matrix th.domain-group { text-align: center; border-bottom: 1px solid var(--border); }
table.matrix thead th { position: static; }
table.matrix th.task-col { white-space: normal; min-width: 92px; max-width: 150px; font-size: 12px; text-align: right; vertical-align: bottom; }
table.matrix td.r1 { background: var(--best-bg); font-weight: 700; color: var(--accent); }
table.matrix td.r2, table.matrix td.r3 { font-weight: 600; }
.rankbar { display: inline-block; height: 6px; background: var(--accent); border-radius: 0 3px 3px 0; vertical-align: middle; margin-left: 8px; opacity: .75; }

/* 调研清单 */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 8px 16px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 16px; }
.kv > .k { color: var(--text-2); }
.any-block { margin: 6px 0 12px; }
.any-block h3, .any-block h4 { margin: 14px 0 6px; }
.any-list { margin: 4px 0 8px; padding-left: 20px; }
.any-list li { margin: 2px 0; }
.prose { max-width: 980px; }
.prose h2 { margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin: 16px 0 6px; }
.prose ul, .prose ol { padding-left: 22px; margin: 6px 0 10px; }
.prose li { margin: 3px 0; }
.prose code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 3px; }
.formula { font-family: var(--mono); background: var(--surface-2); padding: 2px 8px; border-radius: 4px; font-size: 13px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 20, 28, .45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; width: min(680px, 100%); max-height: 86vh; overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-body { padding: 14px 18px 18px; }
.modal-body .kv { grid-template-columns: 120px 1fr; font-size: 13.5px; }
.modal-body .kv .v { word-break: break-word; }
.citation-box { background: var(--cited-bg); border: 1px solid var(--cited-border); border-radius: 5px; padding: 10px 12px; margin-bottom: 14px; color: var(--text); }

.footer { color: var(--text-3); font-size: 12.5px; text-align: center; padding: 24px; }
.err { background: var(--warn-soft); border: 1px solid var(--cited-border); padding: 12px 16px; border-radius: 6px; }

@media (max-width: 1100px) {
  .topbar-inner { flex-wrap: wrap; gap: 6px 16px; padding: 8px 16px; }
  main { padding: 18px 16px 48px; }
  .dsinfo { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}
@media (max-width: 640px) {
  .weather-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .toolbar { display: none; }
}

table.grid thead th .unit { display: block; font-weight: 400; color: var(--text-3); font-size: 11.5px; line-height: 1.2; }

table.grid td.w-s { min-width: 80px; max-width: 150px; white-space: normal; }
table.grid td.w-m { min-width: 170px; white-space: normal; }
table.grid td.w-l { min-width: 280px; white-space: normal; }
table.grid td.w-name { min-width: 120px; max-width: 220px; white-space: normal; }
table.catalog { font-size: 12.5px; }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; margin-top: 20px; }
.ov-grid .panel + .panel { margin-top: 0; }
.ov-card .kv { grid-template-columns: 84px 1fr; }
.panel + .ov-grid + .panel { margin-top: 20px; }
@media (max-width: 640px) { .ov-grid { grid-template-columns: 1fr; } }

table.matrix td.model .mid .tag.fam { font-size: 11.5px; color: var(--text-3); line-height: 16px; }
table.matrix td.model { white-space: normal; min-width: 130px; }

/* 登录页与退出登录 */
.logout-form { margin: 0; }
.login-wrap { max-width: 400px; margin: 64px auto 0; padding: 0 16px; }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { color: var(--text-2); font-size: 13px; margin-top: 6px; }
.login-form input[type="text"], .login-form input[type="password"] { height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--surface); color: var(--text); font: inherit; }
.login-form input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.login-btn { margin-top: 14px; height: 36px; border: none; border-radius: 5px; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer; }
.login-btn:hover { filter: brightness(1.08); }
.login-msg { margin-bottom: 12px; }
