/* Design system of the charging platform. One file, no build step, mobile-first.

   Layers, in order of strength (later wins regardless of specificity):
     tokens      colours, type, space, radii, shadows; light and dark in one place
     base        elements without classes
     components  one component per job: card, panel, well, head, list/row, kv, btn, badge,
                 chip, seg, stat, bar, callout, icon-tile, field, dialog, menu, table, chart
     layout      shell: side bar, top bar, tab bar, page widths, columns; it places
                 components and may adjust them there (a menu in the side bar)
     pages       what belongs to one page or area: live view, sessions, driver's app, …
     utilities   single-purpose helpers (.muted colour only, .num, .grow, .sr-only, spacing)

   Rules of the house:
   - Colours, sizes, radii, shadows and spacing come from tokens; no literals outside
     the token layer.
   - Tones are one vocabulary for every component: .go .wait .bad .info .idle .accent set
     --tone, --tone-soft and --tone-line; a component reads those.
   - Breakpoints: 600 (phone/tablet), 900 (side bar instead of tab bar), 1200 (wide),
     1700 (very wide); 420 only for very narrow phones. Phone rules use max-width 599/899.
   - The signature element is the conductor gauge (L1, L2, L3); everything else stays quiet. */
@layer tokens, base, components, layout, pages, utilities;

@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 800;
  font-display: swap; src: url("inter.woff2") format("woff2"); }

/* == tokens ============================================================================ */
@layer tokens {
  /* The theme is chosen by the colour scheme: "auto" follows the system, a choice of the
     user sets it on the root. Every colour is written once with light-dark(). */
  :root { color-scheme: light dark; }
  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"] { color-scheme: dark; }
  :root {
    --paper: light-dark(#f4f6f9, #0b0f14);
    --surface: light-dark(#ffffff, #151b23);
    --sunken: light-dark(#f1f5f9, #1e2733);
    --line: light-dark(#e2e8f0, #263242);
    /* Borders that must be seen (fields): at least 3:1 on --surface, --sunken and --paper. */
    --line-strong: light-dark(#7d8a9b, #64748b);
    --ink: light-dark(#0f172a, #f1f5f9);
    --ink-2: light-dark(#475569, #a3b1c2);
    --ink-3: light-dark(#5b6b80, #8090a3);
    --accent: light-dark(#047857, #34d399);
    --fill: #047857;
    --on-fill: #ffffff;
    --accent-soft: light-dark(#ecfdf5, #06281e);
    --accent-line: light-dark(#a7f3d0, #065f46);
    --go: light-dark(#047857, #34d399);
    --go-soft: light-dark(#ecfdf5, #06281e);
    --go-line: light-dark(#a7f3d0, #065f46);
    --wait: light-dark(#b45309, #fbbf24);
    --wait-soft: light-dark(#fffbeb, #2b1d06);
    --wait-line: light-dark(#fde68a, #78501a);
    --on-wait: light-dark(#ffffff, #1f1403);
    --info: light-dark(#4338ca, #a5b4fc);
    --info-soft: light-dark(#eef2ff, #1b1c47);
    --info-line: light-dark(#c7d2fe, #3730a3);
    --bad: light-dark(#b91c1c, #fca5a5);
    --bad-fill: light-dark(#b91c1c, #dc2626);
    --bad-soft: light-dark(#fef2f2, #3a1414);
    --bad-line: light-dark(#fecaca, #7f1d1d);
    --idle: light-dark(#5b6b80, #8090a3);
    --idle-soft: light-dark(#f1f5f9, #1e2733);
    /* Data: chart series and energy sources. */
    --series-1: light-dark(#257de0, #338ced);
    --series-2: light-dark(#dc5f1f, #e76624);
    --series-3: light-dark(#009a7c, #00a888);
    --solar: light-dark(#c27c00, #f2b33d);
    --battery: light-dark(#7c5cd6, #a48cf0);
    --forecast: #10b981;
    /* Glass of the floating navigation and the phone header. */
    --glass: light-dark(rgb(244 246 249 / .72), rgb(21 27 35 / .72));
    --sep: light-dark(rgb(15 23 42 / .08), rgb(255 255 255 / .1));
    --scrim: rgb(10 16 22 / .55);
    /* Drawn car of the driver's app. */
    --car-body: #0f766e; --car-body-idle: #334155; --car-body-off: #475569;
    --car-roof: #0f172a; --car-glass: #e2e8f0; --car-lamp: #f8fafc; --car-tail: #fb7185;
    --car-led: #34d399; --car-led-wait: #f59e0b; --car-metal: #94a3b8; --car-tyre: #1e293b;
    --car-shadow: light-dark(rgb(15 23 42 / .1), rgb(0 0 0 / .5));
    --shine: rgb(255 255 255 / .3);
    --press: rgb(0 0 0 / .25);

    /* Type: one family, eight sizes, five weights. */
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --fs-2xs: .66rem; --fs-xs: .72rem; --fs-s: .8rem; --fs-m: .875rem; --fs-base: 1rem;
    --fs-l: 1.25rem; --fs-xl: 1.5rem; --fs-2xl: 1.95rem;
    --fs-chart-l: 12px; --fs-chart: 11px; --fs-chart-m: 10px; --fs-chart-s: 9px;
    --fw-regular: 400; --fw-medium: 500; --fw-semi: 600; --fw-bold: 650; --fw-heavy: 800;

    /* Space: a 4 px grid with the half steps that dense rows need. */
    --s0: 2px; --s1: 4px; --s15: 6px; --s2: 8px; --s25: 10px; --s3: 12px; --s35: 14px;
    --s4: 16px; --s5: 24px; --s6: 32px;
    --r-xs: 4px; --r-s: 8px; --r-m: 12px; --r-l: 20px; --r-pill: 999px;

    /* Lines: a hair for borders and dividers, a ring for focus and emphasis, a stripe
       for the state edge of a tile, a halo around a dot, the reach of a pulse. */
    --hair: 1px; --ring: 2px; --stripe: 3px; --halo: 3px; --pulse: 7px;
    /* Sizes. Icons and marks; dots; controls (--tap is the phone target); page widths. */
    --icon-2xs: 10px; --icon-xs: 12px; --icon-s: 14px; --icon-m: 16px; --icon: 18px;
    --icon-l: 20px; --icon-xl: 22px; --icon-2xl: 24px;
    --dot-xs: 3px; --dot-s: 7px; --dot: 8px;
    --size-xs: 28px; --size-s: 32px; --size-m: 36px; --size-l: 40px; --size-xl: 48px;
    --size-2xl: 56px;
    --w-xs: 320px; --w-menu: 280px; --w-narrow: 440px; --w-dialog: 520px; --w-form: 560px;
    --w-text: 720px; --w-wide: 820px; --w-cols: 960px; --w-page: 1180px;
    /* Letter spacing: headings and large figures, small labels, capitals. */
    --ls-tight: -.02em; --ls-wide: .02em; --ls-caps: .05em;

    --shadow: 0 1px 3px light-dark(rgb(15 23 42 / .04), rgb(0 0 0 / .4)),
      0 4px 16px -4px light-dark(rgb(15 23 42 / .05), transparent);
    --shadow-raised: 0 12px 32px rgb(0 0 0 / .14), var(--shadow);
    --shadow-float: 0 10px 30px -10px rgb(0 0 0 / .28), 0 2px 8px rgb(0 0 0 / .08);
    --shadow-dialog: 0 24px 64px rgb(0 0 0 / .3);

    --tap: 44px; --side: 236px; --topbar: 52px;
    /* Height the floating phone navigation takes, with its distance to the edge. */
    --tabbar: calc(76px + env(safe-area-inset-bottom));
    --z-sticky: 4; --z-top: 6; --z-sheet: 8; --z-nav: 9; --z-menu: 20; --z-toast: 30;
    --ease: cubic-bezier(.25, .1, .25, 1); --glide: cubic-bezier(.3, .7, .2, 1);
  }
}

/* == base ============================================================================== */
@layer base {
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
  body { margin: 0; background: var(--paper); color: var(--ink);
    font: var(--fs-base)/1.45 var(--font);
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
  a { color: var(--accent); text-decoration: none; }
  a:hover { text-decoration: underline; }
  a, button, summary, label { touch-action: manipulation; }
  h1 { font-size: var(--fs-l); line-height: 1.25; margin: 0; font-weight: var(--fw-bold);
    letter-spacing: var(--ls-tight); }
  h2 { font-size: var(--fs-base); margin: 0 0 var(--s3); font-weight: var(--fw-bold); }
  h3 { font-size: var(--fs-m); margin: 0 0 var(--s2); font-weight: var(--fw-bold); }
  p { margin: 0 0 var(--s3); }
  ol { margin: 0 0 var(--s3); padding-left: 1.3em; }
  ol li { margin-bottom: var(--s2); }
  code { font-family: var(--mono); font-size: .86em; overflow-wrap: anywhere; }
  :focus-visible { outline: var(--ring) solid var(--accent); outline-offset: var(--ring); border-radius: var(--r-s); }
  /* The first stop of the keyboard: past the navigation to the content (A11Y-05). */
  .skip-link { position: fixed; z-index: var(--z-toast); top: var(--s2); left: var(--s2);
    padding: var(--s2) var(--s3); border-radius: var(--r-m); background: var(--surface);
    color: var(--accent); font-weight: var(--fw-semi); box-shadow: var(--shadow-raised);
    transform: translateY(-200%); }
  .skip-link:focus-visible { transform: none; }
  main:focus { outline: none; }

  input, select, textarea { width: 100%; min-height: var(--tap); padding: var(--s2) var(--s3);
    border: var(--hair) solid var(--line-strong); border-radius: var(--r-m); background: var(--surface);
    color: var(--ink); font: inherit; }
  input:hover, select:hover, textarea:hover { border-color: var(--ink-2); }
  input:focus, select:focus, textarea:focus { outline: var(--ring) solid var(--accent);
    outline-offset: 0; border-color: var(--accent); }
  input[type=checkbox], input[type=radio] { width: var(--icon); height: var(--icon); min-height: 0;
    accent-color: var(--accent); vertical-align: -3px; margin: 0 var(--s15) 0 0; }
  input[type=range] { padding: 0; border: 0; accent-color: var(--accent); background: none; }
  details > summary { cursor: pointer; min-height: var(--tap); display: flex;
    align-items: center; color: var(--accent); font-weight: var(--fw-semi); }
  details[open] > summary { margin-bottom: var(--s2); }

  table { width: 100%; border-collapse: collapse; font-size: var(--fs-m); }
  th, td { text-align: left; padding: var(--s25) var(--s3) var(--s25) 0;
    border-top: var(--hair) solid var(--line); vertical-align: top; }
  tr:first-child > th, tr:first-child > td { border-top: 0; }
  th { color: var(--ink-2); font-weight: var(--fw-medium); white-space: nowrap; }
  th.r, td.r { text-align: right; padding-left: var(--s3); white-space: nowrap; }
  th:last-child, td:last-child { padding-right: 0; }
  td.wrap { white-space: normal; overflow-wrap: anywhere; }
  tr.sum td { font-weight: var(--fw-semi); border-top: var(--ring) solid var(--line); }

  @media (prefers-reduced-motion: no-preference) { @view-transition { navigation: auto; } }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); }
    100% { box-shadow: 0 0 0 var(--pulse) transparent; } }
  @media (max-width: 599px) {
    h2 { font-size: var(--fs-base); }
    table { font-size: var(--fs-s); }
    td:first-child, th:first-child { white-space: nowrap; }
  }
}

/* == layout: the shell ================================================================= */
@layer layout {
  .side { display: none; }
  .topbar { display: flex; align-items: center; gap: var(--s3); padding: var(--s25) var(--s4);
    background: var(--surface); border-bottom: var(--hair) solid var(--line);
    position: sticky; top: 0; z-index: var(--z-top); min-height: var(--topbar);
    padding-top: max(var(--s25), env(safe-area-inset-top)); }
  .topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .context { display: flex; align-items: center; gap: var(--s15); font-size: var(--fs-xs);
    color: var(--ink-3); line-height: 1.2; }
  .topbar .context strong { font-weight: var(--fw-medium); }
  /* Targets are at least 24 px high (WCAG 2.5.8, CRAWL-03). */
  .topbar .context a.home { display: inline-flex; align-items: center; min-height: var(--icon-2xl); }
  .topbar .back { margin: 0 calc(var(--s2) * -1) 0 calc(var(--s3) * -1); min-height: var(--size-l); }
  .topbar .back .icon { transform: rotate(180deg); }
  .topbar .who { display: inline-flex; align-items: center; gap: var(--s15); color: var(--ink-2);
    min-height: var(--tap); }
  .subtitle { font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--ink-3);
    display: flex; align-items: center; gap: var(--s15); margin-top: var(--s0); }
  .subtitle .dot { width: var(--dot-s); height: var(--dot-s); color: var(--fill); }

  main { max-width: var(--w-page); margin: 0 auto;
    padding: var(--s4) var(--s4) calc(var(--tabbar) + var(--s6)); }
  /* Page widths: narrow (forms), narrow-read (text), default, wide (live, charges). The
     top bar follows the width of the page, so title and content line up. */
  main.narrow { max-width: var(--w-narrow); }
  main.narrow-read { max-width: var(--w-text); }
  main.wide { max-width: none; }

  /* Columns: one on a phone, main and side from 1200 px. */
  .cols { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr);
    align-items: start; }
  .cols > * { min-width: 0; }
  @media (min-width: 1200px) { .cols { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    margin-bottom: var(--s4); } .cols > * { margin-bottom: 0; } }

  /* The driver's area: one column of cards on a phone, two (or three) from 1200 px. */
  .app { max-width: var(--w-narrow); margin-inline: auto; display: grid; gap: var(--s35);
    grid-template-columns: minmax(0, 1fr); }
  .app > p { margin: 0; }
  .app > .card { margin: 0; }
  @media (min-width: 1200px) {
    .app { max-width: var(--w-cols); display: block; columns: 2; column-gap: var(--s5); }
    .app.single { max-width: var(--w-form); columns: 1; }
    .app > * { break-inside: avoid; margin: 0 0 var(--s4); }
    .app > .card { margin: 0 0 var(--s4); }
    .app > .stop-row, .app > p { text-align: left; }
    .app.wide-grid { columns: 3; }
    .app.wide-grid > .card:first-child, .app.wide-grid > .card.full,
    .app.wide-grid > .chips, .app.wide-grid > p { column-span: all; }
  }

  /* Phone navigation: a floating glass pill. Tabs show their icon; the shown tab opens to a
     pill with its text, and a pointer glides behind it (placed by app.js). */
  .tabbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s0);
    position: fixed; z-index: var(--z-nav); left: var(--s25); right: var(--s25); max-width: var(--w-dialog);
    margin: 0 auto; bottom: calc(var(--s2) + env(safe-area-inset-bottom)); padding: var(--s15);
    border-radius: var(--r-pill); background: var(--glass); border: var(--hair) solid var(--sep);
    -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
    box-shadow: var(--shadow-float); touch-action: none; }
  .tabbar > a { position: relative; z-index: 1; flex: 0 1 auto; min-width: var(--size-xl); height: var(--size-xl);
    padding: 0 var(--s3); display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--r-pill); color: var(--ink-2); font-size: var(--fs-m);
    font-weight: var(--fw-bold); text-decoration: none; -webkit-tap-highlight-color: transparent;
    transition: color .25s var(--ease), padding .32s var(--glide); }
  .tabbar > a:hover { text-decoration: none; }
  .tabbar > a:focus-visible { outline: var(--ring) solid var(--accent); outline-offset: var(--ring);
    border-radius: var(--r-pill); }
  .tabbar .tab-text { display: block; min-width: 0; max-width: 0; opacity: 0; margin-left: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: max-width .32s var(--glide), opacity .2s var(--ease), margin-left .32s var(--glide); }
  /* Shown is the tab under the finger while wiping, otherwise the current one. */
  .tabbar:not(.js) > a[aria-current], .tabbar > a.is-shown { color: var(--accent);
    padding: 0 var(--s4) 0 var(--s35); min-width: 0; }
  .tabbar:not(.js) > a[aria-current] .tab-text, .tabbar > a.is-shown .tab-text {
    max-width: 34vw; opacity: 1; margin-left: 7px; }
  .tabbar > a.locked { opacity: .45; }
  .tabbar > a.locked[aria-current] { opacity: .8; }
  .tabbar .alert-dot { position: absolute; margin: 0; top: 9px; left: 28px; box-shadow: none; }
  .tab-pointer { position: absolute; left: var(--s15); top: var(--s15); height: var(--size-xl); width: var(--size-xl);
    border-radius: var(--r-pill); background: color-mix(in srgb, var(--accent) 14%, transparent);
    opacity: 0; pointer-events: none; }
  .tab-pointer.on { opacity: 1; }
  .tab-pointer.ready { transition: transform .32s var(--glide), width .32s var(--glide),
    background .25s var(--ease); }
  @media (prefers-reduced-motion: reduce) {
    .tabbar > a, .tabbar .tab-text, .tab-pointer.ready { transition-duration: .01s; } }

  /* Side bar on wide screens: operator, area switch, navigation, the user at the foot. */
  .side .brand { position: relative; display: flex; align-items: center; gap: var(--s2);
    padding: var(--s1) var(--s3) var(--s4); }
  .side .brand strong { display: block; font-size: var(--fs-base); letter-spacing: var(--ls-tight); }
  .side .brand span { font-size: var(--fs-s); color: var(--ink-3); }
  .side a.nav { display: flex; align-items: center; gap: var(--s3); padding: var(--s25) var(--s3);
    border-radius: var(--r-m); color: var(--ink-2); font-weight: var(--fw-medium); }
  .side a.nav:hover { background: var(--sunken); text-decoration: none; color: var(--ink); }
  .side a.nav[aria-current] { background: var(--accent-soft); color: var(--accent); }
  .side a.nav.locked { opacity: .45; }
  .side a.nav.locked[aria-current] { opacity: .8; }
  /* Setup is not daily work: it sits at the bottom of the side bar. */
  .side a.nav.last { margin-top: auto; }
  .side form { margin: 0; }
  .nav-heading { margin: var(--s3) var(--s3) var(--s1); font-size: var(--fs-xs);
    font-weight: var(--fw-semi); color: var(--ink-3); }
  /* A block of the menu under its heading (e-mobility, energy supply). */
  .nav-group { display: flex; flex-direction: column; gap: var(--s1); margin-top: var(--s2);
    padding-top: var(--s1); border-top: var(--hair) solid var(--line); }
  .nav-group .nav-heading { margin-top: var(--s2); letter-spacing: var(--ls-wide); text-transform: uppercase; }
  .alert-dot { width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--bad); flex: none;
    margin-left: auto; box-shadow: 0 0 0 var(--halo) color-mix(in srgb, var(--bad) 22%, transparent); }
  .side-foot { margin-top: auto; display: flex; align-items: center; gap: var(--s2);
    padding-top: var(--s3); border-top: var(--hair) solid var(--line); }
  .side-foot .btn[aria-current] { background: var(--accent-soft); color: var(--accent); }
  .side-menu { flex: 1; min-width: 0; position: relative; }
  .side-menu > summary { display: flex; align-items: center; gap: var(--s2); padding: var(--s15);
    border-radius: var(--r-m); cursor: pointer; list-style: none; font-weight: var(--fw-semi);
    font-size: var(--fs-m); min-width: 0; color: var(--ink); }
  .side-menu > summary::-webkit-details-marker { display: none; }
  .side-menu > summary:hover, .side-menu[open] > summary { background: var(--sunken); }
  .side-menu > summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-menu .menu-panel { top: auto; bottom: calc(100% + var(--s2)); left: 0; right: auto; }
  .side-menu .menu-panel a { white-space: normal; }
  /* Menus opened from the side bar stay within it; the operator list hangs under the
     whole brand row. */
  .side .menu-panel { width: calc(var(--side) - 2 * var(--s3)); left: 0; right: auto; }
  .side .menu-panel a, .side .menu-panel button { min-width: 0; white-space: normal;
    overflow-wrap: break-word; hyphens: auto; text-align: left; line-height: 1.3; }
  .side .menu-panel .avatar, .side .menu-panel .icon { flex: none; }
  .side .operator-name, .side .operator-menu { position: static; }
  .side .operator-menu .menu-panel { top: calc(100% - var(--s2)); left: 0; right: 0; width: auto;
    z-index: var(--z-toast); }

  /* Operator name: the name leads home, the arrow beside it opens the list. */
  .operator-name { position: relative; display: flex; align-items: center; gap: var(--s0);
    min-width: 0; }
  .operator-menu { position: static; }
  .operator-menu > summary { display: flex; flex: none; align-items: center; justify-content: center;
    gap: var(--s1); min-width: var(--size-xs); min-height: var(--size-xs); border-radius: var(--r-s); cursor: pointer;
    list-style: none; color: var(--ink); }
  .operator-menu > summary:hover { background: var(--sunken); }
  .operator-menu > summary::-webkit-details-marker { display: none; }
  .operator-menu > summary .icon { width: var(--icon-s); height: var(--icon-s); transform: rotate(90deg);
    color: var(--ink-3); flex: none; }
  .operator-menu .menu-panel { left: 0; right: auto; top: calc(100% + var(--s15)); width: var(--w-menu); }
  .operator-menu .menu-panel button { display: flex; align-items: center; gap: var(--s2);
    width: 100%; text-align: left; }
  a.home-logo { display: inline-flex; flex: none; border-radius: 22%; }
  a.home-logo:hover { text-decoration: none; opacity: .85; }
  a.home { color: inherit; min-width: 0; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; }
  a.home:hover { text-decoration: none; color: var(--accent); }
  a.home strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* In the side bar the name may take two lines before it is cut (VIS-04). */
  .side a.home { white-space: normal; }
  .side a.home strong { white-space: normal; line-height: 1.25; display: -webkit-box;
    -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }

  #modal-backdrop { display: none; }

  @media (min-width: 900px) {
    body.has-nav { padding-left: var(--side); }
    .tabbar { display: none; }
    .side { display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0;
      width: var(--side); background: var(--surface); border-right: var(--hair) solid var(--line);
      padding: var(--s4) var(--s3); gap: var(--s1); overflow-y: auto; overflow-x: hidden; }
    .topbar { padding: var(--s3) var(--s5); background: transparent; border: 0; position: static;
      max-width: var(--w-page); margin: 0 auto; }
    .topbar h1 { font-size: var(--fs-xl); }
    .topbar .who { display: none; }
    body:has(main.narrow) .topbar { max-width: calc(var(--w-narrow) + 2 * var(--s5)); }
    body:has(main.narrow-read) .topbar { max-width: calc(var(--w-text) + 2 * var(--s5)); }
    body:has(main.wide) .topbar { max-width: none; }
    body.has-nav .topbar .context, body.has-nav .top-menu, .menu-panel .phone-only { display: none; }
    main { padding: var(--s2) var(--s5) var(--s6); }
    main.narrow { margin-top: 8vh; }
  }
  @media (max-width: 599px) {
    main { padding-left: var(--s3); padding-right: var(--s3); padding-top: var(--s3); }
  }
  @media (max-width: 899px) {
    /* Header of the same glass as the tab bar. The glass lies on a layer of its own, so
       that sheets opened from the header are still placed against the screen. */
    .topbar { background: transparent; border-bottom: var(--hair) solid var(--sep); }
    .topbar::before { content: ""; position: absolute; inset: 0; z-index: -1;
      background: var(--glass); -webkit-backdrop-filter: blur(30px) saturate(180%);
      backdrop-filter: blur(30px) saturate(180%); }
    body:not(.in-my) .topbar h1 { font-size: var(--fs-base); font-weight: var(--fw-bold); }
    /* The driver's area on a phone: a header like an app. */
    body.in-my .topbar { border-bottom: 0; }
    body.in-my .topbar h1 { font-size: var(--fs-l); font-weight: var(--fw-heavy);
      letter-spacing: var(--ls-tight); }
    body.in-my main { padding-top: var(--s1); }
    body.in-my .top-menu { display: none; }
  }

  /* Moving between pages: a skeleton while the next page loads. */
  .skeleton { display: none; }
  body.navigating main > :not(.skeleton) { display: none; }
  body.navigating .skeleton { display: grid; gap: var(--s3); }
  .skeleton i { --block: 96px; display: block; height: var(--block); border-radius: var(--r-l); background: var(--sunken); }
  .skeleton i.wide { height: var(--tap); max-width: 60%; }
  .skeleton i.short { max-width: 70%; }
  @media (prefers-reduced-motion: no-preference) {
    .skeleton i { animation: skeleton 1.1s ease-in-out infinite alternate; }
    @keyframes skeleton { to { opacity: .45; } } }
}

/* == components ======================================================================== */
@layer components {
  /* The stroke is set here, not only in the sprite: Safari (iOS) ignores the sprite's own
     <style> for an external <use>, and the icons then come out filled. */
  .icon { width: var(--icon-l); height: var(--icon-l); flex: none; fill: none;
    stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

  /* -- tones: one vocabulary for every component -------------------------------------- */
  .go { --tone: var(--go); --tone-soft: var(--go-soft); --tone-line: var(--go-line); }
  .wait { --tone: var(--wait); --tone-soft: var(--wait-soft); --tone-line: var(--wait-line); }
  .bad { --tone: var(--bad); --tone-soft: var(--bad-soft); --tone-line: var(--bad-line); }
  .info { --tone: var(--info); --tone-soft: var(--info-soft); --tone-line: var(--info-line); }
  .accent { --tone: var(--accent); --tone-soft: var(--accent-soft); --tone-line: var(--accent-line); }
  .idle { --tone: var(--ink-2); --tone-soft: var(--sunken); --tone-line: var(--line); }

  /* -- surfaces: card (a section), panel (inset in a card), well (sunken) -------------- */
  .card { display: block; background: var(--surface); border: var(--hair) solid var(--line);
    border-radius: var(--r-l); padding: var(--s4); margin-bottom: var(--s4);
    box-shadow: var(--shadow); color: inherit; min-width: 0; }
  a.card:hover { text-decoration: none; border-color: var(--ink-3); }
  .card hr { border: 0; border-top: var(--hair) solid var(--line); margin: var(--s35) 0; }
  .card details + details { border-top: var(--hair) solid var(--line); }
  details.card > summary { min-height: var(--size-xs); font-size: var(--fs-s); color: var(--ink);
    justify-content: space-between; }
  details.card > summary small { display: block; font-size: var(--fs-xs);
    font-weight: var(--fw-regular); color: var(--ink-3); }
  details.card > summary::after { content: ""; width: var(--dot); height: var(--dot); flex: none;
    border-right: var(--ring) solid var(--ink-3); border-bottom: var(--ring) solid var(--ink-3);
    transform: rotate(45deg); transition: transform .2s; margin: 0 var(--s15); }
  details.card[open] > summary::after { transform: rotate(225deg); }
  .panel { border: var(--hair) solid var(--line); border-radius: var(--r-m); padding: var(--s3);
    background: var(--paper); min-width: 0; }
  .panel.on { background: var(--go-soft); border-color: color-mix(in srgb, var(--go) 35%, transparent); }
  .well { border: var(--hair) solid var(--line); border-radius: var(--r-l); padding: var(--s3);
    background: var(--sunken); font-size: var(--fs-s); color: var(--ink-2); }
  .well.go { background: var(--go-soft); border-color: var(--go-line); }
  @media (max-width: 599px) {
    .card { padding: var(--s3); margin-bottom: var(--s3); }
    /* Sections run from edge to edge, like the groups of a phone's settings. */
    main > .card, #results > .card, .cols .card, main > form.card, #tree > .card,
    .live-grid .card, #log > .card { margin-inline: calc(var(--s3) * -1);
      border-radius: 0; border-inline: 0; }
  }

  /* -- head rows: a title and what belongs to it ----------------------------------------- */
  .head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
    margin-bottom: var(--s3); }
  .head h2, .head h3 { margin: 0; }
  .head > :last-child:not(:first-child):not(.grow) { margin-left: auto; }
  .head.spread { justify-content: space-between; flex-wrap: nowrap; gap: var(--s2); }
  .head.spread > :first-child { min-width: 0; }
  .head + .hint { margin-top: calc(var(--s2) * -1); }
  .overline { font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--ink-3);
    letter-spacing: var(--ls-wide); }
  h2.overline { margin: 0; }
  .hint { display: block; font-size: var(--fs-s); color: var(--ink-3); margin: var(--s0) 0 var(--s3);
    font-weight: var(--fw-regular); }
  .page-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3);
    margin-bottom: var(--s4); }
  .page-head .export { flex: none; }
  @media (min-width: 900px) { .page-head .chips { flex-wrap: nowrap; flex: 0 0 auto; }
    .page-head .chip { white-space: nowrap; } }
  @media (max-width: 599px) {
    /* Page head: search and the main action share a row, chips scroll sideways. */
    .page-head { gap: var(--s2); margin-bottom: var(--s3); }
    .page-head > span.grow { display: none; }
    .page-head .search { flex: 1 1 calc(100% - 60px); max-width: none; order: 1; }
    .page-head:has(.search) .btn.primary { order: 2; width: var(--tap); padding: 0; flex: none; }
    .page-head:has(.search) .btn.primary .label, .page-head .export .label {
      position: absolute; width: var(--hair); height: var(--hair); overflow: hidden; clip-path: inset(50%);
      white-space: nowrap; }
    .page-head .export { width: var(--tap); padding: 0; border-color: var(--line); }
    .page-head .more { order: 3; min-height: var(--size-m); padding: 0 var(--s35); border-radius: var(--r-pill);
      border-color: var(--line); font-size: var(--fs-m); font-weight: var(--fw-medium); }
    .page-head .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; flex: 1 1 0;
      min-width: 0; }
    .page-head .chips::-webkit-scrollbar { display: none; }
    .page-head .chip { flex: none; }
    .page-head .external { order: 3; flex-basis: 100%; justify-content: flex-start; padding: 0;
      min-height: var(--size-s); }
  }

  /* -- lists and rows ------------------------------------------------------------------ */
  .list { list-style: none; margin: 0; padding: 0; }
  .list > li { display: flex; align-items: center; gap: var(--s3); padding: var(--s25) 0;
    border-top: var(--hair) solid var(--line); min-height: var(--tap); }
  .list > li:first-child { border-top: 0; }
  .list > li .actions { flex-wrap: nowrap; }
  .list a.row, .list div.row { color: inherit; display: flex; align-items: center; gap: var(--s3);
    flex: 1; min-width: 0; }
  .list a.row { margin: calc(var(--s25) * -1) calc(var(--s2) * -1); padding: var(--s25) var(--s2);
    border-radius: var(--r-m); transition: background-color .15s var(--ease); }
  .list a.row:hover { background: var(--sunken); text-decoration: none; }
  /* The chevron of a row that opens something; the same mark for .kv.link. */
  .list a.row::after, .kv.link::after { content: ""; width: var(--dot-s); height: var(--dot-s); flex: none;
    margin-left: var(--s0); border-right: var(--ring) solid var(--ink-3); border-top: var(--ring) solid var(--ink-3);
    transform: rotate(45deg); opacity: .6; }
  /* A row without a target keeps an empty place for the chevron, so figures line up. */
  .list.aligned div.row::after { content: ""; width: var(--dot-s); margin-left: var(--s0); flex: none; }
  .row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .row-meta { display: block; margin-top: var(--s0); color: var(--ink-2); font-size: var(--fs-s); }
  .row-end { display: flex; align-items: center; gap: var(--s3); flex: none; }
  .row-end.stack { flex-direction: column; align-items: flex-end; gap: var(--s0);
    text-align: right; white-space: nowrap; }
  .row-end.stack strong { font-size: var(--fs-base); font-weight: var(--fw-bold); }
  .row-end.stack strong small { font-size: var(--fs-xs); font-weight: var(--fw-medium);
    color: var(--ink-2); }
  .row-end.stack > small { font-size: var(--fs-xs); }
  .list > li.day { min-height: 0; padding: var(--s3) 0 var(--s1); border-top: 0;
    font-size: var(--fs-s); font-weight: var(--fw-semi); color: var(--ink-2); position: sticky;
    top: var(--topbar); background: var(--surface); z-index: 1; }
  .list > li.day + li { border-top: 0; }
  .list > li.more { border-top: 0; padding-top: var(--s3); }
  .list.log > li { align-items: flex-start; min-height: 0; padding: var(--s2) 0; }
  .list.log code { display: block; margin-top: var(--s0); color: var(--ink-2); }
  @media (min-width: 900px) { .list > li.day { position: static; } }
  @media (max-width: 599px) {
    /* The title keeps its line, figures stack at the right edge. */
    .row-end { flex-direction: column; align-items: flex-end; gap: var(--s0); }
    .list > li { flex-wrap: wrap; min-height: var(--size-2xl); }
    .list > li > .actions { flex-basis: 100%; justify-content: flex-end; margin-top: calc(var(--s15) * -1); }
  }
  .empty { text-align: center; padding: var(--s5) var(--s4); color: var(--ink-2); }

  /* Key and value on one line (driver's app, details of a charge). */
  dd > a:only-child { display: inline-flex; align-items: center; min-height: var(--icon-2xl); }
  .kv { display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
    padding: var(--s15) 0; font-size: var(--fs-s); color: var(--ink-2); font-weight: var(--fw-semi);
    width: 100%; background: none; border: 0; font-family: inherit; text-align: left; }
  .kv > span:first-child { min-width: 0; }
  .kv strong { color: var(--ink); font-weight: var(--fw-bold); }
  .kv > strong { text-align: right; }
  .kv small { display: block; font-size: var(--fs-xs); font-weight: var(--fw-regular);
    color: var(--ink-3); }
  .kv.line { border-top: var(--hair) solid var(--line); padding: var(--s25) 0; font-weight: var(--fw-regular); }
  .kv.line strong { font-weight: var(--fw-semi); }
  .kv.link { cursor: pointer; padding: var(--s25) 0; min-height: var(--tap); color: var(--ink-2); }
  .kv.link:hover { text-decoration: none; }
  .kv.link.no-arrow::after { content: none; }
  .kv.danger strong { color: var(--bad); }
  .with-icon { display: flex; align-items: center; gap: var(--s25); }
  .facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--s15) var(--s4); margin: 0; }
  .facts dt { color: var(--ink-2); font-size: var(--fs-m); }
  .facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
  @media (max-width: 599px) { .facts { gap: var(--s1) var(--s3); } }
  @media (max-width: 420px) {
    /* Long labels (German, Portuguese) get their own line above the value. */
    .facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .facts dt { font-size: var(--fs-xs); margin-top: var(--s15); }
  }

  /* -- buttons --------------------------------------------------------------------------
     .btn            framed, the default
     .primary        the one main action
     .ghost          no frame, for toolbars
     .soft           sunken, small actions inside cards
     .link           text only
     .danger         destructive in red text; .danger.solid filled red
     .raised         a floating icon button (top bar of the driver's app)
     .s .block .icon-only   size and shape */
  .btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s15);
    min-height: var(--tap); padding: 0 var(--s4); border-radius: var(--r-m);
    border: var(--hair) solid var(--line); background: var(--surface); color: var(--ink);
    font: inherit; font-weight: var(--fw-semi); cursor: pointer; white-space: nowrap;
    transition: border-color .15s var(--ease), background-color .15s var(--ease),
      color .15s var(--ease), filter .15s var(--ease), transform .1s var(--ease); }
  .btn:hover { border-color: var(--ink-3); text-decoration: none; }
  .btn:active:not(:disabled) { transform: translateY(.5px); }
  .btn:disabled { opacity: .5; cursor: default; transform: none; }
  label.btn:has(.sr-only:focus-visible) { outline: var(--ring) solid var(--accent); outline-offset: var(--ring); }
  .btn.primary { background: var(--fill); border-color: var(--fill); color: var(--on-fill); }
  .btn.primary:hover { filter: brightness(1.08); }
  .btn.ghost { border-color: transparent; background: none; color: var(--ink-2); }
  .btn.ghost:hover { background: var(--sunken); color: var(--ink); }
  .btn.soft { border-color: transparent; background: var(--sunken); color: var(--ink-2); }
  .btn.soft:hover { color: var(--ink); }
  .btn.link { border: 0; background: none; color: var(--accent); padding: 0 var(--s15);
    font-weight: var(--fw-medium); }
  .btn.link.quiet { color: var(--ink-3); padding: var(--s25) var(--s4); border-radius: var(--r-l); }
  .btn.link.quiet:hover { color: var(--bad); background: var(--bad-soft); }
  .btn.danger { color: var(--bad); }
  .btn.danger:hover { border-color: var(--bad); background: var(--bad-soft); }
  .btn.danger.solid { background: var(--bad-fill); border-color: var(--bad-fill); color: var(--on-fill); }
  .btn.danger.solid:hover { filter: brightness(1.08); }
  .btn.link.danger:hover, .btn.soft.danger:hover { background: var(--bad-soft); }
  .btn.s { min-height: var(--size-s); padding: var(--s15) var(--s25); font-size: var(--fs-xs);
    gap: var(--s15); }
  .btn.s .icon { width: var(--icon-s); height: var(--icon-s); }
  .btn.block { width: 100%; }
  .btn.icon-only { min-width: var(--size-l); min-height: var(--size-l); padding: 0; }
  .btn.raised { width: var(--size-m); min-width: var(--size-m); height: var(--size-m); min-height: var(--size-m);
    border-radius: var(--r-m); background: var(--surface); color: var(--ink-2);
    box-shadow: var(--shadow); }
  .btn.raised .icon { width: var(--icon); height: var(--icon); }
  @media (min-width: 900px) { .btn.raised { margin-right: var(--s2); } }
  .btn.hold { position: relative; overflow: hidden; touch-action: none; user-select: none; }
  .btn.hold > i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--press);
    pointer-events: none; }
  .btn.hold > span { position: relative; pointer-events: none; }
  /* Busy: a spinner in the button that sent the request. */
  .btn.htmx-request, .htmx-request .btn.primary, .htmx-request .btn.danger.solid, .btn.busy,
  .seg.htmx-request { opacity: .6; pointer-events: none; }
  .btn.htmx-request::after, .htmx-request .btn.primary::after,
  .htmx-request .btn.danger.solid::after, .btn.busy::after { content: "";
    width: var(--icon-s); height: var(--icon-s); border-radius: 50%; border: var(--ring) solid currentColor;
    border-right-color: transparent; animation: spin .7s linear infinite; }
  @media (prefers-reduced-motion: reduce) {
    .btn:active:not(:disabled) { transform: none; }
    .btn.htmx-request::after, .htmx-request .btn.primary::after,
    .htmx-request .btn.danger.solid::after, .btn.busy::after { animation: none; } }
  .actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
  .actions.end { justify-content: flex-end; }
  form.inline { display: inline; }

  /* -- badges: a state or a label, in a tone -------------------------------------------- */
  .badge { --tone: var(--ink-2); --tone-soft: var(--idle-soft); --tone-line: var(--line);
    display: inline-flex; align-items: center; gap: var(--s15); padding: var(--s0) var(--s25);
    border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: var(--fw-semi);
    white-space: nowrap; background: var(--tone-soft); color: var(--tone);
    border: var(--hair) solid transparent; }
  .badge.go { --tone: var(--go); --tone-soft: var(--go-soft); --tone-line: var(--go-line); }
  .badge.wait { --tone: var(--wait); --tone-soft: var(--wait-soft); --tone-line: var(--wait-line); }
  .badge.bad { --tone: var(--bad); --tone-soft: var(--bad-soft); --tone-line: var(--bad-line); }
  .badge.info { --tone: var(--info); --tone-soft: var(--info-soft); --tone-line: var(--info-line); }
  .badge.accent { --tone: var(--accent); --tone-soft: var(--accent-soft); --tone-line: var(--accent-line); }
  .badge.idle { --tone: var(--ink-2); --tone-soft: var(--sunken); --tone-line: var(--line); }
  .badge .icon { width: var(--icon-2xs); height: var(--icon-2xs); stroke-width: 2.6; }
  .badge .dot { width: var(--dot-s); height: var(--dot-s); }
  .badge .sep { width: var(--dot-xs); height: var(--dot-xs); border-radius: 50%; background: currentColor; opacity: .4; }
  .badge.s { padding: var(--s0) var(--s2); font-size: var(--fs-2xs); gap: var(--s1); }
  .badge.outline { border-color: var(--tone-line); }
  .badge.l { padding: var(--s1) var(--s25); gap: var(--s2); }
  .badge.solid { background: var(--fill); color: var(--on-fill); }
  .badge.square { border-radius: var(--r-s); padding: var(--s1) var(--s2); font-weight: var(--fw-bold);
    overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .dot { width: var(--dot); height: var(--dot); border-radius: 50%; background: currentColor; flex: none;
    display: inline-block; }
  @media (prefers-reduced-motion: no-preference) {
    .dot.live { animation: pulse 1.6s ease-out infinite; } }
  .plate { display: inline-flex; align-items: center; padding: var(--hair) var(--s15); border-radius: var(--r-xs);
    border: var(--hair) solid var(--line); background: var(--paper); color: var(--ink-2);
    font-size: .78em; font-weight: var(--fw-bold); letter-spacing: var(--ls-caps); white-space: nowrap; }
  a.plate { padding: var(--s1) var(--s25); min-height: var(--size-s); border-radius: var(--r-s);
    background: var(--surface); color: var(--ink); font-size: var(--fs-xs); letter-spacing: var(--ls-caps); }
  a.plate:hover { text-decoration: none; border-color: var(--fill); }

  /* -- notices and callouts --------------------------------------------------------------- */
  .notice { --tone: var(--accent); --tone-soft: var(--accent-soft);
    padding: var(--s25) var(--s35); border-radius: var(--r-m); background: var(--tone-soft);
    color: var(--tone); margin-bottom: var(--s3); font-weight: var(--fw-medium); }
  .notice.bad { --tone: var(--bad); --tone-soft: var(--bad-soft); }
  .notice.go { --tone: var(--go); --tone-soft: var(--go-soft); }
  .notice.wait { --tone: var(--wait); --tone-soft: var(--wait-soft); }
  /* A card that explains a state: icon, title, a line of text, maybe an action. */
  .callout { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s3);
    background: var(--tone-soft, var(--sunken)); border: var(--hair) solid var(--tone-line, var(--line));
    border-radius: var(--r-l); padding: var(--s3) var(--s4); color: var(--ink); }
  .callout > .grow { flex: 1 1 220px; min-width: 0; }
  .callout strong { display: block; font-size: var(--fs-m); line-height: 1.35; }
  .callout p { margin: var(--s0) 0 0; font-size: var(--fs-s); line-height: 1.5; color: var(--ink-2); }
  .callout.bad { color: var(--bad); }
  .callout .btn { flex: none; align-self: center; }
  /* An icon on a soft square in its tone. */
  .icon-tile { --tone: var(--accent); width: var(--size-m); height: var(--size-m); border-radius: var(--r-m);
    flex: none; display: grid; place-items: center; color: var(--tone);
    background: color-mix(in srgb, var(--tone) 14%, var(--surface)); }
  .icon-tile .icon { width: var(--icon); height: var(--icon); }
  .icon-tile.s { width: var(--size-xs); height: var(--size-xs); border-radius: var(--r-s); }
  .icon-tile.s .icon { width: var(--icon-m); height: var(--icon-m); }
  .icon-tile.l { width: var(--size-l); height: var(--size-l); }
  .icon-tile.idle { --tone: var(--ink-2); background: var(--sunken); }
  .icon-tile.go { --tone: var(--go); } .icon-tile.info { --tone: var(--info); }
  .icon-tile.wait { --tone: var(--wait); } .icon-tile.bad { --tone: var(--bad); }
  .icon-tile.series { --tone: var(--series-1); }

  /* -- chips: filters and quick choices ---------------------------------------------------- */
  .chips { display: flex; flex-wrap: wrap; gap: var(--s15); }
  .chip { display: inline-flex; align-items: center; gap: var(--s15); min-height: var(--size-s);
    padding: 0 var(--s25); border-radius: var(--r-pill); border: var(--hair) solid var(--line);
    color: var(--ink-2); font: inherit; font-size: var(--fs-s); background: var(--surface);
    cursor: pointer; }
  .chip:hover { text-decoration: none; border-color: var(--ink-3); }
  .chip[aria-current], .chip[aria-pressed="true"] { background: var(--accent-soft);
    border-color: transparent; color: var(--accent); font-weight: var(--fw-semi); }
  @media (pointer: coarse) { .chip { min-height: var(--size-m); padding: 0 var(--s35); } }

  /* One choice out of a few, side by side: links, buttons or radios. */
  .seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--s0);
    padding: var(--s1); background: var(--sunken); border-radius: var(--r-m); margin-bottom: var(--s3); }
  .seg > a, .seg button, .seg label span { display: flex; align-items: center; justify-content: center;
    min-height: var(--size-l); padding: 0 var(--s15); border: 0; border-radius: var(--r-s); background: none;
    font: inherit; font-weight: var(--fw-semi); color: var(--ink-2); cursor: pointer;
    text-align: center; line-height: 1.2; }
  .seg > a { min-height: 0; padding: var(--s15) var(--s1); font-size: var(--fs-s); }
  /* Between the administration and the driver's own view, at the top of the side bar. */
  .area-switch { flex: none; }
  .seg > a:hover { text-decoration: none; color: var(--ink); }
  .seg button { min-height: var(--tap); }
  .seg > a[aria-current], .seg button[aria-pressed="true"], .seg label input:checked + span {
    background: var(--surface); color: var(--ink);
    box-shadow: inset 0 0 0 var(--hair) var(--line-strong), var(--shadow); }
  .seg label { position: relative; display: flex; cursor: pointer; }
  .seg label span { flex: 1; }
  .seg label input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%;
    margin: 0; cursor: pointer; }
  .seg label input:focus-visible + span { outline: var(--ring) solid var(--accent); outline-offset: var(--ring); }
  .segfield { border: 0; padding: 0; min-width: 0; }

  /* Choice buttons in a grid (plan: hours, energy). Buttons with aria-pressed or radios. */
  .chipset { display: grid; gap: var(--s15); margin: var(--s15) 0 var(--s1); }
  .chipset.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .chipset.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: var(--s3); }
  .chipset button, .chipset.radios span { min-height: var(--size-l); padding: var(--s15) var(--s0);
    border-radius: var(--r-m); border: var(--hair) solid var(--line); background: var(--sunken);
    color: var(--ink-2); font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-semi);
    cursor: pointer; line-height: 1.2; }
  .chipset button strong { display: block; font-size: var(--fs-xs); font-weight: var(--fw-bold); }
  .chipset button span { display: block; font-size: var(--fs-2xs); opacity: .75; }
  .chipset button[aria-pressed="true"], .chipset.radios input:checked + span {
    background: var(--fill); border-color: var(--fill); color: var(--on-fill);
    font-weight: var(--fw-bold); }
  .chipset.three button[aria-pressed="true"] { background: var(--go-soft); color: var(--go); }
  .chipset.radios label { position: relative; display: flex; }
  .chipset.radios input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%;
    margin: 0; cursor: pointer; }
  .chipset.radios span { flex: 1; display: flex; align-items: center; justify-content: center; }
  .chipset.radios input:focus-visible + span { outline: var(--ring) solid var(--accent); outline-offset: var(--ring); }
  /* Choices that save with one tap. */
  .quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2);
    margin-bottom: var(--s4); }
  .quick .btn { flex-direction: column; gap: 0; padding: var(--s2) var(--s3); min-height: var(--size-2xl);
    line-height: 1.25; white-space: normal; }
  .quick .btn span { font-weight: var(--fw-medium); color: var(--ink-2); font-size: var(--fs-s); }
  .quick .btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

  /* -- figures: a label, a value, a line below ------------------------------------------- */
  .stats { display: grid; gap: var(--s3); grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: var(--s4); }
  .stats.four { margin-bottom: var(--s3); }
  @media (min-width: 900px) { .stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
  @media (min-width: 600px) { .stats.auto { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); } }
  @media (min-width: 1200px) { .stats.auto { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); } }
  .stat { display: flex; flex-direction: column; gap: var(--s0); min-width: 0;
    background: var(--surface); border: var(--hair) solid var(--line); border-radius: var(--r-l);
    padding: var(--s3) var(--s4); box-shadow: var(--shadow); }
  .stat.well { background: var(--sunken); border-color: transparent; box-shadow: none;
    border-radius: var(--r-m); padding: var(--s3); }
  .stat .label { display: flex; align-items: center; gap: var(--s15); color: var(--ink-2);
    font-size: var(--fs-s); min-width: 0; }
  .stat .label > span:not(.badge, .share, .sub) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .stat .label .icon { width: var(--icon-m); height: var(--icon-m); }
  .stat .label .badge, .stat .label .share { margin-left: auto; }
  .stat .value { display: flex; align-items: baseline; gap: var(--s15); font-size: var(--fs-xl);
    font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); line-height: 1.2;
    font-variant-numeric: tabular-nums; }
  .stat .value small { font-size: var(--fs-m); font-weight: var(--fw-medium); color: var(--ink-2);
    letter-spacing: 0; }
  .stat .value .share { margin-left: auto; }
  .stat.s .value { font-size: var(--fs-l); }
  .stat .sub { font-size: var(--fs-s); color: var(--ink-3); }
  .stat .sub.split { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
  .stat .sub.split .bar { flex: 0 0 56px; margin: 0; }
  .stat .share { font-size: var(--fs-s); font-weight: var(--fw-bold); color: var(--ink-2); }
  .stat .bar.thin { --bar-h: 5px; --bar-fill: var(--go); margin-top: var(--s2); }
  .stat.is-bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
  .stat.is-bad .value .share { color: var(--bad); }
  /* Change against the period before. */
  .delta.up::before { content: "▲ "; color: var(--go); }
  .delta.down::before { content: "▼ "; color: var(--bad); }
  @media (max-width: 599px) {
    .stats { gap: var(--s2); margin-bottom: var(--s3); }
    .stat { padding: var(--s25) var(--s3); }
    .stat .value { font-size: var(--fs-l); }
    .stat.s .value { font-size: var(--fs-base); }
  }

  /* -- bars: a share of something; --w sets the width, --bar-h and --bar-fill the look ---- */
  .bar { --bar-h: 8px; --bar-fill: var(--accent); display: block; height: var(--bar-h);
    border-radius: var(--r-pill); background: var(--sunken); overflow: hidden; }
  .bar > i { display: block; height: 100%; width: var(--w, 0%); border-radius: inherit;
    background: var(--bar-fill); transition: width .6s ease; }
  .bar.thin { --bar-h: 4px; --bar-fill: var(--series-1); margin-top: var(--s15); max-width: var(--w-narrow); }
  .bar.thin > i { transition: none; }
  .bar.high { --bar-fill: var(--wait); }
  .bar.over { --bar-fill: var(--bad); }
  @media (prefers-reduced-motion: reduce) { .bar > i { transition: none; } }
  /* Shares of the sources of a quarter hour, side by side. */
  .mix { display: flex; height: var(--dot-s); margin-top: var(--s15); max-width: var(--w-narrow); border-radius: var(--r-xs);
    overflow: hidden; background: var(--sunken); gap: var(--s0); }
  .mix i { display: block; height: 100%; width: var(--w, 0%); }
  .from-grid { --swatch: var(--series-1); }
  .from-pv { --swatch: var(--solar); }
  .from-battery { --swatch: var(--battery); }
  .mix .from-grid, .mix .from-pv, .mix .from-battery { background: var(--swatch); }
  .legend { display: inline-flex; flex-wrap: wrap; gap: var(--s2) var(--s4); color: var(--ink-2);
    font-size: var(--fs-s); }
  .legend.below { display: flex; margin: var(--s3) 0 0; }
  .legend span { display: inline-flex; align-items: center; gap: var(--s15); }
  .swatch { width: var(--icon-xs); height: var(--icon-2xs); border-radius: var(--r-xs); display: inline-block;
    background: var(--swatch, var(--ink-3)); }
  .swatch.line { height: var(--dot-xs); border-radius: var(--s0); }

  /* -- conductor gauge: the signature element ---------------------------------------------- */
  .gauge { display: grid; gap: var(--s2) var(--s3); grid-template-columns: repeat(3, 1fr); }
  .gauge.big { grid-template-columns: 1fr; gap: var(--s3); }
  @media (min-width: 600px) { .gauge:not(.big) { gap: var(--s2) var(--s4); } }
  .gauge .cap { display: flex; justify-content: space-between; font-size: var(--fs-xs);
    white-space: nowrap; color: var(--ink-2); margin-bottom: var(--s1); }
  .gauge.big .cap { justify-content: flex-start; align-items: center; gap: var(--s2);
    font-size: var(--fs-m); margin-bottom: var(--s15); }
  .gauge.big .cap .conductor { display: inline-flex; align-items: center; justify-content: center;
    min-width: var(--size-s); height: var(--icon-xl); padding: 0 var(--s15); border-radius: var(--r-s); background: var(--sunken);
    color: var(--ink); font-size: var(--fs-xs); font-weight: var(--fw-bold); }
  .gauge.big .cap strong { color: var(--ink); font-size: var(--fs-m); }
  .gauge.big .cap .percent { margin-left: auto; font-weight: var(--fw-bold); color: var(--ink-3); }
  .gauge.big .bar { --bar-h: 12px; position: relative; overflow: visible; }
  .gauge.big .bar > .mark { position: absolute; top: -3px; bottom: -3px; width: 0;
    left: var(--at); border-left: var(--ring) dashed var(--ink-2); }
  .gauge-note { margin: var(--s2) 0 0; font-size: var(--fs-xs); color: var(--ink-3); text-align: right; }

  /* -- forms ------------------------------------------------------------------------------ */
  .field { display: block; margin-bottom: var(--s3); }
  .field > span, .field > label > span, .choices legend, .segfield legend {
    display: block; font-size: var(--fs-m); color: var(--ink-2); margin-bottom: var(--s1);
    font-weight: var(--fw-medium); padding: 0; }
  .field .hint { margin: var(--s1) 0 0; }
  .field .error { color: var(--bad); font-size: var(--fs-m); margin-top: var(--s1); display: block; }
  .field.invalid input, .field.invalid select { border-color: var(--bad); }
  .field.compact { max-width: var(--w-xs); }
  .field output { float: right; font-weight: var(--fw-bold); color: var(--ink); }
  .fields { display: grid; gap: 0 var(--s4); grid-template-columns: 1fr; }
  @media (min-width: 600px) { .fields { grid-template-columns: 1fr 1fr; } }
  .pair, .days { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s3); }
  .inline-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
    margin-top: var(--s3); }
  .inline-row > input, .inline-row > select { flex: 1 1 200px; width: auto; min-width: 0; }
  /* A checkbox with its text (and a hint below); a group of them on one line. */
  .check-line { display: flex; align-items: flex-start; gap: var(--s15); margin-bottom: var(--s3);
    cursor: pointer; }
  .check-line input { flex: none; margin-top: var(--s1); }
  .check-line .hint { margin: var(--s0) 0 0; }
  .check-line.s { align-items: center; font-size: var(--fs-s); padding: var(--s2) 0; margin: 0;
    color: var(--ink-2); }
  .check-line.s input { margin-top: 0; }
  .check-group { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); margin: 0 0 var(--s3); }
  .check-group label { display: inline-flex; align-items: center; gap: var(--s1); cursor: pointer; }
  /* Choices with a title and a line of text. */
  .choices { display: grid; gap: var(--s2); margin-bottom: var(--s3); border: 0; padding: 0;
    min-width: 0; }
  .choice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s25) var(--s3);
    border: var(--hair) solid var(--line); border-radius: var(--r-m); cursor: pointer;
    transition: border-color .15s var(--ease), background-color .15s var(--ease); }
  .choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
  .choice:has(input:disabled) { opacity: .55; cursor: not-allowed; }
  .choice input { margin-top: var(--s1); flex: none; }
  .choice strong { display: block; font-weight: var(--fw-semi); }
  .choice small { color: var(--ink-2); font-size: var(--fs-s); }
  .stepper { display: grid; grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap); gap: var(--s1); }
  .stepper input { text-align: center; font-variant-numeric: tabular-nums; }
  .stepper .btn { padding: 0; font-size: var(--fs-l); }
  .slider { width: 100%; min-height: var(--size-xs); margin: 0; }
  .slider-scale { display: flex; justify-content: space-between; font-size: var(--fs-2xs);
    color: var(--ink-3); font-weight: var(--fw-medium); }
  .filters { padding-bottom: var(--s2); }
  .filters .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
  @media (min-width: 900px) { .filters .fields { grid-template-columns: repeat(3, minmax(0, 200px)) auto; } }
  .search { position: relative; flex: 1 1 100%; max-width: var(--w-narrow); }
  @media (min-width: 600px) { .search { flex: 1 1 240px; } }
  .search .icon { position: absolute; left: var(--s3); top: var(--s3); color: var(--ink-3); }
  .search input { padding-left: var(--size-l); }
  /* A small search in a toolbar. */
  .search.compact { flex: 0 1 260px; margin-left: auto; }
  .search.compact label { display: flex; align-items: center; gap: var(--s15); padding: 0 var(--s25);
    min-height: var(--size-m); border: var(--hair) solid var(--line); border-radius: var(--r-m);
    background: var(--surface); color: var(--ink-3); }
  .search.compact label:focus-within { border-color: var(--accent); }
  .search.compact input { flex: 1; min-width: 0; border: 0; padding: 0; background: none;
    font-size: var(--fs-m); outline: none; min-height: 0; }
  .search.compact .icon { position: static; width: var(--icon-m); height: var(--icon-m); }
  @media (max-width: 899px) { .search.compact { flex: 1 1 100%; order: 3; margin-left: 0; } }
  /* Period: two days and a step back or forward. */
  .period { display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; }
  .period input[type=date], .period select { width: auto; min-height: var(--size-l); padding: 0 var(--s2); }
  .period .btn[aria-disabled] { opacity: .35; pointer-events: none; }
  .period .btn.back .icon { transform: rotate(180deg); }
  .period strong { padding: 0 var(--s2); white-space: nowrap; }
  /* With the script the form sends itself on a change; the button is the fallback. */
  .js .period .submit { display: none; }
  @media (max-width: 599px) {
    .period { flex-wrap: nowrap; width: 100%; }
    .period:has(select) { flex-wrap: wrap; }
    .period select { flex: 1 1 100%; }
    .period input[type=date] { flex: 1 1 0; min-width: 0; padding: 0 var(--s15); }
    .period .btn.icon-only { flex: none; min-width: var(--size-s); }
  }

  /* -- avatar ------------------------------------------------------------------------------ */
  .avatar { --h: 200; width: var(--size-m); height: var(--size-m); border-radius: 50%; flex: none;
    display: inline-flex; align-items: center; justify-content: center; object-fit: cover;
    font-size: var(--fs-s); font-weight: var(--fw-bold); letter-spacing: var(--ls-wide);
    background: light-dark(hsl(var(--h) 45% 88%), hsl(var(--h) 30% 26%));
    color: light-dark(hsl(var(--h) 55% 26%), hsl(var(--h) 60% 84%)); }
  .avatar.s { width: var(--size-xs); height: var(--size-xs); font-size: var(--fs-2xs); }
  .avatar.l { width: var(--size-2xl); height: var(--size-2xl); font-size: var(--fs-base); }
  .avatar.xl { --d: 88px; width: var(--d); height: var(--d); font-size: var(--fs-2xl); }
  /* An operator's picture is square; a person's stays round. */
  .avatar.sq { border-radius: 22%; }
  .avatar.anon { background: var(--sunken); color: var(--ink-3); }
  .avatar.anon .icon { width: var(--icon-m); height: var(--icon-m); }
  @media (max-width: 599px) { .avatar.xl { --d: 64px; font-size: var(--fs-l); } }

  /* -- menu: a panel that opens from a summary --------------------------------------------- */
  .menu { position: relative; }
  .menu > summary { list-style: none; min-height: 0; cursor: pointer; border-radius: 50%;
    display: flex; margin: 0; }
  .menu > summary::-webkit-details-marker { display: none; }
  .menu-panel { position: absolute; right: 0; top: calc(100% + var(--s2)); z-index: var(--z-menu);
    width: var(--w-menu); background: var(--surface); border: var(--hair) solid var(--line);
    border-radius: var(--r-l); box-shadow: var(--shadow-raised); padding: var(--s2); }
  .menu-who { padding: var(--s2) var(--s3) var(--s3); border-bottom: var(--hair) solid var(--line);
    margin-bottom: var(--s2); }
  .menu-who strong, .menu-who span { display: block; overflow: hidden; text-overflow: ellipsis; }
  .menu-who span { font-size: var(--fs-s); color: var(--ink-2); }
  .menu-panel a:not(.chip), .menu-panel button { display: flex; align-items: center;
    gap: var(--s3); width: 100%; padding: var(--s25) var(--s3); border: 0; background: none;
    border-radius: var(--r-m); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
  .menu-panel a:not(.chip):hover, .menu-panel button:hover { background: var(--sunken);
    text-decoration: none; }
  .menu-panel form { margin: 0; }
  .menu-version { padding: var(--s2) var(--s3) var(--s1); font-size: var(--fs-xs); color: var(--ink-3);
    border-top: var(--hair) solid var(--line); margin-top: var(--s1); }
  @media (max-width: 899px) {
    /* The user menu opens from the picture in the header as a sheet from below; its
       entries end above the navigation. */
    .top-menu[open] > summary::before, body:not(.has-nav) .menu[open] > summary::before {
      content: ""; position: fixed; inset: 0; z-index: calc(var(--z-menu) - 1);
      background: var(--scrim); cursor: default; }
    .top-menu .menu-panel, body:not(.has-nav) .menu-panel { position: fixed; inset: auto 0 0 0;
      width: auto; border-width: var(--hair) 0 0; top: auto; border-radius: var(--r-l) var(--r-l) 0 0;
      padding: var(--s3); }
    body.has-nav .top-menu .menu-panel { padding-bottom: calc(var(--tabbar) + var(--s2)); }
    body:not(.has-nav) .menu-panel { bottom: 0;
      padding-bottom: calc(var(--s3) + env(safe-area-inset-bottom)); }
    .menu-panel a:not(.chip), .menu-panel button { min-height: var(--size-xl); }
  }

  /* -- dialog: centred on wide screens, a sheet from below on a phone ----------------------- */
  dialog#modal { border: 0; padding: 0; border-radius: var(--r-l); background: var(--surface);
    color: var(--ink); width: min(var(--w-form), calc(100vw - var(--icon-2xl))); max-height: calc(100dvh - var(--icon-2xl));
    box-shadow: var(--shadow-dialog); }
  dialog#modal.wide { width: min(var(--w-wide), calc(100vw - var(--icon-2xl))); }
  dialog#modal::backdrop { background: var(--scrim); }
  dialog#modal[open] { display: flex; flex-direction: column; overflow: hidden; }
  #modal-body { padding: var(--s4) var(--s5) 0; overflow-y: auto; min-height: 0;
    overscroll-behavior: contain; }
  #modal-body::after { content: ""; display: block; height: var(--s5); }
  .modal-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
  .modal-head h2 { flex: 1; margin: 0; font-size: var(--fs-l); }
  .modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center;
    gap: var(--s2); margin-top: var(--s4); position: sticky; bottom: 0; background: var(--surface);
    padding: var(--s3) 0 0; }
  .modal-foot > .btn.link.danger { margin-right: auto; }
  /* The detail of a connector: on wide screens a panel at the right. */
  .drawer-actions { display: grid; gap: var(--s2); margin-top: var(--s4); }
  @media (min-width: 900px) {
    dialog#modal:has([data-drawer]) { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh;
      width: min(var(--w-narrow), 100vw); border-radius: 0; border-left: var(--hair) solid var(--line); }
    dialog#modal:has([data-drawer]) #modal-body { flex: 1; } }
  @media (min-width: 900px) and (prefers-reduced-motion: no-preference) {
    dialog#modal[open]:has([data-drawer]) { animation: drawer .22s cubic-bezier(.16, 1, .3, 1); }
    @keyframes drawer { from { transform: translateX(40px); opacity: .6; } } }
  @media (max-width: 899px) {
    /* Where there is a tab bar the sheet ends above it and is opened without making the
       page inert, so nothing ever covers the navigation. */
    dialog#modal, dialog#modal.wide { width: 100vw; max-width: 100vw; margin: auto 0 0;
      max-height: 88dvh; border-radius: var(--r-l) var(--r-l) 0 0; }
    body.has-nav dialog#modal[open] { position: fixed; inset: auto 0 0 0; z-index: var(--z-sheet);
      padding-bottom: var(--tabbar); }
    body.has-nav dialog#modal[open] + #modal-backdrop { display: block; position: fixed;
      inset: 0; z-index: calc(var(--z-sheet) - 1); background: var(--scrim); }
    #modal-body { padding: var(--s2) var(--s4) 0; }
    #modal-body::before { content: ""; display: block; width: var(--size-m); height: var(--r-xs);
      border-radius: var(--s0); background: var(--line); margin: 0 auto var(--s2); }
    #modal-body::after { height: var(--s4); }
    body:not(.has-nav) #modal-body::after { height: calc(var(--s4) + env(safe-area-inset-bottom)); }
    .modal-foot .btn { flex: 1; }
  }
  @media (max-width: 599px) { .modal-foot .btn { font-size: var(--fs-m); padding: 0 var(--s2); } }
  @media (max-width: 899px) and (prefers-reduced-motion: no-preference) {
    dialog#modal[open] { animation: sheet .2s ease-out; }
    @keyframes sheet { from { transform: translateY(24px); opacity: 0; } } }

  /* -- toasts: a message after an action, above the lower edge ------------------------------ */
  .toasts { position: fixed; left: 0; right: 0; z-index: var(--z-toast); pointer-events: none;
    bottom: calc(var(--tabbar) + var(--s3)); display: flex; flex-direction: column;
    align-items: center; gap: var(--s2); padding: 0 var(--s3); }
  .toast { pointer-events: auto; margin: 0; max-width: var(--w-narrow); padding: var(--s25) var(--s4);
    border-radius: var(--r-m); background: var(--ink); color: var(--paper);
    font-weight: var(--fw-medium); box-shadow: var(--shadow-raised); cursor: pointer; }
  .toast.bad { background: var(--bad-fill); color: var(--on-fill); }
  .toast.wait { background: var(--wait); color: var(--on-wait); }
  .toast.go { animation: toast-out .4s ease 3.5s forwards; }
  @keyframes toast-out { to { opacity: 0; visibility: hidden; } }
  @media (min-width: 900px) { .toasts { bottom: var(--s5); }
    body.has-nav .toasts { left: var(--side); } }

  /* -- tables --------------------------------------------------------------------------- */
  .table-wrap { overflow-x: auto; }
  .ranking td:first-child { --col: 180px; min-width: var(--col); }
  .ranking .bar { --bar-h: 4px; --bar-fill: var(--series-1); margin-top: var(--s15); max-width: var(--w-narrow); }
  .ranking .bar > i { transition: none; }
  .ranking .who { display: flex; align-items: center; gap: var(--s2); }
  .ranking .who > span { min-width: 0; }
  @media (max-width: 599px) { .ranking td:first-child { --col: 140px; white-space: normal; } }
  .sortable th a { color: inherit; }
  /* A name with its picture (operators of the platform). */
  .operators td a.who { display: inline-flex; align-items: center; gap: var(--s2); color: var(--ink);
    font-weight: var(--fw-semi); }
  .operators td a.who:hover { text-decoration: none; color: var(--accent); }
  .operators td { vertical-align: middle; }
  .operators td a.who { white-space: nowrap; }
  .operators td.address { --col: 170px; min-width: var(--col); }
  .sortable th a[aria-current] { color: var(--ink); font-weight: var(--fw-bold); }
  .sortable th a[aria-current]::after { content: " ↓"; }
  /* Many rows to scan (quarter hours): less padding, smaller type. */
  table.dense td, table.dense th { padding-top: var(--s15); padding-bottom: var(--s15); font-size: var(--fs-s); }
  /* Heat map: one cell per hour and weekday, five shades of the first series. */
  .heat-wrap { overflow-x: auto; }
  .heat { border-collapse: separate; border-spacing: var(--s0); min-width: var(--w-dialog); font-size: var(--fs-xs); }
  .heat th, .heat td { border: 0; padding: 0; }
  .heat th { text-align: left; font-weight: var(--fw-medium); color: var(--ink-2); padding-right: var(--s15); }
  .heat tr:first-child th { height: var(--icon); }
  .heat td { height: var(--icon-xl); border-radius: var(--r-xs); background: var(--sunken); }
  .heat td.sum { background: none; padding-left: var(--s3); white-space: nowrap; }
  .h1 { background: color-mix(in srgb, var(--series-1) 25%, var(--sunken)) !important; }
  .h2 { background: color-mix(in srgb, var(--series-1) 50%, var(--sunken)) !important; }
  .h3 { background: color-mix(in srgb, var(--series-1) 75%, var(--sunken)) !important; }
  .h4 { background: var(--series-1) !important; }
  .heat-legend { display: flex; align-items: center; gap: var(--s1); margin: var(--s2) 0; }
  .heat-legend i { width: var(--icon-s); height: var(--icon-s); border-radius: var(--r-xs); background: var(--sunken); }

  /* -- code with a copy button ---------------------------------------------------------- */
  .code { position: relative; background: var(--sunken); border-radius: var(--r-m);
    margin: var(--s2) 0 var(--s3); max-width: 100%; }
  .code pre { margin: 0; padding: var(--s3) calc(var(--size-l) + var(--s3)) var(--s3) var(--s3); overflow-x: auto;
    font-size: var(--fs-s); line-height: 1.5; }
  .code code { overflow-wrap: normal; white-space: pre; }
  .code > .btn { position: absolute; top: var(--s1); right: var(--s1); background: var(--sunken); }
  pre.code { margin: 0; padding: var(--s3); overflow-x: auto; font-size: var(--fs-s); line-height: 1.5; }
  .copy-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0;
    border-top: var(--hair) solid var(--line); flex-wrap: wrap; }
  .copy-row > span:first-child { flex: 0 0 120px; font-size: var(--fs-m); color: var(--ink-2); }
  .copy-row code { flex: 1 1 200px; min-width: 0; }
  /* On a phone the label stands above; value and copy button share a line (VIS-08). */
  @media (max-width: 599px) {
    .copy-row { row-gap: var(--s1); }
    .copy-row > span:first-child { flex-basis: 100%; }
    .copy-row code { flex: 1 1 0; }
  }
  @media (max-width: 599px) { .code pre { font-size: var(--fs-xs); } }

  /* -- charts: two drawings of the same data; the screen width picks one ------------------ */
  .chart { margin: var(--s3) 0 0; }
  .chart figcaption { display: flex; align-items: center; gap: var(--s4); font-size: var(--fs-m);
    margin-bottom: var(--s1); }
  .chart-plot { position: relative; }
  .chart-plot.narrow { display: none; }
  .chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
  .chart .grid { stroke: var(--line); stroke-width: 1; }
  .chart .axis { stroke: var(--ink-3); stroke-width: 1; }
  .chart .tick, .chart .end { font-size: var(--fs-chart); fill: var(--ink-2);
    font-variant-numeric: tabular-nums; }
  .chart .end { fill: var(--ink); font-weight: var(--fw-semi); }
  .chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
  .chart .dot { stroke: var(--surface); stroke-width: 2; }
  .chart .cross { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
  .s1 { --swatch: var(--series-1); stroke: var(--series-1); }
  .s2 { --swatch: var(--series-2); stroke: var(--series-2); }
  .s3 { --swatch: var(--series-3); stroke: var(--series-3); }
  .dot.s1, .dot.s2, .dot.s3 { fill: var(--swatch); }
  .chart.bars .bar-mark { fill: var(--series-1); }
  .chart.bars .hit { fill: transparent; }
  .chart.bars .bar-slot:hover .hit { fill: var(--sunken); }
  .tip { position: absolute; top: var(--s1); pointer-events: none; background: var(--surface);
    border: var(--hair) solid var(--line); border-radius: var(--r-s); box-shadow: var(--shadow);
    padding: var(--s15) var(--s25); font-size: var(--fs-xs); white-space: nowrap; z-index: 2;
    font-variant-numeric: tabular-nums; }
  .tip b { display: block; color: var(--ink-2); font-weight: var(--fw-medium); }
  .tip span { display: flex; align-items: center; gap: var(--s15); }
  @media (max-width: 599px) {
    .chart-plot.wide { display: none; }
    .chart-plot.narrow { display: block; }
    .chart .tick { font-size: var(--fs-chart-l); }
    .chart figcaption { flex-wrap: wrap; gap: var(--s0) var(--s3); }
  }

  /* -- steps of an assistant ------------------------------------------------------------------ */
  .steps { list-style: none; display: flex; gap: var(--s2); padding: 0; margin: 0 0 var(--s4);
    overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .steps li { display: flex; align-items: center; gap: var(--s2); flex: 1 0 auto; margin: 0;
    padding: var(--s2) var(--s3); border-radius: var(--r-m); background: var(--surface);
    border: var(--hair) solid var(--line); color: var(--ink-3); font-size: var(--fs-s);
    font-weight: var(--fw-semi); white-space: nowrap; }
  .steps li .n { width: var(--icon-xl); height: var(--icon-xl); border-radius: 50%; display: inline-flex;
    align-items: center; justify-content: center; background: var(--sunken); font-size: var(--fs-xs); }
  .steps li[aria-current] { color: var(--ink); border-color: var(--fill); }
  .steps li[aria-current] .n { background: var(--fill); color: var(--on-fill); }
  .steps li.past .n { background: var(--go-soft); color: var(--go); }
  /* On a phone only the current step shows its name; the others their number, the name
     kept for screen readers (CRAWL-01). */
  @media (max-width: 599px) {
    .steps { overflow: visible; }
    .steps li { flex: none; padding: var(--s15); }
    .steps li[aria-current] { flex: 1 1 auto; min-width: 0; padding-right: var(--s3); }
    .steps li:not([aria-current]) .step-name { position: absolute; width: var(--hair);
      height: var(--hair); overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .steps li[aria-current] .step-name { overflow: hidden; text-overflow: ellipsis; }
  }
  .check { width: var(--icon-2xl); height: var(--icon-2xl); border-radius: 50%; border: var(--ring) solid var(--line);
    flex: none; display: flex; align-items: center; justify-content: center; }
  .check.done { background: var(--fill); border-color: var(--fill); color: var(--on-fill); }
  .check .icon { width: var(--icon-s); height: var(--icon-s); stroke-width: 2.6; }

  /* -- tiles that lead to an area (setup, help, planned features) ----------------------------- */
  .areas { display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 600px) { .areas { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  @media (min-width: 1200px) { .areas { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .areas.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
  .areas + h2 { margin-top: var(--s5); }
  .area { --block: 168px; display: flex; flex-direction: column; gap: var(--s2); margin: 0;
    color: inherit; min-height: var(--block); }
  div.area { cursor: default; }
  .area-head { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s1); }
  .area-head strong { font-size: var(--fs-base); flex: 1; min-width: 0; }
  .area-text { color: var(--ink-2); font-size: var(--fs-m); line-height: 1.45; }
  @media (max-width: 599px) {
    .area { min-height: 0; display: grid; grid-template-columns: 40px minmax(0, 1fr);
      column-gap: var(--s3); row-gap: var(--s0); }
    .area .icon-tile { grid-row: 1 / span 2; }
    .area-head { margin: 0; } }

  /* -- a planned feature: soon -------------------------------------------------------------- */
}

/* == pages ============================================================================= */
@layer pages {
  /* Sign-in under an operator's own address: its logo and app name above the forms. */
  /* Platform: the derived brand colours shown in both themes before they are used. */
  .brand-previews { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: var(--s2); margin: var(--s3) 0; }
  .brand-preview { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2);
    padding: var(--s3); border: var(--hair) solid var(--line); border-radius: var(--r-m);
    background: var(--surface); color: var(--ink); }
  .brand-preview.light { color-scheme: light; }
  .brand-preview.dark { color-scheme: dark; }
  .brand-preview .meta { flex-basis: 100%; }
  .link-sample { color: var(--accent); text-decoration: underline; }
  .login-brand { display: flex; align-items: center; gap: var(--s3); margin: var(--s2) 0 var(--s4);
    font-size: var(--fs-l); }
  /* -- live view ------------------------------------------------------------------------ */
  .live-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s15) var(--s3);
    margin: calc(var(--s1) * -1) 0 var(--s3); font-size: var(--fs-s); color: var(--ink-2); }
  .live-grid { display: grid; gap: 0 var(--s4); grid-template-columns: minmax(0, 1fr); align-items: start; }
  .live-grid > * { min-width: 0; }
  @media (min-width: 1200px) { .live-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); } }
  @media (min-width: 1700px) { main.wide .live-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }
  .live-strip { position: sticky; top: var(--topbar); z-index: var(--z-sticky); display: flex;
    align-items: center; gap: var(--s3); padding: var(--s2) 0; margin-bottom: var(--s2);
    background: var(--surface); }
  .live-strip strong { font-size: var(--fs-base); white-space: nowrap; }
  .live-strip .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; min-width: 0; }
  .live-strip .chips::-webkit-scrollbar { display: none; }
  .live-strip .chip { flex: none; }
  @media (min-width: 900px) { .live-strip { position: static; padding: 0; background: none; } }
  [data-show="charging"] .cp:not(.is-charging), [data-show="waiting"] .cp:not(.is-waiting),
  [data-show="fault"] .cp:not(.is-fault):not(.is-offline) { display: none; }
  [data-show="charging"] .station:not(:has(.cp.is-charging)),
  [data-show="waiting"] .station:not(:has(.cp.is-waiting)),
  [data-show="fault"] .station:not(:has(.cp.is-fault, .cp.is-offline)) { display: none; }
  .states { display: flex; flex-wrap: wrap; gap: var(--s15); margin-top: var(--s2); }
  .imbalance { font-size: var(--fs-s); font-weight: var(--fw-bold); color: var(--ink-2); white-space: nowrap; }
  .imbalance.bad { color: var(--bad); }
  /* Electrical nodes of the live view, foldable. */
  .node { margin-top: var(--s5); }
  .node:first-child { margin-top: 0; }
  .node > .head { margin-bottom: var(--s2); gap: var(--s2); }
  .node .node { margin-top: var(--s4); padding-left: var(--s4); border-left: var(--ring) solid var(--line); }
  .node-sum { margin: var(--s2) 0 0; }
  .fold .icon { transform: rotate(90deg); transition: transform .15s; }
  .node.folded > .head .fold .icon { transform: rotate(0deg); }
  .node.folded > .node-body { display: none; }
  @media (max-width: 599px) { .node .node { margin-top: var(--s3); padding-left: var(--s3); } }
  /* Charge points: tiles; on a phone, and within a station, rows. */
  .cps { display: grid; gap: var(--s3); margin-top: var(--s3);
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .cp { --state: var(--idle); display: block; color: inherit; background: var(--surface);
    border: var(--hair) solid var(--line); border-left: var(--stripe) solid var(--state); border-radius: var(--r-m);
    --block: 104px; padding: var(--s3); min-height: var(--block); cursor: pointer;
    transition: box-shadow .15s var(--ease), border-color .15s var(--ease); }
  a.cp:hover { text-decoration: none; box-shadow: var(--shadow); }
  .cp.is-charging { --state: var(--go); }
  .cp.is-waiting { --state: var(--wait); }
  .cp.is-plugged { --state: var(--info); }
  .cp.is-fault { --state: var(--bad); }
  .cp.is-offline { --state: var(--line); background: var(--sunken); color: var(--ink-2); }
  .cp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s2); }
  .cp-name { flex: 1 1 auto; min-width: 0; font-weight: var(--fw-semi); overflow-wrap: anywhere; }
  .cp-no { flex: none; min-width: var(--icon-xl); height: var(--icon-xl); border-radius: var(--r-xs); display: grid;
    place-items: center; background: var(--sunken); font-size: var(--fs-s); font-weight: var(--fw-bold); }
  .cp-power { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight);
    line-height: 1.25; margin-top: var(--s0); white-space: nowrap; }
  .cp-power small { font-size: var(--fs-s); font-weight: var(--fw-medium); color: var(--ink-2);
    letter-spacing: 0; }
  .cp.is-free .cp-power, .cp.is-offline .cp-power { color: var(--ink-3); }
  .cp-meta, .cp-who { font-size: var(--fs-s); color: var(--ink-2); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
  .cp-note { font-size: var(--fs-s); color: var(--wait); margin-top: var(--s1); }
  .cp-limit { font-size: var(--fs-xs); color: var(--ink-3); margin-top: var(--s1); }
  /* A row instead of a tile: power at the right, the rest at the left. */
  .station .cp, .cps.rows .cp { display: grid; grid-template-columns: minmax(0, 1fr) auto;
    column-gap: var(--s3); align-items: center; min-height: 0; }
  .station .cp-head, .cps.rows .cp-head { grid-column: 1; justify-content: flex-start;
    align-items: center; min-width: 0; }
  .station .cp-power, .cps.rows .cp-power { grid-column: 2; grid-row: 1 / span 2; margin: 0;
    font-size: var(--fs-l); text-align: right; }
  .station .cp-info, .cps.rows .cp-info { grid-column: 1; min-width: 0; }
  .station :is(.cp-note, .cp-limit), .cps.rows :is(.cp-note, .cp-limit) { grid-column: 1 / -1; }
  /* A device with several connectors: its name once, a row per connector, no box in a box. */
  .stations { display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 600px) { .stations { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  .stations + .cps { margin-top: var(--s4); }
  .station .head { margin-bottom: 0; align-items: baseline; }
  .station .head strong { display: block; font-size: var(--fs-m); }
  .station .head small { display: block; font-size: var(--fs-xs); color: var(--ink-3);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .station .head .num { font-size: var(--fs-s); font-weight: var(--fw-bold); color: var(--go); white-space: nowrap; }
  .station .cps { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: var(--s2); }
  .station .cp { padding: var(--s25) var(--s2) var(--s25) var(--s3); border: 0;
    border-left: var(--stripe) solid var(--state); border-radius: 0; background: none; }
  .station .cp + .cp { border-top: var(--hair) solid var(--line); }
  .station a.cp:hover { box-shadow: none; background: var(--sunken); }
  .station .cp-name { flex: 0 1 auto; overflow-wrap: normal; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
  .station .cp-info { margin-top: var(--s0); }
  .station .cp-meta { white-space: normal; }
  @media (max-width: 599px) {
    .cps { grid-template-columns: 1fr; gap: var(--s2); }
    .cp { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s3);
      align-items: center; min-height: 0; padding: var(--s2) var(--s3); }
    .cp-head { grid-column: 1; justify-content: flex-start; min-width: 0; }
    .cp-power { grid-column: 2; grid-row: 1 / span 2; margin: 0; font-size: var(--fs-l); text-align: right; }
    .cp-info { grid-column: 1; min-width: 0; white-space: nowrap; overflow: hidden;
      text-overflow: ellipsis; font-size: var(--fs-s); color: var(--ink-2); }
    .cp-info > div { display: inline; }
    .cp-who::before { content: " · "; }
    .cp-note, .cp-limit { grid-column: 1 / -1; margin-top: var(--s0); }
  }
  /* Events of the last day. */
  .events { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
  .events li { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s2) var(--s25);
    font-size: var(--fs-s); }
  .events .grow { flex: 1; min-width: 0; }
  .events .dot { margin-top: var(--s15); color: var(--accent); }
  .events .is-ended .dot { color: var(--ink-3); }
  .events .is-started .dot { color: var(--go); }
  .events .is-reported .dot { color: var(--bad); }
  .events small { display: block; color: var(--ink-3); }
  .events time { flex: none; color: var(--ink-3); font-size: var(--fs-xs); }
  /* Detail of a connector. */
  .detail-card { margin-bottom: var(--s3); }
  .detail-top { display: flex; align-items: center; justify-content: space-between;
    gap: var(--s2); font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--ink-2); }
  .detail-card strong { display: block; margin-top: var(--s15); }
  .detail-card p { margin: var(--s0) 0 0; font-size: var(--fs-s); color: var(--ink-2); }
  /* Power flow: sources left, sinks right, bands in the colour of the source. */
  .flow { margin-bottom: var(--s5); }
  .card > .flow { margin: 0; }
  .flow figcaption { margin-bottom: var(--s2); }
  .flow figcaption strong { font-size: var(--fs-base); font-weight: var(--fw-bold); }
  .flow .band { opacity: .32; fill: var(--swatch); transition: opacity .15s; }
  .flow svg:has(.band:hover) .band:not(:hover) { opacity: .25; }
  .flow .band:hover { opacity: .55; }
  .flow .flow-node { fill: var(--swatch); }
  .flow .flow-node.to { fill: var(--ink-3); }
  .flow .flow-label { font-size: var(--fs-chart-l); font-weight: var(--fw-semi); fill: var(--ink); }
  .flow .flow-value { font-size: var(--fs-chart); fill: var(--ink-2); font-variant-numeric: tabular-nums; }
  .flow .legend { display: flex; margin: var(--s2) 0 0; }
  .flow .chart-plot.wide { max-width: var(--w-text); }
  /* Price of a kWh over today and tomorrow: a step line, the moment now marked. */
  .chart.price { margin: 0; max-width: var(--w-text); }
  .chart.price .price-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; }
  .chart.price .axis { font-size: var(--fs-chart-m); fill: var(--ink-3); stroke: none; font-variant-numeric: tabular-nums; }
  .chart.price .day-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
  .chart.price .now-line { stroke: var(--ink-2); stroke-width: 1; }
  .chart.price .now-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
  .chart.price .hit { fill: transparent; }
  .chart.price .hit:hover { fill: color-mix(in srgb, var(--series-1) 14%, transparent); }

  /* -- charges: a list on a phone, a table from 1200 px --------------------------------- */
  .only-wide, .list.sessions > .thead { display: none; }
  .c-card, .c-make { display: none; }
  .c-avatar { flex: none; display: inline-flex; }
  .c-share { font-weight: var(--fw-medium); color: var(--ink-2); font-size: .85em; }
  .list.sessions .c-who strong { font-weight: var(--fw-semi); }
  .list.sessions .c-point { color: var(--ink-2); }
  .list.sessions li.session .bar { --bar-h: 4px; margin-top: var(--s15); max-width: var(--w-narrow); }
  .list.sessions li.session .bar > i { transition: none; }
  @media (min-width: 1200px) {
    .only-wide { display: revert; }
    .badge.only-wide { display: inline-flex; }
    /* Every column has a real least width; a text never leaves its cell. */
    .list.sessions > .thead, .list.sessions li.session a.row { display: grid; align-items: center;
      grid-template-columns: 96px 32px minmax(150px, 1.3fr) minmax(130px, 1fr) 116px
        minmax(120px, .9fr); column-gap: var(--s4); }
    .list.sessions > .thead { min-height: 0; padding: 0 0 var(--s2); border-top: 0;
      font-size: var(--fs-2xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-caps);
      text-transform: uppercase; color: var(--ink-3); }
    .list.sessions > .thead > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .list.sessions > .thead .h-who { grid-column: 2 / span 2; }
    .list.sessions > .thead .h-energy { text-align: right; }
    .list.sessions > .thead + li { border-top: var(--hair) solid var(--line); }
    .list.sessions li.session a.row { grid-template-rows: auto auto; row-gap: var(--s15);
      margin: calc(var(--s25) * -1) 0; padding: var(--s25) 0; border-radius: 0; }
    .list.sessions li.session a.row::after { content: none; }
    .list.sessions li.session :is(.grow, .row-title, .row-end) { display: contents; }
    .list.sessions li.session .sep { display: none; }
    .list.sessions li.session :is(.c-state, .c-avatar, .c-point, .c-who, .c-time) {
      grid-row: 1 / span 2; min-width: 0; overflow: hidden; }
    .list.sessions li.session .c-state { grid-column: 1; display: flex; flex-wrap: wrap; gap: var(--s1); }
    .list.sessions li.session .c-avatar { grid-column: 2; }
    .list.sessions li.session .c-who { grid-column: 3; }
    .list.sessions li.session :is(.c-who strong, .c-name, .c-card, .c-make) { display: block;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .list.sessions li.session :is(.c-card, .c-make) { font-size: var(--fs-xs); color: var(--ink-3); }
    .list.sessions li.session .c-point { grid-column: 4; }
    .list.sessions li.session .c-name { color: var(--ink); }
    .list.sessions li.session .c-time { grid-column: 5; white-space: nowrap; }
    .list.sessions li.session .c-kwh { grid-column: 6; grid-row: 1; text-align: right;
      font-weight: var(--fw-bold); align-self: end; min-width: 0; white-space: nowrap; }
    .list.sessions li.session .bar { grid-column: 6; grid-row: 2; margin: 0; max-width: none;
      align-self: start; min-width: 0; }
  }

  /* -- driver's history: a row per charge, grouped by day ------------------------------- */
  .history-list > li.charge { padding: 0; }
  .history-list .row { padding: var(--s3) 0; }
  .history-list a.row { margin: 0 calc(var(--s2) * -1); padding-inline: var(--s2); }
  .history-list .row-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s0) var(--s15);
    white-space: normal; }
  .history-list .row-title strong { font-weight: var(--fw-semi); }
  .history-list .row-site { color: var(--ink-2); }
  .history-list .row-site::before { content: "· "; }
  .history-list .bar { --bar-h: 4px; --bar-fill: var(--series-1); margin-top: var(--s2); max-width: var(--w-narrow); }
  @media (max-width: 599px) {
    .history-list .row-site { order: 3; flex-basis: 100%; font-size: var(--fs-s); }
    .history-list .row-site::before { content: none; } }

  /* -- driver's app: vehicle, charge, plan, parking ------------------------------------- */
  .vcard-car { display: flex; align-items: center; gap: var(--s35); margin-bottom: var(--s35); }
  .vcard-car .grow { min-width: 0; flex: 1; }
  .vname { font-size: var(--fs-base); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight);
    line-height: 1.25; overflow-wrap: break-word; hyphens: auto; }
  /* The name keeps its words: when there is no room, the button moves below it. */
  .vname-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
    gap: var(--s15) var(--s2); }
  .vname-row .vname { flex: 1 1 8em; min-width: 0; overflow-wrap: normal; hyphens: manual; }
  .vsub { font-size: var(--fs-xs); color: var(--ink-3); margin-top: var(--s0); display: flex;
    align-items: center; gap: var(--s1); }
  .vsub .icon { width: var(--icon-xs); height: var(--icon-xs); color: var(--go); }
  .car-wrap { --w: 132px; --h: 68px; position: relative; width: var(--w); height: var(--h); flex: none; }
  .car { position: relative; width: 100%; height: 100%; display: block; }
  .car-glow { position: absolute; left: var(--s3); right: var(--s3); bottom: var(--s1); height: var(--icon-s);
    border-radius: var(--r-pill); background: var(--tone); opacity: .35; filter: blur(8px); }
  .car-wrap.idle .car-glow, .car-wrap.unknown .car-glow { display: none; }
  @media (prefers-reduced-motion: no-preference) {
    .car-wrap.go .car-glow { animation: glow 3s ease-in-out infinite; }
    @keyframes glow { 0%, 100% { opacity: .25; transform: scaleX(.96); }
      50% { opacity: .5; transform: scaleX(1.04); } } }
  .car-body { fill: var(--car-body); }
  .car-wrap:is(.info, .wait) .car-body { fill: var(--car-body-idle); }
  .car-wrap.idle .car-body { fill: var(--car-body-off); }
  .car-roof { fill: var(--car-roof); opacity: .85; }
  .car-glass { fill: var(--car-glass); opacity: .88; }
  .car-line { fill: none; stroke: var(--on-fill); stroke-opacity: .28; stroke-width: 1.5; stroke-linecap: round; }
  .car-lamp { fill: var(--car-lamp); }
  .car-tail { fill: var(--car-tail); opacity: .9; }
  .car-led { fill: var(--car-led); }
  .car-wrap:is(.info, .wait) .car-led { fill: var(--car-led-wait); }
  .car-wrap.idle .car-led { fill: var(--car-metal); }
  .car-tyre { fill: var(--car-tyre); }
  .car-rim { fill: var(--car-metal); }
  .car-shadow { fill: var(--car-shadow); }
  .car-wrap.unknown .car-body { fill: var(--sunken); stroke: var(--ink-3); stroke-width: 1.5;
    stroke-dasharray: 5 4; }
  .car-wrap.unknown :is(.car-roof, .car-glass, .car-line, .car-lamp, .car-tail, .car-led) { display: none; }
  .kwh { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s2); }
  .kwh > div:first-child { min-width: 0; }
  .kwh-big strong { font-size: var(--fs-2xl); font-weight: var(--fw-heavy); letter-spacing: var(--ls-tight); line-height: 1; }
  .kwh-big span { font-size: var(--fs-base); font-weight: var(--fw-bold); color: var(--ink-3); }
  .kwh-sub { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s15) var(--s2);
    margin-top: var(--s15); font-size: var(--fs-xs); color: var(--ink-3); font-weight: var(--fw-medium); }
  .kwh-sub strong { color: var(--ink-2); font-size: var(--fs-xs); }
  .finish { text-align: right; flex: none; }
  .finish span { display: block; font-size: var(--fs-2xs); color: var(--ink-3); font-weight: var(--fw-medium); }
  .finish strong { font-size: var(--fs-m); font-weight: var(--fw-bold); color: var(--tone); }
  details.info { flex-basis: 100%; }
  details.info > summary { min-height: var(--icon-2xl); display: inline-flex; align-items: center; gap: var(--s1);
    margin: 0; color: var(--ink-3); font-weight: var(--fw-semi); list-style: none; }
  details.info > summary::-webkit-details-marker { display: none; }
  details.info p { margin: var(--s15) 0 0; padding: var(--s25); border-radius: var(--r-m);
    background: var(--sunken); font-size: var(--fs-xs); line-height: 1.5; color: var(--ink-2); }
  /* Energy of the charge against the need. */
  .kbar { height: var(--size-xs); border-radius: var(--r-l); background: var(--sunken); overflow: hidden;
    margin-top: var(--s25); box-shadow: inset 0 0 0 var(--hair) var(--line); }
  .kbar > i { display: block; height: 100%; width: var(--w, 0%); position: relative; overflow: hidden;
    border-radius: var(--r-l) 0 0 var(--r-l); transition: width .5s ease-out;
    background: var(--tone, var(--fill)); }
  .kbar > b { position: absolute; top: 0; bottom: 0; width: 0; left: var(--at);
    border-left: var(--ring) dashed var(--ink-2); opacity: .8; }
  @media (prefers-reduced-motion: no-preference) {
    .kbar.live > i::after { content: ""; position: absolute; inset: 0; width: 45%;
      background: linear-gradient(90deg, transparent, var(--shine), transparent);
      animation: shimmer 2.4s cubic-bezier(.4, 0, .2, 1) infinite; }
    @keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(220%); } } }
  .kbar-wrap { position: relative; margin-top: calc(var(--s5) + var(--s0)); }
  .kbar-wrap .kbar { margin-top: 0; height: var(--icon-2xl); position: relative; }
  .kbar-label { position: absolute; top: -16px; left: var(--at); transform: translateX(-50%);
    font-size: var(--fs-2xs); font-weight: var(--fw-bold); color: var(--ink-3); white-space: nowrap; }
  .stop-row { text-align: center; }
  /* Forecast of a charge: measured filled, the projection hatched. */
  .forecast { margin: 0; }
  .forecast .past-area { fill: var(--fill); opacity: .22; }
  .forecast .past-line { fill: none; stroke: var(--fill); stroke-width: 2.2; stroke-linejoin: round; }
  .forecast .future-line { fill: none; stroke: var(--forecast); stroke-width: 2.2; stroke-dasharray: 4 3;
    stroke-linejoin: round; }
  .hatch-bg { fill: var(--forecast); opacity: .08; }
  .hatch-line { stroke: var(--forecast); stroke-opacity: .4; stroke-width: 1.6; }
  .forecast .now { stroke: var(--ink); stroke-width: 1.3; }
  .forecast .now-label { font-size: var(--fs-chart-s); font-weight: var(--fw-bold); fill: var(--ink); }
  .forecast .departure { stroke: var(--info); stroke-width: 1.4; stroke-dasharray: 3 2; }
  .forecast .departure-label { font-size: var(--fs-chart-s); font-weight: var(--fw-bold); fill: var(--info); }
  .forecast .tick { font-size: var(--fs-chart-s); }
  .legend.s { font-size: var(--fs-2xs); font-weight: var(--fw-semi); color: var(--ink-3); margin-top: var(--s15); }
  .key { width: var(--icon-2xs); height: var(--icon-2xs); border-radius: var(--r-xs); display: inline-block; }
  .key.past { background: var(--fill); opacity: .8; }
  .key.future { border: var(--hair) dashed var(--forecast); background: color-mix(in srgb, var(--forecast) 20%, transparent); }
  /* What a plan gives, shown before it is saved. */
  .plan-preview { display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
    padding: var(--s3); border-radius: var(--r-l); background: var(--go-soft);
    border: var(--hair) solid var(--go-line); font-size: var(--fs-s); margin-top: var(--s2); }
  .plan-preview strong { color: var(--go); }
  /* Vehicles with their own defaults. */
  .vehicle { margin-top: var(--s2); }
  .vehicle-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s1); }
  .vehicle-head form { min-width: 0; margin: 0; }
  .vehicle-pick { display: block; width: 100%; background: none; border: 0; padding: 0;
    font: inherit; color: inherit; text-align: left; cursor: pointer; }
  .vehicle-pick:disabled { cursor: default; }
  .vehicle-pick .vname { display: block; }
  .vehicle .kv.line { padding: var(--s2) 0; min-height: 0; }
  .vehicle-foot { display: flex; justify-content: flex-end; gap: var(--s15); padding-top: var(--s2);
    border-top: var(--hair) solid var(--line); }
  /* Charge points of the parking page. */
  .charger .head { margin: 0; }
  .charger strong { display: block; font-size: var(--fs-s); }
  .charger small { font-size: var(--fs-xs); color: var(--ink-3); }
  .charger-head { display: flex; align-items: center; justify-content: space-between;
    gap: var(--s2); font-size: var(--fs-s); color: var(--ink-2); }
  /* Export formats. */
  .fmt { width: var(--size-s); height: var(--size-xs); border-radius: var(--r-s); flex: none; display: inline-flex;
    align-items: center; justify-content: center; font-size: var(--fs-2xs); font-weight: var(--fw-heavy);
    background: var(--tone-soft); color: var(--tone); }
  .export-row { margin-top: var(--s2); padding: var(--s25) var(--s3); }
  .intro { display: flex; gap: var(--s3); align-items: flex-start; }
  .intro p { margin: var(--s1) 0 var(--s15); font-size: var(--fs-s); color: var(--ink-2); line-height: 1.5; }

  /* -- profile and account ------------------------------------------------------------- */
  .profile { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
  .profile .grow { --col: 180px; flex: 1; min-width: var(--col); }
  .profile h2 { font-size: var(--fs-l); margin: 0; }
  .operator-card { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
  .who-card { display: flex; align-items: center; gap: var(--s35); }
  .who-card .badge { margin-top: var(--s1); }
  @media (max-width: 599px) {
    .profile { gap: var(--s3); }
    .profile .actions { flex-basis: 100%; }
    .profile .actions .btn { flex: 1 1 auto; }
  }

  /* -- onboarding: start page and assistant -------------------------------------------- */
  .wizard { max-width: var(--w-text); }
  .wizard ol li { margin-bottom: var(--s2); }
  .how { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .how p { margin: var(--s1) 0 0; font-size: var(--fs-m); color: var(--ink-2); }
  .how .icon-tile { margin-bottom: var(--s2); }
  .checks li { align-items: flex-start; gap: var(--s3); }
  .checks .badge { --col: 74px; flex: none; min-width: var(--col); justify-content: center; margin-top: var(--s0); }
  ul.plain { margin: 0; padding-left: 1.1em; display: grid; gap: var(--s15); }
  p.lead { font-size: var(--fs-base); line-height: 1.5; max-width: 68ch; margin: var(--s2) 0 var(--s3); }

  /* -- electrical layout: one tree per site --------------------------------------------- */
  .tree { list-style: none; margin: 0; padding: 0; }
  .tree .tree { margin: var(--s2) 0 0 var(--s4); padding-left: var(--s4); border-left: var(--ring) solid var(--line); }
  .tree > li { margin-top: var(--s2); }
  .tnode.grid { border-color: var(--ink-3); }
  .tnode-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
  .tnode-head .grow { flex: 1 1 auto; min-width: 0; }
  .tnode-meter { display: flex; align-items: center; gap: var(--s15); margin: var(--s2) 0 0; }
  .tnode-meter .icon { width: var(--icon-s); height: var(--icon-s); }
  .tnode-meter a { flex: 0 1 auto; min-width: 0; }
  .tree .leaf { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2);
    padding: var(--s2) var(--s3); border: var(--hair) solid var(--line); border-radius: var(--r-m);
    background: var(--surface); }
  .tree .leaf.add { border-style: dashed; padding: var(--s0) var(--s2); background: none; }
  .tree .leaf .grow { flex: 1 1 auto; min-width: 0; }
  .tree .leaf a.grow { color: inherit; }
  .tree .leaf strong { display: block; font-weight: var(--fw-semi); overflow-wrap: anywhere; }
  .tree .leaf small { color: var(--ink-2); font-size: var(--fs-s); }
  .tree .leaf > .icon { color: var(--ink-2); }
  .tree .leaf > .num, .tnode-meter .num { white-space: nowrap; }
  .tree.loose { min-height: var(--tap); border: var(--hair) dashed var(--line); border-radius: var(--r-m);
    padding: 0 var(--s2) var(--s2); }
  [data-layout] [draggable="true"] { cursor: grab; }
  [data-layout] .dragging { opacity: .45; }
  [data-layout] .drop { outline: var(--ring) dashed var(--accent); outline-offset: var(--ring); background: var(--accent-soft); }
  /* The move and edit buttons are icons; names take the room. */
  [data-layout] .btn.icon-only { min-width: var(--size-m); min-height: var(--size-m); flex: none; }
  [data-layout] .btn.icon-only .label { position: absolute; width: var(--hair); height: var(--hair);
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  @media (max-width: 599px) { .tree .tree { margin-left: var(--s2); padding-left: var(--s2); } }

  /* -- charge point configuration --------------------------------------------------------- */
  .config-input { --col: 90px; max-width: var(--col); }
  .config-input.s { --col: 80px; }

  /* -- before setup: a blurred outline of the page; the note floats over it ---------------- */
  .preview-stage { --room: 140px; display: grid; min-height: calc(100dvh - var(--room)); }
  .preview-stage > * { grid-area: 1 / 1; }
  /* Blurred enough that nothing reads as data, clear enough to see the page's structure. */
  .preview-demo { filter: blur(2.5px) saturate(.85); opacity: .9; pointer-events: none;
    user-select: none; overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, var(--ink) 70%, transparent);
    mask-image: linear-gradient(to bottom, var(--ink) 70%, transparent); }
  .preview-demo .sk { display: block; height: var(--icon-2xs); border-radius: var(--r-xs); background: var(--ink-3);
    opacity: .45; margin: var(--s15) 0; width: var(--w, 50%); }
  .preview-demo .sk.big { height: var(--icon-xl); opacity: .7; }
  .preview-demo .sk.thin { height: var(--dot-s); opacity: .3; }
  .preview-demo .sk.head { height: var(--icon-s); margin-bottom: var(--s4); opacity: .6; }
  .preview-demo .sk.end { flex: none; width: var(--size-2xl); }
  .preview-demo .chip { --w: 72px; width: var(--w); }
  .preview-demo .sk-dot { background: var(--sunken); }
  .preview-demo .sk-field { display: block; height: var(--size-l); max-width: var(--w-xs);
    border-radius: var(--r-m); background: var(--surface); border: var(--hair) solid var(--line); }
  .preview-demo .bar { --bar-fill: var(--series-1); margin-top: var(--s2); }
  .preview-cols { display: grid; gap: var(--s3); }
  @media (min-width: 1200px) { .preview-cols { grid-template-columns: 3fr 2fr; } }
  .preview-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s2); }
  .preview-phase { display: grid; grid-template-columns: 40px 1fr; align-items: center;
    gap: var(--s2); margin-bottom: var(--s2); }
  .preview-bars { --block: 200px; display: flex; align-items: flex-end; gap: var(--s1); height: var(--block);
    border-bottom: var(--hair) solid var(--line); }
  .preview-bars > i { flex: 1; height: var(--h); border-radius: var(--r-xs) var(--r-xs) 0 0;
    background: var(--series-1); }
  .preview-heat { display: grid; grid-template-columns: repeat(24, 1fr); gap: var(--s0); }
  .preview-heat > i { height: var(--icon); border-radius: var(--r-xs); background: var(--sunken); }
  .preview-note { position: sticky; z-index: 5; align-self: end; bottom: 20px;
    display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin: 0 auto;
    width: min(100%, var(--w-text)); box-shadow: var(--shadow-raised); }
  @media (max-width: 899px) {
    .preview-note { bottom: calc(var(--tabbar) + var(--s3)); }
    .preview-note .btn { flex: 1 1 100%; } }
}

/* == utilities ========================================================================= */
@layer utilities {
  .grow { flex: 1 1 auto; min-width: 0; }
  /* A secondary line: a date, a count, an explanation below a title (one way, DS-03); a
     utility, so it wins over the component it sits in, as .muted and .small did.
     .hint is only the hint of a form field. */
  .meta { color: var(--ink-2); font-size: var(--fs-m); }
  /* A figure at the size of a secondary line, read as the row's value. */
  .meta.figure { color: var(--ink); }
  .muted { color: var(--ink-2); }
  .num { font-variant-numeric: tabular-nums; }
  .sr-only { position: absolute; width: var(--hair); height: var(--hair); padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .mt-2 { margin-top: var(--s2); }
  .mt-3 { margin-top: var(--s3); }
  .mt-4 { margin-top: var(--s4); }
  .mb-2 { margin-bottom: var(--s2); }
  .mb-4 { margin-bottom: var(--s4); }
  .ml-2 { margin-left: var(--s2); }
}
