/* Pi Command Center — dark-first, dependency-free styles */

:root {
  color-scheme: dark;
  --bg: #08090c;
  --bg-glow-1: rgba(124, 108, 255, .14);
  --bg-glow-2: rgba(34, 211, 238, .07);
  --grid-dot: rgba(255, 255, 255, .035);
  --surface: #0f1116;
  --surface-2: #151820;
  --surface-3: #1b1f29;
  --sheen: rgba(255, 255, 255, .025);
  --border: rgba(255, 255, 255, .075);
  --border-strong: rgba(255, 255, 255, .14);
  --text: #eceef3;
  --text-2: #a7aebb;
  --text-3: #7a8191;
  --accent: #8b7dff;
  --accent-2: #e5486f;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --info: #60a5fa;
  --muted: #6b7280;
  --c-cpu: #60a5fa;
  --c-temp: #f59e0b;
  --c-mem: #a78bfa;
  --c-disk: #2dd4bf;
  --c-rx: #34d399;
  --c-tx: #60a5fa;
  --c-permitted: #6378ff;
  --c-blocked: #f43f5e;
  --c-cached: #2dd4bf;
  --c-forwarded: #a78bfa;
  --c-air: #34d399;
  --c-energy: #fbbf24;
  --c-climate: #38bdf8;
  --c-other: #a78bfa;
  --track: rgba(255, 255, 255, .07);
  --shadow: 0 1px 0 rgba(255, 255, 255, .035) inset, 0 14px 34px -22px rgba(0, 0, 0, .95);
  --tooltip-bg: rgba(18, 20, 27, .94);
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f8;
  --bg-glow-1: rgba(124, 108, 255, .13);
  --bg-glow-2: rgba(34, 211, 238, .09);
  --grid-dot: rgba(15, 23, 42, .07);
  --surface: #ffffff;
  --surface-2: #f5f6f9;
  --surface-3: #eceef3;
  --sheen: rgba(255, 255, 255, 0);
  --border: rgba(15, 23, 42, .085);
  --border-strong: rgba(15, 23, 42, .17);
  --text: #0d1017;
  --text-2: #4a5263;
  --text-3: #687082;
  --accent: #6d5dfc;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --info: #2563eb;
  --c-cpu: #2563eb;
  --c-temp: #d97706;
  --c-mem: #7c3aed;
  --c-disk: #0d9488;
  --c-rx: #059669;
  --c-tx: #2563eb;
  --c-permitted: #5b6cf0;
  --c-blocked: #e11d48;
  --c-cached: #0d9488;
  --c-forwarded: #8b5cf6;
  --c-air: #059669;
  --c-energy: #d97706;
  --c-climate: #0284c7;
  --c-other: #7c3aed;
  --track: rgba(15, 23, 42, .08);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 28px -20px rgba(15, 23, 42, .35);
  --tooltip-bg: rgba(255, 255, 255, .97);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-color: var(--surface-3) transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(1100px 520px at 10% -14%, var(--bg-glow-1), transparent 62%),
    radial-gradient(900px 480px at 96% -10%, var(--bg-glow-2), transparent 60%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1.3px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 560px);
  mask-image: linear-gradient(to bottom, #000, transparent 560px);
}

::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

a { color: inherit; }

.mono, code { font-family: var(--mono); font-size: .92em; }

code {
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  overflow-wrap: anywhere;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 clamp(14px, 3vw, 32px);
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) clamp(14px, 3vw, 32px) 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  text-decoration: none;
}

.logo {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  box-shadow: 0 6px 18px -6px rgba(139, 125, 255, .65);
}

.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }

.brand-host {
  overflow: hidden;
  color: var(--text-3);
  font: 11.5px/1.3 var(--mono);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.topnav { display: flex; gap: 2px; margin-left: auto; }

.topnav a {
  padding: 6px 11px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: color .2s, background-color .2s;
}

.topnav a:hover { color: var(--text); background: var(--surface-2); }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: 6px; }

.live {
  --tone: var(--ok);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 9px 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: 500 12px/1 var(--font);
  cursor: pointer;
  transition: border-color .2s, color .2s;
}

.live:hover { border-color: var(--border-strong); color: var(--text); }
.live[data-state="retrying"] { --tone: var(--warn); }
.live[data-state="offline"], .live[data-state="expired"] { --tone: var(--bad); color: var(--text); }

.ring { display: inline-block; width: 16px; height: 16px; }
.ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 2.4; }
.ring-track { stroke: var(--track); }
.ring-progress { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 50.27; stroke-dashoffset: 50.27; }
.ring.run .ring-progress { animation: ring var(--dur, 15s) linear forwards; }
.live:not([data-state="live"]) .ring { display: none; }

@keyframes ring { from { stroke-dashoffset: 50.27; } to { stroke-dashoffset: 0; } }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: color .2s, border-color .2s;
}

.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn > span { display: inline-grid; }
:root[data-theme="dark"] .theme-light, :root[data-theme="light"] .theme-dark { display: none; }

a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Status primitives ---------- */

.tone-ok { --tone: var(--ok); }
.tone-warn { --tone: var(--warn); }
.tone-bad { --tone: var(--bad); }
.tone-info { --tone: var(--info); }
.tone-muted { --tone: var(--muted); }

.dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--tone, var(--muted));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone, var(--muted)) 20%, transparent);
}

.dot.pulse { animation: pulse 2.6s var(--ease) infinite; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tone) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 8px transparent; }
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: border-color .2s, color .2s;
}

a.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill-state { color: var(--text-3); }
.pill-state::before { content: "·"; margin-right: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  margin-left: auto;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.chip .dot { width: 6px; height: 6px; box-shadow: none; }

/* ---------- Overview ---------- */

.overview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin: 22px 0 4px;
  padding: 12px 14px 12px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--sheen), transparent), var(--surface);
  box-shadow: var(--shadow);
}

.overall { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.overall .dot { width: 9px; height: 9px; }
.overview-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.overview-meta { margin-left: auto; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.overview-meta time { color: var(--text-2); }

/* ---------- Sections & grids ---------- */

.section { margin-top: 34px; scroll-margin-top: 76px; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 14px;
}

.section-head h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.section-head h2 .icon { width: 15px; height: 15px; color: var(--accent); }
.section-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text-3); font-size: 12.5px; }
.sep { margin: 0 2px; color: var(--text-3); opacity: .7; }
.section-foot { margin: 14px 2px 0; color: var(--text-3); font-size: 12px; }

.grid { display: grid; gap: 14px; }
.grid + .grid { margin-top: 14px; }
.grid-metrics, .grid-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.grid-pihole { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-sensors { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* ---------- Cards ---------- */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px 18px 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--sheen), transparent 45%), var(--surface);
  box-shadow: var(--shadow);
  transition: border-color .3s var(--ease), opacity .4s var(--ease), filter .4s var(--ease);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--c, #ffffff) 55%, transparent), transparent);
  opacity: .45;
}

.card:hover { border-color: var(--border-strong); }

[data-accent="cpu"] { --c: var(--c-cpu); }
[data-accent="temp"] { --c: var(--c-temp); }
[data-accent="mem"] { --c: var(--c-mem); }
[data-accent="disk"] { --c: var(--c-disk); }
[data-accent="net"] { --c: var(--c-rx); }
[data-accent="sys"] { --c: var(--accent); }
[data-accent="queries"] { --c: var(--c-permitted); }
[data-accent="blocked"] { --c: var(--c-blocked); }
[data-accent="rate"] { --c: var(--accent-2); }
[data-accent="clients"] { --c: var(--c-cached); }
[data-accent="dns"] { --c: var(--ok); }

.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 9px; min-width: 0; min-height: 26px; }

.card-head h3 {
  flex-shrink: 0;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.card-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 8px;
  color: var(--c, var(--accent));
  background: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent);
}

.card-icon .icon { width: 15px; height: 15px; }

.metric-value { display: flex; align-items: baseline; gap: 5px; min-width: 0; margin-top: 14px; }

.num {
  color: var(--text);
  font-size: 32px;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
  line-height: 1.05;
  white-space: nowrap;
}

.num.na { color: var(--text-3); font-size: 17px; font-weight: 550; letter-spacing: 0; }
.num.text { font-size: 22px; letter-spacing: -.015em; }
.unit { color: var(--text-2); font-size: 14px; font-weight: 500; white-space: nowrap; }

.metric-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  color: var(--text-2);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.metric-sub .mono { color: var(--text); }
.text-bad { color: var(--bad); font-weight: 600; }
.inline-icon { display: inline-flex; align-items: center; gap: 5px; }
.inline-icon .icon { width: 14px; height: 14px; color: var(--text-3); }

.bar {
  position: relative;
  height: 6px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--track);
}

.bar-lg { height: 8px; margin-top: 0; }

.bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--p, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 55%, transparent), var(--c));
  transition: width .9s var(--ease);
}

.cores {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 5px;
  height: 24px;
  margin-top: 12px;
}

.core { position: relative; overflow: hidden; border-radius: 4px; background: var(--track); }

.core > span {
  position: absolute;
  inset: auto 0 0;
  height: var(--p, 0%);
  border-radius: 3px;
  background: linear-gradient(180deg, var(--c), color-mix(in srgb, var(--c) 40%, transparent));
  transition: height .9s var(--ease);
}

.spark-wrap { margin: auto -18px -18px; padding-top: 14px; }
.spark { display: block; width: 100%; height: 54px; overflow: visible; color: var(--c, var(--accent)); }
.spark-line { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark-line.secondary { stroke: var(--c-tx); opacity: .9; }
.spark-area { stroke: none; }

.disk-foot, .kpi-foot { margin-top: auto; padding-top: 14px; }
.disk-foot .metric-sub { margin-top: 8px; }

/* Network & system info */

.net-rates { display: flex; flex-wrap: wrap; gap: 8px 32px; margin-top: 12px; }
.rate { display: flex; flex-direction: column; min-width: 0; }
.rate .metric-value { margin-top: 4px; }
.rate-label { display: inline-flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 12px; font-weight: 500; }

.lg { display: inline-block; width: 8px; height: 8px; flex: none; border-radius: 2.5px; }
.lg-rx { background: var(--c-rx); }
.lg-tx { background: var(--c-tx); }
.lg-permitted { background: var(--c-permitted); }
.lg-blocked { background: var(--c-blocked); }
.lg-cached { background: var(--c-cached); }
.lg-forwarded { background: var(--c-forwarded); }

.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; margin: 10px 0 0; }
.kv > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.kv > div:nth-last-child(-n + 2) { border-bottom: 0; }
.kv dt { color: var(--text-3); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.kv dd { margin: 0; overflow: hidden; color: var(--text); font-size: 13.5px; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- Pi-hole ---------- */

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-left: auto; color: var(--text-3); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.qchart { position: relative; height: 190px; margin-top: 16px; cursor: crosshair; touch-action: pan-y; }
.qchart svg { display: block; width: 100%; height: 100%; }
.qgrid { fill: none; stroke: var(--border); stroke-dasharray: 3 5; vector-effect: non-scaling-stroke; }
.qbase { fill: none; stroke: var(--border-strong); vector-effect: non-scaling-stroke; }
.qpermitted { fill: var(--c-permitted); opacity: .82; }
.qblocked { fill: var(--c-blocked); }

.qchart-cursor {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 4px;
  background: color-mix(in srgb, var(--text) 9%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}

.qchart.hover .qchart-cursor { opacity: 1; }
.qchart-scale { position: absolute; inset: 0; pointer-events: none; }

.qchart-scale span {
  position: absolute;
  right: 0;
  padding: 0 5px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--text-3);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.qchart-scale span:first-child { top: -2px; }
.qchart-scale span:last-child { top: 50%; transform: translateY(-50%); }
.qchart-x { display: flex; justify-content: space-between; margin-top: 8px; color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }

.chart-empty {
  display: grid;
  place-items: center;
  height: 190px;
  margin-top: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
}

.status-list { margin: 10px 0 0; padding: 0; list-style: none; }

.status-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
  color: var(--text-2);
  font-size: 13px;
}

.status-list li > span:last-child:not(.pill) { color: var(--text); }

.split { margin-top: auto; padding-top: 16px; }
.split-bar { display: flex; gap: 3px; height: 10px; overflow: hidden; border-radius: 999px; background: var(--track); }
.seg { width: var(--p, 0%); min-width: 0; transition: width .9s var(--ease); }
.seg-blocked { background: var(--c-blocked); }
.seg-cached { background: var(--c-cached); }
.seg-forwarded { background: var(--c-forwarded); }
.split-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; color: var(--text-3); font-size: 12px; }
.split-legend span { display: inline-flex; align-items: center; gap: 6px; }
.split-legend b { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Home Assistant ---------- */

.group + .group { margin-top: 22px; }

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 2px 10px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.group-title .count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11px;
}

.sensor { min-height: 168px; padding: 14px 16px 16px; }
.sensor[data-cat="air"] { --c: var(--c-air); }
.sensor[data-cat="energy"] { --c: var(--c-energy); }
.sensor[data-cat="climate"] { --c: var(--c-climate); }
.sensor[data-cat="other"] { --c: var(--c-other); }
.sensor[data-kind="temperature"], .sensor[data-kind="weather"] { --c: #fb923c; }
.sensor[data-kind="energy"] { --c: #f59e0b; }
.sensor[data-kind="voltage"], .sensor[data-kind="current"], .sensor[data-kind="power_factor"] { --c: #eab308; }
.sensor.is-unavailable { --c: var(--muted); }

.sensor-head { display: flex; align-items: center; gap: 8px; min-width: 0; }

.sensor-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 7px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
}

.sensor-icon .icon { width: 14px; height: 14px; }
.sensor-label { overflow: hidden; color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }

.quality {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tone) 14%, transparent);
  color: var(--tone);
  font-size: 11px;
  font-weight: 650;
}

.sensor .metric-value { margin-top: 12px; }
.sensor .num { font-size: 28px; }
.sensor-name {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.sensor-caption { color: var(--text-3); font-size: 12px; }
.sensor-foot { min-height: 17px; margin-top: 2px; color: var(--text-3); font-size: 11.5px; }
.sensor .spark-wrap { margin: auto -16px -16px; padding-top: 8px; }
.sensor .spark { height: 38px; }
.sensor.is-unavailable .sensor-name { color: var(--text-3); }

/* ---------- Notices & stale data ---------- */

.notice { --c: var(--tone); flex-direction: row; align-items: center; gap: 14px; padding: 18px; }

.notice-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 13%, transparent);
}

.notice-icon .icon { width: 20px; height: 20px; }
.notice-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; color: var(--text-2); font-size: 13px; }
.notice-body strong { color: var(--text); font-size: 14px; font-weight: 600; }
.notice-hint { color: var(--text-3); }
.notice-hint a { color: var(--accent); }

.stale-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn) 9%, transparent);
  font-size: 12.5px;
}

.stale-banner .icon { color: var(--warn); }
.is-stale .card { opacity: .6; filter: saturate(.55); }

/* ---------- Tooltip, footer, error ---------- */

.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  min-width: 170px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--tooltip-bg);
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, .6);
  color: var(--text);
  font-size: 12px;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.tooltip[hidden] { display: none; }
.tip-title { margin-bottom: 5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-row { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tip-row b { margin-left: auto; padding-left: 14px; color: var(--text); font-weight: 600; }

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 44px;
  padding-top: 18px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
}

.footer a { color: var(--text-2); text-decoration: none; }
.footer a:hover { color: var(--text); }
.error-page { padding-top: 12vh; max-width: 640px; }

/* ---------- Motion ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.js .card { animation: rise .55s var(--ease) both; }
.js .grid > .card:nth-child(2) { animation-delay: 40ms; }
.js .grid > .card:nth-child(3) { animation-delay: 80ms; }
.js .grid > .card:nth-child(4) { animation-delay: 120ms; }
.js .grid > .card:nth-child(n + 5) { animation-delay: 160ms; }

.flash { animation: flash 1.4s var(--ease); }

@keyframes flash {
  from {
    color: var(--c, var(--accent));
    text-shadow: 0 0 22px color-mix(in srgb, var(--c, var(--accent)) 55%, transparent);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .grid-metrics, .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-pihole { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .topnav { display: none; }
  .topbar-actions { margin-left: auto; }
  .overview { padding: 12px 14px; }
  .overview-meta { width: 100%; margin-left: 0; }
  .num { font-size: 27px; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv > div:nth-last-child(2) { border-bottom: 1px dashed var(--border); }
  .chart-card .card-head { flex-wrap: wrap; }
  .chart-card .legend { width: 100%; margin-left: 35px; }
  .qchart, .chart-empty { height: 150px; }
}

@media (max-width: 480px) {
  .live-label { display: none; }
  .brand-host { max-width: 46vw; }
  .grid, .grid-sensors { gap: 10px; }
  .grid + .grid { margin-top: 10px; }
  .card { padding: 14px 14px 16px; }
  .spark-wrap { margin: auto -14px -16px; }
  .num { font-size: 24px; }
  .metric-sub { font-size: 12px; }
  .grid-sensors { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sensor { min-height: 150px; padding: 12px 12px 14px; }
  .sensor .spark-wrap { margin: auto -12px -14px; }
  .sensor .num { font-size: 23px; }
  .section { margin-top: 28px; }
}

@media (max-width: 360px) {
  .grid-metrics, .grid-kpi, .grid-sensors { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .ring { display: none; }
}
