:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #16202e;
  --muted: #6b7684;
  --line: #e4e8ef;
  --accent: #2563eb;
  --accent-soft: #e3edff;
  --good: #0f9d58;
  --warn: #d98014;
  --bad: #d64545;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 28px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  background: linear-gradient(120deg, #12213c, #1d3a6b 55%, #24508f);
  color: #fff;
}

.topbar h1 { margin: 0; font-size: 21px; letter-spacing: .3px; }

.subtitle { margin: 4px 0 0; color: #b9c9e6; font-size: 13px; }

.freshness {
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius);
  padding: 10px 16px;
}

.freshness-label { font-size: 12px; color: #b9c9e6; }

.freshness-time { font-size: 17px; font-weight: 600; letter-spacing: .4px; }

.freshness-note { font-size: 12px; color: #b9c9e6; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #7f8ea8;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .12);
  flex: none;
}

.dot.fresh { background: #34d399; }
.dot.aging { background: #fbbf24; }
.dot.stale { background: #f87171; }

.restore-bar {
  margin: 20px 28px 0;
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
}

.restore-state { display: flex; align-items: center; gap: 10px; }

.restore-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.restore-badge.on { background: #e4f6ec; color: var(--good); }

.restore-desc { color: var(--muted); font-size: 13px; }

.restore-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-left: auto; }

.restore-controls input[type="password"] {
  width: 210px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #fbfcfe;
}

.restore-controls input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: #1d4fd8; }
button.primary:disabled { background: #9db4e6; cursor: default; }

button.ghost { background: #fff; border-color: var(--line); color: var(--muted); }
button.ghost:hover { border-color: var(--accent); color: var(--accent); }

.remember { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

.restore-message { flex-basis: 100%; margin: 0; font-size: 13px; min-height: 20px; }
.restore-message.error { color: var(--bad); }
.restore-message.ok { color: var(--good); }
.restore-message.busy { color: var(--muted); }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin: 18px 28px 0;
}

.metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.metric-label { color: var(--muted); font-size: 13px; }

.metric-value { font-size: 26px; font-weight: 700; letter-spacing: .5px; margin-top: 2px; }

.metric-unit { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }

.metric-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 16px;
  margin: 18px 28px 0;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 20px;
  min-width: 0;
}

.panel.wide { grid-column: 1 / -1; }

.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }

.panel-title { font-size: 15px; font-weight: 600; margin: 0; }

.panel-unit { font-size: 12px; color: var(--muted); }

.panel-sub { font-size: 12px; color: var(--muted); margin: 0 0 14px; }

.bars { display: flex; flex-direction: column; gap: 9px; }

.bar-row { display: grid; grid-template-columns: minmax(84px, 150px) 1fr auto; gap: 10px; align-items: center; }

.bar-label {
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track { background: #eef1f6; border-radius: 7px; height: 20px; overflow: hidden; }

.bar-fill {
  height: 100%;
  border-radius: 7px;
  background: linear-gradient(90deg, #4f7fe6, #2563eb);
  transition: width .5s ease;
}

.bar-fill.masked { background: linear-gradient(90deg, #9aa8bd, #7c8ba1); }

.bar-value { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.chart { width: 100%; height: auto; display: block; }

.chart .axis-line { stroke: #dfe4ec; stroke-width: 1; }

.chart .grid-line { stroke: #eef1f6; stroke-width: 1; }

.chart .axis-text { fill: #86909c; font-size: 11px; }

.chart .series-line { fill: none; stroke: #2563eb; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }

.chart .series-area { fill: url(#areaGradient); }

.chart .series-dot { fill: #fff; stroke: #2563eb; stroke-width: 2; }

.chart .bar-rect { fill: #4f7fe6; }

.chart .bar-rect:hover { fill: #2563eb; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }

table.data-table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #fafbfd;
  position: sticky;
  top: 0;
}

table.data-table td { padding: 8px 10px; border-bottom: 1px solid #f3f5f9; }

table.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

table.data-table tbody tr:hover { background: #f8faff; }

.table-wrap { max-height: 420px; overflow: auto; }

.cell-masked { color: #7c8ba1; font-family: Consolas, "Courier New", monospace; font-size: 12.5px; }

.cell-restored { color: var(--good); font-weight: 600; }

.empty { color: var(--muted); font-size: 13px; padding: 16px 0; }

.footer { margin: 22px 28px 0; color: var(--muted); font-size: 12.5px; line-height: 1.9; }

.footer-note { color: #9aa4b2; }

@media (max-width: 720px) {
  .topbar, .restore-bar, .metrics, .grid, .footer { margin-left: 14px; margin-right: 14px; }
  .topbar { padding: 18px; }
  .grid { grid-template-columns: 1fr; }
  .restore-controls { margin-left: 0; width: 100%; }
  .restore-controls input[type="password"] { flex: 1; min-width: 140px; }
}

/* 整页加密时的解锁界面 */
.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(140deg, #12213c, #1d3a6b 60%, #24508f);
}

.gate[hidden] { display: none; }

.gate-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(8, 18, 38, .35);
  padding: 30px 28px 24px;
  text-align: center;
}

.gate-mark {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .6px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 12px;
  margin-bottom: 14px;
}

.gate-title { margin: 0 0 4px; font-size: 19px; }

.gate-note { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

.gate-card input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #fbfcfe;
  margin-bottom: 12px;
}

.gate-card input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.gate-button { width: 100%; padding: 11px 16px; font-size: 14px; }

.gate-remember { justify-content: center; margin-top: 12px; }

.gate-message { margin: 10px 0 0; font-size: 13px; min-height: 20px; }
.gate-message.error { color: var(--bad); }
.gate-message.busy { color: var(--muted); }

.gate-time { margin: 6px 0 0; font-size: 12px; color: #9aa4b2; }
