/* 共享基础样式 — 所有页面引用 */
:root {
  --bg: #0f141d;
  --card: #171f2b;
  --border: #2a3547;
  --text: #d7e1f0;
  --muted: #93a4ba;
  --primary: #5f8fd6;
  --primary-deep: #4f7fc8;
  --success-bg: #10261d;
  --success-text: #63d9aa;
  --error-bg: #341c22;
  --error-text: #ffa2b1;
  --table-head-bg: #202a3a;
  --table-row-even: #141c27;
  --card-soft: #121a26;
  --shadow-soft: 0 10px 24px rgba(6, 10, 20, 0.32);
  --chart-grid: rgba(154, 172, 191, 0.2);
  --green: #34d399;
  --red: #f87171;
}
body[data-theme="light"] {
  --bg: #f4f7ff;
  --card: #ffffff;
  --border: #e3e8f5;
  --text: #1f2a44;
  --muted: #65708a;
  --primary: #3b82f6;
  --primary-deep: #2563eb;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --error-bg: #fef2f2;
  --error-text: #b91c1c;
  --table-head-bg: #f3f7ff;
  --table-row-even: #fafcff;
  --card-soft: #fbfdff;
  --shadow-soft: 0 8px 24px rgba(30, 70, 140, 0.08);
  --chart-grid: rgba(148, 163, 184, 0.28);
  --green: #059669;
  --red: #dc2626;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(0deg, rgba(15, 22, 34, 0.70), rgba(15, 22, 34, 0.70)),
    url("/scripts/2.jpg") center center / cover no-repeat fixed;
  line-height: 1.55;
}
body[data-theme="light"] {
  background:
    linear-gradient(0deg, rgba(244, 248, 255, 0.70), rgba(244, 248, 255, 0.70)),
    url("/scripts/2.jpg") center center / cover no-repeat fixed;
}
.page {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 18px 24px;
}
.header-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #1e2a3b 0%, #162132 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 12px;
}
.header-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(150, 182, 230, 0.18) 0%, rgba(11, 20, 34, 0.04) 100%);
  pointer-events: none;
}
.header-card > * { position: relative; z-index: 2; }
body[data-theme="light"] .header-card { background: linear-gradient(135deg, #ffffff 0%, #f7faff 100%); }
.title { margin: 0 0 4px; font-size: 24px; font-weight: 700; }
.subtitle { color: var(--muted); font-size: 14px; margin: 0; }
.header-actions { margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nav-links a { color: var(--primary); text-decoration: none; margin-right: 14px; }
.nav-links a:hover { text-decoration: underline; }
button.theme-toggle {
  min-height: 30px; padding: 5px 12px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--border); background: #1f2c3f; color: #d7e4fa; cursor: pointer;
}
body[data-theme="light"] button.theme-toggle { background: #fff; color: #334155; }
.block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px 12px;
  margin-top: 12px;
  box-shadow: var(--shadow-soft);
}
.block h3 { margin: 0 0 10px; font-size: 17px; font-weight: 650; }
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.metric-item {
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
}
.metric-value { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 2px; }
.metric-value.up { color: var(--green); }
.metric-value.down { color: var(--red); }
.metric-label { font-size: 12px; color: var(--muted); }
.chart-wrap {
  width: 100%;
  height: 260px;
  padding: 16px;
  background: var(--card-soft);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  margin-top: 10px;
}
.range-btn {
  padding: 5px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: var(--card-soft); color: var(--muted); cursor: pointer;
}
.range-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.range-btn:hover:not(.active) { background: rgba(95,143,214,0.15); }
.record-list { list-style: none; padding: 0; margin: 0; }
.record-list li { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
.record-list li:last-child { border-bottom: none; }
.record-date { color: var(--muted); font-size: 12px; margin-left: 8px; }
.loading { text-align: center; color: var(--muted); padding: 20px; }
.msg, .err { margin: 10px 0; padding: 10px 12px; border-radius: 10px; border: 1px solid transparent; font-size: 14px; }
.msg { color: var(--success-text); background: var(--success-bg); border-color: #a7f3d0; }
.err { color: var(--error-text); background: var(--error-bg); border-color: #fecaca; }
table {
  width: 100%;
  margin-top: 10px;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #e4eaf8;
  border-radius: 12px;
  overflow: hidden;
  font-size: 14px;
  background: var(--card);
}
th, td { border-bottom: 1px solid #edf1fb; padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--table-head-bg); color: var(--text); font-weight: 650; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: var(--table-row-even); }
body[data-theme="dark"] table { border-color: #2a3446; background: #161e2a; }
body[data-theme="dark"] th, body[data-theme="dark"] td { border-bottom-color: #273246; color: #d2dceb; }
body[data-theme="dark"] th { background: #202a3a; color: #d9e3f2; }
body[data-theme="dark"] tr:nth-child(odd) td { background: #171f2b; }
body[data-theme="dark"] tr:nth-child(even) td { background: #141c27; }
table td a { color: #2563eb; text-decoration: none; }
body[data-theme="dark"] table td a { color: #7ea7d9; }
table td a:hover { text-decoration: underline; }

/* 移动端适配 */
@media (max-width: 768px) {
  .page { padding: 10px 12px 18px; }
  .header-card { padding: 14px 14px; }
  .title { font-size: 20px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-wrap { height: 200px; padding: 10px; }
  .range-btn { padding: 8px 14px; font-size: 14px; }
  button.theme-toggle { padding: 8px 14px; font-size: 13px; }
  table { font-size: 13px; }
  th, td { padding: 6px 8px; }
}
@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .header-actions { gap: 6px; }
}
