/* =========================================================================
 * INFILITH BMS — portal shell (v5.70 Modern; single-view since v5.97).
 *
 * Every rule is scoped to html[data-view="modern"], which the pre-paint
 * script in index.html now sets unconditionally — the attribute stays as the
 * stylesheet hook even though there is no Classic view left to switch to.
 * The one unscoped rule (`#sidebar { display: none }`) is kept deliberately
 * as a graceful fallback: if the attribute were ever missing, the sidebar
 * stays out instead of overlapping a plain styles.css shell. styles.css is
 * untouched (it is byte-frozen and still carries the class kit this file
 * re-skins).
 *
 * Tokens come first: the whole component kit (cards, tables, buttons, badges)
 * re-skins from var() alone. The palette is FIXED DARK (v5.90 charcoal
 * re-skin — near-black ground, single orange hero accent, green / amber data
 * semantics, contrast-first): core.js applyTheme pins html[data-theme="dark"]
 * and the pre-paint script in index.html (CSP-frozen inline) pins it before
 * first paint, so the view always renders on the charcoal palette. The old
 * AUTO/DARK/LIGHT topbar button was classic-only chrome and is gone.
 *
 * Load order matters: link this AFTER styles.css in index.html — the token
 * overrides are equal-specificity with html[data-theme="dark"] and win by
 * source order.
 * ========================================================================= */

/* ---------- Tokens: modern dark palette (charcoal + orange accent) ------- */
html[data-view="modern"] {
  --bg: #0E1116;            /* near-black charcoal ground (v5.90) — cards
                               float a step lighter above it */
  --card: #171B21;          /* panels float on --bg */
  --card2: #1E232B;         /* nested surfaces, table headers, inputs */
  --border: #2A313C;        /* edges hold without shouting */
  --divider: #232932;
  --text: #E9EDF3;          /* ~15:1 on --bg, ~13:1 on --card */
  --muted: #9AA5B4;         /* ~7:1 on --bg — secondary copy */
  --dim: #7E8A9A;           /* ~5.5:1 on card / ~4.8:1 on ground — labels */
  /* Single hero accent (v5.90): orange replaces the cyan — it doubles as
      TEXT color (links, active nav, focus borders) and clears 6.1:1 on
      --card and ~6.4:1 on --bg; --neon-light is the hover step. */
  --neon: #F97316;
  --neon-light: #FB923C;
  --neon-glow: rgba(249, 115, 22, 0.14);
  --blue: #60A5FA;
  --cyan: #F97316;          /* text accent follows the hero (var(--neon)) */
  /* Accent TEXT tokens: data semantics on charcoal — all ≥4.5:1 on
     --card and on their own tint-chip fills. */
  --amber: #F59E0B;
  --red: #F87171;
  --purple: #A78BFA;
  /* KPI accents + SOC ring track (modern-only tokens). */
  --green: #22C55E;
  --indigo: #818CF8;
  --ring-track: #2A313C;
  color-scheme: dark;
}

/* styles.css pins .btn-neon's label to near-black (#0A0C04) for the dark
   palette — correct on the orange hero (~7:1), so modern needs no flip
   here (the v5.82 white flip is gone with the light palette). */

/* ---------- Shell: 232px sidebar + content column ------------------------ */
/* 232 = the mock's .shell column exactly (?v=5.76). At 248 the content sat
   16px narrower than the mock at the same viewport, squeezing every
   .md-batt track ~5px below the mock's own — the last ~6px of the card
   overflow the user reported. Classic never sees this (see below). */
/* Classic never shows the sidebar (only rule here without the view scope). */
#sidebar { display: none; }

html[data-view="modern"] #app {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: auto auto auto 1fr;
  grid-template-areas:
    "sb top"
    "sb banner"
    "sb greet"
    "sb view";
  min-height: 100vh;
}
html[data-view="modern"] #sidebar {
  grid-area: sb;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: start;
  /* v5.90: charcoal sidebar a step lighter than the #0E1116 ground —
     nav chips (card2) and the border still separate. */
  background: #12151B;
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
}
html[data-view="modern"] .topbar { grid-area: top; }
html[data-view="modern"] #banner { grid-area: banner; }
html[data-view="modern"] #greetingLine { grid-area: greet; }
html[data-view="modern"] #view { grid-area: view; }
/* v5.73 fidelity: the mockup has no greeting strip. The routine time-of-day
   line drops out of the modern view only; the wishes that carry real content
   (birthday/festival — renderGreeting tags them .greet-special) stay, so no
   feature is lost. Classic keeps the strip unconditionally. */
html[data-view="modern"] #greetingLine:not(.greet-special) { display: none; }

/* ---------- Sidebar: brand / nav / foot (mockup bms-redesign-mockup) ----- */
html[data-view="modern"] .sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 16px;
}
html[data-view="modern"] .sb-logo { width: 30px; height: 30px; flex: none; }
/* Brand logo hex paths in the sidebar ride hardcoded cyan — flip them to
   the orange hero (same attribute-selector trick as the classic .logo). */
html[data-view="modern"] .sb-logo path[stroke="#22D3EE"] { stroke: var(--cyan); }
html[data-view="modern"] .sb-logo path[fill="#22D3EE"] { fill: var(--cyan); }
html[data-view="modern"] .sb-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
html[data-view="modern"] .sb-brand-title {
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: var(--text);
}
html[data-view="modern"] .sb-brand-title em { font-style: normal; color: var(--cyan); }
html[data-view="modern"] .sb-brand-sub {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 2.2px;
  color: var(--dim);
}
html[data-view="modern"] .sb-nav { display: flex; flex-direction: column; gap: 2px; }
html[data-view="modern"] .sb-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: var(--dim);
  padding: 14px 10px 6px;
}
html[data-view="modern"] .sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  position: relative;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
html[data-view="modern"] .sb-link svg { width: 16px; height: 16px; flex: none; opacity: 0.8; }
html[data-view="modern"] .sb-link:hover { background: rgba(148, 163, 184, 0.12); color: var(--text); }
html[data-view="modern"] .sb-link.active {
  background: rgba(249, 115, 22, 0.10);
  color: var(--cyan);
  font-weight: 600;
}
html[data-view="modern"] .sb-link.active svg { opacity: 1; }
/* Cyan accent bar at the sidebar's inner edge (mockup .nav-item.active). */
html[data-view="modern"] .sb-link.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 2px;
  background: var(--cyan);
}
html[data-view="modern"] .sb-foot {
  margin-top: auto;
  border-top: 1px solid var(--divider);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
html[data-view="modern"] .sb-view-btn {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card2);
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
html[data-view="modern"] .sb-view-btn:hover { color: var(--text); border-color: var(--cyan); }

/* v5.73: the mockup's .user-chip at the sidebar's foot — avatar + name +
   role + sign-out. It carries the topbar's userchip duties on desktop (the
   topbar hides at >=769px), so it needs its own sign-out control; the real
   #uEmail/#uRole/.userchip stay put for <=768px, where the topbar shows. */
html[data-view="modern"] .sb-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  min-width: 0;
}
html[data-view="modern"] .sb-user:hover { background: var(--card2); }
html[data-view="modern"] .sb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--cyan));
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  flex: none;
}
html[data-view="modern"] .sb-umeta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
html[data-view="modern"] .sb-uname {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-view="modern"] .sb-urole {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--dim);
  text-transform: uppercase;
}
html[data-view="modern"] .sb-signout {
  margin-left: auto;
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: var(--dim);
  cursor: pointer;
}
html[data-view="modern"] .sb-signout:hover { color: var(--red); border-color: rgba(248, 113, 113, 0.4); }
html[data-view="modern"] .sb-signout svg { width: 15px; height: 15px; }

/* ---------- Slim topbar: nav + theme + switcher live elsewhere ----------- */
/* v5.73 fidelity pass: the mockup has NO top bar — nav lives in the sidebar
   and the user chip sits at the sidebar's foot. The topbar's only remaining
   occupant at >=769px is .userchip (brand is hidden below), so the whole bar
   drops out on desktop and its chip is mirrored by #sbUser in .sb-foot. At
   <=768px the sidebar steps aside and the bar comes back carrying
   #navSelect + the real .userchip.
   v5.97: #tabs, #viewBtn and #themeBtn are gone from index.html with the
   classic view and its switcher/theme button, so their hide rules went too. */
html[data-view="modern"] .topbar {
  display: none;
  background: var(--bg);
  border-bottom: 1px solid var(--divider);
  gap: 12px;
  padding: 8px 24px;
  align-items: center;
}
html[data-view="modern"] .topbar .brand { display: none; }   /* brand sits in the sidebar */
html[data-view="modern"] .userchip { margin-left: auto; }

/* ---------- Content column ----------------------------------------------- */
/* width:100% is required, not cosmetic: .view is a grid item, and classic
 * .view { margin: 0 auto } (styles.css) makes an auto margin, which turns off
 * the grid stretch — the panel shrinks to fit-content (max-content width) and
 * centres, squeezing every modern tab to ~its widest unwrapped strip. The
 * definite width beats fit-content; margin:0 auto still centres it under
 * max-width:1500px on wide tracks. */
html[data-view="modern"] .view {
  width: 100%;
  max-width: 1500px;
  padding: 22px 26px 44px;
}

/* ---------- <=768px: sidebar steps aside, the nav select takes over ------- */
@media (max-width: 768px) {
  html[data-view="modern"] #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "top"
      "banner"
      "greet"
      "view";
  }
  html[data-view="modern"] #sidebar { display: none; }
  /* The topbar returns — it is the only chrome left at this width (the nav
     select and the real user chip both live inside it). */
  html[data-view="modern"] .topbar { display: flex; padding: 8px 14px; }
  html[data-view="modern"] .view { padding: 14px 14px 36px; }
}

/* ---------- Modern Dashboard (Phase B; mockup bms-redesign-mockup) ------- */
html[data-view="modern"] .md-topline {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
html[data-view="modern"] .md-page-title { font-size: 21px; font-weight: 800; letter-spacing: 0.2px; }
html[data-view="modern"] .md-page-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
html[data-view="modern"] .md-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--green);
  background: rgba(34, 197, 94, 0.10);
  border: 1px solid rgba(34, 197, 94, 0.30);
  padding: 5px 11px;
  border-radius: 999px;
}
html[data-view="modern"] .md-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: mdPulse 2s infinite;
}
@keyframes mdPulse {
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Header search — the mockup's top-right "Search pack, serial, dealer…"
   box. Enter (or a live typing pause) carries the query to the Batteries
   tab's existing fleet search, so nothing is filtered twice. */
html[data-view="modern"] .md-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  width: 260px;
  color: var(--dim);
}
html[data-view="modern"] .md-search:focus-within { border-color: var(--cyan); }
html[data-view="modern"] .md-search svg { width: 14px; height: 14px; flex: none; stroke: var(--dim); }
html[data-view="modern"] .md-search input {
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  width: 100%;
  min-width: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}
html[data-view="modern"] .md-search input::-webkit-search-cancel-button { filter: invert(0.6); }
html[data-view="modern"] .md-search input::placeholder { color: var(--dim); }

/* KPI row — mockup cards; 150px floor keeps all six (staff freshness tile
   included) on ONE row at 1280 instead of a 5+1 wrap (v5.90 added the
   "Charging now" tile; the old 168px floor fit five, not six). */
html[data-view="modern"] .md-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
html[data-view="modern"] .md-kpi {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px 16px 13px;
  position: relative;
  overflow: hidden;
}
html[data-view="modern"] .md-kpi::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--accent, var(--cyan));
  opacity: 0.65;
}
html[data-view="modern"] .md-kpi-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.1px;
  color: var(--muted);
  text-transform: uppercase;
}
html[data-view="modern"] .md-kpi-value {
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}
html[data-view="modern"] .md-kpi-value small { font-size: 14px; font-weight: 600; color: var(--muted); }
html[data-view="modern"] .md-kpi-delta { font-size: 11.5px; font-weight: 600; margin-top: 3px; }
html[data-view="modern"] .md-kpi-delta.up { color: var(--green); }
html[data-view="modern"] .md-kpi-delta.down { color: var(--red); }
html[data-view="modern"] .md-kpi-delta.flat { color: var(--muted); }

/* Content grid: batteries column + 320px rail. */
html[data-view="modern"] .md-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}
html[data-view="modern"] .md-col { min-width: 0; }
html[data-view="modern"] .md-rail { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (max-width: 1024px) {
  html[data-view="modern"] .md-grid { grid-template-columns: minmax(0, 1fr); }
}

html[data-view="modern"] .md-section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 4px 0 12px;
}
html[data-view="modern"] .md-section-title { font-size: 14.5px; font-weight: 800; letter-spacing: 0.3px; }
html[data-view="modern"] .md-section-sub { font-size: 12px; color: var(--muted); }
html[data-view="modern"] .md-section-link {
  margin-left: auto;
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--cyan);
  cursor: pointer;
  white-space: nowrap;
}
html[data-view="modern"] .md-section-link:hover { text-decoration: underline; }
html[data-view="modern"] .md-count {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.30);
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
}
html[data-view="modern"] .md-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 14px;
}
html[data-view="modern"] .md-panel .md-section-head { margin-top: 0; }
html[data-view="modern"] .md-panel-foot { margin-top: 10px; }

/* v6.01 (user request): collapsible rail sections — collapsed renders the
   header row only (title + count badge + chevron, one line; body omitted
   until open — dashboard.js's railOpen Set replays across the 5 s repaint).
   The header's own links (View all / History) sit outside the toggle, so a
   collapsed section never hides its shortcut. */
html[data-view="modern"] .md-sec-toggle {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
html[data-view="modern"] .md-sec-toggle .md-chev {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
}
html[data-view="modern"] .md-sec-toggle:hover .md-section-title { text-decoration: underline; }
html[data-view="modern"] .md-panel.md-collapsed .md-section-head { margin-bottom: 0; }

/* v6.01: per-pack KPI detail grid — ONE renderer (packKpiHtml in fleet.js)
   feeds both placements: the Dashboard card's in-place expand (.md-batt-kpi)
   and the Batteries card's "Pack KPIs" ctrl-group. Numeric tiles: label +
   tabular value + honest sub-line; auto-fill keeps 2-up inside a narrow
   pack card and a wide row across the full-width Batteries expansion. */
html[data-view="modern"] .pack-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
html[data-view="modern"] .pack-kpi {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
html[data-view="modern"] .pack-kpi .k {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}
html[data-view="modern"] .pack-kpi b {
  font-size: 15.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
html[data-view="modern"] .pack-kpi i {
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  overflow-wrap: anywhere;
}
html[data-view="modern"] .md-batt-kpi {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
html[data-view="modern"] .md-batt-kpi-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* Battery cards (mockup .batt): SOC ring + stat rows + cell strip.
   Mock is repeat(3,1fr) — three across whenever the column allows, which is
   what 1280+ gets here; below that auto-fill at a 240px floor (the cards'
   real readable width). The old 200px floor produced 200–212px tracks where
   the stat rows spilled past the card border (?v=5.75 fix, see .md-stat). */
html[data-view="modern"] .md-batt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
@media (min-width: 1280px) {
  html[data-view="modern"] .md-batt-grid { grid-template-columns: repeat(3, 1fr); }
}
html[data-view="modern"] .md-batt {
  display: block;
  width: 100%;
  /* grid item: min-width 0 lets the card honour its track even when the
     min-content (cell strip) would otherwise force an overflow. */
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 15px;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
html[data-view="modern"] .md-batt:hover { border-color: #3D4756; transform: translateY(-2px); }
html[data-view="modern"] .md-batt:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
html[data-view="modern"] .md-batt-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
html[data-view="modern"] .md-batt-name {
  font-size: 13.5px;
  font-weight: 700;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-view="modern"] .md-batt-id {
  font-size: 11px;
  color: var(--dim);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  min-width: 0;
  max-width: 42%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* v5.81: owner line under the pack name (user request — know WHICH person's
 * pack a card belongs to without opening it). Muted, single-line ellipsis. */
html[data-view="modern"] .md-batt-owner {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: -6px 0 10px;
  font-size: 11.5px;
  color: var(--muted);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-view="modern"] .md-batt-owner svg {
  width: 12px;
  height: 12px;
  flex: none;
  stroke: var(--dim);
}
html[data-view="modern"] .md-pill {
  margin-left: auto;
  flex: none;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.7px;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  border: 1px solid transparent;
}
html[data-view="modern"] .md-pill-on { background: rgba(34, 197, 94, 0.12); color: var(--green); border-color: rgba(34, 197, 94, 0.30); }
html[data-view="modern"] .md-pill-stale { background: rgba(245, 158, 11, 0.12); color: var(--amber); border-color: rgba(245, 158, 11, 0.30); }
html[data-view="modern"] .md-pill-fault { background: rgba(248, 113, 113, 0.12); color: var(--red); border-color: rgba(248, 113, 113, 0.30); }
html[data-view="modern"] .md-pill-off { background: rgba(148, 163, 184, 0.10); color: var(--muted); border-color: rgba(148, 163, 184, 0.28); }
html[data-view="modern"] .md-batt-body { display: flex; align-items: center; gap: 14px; }
html[data-view="modern"] .md-soc {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  flex: none;
  background: conic-gradient(var(--c, var(--green)) calc(var(--v) * 1%), var(--ring-track) 0);
  display: grid;
  place-items: center;
  position: relative;
}
html[data-view="modern"] .md-soc::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--card);
}
html[data-view="modern"] .md-soc-inner { position: relative; text-align: center; line-height: 1.1; }
html[data-view="modern"] .md-soc-v { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
html[data-view="modern"] .md-soc-l { font-size: 9px; font-weight: 700; letter-spacing: 1px; color: var(--dim); }
html[data-view="modern"] .md-batt-stats { display: grid; gap: 5px; flex: 1; min-width: 0; }
/* Mock .stat: plain flex, labels AND values wrap — no nowrap anywhere.
   nowrap made every row's min-content 102px (grid items default to
   min-width:auto), so at 200–212px tracks the rows spilled ~6–22px past
   the card border. min-width:0 on the row + natural wrapping = fits.
   flex-wrap + zero column gap (?v=5.76) = the mock's own math: the mock's
   rows fit ONLY because floors sum exactly to its box ("Temperature" 66.6
   + "28.4" 25 ≈ 91.6 ≤ 91.67) — any tighter and even the mock overflows.
   With wrap, the value drops to its own line instead of crossing the
   border, at every track width — the mock has no breakpoints at all (it
   just overflows below its design width); ours never does. */
html[data-view="modern"] .md-stat {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 0;
  font-size: 12px;
  min-width: 0;
}
html[data-view="modern"] .md-stat b { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 0; }
html[data-view="modern"] .md-stat span { color: var(--muted); min-width: 0; }
html[data-view="modern"] .md-cells { display: flex; gap: 3px; margin-top: 12px; }
html[data-view="modern"] .md-cell {
  flex: 1;
  /* 2px (not 3px): 32×3 + 31×3 gaps = 189px min-content, wider than a
     200px track's 168px body — the second overflow source. 2px → 157px. */
  min-width: 2px;
  height: 5px;
  border-radius: 3px;
  background: var(--green);
  opacity: 0.85;
}
html[data-view="modern"] .md-cell.hi { background: var(--amber); }
html[data-view="modern"] .md-cell.lo { background: var(--red); }

/* ---------- Phase C: modern battery detail (mockup battery-detail) ------- */
/* Quick bar: slim always-visible summary under the card head (classic's
   .batt-summary slot). */
html[data-view="modern"] .mb-quick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--divider);
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
html[data-view="modern"] .mb-quick b,
html[data-view="modern"] .mb-quick .mb-quick-soc { font-weight: 700; }
html[data-view="modern"] .mb-quick-soc.neon { color: var(--green); }
html[data-view="modern"] .mb-quick-soc.amber { color: var(--amber); }
html[data-view="modern"] .mb-quick-soc.red { color: var(--red); }

/* Stat strip: 8 instrument cards (?v=6.11 — Speed + Distance ride at the
   end): SOC ring, Health Score ring (real % from the app's derived
   sohPercent since ?v=5.78, "not reported" when the pack never sends it),
   Current, Pack, Temp, Cycles, Speed, Distance. 4 columns keeps the 8 cards
   on two neat rows (6 columns squeezed the pair into a ragged third row);
   values/subs wrap like the mock's .stat-meta (the old nowrap + ellipsis
   truncated "3,214 / 5,000 Ah" the moment a 6th card landed). */
html[data-view="modern"] .mb-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
html[data-view="modern"] .mb-stat {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
html[data-view="modern"] .mb-ring {
  --v: 0;
  --c: var(--green);
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(closest-side, var(--card2) 78%, transparent 79% 100%),
    conic-gradient(var(--c) calc(var(--v) * 1%), var(--ring-track) 0);
}
html[data-view="modern"] .mb-ring b {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
html[data-view="modern"] .mb-stat-meta { min-width: 0; }
html[data-view="modern"] .mb-stat-meta .k {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--dim);
}
html[data-view="modern"] .mb-stat-meta .v {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
html[data-view="modern"] .mb-stat-meta .v small {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
html[data-view="modern"] .mb-stat-meta .s {
  font-size: 11.5px;
  color: var(--muted);
}
/* Mock .s.good/.warn (+ .bad for hard limits): charging/normal = green,
   watch = amber, over-limit = red. */
html[data-view="modern"] .mb-stat-meta .s.good { color: var(--green); }
html[data-view="modern"] .mb-stat-meta .s.warn { color: var(--amber); }
html[data-view="modern"] .mb-stat-meta .s.bad { color: var(--red); }

/* Mock .head-actions (?v=5.75): ⚡ Controls (primary) / Configure /
   Lockdown (danger) — rendered under the fault banner of an expanded card,
   styled like the mock's .btn family. */
html[data-view="modern"] .mb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 12px 16px 0;
}
html[data-view="modern"] .mb-act {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  cursor: pointer;
}
html[data-view="modern"] .mb-act:hover { border-color: #3D4756; }
html[data-view="modern"] .mb-act:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
html[data-view="modern"] .mb-act-primary {
  background: rgba(249, 115, 22, 0.12);
  border-color: rgba(249, 115, 22, 0.4);
  color: var(--cyan);
}
html[data-view="modern"] .mb-act-danger {
  background: rgba(248, 113, 113, 0.10);
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--red);
}
/* Mock's cyan TELEMETRY pill in the card head (online packs only — there is
   no telemetry cadence to report for an offline pack). */
html[data-view="modern"] .pill-telem {
  background: rgba(249, 115, 22, 0.10);
  color: var(--cyan);
  border-color: rgba(249, 115, 22, 0.30);
  border-radius: 999px;
  /* mock .pill uppercases → renders "TELEMETRY 5S" (?v=5.77). */
  text-transform: uppercase;
}

/* Status row under the strip: classic status chips + reset + age. */
html[data-view="modern"] .mb-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
html[data-view="modern"] .mb-status-age {
  margin-left: auto;
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

/* v5.91 (user request): the Online/Offline tabs' "since" clock stamp under
 * the owner/dealer lines — the .batt-dealer base (styles.css, frozen)
 * already sizes and dims the line; this only brightens the clock itself so
 * the time reads at a glance. Classic view keeps the plain base styling. */
html[data-view="modern"] .batt-since b { color: var(--text); font-weight: 600; }

/* Two-column expansion: functional blocks left, info rail right. */
/* Expanded card spans the whole .grid row: mb-cols' 1fr+300px needs room the
 * card grid cell doesn't give (483px → main squeezed to 130px, the mb-seg
 * toggle slid under the rail — user-reported "overlap"). The mockup
 * (bms-mockup-battery-detail) shows the detail full-width; full span also
 * makes the viewport-based collapse rules below track the card's width.
 * dense backfills the cell a mid-row expansion vacates (no hole; no-op
 * without a span, so the resting grid is untouched). */
html[data-view="modern"] .batt-card.expanded { grid-column: 1 / -1; }
html[data-view="modern"] .grid:has(.batt-card.expanded) { grid-auto-flow: row dense; }
html[data-view="modern"] .mb-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}
html[data-view="modern"] .mb-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
html[data-view="modern"] .mb-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 12px;
}

/* Generic panel kit for the modern detail's own blocks. */
html[data-view="modern"] .mb-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
html[data-view="modern"] .mb-card-head {
  display: flex;
  align-items: center;
  /* wrap instead of overflowing into the rail at mid widths (981–1240px the
   * two-column mb-cols is still on while main is only ~350px wide). */
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
html[data-view="modern"] .mb-card-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text);
}
html[data-view="modern"] .mb-card-note {
  font-size: 11.5px;
  color: var(--dim);
}

/* Voltage ↔ IR segmented toggle. */
html[data-view="modern"] .mb-seg {
  margin-left: auto;
  display: inline-flex;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
}
html[data-view="modern"] .mb-seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
}
html[data-view="modern"] .mb-seg button:hover { color: var(--text); }
html[data-view="modern"] .mb-seg button.on {
  background: var(--neon-glow);
  color: var(--cyan);
}

/* Cell tiles: voltage heatmap (min lo / max hi) + IR thresholds. */
html[data-view="modern"] .mb-cells {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 7px;
}
html[data-view="modern"] .mb-cellt {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 6px 7px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
html[data-view="modern"] .mb-cellt .n {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--dim);
}
html[data-view="modern"] .mb-cellt .mv {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
}
html[data-view="modern"] .mb-cellt .d {
  font-size: 10.5px;
  color: var(--muted);
}
html[data-view="modern"] .mb-cellt.ok .mv { color: var(--green); }
html[data-view="modern"] .mb-cellt.hi {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.08);
}
html[data-view="modern"] .mb-cellt.hi .mv { color: var(--amber); }
html[data-view="modern"] .mb-cellt.lo {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(248, 113, 113, 0.09);
}
html[data-view="modern"] .mb-cellt.lo .mv { color: var(--red); }
html[data-view="modern"] .mb-cellt.na { opacity: 0.55; }
html[data-view="modern"] .mb-cellt.na .mv { color: var(--dim); }

html[data-view="modern"] .mb-cfoot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
html[data-view="modern"] .mb-cfoot b { color: var(--text); font-weight: 700; }
html[data-view="modern"] .mb-ir-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--divider);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--dim);
}

/* Info rows (Pack Info / Attention rail cards). */
html[data-view="modern"] .mb-info { display: flex; flex-direction: column; }
html[data-view="modern"] .mb-irow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  font-size: 12.5px;
  border-bottom: 1px solid var(--divider);
}
html[data-view="modern"] .mb-irow:last-child { border-bottom: 0; padding-bottom: 2px; }
html[data-view="modern"] .mb-irow > span { color: var(--muted); flex: 0 0 auto; }
html[data-view="modern"] .mb-irow > b {
  color: var(--text);
  font-weight: 700;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}
html[data-view="modern"] .mb-bad { color: var(--red); }
/* v5.96: muted age suffix on an info-row value ("In use by X · 2h ago").
   Sits inside .mb-irow > b, so it must opt out of that rule's bold/primary
   colour rather than inherit it. */
html[data-view="modern"] .mb-irow > b .mb-sub {
  color: var(--muted);
  font-weight: 500;
}
/* v5.81: Warranty card's no-record line (matches .mb-ir-note tone). */
html[data-view="modern"] .mb-inote {
  padding: 8px 0 2px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--dim);
}

/* Responsive: strip wraps, rail drops under the main column. */
@media (max-width: 1240px) {
  html[data-view="modern"] .mb-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  html[data-view="modern"] .mb-cols { grid-template-columns: minmax(0, 1fr); }
  html[data-view="modern"] .mb-rail { position: static; }
}
@media (max-width: 720px) {
  html[data-view="modern"] .mb-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Phase D: modern map (mockup bms-mockup-map.html) -------------- */
/* Head: title block + fix pill + search + status chips. */
html[data-view="modern"] .mm-head {
  align-items: center;
  gap: 10px 16px;
  margin: 4px 0 14px;
}
html[data-view="modern"] .mm-head-t {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  margin-right: auto;
}
html[data-view="modern"] .mm-sub { font-size: 12px; color: var(--dim); }
html[data-view="modern"] .mm-fix {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--cyan);
  background: var(--neon-glow);
  border: 1px solid rgba(249, 115, 22, 0.35);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
html[data-view="modern"] .mm-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  flex: 1 1 200px;
  min-width: 180px;
  max-width: 300px;
}
html[data-view="modern"] .mm-search:focus-within { border-color: var(--cyan); }
html[data-view="modern"] .mm-search svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  stroke: var(--dim);
}
html[data-view="modern"] .mm-search input {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  outline: none;
  width: 100%;
  min-width: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}
html[data-view="modern"] .mm-search input::-webkit-search-cancel-button { filter: invert(0.6); }
html[data-view="modern"] .mm-search input::placeholder { color: var(--dim); }

html[data-view="modern"] .mm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
html[data-view="modern"] .mm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--muted);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
html[data-view="modern"] .mm-chip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
html[data-view="modern"] .mm-chip:hover { color: var(--text); border-color: var(--dim); }
html[data-view="modern"] .mm-chip.on {
  color: var(--text);
  border-color: var(--cyan);
  background: var(--neon-glow);
}

/* Layout: fixed-width pack rail + map card with the legend overlay. */
html[data-view="modern"] .mm-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
html[data-view="modern"] .mm-rail {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: min(72vh, 620px); /* lines up with .fleet-map's height */
}
html[data-view="modern"] .mm-rail-head {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--divider);
}
html[data-view="modern"] .mm-rail-title { font-size: 13px; font-weight: 800; color: var(--text); }
html[data-view="modern"] .mm-rail-note { font-size: 11px; color: var(--dim); margin-top: 2px; }
html[data-view="modern"] .mm-rail-list { flex: 1; min-height: 120px; overflow-y: auto; padding: 6px; }
html[data-view="modern"] .mm-rail-foot {
  padding: 9px 14px;
  border-top: 1px solid var(--divider);
  font-size: 11px;
  line-height: 1.45;
  color: var(--dim);
}
html[data-view="modern"] .mm-rail-empty {
  padding: 22px 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}

/* Rail rows: dot + name/meta + SOC, click-to-focus. */
html[data-view="modern"] .mm-prow {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  border-radius: 9px;
  padding: 8px 9px;
  cursor: pointer;
}
html[data-view="modern"] .mm-prow:hover { background: var(--card2); }
html[data-view="modern"] .mm-prow.sel {
  background: var(--neon-glow);
  border-color: rgba(249, 115, 22, 0.35);
}
html[data-view="modern"] .mm-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dim);
}
html[data-view="modern"] .mm-dot.on { background: var(--green); }
html[data-view="modern"] .mm-dot.stale { background: var(--amber); }
html[data-view="modern"] .mm-dot.off { background: var(--dim); }
html[data-view="modern"] .mm-prow-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
html[data-view="modern"] .mm-nm {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-view="modern"] .mm-meta {
  font-size: 11px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-view="modern"] .mm-soc {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
html[data-view="modern"] .mm-soc.lo { color: var(--amber); }

/* Map card: neutralise classic .fleet-map margins; legend overlays bottom-left
   (pointer-events: none so it never blocks the map or the OSM attribution). */
html[data-view="modern"] .mm-map-card { position: relative; }
html[data-view="modern"] .mm-map { margin: 0; }
/* v5.90 dark re-skin: the pre-5.82 dark-basemap invert is BACK — stock OSM
   tiles are near-white, so modern inverts them to a near-black basemap
   (invert(1) hue-rotate(180deg) keeps road/water hues sane). Scoped to the
   tile images only: markers live in .leaflet-marker-pane and controls in
   .leaflet-control-pane, so both stay untouched. The marker ring flips
   light in map.js to hold against the inverted tiles; the legend chip below
   stays dark to match. */
html[data-view="modern"] .mm-map .leaflet-tile-pane img {
  filter: invert(1) hue-rotate(180deg);
}
html[data-view="modern"] .mm-legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  /* Leaflet's panes carry z-index 200–700 and ESCAPE .leaflet-container
     (position:relative, z:auto → no stacking context), so they compete in
     this card's stacking context: without a z-index the legend sat at 0 and
     painted BEHIND the tiles (map-pane 400) — DOM-present but invisible.
     699 = above map/tiles/markers(600)/tooltips(650), below popups(700)
     and controls(1000), so popups and zoom/attribution stay on top. */
  z-index: 699;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  max-width: calc(100% - 20px);
  /* v5.90 dark: back to a dark frosted chip — muted label text reads
      light-on-dark and it separates from the inverted tiles with a lift
      shadow. */
  background: rgba(23, 27, 33, 0.93);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 11px;
  pointer-events: none;
}
html[data-view="modern"] .mm-lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
html[data-view="modern"] .mm-lg i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--dim);
}

/* Modern popup: title + pill, id/coords line, stats grid, ages, actions. */
html[data-view="modern"] .mm-pop {
  min-width: 230px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
}
html[data-view="modern"] .mm-pop-t {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  overflow-wrap: anywhere;
}
html[data-view="modern"] .mm-pill {
  flex: 0 0 auto;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  color: var(--muted);
}
html[data-view="modern"] .mm-pill.on {
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.1);
}
html[data-view="modern"] .mm-pill.stale {
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.1);
}
html[data-view="modern"] .mm-pill.off { color: var(--dim); }
html[data-view="modern"] .mm-pop-id {
  font-size: 11px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
html[data-view="modern"] .mm-pop-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--divider);
}
html[data-view="modern"] .mm-pop-stats span { color: var(--muted); font-size: 11.5px; }
html[data-view="modern"] .mm-pop-stats b {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}
html[data-view="modern"] .mm-pop-age {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  font-size: 11px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
html[data-view="modern"] .mm-pop-acts { display: flex; gap: 7px; margin-top: 9px; }
html[data-view="modern"] .mm-pop-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
html[data-view="modern"] .mm-pop-btn:hover { border-color: var(--cyan); }
html[data-view="modern"] .mm-pop-btn.primary {
  background: var(--neon-glow);
  border-color: rgba(249, 115, 22, 0.4);
  color: var(--cyan);
}

/* Responsive: rail stacks over the map; search takes the full row. */
@media (max-width: 1100px) {
  html[data-view="modern"] .mm-layout { grid-template-columns: minmax(0, 1fr); }
  html[data-view="modern"] .mm-rail { max-height: 300px; }
}
@media (max-width: 720px) {
  html[data-view="modern"] .mm-search { max-width: none; flex-basis: 100%; }
  html[data-view="modern"] .mm-fix { order: 3; }
}

/* ---------- Phase E: modern announcements (mockup bms-mockup-announcements) */
/* The composer/push cards reuse the classic .ann-* kit (token-based, already
   re-skinned); new chrome: admin pill, KPI row, 2-col layout, status pills,
   draft preview, schedule timeline. */
html[data-view="modern"] .man-pill {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.7px;
  color: var(--indigo);
  background: rgba(129, 140, 248, 0.12);
  border: 1px solid rgba(129, 140, 248, 0.35);
  padding: 5px 11px;
  border-radius: 999px;
  text-transform: uppercase;
}

html[data-view="modern"] .man-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
html[data-view="modern"] .man-kpi {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 16px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}
html[data-view="modern"] .man-kpi::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--accent, var(--cyan));
  opacity: 0.65;
}
html[data-view="modern"] .man-kpi-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.1px;
  color: var(--muted);
  text-transform: uppercase;
}
html[data-view="modern"] .man-kpi-value {
  font-size: 24px;
  font-weight: 800;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
html[data-view="modern"] .man-kpi-sub {
  font-size: 11.5px;
  color: var(--dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-view="modern"] .man-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 14px;
  align-items: start;
}
html[data-view="modern"] .man-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* Status pill on each list row (classic's PAUSED pill moved here). */
html[data-view="modern"] .man-st {
  flex: 0 0 auto;
  margin-top: 2px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.7px;
  padding: 3.5px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
html[data-view="modern"] .man-st.live {
  background: rgba(34, 197, 94, 0.13);
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.33);
}
html[data-view="modern"] .man-st.sched {
  background: rgba(249, 115, 22, 0.1);
  color: var(--cyan);
  border-color: rgba(249, 115, 22, 0.3);
}
html[data-view="modern"] .man-st.exp {
  background: rgba(148, 163, 184, 0.1);
  color: var(--muted);
  border-color: rgba(148, 163, 184, 0.28);
}
html[data-view="modern"] .man-st.off {
  background: rgba(248, 113, 113, 0.1);
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.3);
}
/* Classic's editing outline is neon-yellow — recolor for the modern palette. */
html[data-view="modern"] .ann-item.editing { border-color: rgba(249, 115, 22, 0.5); }

/* Draft preview: the banner exactly as the panel will show it. */
html[data-view="modern"] .man-pv-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.1px;
  color: var(--dim);
  text-transform: uppercase;
  margin-bottom: 9px;
}
html[data-view="modern"] .man-banner {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.14), rgba(129, 140, 248, 0.12));
  border: 1px solid rgba(249, 115, 22, 0.35);
  border-radius: 11px;
  padding: 13px 15px;
}
html[data-view="modern"] .man-banner-empty {
  background: var(--card2);
  border-color: var(--border);
}
html[data-view="modern"] .man-bt {
  font-size: 13.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-wrap: anywhere;
}
html[data-view="modern"] .man-btag {
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--cyan);
  border: 1px solid rgba(249, 115, 22, 0.4);
  background: rgba(249, 115, 22, 0.1);
  padding: 2px 7px;
  border-radius: 5px;
  text-transform: uppercase;
}
html[data-view="modern"] .man-bd {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
html[data-view="modern"] .man-blink {
  color: var(--cyan);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-view="modern"] .man-who {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 11px;
  flex-wrap: wrap;
}
html[data-view="modern"] .man-who-lbl {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.1px;
  color: var(--dim);
  text-transform: uppercase;
  margin-right: 2px;
}
html[data-view="modern"] .man-who-chip {
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--muted);
}
html[data-view="modern"] .man-who-chip.yes {
  border-color: rgba(34, 197, 94, 0.35);
  color: var(--green);
  background: rgba(34, 197, 94, 0.08);
}
html[data-view="modern"] .man-who-chip.no {
  opacity: 0.5;
  text-decoration: line-through;
}

/* Schedule timeline (inline SVG — axis/today text styled here). */
html[data-view="modern"] .man-tl svg { width: 100%; height: auto; display: block; }
html[data-view="modern"] .man-tl text {
  fill: var(--dim);
  font-size: 9px;
  font-weight: 700;
  font-family: inherit;
}
html[data-view="modern"] .man-tl .man-tl-today { fill: var(--red); }
html[data-view="modern"] .man-tl-more { font-size: 11px; color: var(--dim); margin-top: 6px; }
html[data-view="modern"] .man-empty { font-size: 12.5px; color: var(--muted); padding: 4px 0; }

/* Responsive: KPIs wrap; columns stack (composer stays first). */
@media (max-width: 1240px) {
  html[data-view="modern"] .man-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  html[data-view="modern"] .man-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  html[data-view="modern"] .man-kpis { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Phase E: classic-literal re-skin (keep-markup tabs) ----------
   Everything in styles.css that reads var(--neon) re-tokenizes automatically,
   but these rules carry HARD-CODED classic neon (rgba(229,255,0) / #E5FF00)
   and would keep glowing yellow-green in the modern palette. Scoped overrides
   recolor the chrome to the modern accent — on the v5.90 charcoal palette
   that is the orange hero (var(--cyan) / rgba(249,115,22)). Classic is
   untouched. Covers Alerts/Users/Warranties/Devices, the shell's greeting
   strip, and the classic blocks the modern views reuse (controls, pills,
   filters, history toolbar). Chart series colors adapt in charts.js via a
   state.view branch; map markers keep their set (their ring flips light in
   map.js for the inverted dark tiles). */
html[data-view="modern"] .greeting-line {
  background: rgba(249, 115, 22, 0.06);
  border-bottom-color: rgba(249, 115, 22, 0.16);
}
html[data-view="modern"] .role-ADMIN {
  border-color: rgba(249, 115, 22, 0.5);
  background: rgba(249, 115, 22, 0.1);
}
html[data-view="modern"] .ctrl-btn.ctrl-btn-on {
  border-color: rgba(249, 115, 22, 0.5);
  background: rgba(249, 115, 22, 0.12);
}
html[data-view="modern"] .ctrl-input:focus { box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.15); }
html[data-view="modern"] .pill-online,
html[data-view="modern"] .pill-charging {
  border-color: rgba(249, 115, 22, 0.45);
  background: rgba(249, 115, 22, 0.1);
}
html[data-view="modern"] .chip-on {
  border-color: rgba(249, 115, 22, 0.4);
  background: rgba(249, 115, 22, 0.08);
}
html[data-view="modern"] .status-neon {
  border-color: rgba(249, 115, 22, 0.45);
  background: rgba(249, 115, 22, 0.1);
}
html[data-view="modern"] .view-tab.active {
  border-color: rgba(249, 115, 22, 0.45);
  background: rgba(249, 115, 22, 0.1);
}
html[data-view="modern"] .search-box:focus { box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12); }
html[data-view="modern"] .hist-chip.active { background: rgba(249, 115, 22, 0.1); }
/* Live-chart legend dots are HARD-CODED classic hex — flip them to the
   METRICS_DARK ramp so the dots match the series charts.js now draws. */
html[data-view="modern"] .live-key-soc { background: #4ADE80; }
html[data-view="modern"] .live-key-cur { background: #A78BFA; }
/* Brand logo hex paths — same attribute-selector trick as the light theme. */
html[data-view="modern"] .logo path[stroke="#E5FF00"] { stroke: var(--cyan); }
html[data-view="modern"] .logo path[fill="#E5FF00"] { fill: var(--cyan); }

/* =========================================================================
 * v5.85 — living motion + 3D depth (modern view only; classic untouched).
 *
 * Motion is driven by LIVE DATA, never by the 5 s poll's clock: wheels spin
 * only while a pack reports movement (period scales with speed), charge
 * rings flow only while current is actually flowing, cell strips shimmer
 * only while charging. The view entrance stagger keys off renderActive's
 * foreground path (tab/view switches, render.js) — background refreshes
 * strip .view-enter before the DOM swap, so data updates never restart it.
 *
 * Depth is cheap: layered elevation shadows at rest, a self-contained
 * perspective() tilt on hover (the tilt rides the HOVERED element, so no
 * ancestor ever gains a transform and the position:fixed Configure sheet
 * keeps its viewport containing block; a :has() guard cancels the entrance
 * transform on any subtree hosting one). Everything dies under
 * prefers-reduced-motion (final block).
 * ========================================================================= */

/* ---------- Elevation: layered depth at rest + hover steps -------------- */
html[data-view="modern"] {
  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 6px -2px rgba(0, 0, 0, 0.40);
  --elev-2: 0 2px 4px rgba(0, 0, 0, 0.40), 0 14px 30px -14px rgba(0, 0, 0, 0.55);
  --elev-3: 0 4px 10px rgba(0, 0, 0, 0.45), 0 30px 60px -24px rgba(0, 0, 0, 0.65);
}
html[data-view="modern"] .md-kpi,
html[data-view="modern"] .md-panel,
html[data-view="modern"] .md-batt,
html[data-view="modern"] .mb-stat,
html[data-view="modern"] .man-kpi,
html[data-view="modern"] .batt-card { box-shadow: var(--elev-1); }
/* The sidebar reads as a raised rail against the content plane. */
html[data-view="modern"] #sidebar { box-shadow: 6px 0 26px -20px rgba(0, 0, 0, 0.75); }

@media (hover: hover) and (pointer: fine) {
  html[data-view="modern"] .md-kpi,
  html[data-view="modern"] .md-panel,
  html[data-view="modern"] .mb-stat,
  html[data-view="modern"] .man-kpi {
    transition: transform 0.35s cubic-bezier(0.2, 0.75, 0.3, 1),
      box-shadow 0.35s cubic-bezier(0.2, 0.75, 0.3, 1);
  }
  html[data-view="modern"] .md-kpi:hover,
  html[data-view="modern"] .md-panel:hover,
  html[data-view="modern"] .mb-stat:hover,
  html[data-view="modern"] .man-kpi:hover {
    transform: perspective(760px) translateY(-4px) rotateX(5deg);
    box-shadow: var(--elev-2);
  }
  html[data-view="modern"] .md-batt {
    transition: border-color 0.15s, transform 0.35s cubic-bezier(0.2, 0.75, 0.3, 1),
      box-shadow 0.35s cubic-bezier(0.2, 0.75, 0.3, 1);
  }
  html[data-view="modern"] .md-batt:hover {
    border-color: #3D4756;
    transform: perspective(760px) translateY(-4px) rotateX(3deg);
    box-shadow: var(--elev-2);
  }
  html[data-view="modern"] .md-batt:hover .md-soc { transform: scale(1.06); }
  html[data-view="modern"] .md-batt:active { box-shadow: var(--elev-3); }

  /* v6.06 (user report: hovering the Fleet trends chart "gets tilted" and
     looked odd): the perspective tilt is a depth cue for LIST/KPI panels,
     but a panel hosting a CHART must stay geometrically true — the warp
     skews gridlines and defeats Chart.js's bounding-rect tooltip math.
     Both chart-hosting rail panels (Fleet trends + Insights) opt out of
     the transform; the shadow step below stays as the hover cue. :has()
     reads the section's own data-rail key, so it matches whether the
     section is open or collapsed. */
  html[data-view="modern"] .md-panel:has([data-rail="trends"]):hover,
  html[data-view="modern"] .md-panel:has([data-rail="insights"]):hover {
    transform: none;
  }
}
html[data-view="modern"] .md-soc {
  transition: transform 0.35s cubic-bezier(0.2, 0.75, 0.3, 1);
}
html[data-view="modern"] .md-soc-inner { z-index: 1; }

/* ---------- View entrance: stagger on tab/view switch ONLY --------------
   render.js adds .view-enter on foreground renders when the tab|view key
   changes and strips it before every DOM swap, so the 5 s poll never
   restarts it. Direct children of #view rise in document order. */
@keyframes mdRise {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
html[data-view="modern"] #view.view-enter > * {
  animation: mdRise 0.55s cubic-bezier(0.2, 0.75, 0.3, 1) both;
}
html[data-view="modern"] #view.view-enter > *:nth-child(2) { animation-delay: 60ms; }
html[data-view="modern"] #view.view-enter > *:nth-child(3) { animation-delay: 120ms; }
html[data-view="modern"] #view.view-enter > *:nth-child(4) { animation-delay: 180ms; }
html[data-view="modern"] #view.view-enter > *:nth-child(5) { animation-delay: 240ms; }
html[data-view="modern"] #view.view-enter > *:nth-child(6) { animation-delay: 300ms; }
html[data-view="modern"] #view.view-enter > *:nth-child(7) { animation-delay: 360ms; }
html[data-view="modern"] #view.view-enter > *:nth-child(n+8) { animation-delay: 420ms; }
/* A transformed ancestor would capture the position:fixed Configure sheet —
   never animate a subtree that hosts one (guard applies the moment the
   sheet mounts, mid-flight included). */
html[data-view="modern"] #view.view-enter > *:has(.config-overlay),
html[data-view="modern"] #view.view-enter > *:has(.modal-overlay) {
  animation: none;
  opacity: 1;
  transform: none;
}

/* ---------- Scooter: speed-scaled wheel spin + wind streaks -------------
   Inline SVG in the strip's Speed card (mb-scoot) and the dashboard Speed
   row (md-scoot); markup rides along in fleet.js / dashboard.js. Wheels
   only spin under .moving (gpsSpeed >= 0.5) and their period is written to
   --spin by the renderer: faster pack, faster spin. */
html[data-view="modern"] .mb-scoot,
html[data-view="modern"] .md-scoot {
  flex: none;
  overflow: visible;
  color: var(--dim);
}
html[data-view="modern"] .mb-scoot { width: 56px; height: 32px; }
html[data-view="modern"] .md-scoot { width: 35px; height: 20px; align-self: center; }
html[data-view="modern"] .mb-scoot .sc-frame,
html[data-view="modern"] .md-scoot .sc-frame {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
html[data-view="modern"] .mb-scoot .sc-tire,
html[data-view="modern"] .md-scoot .sc-tire {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-dasharray: 4.6 3.4;
}
html[data-view="modern"] .mb-scoot .sc-hub,
html[data-view="modern"] .md-scoot .sc-hub { fill: currentColor; stroke: none; }
html[data-view="modern"] .mb-scoot .sc-streak,
html[data-view="modern"] .md-scoot .sc-streak { opacity: 0; }
html[data-view="modern"] .mb-scoot.moving,
html[data-view="modern"] .md-scoot.moving { color: var(--cyan); }
html[data-view="modern"] .mb-scoot.moving .sc-tire,
html[data-view="modern"] .md-scoot.moving .sc-tire {
  animation: scSpin var(--spin, 1.2s) linear infinite;
  transform-box: fill-box;
  transform-origin: center;
}
html[data-view="modern"] .mb-scoot.moving .sc-frame,
html[data-view="modern"] .md-scoot.moving .sc-frame {
  animation: scBob 1.5s ease-in-out infinite;
}
html[data-view="modern"] .mb-scoot.moving .sc-streak,
html[data-view="modern"] .md-scoot.moving .sc-streak {
  animation: scStreak 0.75s linear infinite;
}
@keyframes scSpin { to { transform: rotate(360deg); } }
@keyframes scBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1.3px); }
}
@keyframes scStreak {
  0% { opacity: 0; transform: translateX(7px); }
  35% { opacity: 0.75; }
  100% { opacity: 0; transform: translateX(-9px); }
}
/* The dashboard Speed row shares its flex line with the value: icon + label
   left, number pinned right (the row is flagged data-sp). */
html[data-view="modern"] .md-stat[data-sp] { justify-content: flex-start; gap: 7px; }
html[data-view="modern"] .md-stat[data-sp] b { margin-left: auto; }

/* ---------- Battery charge flow: ring sweep + halo + cell shimmer --------
   .chg is emitted only while b.current > 0.1 (actually charging). The
   sweep is a masked conic comet riding the ring band; the halo breathes
   around the dashboard ring; the cell strip runs a staggered wave. Colors
   never animate — text contrast stays exactly where the 5.84 audit left
   it (motion is shadow/transform/background-image only). */
html[data-view="modern"] .mb-ring { position: relative; }
html[data-view="modern"] .mb-ring b { position: relative; z-index: 1; }
html[data-view="modern"] .mb-ring.chg::after,
html[data-view="modern"] .md-soc.chg::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    rgba(255, 255, 255, 0) 0deg,
    rgba(255, 255, 255, 0) 300deg,
    rgba(255, 255, 255, 0.85) 345deg,
    rgba(255, 255, 255, 0) 360deg);
  -webkit-mask: radial-gradient(closest-side, transparent 75%, #000 77%);
  mask: radial-gradient(closest-side, transparent 75%, #000 77%);
  animation: scSpin 2.6s linear infinite;
  pointer-events: none;
}
html[data-view="modern"] .md-soc.chg::after {
  -webkit-mask: radial-gradient(closest-side, transparent 80%, #000 82%);
  mask: radial-gradient(closest-side, transparent 80%, #000 82%);
}
html[data-view="modern"] .md-soc.chg { animation: chgHalo 2.6s ease-in-out infinite; }
@keyframes chgHalo {
  0%, 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); }
  50% { box-shadow: 0 0 0 7px rgba(249, 115, 22, 0.14); }
}
html[data-view="modern"] .md-cells.chg .md-cell {
  background-image: linear-gradient(90deg,
    rgba(255, 255, 255, 0) 40%,
    rgba(255, 255, 255, 0.95) 50%,
    rgba(255, 255, 255, 0) 60%);
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: cellFlow 1.5s linear infinite;
}
html[data-view="modern"] .md-cells.chg .md-cell:nth-child(4n+2) { animation-delay: 0.16s; }
html[data-view="modern"] .md-cells.chg .md-cell:nth-child(4n+3) { animation-delay: 0.32s; }
html[data-view="modern"] .md-cells.chg .md-cell:nth-child(4n+4) { animation-delay: 0.48s; }
@keyframes cellFlow {
  from { background-position: 140% 0; }
  to { background-position: -40% 0; }
}
/* Quick bar SOC number breathes a brand-cyan glow while charging (shadow
   only — the text color, and therefore its AA contrast, never moves). */
html[data-view="modern"] .mb-quick-soc.chg {
  animation: chgBreathe 2.4s ease-in-out infinite;
}
@keyframes chgBreathe {
  0%, 100% { text-shadow: 0 0 0 rgba(249, 115, 22, 0); }
  50% { text-shadow: 0 0 9px rgba(249, 115, 22, 0.55); }
}

/* ---------- KPI accent rail: slow telemetry sweep -----------------------
   The 2px accent bar on every KPI card carries a light comet on a 6s loop —
   a quiet "data is live" ticker. Endpoints sit off-card, so the loop point
   never pops; under reduced motion the static accent gradient remains. */
html[data-view="modern"] .md-kpi::after {
  background: linear-gradient(90deg,
    var(--accent, var(--cyan)) 0 46%,
    rgba(255, 255, 255, 0.95) 50%,
    var(--accent, var(--cyan)) 54% 100%);
  background-size: 300% 100%;
  background-repeat: no-repeat;
  animation: kpiSweep 6s linear infinite;
}
@keyframes kpiSweep {
  from { background-position: 105% 0; }
  to { background-position: -5% 0; }
}

/* ---------- Reduced motion: depth stays, movement goes ------------------
   Shadows and layout keep the sense of depth; every loop, tilt, rise and
   sweep is neutralised for users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  html[data-view="modern"],
  html[data-view="modern"] *,
  html[data-view="modern"] *::before,
  html[data-view="modern"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html[data-view="modern"] #view.view-enter > * {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  html[data-view="modern"] .md-kpi:hover,
  html[data-view="modern"] .md-panel:hover,
  html[data-view="modern"] .mb-stat:hover,
  html[data-view="modern"] .man-kpi:hover,
  html[data-view="modern"] .md-batt:hover,
  html[data-view="modern"] .md-batt:hover .md-soc {
    transform: none !important;
  }
  html[data-view="modern"] .sc-streak { display: none; }
}

/* v6.02 (user request): Dashboard Insights — four pure-CSS charts + auto
   insight bullets on the collapsible section under the KPI row; every role
   (admin/dealer/customer) renders it over its own server-scoped fleet.
   Static markup on purpose: the 5 s innerHTML repaint rebuilds these
   losslessly — no chart instances to re-parent, no flash, no hover state
   to lose. Bars scale against the largest count inside a fixed slot so the
   labels can never push the row past its height; the donut is a
   conic-gradient with a card-coloured hole; h-bars share one track/fill
   pair with an explicit value column so a 1-pack fleet reads cleanly. */
html[data-view="modern"] .mi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 12px;
  margin-top: 4px;
}
html[data-view="modern"] .mi-card {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px 12px;
  min-width: 0;
}
html[data-view="modern"] .mi-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 10px;
}
html[data-view="modern"] .mi-bars {
  display: flex;
  align-items: stretch;
  gap: 8px;
  height: 104px;
}
html[data-view="modern"] .mi-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
html[data-view="modern"] .mi-n {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
html[data-view="modern"] .mi-slot {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}
html[data-view="modern"] .mi-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 4px 4px 2px 2px;
}
html[data-view="modern"] .mi-x {
  font-size: 10px;
  color: var(--dim);
  white-space: nowrap;
}
html[data-view="modern"] .mi-donut-wrap {
  display: flex;
  align-items: center;
  gap: 13px;
}
html[data-view="modern"] .mi-donut {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  flex: none;
}
html[data-view="modern"] .mi-donut::after {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  background: var(--card2);
}
html[data-view="modern"] .mi-donut-c {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--dim);
}
html[data-view="modern"] .mi-donut-c b {
  font-size: 19px;
  line-height: 1.15;
  color: var(--text);
}
html[data-view="modern"] .mi-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
  min-width: 0;
}
html[data-view="modern"] .mi-legend li {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--dim);
}
html[data-view="modern"] .mi-legend b {
  margin-left: auto;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
html[data-view="modern"] .mi-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
html[data-view="modern"] .mi-row {
  display: grid;
  grid-template-columns: minmax(56px, 32%) 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
html[data-view="modern"] .mi-lbl {
  font-size: 11.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html[data-view="modern"] .mi-track {
  display: block;
  height: 7px;
  border-radius: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  overflow: hidden;
}
html[data-view="modern"] .mi-track i {
  display: block;
  height: 100%;
  border-radius: 3px;
}
html[data-view="modern"] .mi-val {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
html[data-view="modern"] .mi-empty {
  font-size: 11.5px;
  color: var(--dim);
  padding: 6px 0 4px;
}
html[data-view="modern"] .mi-notes {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 5px;
}
html[data-view="modern"] .mi-notes li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
}
html[data-view="modern"] .mi-notes li .mi-dot {
  margin-top: 6px;
}

/* v6.05 (user-approved round): fleet-trends chart box on the Dashboard.
   The per-pack box (styles.css .hist-chart-box) is 210 px; the fleet chart
   shares its canvas with up to 10 legend rows, so it gets 300 px. Declared
   after styles.css with a higher-specificity selector, so it wins the
   same-specificity cascade cleanly — styles.css stays byte-frozen. */
html[data-view="modern"] .ftrend-box { height: 300px; }

/* v6.12 (user request): the Users tab's JOINED stamp renders the full
   registration instant ("13 Oct 2026, 08:36:40", fmtClockMs(…, true)).
   Under the auto table layout the column collapsed to ~50 px of content and
   wrapped the timestamp into unreadable fragments, so pin a floor and keep
   it on one line. Scoped to >= 769 px: below that styles.css turns the table
   into stacked cards (td = flex row, wrap allowed), where a nowrap stamp
   would overflow the card. The column itself sits right after ROLE in the
   DOM (users.js) — beside the control the admin is actually working in.
   styles.css stays byte-frozen (rule B6). */
@media (min-width: 769px) {
  td[data-label="Joined"],
  th[data-users-sort="joined"] { white-space: nowrap; }
  td[data-label="Joined"] { min-width: 172px; }
}
