/* 视觉风格：黑白为主 + 大块高饱和浅色色块，粗标题，黑色主按钮，顶部胶囊导航 */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f3f1;
  --text: #0d0d0d;
  --text-2: #4b4b48;
  --muted: #8a8983;
  --border: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.28);
  --ink: #0d0d0d;
  --on-ink: #ffffff;
  --accent: #0d0d0d;
  --link: #3a5bd9;
  --good: #11753a;
  --bad: #c7322b;
  --warn-bg: #fff1c2;
  --warn: #6b4a00;
  /* 色块 */
  --block-lav: #d6c9ff;
  --block-lime: #e4f99a;
  --block-mint: #c8f0d6;
  --block-pink: #ffcdea;
  --block-sky: #cfe3ff;
  /* 图表（经过色盲校验的分类色） */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e4e3dc;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f0f0f;
    --surface: #181818;
    --surface-2: #232323;
    --text: #f2f2ee;
    --text-2: #c4c3bb;
    --muted: #8a8983;
    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.3);
    --ink: #f2f2ee;
    --on-ink: #0d0d0d;
    --link: #8fa8ff;
    --good: #4cc77a;
    --bad: #f0706a;
    --warn-bg: #3d3210;
    --warn: #f3cf6b;
    --block-lav: #352c5e;
    --block-lime: #36421a;
    --block-mint: #1d3d2b;
    --block-pink: #4a2340;
    --block-sky: #1c3152;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2c2c2a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.6 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
h1 { font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 20px; }
h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 700; margin: 18px 0 8px; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }

input, select, textarea {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 6px 10px; min-height: 36px; max-width: 100%;
}
input:hover, select:hover { border-color: var(--ink); }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

button {
  background: var(--surface); border: 1px solid var(--ink); border-radius: var(--radius);
  padding: 6px 14px; min-height: 36px; cursor: pointer; white-space: nowrap; font-weight: 500;
}
button:hover { background: var(--surface-2); }
button:active { transform: translateY(1px); }
button.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
button.primary:hover { opacity: 0.85; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.link { border: none; background: none; color: var(--link); padding: 0 4px; min-height: 0; font-weight: 400; }
button.link:hover { text-decoration: underline; }
button.link.danger { color: var(--bad); }
button:disabled { opacity: 0.45; cursor: default; transform: none; }

/* ---------- 顶部导航 ---------- */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 24px; padding: 0 32px; height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; white-space: nowrap; }
.mark { display: grid; grid-template-columns: 9px 9px; gap: 2px; }
.mark i { width: 9px; height: 9px; display: block; }
.mark i:nth-child(1) { background: var(--ink); border-radius: 2px; }
.mark i:nth-child(2) { background: #ff7a2f; border-radius: 50%; }
.mark i:nth-child(3) { background: #b9a6ff; border-radius: 50% 0 50% 50%; }
.mark i:nth-child(4) { background: #c8ee5a; border-radius: 2px 50% 2px 50%; }
.nav { display: flex; gap: 4px; overflow-x: auto; }
.nav a { padding: 6px 14px; border-radius: 999px; color: var(--text); text-decoration: none; white-space: nowrap; font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--ink); color: var(--on-ink); }
.who { margin-left: auto; font-size: 13px; color: var(--text-2); white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.who button { min-height: 30px; padding: 2px 12px; }

.main { padding: 36px 32px 64px; max-width: 1320px; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 24px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-2); font-size: 15px; margin: 6px 0 0; }

/* ---------- 卡片、色块 ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px 24px; margin-bottom: 20px; }
.card.block { border: none; }
.block-lav { background: var(--block-lav); }
.block-lime { background: var(--block-lime); }
.block-mint { background: var(--block-mint); }
.block-pink { background: var(--block-pink); }
.block-sky { background: var(--block-sky); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { border-radius: 16px; padding: 18px 20px; min-height: 132px; display: flex; flex-direction: column; }
.kpi .l { font-size: 13px; font-weight: 600; }
.kpi .v { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: auto; line-height: 1.2; }
.kpi .s { font-size: 12px; color: var(--text-2); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.hint { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 14px; margin: 8px 0; }
.ok-box { background: var(--block-mint); border-radius: 10px; padding: 12px 16px; margin: 8px 0; }

/* ---------- 表格 ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-weight: 600; color: var(--text); font-size: 12px; white-space: nowrap; border-bottom: 1px solid var(--ink); }
td.n, th.n { text-align: right; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 1px solid var(--ink); }
tbody tr:hover td { background: var(--surface-2); }
.card.block tbody tr:hover td { background: rgba(255, 255, 255, 0.35); }

/* ---------- 表单 ---------- */
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; align-items: end; }
/* 标签文字和必填星号在第一行，输入框在第二行占满 */
.form label { display: grid; grid-template-columns: max-content 1fr; column-gap: 2px; row-gap: 5px; align-content: end; font-size: 12px; font-weight: 600; color: var(--text); }
.form label > input, .form label > select, .form label > textarea { grid-column: 1 / -1; grid-row: 2; width: 100%; font-weight: 400; }
.form label.wide { grid-column: 1 / -1; }
.req::after { content: "*"; color: var(--bad); grid-row: 1; grid-column: 2; }

/* 胶囊分段切换（设置页的标签） */
.tabs { display: inline-flex; gap: 2px; flex-wrap: wrap; margin-bottom: 24px; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.tabs button { border: none; border-radius: 999px; background: none; color: var(--text-2); min-height: 32px; padding: 4px 16px; }
.tabs button:hover { background: none; color: var(--text); }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); vertical-align: 2px; white-space: nowrap; }
#rf-body td { white-space: nowrap; }
.pill.warn { background: var(--block-pink); color: var(--text); }
.pill.ok { background: var(--block-mint); color: var(--text); }
.block-pink .pill.warn { background: var(--surface); }
.block-pink .tabs { background: rgba(255, 255, 255, 0.55); }
details > summary { cursor: pointer; font-weight: 700; padding: 2px 0; }

/* ---------- 图表 ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-2); font-size: 11px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; white-space: nowrap; display: none; z-index: 5;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}
.bars .bar-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 140px; gap: 10px; align-items: center; margin: 8px 0; font-size: 13px; }
.bars .track { height: 14px; }
.bars .fill { height: 14px; background: var(--ink); border-radius: 0 4px 4px 0; min-width: 2px; }
.bars .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

/* ---------- 登录页 ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth-hero { background: var(--block-lav); padding: 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; overflow: hidden; }
.auth-hero h1 { font-size: 52px; line-height: 1.05; margin: 0; }
.auth-hero p { font-size: 17px; max-width: 460px; margin: 16px 0 0; }
.shapes { display: grid; grid-template-columns: repeat(4, 72px); gap: 12px; }
.shapes i { width: 72px; height: 72px; display: block; }
.shapes i:nth-child(1) { background: #ff7a2f; border-radius: 50%; }
.shapes i:nth-child(2) { background: #0d0d0d; border-radius: 0 36px 36px 0; }
.shapes i:nth-child(3) { background: #e4f99a; border-radius: 8px; }
.shapes i:nth-child(4) { background: #ff5fc8; border-radius: 36px 36px 0 36px; }
.shapes i:nth-child(5) { background: #4a6cf7; border-radius: 36px 0 36px 0; }
.shapes i:nth-child(6) { background: #ffcdea; border-radius: 50%; }
.shapes i:nth-child(7) { background: #c8f0d6; border-radius: 8px 36px 8px 36px; }
.shapes i:nth-child(8) { background: #ffd23f; border-radius: 50% 50% 8px 8px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login { width: 100%; max-width: 380px; }
.login h2 { font-size: 26px; margin-bottom: 6px; }
.login .form { grid-template-columns: 1fr; margin-top: 20px; }
.login button.primary { min-height: 44px; font-size: 15px; }
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--on-ink);
  padding: 10px 18px; border-radius: 10px; display: none; z-index: 50; max-width: calc(100vw - 32px); font-weight: 500;
}
#toast.err { background: var(--bad); color: #fff; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 32px 24px; }
  .auth-hero h1 { font-size: 36px; }
  .shapes { grid-template-columns: repeat(4, 44px); gap: 8px; }
  .shapes i { width: 44px; height: 44px; }
}
@media (max-width: 760px) {
  h1 { font-size: 26px; }
  .top { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px 16px; }
  .nav { order: 3; width: 100%; padding-bottom: 2px; }
  .main { padding: 20px 16px 48px; }
  .grid2 { grid-template-columns: 1fr; }
  .kpi { min-height: 108px; }
  .kpi .v { font-size: 26px; }
  .card { padding: 18px 16px; }
  .bars .bar-row { grid-template-columns: 80px minmax(0, 1fr) 110px; }
}
