/* ═════════════════════════════════════════════��══════════════════════
   木子监测台 · 样式
   视觉沿用官网（Xhoper）：米白底 + 靛蓝点缀 + 大圆角卡片 + Barlow 数字
   ══════════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Barlow Numeral';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('assets/fonts/barlow-500.woff2') format('woff2');
  unicode-range: U+0030-0039;
}
@font-face {
  font-family: 'Barlow Numeral';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('assets/fonts/barlow-600.woff2') format('woff2');
  unicode-range: U+0030-0039;
}
@font-face {
  font-family: 'Barlow Numeral';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/barlow-700.woff2') format('woff2');
  unicode-range: U+0030-0039;
}

:root {
  --bg: #f6f6f2;
  --card: #ffffff;
  --soft: #eeeee9;
  --line: #e4e3dc;
  --line-soft: #efece5;
  --ink: #14171e;
  --muted: #4a5160;
  --quiet: #8b8b84;
  --accent: #5a54e8;
  --accent-soft: #edecfd;
  --accent-line: #d5d2f7;
  --ok: #2f6f5e;
  --ok-soft: #e6f0ec;
  --warn: #c97b3f;
  --warn-soft: #f9ece0;
  --bad: #b06367;
  --bad-soft: #f8eaea;
  --radius: 20px;
  --shadow: 0 2px 8px rgba(20, 22, 30, 0.04);
  --shadow-lg: 0 8px 28px -8px rgba(20, 22, 30, 0.1);
}

html[data-theme='dark'] {
  --bg: #14161c;
  --card: #1c1f27;
  --soft: #23262f;
  --line: #2b2f39;
  --line-soft: #242831;
  --ink: #eceef2;
  --muted: #a8adba;
  --quiet: #71768a;
  --accent: #8b86ff;
  --accent-soft: #23243a;
  --accent-line: #363a5c;
  --ok: #63b39c;
  --ok-soft: #1d2c28;
  --warn: #d99a63;
  --warn-soft: #2e241c;
  --bad: #d08d90;
  --bad-soft: #2f2022;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 28px -8px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
html[data-theme='dark'] body {
  background-image: radial-gradient(900px 500px at 88% -8%, rgba(90, 84, 232, 0.13), transparent 70%);
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(rgba(20, 22, 30, 0.045) 1px, transparent 1.5px);
  background-size: 22px 22px;
}
html[data-theme='dark'] body::before {
  background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1.5px);
}
b, .num { font-family: 'Barlow Numeral', -apple-system, sans-serif; font-variant-numeric: tabular-nums; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--soft);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--muted);
}

/* ───────────────── 登录 ───────────────── */
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}
.gate[hidden] { display: none; }
.gate-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 34px 32px 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.gate-mark { display: grid; place-items: center; margin-bottom: 16px; }
.gate-card h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.gate-sub { margin: 6px 0 24px; color: var(--quiet); font-size: 13.5px; }
.field { display: block; text-align: left; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gate-msg { min-height: 20px; margin: 10px 0 0; font-size: 12.5px; color: var(--bad); }
.gate-hint { margin: 16px 0 0; font-size: 11.5px; color: var(--quiet); line-height: 1.7; }
.gate-hint code { font-size: 11px; }

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }

/* ───────────────── 骨架 ───────────────── */
.shell { position: relative; z-index: 1; display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.shell[hidden] { display: none; }
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: var(--card);
}
.side-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 11px;
  text-decoration: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.18s, color 0.18s;
}
.side-nav a svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: 0.75; }
.side-nav a:hover { background: var(--soft); color: var(--ink); }
.side-nav a.on { background: var(--accent); color: #fff; }
.side-nav a.on svg { opacity: 1; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  color: var(--quiet);
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 9px;
}
.side-stat b { font-size: 16px; color: var(--ink); }
.side-logout {
  font: inherit;
  font-size: 12px;
  color: var(--quiet);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  text-align: left;
  border-radius: 9px;
}
.side-logout:hover { color: var(--bad); background: var(--bad-soft); }

.main { min-width: 0; padding: 22px 28px 56px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.topbar h2 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.page-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--quiet); }
.topbar-r { display: flex; align-items: center; gap: 10px; }
.range { display: flex; background: var(--soft); border-radius: 11px; padding: 3px; gap: 2px; }
.range button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.range button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent-line); }

.view { min-height: 300px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--quiet); padding: 60px 0; justify-content: center; }
.spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────────── 卡片与栅格 ───────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 2px; font-size: 14px; font-weight: 600; }
.card .card-sub { margin: 0 0 14px; font-size: 12px; color: var(--quiet); }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

.kpi { display: flex; flex-direction: column; gap: 3px; }
.kpi .k-label { font-size: 12px; color: var(--quiet); }
.kpi .k-value { font-family: 'Barlow Numeral', sans-serif; font-size: 30px; font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
.kpi .k-sub { font-size: 11.5px; color: var(--quiet); }
.kpi.accent .k-value { color: var(--accent); }

/* ───────────────── 表格 ───────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--quiet);
  padding: 0 10px 9px 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.clickable { cursor: pointer; transition: background 0.15s; }
.tbl tr.clickable:hover { background: var(--soft); }
.tbl .r { text-align: right; padding-right: 0; }
.tbl .name { font-weight: 600; }
.tbl .muted { color: var(--quiet); font-size: 12px; }
.tbl a { color: inherit; text-decoration: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ───────────────── 图表 ───────────────── */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis-text { fill: var(--quiet); font-size: 10px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.bar-row { display: grid; grid-template-columns: 1fr 56px; gap: 10px; align-items: center; padding: 5px 0; font-size: 12.5px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bar-track { height: 8px; background: var(--line-soft); border-radius: 4px; overflow: hidden; margin-top: 3px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bar-val { font-family: 'Barlow Numeral', sans-serif; text-align: right; color: var(--ink); font-size: 13px; }

/* ───────────────── 杂项 ───────────────── */
.empty { padding: 44px 16px; text-align: center; color: var(--quiet); font-size: 13px; }
.note {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}
.note.warn { background: var(--warn-soft); border-color: #e6cfb4; }
.note.bad { background: var(--bad-soft); border-color: #eccfd0; }
.note b { color: var(--ink); }
.code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.75;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  overflow-x: auto;
  white-space: pre;
  color: var(--muted);
}
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li {
  counter-increment: s;
  position: relative;
  padding: 0 0 16px 30px;
  font-size: 13px;
  color: var(--muted);
}
.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0; top: 0;
  width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.steps li strong { display: block; color: var(--ink); font-size: 13.5px; margin-bottom: 2px; }
select, input[type='text'], input[type='number'], input[type='password'] {
  font: inherit;
  font-size: 13.5px;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  outline: none;
}
select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.sec { margin-bottom: 20px; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-head h3 { font-size: 15px; font-weight: 600; margin: 0; }
.sec-head .muted { font-size: 12px; color: var(--quiet); }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; }
  .side-nav { flex-direction: row; overflow-x: auto; flex: 1; }
  .side-nav a { padding: 7px 10px; font-size: 12.5px; white-space: nowrap; }
  .side-foot { margin: 0; flex-direction: row; align-items: center; }
  .side-stat { padding: 4px 10px; }
  .main { padding: 16px 16px 44px; }
}
