  /* ---------- design tokens (mobile-first, 360px baseline) ---------- */
  :root {
    --bg:        #0b1220;
    --bg-2:      #0f1729;
    --surface:   #131c33;
    --surface-2: #1b2747;
    --line:      #243154;
    --text:      #e6ecf7;
    --text-dim:  #94a3b8;
    --text-mute: #7d8aa0;   /* lightened to clear WCAG AA 4.5:1 on dark surfaces */
    --accent:    #38bdf8;
    --accent-2:  #818cf8;
    --ok:        #22c55e;
    --warn:      #f59e0b;
    --err:       #ef4444;
    --phase-r:   #ef4444;
    --phase-y:   #eab308;
    --phase-b:   #3b82f6;
    /* lighter per-phase tints for value text on dark panels (wall/kiosk) */
    --phase-r-tint: #fca5a5;
    --phase-y-tint: #fde68a;
    --phase-b-tint: #7dd3fc;
    --radius:    14px;
    --shadow:    0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px -8px rgba(0,0,0,0.5);
    --mono:      ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  }
  * { box-sizing: border-box; }
  html, body {
    margin: 0; padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;    /* fallback for older browsers (e.g. Pi Chromium 88) */
    min-height: 100dvh;
    line-height: 1.4;
  }
  button { font-family: inherit; cursor: pointer; }
  /* Keyboard focus must always be visible. :focus-visible shipped in Chromium 86,
     so the Pi kiosk (Chromium 88) honours it; mouse clicks stay ring-free. */
  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
  }
  h2 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.08em; text-transform: uppercase; }
  h3 { margin: 0; font-size: 15px; font-weight: 600; }

  /* ---------- login ---------- */
  #login {
    min-height: 100vh;    /* fallback for older browsers (e.g. Pi Chromium 88) */
    min-height: 100dvh;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 24px;
    background:
      radial-gradient(60% 50% at 15% 0%, rgba(56,189,248,0.12), transparent 70%),
      radial-gradient(55% 50% at 100% 100%, rgba(129,140,248,0.12), transparent 70%),
      radial-gradient(ellipse at top, var(--bg-2), var(--bg));
  }
  .login-shell {
    width: 100%; max-width: 420px;
    display: grid; grid-template-columns: 1fr; gap: 18px;
  }

  /* ── brand / about pane (mobile-first: compact + centered) ── */
  .login-hero { text-align: center; }
  .login-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 14px; }
  .login-mark { width: 36px; height: 36px; flex: none; }
  .login-co { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
  .login-co-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
  .login-co-tag  { font-size: 10.5px; font-weight: 500; color: var(--accent); letter-spacing: 0.04em; }
  .login-headline {
    font-size: 22px; font-weight: 800; letter-spacing: -0.02em;
    margin: 0 0 8px; line-height: 1.15;
  }
  .login-about {
    color: var(--text-dim); font-size: 13px; line-height: 1.5;
    margin: 0 auto 16px; max-width: 42ch;
  }
  /* mobile: 2-up compact chips (icon + label, no sub-text) */
  .login-features { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .login-features li {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; min-height: 44px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    text-align: left;
  }
  .lf-ico {
    width: 28px; height: 28px; flex: none;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: var(--surface-2); color: var(--accent);
    border: 1px solid var(--line);
  }
  .lf-ico svg { width: 16px; height: 16px; }
  .lf-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
  .lf-txt b { font-size: 12.5px; font-weight: 600; color: var(--text); }
  .lf-txt small { font-size: 12px; color: var(--text-dim); display: none; }

  /* ── sign-in card ── */
  .login-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 28px 24px;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column;
  }
  .login-card-title { font-size: 18px; font-weight: 700; color: var(--text);
    text-transform: none; letter-spacing: -0.01em; margin: 0 0 4px; }
  .login-sub   { color: var(--text-dim); font-size: 14px; margin: 0 0 20px; }
  .google-btn {
    width: 100%; min-height: 48px;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    background: #fff; color: #1f2937;
    border: none; border-radius: 10px;
    font-size: 15px; font-weight: 500;
    padding: 0 16px;
    transition: transform 0.08s ease, box-shadow 0.15s ease;
  }
  .google-btn:hover { box-shadow: 0 4px 16px -4px rgba(0,0,0,0.45); }
  .google-btn:active { transform: scale(0.98); }
  .login-status { margin-top: 14px; font-size: 13px; min-height: 1.4em; }
  .login-status.error { color: var(--err); }
  .login-status.info  { color: var(--text-dim); }
  .login-share {
    margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 10px;
  }
  .login-share-q { font-size: 13px; color: var(--text-dim); margin: 0; line-height: 1.4; }
  .wa-btn {
    width: 100%; min-height: 44px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: #25D366; color: #fff;
    border: none; border-radius: 10px;
    font-size: 14px; font-weight: 600;
    padding: 0 16px; text-decoration: none;
    transition: transform 0.08s ease, box-shadow 0.15s ease;
  }
  .wa-btn:hover { box-shadow: 0 4px 16px -4px rgba(0,0,0,0.45); }
  .wa-btn:active { transform: scale(0.98); }
  .login-foot {
    margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line);
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-mute);
  }
  .login-foot-sep { opacity: 0.5; }
  .login-foot a { color: var(--accent); text-decoration: none; }
  .login-foot a:hover { text-decoration: underline; }

  /* ── desktop: split hero + card, roomy left-aligned list ── */
  @media (min-width: 860px) {
    .login-shell {
      max-width: 920px;
      grid-template-columns: 1.15fr 0.85fr;
      gap: 48px; align-items: center;
    }
    .login-hero { text-align: left; }
    .login-logo { justify-content: flex-start; margin-bottom: 22px; }
    .login-mark { width: 40px; height: 40px; }
    .login-co-name { font-size: 16px; }
    .login-co-tag  { font-size: 11px; }
    .login-headline { font-size: 30px; margin-bottom: 12px; }
    .login-about { font-size: 14px; margin: 0 0 24px; max-width: 46ch; }
    .login-features { grid-template-columns: 1fr; gap: 6px; }
    .login-features li {
      gap: 12px; padding: 0; min-height: 44px;
      background: none; border: none; border-radius: 0;
    }
    .lf-ico { width: 40px; height: 40px; border-radius: 10px; }
    .lf-ico svg { width: 20px; height: 20px; }
    .lf-txt b { font-size: 14px; }
    .lf-txt small { display: block; }
  }

  /* ---------- dashboard ---------- */
  #dash { display: none; }
  #dash.shown { display: block; }
  .topbar {
    position: sticky; top: 0; z-index: 20;
    background: rgba(11, 18, 32, 0.85);
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--line);
    padding: 9px 16px;
    /* Left-grouped flex row: brand+tenant and the site identity sit together on
       the left as one branding unit; margin-right:auto on the identity pushes the
       account block to the far right. No centered cell → no dead gap in the middle.
       min-width:0 + ellipsis on the name keeps a long company name from widening
       the row (it truncates instead). */
    display: flex; align-items: center; gap: 10px;
  }
  /* flex:0 1 auto (was none) so when the superadmin tenant switcher appears, the
     brand can shrink and the <select> truncates instead of widening the row past
     the viewport (that overflow was the "page loads zoomed-in / must pinch-out"). */
  .brand { flex: 0 1 auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
  .brand h1 { flex: none; }
  .brand .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--ok); box-shadow: 0 0 0 3px rgba(34,197,94,0.18);
    animation: live-pulse 1.4s ease-in-out infinite;
  }
  .brand .dot.stale   { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,158,11,0.18); animation: none; }
  .brand .dot.offline { background: var(--err);  box-shadow: 0 0 0 3px rgba(239,68,68,0.18); animation: none; }
  @keyframes live-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(34,197,94,0.12); transform: scale(1);    }
    50%      { box-shadow: 0 0 0 6px rgba(34,197,94,0.32); transform: scale(1.18); }
  }
  .brand h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }

  /* Tenant switcher (admin-only). The label wraps the slash + select so the
     hit target is generous on mobile. */
  .tenant-switch {
    display: flex; align-items: center; gap: 6px;
    margin-left: 6px; min-width: 0; flex: 0 1 auto;
  }
  .tenant-switch[hidden] { display: none !important; }
  .tenant-switch-sep { color: var(--text-mute); font-weight: 500; }
  .tenant-switch select {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 5px 26px 5px 10px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    min-height: 32px;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
    max-width: 28vw;
    min-width: 0;            /* allow the select to shrink below its content (it truncates) */
    text-overflow: ellipsis;
  }
  .tenant-switch select:hover { border-color: var(--text-dim); }
  .tenant-switch select option { background: var(--surface); color: var(--text); }
  /* Site identity (customer company name + logo). Sits just after the tenant on
     the left; margin-right:auto eats the remaining row width so the account block
     lands flush-right. flex:0 1 auto lets it shrink (name truncates) when the row
     is tight; pointer-events:none so it never blocks a control it may overlap. */
  .site-identity {
    flex: 0 1 auto; margin-right: auto;
    display: flex; align-items: center; gap: 8px;
    min-width: 0; overflow: hidden;
    padding-left: 4px;
    pointer-events: none;
  }
  .site-identity[hidden] { display: none; }
  .site-identity-logo {
    height: 22px; width: auto; max-width: 84px;
    object-fit: contain; border-radius: 5px; flex: none;
  }
  .site-identity-logo[hidden] { display: none; }
  .site-identity-name {
    font-size: 13.5px; font-weight: 700; letter-spacing: -0.01em; color: var(--text);
    min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  /* Mobile top row is tight — show the logo only (the full company name doesn't
     fit cleanly), kept inline next to the tenant with the account block flush-right. */
  @media (max-width: 640px) {
    .site-identity-name { display: none; }
  }

  .user-block { display: flex; gap: 7px; align-items: center; flex: none; }
  .user-email { font-size: 12px; color: var(--text-dim); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .signout {
    background: transparent; color: var(--text-dim);
    border: 1px solid var(--line); border-radius: 8px;
    padding: 6px 10px; font-size: 12px; min-height: 32px; white-space: nowrap;
  }
  .signout:hover { color: var(--text); border-color: var(--text-dim); }

  /* Account menu (gear → notifications + sign out). The gear goes amber with a dot
     when THIS device isn't subscribed to push — i.e. one tap away from alerts. */
  .account { position: relative; display: flex; }
  .account-btn { position: relative; }
  .account-btn.unsub { color: var(--warn); border-color: var(--warn); }
  .account-btn.unsub::after {
    content: ''; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px;
    border-radius: 50%; background: var(--warn); border: 2px solid var(--surface);
  }
  .account-menu {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 300;
    min-width: 248px; max-width: min(86vw, 300px);
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--shadow); padding: 10px; display: flex; flex-direction: column; gap: 10px;
  }
  .account-menu[hidden] { display: none; }
  .account-menu-h {
    font-size: 12px; color: var(--text-dim); padding: 2px 4px 8px;
    border-bottom: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .account-notif { display: flex; flex-direction: column; gap: 8px; padding: 0 4px; }
  .account-notif-title { font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 7px; }
  .account-notif-title svg { width: 15px; height: 15px; flex: none; }
  .account-notif-state { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 7px; }
  .account-notif-state .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-dim); }
  .account-notif-state .dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(34,197,94,0.18); }
  .account-notif-state .dot.warn { background: var(--warn); }
  .account-notif-msg { font-size: 12px; color: var(--text-dim); line-height: 1.45; }
  .account-notif-btn {
    appearance: none; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
    padding: 10px 12px; min-height: 44px; border-radius: 9px; border: 1px solid transparent;
    background: var(--accent); color: #04121e; text-align: center;
  }
  .account-notif-btn.ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }
  .account-notif-btn.ghost:hover { color: var(--text); border-color: var(--text-dim); }
  .account-signout {
    appearance: none; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
    background: transparent; color: var(--text-dim); border: 1px solid var(--line);
    border-radius: 9px; min-height: 44px; padding: 10px 12px; width: 100%;
  }
  .account-signout:hover { color: var(--text); border-color: var(--text-dim); }

  /* large "you're not subscribed" opt-in modal (never-decided devices) */
  .notif-modal-backdrop {
    position: fixed; inset: 0; background: rgba(2,6,16,0.72);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity 0.18s ease; z-index: 300;
  }
  .notif-modal-backdrop.open { opacity: 1; pointer-events: auto; }
  .notif-modal {
    position: fixed; z-index: 301;
    left: 50%; top: 50%; transform: translate(-50%, -46%) scale(0.98);
    width: min(440px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);     /* fallback for older browsers (Pi Chromium 88) */
    max-height: calc(100dvh - 28px); overflow-y: auto;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 26px 22px 22px; text-align: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }
  .notif-modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
  .notif-modal-x {
    position: absolute; top: 9px; right: 9px; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    appearance: none; cursor: pointer; background: none; border: none;
    color: var(--text-dim); font-size: 24px; line-height: 1; border-radius: 8px;
  }
  .notif-modal-x:hover { color: var(--text); background: var(--surface-2); }
  .notif-modal-ic {
    width: 62px; height: 62px; margin: 2px auto 14px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--warn); background: rgba(245,158,11,0.12);
    box-shadow: 0 0 0 6px rgba(245,158,11,0.06);
  }
  .notif-modal-eyebrow {
    font-size: 11.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
    color: var(--warn); margin-bottom: 8px;
  }
  .notif-modal-msg {
    font-size: 16px; font-weight: 600; line-height: 1.5; color: var(--text);
    margin: 0 0 18px;
  }
  .notif-modal-check {
    display: flex; align-items: center; gap: 11px; text-align: left;
    padding: 13px 14px; margin-bottom: 14px;
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px;
    cursor: pointer; font-size: 14px; color: var(--text);
  }
  .notif-modal-check input {
    width: 20px; height: 20px; flex: none; accent-color: var(--accent); cursor: pointer;
  }
  .notif-modal-submit {
    width: 100%; min-height: 48px; border: none; border-radius: 11px;
    background: var(--accent); color: #04223a; font-size: 15px; font-weight: 700;
    cursor: pointer; transition: filter 0.15s ease, transform 0.08s ease;
  }
  .notif-modal-submit:hover { filter: brightness(1.06); }
  .notif-modal-submit:active { transform: scale(0.98); }
  .notif-modal-submit:disabled { opacity: 0.6; cursor: default; }

  main { padding: 16px; max-width: 1280px; margin: 0 auto; }
  .updated { font-size: 12px; color: var(--text-dim); margin-bottom: 16px; display: flex; gap: 6px; align-items: center; }
  .updated-stale { color: var(--warn); font-weight: 600; }

  section.panel { margin-bottom: 24px; }

  /* ---------- NOW section ---------- */
  .now-card {
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 18px 16px;
    box-shadow: var(--shadow);
  }
  .now-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 12px;
  }
  .now-meter { font-size: 13px; color: var(--text-dim); }
  /* (old .now-grid/.gauge-primary/.dials/.dial styles removed — replaced by the
     SCADA instrument cluster in instruments.css) */
  .badge { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 600; margin-left: 4px; letter-spacing: 0.04em; }
  .badge.lag   { background: rgba(245,158,11,0.18); color: var(--warn); }
  .badge.lead  { background: rgba(56,189,248,0.18); color: var(--accent); }
  .badge.unity { background: rgba(34,197,94,0.18);  color: var(--ok); }

  .now-stats {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
  }
  .now-stat { display: flex; flex-direction: column; gap: 2px; }
  .live-trend-card { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
  .live-trend-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
  .live-trend-title { font-size: 13px; font-weight: 600; }
  .live-trend-sub   { font-size: 11px; color: var(--text-dim); }
  .live-trend-body  { width: 100%; min-height: 110px; }
  .now-stat .label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
  .now-stat .value { font-size: 18px; font-weight: 700; }
  .now-stat .value .sub { font-size: 11px; color: var(--text-dim); font-weight: 500; margin-left: 2px; }

  /* ---------- METERS section ---------- */
  .meters { display: grid; gap: 12px; grid-template-columns: 1fr; }
  .meter-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.15s, transform 0.15s;
  }
  .meter-card:active { transform: scale(0.99); }
  .meter-card.stale   { border-color: rgba(245,158,11,0.5); }
  .meter-card.offline { border-color: rgba(239,68,68,0.5); opacity: 0.75; }
  /* brief border flash on every successful poll — visible "I just refreshed" cue */
  @keyframes card-tick {
    0%   { border-color: rgba(34,197,94,0.85); box-shadow: 0 0 0 2px rgba(34,197,94,0.15), var(--shadow); }
    100% { border-color: var(--line);          box-shadow: var(--shadow); }
  }
  .meter-card.tick { animation: card-tick 1.1s ease-out; }
  .meter-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 10px; gap: 8px;
  }
  .meter-title h3 { font-size: 15px; }
  .meter-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
  .freshness {
    font-size: 10px;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(34,197,94,0.14); color: var(--ok);
    white-space: nowrap;
  }
  .freshness.stale   { background: rgba(245,158,11,0.14); color: var(--warn); }
  .freshness.offline { background: rgba(239,68,68,0.14); color: var(--err); }
  .freshness.nodata  { background: rgba(100,116,139,0.18); color: var(--text-mute); }

  .meter-body {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 12px; align-items: center;
  }
  .meter-primary {
    display: flex; flex-direction: column; gap: 4px;
  }
  .meter-primary .p-value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
  .meter-primary .p-unit  { font-size: 11px; color: var(--text-dim); }
  .meter-side {
    display: flex; flex-direction: column; gap: 6px;
    align-items: flex-end;
  }
  .pf-line { font-size: 13px; font-weight: 600; }
  .pf-line .sub { font-size: 11px; color: var(--text-dim); font-weight: 500; }
  .freq-line { font-size: 12px; color: var(--text-dim); }

  .phase-chips {
    display: flex; gap: 6px; margin-top: 10px;
    flex-wrap: wrap;
  }
  .phase-chip {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    background: rgba(255,255,255,0.025);
    border-radius: 8px;
    padding: 6px 8px;
    border-left: 3px solid;
  }
  .phase-chip.r { border-left-color: var(--phase-r); }
  .phase-chip.y { border-left-color: var(--phase-y); }
  .phase-chip.b { border-left-color: var(--phase-b); }
  .phase-chip .ph-name { font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
  .phase-chip .ph-v { font-size: 12px; font-weight: 600; }
  .phase-chip .ph-i { font-size: 11px; color: var(--text-dim); }

  .meter-spark {
    margin-top: 10px;
    height: 28px;
    color: var(--accent);
  }
  .meter-spark svg { width: 100%; height: 100%; display: block; }

  .meter-foot {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 10px;
    font-size: 11px; color: var(--text-dim);
  }
  .tap-hint { display: inline-flex; align-items: center; gap: 4px; }
  .tap-hint svg { width: 12px; height: 12px; }

  /* ---------- HISTORY section ---------- */
  .chart-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
  }
  .chart-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 10px;
  }
  .chart-title { font-size: 13px; font-weight: 600; }
  .chart-sub { font-size: 11px; color: var(--text-dim); }
  .chart-body { min-height: 140px; position: relative; }
  .chart-empty { color: var(--text-mute); font-size: 12px; padding: 20px; text-align: center; }

  /* uPlot overrides for our dark theme */
  .uplot { font-family: inherit !important; }
  .u-legend { color: var(--text-dim); font-size: 11px; }
  .u-tooltip { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); padding: 6px 8px; border-radius: 6px; font-size: 11px; }

  /* ---------- bottom sheet (phase detail) ---------- */
  /* Scroll-lock the page body while any sheet/modal is open. iOS Safari honors
     overflow:hidden imperfectly (rubber-banding), but we keep it simple here —
     no position:fixed scroll-restore dance. */
  body.sheet-open { overflow: hidden; }
  .sheet-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
    z-index: 50;
  }
  .sheet-backdrop.open { opacity: 1; pointer-events: auto; }
  .sheet {
    position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--bg-2);
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    padding: 8px 16px 24px;
    max-height: 90vh;    /* fallback for older browsers (e.g. Pi Chromium 88) */
    max-height: 90dvh; overflow-y: auto;
    transform: translateY(100%);
    /* visibility, not just transform: a transform-hidden sheet stays in the tab
       order and the accessibility tree, so its controls were reachable from every
       view. Delay it to the end of the slide-out so the animation still plays. */
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s 0.25s;
    z-index: 60;
    box-shadow: 0 -24px 64px -16px rgba(0,0,0,0.6);
  }
  .sheet.open { transform: translateY(0); visibility: visible; transition: transform 0.25s ease; }
  .sheet-handle {
    display: block;
    width: 40px; height: 4px;
    background: var(--line);
    border-radius: 2px;
    margin: 8px auto 14px;
  }
  .sheet-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 16px; gap: 12px;
  }
  .sheet-close {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text-dim);
    width: 44px; height: 44px;
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .sheet-section { margin-bottom: 18px; }
  .sheet-section-title { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }

  /* settings modal — centered card on desktop, bottom sheet on mobile */
  .iconbtn-sm {
    background: var(--surface); border: 1px solid var(--line); color: var(--text-dim);
    width: 44px; height: 44px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; flex: none;
  }
  .iconbtn-sm:hover { color: var(--text); border-color: var(--text-dim); }
  @media (min-width: 720px) { .iconbtn-sm { width: 36px; height: 36px; } }
  .settings-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
  .settings-field label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
  .settings-field input {
    background: var(--surface); border: 1px solid var(--line); color: var(--text);
    border-radius: 8px; padding: 10px 12px; font-size: 15px; min-height: 44px; width: 100%;
  }
  .settings-field input:focus { border-color: var(--accent); }
  .settings-save {
    background: var(--accent); color: #04121f; border: none; border-radius: 8px;
    padding: 11px 16px; font-size: 14px; font-weight: 700; min-height: 44px; width: 100%;
  }
  .settings-note { font-size: 12px; color: var(--text-mute); margin-top: 10px; }
  @media (min-width: 720px) {
    .settings-sheet {
      left: 50%; right: auto; bottom: auto; top: 50%;
      width: min(420px, 92vw);
      border-radius: 18px;
      transform: translate(-50%, -46%) scale(0.98); opacity: 0;
      transition: opacity 0.18s ease, transform 0.18s ease;
      border: 1px solid var(--line);
      pointer-events: none;
    }
    .settings-sheet.open { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }
  }
  .sheet-phase-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .pq-gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .pq-gauge {
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
    padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  }
  .pq-cap { font-size: 12px; color: var(--text-dim); font-weight: 600; font-variant-numeric: tabular-nums; }
  /* short viewports (landscape phones): trim vertical spacing so the sheet
     content fits within its 90dvh cap with less scrolling */
  @media (max-height: 640px) {
    .sheet-section { margin-bottom: 12px; }
    .pq-gauges { gap: 6px; }
  }
  .sheet-phase {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
    border-top: 3px solid;
  }
  .sheet-phase.r { border-top-color: var(--phase-r); }
  .sheet-phase.y { border-top-color: var(--phase-y); }
  .sheet-phase.b { border-top-color: var(--phase-b); }
  .sheet-phase .ph-tag { font-size: 11px; font-weight: 700; color: var(--text-dim); margin-bottom: 4px; }
  .sheet-phase .ph-row { display: flex; justify-content: space-between; font-size: 12px; margin-top: 4px; }
  .sheet-phase .ph-row .lbl { color: var(--text-dim); }
  .sheet-phase .ph-row .val { font-weight: 600; }

  .sheet-kv {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .sheet-kv .kv {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
  }
  .sheet-kv .kv .k { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
  .sheet-kv .kv .v { font-size: 18px; font-weight: 700; margin-top: 2px; }
  .sheet-kv .kv .v .sub { font-size: 11px; color: var(--text-dim); font-weight: 500; margin-left: 3px; }

  /* ---------- empty/error states ---------- */
  .empty-state, .error-state {
    text-align: center; padding: 36px 16px;
    color: var(--text-dim); font-size: 13px;
  }
  .error-state { color: var(--err); }

  /* Non-destructive connection banner — sits above the views, keeps last-good
     data visible underneath. amber = reconnecting, red = harder failure. */
  /* the [hidden] attribute alone is defeated by `display:flex` below (author
     styles beat the UA `[hidden]{display:none}`), so restore it explicitly. */
  .conn-banner[hidden] { display: none; }
  .conn-banner {
    margin: 0 0 12px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 12.5px; font-weight: 600;
    border: 1px solid;
    display: flex; align-items: center; gap: 8px;
  }
  .conn-banner::before { content: "⟳"; font-size: 14px; }
  /* rgba literals (not color-mix) — color-mix is post-Chromium-88; kiosk = 88. */
  .conn-banner.warn { color: var(--warn); border-color: rgba(245,158,11,0.40); background: rgba(245,158,11,0.12); }
  .conn-banner.err  { color: var(--err);  border-color: rgba(239,68,68,0.40);  background: rgba(239,68,68,0.12); }

  /* (old .tab-bar styles removed — replaced by the app-shell sidebar/bottom-nav) */
  .view { display: none; }
  .view.active { display: block; }

  /* ---------- history view controls ---------- */
  .hist-controls {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    display: flex; flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow);
  }
  .hist-row {
    display: flex; flex-direction: column; gap: 6px;
  }
  .hist-label {
    font-size: 10px; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.08em;
  }
  .hist-meter-select {
    width: 100%; min-height: 44px;   /* touch target floor (CLAUDE.md) */
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 10px;
    font-family: inherit; font-size: 14px;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
  }
  .hist-chips {
    display: flex; gap: 6px; flex-wrap: wrap;
  }
  .hist-chip {
    flex: 1; min-width: 56px;
    min-height: 44px;
    background: var(--bg-2);
    color: var(--text-dim);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 12px; font-weight: 600;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
  }
  .hist-chip:hover { color: var(--text); }
  .hist-chip.active {
    background: var(--accent);
    color: #0b1220;
    border-color: var(--accent);
  }
  .hist-custom {
    display: none;
    gap: 8px; align-items: end; flex-wrap: wrap;
  }
  .hist-custom.open { display: flex; }
  .hist-custom .field { flex: 1; min-width: 130px; display: flex; flex-direction: column; gap: 4px; }
  .hist-custom input[type="date"] {
    min-height: 40px;
    background: var(--bg-2); color: var(--text);
    border: 1px solid var(--line); border-radius: 8px;
    padding: 0 10px; font-family: inherit; font-size: 13px;
    color-scheme: dark;
  }
  .hist-custom button {
    min-height: 40px; padding: 0 16px;
    background: var(--accent); color: #0b1220;
    border: none; border-radius: 8px;
    font-weight: 700; font-size: 13px;
  }
  .hist-overlay {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--text-dim);
    cursor: pointer;
    user-select: none;
  }
  .hist-overlay input { width: 18px; height: 18px; accent-color: var(--accent); }

  /* stats strip */
  .hist-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
  }
  .hist-stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
  }
  .hist-stat .k { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
  .hist-stat .v { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; margin-top: 2px; }
  .hist-stat .v .sub { font-size: 11px; color: var(--text-dim); font-weight: 500; margin-left: 3px; }

  /* main chart header */
  .hist-chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
  .hist-chart-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; gap: 8px;
  }
  .hist-chart-title { font-size: 13px; font-weight: 600; }
  .hist-chart-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
  .icon-btn {
    background: var(--bg-2);
    border: 1px solid var(--line);
    color: var(--text-dim);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    min-height: 44px;   /* touch target on mobile; compacts at ≥720px */
  }
  @media (min-width: 720px) { .icon-btn { min-height: 36px; } }
  .icon-btn:hover { color: var(--text); border-color: var(--text-dim); }
  .icon-btn svg { width: 12px; height: 12px; }

  .legend-row {
    display: flex; gap: 14px; flex-wrap: wrap;
    margin-top: 10px;
    font-size: 11px; color: var(--text-dim);
  }
  .legend-row .sw {
    display: inline-block; width: 12px; height: 3px;
    margin-right: 5px; vertical-align: middle; border-radius: 2px;
  }

  /* ---------- overview / command-center ---------- */
  .ov-grid { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
  .ov-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
    min-height: 86px;
  }
  .kpi-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
  .kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.05; }
  .kpi-unit { font-size: 13px; color: var(--text-dim); font-weight: 600; margin-left: 4px; }
  .kpi-sub { font-size: 11px; color: var(--text-mute); margin-top: 4px; }

  .ov-panel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  }
  .ov-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
  .ov-panel-head h2 { margin: 0; }
  .ov-panel-sub { font-size: 11px; color: var(--text-dim); }
  .ov-chart { min-height: 200px; }
  .ov-chart-flex { min-height: 120px; }
  .ov-muted { color: var(--text-mute); font-size: 12px; padding: 8px 2px; }

  .ov-toggle { display: inline-flex; gap: 2px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
  .ov-toggle button { background: transparent; border: none; color: var(--text-dim); font-size: 11px; font-weight: 600; padding: 5px 12px; border-radius: 6px; min-height: 44px; }
  @media (min-width: 720px) { .ov-toggle button { min-height: 30px; } }
  .ov-toggle button.active { background: var(--surface-2); color: var(--text); }

  .ov-alerts { display: flex; flex-direction: column; gap: 6px; }
  .ov-alert {
    display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
    padding: 9px 12px; min-height: 44px; color: var(--text); font-size: 12.5px;
  }
  .ov-alert:hover { border-color: var(--text-mute); }
  .ov-alert-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
  .ov-alert.err  { border-color: rgba(239,68,68,0.4); }
  .ov-alert.err  .ov-alert-dot { background: var(--err); }
  .ov-alert.warn { border-color: rgba(245,158,11,0.35); }
  .ov-alert.warn .ov-alert-dot { background: var(--warn); }

  .ov-status-grid { display: flex; flex-direction: column; gap: 5px; }
  .ov-chip {
    display: flex; align-items: center; gap: 8px; text-align: left;
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 12px; min-height: 44px; color: var(--text);
  }
  .ov-chip:hover { border-color: var(--text-mute); }
  .ov-chip-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--ok); }
  .ov-chip.stale   .ov-chip-dot { background: var(--warn); }
  .ov-chip.offline .ov-chip-dot { background: var(--err); }
  .ov-chip.nodata  .ov-chip-dot { background: var(--text-mute); }
  .ov-chip.is-root { border-color: var(--line); background: var(--surface-2); }
  .ov-chip-twig { color: var(--text-mute); font-size: 12px; flex: none; }
  .ov-chip-name { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ov-chip.is-root .ov-chip-name { font-weight: 700; }
  .ov-chip-tag { font-size: 9px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em; border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; flex: none; }
  .ov-chip-val { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .ov-chip-val .u { font-size: 10px; color: var(--text-dim); font-weight: 500; margin-left: 2px; }

  /* energy balance — segmented bar (children + unaccounted) */
  .ov-incomer-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); margin-bottom: 8px; min-width: 0; }
  .ov-select { background: var(--bg-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 8px; font-size: 12px; min-height: 32px; max-width: 220px; min-width: 0; flex: 0 1 auto; text-overflow: ellipsis; }
  .ov-balance-bar { display: flex; width: 100%; height: 22px; border-radius: 6px; overflow: hidden; background: var(--bg-2); border: 1px solid var(--line); }
  .ov-balance-seg { height: 100%; min-width: 2px; }
  .ov-balance-seg.other { background: repeating-linear-gradient(45deg, var(--text-mute) 0 4px, transparent 4px 8px); opacity: 0.6; }
  .ov-balance-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 11px; color: var(--text-dim); }
  .ov-balance-legend .it { display: inline-flex; align-items: center; gap: 5px; }
  .ov-balance-legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
  .ov-balance-err { color: var(--err); font-size: 12px; margin-top: 8px; display: flex; align-items: center; gap: 6px; }

  /* ---------- responsive ---------- */
  @media (min-width: 720px) {
    .meters { grid-template-columns: repeat(2, 1fr); }
    main { padding: 24px; }
    .hist-stats { grid-template-columns: repeat(4, 1fr); }
    .ov-kpis { grid-template-columns: repeat(4, 1fr); }
    .ov-grid {
      grid-template-columns: 1fr 1fr;
      grid-template-areas:
        "kpis    kpis"
        "alerts  alerts"
        "trend   trend"
        "status  ranking"
        "balance balance"
        "heatmap heatmap";
    }
    .ov-kpis         { grid-area: kpis; }
    .ov-area-trend   { grid-area: trend; }
    .ov-area-alerts  { grid-area: alerts; }
    .ov-area-balance { grid-area: balance; }
    .ov-area-ranking { grid-area: ranking; }
    .ov-area-status  { grid-area: status; }
    .ov-area-heatmap { grid-area: heatmap; }
  }
  @media (min-width: 1080px) {
    .meters { grid-template-columns: repeat(3, 1fr); }
  }

  /* Workstation desktop — 1280px+ */
  @media (min-width: 1280px) {
    main { max-width: 1600px; padding: 32px; }
    .meters { grid-template-columns: repeat(4, 1fr); }
    .live-trend-body { min-height: 160px; }
    .ov-grid { grid-template-columns: 2fr 1fr; gap: 16px; }
    .ov-chart { min-height: 200px; }
  }

  /* ---------- wall / TV monitoring view ---------- */
  /* Hidden by default — only rendered when route is #/wall. The router toggles
     `body.wall-mode`, which both reveals the view and strips chrome (topbar,
     tab bar) so the page reads cleanly on an unattended 1080p display. */
  #view-wall { display: none; }
  #view-wall.active { display: block; }

  body.wall-mode {
    background: #000;
  }
  body.wall-mode .topbar,
  body.wall-mode .updated {
    display: none !important;
  }
  body.wall-mode main {
    max-width: none;
    padding: 24px;
  }
  body.wall-mode #view-overview,
  body.wall-mode #view-live,
  body.wall-mode #view-history { display: none !important; }

  .wall-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    gap: 20px;
  }
  .wall-hero, .wall-phases, .wall-trend {
    background: #0a0a0a;
    border: 1px solid #1f1f1f;
    border-radius: 18px;
    padding: 24px;
    /* let grid tracks shrink below big tabular numbers (no horizontal blowout)
       and clip rather than overrun the panel on the kiosk */
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  .wall-hero-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
  .wall-hero-name { margin: 0; font-size: 28px; font-weight: 700; color: #fff; letter-spacing: -0.01em; text-transform: none; }
  .wall-hero-tag  { font-size: 14px; color: #9aa4b2; font-variant-numeric: tabular-nums; }

  .wall-kw {
    display: flex; align-items: baseline; gap: 12px;
    margin: 18px 0 8px;
    font-variant-numeric: tabular-nums;
  }
  .wall-kw-num  { font-size: clamp(64px, 11vw, 160px); font-weight: 800; color: #22d3ee; line-height: 1; letter-spacing: -0.04em; }
  .wall-kw-unit { font-size: clamp(20px, 2.4vw, 36px); color: #94a3b8; font-weight: 500; }

  .wall-gauge { width: 100%; max-width: 440px; }
  /* The dial's viewBox is near-square, so an unconstrained width:100% made it
     ~430px tall and pushed the hero off the bottom of the screen. Cap by height
     and let the SVG keep its own aspect ratio (width derives from the viewBox). */
  .wall-gauge svg { width: auto; height: 200px; max-width: 100%; display: block; }

  .wall-counters { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
  .wall-counter  { background: #050505; border: 1px solid #1a1a1a; border-radius: 12px; padding: 14px 18px; }
  .wall-counter-k { display: block; font-size: 12px; color: #9aa4b2; letter-spacing: 0.08em; text-transform: uppercase; }
  .wall-counter-v { display: block; font-size: clamp(28px, 3.6vw, 48px); font-weight: 700; color: #fff; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
  .wall-counter-v .sub { font-size: 0.42em; color: #9aa4b2; font-weight: 500; margin-left: 6px; }

  .wall-phases { display: grid; gap: 14px; }
  .wall-phase  {
    display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 18px;
    padding: 12px 18px;
    background: #050505;
    border: 1px solid #1a1a1a;
    border-radius: 14px;
  }
  .wall-phase-tag {
    display: inline-flex; align-items: center; justify-content: center;
    width: 54px; height: 54px;
    font-size: 26px; font-weight: 800;
    border-radius: 14px;
    color: #000;
  }
  .wall-phase-r .wall-phase-tag { background: var(--phase-r); }
  .wall-phase-y .wall-phase-tag { background: var(--phase-y); }
  .wall-phase-b .wall-phase-tag { background: var(--phase-b); }
  .wall-phase-r { border-left: 4px solid var(--phase-r); }
  .wall-phase-y { border-left: 4px solid var(--phase-y); }
  .wall-phase-b { border-left: 4px solid var(--phase-b); }

  .wall-phase-readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; font-variant-numeric: tabular-nums; }
  .wall-phase-readouts > div { display: flex; align-items: baseline; gap: 6px; }
  .wall-phase-v, .wall-phase-i { font-size: clamp(28px, 3.2vw, 44px); font-weight: 700; color: #fff; line-height: 1; }
  .wall-phase-r .wall-phase-v, .wall-phase-r .wall-phase-i { color: var(--phase-r-tint); }
  .wall-phase-y .wall-phase-v, .wall-phase-y .wall-phase-i { color: var(--phase-y-tint); }
  .wall-phase-b .wall-phase-v, .wall-phase-b .wall-phase-i { color: var(--phase-b-tint); }
  .wall-phase-u { font-size: 14px; color: #9aa4b2; font-weight: 500; }

  .wall-aux { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4px; }
  .wall-aux-item { background: #050505; border: 1px solid #1a1a1a; border-radius: 12px; padding: 12px 18px; }
  .wall-aux-k { display: block; font-size: 12px; color: #9aa4b2; letter-spacing: 0.08em; text-transform: uppercase; }
  .wall-aux-v { display: block; font-size: clamp(24px, 2.6vw, 36px); font-weight: 700; color: #fff; margin-top: 4px; font-variant-numeric: tabular-nums; }
  .wall-aux-v .sub { font-size: 0.5em; color: #9aa4b2; font-weight: 500; margin-left: 6px; }

  .wall-trend-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
  .wall-trend-title { font-size: 14px; color: #94a3b8; letter-spacing: 0.08em; text-transform: uppercase; }
  .wall-trend-sub   { font-size: 12px; color: #9aa4b2; font-variant-numeric: tabular-nums; }
  .wall-trend-body  { min-height: 220px; }

  /* On wide displays (1080p+ in landscape), arrange hero + phases side-by-side
     and fill exactly the locked viewport height — minmax(0,…) lets the tracks
     shrink so the grid is bounded by the screen, not by its content. */
  @media (min-width: 1280px) {
    /* Lock the kiosk to exactly one viewport so panels never spill past the
       display edges. vh first for Pi Chromium 88 (no dvh). Narrow viewports
       (phones opening #/wall) keep their natural scroll — no lock there. */
    body.wall-mode { overflow: hidden; }
    body.wall-mode main {
      padding: 32px;
      height: 100vh;
      height: 100dvh;
      overflow: hidden;
    }
    .wall-grid {
      height: 100%;
      grid-template-columns: 1.4fr 1fr;
      grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
      gap: 28px;
    }
    .wall-hero   { grid-column: 1; grid-row: 1 / span 2; }
    .wall-phases { grid-column: 2; grid-row: 1; }
    .wall-trend  { grid-column: 2; grid-row: 2; }
    /* trend chart fills its panel's remaining height instead of a fixed min */
    .wall-trend  { display: flex; flex-direction: column; }
    .wall-trend .wall-trend-body { flex: 1; min-height: 0; }
  }

  /* Wide workstation / 1080p+ — 1680px+ */
  @media (min-width: 1680px) {
    main { max-width: 1880px; }
    .meters { grid-template-columns: repeat(5, 1fr); }
    /* Sit history controls beside stats + chart instead of stacking */
    #view-history { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
    #view-history .hist-controls   { grid-column: 1; grid-row: 1 / span 2; position: sticky; top: 96px; }
    #view-history .hist-stats      { grid-column: 2; grid-row: 1; }
    #view-history .hist-chart-card { grid-column: 2; grid-row: 2; }
  }

  /* ============ APP SHELL — sidebar (desktop) / bottom-nav (mobile) ============ */
  :root { --side-w: 224px; --bottom-h: 60px; --topbar-h: 56px; }

  .app-side { display: none; }                 /* hidden on mobile */
  .app-bottom {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; gap: 2px;
    background: rgba(11,18,32,0.94);
    backdrop-filter: saturate(140%) blur(12px);
    -webkit-backdrop-filter: saturate(140%) blur(12px);
    border-top: 1px solid var(--line);
    /* viewport-fit=cover + Android 3-button nav reports safe-area-inset-bottom:0,
       which let the labels render under the system bar (clipped). Floor the bottom
       padding so the labels always clear it. */
    padding: 6px 4px max(10px, env(safe-area-inset-bottom));
    padding-left: calc(4px + env(safe-area-inset-left));
    padding-right: calc(4px + env(safe-area-inset-right));
  }
  main { padding-bottom: calc(var(--bottom-h) + 24px + env(safe-area-inset-bottom)); }

  /* nav items shared by both surfaces */
  .nav-item {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: transparent; border: none; color: var(--text-mute);
    min-height: 48px; padding: 4px; border-radius: 10px;
    font-family: inherit; font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
    -webkit-tap-highlight-color: transparent; position: relative; cursor: pointer;
  }
  .nav-item[hidden] { display: none !important; }   /* role-gated items: make the `hidden` attr win over .nav-item{display:flex} */
  .nav-item .nav-ico { width: 22px; height: 22px; flex: none; }
  .nav-item .nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; line-height: 1.3; padding-bottom: 1px; }
  .nav-item.active { color: var(--accent); }
  .nav-item:active { transform: scale(0.96); }
  .nav-badge {
    position: absolute; top: 3px; left: 50%; transform: translateX(6px);
    min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px;
    background: var(--err); color: #fff; font-size: 9px; font-weight: 700;
    line-height: 15px; text-align: center;
  }

  /* page headers for the new pages */
  .page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
  .page-title { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; text-transform: none; color: var(--text); }
  .page-sub { font-size: 12px; color: var(--text-dim); }
  .page-tools { display: flex; gap: 8px; align-items: center; }

  @media (min-width: 720px) {
    #dash.shown { display: grid; grid-template-columns: var(--side-w) 1fr; align-items: start; }
    .app-bottom { display: none; }
    .app-main { min-width: 0; }                 /* prevent 1fr column blowout */
    main { padding-bottom: 24px; }

    .app-side {
      display: flex; flex-direction: column; gap: 4px;
      position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
      background: var(--bg-2); border-right: 1px solid var(--line);
      padding: 14px 10px;
    }
    .side-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px 14px; }
    .side-head .dot { flex: none; }
    .side-brand { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; flex: 1; }
    .side-collapse {
      background: transparent; border: 1px solid var(--line); color: var(--text-dim);
      width: 28px; height: 28px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; flex: none; cursor: pointer;
    }
    .side-collapse svg { width: 16px; height: 16px; }
    .side-collapse:hover { color: var(--text); border-color: var(--text-dim); }
    .side-nav { display: flex; flex-direction: column; gap: 3px; }
    .side-nav .nav-item {
      flex-direction: row; justify-content: flex-start; gap: 12px;
      min-height: 42px; padding: 0 12px; font-size: 13.5px; border-radius: 10px;
      color: var(--text-dim);
    }
    .side-nav .nav-item { transition: background .15s ease, color .15s ease; }
    .side-nav .nav-item .nav-ico { transition: color .15s ease; }
    .side-nav .nav-item .nav-label { flex: 1; text-align: left; }
    .side-nav .nav-item:hover { background: var(--surface); color: var(--text); }
    .side-nav .nav-item.active { background: var(--surface-2); color: var(--text); }
    .side-nav .nav-item.active .nav-ico { color: var(--accent); }
    /* tab-style indicator: vertically-centered accent bar, absolutely positioned
       so it never shifts the icon/label (the old inset box-shadow made the icon
       look shoved right). */
    .side-nav .nav-item.active::before {
      content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
      width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent);
    }
    .side-nav .nav-item .nav-badge { position: static; transform: none; margin-left: auto; }
    /* desktop topbar drops the duplicate brand; keeps tenant + account block */
    .topbar .brand > .dot, .topbar .brand > h1 { display: none; }

    body.side-collapsed { --side-w: 64px; }
    /* Collapsed: hide brand + labels but KEEP the toggle reachable (it was being
       display:none'd, a dead-end). Flip its chevron to mean "expand". */
    body.side-collapsed .side-brand,
    body.side-collapsed .side-nav .nav-label { display: none; }
    body.side-collapsed .side-collapse { display: inline-flex; }
    body.side-collapsed .side-collapse svg { transform: rotate(180deg); }
    body.side-collapsed .side-nav .nav-item { justify-content: center; padding: 0; gap: 0; }
    body.side-collapsed .side-nav .nav-item .nav-ico { width: 24px; height: 24px; }
    /* collapsed: drop the left accent bar (icon is centered — a left bar reads as
       off-center) and let the tinted pill + accent icon carry the active state. */
    body.side-collapsed .side-nav .nav-item.active::before { display: none; }
    body.side-collapsed .side-head { justify-content: center; padding: 4px 0 14px; }
  }

  /* wall/kiosk strips the shell entirely */
  body.wall-mode .app-side,
  body.wall-mode .app-bottom { display: none !important; }
  body.wall-mode #dash { display: block; }

  /* keep the mobile topbar from crowding at 360–430px */
  .topbar { min-height: var(--topbar-h); }
  @media (max-width: 430px) { .user-email { display: none; } }

  /* page-level horizontal-overflow guard (main has no sticky descendants, so
     this is safe and stops any single wide child pushing the page offscreen) */
  main { overflow-x: hidden; }

  /* ---------- maintenance insights (superadmin) ---------- */
  .insights-body { padding: 2px 0 24px; }
  .insights-summary {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin: 4px 0 14px;
  }
  .ins-pill {
    font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
    letter-spacing: 0.01em;
  }
  .ins-pill.ins-critical { background: rgba(239,68,68,0.16);  color: var(--err);  }
  .ins-pill.ins-warn     { background: rgba(245,158,11,0.16); color: var(--warn); }
  .ins-pill.ins-info     { background: rgba(56,189,248,0.16); color: var(--accent); }
  .insights-asof { margin-left: auto; font-size: 11.5px; color: var(--text-mute); }

  .insights-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
  @media (min-width: 760px)  { .insights-grid { grid-template-columns: 1fr 1fr; } }
  @media (min-width: 1180px) { .insights-grid { grid-template-columns: 1fr 1fr 1fr; } }

  .ins-card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 12px 14px;
    border-left-width: 3px;
  }
  .ins-card-critical { border-left-color: var(--err);  }
  .ins-card-warn     { border-left-color: var(--warn); }
  .ins-card-info     { border-left-color: var(--accent); }
  .ins-card-head {
    display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px;
  }
  .ins-meter { font-size: 14px; font-weight: 600; color: var(--text); }
  .ins-meter-id { font-size: 11px; color: var(--text-mute); font-family: var(--mono); }

  .ins-finding { padding: 8px 0; border-top: 1px solid var(--line); }
  .ins-finding:first-of-type { border-top: none; padding-top: 0; }
  .ins-finding-head { display: flex; align-items: center; gap: 7px; }
  .ins-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
  .ins-critical .ins-dot { background: var(--err);  }
  .ins-warn .ins-dot     { background: var(--warn); }
  .ins-info .ins-dot     { background: var(--accent); }
  .ins-rule { font-size: 13px; font-weight: 600; color: var(--text); }
  .ins-metric {
    font-family: var(--mono); font-size: 12.5px; font-weight: 600;
    color: var(--text-dim); margin-left: 2px;
  }
  .ins-live {
    margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
    text-transform: uppercase; color: var(--accent);
    background: rgba(56,189,248,0.14); padding: 2px 6px; border-radius: 5px;
  }
  .ins-detail { font-size: 12.5px; line-height: 1.45; color: var(--text-dim); margin-top: 4px; padding-left: 15px; }

  .insights-allclear {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    gap: 6px; padding: 48px 20px; color: var(--text-dim);
  }
  .insights-allclear svg { color: var(--ok); }
  .insights-allclear-t { font-size: 16px; font-weight: 600; color: var(--text); }
  .insights-allclear-s { font-size: 12.5px; max-width: 360px; color: var(--text-mute); }

  /* ====================================================================
     DEMO FUNNEL — login CTA, lead modal, demo ribbon, leads page
     ==================================================================== */

  /* "or" divider + demo CTA on the login card */
  .login-or {
    display: flex; align-items: center; gap: 10px;
    margin: 14px 0 12px; color: var(--text-mute); font-size: 12px;
  }
  .login-or::before, .login-or::after {
    content: ""; flex: 1; height: 1px; background: var(--line);
  }
  .demo-btn {
    width: 100%; min-height: 46px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: transparent; color: var(--text);
    border: 1px solid var(--line); border-radius: 10px;
    font-size: 14px; font-weight: 600;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
  }
  .demo-btn svg { color: var(--accent); }
  .demo-btn:hover { border-color: var(--accent); background: rgba(56,189,248,0.08); }
  .demo-btn:active { transform: scale(0.98); }

  /* lead-capture modal */
  .lead-backdrop {
    position: fixed; inset: 0; background: rgba(2,6,16,0.66);
    backdrop-filter: blur(2px); opacity: 0; pointer-events: none;
    transition: opacity 0.18s ease; z-index: 80;
  }
  .lead-backdrop.open { opacity: 1; pointer-events: auto; }
  .lead-modal {
    position: fixed; z-index: 81;
    left: 50%; top: 50%; transform: translate(-50%, -46%) scale(0.98);
    width: min(560px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);     /* fallback for older browsers (Pi Chromium 88) */
    max-height: calc(100dvh - 28px); overflow-y: auto;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; opacity: 0; pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }
  .lead-modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
  .lead-modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
  .lead-modal-head h3 { font-size: 18px; font-weight: 700; }
  .lead-modal-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-dim); }
  .lead-form { display: flex; flex-direction: column; gap: 12px; }
  .lead-row2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
  .lead-field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-dim); }
  .lead-field em { font-style: normal; color: var(--text-mute); }
  .lead-field input, .lead-field select {
    width: 100%; min-height: 44px; padding: 0 12px;
    background: var(--bg-2); color: var(--text);
    border: 1px solid var(--line); border-radius: 9px;
    font-size: 15px; font-family: inherit;
  }
  .lead-field input:focus, .lead-field select:focus { outline: none; border-color: var(--accent); }
  .lead-error { min-height: 1em; font-size: 12.5px; color: var(--err); }
  .lead-error.lead-error-ok { color: var(--ok); }
  .lead-submit {
    width: 100%; min-height: 48px; border: none; border-radius: 10px;
    background: var(--accent); color: #04223a; font-size: 15px; font-weight: 700;
    transition: filter 0.15s ease, transform 0.08s ease;
  }
  .lead-submit:hover { filter: brightness(1.06); }
  .lead-submit:active { transform: scale(0.98); }
  .lead-submit:disabled { opacity: 0.6; cursor: default; }
  .lead-continue {
    width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px;
    background: transparent; color: var(--text); font-size: 13.5px; font-weight: 600;
  }
  .lead-priv { margin: 2px 0 0; font-size: 11.5px; color: var(--text-mute); text-align: center; }

  /* demo-mode ribbon (top of the dashboard while in the prospect demo) */
  /* Hidden for EVERYONE by default — only shown inside the prospect demo.
     (A bare `.demo-ribbon{display:flex}` would override [hidden] and leak the
     ribbon onto every real user's dashboard.) */
  .demo-ribbon { display: none; }
  body.demo-mode .demo-ribbon {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; font-size: 13px; color: #04223a;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    position: sticky; top: 0; z-index: 60;
    /* #dash is a 2-col grid on desktop (sidebar | main); the ribbon must span
       the whole row, otherwise it steals the sidebar column and wrecks the
       layout (and blows out the main column width). Ignored in mobile block flow. */
    grid-column: 1 / -1;
  }
  .demo-ribbon b { font-weight: 800; }
  .demo-ribbon-text { flex: 1; }
  .demo-ribbon-dot { width: 9px; height: 9px; border-radius: 50%; background: #04223a; animation: demo-pulse 1.6s ease-in-out infinite; }
  @keyframes demo-pulse { 0%,100% { opacity: 0.45; } 50% { opacity: 1; } }
  .demo-ribbon-exit {
    border: 1px solid rgba(4,34,58,0.4); background: rgba(255,255,255,0.18);
    color: #04223a; font-weight: 700; font-size: 12.5px;
    padding: 5px 12px; border-radius: 8px; min-height: 32px;
  }
  .demo-ribbon-exit:hover { background: rgba(255,255,255,0.32); }
  /* in demo, the sticky ribbon sits above the topbar; nudge bottom-nav clear of nothing */
  body.demo-mode .site-identity { opacity: 0.95; }

  /* leads page (superadmin) */
  .leads-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .lead-chip {
    font-size: 12px; font-weight: 600; color: var(--text-dim);
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 999px; padding: 4px 11px;
  }
  .lead-chip-new { color: var(--bg); background: var(--accent); border-color: var(--accent); }
  .lead-chip-total { color: var(--text); }
  /* Mobile-first: a 5-column table can't fit 360px, so each lead renders as a
     stacked card on phones; the real table layout returns at ≥720px. */
  .leads-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
  .leads-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .leads-table thead { display: none; }                 /* header row only makes sense in table mode */
  .leads-table tr.lead-row { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .leads-table tbody tr.lead-row:last-child { border-bottom: none; }
  .leads-table td { display: block; padding: 2px 0; border: none; vertical-align: top; }
  .lead-name { font-weight: 600; color: var(--text); font-size: 14px; }
  .lead-co { color: var(--text-dim); font-size: 12px; }
  .lead-c-seg { color: var(--text-dim); font-size: 12.5px; margin-top: 5px; }
  .lead-c-seg::before { content: "Segment: "; color: var(--text-mute); }
  .lead-conn { margin-left: 6px; font-size: 11px; color: var(--text-mute); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
  .lead-c-contact { margin-top: 6px; }
  .lead-c-contact a { display: inline-block; margin-right: 10px; color: var(--accent); text-decoration: none; font-size: 12.5px; }
  .lead-c-contact a.lead-mail { display: block; margin-top: 3px; color: var(--text-dim); overflow-wrap: anywhere; }
  .lead-c-contact a.lead-wa { color: var(--ok); }
  .lead-c-when { color: var(--text-mute); font-size: 12px; margin-top: 6px; }
  .lead-c-when::before { content: "Received: "; }
  .lead-c-act { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
  .lead-status { flex: 1 1 auto; background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 7px; min-height: 38px; padding: 0 8px; font-family: inherit; }
  .lead-del { flex: none; border: 1px solid var(--line); background: transparent; color: var(--text-mute); border-radius: 7px; width: 38px; height: 38px; line-height: 1; }
  .lead-del:hover { color: var(--err); border-color: var(--err); }
  .lead-row.lead-st-new { background: rgba(56,189,248,0.05); }
  .lead-row.lead-st-closed { opacity: 0.6; }

  @media (min-width: 720px) {
    .leads-table { min-width: 640px; }
    .leads-table thead { display: table-header-group; }
    .leads-table th {
      text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
      color: var(--text-mute); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg-2);
    }
    .leads-table tr.lead-row { display: table-row; padding: 0; }
    .leads-table td { display: table-cell; padding: 11px 12px; border-bottom: 1px solid var(--line); }
    .leads-table tbody tr:last-child td { border-bottom: none; }
    .lead-c-seg::before, .lead-c-when::before { content: none; }
    .lead-c-seg, .lead-c-contact, .lead-c-when { margin-top: 0; }
    .lead-c-when { white-space: nowrap; }
    .lead-c-act { display: table-cell; }
    .lead-status { flex: none; }
    .lead-del { display: inline-block; margin-left: 8px; width: 34px; height: 34px; }
  }

  /* desktop: two-column lead fields */
  @media (min-width: 560px) {
    .lead-row2 { grid-template-columns: 1fr 1fr; }
  }

/* ───────────── zoom-on-load guard ─────────────
   Mobile browsers may auto-inflate text on first paint (text auto-sizing),
   which reads as the page "zooming in" right after load. Pin it to 100%. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* Final safety net: never let any row (e.g. the topbar when the superadmin
   tenant switcher appears) widen the page past the viewport and force a zoom. */
body { overflow-x: hidden; }

/* ───────────── mobile "Admin" popup sheet ─────────────
   Collapses the superadmin/admin pages off the 360px bottom bar. Reuses the
   shared .sheet-backdrop. Only ever opened on mobile (the trigger lives in the
   bottom bar, which is display:none on desktop). */
.admin-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 8px 14px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  visibility: hidden;                                   /* see .sheet above */
  transition: transform 0.25s ease, visibility 0s 0.25s;
  z-index: 60;
  box-shadow: 0 -24px 64px -16px rgba(0,0,0,0.6);
}
.admin-sheet.open { transform: translateY(0); visibility: visible; transition: transform 0.25s ease; }
.admin-sheet-title { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; margin: 2px 4px 10px; }
.admin-sheet-list { display: flex; flex-direction: column; gap: 4px; }
.admin-sheet-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 52px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); font-size: 15px; font-weight: 600; text-align: left;
}
.admin-sheet-item:active { transform: scale(0.99); }
/* role-gated items set the `hidden` attr in JS; `display:flex` above beats the UA
   `[hidden]{display:none}`, so restore it — otherwise a normal admin sees the
   superadmin pages (Online Users / Notifications / Maintenance / Leads) in this popup */
.admin-sheet-item[hidden] { display: none !important; }
.admin-sheet-item svg { width: 22px; height: 22px; color: var(--text-dim); flex: none; }
.nav-admin-trigger.active { color: var(--accent); }

/* ───────────── Online Users (presence) page ───────────── */
.presence-count {
  font-size: 12px; font-weight: 700; color: var(--ok);
  background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.35);
  border-radius: 999px; padding: 4px 11px; white-space: nowrap;
}
.pr-site { margin-bottom: 18px; }
.pr-site-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 0 2px 8px; border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.pr-site-name { font-size: 13px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.04em; }
.pr-site-on { font-size: 11px; color: var(--text-mute); }
.pr-user {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); margin-bottom: 8px; overflow: hidden;
}
.pr-user.pr-st-active { border-color: rgba(34,197,94,0.40); background: rgba(34,197,94,0.05); }
.pr-user.pr-st-idle   { border-color: rgba(245,158,11,0.40); background: rgba(245,158,11,0.05); }
.pr-user-head { display: flex; align-items: center; gap: 12px; padding: 11px 10px; }
.pr-user-head.pr-toggle { cursor: pointer; user-select: none; }
.pr-user-head.pr-toggle:hover { background: rgba(148,163,184,0.05); }
.pr-chevron { flex: none; color: var(--text-mute); font-size: 12px; line-height: 1; transition: transform 0.15s ease; }
.pr-chevron.open { transform: rotate(180deg); }
.pr-devices { border-top: 1px dashed var(--line); padding: 6px 10px 8px 34px; display: flex; flex-direction: column; gap: 4px; }
/* Expanded last-10-login history (absolute timestamps, never relative) */
.pr-logins { border-top: 1px dashed var(--line); padding: 8px 10px 10px 34px; display: flex; flex-direction: column; gap: 6px; }
.pr-logins[hidden] { display: none; }
.pr-logins-h { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-mute); }
.pr-login-row { display: flex; align-items: baseline; gap: 8px 10px; font-size: 12px; color: var(--text-dim); flex-wrap: wrap; }
.pr-login-dev { font-weight: 600; color: var(--text-dim); flex: none; }
.pr-login-when { color: var(--text); font-variant-numeric: tabular-nums; }
.pr-login-dur { color: var(--text-mute); }
.pr-login-dur.live { color: var(--ok); font-weight: 600; }
.pr-login-ip { margin-left: auto; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.pr-login-loading, .pr-login-empty { color: var(--text-mute); font-style: italic; }
.pr-devrow { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-mute); }
.pr-devrow.active .pr-devname, .pr-devrow.idle .pr-devname { color: var(--text-dim); }
.pr-devname { font-weight: 600; }
.pr-devseen { margin-left: auto; text-align: right; white-space: nowrap; }
.pr-devrow.active .pr-devseen { color: var(--ok); }
.pr-devrow.idle .pr-devseen { color: var(--warn); }
.pr-dot.small { width: 8px; height: 8px; box-shadow: none; }
.pr-dot.small.live { box-shadow: 0 0 0 2px rgba(34,197,94,0.18); }
.pr-dot.small.idle { box-shadow: 0 0 0 2px rgba(245,158,11,0.20); }
.pr-dot {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  background: var(--text-mute); box-shadow: 0 0 0 3px rgba(148,163,184,0.12);
}
.pr-dot.live {
  background: var(--ok); box-shadow: 0 0 0 3px rgba(34,197,94,0.18);
  animation: live-pulse 1.6s ease-in-out infinite;
}
/* idle = connected, data showing, but no recent interaction. Steady amber (no
   pulse) so it reads as distinct from the pulsing-green "active". */
.pr-dot.idle { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,158,11,0.20); }
.pr-who { flex: 1 1 auto; min-width: 0; }
.pr-name { font-size: 14.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pr-sub { font-size: 12px; color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-meta { text-align: right; flex: none; }
.pr-seen { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.pr-user.pr-st-active .pr-seen { color: var(--ok); }
.pr-user.pr-st-idle .pr-seen { color: var(--warn); }
.pr-dev { font-size: 11px; color: var(--text-mute); margin-top: 2px; }
.pr-role {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  border-radius: 5px; padding: 1px 6px; border: 1px solid var(--line); color: var(--text-mute);
}
.pr-role-superadmin { color: var(--accent); border-color: var(--accent); }
.pr-role-admin { color: var(--warn); border-color: var(--warn); }
