/* Watchtower — mission-control UI. Mobile-first; no inline styles required (strict CSP). */
:root {
  --bg: #050810;
  --panel: #0c1220;
  --panel-2: #111a2b;
  --border: #1f2c4b;
  --border-soft: #17213a;
  --cyan: #22d3ee;
  --mint: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --magenta: #e879f9;
  --text: #e4ebf7;
  --text-dim: #9aa7c4;     /* 7.5:1 on --panel */
  --text-faint: #8190b0;   /* 5.6:1 on --panel */
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, 'Cascadia Mono', Menlo, Consolas, 'Roboto Mono', monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --gutter: 12px;
  --tabbar-h: 58px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

h1, h2 { font-weight: inherit; font-size: inherit; }
button { font: inherit; touch-action: manipulation; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.noscript { padding: 24px; text-align: center; color: var(--amber); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3b60; border-radius: 3px; }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }

.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
}

.dim { color: var(--text-dim); }
.ok { color: var(--mint); }
.warn { color: var(--amber); }
.crit { color: var(--red); }
.acc { color: var(--cyan); }

/* severity (set from JS via data-sev, no inline styles) */
[data-sev="warn"].sev-txt { color: var(--amber); }
[data-sev="crit"].sev-txt { color: var(--red); }
.meter > i[data-sev="warn"] { background: var(--amber); }
.meter > i[data-sev="crit"] { background: var(--red); }
.g-arc[data-sev="warn"] { stroke: var(--amber); }
.g-arc[data-sev="crit"] { stroke: var(--red); }
.g-num[data-sev="warn"] { fill: var(--amber); }
.g-num[data-sev="crit"] { fill: var(--red); }

/* header */
header.top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + var(--sat)) calc(var(--gutter) + var(--sar)) 8px calc(var(--gutter) + var(--sal));
  background: #0c1220;
  border-bottom: 1px solid var(--border);
}
.wordmark {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; letter-spacing: 0.2em; font-size: 13px;
  text-transform: uppercase; color: var(--cyan); flex-shrink: 0;
}
.wordmark svg { display: block; }
.host-id { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; flex: 1 1 auto; }
.host-id .name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.host-id .os { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.live-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--mint); border: 1px solid rgba(52, 211, 153, 0.4);
  padding: 4px 9px; border-radius: 4px; white-space: nowrap;
}
.live-badge.stale { color: var(--red); border-color: rgba(248, 113, 113, 0.5); }
.led { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); animation: pulse 1.5s ease-in-out infinite; }
.live-badge.stale .led { background: var(--red); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.clock { font-size: 12px; color: var(--text-dim); letter-spacing: 0.06em; }

.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 12px;
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-dim); font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { color: var(--text); border-color: #34496f; background: var(--panel-2); }
.icon-btn:active { background: var(--panel-2); }
.icon-btn:disabled { opacity: 0.5; cursor: wait; }

.badge-count {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--red); color: #050810; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* alert ticker */
.ticker { overflow: hidden; border-bottom: 1px solid var(--border); background: #1a1217; display: none; }
.ticker.on { display: block; }
.ticker-track {
  display: inline-flex; gap: 48px; white-space: nowrap; padding: 8px 0;
  animation: tick 42s linear infinite; font-size: 12px; letter-spacing: 0.05em; color: var(--amber);
}
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes tick { from { transform: translateX(100vw); } to { transform: translateX(-100%); } }

/* tabs: top strip on desktop, bottom bar on phones */
nav.tabs {
  display: flex; gap: 2px;
  padding: 0 calc(20px + var(--sar)) 0 calc(20px + var(--sal));
  border-bottom: 1px solid var(--border);
  background: #0a1019;
  overflow-x: auto;
}
.tab-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); font-family: var(--mono); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.16em;
  min-height: 48px; padding: 0 16px; cursor: pointer; white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab-btn svg { display: none; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--cyan); border-bottom-color: var(--cyan); }

/* layout */
main {
  padding: 16px calc(20px + var(--sar)) 16px calc(20px + var(--sal));
  max-width: 1720px; margin: 0 auto;
}
.view { display: none; }
.view.active { display: block; }

.grid { display: grid; gap: 12px; }
.gauges-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); margin-bottom: 12px; }
.charts-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); margin-bottom: 12px; }
.panels-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 14px 16px;
  min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-head .label { color: var(--text-dim); }
.panel-head .value-hint { font-size: 12px; color: var(--text-dim); overflow-wrap: anywhere; }

/* gauges */
.gauge { text-align: center; padding: 10px 6px 10px; }
.gauge svg { width: 100%; max-width: 170px; height: auto; display: block; margin: 0 auto; }
.gauge .g-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; overflow-wrap: anywhere; }
.g-track { fill: none; stroke: #1a2540; stroke-width: 9; stroke-linecap: round; }
.g-tick { stroke: #34496f; stroke-width: 2; }
.g-arc { fill: none; stroke: var(--cyan); stroke-width: 9; stroke-linecap: round; transition: stroke 0.3s ease; }
.g-needle {
  stroke: var(--text); stroke-width: 2.5; stroke-linecap: round;
  transform-origin: 80px 76px;
  transition: transform 0.6s cubic-bezier(.22, 1, .36, 1);
}
.g-hub { fill: #0c1220; stroke: #34496f; stroke-width: 2; }
.g-num { fill: var(--cyan); font-size: 20px; font-weight: 700; font-family: inherit; text-anchor: middle; }
.g-un { fill: var(--text-dim); font-size: 10px; font-family: inherit; letter-spacing: 2px; text-anchor: middle; }

/* charts */
.chart-wrap { position: relative; }
.chart-wrap canvas { width: 100%; height: 150px; display: block; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-dim); margin-top: 6px; flex-wrap: wrap; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.sw-cyan { background: var(--cyan); }
.sw-mint { background: var(--mint); }
.sw-amber { background: var(--amber); }
.sw-magenta { background: var(--magenta); }

/* tables */
.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-dim); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td {
  padding: 8px; border-bottom: 1px solid var(--border-soft); color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px;
}
table.data tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; }
table.data td.span-all { white-space: normal; color: var(--text-dim); }
td .gap { margin-left: 6px; }

.meter { position: relative; height: 6px; background: var(--border-soft); border-radius: 3px; overflow: hidden; min-width: 70px; }
.meter > i {
  position: absolute; inset: 0; border-radius: 3px; background: var(--cyan);
  transform-origin: left center; transform: scaleX(0);
  transition: transform 0.6s ease, background 0.3s ease;
}

.core-row { display: grid; grid-template-columns: 48px 1fr 54px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.core-row .pct { text-align: right; color: var(--text-dim); }

/* pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.1em; padding: 3px 9px; border-radius: 4px; border: 1px solid;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.running, .pill.ok { color: var(--mint); border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.pill.running .dot { animation: pulse 1.5s ease-in-out infinite; }
.pill.exited, .pill.dead, .pill.crit { color: var(--red); border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.08); }
.pill.paused, .pill.restarting, .pill.warn { color: var(--amber); border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.08); }
.pill.neutral { color: var(--text-dim); border-color: var(--border); background: transparent; }

/* docker cards */
.docker-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 12px; }
.container-card { padding: 12px 14px; }
.container-card .c-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.container-card .c-id { min-width: 0; flex: 1 1 160px; }
.container-card .c-name { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.container-card .c-image { font-size: 12px; color: var(--text-dim); overflow-wrap: anywhere; }
.container-card .c-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 16px; margin-top: 8px; }
.container-card .c-stat { min-width: 0; }
.container-card .c-stat .v { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.container-card .c-stat .meter { margin-top: 4px; }
.c-actions { display: flex; gap: 8px; width: 100%; }
.c-actions button { flex: 1 1 0; min-height: 44px; }

/* coolify */
.badge {
  display: inline-flex; align-items: center; font-size: 11px; letter-spacing: 0.04em; padding: 1px 7px;
  border-radius: 10px; border: 1px solid var(--border-soft); color: var(--text-dim); white-space: nowrap; max-width: 100%;
}
.badge.ok { color: var(--mint); border-color: rgba(52, 211, 153, 0.3); }
.badge.crit { color: var(--red); border-color: rgba(248, 113, 113, 0.35); }
.badge.warn { color: var(--amber); border-color: rgba(251, 191, 36, 0.35); }
.badge.neutral { color: var(--text-dim); border-color: var(--border); background: transparent; }
.cf-section { margin-bottom: 14px; min-width: 0; }
.cf-section > .label { margin-bottom: 8px; }
.cf-legend { font-size: 12px; color: var(--text-faint); margin: -2px 0 14px; overflow-wrap: anywhere; }
.cf-groups { display: flex; flex-direction: column; gap: 10px; }
.cf-group { border: 1px solid var(--border-soft); border-radius: 8px; background: var(--panel); min-width: 0; }
.cf-group > summary {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; min-height: 44px; padding: 10px 14px;
  cursor: pointer; list-style: none; font-weight: 700; overflow-wrap: anywhere;
}
.cf-group > summary::-webkit-details-marker { display: none; }
.cf-group > summary::before { content: '▸'; color: var(--cyan); display: inline-block; width: 1em; transition: transform 0.15s; }
.cf-group[open] > summary::before { transform: rotate(90deg); }
.cf-gcount { font-size: 12px; font-weight: 400; color: var(--text-dim); }
.cf-gcount.crit { color: var(--red); }
.cf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 10px; }
.cf-group > .cf-grid { padding: 0 10px 10px; }
.cf-card { padding: 12px 14px; min-width: 0; display: flex; flex-direction: column; gap: 6px; background: var(--panel-2); }
.cf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 10px; flex-wrap: wrap; }
.cf-id { min-width: 0; flex: 1 1 150px; }
.cf-name { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.cf-sub { font-size: 12px; color: var(--text-dim); overflow-wrap: anywhere; }
.cf-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cf-note { font-size: 12px; color: var(--text-faint); overflow-wrap: anywhere; }
.cf-note.crit { color: var(--red); }
.cf-line { font-size: 12px; color: var(--text-dim); overflow-wrap: anywhere; }
.cf-domains { display: flex; flex-direction: column; gap: 4px; }
.cf-dom { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.cf-link { color: var(--cyan); font-size: 13px; overflow-wrap: anywhere; min-width: 0; }
.cf-kids { list-style: none; border-top: 1px solid var(--border-soft); margin-top: 4px; padding-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.cf-kids li { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 12px; min-width: 0; }
.cf-kids .k-name { font-weight: 600; overflow-wrap: anywhere; }
.cf-kids .k-img { color: var(--text-faint); flex: 1 1 100px; min-width: 0; overflow-wrap: anywhere; }

/* events */
.event {
  border: 1px solid var(--border-soft); border-left: 3px solid var(--text-faint); border-radius: 6px;
  padding: 10px 14px; margin-bottom: 8px; background: var(--panel);
  display: flex; gap: 4px 14px; align-items: baseline; flex-wrap: wrap;
}
.event.critical { border-left-color: var(--red); }
.event.warning { border-left-color: var(--amber); }
.event .e-time { font-size: 12px; color: var(--text-dim); }
.event .e-title { font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.event .e-detail { font-size: 13px; color: var(--text-dim); flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
.event .e-sev { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; }
.event.critical .e-sev { color: var(--red); }
.event.warning .e-sev { color: var(--amber); }

/* empty / error */
.empty {
  border: 1px dashed var(--border); border-radius: 8px; padding: 28px 16px;
  text-align: center; color: var(--text-dim); font-size: 13px; line-height: 1.8; overflow-wrap: anywhere;
}
.empty .title { font-size: 14px; font-weight: 700; }
.empty .hint { font-size: 12px; color: var(--text-faint); }
.empty code { background: var(--panel-2); border: 1px solid var(--border); border-radius: 3px; padding: 1px 6px; font-size: 12px; color: var(--cyan); }

/* login */
.login-screen {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
}
.login-card {
  width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 28px 22px 22px; position: relative;
}
.boot-line { font-size: 12px; color: var(--mint); min-height: 54px; margin-bottom: 14px; white-space: pre-wrap; }
.boot-line .cursor { display: inline-block; width: 7px; height: 13px; background: var(--mint); vertical-align: -2px; animation: pulse 1s steps(2) infinite; }
.login-card h1 { font-size: 18px; font-weight: 700; letter-spacing: 0.28em; text-transform: uppercase; color: var(--cyan); margin-bottom: 4px; }
.login-card .sub { font-size: 12px; color: var(--text-faint); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 22px; }

.field { margin-bottom: 16px; }
.field > .label { display: block; margin-bottom: 6px; }
.field input[type='password'], .field input[type='text'] {
  width: 100%; min-height: 48px; background: #0a0f1c; border: 1px solid #2a3b60; border-radius: 6px;
  color: var(--text); font-family: var(--mono);
  font-size: 16px; /* >=16px prevents iOS focus zoom */
  padding: 10px 12px;
}
.field input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.35); }

.captcha-box { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; max-width: 100%; }
.captcha-box .captcha-img { display: block; border: 1px solid var(--border); border-radius: 6px; max-width: 100%; height: auto; background: #0c1220; }
.captcha-box input[type='text'] { width: 110px; }
.captcha-box button { flex-shrink: 0; }
.captcha-box .msg { font-size: 12px; }
#recaptcha-slot { max-width: 100%; overflow-x: auto; }

.btn-primary {
  width: 100%; min-height: 48px; margin-top: 8px;
  background: rgba(34, 211, 238, 0.12); color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.55); border-radius: 6px;
  font-family: var(--mono); font-size: 14px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase;
  cursor: pointer; transition: background 0.15s ease;
}
.btn-primary:hover, .btn-primary:active { background: rgba(34, 211, 238, 0.22); }
.btn-primary:disabled { opacity: 0.55; cursor: wait; }

.login-error {
  display: none; margin-top: 14px; font-size: 13px; color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.08);
  border-radius: 6px; padding: 8px 10px; overflow-wrap: anywhere;
}
.login-error.on { display: block; }
.login-foot { margin-top: 20px; font-size: 11px; color: var(--text-faint); letter-spacing: 0.08em; display: flex; justify-content: space-between; gap: 8px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--sab)); z-index: 60;
  max-width: min(92vw, 520px);
  background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--cyan);
  border-radius: 6px; padding: 12px 16px; font-size: 14px; overflow-wrap: anywhere;
  transform: translate(-50%, 200%); opacity: 0; visibility: hidden;
  transition: transform 0.25s ease, opacity 0.25s ease, visibility 0.25s;
}
.toast.on { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.toast.err { border-left-color: var(--red); }

/* kv + tiles */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; padding-top: 2px; }
.kv dd { color: var(--text); overflow-wrap: anywhere; min-width: 0; }

.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); gap: 10px; margin-bottom: 12px; }
.stat-tile { background: var(--panel); border: 1px solid var(--border-soft); border-radius: 8px; padding: 12px 14px; min-width: 0; }
.stat-tile .v { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.stat-tile .l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-dim); margin-top: 2px; }

footer.foot {
  padding: 18px 20px 26px; text-align: center; font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-faint);
}

/* desktop-only decoration */
@media (min-width: 701px) and (hover: hover) {
  body::after {
    content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 40;
    background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px);
  }
  .wordmark { text-shadow: 0 0 12px rgba(34, 211, 238, 0.35); }
}

/* phones */
@media (max-width: 700px) {
  :root { --gutter: 12px; }
  body { padding-bottom: calc(var(--tabbar-h) + var(--sab)); }
  main { padding: 12px calc(var(--gutter) + var(--sar)) 12px calc(var(--gutter) + var(--sal)); }
  .clock, .host-id .os, .btn-text { display: none; }
  .wordmark .wm-text { display: none; }
  .live-badge { padding: 4px 8px; }

  nav.tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    padding: 0 var(--sar) var(--sab) var(--sal);
    gap: 0; overflow: visible;
    border-top: 1px solid var(--border); border-bottom: none; background: #0c1220;
  }
  .tab-btn {
    flex: 1 1 0; flex-direction: column; justify-content: center; gap: 2px;
    min-height: var(--tabbar-h); padding: 6px 2px; font-size: 11px; letter-spacing: 0.06em;
    border-bottom: none; border-top: 2px solid transparent;
  }
  .tab-btn svg { display: block; }
  .tab-btn.active { border-top-color: var(--cyan); }
  .toast { bottom: calc(var(--tabbar-h) + var(--sab) + 12px); }

  .panel { padding: 12px; }
  .gauges-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .charts-grid, .panels-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  table.data td { max-width: 150px; }
  .ticker-track { animation-duration: 30s; }

  /* wide tables become stacked cards */
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; max-width: none; }
  table.stack thead { display: none; }
  table.stack tr { border: 1px solid var(--border-soft); border-radius: 6px; padding: 6px 10px; margin-bottom: 8px; background: var(--panel-2); }
  table.stack td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: none; text-align: right; white-space: normal; overflow-wrap: anywhere; }
  table.stack td::before { content: attr(data-label); color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; text-align: left; flex-shrink: 0; }
  table.stack td.span-all { display: block; text-align: left; }
  table.stack td.span-all::before { content: none; }
}

@media (max-width: 360px) {
  .gauges-grid { grid-template-columns: minmax(0, 1fr); }
  .core-row { grid-template-columns: 40px 1fr 48px; }
}

@media (max-width: 700px) and (orientation: landscape) {
  :root { --tabbar-h: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .ticker { overflow-x: auto; }
  .ticker-track { animation: none; transform: none; }
}
