/* 配色与设备界面一致 */
:root {
  --bg: #EEF1F5; --card: #FFFFFF; --card2: #E3E8EF; --line: #D5DCE5;
  --text: #111827; --muted: #5E6A7D; --dim: #A3ADBC; --accent: #0A84E0; --on-fill: #FFFFFF;
  --good: #059669; --fair: #D98A04; --poor: #EA580C; --bad: #DC2626;
  --radius: 18px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0D1117; --card: #161C26; --card2: #212A38; --line: #263041;
  --text: #EEF2F7; --muted: #8793A8; --dim: #4A5568; --accent: #4CC2FF; --on-fill: #0D1117;
  --good: #34D399; --fair: #FBBF24; --poor: #FB923C; --bad: #F87171;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font: 15px/1.5 "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  transition: background-color .25s, color .25s;
}
button, select, input { font: inherit; color: inherit; }
svg { display: block; }

/* 顶栏 */
.top {
  max-width: 1200px; margin: 0 auto; padding: 22px 24px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.dev { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dim); flex: none; transition: background-color .3s; }
.dot.on { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 22%, transparent); }
.dev-name { position: relative; min-width: 0; }
h1 { margin: 0; font-size: 22px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-name.multi h1::after { content: " ▾"; color: var(--muted); font-size: 15px; }
#devsel { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.ago { color: var(--muted); font-size: 14px; white-space: nowrap; }
.ago.stale { color: var(--poor); }
.tools { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--card); color: var(--muted); cursor: pointer; text-decoration: none;
  transition: background-color .2s, color .2s, transform .15s;
}
.icon-btn:hover { color: var(--text); background: var(--card2); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.small { width: 30px; height: 30px; background: transparent; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.small svg { width: 16px; height: 16px; }
:root[data-theme="dark"] .sun, :root[data-theme="light"] .moon { display: none; }

.err {
  max-width: 1152px; margin: 8px auto 0; padding: 10px 16px; border-radius: 12px;
  background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad);
}

main { max-width: 1200px; margin: 0 auto; padding: 12px 24px 40px; display: grid; gap: 20px; }
.card { background: var(--card); border-radius: var(--radius); transition: background-color .25s; }

/* 当前值 */
.now { display: grid; grid-template-columns: 300px 1fr; gap: 20px; }
.hero { position: relative; display: grid; place-items: center; padding: 24px; min-height: 300px; }
.ring { width: 230px; height: 230px; transform: rotate(135deg); }
.ring circle { fill: none; stroke-width: 14; stroke-linecap: round; stroke-dasharray: 395.8 527.8; }
.ring .track { stroke: var(--line); }
.ring .arc { stroke: var(--dim); stroke-dashoffset: 395.8; transition: stroke-dashoffset .9s cubic-bezier(.2,.8,.2,1), stroke .6s; }
.hero-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.lvl { font-size: 64px; font-weight: 700; line-height: 1.1; color: var(--dim); transition: color .6s; }
.worst { color: var(--muted); font-size: 16px; min-height: 24px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.tile {
  position: relative; text-align: left; border: 2px solid transparent; border-radius: var(--radius);
  background: var(--card); padding: 14px 16px 12px; cursor: pointer; min-height: 92px;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: border-color .2s, background-color .25s, transform .15s;
}
.tile:hover { background: color-mix(in srgb, var(--card) 70%, var(--card2)); }
.tile:active { transform: scale(.97); }
.tile.sel { border-color: var(--accent); }
.tile .name { color: var(--muted); font-size: 14px; }
.tile .lv { position: absolute; top: 16px; right: 16px; width: 9px; height: 9px; border-radius: 50%; background: var(--dim); transition: background-color .5s; }
.tile .val { font-size: 28px; font-weight: 700; line-height: 1.15; }
.tile .val small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; }

/* 曲线 */
.chart-card { padding: 20px 22px 18px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chart-title { font-size: 20px; font-weight: 600; }
.chart-title .unit { color: var(--muted); font-size: 14px; font-weight: 400; margin-left: 6px; }
.seg { display: flex; background: var(--bg); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--muted); padding: 6px 14px; border-radius: 999px; cursor: pointer;
  white-space: nowrap; transition: background-color .2s, color .2s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--card2); color: var(--text); }
.custom { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); flex-wrap: wrap; }
.custom input { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.chart-wrap { position: relative; height: 380px; margin-top: 14px; touch-action: pan-y; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }
.tip {
  position: absolute; top: 4px; pointer-events: none; white-space: nowrap;
  background: var(--text); color: var(--bg); border-radius: 10px; padding: 6px 12px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.tip b { font-size: 16px; }
.tip .rng { opacity: .7; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
.stats div { background: var(--bg); border-radius: 14px; padding: 10px 16px; transition: background-color .25s; }
.stats span { display: block; color: var(--muted); font-size: 13px; }
.stats b { font-size: 22px; }

/* 汇总 */
.summary { display: grid; gap: 20px; min-width: 0; transition: opacity .2s; }
.summary > *, main > * { min-width: 0; } /* 宽表格只在自己的卡片里横向滚动，不撑宽整页 */
.summary.busy { opacity: .55; }
.sum-card { padding: 20px 22px 12px; }
.sum-top { display: flex; align-items: center; gap: 16px; }
.obar { flex: 1; display: flex; height: 34px; border-radius: 10px; overflow: hidden; gap: 2px; background: var(--card2); }
.obar div {
  min-width: 3px; display: grid; place-items: center; color: var(--on-fill); font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; transition: flex-grow .5s cubic-bezier(.2,.8,.2,1);
}
.cover { color: var(--muted); font-size: 14px; white-space: nowrap; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; }
.sum-table { margin-top: 10px; min-width: 640px; }
.sum-table th, .sum-table td { padding: 10px 8px; text-align: right; white-space: nowrap; }
.sum-table thead th { color: var(--muted); font-size: 13px; font-weight: 400; }
.sum-table tbody th { text-align: left; font-weight: 600; }
.sum-table tbody th small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 5px; }
.sum-table tbody tr { border-top: 1px solid var(--line); cursor: pointer; transition: background-color .15s; }
.sum-table tbody tr:hover { background: color-mix(in srgb, var(--card2) 45%, transparent); }
.sum-table tbody tr.sel th { color: var(--accent); }
.sum-table td[title] { text-decoration: underline dotted var(--dim); text-underline-offset: 4px; }
.sum-table .dist-h, .sum-table .dist-c { width: 26%; min-width: 140px; }
.ldot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; background: var(--dim); }
.dist { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 1px; background: var(--card2); }
.dist i { min-width: 2px; }

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.pane { padding: 18px 20px 20px; min-width: 0; }
.pane h2 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
.pane h2 .count { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 14px; }

.heat { display: grid; grid-template-columns: 46px repeat(24, 1fr); gap: 2px; font-size: 11px; }
.heat .hl, .heat .dl { color: var(--muted); white-space: nowrap; overflow: visible; line-height: 16px; }
.heat .dl { font-size: 12px; align-self: center; }
.heat .c { height: 16px; border-radius: 3px; background: color-mix(in srgb, var(--card2) 55%, transparent); }
.heat .avg-row { margin-top: 4px; }

.corr { display: grid; gap: 3px; font-size: 13px; }
.corr .n { color: var(--muted); font-size: 12px; display: grid; place-items: center; white-space: nowrap; }
.corr .n.row { justify-content: start; }
.corr .c { aspect-ratio: 1.6; border-radius: 6px; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.corr .c.diag { background: var(--card2); }
.corr .c.strong { color: var(--on-fill); font-weight: 600; }

.daily-wrap { max-height: 430px; overflow-y: auto; }
.daily { font-size: 14px; }
.daily th, .daily td { padding: 7px 6px; text-align: right; white-space: nowrap; }
.daily thead th { position: sticky; top: 0; background: var(--card); color: var(--muted); font-size: 13px; font-weight: 400; transition: background-color .25s; }
.daily tbody th { text-align: left; font-weight: 400; }
.daily tbody th small { color: var(--muted); margin-left: 4px; }
.daily tbody tr { border-top: 1px solid var(--line); cursor: pointer; }
.daily tbody tr:hover { background: color-mix(in srgb, var(--card2) 45%, transparent); }

.eps { list-style: none; margin: 0; padding: 0; max-height: 430px; overflow-y: auto; }
.eps li {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 12px;
  padding: 10px 6px; border-top: 1px solid var(--line); cursor: pointer; transition: background-color .15s;
}
.eps li:first-child { border-top: 0; }
.eps li:hover { background: color-mix(in srgb, var(--card2) 45%, transparent); }
.eps .ldot { margin: 0; }
.eps .when { color: var(--muted); font-size: 13px; grid-column: 2 / 4; }
.eps .peak { font-weight: 600; }
.eps .peak small { color: var(--muted); font-weight: 400; margin-left: 3px; }
.none { color: var(--muted); padding: 24px 0; text-align: center; }

.welcome { max-width: 560px; margin: 16vh auto; padding: 0 24px; text-align: center; }
.welcome h2 { font-weight: 600; }
.welcome p { color: var(--muted); }
.welcome code { display: inline-block; padding: 10px 16px; border-radius: 12px; background: var(--card); user-select: all; word-break: break-all; }

@media (max-width: 900px) {
  .now { grid-template-columns: 1fr; }
  .hero { min-height: 0; padding: 16px; }
  .ring { width: 190px; height: 190px; }
  .duo { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .top { padding: 16px 16px 4px; }
  main { padding: 8px 12px 28px; gap: 14px; }
  .tiles { gap: 10px; }
  .tile { padding: 10px 12px; min-height: 80px; }
  .tile .val { font-size: 22px; }
  .tile .val small { display: block; margin: 0; font-size: 11px; }
  .tile .lv { top: 13px; right: 12px; }
  .chart-card { padding: 16px 12px 14px; }
  .seg button { padding: 6px 10px; font-size: 13px; }
  .chart-wrap { height: 300px; }
  .stats { gap: 8px; }
  .stats b { font-size: 18px; }
  .ago { display: none; }
  .summary { gap: 14px; }
  .duo { gap: 14px; }
  .sum-card, .pane { padding: 16px 12px 12px; }
  .sum-top { flex-direction: column; align-items: stretch; gap: 8px; }
  .cover { text-align: right; }
  .heat { grid-template-columns: 38px repeat(24, 1fr); gap: 1px; }
  .heat .c { height: 13px; border-radius: 2px; }
  .corr { font-size: 11px; gap: 2px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
