:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15181d;
  --card: #20242a;
  --surface: #20242a;
  --text: #f4f6f8;
  --muted: #aab2bd;
  --border: #3a414b;
  --line: #3a414b;
  --primary: #42a5e8;
  --primary-soft: #17364a;
  --accent: #54b3ea;
  --accent-soft: #17364a;
  --blue: #54b3ea;
  --blue-soft: #17364a;
  --cyan: #45b5dd;
  --success-soft: #183b2b;
  --green: #49bd84;
  --green-soft: #183b2b;
  --warning: #f0ad43;
  --warning-soft: #49371b;
  --amber: #f0ad43;
  --amber-soft: #49371b;
  --danger: #f06b72;
  --danger-soft: #49252a;
  --red: #f06b72;
  --red-soft: #49252a;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
:root[data-theme="dark"] .metric-pill,
:root[data-theme="dark"] .badge:not(.ok):not(.warn):not(.danger),
:root[data-theme="dark"] .badge.idle,
:root[data-theme="dark"] .tabs {
  border-color: var(--border);
  background: #292e35;
  color: var(--muted);
}
:root[data-theme="dark"] .track,
:root[data-theme="dark"] .bar-track,
:root[data-theme="dark"] .mini-track { background: #343a43; }
:root[data-theme="dark"] .tag,
:root[data-theme="dark"] .refresh,
:root[data-theme="dark"] .icon-button {
  border-color: #2d6687;
  background: var(--blue-soft);
  color: #7bc8f1;
}
:root[data-theme="dark"] .refresh { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18); }
:root[data-theme="dark"] .refresh:hover { box-shadow: 0 7px 18px rgba(0, 0, 0, 0.24); }
:root[data-theme="dark"] .tab.active { background: #3a424d; color: #8bd2f5; }
:root[data-theme="dark"] .entity-row:hover { background: #202f3a; }
:root[data-theme="dark"] .icon-button:hover { background: #23475e; }
:root[data-theme="dark"] .plot-change,
:root[data-theme="dark"] .hover-dot { background: var(--card); fill: var(--card); }
:root[data-theme="dark"] .axis,
:root[data-theme="dark"] .trend-grid { stroke: #414957; }

html, body { transition: background-color 180ms ease, color 180ms ease; }
.monitor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.monitor-nav {
  display: flex;
  align-items: stretch;
  max-width: 100%;
  overflow-x: auto;
  border-bottom: 1px solid var(--border, var(--line, #e4e7ec));
  scrollbar-width: none;
}
.monitor-nav::-webkit-scrollbar { display: none; }
.monitor-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 12px;
  color: var(--muted, #667085);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  transition: color 150ms ease, background-color 150ms ease;
}
.monitor-nav a::after {
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  content: "";
}
.monitor-nav a:hover { background: var(--primary-soft, var(--blue-soft, #eaf6fe)); color: var(--primary, var(--blue, #1578ba)); }
.monitor-nav a:focus-visible { z-index: 1; outline: 3px solid rgba(62, 164, 236, 0.38); outline-offset: -3px; }
.monitor-nav a[aria-current="page"] { color: var(--primary, var(--blue, #1578ba)); }
.monitor-nav a[aria-current="page"]::after { background: currentColor; }
.theme-toggle {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 1000;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border, var(--line, #d0d5dd));
  border-radius: 8px;
  background: var(--card, var(--surface, #fff));
  color: var(--text, #111827);
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.14);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.theme-toggle:hover { transform: translateY(-1px); box-shadow: 0 9px 24px rgba(16, 24, 40, 0.18); }
.theme-toggle:focus-visible { outline: 3px solid rgba(62, 164, 236, 0.38); outline-offset: 3px; }
.theme-icon { width: 19px; height: 19px; }
:root[data-theme="light"] .theme-icon-sun,
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32); }
@media (max-width: 640px) {
  .monitor-toolbar { align-items: stretch; flex-direction: column; gap: 10px; margin-bottom: 18px; }
  .monitor-nav { width: 100%; }
  .monitor-nav a { min-height: 44px; padding-right: 10px; padding-left: 10px; }
  .theme-toggle { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  html, body, .theme-toggle { transition: none; }
}

/* Shared monitor surface: quiet neutral surfaces, consistent density, visible controls. */
:root[data-theme="light"]{--bg:#f5f7fa;--card:#fff;--surface:#fff;--text:#202938;--muted:#606d7e;--border:#e1e6ed;--line:#e1e6ed;--primary:#255cbd;--accent:#255cbd;--blue:#255cbd;--cyan:#296d96;--primary-soft:#edf3fc;--accent-soft:#edf3fc;--blue-soft:#edf3fc;--hover:#f6f8fc;--shadow:none}
:root[data-theme="dark"]{--bg:#12161d;--card:#1b222c;--surface:#1b222c;--text:#e7edf5;--muted:#a8b5c6;--border:#333e4e;--line:#333e4e;--primary:#8ab7ff;--accent:#8ab7ff;--blue:#8ab7ff;--cyan:#83c7e6;--primary-soft:#25364e;--accent-soft:#25364e;--blue-soft:#25364e;--hover:#222d3a;--shadow:none;--upload:#f0b568;--download:#83b6ff}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;line-height:1.55;-webkit-font-smoothing:antialiased;background:var(--bg);color:var(--text)}
body>main,body>.wrap{width:100%;max-width:none;min-width:0;margin:0;padding:24px clamp(20px,2.5vw,48px) 64px}
.monitor-toolbar{flex-wrap:wrap;gap:12px;align-items:center;margin-bottom:32px;padding-bottom:16px;border-bottom:1px solid var(--border)}
.monitor-nav{border:0;flex:1 1 auto;gap:4px}
.monitor-nav a{min-height:44px;padding:10px 14px;border-radius:8px;font-size:14px;font-weight:550}
.monitor-nav a::after{display:none}
.monitor-nav a[aria-current="page"]{background:var(--primary-soft);color:var(--primary);font-weight:650}
.monitor-toolbar>.actions,.monitor-toolbar>.controls{flex-wrap:wrap}
.theme-controls{display:flex;align-items:center;gap:6px;flex-shrink:0}
.theme-controls .theme-toggle,.theme-controls #theme-system{position:static;display:inline-flex;align-items:center;justify-content:center;gap:8px;width:auto;height:auto;min-height:42px;padding:8px 12px;border:1px solid var(--border);border-radius:8px;background:var(--card);color:var(--text);box-shadow:none;font:inherit;font-size:13px;white-space:nowrap;cursor:pointer;transform:none}
.theme-controls .theme-toggle:hover,.theme-controls #theme-system:hover{background:var(--hover);box-shadow:none;transform:none}
.theme-controls #theme-system{border-color:transparent;color:var(--muted);background:transparent}
.theme-controls #theme-system[aria-pressed="true"]{color:var(--primary);background:var(--primary-soft)}
.theme-controls button:focus-visible{outline:2px solid var(--blue);outline-offset:3px}
.theme-icon{width:17px;height:17px}
.eyebrow{display:none}
h1,.head h2{font-size:28px;font-weight:700;letter-spacing:-.02em;line-height:1.3;margin:0 0 10px}
.subtitle,.head .sub{font-size:14px;line-height:1.7;color:var(--muted)}
.title-icon{background:var(--primary-soft);color:var(--primary);box-shadow:none}
body .card,body .section,body .summary-card,body .metric-card,body .priority-panel{border:1px solid var(--border);border-radius:14px;background:var(--card);box-shadow:none}
body .section{padding:22px;margin-top:20px}
.section-title,.summary-title,.viz-title{font-weight:650;letter-spacing:0}
.section-note,.metric-meta,.score-meta{line-height:1.65;color:var(--muted)}
.metric-value,.summary-value,.value{font-variant-numeric:tabular-nums;letter-spacing:-.02em}
body .refresh,body .icon-button{min-height:42px;border:1px solid var(--border);border-radius:8px;background:var(--card);color:var(--primary);box-shadow:none;font-weight:600;transform:none}
body .refresh:hover,body .icon-button:hover{background:var(--primary-soft);box-shadow:none;transform:none}
body .range,body .metric-select{min-height:42px;background:var(--card);border-color:var(--border);color:var(--text)}
table{font-size:13px;line-height:1.6}body .table th,body .table td{padding:12px 12px;border-color:var(--border)}
table thead{background:var(--hover)}table th{color:var(--muted);font-weight:600}table tbody tr:hover{background:var(--hover)}
body input:not([type="checkbox"]):not([type="radio"]),body select,body textarea{color:var(--text);background-color:var(--card);border-color:var(--border)}
input::placeholder,textarea::placeholder{color:var(--muted);opacity:1}
body button:focus-visible,body select:focus-visible,body input:focus-visible{outline:2px solid var(--primary);outline-offset:3px}
body .table-wrap{border-radius:8px}
:root[data-theme="dark"] .error{color:#ff969d}
:root[data-theme="dark"] .priority-delay small,:root[data-theme="dark"] .pool-option small{color:var(--muted)}
@media(max-width:760px){body>main,body>.wrap{padding:18px max(14px,env(safe-area-inset-right)) 40px max(14px,env(safe-area-inset-left))}.monitor-toolbar{flex-direction:row;gap:10px;margin-bottom:24px}.monitor-nav{flex-basis:100%;width:100%}.monitor-nav a{flex:1;padding:10px 8px;font-size:13px}.theme-controls{margin-left:auto}.monitor-toolbar>.actions{width:auto;flex:1 1 auto}.monitor-toolbar>.actions .refresh-meta{display:none}body .section{padding:16px}h1,.head h2{font-size:25px}.theme-controls .theme-toggle,.theme-controls #theme-system{min-height:44px}body input:not([type="checkbox"]):not([type="radio"]),body select{font-size:16px}}
