/* Poweral brand fonts (self-hosted; SIL Open Font License) */
@font-face { font-family: 'Space Grotesk'; font-weight: 500; font-display: swap; src: url('/fonts/space-grotesk-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 600; font-display: swap; src: url('/fonts/space-grotesk-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 700; font-display: swap; src: url('/fonts/space-grotesk-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 400; font-display: swap; src: url('/fonts/dm-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 500; font-display: swap; src: url('/fonts/dm-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 600; font-display: swap; src: url('/fonts/dm-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 700; font-display: swap; src: url('/fonts/dm-sans-latin-700-normal.woff2') format('woff2'); }
/* Poweral Charge admin. Interim styling; will be aligned with Poweral Command's look once screenshots arrive.
   Chart colors follow a validated palette: one series = blue; status colors always paired with an icon + label. */
:root {
  --green: #10893e; --green-dark: #0b6b3a; --green-soft: #e7f5ec;
  --ink: #17202a; --muted: #66707c; --line: #e3e8ee; --bg: #f5f7f9; --card: #fff;
  --series-1: #257de0; --series-1-soft: #cce3fd;
  --good: #0aac23; --good-ink: #006c10; --good-soft: #e5f6e8;
  --warning: #fbb315; --warning-ink: #8a5a00; --warning-soft: #fff5dc;
  --serious: #f18a59; --serious-ink: #a4441a; --serious-soft: #fdeee6;
  --critical: #dc3c3d; --critical-ink: #b3261e; --critical-soft: #fdecec;
  --charging: #257de0; --charging-soft: #e8f1fd;
  --offline-soft: #eef1f4;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); }
button { font: inherit; }
.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.bolt { color: var(--green); }
.env { font-size: 11px; font-weight: 700; text-transform: uppercase; background: var(--warning-soft); color: var(--warning-ink); padding: 2px 8px; border-radius: 999px; }
.tabs { display: flex; gap: 4px; }
.tabs button { background: none; border: 0; padding: 8px 12px; border-radius: 7px; color: var(--muted); cursor: pointer; font-weight: 600; }
.tabs button:hover { background: var(--bg); color: var(--ink); }
.tabs button.active { background: var(--green-soft); color: var(--green-dark); }
.topbar-right { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: #fff; border: 0; padding: 6px 12px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--ink); color: #fff; }
main { padding: 20px 24px 60px; max-width: 1440px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 18px; }
.card.narrow { max-width: 460px; margin: 60px auto; }
.card h2 { font-size: 15px; margin: 0 0 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #f3efff; border: 1px solid #ddd3fb; color: #3b2a85; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .03em; background: #ece6ff; color: #4b33b5; padding: 1px 6px; border-radius: 4px; vertical-align: 1px; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-delta b { color: var(--ink); }
.fleet { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; }
.fleet-title { font-weight: 700; margin-right: 4px; }
.fleet-bar { flex: 1 1 260px; display: flex; height: 10px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--card); min-width: 200px; }
.fleet-bar span { display: block; height: 100%; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip .ic { font-size: 11px; }
.st-charging { background: var(--charging-soft); color: var(--charging); }
.st-available { background: var(--good-soft); color: var(--good-ink); }
.st-faulted { background: var(--critical-soft); color: var(--critical-ink); }
.st-busy { background: var(--warning-soft); color: var(--warning-ink); }
.st-offline { background: var(--offline-soft); color: var(--muted); }
.sev-critical { background: var(--critical-soft); color: var(--critical-ink); }
.sev-serious { background: var(--serious-soft); color: var(--serious-ink); }
.sev-warning { background: var(--warning-soft); color: var(--warning-ink); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.chart { position: relative; height: 230px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: #eceff3; stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--series-1); }
.chart .bar.hover { fill: #1b64be; }
.chart .hit { fill: transparent; cursor: default; }
.chart .empty { fill: var(--muted); font-size: 13px; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: #fff; padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.tooltip b { font-variant-numeric: tabular-nums; }
.attention { list-style: none; margin: 0; padding: 0; max-height: 330px; overflow: auto; }
.attention li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.attention li:hover { background: var(--bg); }
.attention li:last-child { border-bottom: 0; }
.attention .who { font-weight: 600; }
.attention .what { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.compact td { padding: 7px 8px; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--bg); }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.flag { display: inline-block; font-size: 11px; background: var(--warning-soft); color: var(--warning-ink); padding: 1px 6px; border-radius: 4px; margin: 1px 2px 1px 0; white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.filters input[type=search], .filters select { width: auto; min-width: 180px; }
.btn { background: var(--green); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; font-size: 13px; }
.btn:hover { background: var(--green-dark); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: #fff; color: var(--critical-ink); border: 1px solid #f3c4c4; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--green-dark); font-weight: 600; cursor: pointer; padding: 0; }
input, select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
input[type=checkbox] { width: auto; }
label.inline { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
label.inline input[type=number] { width: 110px; }
label.inline input[type=date] { width: auto; }
.stack { display: flex; flex-direction: column; gap: 9px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
#login-form { display: flex; gap: 8px; }
.muted { color: var(--muted); } .small-text { font-size: 12px; }
.error { color: var(--critical-ink); }
.notice { margin-top: 12px; padding: 12px; background: var(--warning-soft); border-radius: 8px; font-size: 13px; }
.secret { font-family: Menlo, Consolas, monospace; background: #fff; padding: 2px 6px; border-radius: 4px; word-break: break-all; }
code { font-family: Menlo, Consolas, monospace; font-size: 12px; background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; max-width: 440px; z-index: 60; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: #fff; border-left: 1px solid var(--line); box-shadow: -12px 0 30px rgba(0,0,0,.08); z-index: 40; overflow-y: auto; padding: 18px 20px 40px; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.drawer-title { font-size: 18px; font-weight: 700; }
.drawer h3 { font-size: 13px; margin: 18px 0 8px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; font-size: 13px; }
.facts div span { display: block; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.hidden { display: none !important; }
@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, 1fr); } .tabs button { padding: 8px 8px; } }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } .topbar { flex-wrap: wrap; } .kpis { grid-template-columns: repeat(2, 1fr); } }

/* ---- v0.4 additions ---- */
.periodbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 53px; z-index: 9; }
.custom-range { display: inline-flex; align-items: center; gap: 6px; }
.custom-range input { width: auto; padding: 5px 8px; }
.seg.small button { padding: 4px 10px; font-size: 12px; }
.btn.ask { background: #fff; color: #4b33b5; border: 1px solid #ddd3fb; }
.btn.ask:hover { background: #f3efff; }
.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.per { display: flex; flex-wrap: wrap; gap: 8px 28px; padding: 12px 18px; }
.per div { font-size: 13px; color: var(--muted); }
.per b { color: var(--ink); font-variant-numeric: tabular-nums; font-size: 14px; margin-right: 4px; }
.per .link { font-size: 13px; }
.health { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.health div span { display: block; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.health div b { font-size: 18px; font-variant-numeric: tabular-nums; }
.health div small { display: block; color: var(--muted); font-size: 11px; }
.site-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.site-head h1 { font-size: 22px; margin: 0; }
.site-grid { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: 18px; }
.site-grid .kpis { margin-bottom: 18px; }
.facts.single { grid-template-columns: 1fr; }
.chart.short { height: 180px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.heatmap { display: grid; grid-template-columns: 44px repeat(24, minmax(14px, 1fr)); gap: 2px; font-size: 11px; color: var(--muted); }
.heatmap .cell { height: 20px; border-radius: 3px; background: #eef4fc; }
.heatmap .lbl { display: flex; align-items: center; }
.heatmap .hlbl { text-align: center; }
.kind { margin-bottom: 12px; }
.diag { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-bottom: 14px; }
.diag .card { margin: 0; padding: 12px 14px; }
.diag h3 { font-size: 14px; margin: 0 0 4px; }
.diag p { margin: 6px 0 0; font-size: 13px; }
.diag .big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 14px 0 10px; }
.dtabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 7px 10px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.dtabs button.active { color: var(--green-dark); border-bottom-color: var(--green); }
.msg { border-bottom: 1px solid var(--line); padding: 6px 0; font-size: 12px; }
.msg-head { display: flex; justify-content: space-between; gap: 10px; cursor: pointer; }
.msg pre { white-space: pre-wrap; word-break: break-all; background: var(--bg); padding: 8px; border-radius: 6px; margin: 6px 0 0; font-size: 11px; max-height: 260px; overflow: auto; }
.dir { font-weight: 700; font-size: 10px; padding: 1px 5px; border-radius: 4px; margin-right: 6px; }
.dir.in { background: var(--good-soft); color: var(--good-ink); }
.dir.out { background: var(--charging-soft); color: var(--charging); }
.ask-panel { width: min(460px, 100vw); display: flex; flex-direction: column; z-index: 45; }
.ask-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 0 10px; }
.bubble { padding: 9px 12px; border-radius: 12px; max-width: 92%; white-space: pre-wrap; font-size: 13px; line-height: 1.5; }
.bubble.me { background: var(--ink); color: #fff; align-self: flex-end; }
.bubble.ai { background: var(--bg); border: 1px solid var(--line); align-self: flex-start; }
.bubble.note { background: #f3efff; border: 1px solid #ddd3fb; color: #3b2a85; align-self: stretch; max-width: none; }
.ask-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ask-examples button { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--ink); }
.ask-examples button:hover { background: var(--bg); }
.ask-form { display: flex; gap: 8px; align-items: flex-end; }
.ask-form textarea { flex: 1; resize: vertical; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.stack-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.live { font-size: 12px; color: var(--charging); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) { .site-grid { grid-template-columns: 1fr; } .health { grid-template-columns: repeat(2, 1fr); } }

/* ---- sign-in and team ---- */
.whoami { font-size: 12px; color: var(--muted); white-space: nowrap; }
.whoami b { color: var(--ink); }
.steps { margin: 0; padding-left: 18px; color: var(--muted); }
.qr { display: flex; justify-content: center; }
.qr img { width: 200px; height: 200px; border: 1px solid var(--line); border-radius: 8px; }
.codes { background: var(--bg); padding: 12px; border-radius: 8px; font-size: 14px; letter-spacing: .04em; text-align: center; line-height: 1.8; margin: 0; }
.card h3 { font-size: 13px; margin: 16px 0 8px; }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.pill.ok { background: var(--good-soft); color: var(--good-ink); }
.pill.bad { background: var(--critical-soft); color: var(--critical-ink); }
#user-form input { width: auto; flex: 1 1 200px; }
#user-form select { min-width: 160px; flex: 0 1 auto; }

.help { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 700; cursor: help; vertical-align: 1px; margin-left: 4px; }
.help:hover, .help:focus { background: var(--ink); color: #fff; outline: none; }
.tooltip.wide { max-width: 420px; }

/* ---- Poweral branding (matches poweral.com: charcoal header, Poweral green, Space Grotesk / DM Sans) ---- */
:root {
  --brand: #43db00; --brand-hover: #3bc300; --brand-ink: #14181c; --brand-dark: #2b8a00; --brand-soft: #ecfbe4;
  --charcoal: #2b2d31; --slate: #2f3a46;
  --green: var(--brand-dark); --green-dark: #1f6b00; --green-soft: var(--brand-soft);
  --ink: #1d232a;
}
body { font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }
h1, h2, h3, .kpi-value, .drawer-title, .fleet-title, .diag .big, .health div b { font-family: 'Space Grotesk', 'DM Sans', sans-serif; font-weight: 600; letter-spacing: -.01em; color: var(--slate); }
.kpi-value { color: var(--ink); }
.topbar { background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 1px 2px rgba(20,24,28,.04); }
.brand { gap: 12px; }
.lockup { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.brand .logo { height: 22px; width: auto; display: block; }
.brand .product { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 9.5px; letter-spacing: .32em; text-transform: uppercase; color: var(--brand-dark); margin-top: 4px; padding-left: 2px; }
.tabs button { color: var(--muted); }
.tabs button:hover { background: var(--bg); color: var(--ink); }
.tabs button.active { background: var(--brand-soft); color: var(--green-dark); }
.btn.ask { background: #fff; color: var(--green-dark); border: 1px solid var(--brand); }
.btn.ask:hover { background: rgba(67,219,0,.12); }
.btn { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.btn:hover { background: var(--brand-hover); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 600; }
.link { color: var(--brand-dark); }
.seg button.active { background: var(--charcoal); color: #fff; }
.card h2::before { content: ''; display: block; width: 34px; height: 3px; background: var(--brand); border-radius: 2px; margin-bottom: 8px; }
.card-head h2::before, #auth h2::before { display: block; }
.periodbar { top: 50px; }
.mini-select { width: auto; padding: 4px 8px; font-size: 12px; }
.dtabs button.active { color: var(--brand-dark); border-bottom-color: var(--brand); }
#auth { border-top: 3px solid var(--brand); }

/* ---- Power sharing ---- */
.row-actions { display: flex; gap: 8px; }
.callout { border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; font-size: 13px; line-height: 1.45; }
.callout.warn { background: var(--warning-soft); color: var(--warning-ink); }
.callout.bad { background: var(--critical-soft); color: var(--critical-ink); }
.callout.ok { background: var(--good-soft); color: var(--good-ink); }
.callout.info { background: var(--bg); color: var(--ink); }
.panel-block { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 16px; }
.panel-facts { display: flex; gap: 18px; flex-wrap: wrap; margin: 8px 0 10px; font-size: 13px; color: var(--muted); }
.panel-facts b { color: var(--ink); font-weight: 600; }
.meter { height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; margin: 6px 0 4px; }
.meter > div { height: 100%; background: var(--brand-dark); border-radius: 999px; }
.meter.over > div { background: var(--critical); }
.panel-notes { font-size: 12px; color: var(--muted); margin-top: 8px; }
.pw-edit-row { display: grid; grid-template-columns: 22px 1fr 92px 92px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.pw-edit-row input[type=number] { width: 100%; padding: 4px 6px; }
.pw-edit-row .muted { font-size: 11px; }
.pw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.req { border-top: 1px solid var(--line); padding: 10px 0; font-size: 13px; }
.req .muted { font-size: 12px; }
.stack-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; }
.stack-field > span { font-weight: 600; }
#d-body textarea { font: inherit; width: 100%; }

/* ---- Commissioning ---- */
.checklist { list-style: none; padding: 0; margin: 0 0 12px; }
.checklist li { display: grid; grid-template-columns: 26px 1fr; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.checklist .mark { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.checklist .pass .mark { background: var(--good-soft); color: var(--good-ink); }
.checklist .fail .mark { background: var(--critical-soft); color: var(--critical-ink); }
.checklist .todo .mark, .checklist .info .mark { background: var(--bg); color: var(--muted); }
.checklist small { display: block; color: var(--muted); margin-top: 2px; }
.progress-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.progress-row .meter { flex: 1; max-width: 240px; margin: 0; }
.setup-sheet { position: fixed; inset: 0; background: #fff; z-index: 60; overflow: auto; padding: 32px; }
.setup-sheet table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.setup-sheet th, .setup-sheet td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; font-size: 13px; }
.setup-sheet .secret { font-family: ui-monospace, Menlo, monospace; }
@media print { body > *:not(#setup-sheet) { display: none !important; } .setup-sheet { position: static; padding: 0; } .setup-sheet .no-print { display: none; } }

/* ---- Alerts ---- */
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--critical); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.badge.warn { background: var(--warning); color: #14181c; }
.alert-row td { vertical-align: top; padding-top: 12px; padding-bottom: 12px; }
.alert-row .title { font-weight: 600; }
.alert-row .detail { color: var(--muted); font-size: 13px; margin-top: 3px; max-width: 720px; }
.sev { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.sev.critical { background: var(--critical-soft); color: var(--critical-ink); }
.sev.warning { background: var(--warning-soft); color: var(--warning-ink); }
.sev.info { background: var(--bg); color: var(--muted); }

/* Add-site form: address suggestions */
.addr-wrap { position: relative; }
.addr-list { position: absolute; left: 0; right: 0; top: 100%; margin-top: -6px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.1); z-index: 5; overflow: hidden; }
.addr-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 9px 12px; font-size: 13px; cursor: pointer; color: var(--ink); }
.addr-item:last-child { border-bottom: 0; }
.addr-item:hover, .addr-item:focus { background: var(--bg); }
#add-site-btn { margin-left: auto; }

/* In-page confirmation box (replaces browser pop-ups) */
.modal-back { position: fixed; inset: 0; background: rgba(20, 24, 28, .35); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.2); width: min(440px, 100%); padding: 20px 22px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 10px; font-size: 14px; color: var(--ink); }
.modal textarea { min-height: 70px; width: 100%; font-family: inherit; font-size: 14px; }
.modal .modal-actions { justify-content: flex-end; margin-top: 8px; }
.modal .btn.danger { background: var(--critical-ink); color: #fff; border: 0; }

/* Sites grouped by state */
.group-row td { background: var(--bg); padding-top: 14px; font-size: 13px; }

/* Sortable table headings */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover, th.sortable:focus-visible { color: var(--ink); outline: none; text-decoration: underline; }
th.sorted { color: var(--ink); }
.sort-ic { font-size: 10px; }
td.nowrap { white-space: nowrap; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.price-save { padding-bottom: 10px; }
button.whoami { background: none; border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--muted); }
button.whoami:hover { border-color: var(--line); color: var(--ink); }

/* ---- Branding v3 (Tzvi, Nov 30 evening): light, like poweral.com's pages. White header with the green line on top,
   uppercase Space Grotesk menu with a green underline for the current page, bright Poweral green buttons, slate
   headings with the short green bar, white cards on a very light gray page. No dark areas. ---- */
:root { --web-green: #36d917; --web-green-hover: #2fc313; --page: #f7f8f9; --card-line: #e6e9ec; }
body { background: var(--page); }
.topbar { background: #fff; border-top: 3px solid var(--web-green); border-bottom: 1px solid var(--card-line); box-shadow: 0 2px 8px rgba(47, 58, 70, .06); padding: 12px 24px; }
.brand .logo { height: 30px; }
.brand .product { color: #2b8a00; font-size: 11px; margin-top: 5px; }
.tabs button { color: var(--slate); font-family: 'Space Grotesk', 'DM Sans', sans-serif; text-transform: uppercase; letter-spacing: .04em; font-size: 13px; font-weight: 500; background: none; border-radius: 0; }
.tabs button:hover { background: none; color: #2b8a00; }
.tabs button.active { background: none; color: #2b8a00; box-shadow: inset 0 -2px 0 var(--web-green); }
button.whoami { color: var(--muted); }
button.whoami b { color: var(--slate); }
.topbar .btn.ask { background: #fff; color: #2b8a00; border: 1.5px solid var(--web-green); }
.topbar .btn.ask:hover { background: rgba(54, 217, 23, .08); }
.env { background: var(--warning-soft); color: var(--warning-ink); }
.periodbar { top: 61px; background: #fff; }
/* Buttons like poweral.com: bright Poweral green, uppercase */
.btn { background: var(--web-green); color: #10210a; border: 0; font-family: 'Space Grotesk', 'DM Sans', sans-serif; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.btn:hover { background: var(--web-green-hover); }
.btn.ghost { background: #fff; color: var(--slate); border: 1px solid var(--card-line); text-transform: none; letter-spacing: 0; font-family: inherit; font-weight: 600; }
.btn.ghost:hover { border-color: var(--web-green); }
.btn.danger { text-transform: none; letter-spacing: 0; font-family: inherit; }
.btn.small { font-size: 12px; }
.link { color: #2b8a00; }
.card, .kpi { background: #fff; border-color: var(--card-line); border-radius: 12px; box-shadow: 0 1px 6px rgba(47, 58, 70, .05); }
.card h2::before { background: var(--web-green); width: 40px; }
.kpi { border-top: 3px solid var(--web-green); }
.kpi-value { color: var(--slate); }
h1, h2, h3 { color: var(--slate); }
thead th { background: #f7f8f9; }
tr.clickable:hover td { background: rgba(54, 217, 23, .06); }
.drawer { border-left: 3px solid var(--web-green); }
.seg button.active { background: var(--slate); color: #fff; }
.pw-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* Tablets and small laptops (701-1200 px): the menu moves to its own row under the logo so nothing runs off the right edge. */
@media (min-width: 701px) and (max-width: 1200px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .brand { order: 1; }
  .topbar-right { order: 2; margin-left: auto; }
  .tabs { order: 3; width: 100%; margin: 0; }
  .topbar, .periodbar { position: static; }
}

/* ---- Phone layout v2 (Tzvi, Dec 1: "words went past the box", "different font sizes in the same line").
   Rules: nothing is ever cut off or hidden to the side. The menu and the date buttons wrap into rows; every table
   turns into a stack of cards (one card per row, each value labelled with its column name, all the same size);
   filters and search boxes are full width, one per line, all at 16px. ---- */
@media (max-width: 700px) {
  html, body { overflow-x: hidden; }
  .topbar { position: static; flex-wrap: wrap; gap: 8px 10px; padding: 10px 14px 0; }
  .brand { order: 1; }
  .brand .logo { height: 24px; }
  .topbar-right { order: 2; margin-left: auto; display: flex; align-items: center; gap: 6px; }
  .topbar .btn.ask { font-size: 0; padding: 7px 10px; }
  .topbar .btn.ask::before { content: '✦ Ask'; font-size: 12px; }
  button.whoami { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; padding: 4px; }
  #logout { padding: 7px 9px; font-size: 12px; }
  /* Menu: 4 per row, all visible */
  .tabs { order: 3; width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 0; overflow: visible; }
  .tabs button { padding: 10px 2px; font-size: 11px; letter-spacing: .02em; text-align: center; white-space: nowrap; }
  .tabs button .badge, .tabs button .count { font-size: 10px; }
  /* Date buttons: wrap, all visible */
  .periodbar { position: static; padding: 8px 14px; gap: 6px; flex-wrap: wrap; }
  .periodbar .seg { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; }
  .periodbar .seg button { padding: 8px 2px; font-size: 13px; white-space: nowrap; }
  .periodbar input, .periodbar select { flex: 1 1 140px; min-width: 0; }
  .periodbar .muted, .periodbar small { font-size: 12px; }
  main { padding: 12px !important; }
  .card { padding: 14px; }
  .card h2 { font-size: 17px; }
  .kpis, .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 22px; overflow-wrap: anywhere; }
  .grid2 > *, .grid3 > *, .site-grid > * { min-width: 0; }
  h1 { font-size: 20px; overflow-wrap: anywhere; }
  .site-head { display: block; }
  .site-head .link { display: block; margin: 0 0 6px; font-size: 14px; }
  .site-head #site-sub { display: block; font-size: 14px; margin-top: 4px; }
  /* Card headers and filter rows: one control per line, full width, same size */
  .card-head { flex-wrap: wrap; gap: 8px; }
  .card-head > h2 { flex: 1 1 100%; }
  .card-head input, .card-head select, .toolbar input, .toolbar select, .filters input, .filters select, .row > input, .row > select { flex: 1 1 100%; width: 100%; min-width: 0; }
  .toolbar, .filters, .row, .row-actions { flex-wrap: wrap; gap: 8px; }
  .row-actions > input, .row-actions > select, .row-actions > .site-select { flex: 1 1 100%; width: 100%; min-width: 0; }
  input, select, textarea { font-size: 16px; max-width: 100%; } /* 16px stops iPhone zooming in when you tap a box */
  label { font-size: 14px; }
  input[type='date'], input[type='datetime-local'] { flex: 1 1 160px; min-width: 0; }
  .btn, .btn.small, .btn.ghost { font-size: 13px; padding: 9px 12px; }
  /* Tables become cards */
  .table-wrap { overflow: visible; margin: 0; padding: 0; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { border: 1px solid var(--card-line); border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; background: #fff; }
  .table-wrap tr:hover td { background: none; }
  /* a labelled value: name on the left, value on the right (value may be several pieces, they flow together) */
  .table-wrap td { border: 0 !important; padding: 4px 0 !important; white-space: normal !important; text-align: right !important; font-size: 14px !important; line-height: 1.4; overflow-wrap: anywhere; position: static !important; box-shadow: none !important; min-width: 0 !important; max-width: none !important; }
  .table-wrap td::after { content: ''; display: block; clear: both; }
  .table-wrap td[data-label]:not([data-label=''])::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--muted); font-size: 13px; font-weight: 400; text-align: left; max-width: 45%; }
  .table-wrap td > div { text-align: right; }
  /* no column name (titles, notes, buttons): full width, left */
  .table-wrap td:not([data-label]), .table-wrap td[data-label=''] { text-align: left !important; }
  .table-wrap td:not([data-label]) > div, .table-wrap td[data-label=''] > div { text-align: left; }
  .table-wrap td:first-child { text-align: left !important; font-size: 15px !important; font-weight: 600; padding-bottom: 6px !important; }
  .table-wrap td:first-child::before { content: none !important; }
  .table-wrap td:first-child > div { text-align: left; }
  .table-wrap td:first-child .muted, .table-wrap td:first-child small { font-size: 13px; font-weight: 400; display: block; }
  .table-wrap td .tag, .table-wrap td .demo, .table-wrap td .pill, .table-wrap td .chip, .table-wrap td .badge, .table-wrap td [class*='tag'] { white-space: nowrap; font-size: 11px !important; vertical-align: middle; }
  .table-wrap td:empty { display: none; }
  .table-wrap td[colspan] { display: block; text-align: left !important; }
  .table-wrap td .muted, .table-wrap td small, .table-wrap td .small-text { font-size: 13px; }
  .table-wrap td .btn { padding: 6px 10px; }
  /* Lists with a status badge, text and a date */
  .attention li { grid-template-columns: auto 1fr; }
  .attention li > :last-child { grid-column: 2; font-size: 12px; }
  .attention { max-height: none; overflow: visible; }
  .progress-row { flex-wrap: wrap; row-gap: 4px; font-size: 14px; }
  .progress-row .meter { flex: 1 1 auto; max-width: none; }
  .progress-row > :last-child { flex: 1 1 100%; font-size: 13px; }
  .progress-row b { white-space: nowrap; }
  .heatmap { grid-template-columns: 30px repeat(24, minmax(8px, 1fr)); font-size: 9px; gap: 1px; }
  .drawer { width: 100vw; max-width: 100vw; padding: 14px 14px 40px; border-left: 0; border-top: 3px solid var(--web-green); }
  .drawer .facts { grid-template-columns: 1fr 1fr; }
  .pw-grid3 { grid-template-columns: 1fr 1fr; }
  .pw-edit-row { grid-template-columns: 22px 1fr 76px 76px; }
}
