/* PlugSure Enterprise Console — design system.
 *
 * One stylesheet, no framework. Tokens first; components are small and
 * composable. High-density by default (13–14 px body, 32 px controls) because
 * the console is a NOC tool, with enough whitespace that a table of 200
 * chargers is still scannable. Light and dark follow the OS unless the user
 * picks one (html[data-theme]).
 */

:root {
  --brand: #1b4d8c;
  --brand-2: #2fd6a7;
  --bg: #f4f6f9;
  --bg-2: #eceff4;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #636b78;   /* ≥4.5:1 on every light surface incl. --bg-2 tags (was #6b7280, 4.19:1) */
  --line: #e2e6ec;
  --line-2: #d3d9e1;
  --accent: #0c7856;  /* 4.8:1 on --accent-soft tags (was exactly on the 4.5 line) */
  --accent-ink: #ffffff;
  --accent-soft: #e3f4ed;
  --info: #1d63c9;
  --info-soft: #e5effc;
  --warn: #a15c07;
  --warn-soft: #fdf1d8;
  --crit: #b42318;
  --crit-soft: #fde6e4;
  /* Text on a SOLID crit / warn fill (danger buttons, alert badge, toasts).
     White in light mode; dark in dark mode, where the fills are light pastels
     and white on them fell to 1.9–2.5:1. Same idea as --accent-ink. */
  --crit-ink: #ffffff;
  --warn-ink: #ffffff;
  /* Dimming behind the menu, drawers and dialogs. A slate tint works on a light
     page; on a dark page it changed nothing (1.01:1), so dark mode uses black. */
  --scrim: rgba(15, 23, 42, .35);
  --scrim-strong: rgba(15, 23, 42, .45);
  --focus: #2563eb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16), 0 2px 6px rgba(16, 24, 40, .08);
  --radius: 10px;
  --radius-sm: 7px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 232px;
  --header-h: 56px;
  /* Edge of form fields and segmented controls (the boundary that identifies them). */
  --field-line: var(--line-2);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --bg-2: #11161d; --panel: #151b23; --panel-2: #1a212b; --ink: #e6e9ee; --ink-2: #c3c9d2;
    --muted: #98a2af; --line: #252d38; --line-2: #313b48; --accent: #34c38f; --accent-ink: #06231a;
    --accent-soft: #12342a; --info: #6aa5ff; --info-soft: #14263f; --warn: #f0b429; --warn-soft: #3a2c0c;
    --crit: #ff7b72; --crit-soft: #3d1d1a; --focus: #6aa5ff; --crit-ink: #2b0b08; --warn-ink: #2a1c02; --scrim: rgba(0, 0, 0, .6); --scrim-strong: rgba(0, 0, 0, .66);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
    /* Field edges were --line-2 at 1.53:1 — an empty field nearly vanished on a dark
       panel. 3.2–3.7:1 on panel, page and panel-2 (WCAG 1.4.11 asks 3:1). */
    --field-line: #646f7d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --bg-2: #11161d; --panel: #151b23; --panel-2: #1a212b; --ink: #e6e9ee; --ink-2: #c3c9d2;
  --muted: #98a2af; --line: #252d38; --line-2: #313b48; --accent: #34c38f; --accent-ink: #06231a;
  --accent-soft: #12342a; --info: #6aa5ff; --info-soft: #14263f; --warn: #f0b429; --warn-soft: #3a2c0c;
  --crit: #ff7b72; --crit-soft: #3d1d1a; --focus: #6aa5ff; --crit-ink: #2b0b08; --warn-ink: #2a1c02; --scrim: rgba(0, 0, 0, .6); --scrim-strong: rgba(0, 0, 0, .66);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  --field-line: #646f7d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 13.5px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
code, .mono { font-family: var(--mono); font-size: 12px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.shell.collapsed { --sidebar-w: 60px; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden;
  background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; height: var(--header-h); padding: 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.brand svg { width: 28px; height: 28px; flex: none; }
/* White-label console (v1.5.0): the operator's logo, or its initials on its colour. */
.brand-logo { width: 28px; height: 28px; flex: none; border-radius: 7px; object-fit: contain; }
.brand-tile { display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 700; font-size: 12px; letter-spacing: .02em; }
.login-brand .brand-logo, .login-brand svg { width: 40px; height: 40px; border-radius: 10px; }
.login-brand .brand-tile { font-size: 16px; }
.sidebar-foot .powered-by { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.shell.collapsed .sidebar-foot .powered-by { display: none; }
.brand b { font-size: 16px; letter-spacing: -.02em; white-space: nowrap; }
.brand small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.nav { padding: 10px 8px 16px; flex: 1; }
.nav-group { margin-top: 12px; }
.nav-group > .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 6px 10px; font-weight: 600; white-space: nowrap; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500; white-space: nowrap; text-decoration: none; position: relative;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: var(--bg-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav a[aria-current="page"] svg { opacity: 1; }
.nav a .count { margin-left: auto; font-size: 11px; background: var(--crit); color: var(--crit-ink); border-radius: 99px; padding: 0 6px; min-width: 18px; text-align: center; }
.shell.collapsed .nav a span, .shell.collapsed .nav-group > .label, .shell.collapsed .brand b, .shell.collapsed .nav a .count { display: none; }
.shell.collapsed .nav a { justify-content: center; }
.sidebar-foot { padding: 10px 12px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.shell.collapsed .sidebar-foot { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--header-h); display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .crumbs { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .crumbs .sub { color: var(--muted); font-weight: 500; }
.topbar .spacer { flex: 1; }
.search { position: relative; width: min(360px, 32vw); }
.search input { width: 100%; padding-left: 32px; }
.search > svg { position: absolute; left: 9px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }
.search .results svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
/* Two classes deep, so .btn's own display cannot win and show them on desktop. */
.topbar .mobile-only, .search .search-close { display: none; }
.search .results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 360px; overflow: auto; z-index: 40;
}
.search .results a { display: flex; gap: 10px; align-items: center; padding: 8px 12px; color: var(--ink); border-bottom: 1px solid var(--line); }
.search .results a:last-child { border-bottom: 0; }
.search .results a:hover, .search .results a.active { background: var(--bg-2); text-decoration: none; }
.live-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--muted); display: inline-block; }
.live-dot.on { background: var(--accent); animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.userchip { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.avatar { width: 28px; height: 28px; border-radius: 99px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.userchip .who { line-height: 1.15; }
.userchip .who small { display: block; color: var(--muted); font-size: 11px; }
.menu {
  position: absolute; right: 16px; top: calc(var(--header-h) - 4px); min-width: 220px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50;
}
.menu button, .menu a { display: flex; width: 100%; gap: 8px; align-items: center; text-align: left; padding: 7px 10px; border: 0; background: none; color: var(--ink); border-radius: var(--radius-sm); font: inherit; cursor: pointer; }
.menu button:hover, .menu a:hover { background: var(--bg-2); text-decoration: none; }
.menu svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.content { padding: 20px 24px 48px; max-width: 1600px; width: 100%; }

/* ------------------------------------------------------------------ page chrome */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; }
.page-head p { margin: 2px 0 0; color: var(--muted); max-width: 90ch; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.section { margin-top: 22px; }
.section > h2 { font-size: 14.5px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.hint { color: var(--muted); font-size: 12.5px; max-width: 90ch; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.grow { flex: 1; }
.right { margin-left: auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.wrap { white-space: normal; word-break: break-word; }
.grid { display: grid; gap: 14px; }
/* min(…, 100%): a column never demands more than the container has — without it
   a 380px minimum pushed the whole page sideways on a 375px phone. */
.grid.k4 { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.grid.k3 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.grid > * { min-width: 0; }

/* ------------------------------------------------------------------ cards / kpis */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 16px; }
.card > header { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card > header h3 { font-size: 13.5px; }
.card > .body { padding: 14px 16px; }
.kpi { padding: 14px 16px; }
.kpi .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.crit .value { color: var(--crit); }
.kpi.warn .value { color: var(--warn); }
.kpi.ok .value { color: var(--accent); }
.meter { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.meter > i.warn { background: var(--warn); }
.meter > i.crit { background: var(--crit); }

/* ------------------------------------------------------------------ tags */
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; line-height: 1.6; background: var(--bg-2); color: var(--muted); }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; opacity: .8; }
.tag.plain::before { display: none; }
.t-ok { background: var(--accent-soft); color: var(--accent); }
.t-info { background: var(--info-soft); color: var(--info); }
.t-warn { background: var(--warn-soft); color: var(--warn); }
.t-crit { background: var(--crit-soft); color: var(--crit); }
.t-mute { background: var(--bg-2); color: var(--muted); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); border-radius: var(--radius-sm);
  font: 500 13px/1 var(--sans); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: var(--crit); border-color: var(--crit); color: var(--crit-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-2); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.icon { width: 32px; padding: 0; }
.btn[disabled], .btn.busy { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn.busy::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 99px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.seg { display: inline-flex; border: 1px solid var(--field-line); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: none; padding: 0 12px; height: 30px; font: 500 12.5px var(--sans); color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------------ forms */
input, select, textarea {
  font: 13px var(--sans); color: var(--ink); background: var(--panel); border: 1px solid var(--field-line);
  border-radius: var(--radius-sm); height: 32px; padding: 0 10px; min-width: 0;
}
textarea { height: auto; padding: 8px 10px; min-height: 80px; resize: vertical; font-family: var(--mono); font-size: 12px; }
input[type="checkbox"], input[type="radio"] { height: auto; width: 16px; height: 16px; accent-color: var(--accent); }
input[type="range"] { padding: 0; border: 0; background: transparent; height: 24px; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
/* Hints like "Find a charger, site or card…" are read, not decoration; the browser
   default grey fell to 3.8:1 on dark panels. */
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--crit); background: var(--crit-soft); }
.form { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
.form.one { grid-template-columns: 1fr; }
.form .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field > .lbl { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field > label .opt { font-weight: 400; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; }
.field .help { font-size: 11.5px; color: var(--muted); }
.field .err { font-size: 11.5px; color: var(--crit); font-weight: 500; }
.inputgroup { display: flex; }
.inputgroup input { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1; }
.inputgroup .btn, .inputgroup .suffix { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.inputgroup .suffix { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--field-line); background: var(--panel-2); color: var(--muted); border-radius: var(--radius-sm); font-size: 12px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0; min-width: 0; }
legend { font-size: 12px; font-weight: 650; padding: 0 6px; color: var(--ink-2); }
.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 2px; flex: none; width: auto; height: auto; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 16px; padding: 4px 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.filters .field { min-width: 150px; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.t th {
  position: sticky; top: 0; background: var(--panel-2); text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); font-weight: 600; white-space: nowrap;
}
table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.clickable { cursor: pointer; }
table.t tbody tr.clickable:hover td { background: var(--panel-2); }
table.t td.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
table.t th.num, table.t td.num { text-align: right; }
table.t tfoot td { font-weight: 650; background: var(--panel-2); border-top: 1px solid var(--line); }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 11.5px; color: var(--muted); }
pre.json { margin: 0; font: 11.5px/1.45 var(--mono); white-space: pre-wrap; word-break: break-all; color: var(--ink-2); max-height: 220px; overflow: auto; }

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 12px; font: 500 13px var(--sans); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--ink); }

/* ------------------------------------------------------------------ overlays */
.backdrop { position: fixed; inset: 0; background: var(--scrim-strong); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(560px, 100%); display: flex; flex-direction: column; max-height: 88vh; animation: rise .18s; }
.modal.lg { width: min(820px, 100%); }
.modal.xl { width: min(1080px, 100%); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.modal > header { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.modal > header h2 { font-size: 16px; }
.modal > header p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.modal > .body { padding: 16px 20px; overflow-y: auto; }
.modal > footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 14px 14px; }
.drawer-backdrop { position: fixed; inset: 0; background: var(--scrim); z-index: 55; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(920px, 96vw); background: var(--bg); border-left: 1px solid var(--line-2); z-index: 56; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer > header { display: flex; gap: 12px; align-items: flex-start; padding: 16px 20px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.drawer > header .title { flex: 1; min-width: 0; }
.drawer > header h2 { font-size: 17px; }
.drawer > header .tabs { margin: 10px 0 0; border-bottom: 0; }
.drawer .dhead { padding: 16px 20px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.drawer > .body { flex: 1; overflow-y: auto; padding: 18px 20px 40px; }
.x { border: 0; background: none; color: var(--muted); cursor: pointer; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.x:hover { background: var(--bg-2); color: var(--ink); }
.x svg { width: 18px; height: 18px; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: var(--ink); color: var(--panel); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 420px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; animation: rise .2s; }
.toast.ok { background: var(--accent); color: var(--accent-ink); }
.toast.crit { background: var(--crit); color: var(--crit-ink); }
.toast.warn { background: var(--warn); color: var(--warn-ink); }

/* ------------------------------------------------------------------ callouts */
.callout { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12.5px; background: var(--info-soft); color: var(--ink-2); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout.crit { background: var(--crit-soft); border-color: color-mix(in srgb, var(--crit) 30%, transparent); }
.callout.ok { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.callout svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.card > header h3 svg { width: 18px; height: 18px; flex: none; vertical-align: -3px; margin-right: 4px; }
.callout b { color: var(--ink); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state h3 { color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--bg-2), var(--panel-2), var(--bg-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------------ key/value */
dl.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; word-break: break-word; }

/* ------------------------------------------------------------------ steps (wizard) */
.steps { display: flex; gap: 0; margin-bottom: 18px; counter-reset: step; }
.steps li { list-style: none; flex: 1; position: relative; padding-top: 30px; text-align: center; font-size: 12px; color: var(--muted); counter-increment: step; }
.steps li::before { content: counter(step); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 24px; height: 24px; border-radius: 99px; border: 2px solid var(--line-2); background: var(--panel); display: grid; place-items: center; font-weight: 700; font-size: 11.5px; z-index: 1; }
.steps li::after { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--line-2); }
.steps li:first-child::after { display: none; }
.steps li.done::before { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); content: "✓"; }
.steps li.done::after, .steps li.active::after { background: var(--accent); }
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active::before { border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------------ connector tiles */
.plugs { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.plug { border: 1.5px solid var(--line-2); border-radius: var(--radius); padding: 10px 8px; text-align: center; cursor: pointer; background: var(--panel); font-size: 12px; font-weight: 600; color: var(--ink-2); }
.plug svg { width: 34px; height: 34px; display: block; margin: 0 auto 6px; color: var(--muted); }
.plug small { display: block; font-weight: 500; color: var(--muted); font-size: 10.5px; }
.plug[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.plug[aria-pressed="true"] svg { color: var(--accent); }
.evse-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); padding: 14px; margin-bottom: 12px; }
.evse-card > .head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.conn-tile { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--panel); }
.conn-tile .top { display: flex; align-items: center; gap: 8px; }
.conn-tile .big { font-size: 18px; font-weight: 650; }

/* ------------------------------------------------------------------ DLM */
.slider-wrap { position: relative; padding: 18px 0 6px; }
.slider-wrap input[type="range"] { width: 100%; }
.slider-wrap.over input[type="range"] { accent-color: var(--crit); }
.slider-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.cap-mark { position: absolute; top: 0; font-size: 10.5px; color: var(--crit); font-weight: 600; transform: translateX(-50%); white-space: nowrap; }
.big-switch { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius); border: 1.5px solid var(--line-2); background: var(--panel); }
.big-switch.on { border-color: var(--crit); background: var(--crit-soft); }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 99px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 99px; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--crit); }
.switch.green input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); cursor: grab; }
.rank-list li.dragging { opacity: .5; }
.rank-list li.over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.rank-list .grip { color: var(--muted); cursor: grab; }
.rank-list .pos { width: 22px; height: 22px; border-radius: 99px; background: var(--bg-2); display: grid; place-items: center; font-size: 11px; font-weight: 700; }

/* ------------------------------------------------------------------ charts */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 8px; }
.bars .b { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; opacity: .85; }
.bars .b:hover { opacity: 1; }
.bars-x { display: flex; gap: 4px; font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.bars-x span { flex: 1; text-align: center; }
.stackbar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--bg-2); }
.stackbar i { display: block; height: 100%; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; background: var(--c); vertical-align: -1px; }

/* ------------------------------------------------------------------ map picker */
.map { position: relative; height: 280px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #dfe7ee; cursor: crosshair; touch-action: none; user-select: none; }
.map img { position: absolute; width: 256px; height: 256px; max-width: none; pointer-events: none; }
.map .pin { position: absolute; width: 26px; height: 26px; transform: translate(-50%, -100%); pointer-events: none; color: var(--crit); filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.map .ctrls { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; z-index: 2; }
.map .ctrls button { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); cursor: pointer; font-weight: 700; }
.map .attr { position: absolute; right: 0; bottom: 0; font-size: 10px; background: rgba(255,255,255,.8); color: #333; padding: 1px 5px; z-index: 2; }
.map .attr a { color: #333; }

/* ------------------------------------------------------------------ progress (FOTA) */
.pipeline { display: flex; gap: 3px; }
.pipeline i { flex: 1; height: 7px; border-radius: 99px; background: var(--bg-2); }
.pipeline i.done { background: var(--accent); }
.pipeline i.now { background: var(--info); animation: pulse 1.4s infinite; }
.pipeline.failed i.done { background: var(--crit); }
.logview { background: #0b0f14; color: #d6dde6; font: 12px/1.5 var(--mono); padding: 12px; border-radius: var(--radius); height: 460px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.logview .e { color: #ff8b82; font-weight: 600; }
.logview .w { color: #f7c65c; }
.logview mark { background: #6b5a00; color: #fff; }

/* ------------------------------------------------------------------ login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(145deg, #10335f, #1b4d8c 55%, #1f7a74); color: #e7f2ff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { font-size: 30px; line-height: 1.2; max-width: 16ch; color: #fff; }
.login-art p { max-width: 46ch; opacity: .85; }
.login-art ul { padding-left: 18px; opacity: .9; }
.login-form { display: grid; place-items: center; padding: 32px; background: var(--panel); }
.login-form form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-form h2 { font-size: 20px; }

/* ------------------------------------------------------------------ misc */
.qr { background: #fff; padding: 10px; border-radius: 10px; border: 1px solid var(--line); width: 220px; }
.qr img { width: 100%; display: block; }
.secret { font-family: var(--mono); font-size: 13px; background: var(--panel-2); border: 1px dashed var(--line-2); padding: 8px 10px; border-radius: 8px; word-break: break-all; user-select: all; }
.kbd { font: 11px var(--mono); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--muted); }
.pill-count { font-size: 11px; background: var(--bg-2); border-radius: 99px; padding: 1px 7px; color: var(--muted); font-weight: 600; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }

.nav-scrim { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 70; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .shell.mobile-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  /* Dim the page behind the open menu; a tap on it closes the menu instead of
     falling through to whatever control sits underneath. */
  .shell.mobile-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 65; background: var(--scrim); animation: fade .15s; }
  .content { padding: 16px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .search { display: none; }
  .topbar .mobile-only { display: inline-flex; }
  .topbar.search-open [data-search-open] { display: none; }
  /* Phone search: the button opens the search as a full-width bar over the header. */
  .topbar.search-open .search {
    display: flex; align-items: center; gap: 6px; position: absolute; inset: 0; width: auto;
    padding: 0 8px 0 12px; background: var(--panel); z-index: 5;
  }
  .topbar.search-open .search > svg { left: 21px; }
  .topbar.search-open .search input { flex: 1; height: 40px; }
  /* One close control, not two: hide the browser's own clear (×) button. */
  .topbar.search-open .search input::-webkit-search-cancel-button { display: none; }
  .topbar.search-open .search-close { display: inline-flex; flex: none; }
  .topbar.search-open .search .results { left: 8px; right: 8px; max-height: min(420px, 70vh); }
  .search .results a { min-height: 48px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .userchip .who { display: none; }
  /* The drawer is the whole workspace on a phone: full width, tighter padding. */
  .drawer { width: 100vw; }
  .drawer > header, .drawer .dhead { padding: 12px 14px 0; }
  .drawer > .body { padding: 14px 14px 32px; }
  .modal > header, .modal > .body, .modal > footer { padding-left: 14px; padding-right: 14px; }
  dl.kv { grid-template-columns: minmax(96px, max-content) minmax(0, 1fr); }
  dl.kv dd { min-width: 0; overflow-wrap: anywhere; }
  /* A long status pill ("unreliable — never load-bearing") wraps instead of overflowing its card. */
  .tag { white-space: normal; max-width: 100%; }
}
/* Touch sizing. Keyed to the POINTER as well as the width: a landscape iPad is
   wider than 900px and gets the desktop layout, but it is still driven by a
   finger, so it needs finger-sized controls (it had 26px buttons). */
@media (max-width: 900px), (pointer: coarse) {
  /* iOS zooms the page into any focused field under 16px. */
  input, select, textarea { font-size: 16px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select { height: 40px; }
  /* Finger-sized targets. Emergency actions (Unlock cable) live in .btn.sm rows. */
  .btn { height: auto; min-height: 40px; }
  .btn.sm { min-height: 36px; font-size: 13px; }
  .btn.icon { width: 40px; }
  /* Drawer / dialog close: was 30px, under the finger-size minimum on every drawer. */
  .x { width: 40px; height: 40px; }
  .seg button { height: 38px; }
  .tabs button { padding: 11px 12px; }
  .nav a { padding-top: 10px; padding-bottom: 10px; }
  /* A taller track so the slider can be dragged with a finger. */
  input[type="range"] { height: 36px; }
  .switch { width: 50px; height: 28px; }
  .switch span::before { width: 22px; height: 22px; }
  .switch input:checked + span::before { transform: translateX(22px); }
}
/* Wide tables (Sessions has 12+ columns) scroll sideways inside their box below
   desktop width; pin the first column so each row stays identifiable while the
   money columns are on screen. */
@media (max-width: 1279px) {
  .table-wrap table.t th:first-child, .table-wrap table.t td:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--panel); box-shadow: 1px 0 0 var(--line);
  }
  .table-wrap table.t th:first-child { z-index: 2; background: var(--panel-2); }
  .table-wrap table.t tfoot td:first-child { background: var(--panel-2); }
}
@media (max-width: 600px) {
  /* KPIs two-up, so a phone sees the numbers and the list without scrolling past a wall of cards. */
  .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 20px; }
  .page-head h1 { font-size: 18px; }
  .page-head .actions { margin-left: 0; }
}
@media print {
  .sidebar, .topbar, .page-head .actions, .filters { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}

/* Commercial → Driver app: form beside a phone-sized live preview */
.da-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.da-side { position: sticky; top: 72px; }
.da-phone { width: 380px; max-width: 100%; height: 740px; margin: 0 auto; border-radius: 34px; padding: 10px; background: #0b0f14; box-shadow: 0 18px 50px rgba(0, 0, 0, .28); }
.da-phone iframe { width: 100%; height: 100%; border: 0; border-radius: 26px; background: #0a1417; }
.da-swatches { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 6px; }
.da-swatch { display: flex; gap: 10px; align-items: center; }
.da-swatch .chip { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; border: 1px solid var(--line); }
.da-icons { display: flex; flex-wrap: wrap; gap: 18px; align-items: end; margin: 4px 0 12px; }
.da-icons figure { margin: 0; text-align: center; }
.da-icons img { display: block; margin: 0 auto 4px; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); border-radius: 12px; }
.da-icons figcaption { font-size: 11px; color: var(--muted); }
.da-checks + .da-checks { margin-top: 12px; }
.da-checks ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.da-checks li { display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.da-checks li svg { width: 14px; height: 14px; flex: none; }
.da-checks li.ok svg { color: var(--accent); }
.da-checks li.todo { color: var(--muted); }
.da-checks li.todo svg { color: var(--warn); }
@media (max-width: 1100px) { .da-layout { grid-template-columns: 1fr; } .da-side { position: static; } .da-phone { height: 640px; } }
