/* HiveHub dashboard — honey-themed, dependency-free.
   Shares the design language of website/assets/style.css (same tokens) but adds
   the app shell: top bar, fixed sidebar and a responsive card grid. */

:root {
  color-scheme: light;
  --honey: #f2a900;
  --honey-dark: #c98a00;
  --comb: #fff8e6;
  --ink: #1f2421;
  --ink-soft: #4b524d;
  --ink-faint: #8a9088;
  --line: #e7ddc4;
  --card: #ffffff;
  --bg: #fbf7ee;
  --good: #2e7d32;
  --warn: #b26a00;
  --danger: #b00020;
  --info: #2563a8;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 36, 33, .06), 0 8px 24px rgba(31, 36, 33, .06);
  --topbar-h: 60px;
  --sidebar-w: 220px;

  /* Surfaces that used to be hardcoded — tokenised so the dark theme can swap
     them (see the [data-theme="dark"] block below). */
  --topbar-bg: rgba(251, 247, 238, .9);
  --overlay-bg: var(--ink);   /* toasts, floating status pill */
  --overlay-fg: #ffffff;
  --on-accent: #1f2421;       /* text on the honey accent */

  /* Chart canvas colours — read at draw time by charts.js (getComputedStyle),
     so the dependency-free canvas charts follow the active theme. */
  --chart-axis: #8a9088;
  --chart-grid: rgba(31, 36, 33, .08);
  --chart-cursor: rgba(31, 36, 33, .35);
  --chart-cursor-strong: rgba(31, 36, 33, .5);
  --chart-latest: #111111;
  --chart-marker-ring: #ffffff;
}

/* ── Dark theme ──────────────────────────────────────────────────
   Applied when <html data-theme="dark"> is set. The attribute is chosen up
   front by a tiny inline script in index.html (saved preference, else the OS
   `prefers-color-scheme`), so the whole app — including the login screen —
   paints in the right theme with no flash. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --honey: #f5b421;
  --honey-dark: #ffca4d;   /* hover reads brighter, not darker, on a dark bg */
  --comb: #2c2717;         /* subtle warm hover/fill tint */
  --ink: #f3eee1;
  --ink-soft: #c2bcac;
  --ink-faint: #8c8676;
  --line: #38342a;
  --card: #211f18;
  --bg: #15140e;
  --good: #6cc077;
  --warn: #e6a93a;
  --danger: #f0687d;
  --info: #6ba7e6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
  --topbar-bg: rgba(21, 20, 14, .9);
  --overlay-bg: #2f2b20;
  --overlay-fg: var(--ink);
  --on-accent: #1f2421;
  --chart-axis: #8c8676;
  --chart-grid: rgba(243, 238, 225, .09);
  --chart-cursor: rgba(243, 238, 225, .38);
  --chart-cursor-strong: rgba(243, 238, 225, .55);
  --chart-latest: #f3eee1;
  --chart-marker-ring: #211f18;   /* == --card, so markers punch out on lines */
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0 1.1rem;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: .5rem; font-weight: 800; font-size: 1.15rem; }
.brand .logo { font-size: 1.35rem; }
.brand-sub { font-weight: 600; font-size: .85rem; color: var(--ink-faint); }

.topbar-controls { margin-left: auto; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: .15rem; }
.field-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); font-weight: 700; }
select {
  font: inherit; padding: .35rem .6rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  min-width: 130px; cursor: pointer;
}
/* A fixed, non-choosable value (e.g. the Board of a single-board firmware
   target) stays readable but clearly inert. */
select:disabled { opacity: .7; cursor: not-allowed; }

/* ── Cross-device hive picker ────────────────────────────────────
   One popover menu, grouped by device, replaces the old Device + Hive
   dropdowns. Selected hives from any device are compared together. */
.hive-picker { position: relative; }
.hive-trigger {
  font: inherit; display: inline-flex; align-items: center; gap: .45rem;
  padding: .35rem .6rem; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  min-width: 150px; font-weight: 600;
}
.hive-trigger:hover { background: var(--comb); }
.hive-trigger-label { white-space: nowrap; }
.hive-caret { color: var(--ink-faint); font-size: .7rem; margin-left: auto; }
.hive-count {
  font-family: var(--mono); font-size: .72rem; font-weight: 700;
  background: var(--honey); color: var(--on-accent);
  padding: .02rem .42rem; border-radius: 999px;
}
.hive-pop {
  position: absolute; top: calc(100% + .5rem); left: 0; z-index: 40;
  width: 340px; max-width: min(92vw, 340px);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 6px 14px rgba(31,36,33,.10), 0 20px 46px rgba(31,36,33,.18);
  padding: .55rem;
}
:root[data-theme="dark"] .hive-pop { box-shadow: 0 6px 14px rgba(0,0,0,.5), 0 22px 50px rgba(0,0,0,.6); }
.hive-search {
  width: 100%; font: inherit; font-size: .85rem; min-width: 0;
  padding: .45rem .6rem; border-radius: 8px; margin-bottom: .4rem;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.hive-pop-list { max-height: min(60vh, 340px); overflow-y: auto; }
.hive-dev-group { padding: .1rem 0 .25rem; }
.hive-dev-group + .hive-dev-group { border-top: 1px dashed var(--line); margin-top: .25rem; padding-top: .35rem; }
.hive-dev-head {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .3rem .35rem; border-radius: 7px; cursor: pointer;
  border: 0; background: transparent; color: var(--ink); text-align: left; font: inherit;
}
.hive-dev-head:hover { background: var(--comb); }
.hive-dev-head input { accent-color: var(--honey); width: 1rem; height: 1rem; cursor: pointer; }
.hive-dev-name { font-weight: 750; font-size: .82rem; }
.hive-dev-id { font-family: var(--mono); font-size: .66rem; color: var(--ink-faint); }
.hive-dev-meta { margin-left: auto; font-size: .7rem; color: var(--ink-faint); font-weight: 650; }
.hive-opt-row {
  display: flex; align-items: center; gap: .55rem;
  padding: .34rem .35rem .34rem 1.2rem; border-radius: 7px; cursor: pointer;
}
.hive-opt-row:hover { background: var(--comb); }
.hive-opt-row input { accent-color: var(--honey); width: 1rem; height: 1rem; cursor: pointer; }
.hive-opt-row .hive-swatch { width: .68rem; height: .68rem; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); flex: 0 0 auto; }
.hive-opt-name { font-size: .86rem; font-weight: 600; }
.hive-opt-val { margin-left: auto; font-family: var(--mono); font-size: .74rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.hive-opt-row.on { background: color-mix(in srgb, var(--honey) 12%, transparent); }
.hive-pop-empty { padding: .6rem .5rem; color: var(--ink-faint); font-size: .82rem; }
.hive-pop-foot {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .35rem .15rem; border-top: 1px solid var(--line); margin-top: .35rem;
}
.hive-pop-hint { font-size: .74rem; color: var(--ink-faint); margin-left: auto; margin-right: .5rem; }
.link-btn {
  border: 0; background: transparent; color: var(--info); font: inherit;
  font-size: .8rem; font-weight: 650; cursor: pointer; padding: .2rem .35rem; border-radius: 6px;
}
.link-btn:hover { background: var(--comb); }

/* ── Selection strip: the current comparison set, always visible ──
   Sits in normal flow directly under the top bar (not sticky), so it can't
   overlap the bar when its controls wrap onto a second row at narrow widths. */
.selection-strip {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .5rem 1.1rem; background: var(--comb);
  border-bottom: 1px solid var(--line);
}
.selection-strip .strip-label {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-faint); font-weight: 800; margin-right: .1rem;
}
.hive-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .22rem .3rem .22rem .5rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  font-size: .8rem; font-weight: 600; max-width: 100%;
}
.hive-chip .hive-swatch { width: .6rem; height: .6rem; border-radius: 3px; flex: 0 0 auto; }
.hive-chip .chip-dev { color: var(--ink-faint); font-weight: 600; }
.hive-chip .chip-x {
  border: 0; background: transparent; cursor: pointer; color: var(--ink-faint);
  font-size: .95rem; line-height: 1; padding: .05rem .2rem; border-radius: 6px;
}
.hive-chip .chip-x:hover { background: var(--comb); color: var(--danger); }
.selection-strip .strip-empty { color: var(--ink-faint); font-size: .82rem; font-style: italic; }

/* Context note shown on device-scoped views while comparing several devices. */
.device-context-note {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  margin: 0 0 1rem; padding: .5rem .7rem; border-radius: 10px;
  background: var(--comb); border: 1px solid var(--line);
  font-size: .84rem; color: var(--ink-soft);
}
.device-context-note b { color: var(--ink); }

.range-group { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.range-group button {
  font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
  border: 0; background: transparent; color: var(--ink-soft);
  padding: .35rem .7rem;
}
.range-group button:hover { background: var(--comb); }
.range-group button.active { background: var(--honey); color: var(--on-accent); }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1rem; border-radius: 999px; font-weight: 700; font-size: .9rem;
  cursor: pointer; border: 1px solid transparent; background: var(--honey); color: var(--on-accent);
  transition: background .15s ease, box-shadow .15s ease, transform .05s ease;
}
.btn:hover { background: var(--honey-dark); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--card); }
.btn.small { padding: .4rem .8rem; font-size: .82rem; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #8c0019; }

/* Icon-only theme switcher in the top bar (🌙 / ☀️, filled by theme.js). */
.theme-toggle { padding: .4rem; width: 2.1rem; justify-content: center; font-size: 1rem; line-height: 1; }

/* ── Layout ──────────────────────────────────────────────────── */
.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  position: sticky; top: var(--topbar-h); align-self: flex-start;
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  border-right: 1px solid var(--line); background: var(--card);
  padding: .75rem .5rem;
}
.nav-item {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .6rem .7rem; border-radius: 10px; border: 0; background: transparent;
  font: inherit; font-weight: 600; color: var(--ink-soft); cursor: pointer; text-align: left;
}
.nav-item:hover { background: var(--comb); color: var(--ink); }
.nav-item.active { background: var(--honey); color: var(--on-accent); }
.nav-item .nav-ico { font-size: 1.05rem; width: 1.3rem; text-align: center; }

.content { flex: 1 1 auto; padding: 1.25rem; min-width: 0; }

/* ── View header ─────────────────────────────────────────────── */
.view-head { margin: 0 0 1rem; }
.view-head h1 { margin: 0; font-size: 1.5rem; }
.view-head p { margin: .25rem 0 0; color: var(--ink-soft); }
.view-head p .doc-link { color: var(--honey-dark); font-weight: 600; text-decoration: none; }
.view-head p .doc-link:hover { text-decoration: underline; }

/* ── Cards & grid ────────────────────────────────────────────── */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }

/* Device & admin page: three independent columns, each a vertical stack of
   cards, so related panels group by column (config/calibration/account ·
   names/tempcomp/users · firmware/data/devices). Collapses to one column on
   narrow screens (see the 800px media query). */
.admin-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.admin-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

/* Full-width collapsible admin sections (Configuration, Admin) that fold away
   below the five always-visible panels. Built on native <details>/<summary>. */
.collapsible-panel { margin-top: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.collapsible-panel > summary { cursor: pointer; list-style: none; padding: .85rem 1.1rem; font-size: 1rem; font-weight: 800; display: flex; align-items: center; gap: .55rem; }
.collapsible-panel > summary::-webkit-details-marker { display: none; }
.collapsible-panel > summary::before { content: "\25B8"; color: var(--ink-soft); transition: transform .15s ease; }
.collapsible-panel[open] > summary::before { transform: rotate(90deg); }
.collapsible-body { padding: 0 1.1rem 1.1rem; }
/* Cards nested inside a collapsible's admin grid keep their own frame. */
.collapsible-body .admin-cols { align-items: start; }

/* Configuration form laid across the full-width Configuration panel: two blocks
   (General · Scale calibration & compensation) that wrap to one column when narrow. */
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .4rem 1.75rem; align-items: start; }
.config-block h3 { margin: .1rem 0 .55rem; font-size: .9rem; }
/* The per-scale field group is a transparent wrapper so its rows flow inside the
   block; toggling [hidden] on it swaps which scale is shown. */
.scale-fields { display: contents; }
.fit-row { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; }
.fit-row .form-row { margin-bottom: 0; flex: 1 1 8rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem 1.1rem;
}
.card h2 { margin: 0 0 .15rem; font-size: 1rem; }
.card .card-sub { margin: 0 0 .75rem; font-size: .82rem; color: var(--ink-faint); }

.metric { display: flex; flex-direction: column; gap: .15rem; }
.metric .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); font-weight: 700; }
.metric .value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.metric .unit { font-size: 1rem; font-weight: 600; color: var(--ink-soft); }
.metric .sub { font-size: .8rem; color: var(--ink-soft); }

/* Per-hive breakdown inside a metric panel: one compact, name-tagged row per
   hive so several selected hives stay visible (and identifiable) at once. */
.metric .hive-rows { display: flex; flex-direction: column; gap: .15rem; margin: .1rem 0 .1rem; }
.metric .hive-row { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.metric .hive-row-name { font-size: .82rem; font-weight: 600; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric .hive-row-val { font-size: 1.2rem; font-weight: 800; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric .hive-row-unit { font-size: .78rem; font-weight: 600; color: var(--ink-soft); }
.metric .hive-row-delta { font-size: .78rem; font-weight: 600; color: var(--ink-faint); margin-left: .35rem; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.good { background: #e7f3e8; color: var(--good); }
.badge.warn { background: #fbeed8; color: var(--warn); }
.badge.danger { background: #fbe3e6; color: var(--danger); }
.badge.info { background: #e4eefb; color: var(--info); }
.badge.muted { background: #eee9dd; color: var(--ink-soft); }
/* Dark theme: the light pastel badge fills don't work on dark cards — swap them
   for translucent tints of the same semantic hue. */
:root[data-theme="dark"] .badge.good   { background: rgba(108, 192, 119, .16); }
:root[data-theme="dark"] .badge.warn   { background: rgba(230, 169, 58, .16); }
:root[data-theme="dark"] .badge.danger { background: rgba(240, 104, 125, .16); }
:root[data-theme="dark"] .badge.info   { background: rgba(107, 167, 230, .16); }
:root[data-theme="dark"] .badge.muted  { background: rgba(243, 238, 225, .08); }
.dot { width: .55rem; height: .55rem; border-radius: 50%; display: inline-block; }
.dot.good { background: var(--good); } .dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); } .dot.muted { background: var(--ink-faint); }

/* ── Charts ──────────────────────────────────────────────────── */
.chart-card { grid-column: 1 / -1; }
.chart-wrap { position: relative; width: 100%; height: 300px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .9rem; margin: .5rem 0 .25rem; font-size: .82rem; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: .35rem; color: var(--ink-soft); }
.chart-legend .lg-value { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.chart-legend .swatch { width: .8rem; height: .8rem; border-radius: 3px; display: inline-block; }
.chart-legend .spectrum-gradient { width: 3.5rem; height: .5rem; border-radius: 4px; display: inline-block; }
.chart-hint { margin-left: auto; font-size: .78rem; color: var(--ink-faint); }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-faint); font-size: .95rem; }

/* Clickable legend entries (series / Older / Latest visibility toggles) */
.chart-legend .lg.clickable { cursor: pointer; user-select: none; }
.chart-legend .lg.clickable:hover { color: var(--ink); }
.chart-legend .lg.off { opacity: .45; text-decoration: line-through; }

/* Per-chart toolbox on the legend row: CSV export, reset-y-axis, drag hint */
.chart-tools { margin-left: auto; display: inline-flex; align-items: center; gap: .55rem; }
.chart-tools .chart-hint { margin-left: 0; }
.chart-tool-btn {
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  font: 600 .72rem var(--sans); line-height: 1; padding: .24rem .5rem;
  border-radius: 7px; cursor: pointer;
}
.chart-tool-btn:hover { background: var(--comb); color: var(--ink); border-color: var(--honey); }

/* Inline y-axis min/max editor (opened by clicking an axis end label) */
.y-edit-input {
  position: absolute; left: 0; z-index: 5; box-sizing: border-box;
  font: 600 .74rem var(--mono); padding: .14rem .3rem;
  border: 1px solid var(--honey); border-radius: 6px;
  background: var(--card); color: var(--ink);
}

/* ── Tables / definition rows ────────────────────────────────── */
.rows { display: flex; flex-direction: column; }
.rows .row { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.rows .row:last-child { border-bottom: 0; }
.rows .row .k { color: var(--ink-soft); }
.rows .row .v { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Insights list ───────────────────────────────────────────── */
.insight { display: flex; gap: .75rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.insight:last-child { border-bottom: 0; }
.insight .sev { flex: 0 0 auto; }
.insight .body h3 { margin: 0 0 .2rem; font-size: .95rem; }
.insight .body p { margin: 0; color: var(--ink-soft); font-size: .85rem; }

/* ── Forms (admin) ───────────────────────────────────────────── */
.form-row { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.form-row label { font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
.form-row input, .form-row select.full { font: inherit; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); width: 100%; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; align-items: center; }
.note { font-size: .82rem; color: var(--ink-soft); }
.note.warn { color: var(--warn); }

/* ── Info tooltips: a "?"/"!" affordance that reveals help text on hover or
   keyboard focus. Used next to the Board label, the Upload firmware button and
   the HiveInside nodes heading. */
.info-tip { position: relative; display: inline-flex; align-items: center; align-self: center; vertical-align: middle; cursor: help; }
.info-tip-icon {
  display: inline-grid; place-items: center; width: 1.05rem; height: 1.05rem;
  border-radius: 999px; border: 1px solid var(--info); color: var(--info);
  font-size: .72rem; font-weight: 800; line-height: 1;
}
.info-tip-bubble {
  position: absolute; bottom: calc(100% + .55rem); left: 50%;
  /* Centred on the icon, then nudged back inside the viewport by --tip-shift
     (set in infoTip() just before the bubble is shown) when a tip sits close
     enough to a screen edge that half the bubble would hang off it. The bubble
     also never exceeds the viewport width, so a narrow phone cannot clip a tip
     that no amount of shifting would fit. */
  transform: translateX(calc(-50% + var(--tip-shift, 0px)));
  width: max-content; max-width: min(17rem, calc(100vw - 1.5rem)); padding: .5rem .65rem;
  background: var(--overlay-bg); color: var(--overlay-fg); border-radius: 8px;
  box-shadow: var(--shadow); font-size: .78rem; font-weight: 500; line-height: 1.35;
  text-align: left; white-space: normal; z-index: 40; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity .12s ease;
}
.info-tip-bubble::after {
  content: ""; position: absolute; top: 100%;
  /* Move the arrow back by whatever the bubble was shifted, so it keeps pointing
     at the icon; clamped to stay on the bubble when the shift is large. */
  left: clamp(.6rem, calc(50% - var(--tip-shift, 0px)), calc(100% - .6rem));
  transform: translateX(-50%);
  border: .35rem solid transparent; border-top-color: var(--overlay-bg);
}
.info-tip:hover .info-tip-bubble,
.info-tip:focus .info-tip-bubble,
.info-tip:focus-visible .info-tip-bubble { opacity: 1; visibility: visible; }

/* ── Firmware panel: 2×2 status grid above the folded-in upload form. ── */
.fw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .9rem; margin-top: .6rem; }
.fw-stat {
  display: flex; flex-direction: column; gap: .1rem; min-width: 0;
  padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.fw-stat-k { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); font-weight: 700; }
.fw-stat-v { font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fw-upload-head { margin: 1rem 0 .55rem; font-size: .9rem; border-top: 1px solid var(--line); padding-top: .85rem; }
/* A node's running version, followed by the inline "latest x.y.z" release flag,
   the relay status badge and the relay button. The version never breaks; the
   rest is one group (.fw-node-meta) so it wraps under the version as a block
   rather than squeezing it — a HiveTraffic row carries a wide "Relay to
   counter" button and used to crush the version down to "v0." on a phone. */
.fw-node-v { display: inline-flex; align-items: center; justify-content: flex-end; gap: .35rem .45rem; flex-wrap: wrap; min-width: 0; }
.fw-node-ver { flex: 0 0 auto; white-space: nowrap; }
.fw-node-meta { display: inline-flex; align-items: center; justify-content: flex-end; gap: .35rem .45rem; flex-wrap: wrap; min-width: 0; }
/* Phone: always give the flag/status/button group its own line, so the version
   keeps the full row width no matter how long the button label is. */
@media (max-width: 560px) { .fw-node-meta { flex-basis: 100%; } }

/* ── Misc ────────────────────────────────────────────────────── */
/* The hidden attribute must win over author display rules (.form-row,
   .user-area, … set display and would otherwise keep "hidden" nodes visible). */
[hidden] { display: none !important; }
.empty-state { display: grid; place-items: center; min-height: 40vh; color: var(--ink-faint); font-size: 1.05rem; }
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--overlay-bg); color: var(--overlay-fg); padding: .7rem 1.1rem; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 60; font-size: .9rem; max-width: 90vw;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--good); color: #fff; }
.device-status {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 25;
  background: var(--overlay-bg); color: var(--overlay-fg); font-size: .78rem;
  padding: .4rem .8rem; border-radius: 999px; opacity: .85;
}

.muted-text { color: var(--ink-faint); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

@media (max-width: 800px) {
  .sidebar { position: static; width: 100%; height: auto; flex-basis: auto; display: flex; flex-wrap: wrap; gap: .25rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-item { width: auto; }
  .layout { flex-direction: column; }
  .topbar { flex-wrap: wrap; height: auto; padding: .6rem 1rem; }
  .topbar-controls { margin-left: 0; width: 100%; }
  /* .grid.wide's 420px minimum would overflow narrow phones — stack instead */
  .grid.wide { grid-template-columns: 1fr; }
  /* The 3-column admin layout stacks into a single column on phones/tablets */
  .admin-cols { grid-template-columns: 1fr; }
}

/* Visible keyboard-focus ring (controls otherwise only signal state on hover) */
.btn:focus-visible, .nav-item:focus-visible, .range-group button:focus-visible,
select:focus-visible, input:focus-visible, canvas:focus-visible {
  outline: 2px solid var(--honey-dark, var(--honey));
  outline-offset: 2px;
}

/* ── Auth (login / first-run setup) ─────────────────────────── */
.user-area { display: inline-flex; align-items: center; gap: .5rem; }
.user-chip {
  font-size: .8rem; color: var(--ink-faint); white-space: nowrap;
  padding: .3rem .6rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
}
.auth-wrap { display: grid; place-items: center; min-height: 70vh; padding: 1.5rem; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.6rem 1.5rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .35rem;
}
.auth-card h1 { margin: 0 0 .1rem; font-size: 1.3rem; }
.auth-sub { margin: 0 0 .8rem; color: var(--ink-faint); font-size: .9rem; }
.auth-field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .6rem; font-size: .85rem; color: var(--ink-faint); }
.auth-field input {
  font: inherit; color: var(--ink); padding: .55rem .65rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); width: 100%;
}
.auth-error { color: var(--danger); font-size: .85rem; min-height: 1.1em; margin: .1rem 0 .4rem; }

/* ── Publish data (public embeds) ───────────────────────────── */
/* Two columns: the publish form on the left at a fixed, form-sized width, and
   the live publications on the right — those carry the paste-ready embed code
   and URLs, so they get all the remaining room. */
.publish-cols { display: grid; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .publish-cols { grid-template-columns: 1fr; } }
.publish-list .card h2 { font-size: .98rem; }
.publish-series-row .k { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; }
.publish-series-row input[type="checkbox"] { accent-color: var(--honey); width: 1rem; height: 1rem; cursor: pointer; }
.publish-series-row .series-source { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The published (public) name for a series — editable, so a chart on a website
   need not carry the hive's internal name. */
.publish-series-row .series-label {
  font: inherit; font-size: .85rem; padding: .3rem .5rem; min-width: 9rem; max-width: 12rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink);
}

/* Copy-me rows: the embed snippet and the public URLs. */
.copy-row { display: flex; align-items: center; gap: .5rem; margin: .4rem 0; flex-wrap: wrap; }
.copy-row .copy-label { font-size: .74rem; font-weight: 700; color: var(--ink-faint); flex: 0 0 5.5rem; }
.copy-row .copy-field {
  flex: 1 1 12rem; min-width: 0; font: 500 .74rem var(--mono); color: var(--ink-soft);
  padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
