/* ===========================================================================
   styles.css — "Data-Dense Dashboard" design system + left-sidebar app shell.
   Clean neutral light theme · near-black headings · colour ONLY for status ·
   Inter (UI) with tabular numerals · blue reserved for interactive/nav.
   (Design-system pass 2026-07-02 — matches the owner's clean mockup.)
   =========================================================================== */

/* The hidden attribute must always win (fixes stacked login+dashboard bug). */
[hidden] { display: none !important; }

:root {
  --primary: #2563EB; --primary-hover: #1D4ED8; --secondary: #3B82F6; --accent: #B45309;
  --bg: #F6F8FB; --panel: #FFFFFF; --fg: #111827; --heading: #0F172A; --muted: #64748B;
  --border: #E4E9F0; --sidebar: #0F1B33; --sidebar-fg: #AEBBD4; --sidebar-active: #2563EB;
  --ok: #15803D; --ok-bg: #E7F6EC; --bad: #DC2626; --bad-bg: #FBE9E9;
  --idle: #64748B; --idle-bg: #EFF2F7; --info: #1D4ED8; --info-bg: #E8EFFD; --accent-bg: #FEF3C7;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  --font-ui: 'Inter', system-ui, 'Segoe UI', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
/* Numbers stay in the UI font (matches the mockup) but use tabular figures so
   data columns line up cleanly. */
.num, .kpi-val, .wval, td.n { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
a { color: var(--primary); }

/* --- brand / buttons --- */
.brand { display: flex; align-items: center; gap: .6rem; }
.drop { width: 26px; height: 26px; fill: var(--primary); flex: none; }
.brand-name { font-weight: 700; color: var(--heading); letter-spacing: -.01em; }
.brand--lg { margin-bottom: 1.25rem; } .brand--lg .drop { width: 40px; height: 40px; } .brand--lg .brand-name { font-size: 1.2rem; }
.brand-sub { font-size: .8rem; color: var(--muted); }
.btn { cursor: pointer; border: 1px solid transparent; border-radius: 8px; padding: .6rem 1rem; font: 600 .95rem var(--font-ui); min-height: 44px; transition: background-color .15s, border-color .15s; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; width: 100%; } .btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--border); } .btn-ghost:hover { background: var(--idle-bg); }
.btn-sm { min-height: 36px; padding: .4rem .7rem; font-size: .85rem; width: auto; }
.btn-accent { background: var(--accent); color: #fff; width: auto; } .btn-accent:hover { filter: brightness(.95); }
:focus-visible { outline: 3px solid rgba(30,64,175,.4); outline-offset: 2px; }
.iconbtn { background: transparent; border: none; cursor: pointer; padding: .35rem; border-radius: 8px; display: inline-flex; }
.iconbtn svg { width: 24px; height: 24px; stroke: var(--fg); fill: none; stroke-width: 2; }

/* --- login --- */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: radial-gradient(1200px 500px at 50% -10%, #E0EAFB, var(--bg)); }
.login-card { background: var(--panel); padding: 2rem; border-radius: 16px; width: 100%; max-width: 380px; box-shadow: 0 12px 40px rgba(15,23,42,.12); border: 1px solid var(--border); }
.login-card label { display: block; margin: 1rem 0 .3rem; font-size: .82rem; color: var(--muted); font-weight: 500; }
.login-card input { width: 100%; padding: .65rem .75rem; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--fg); font-size: 1rem; min-height: 44px; }
.login-card input:focus { border-color: var(--secondary); outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,.25); }
.login-card .btn-primary { margin-top: 1.4rem; }
.error { color: var(--bad); background: var(--bad-bg); border-radius: 8px; padding: .5rem .7rem; margin-top: .9rem; font-size: .88rem; }

/* --- app shell --- */
.shell { display: flex; min-height: 100dvh; }
.sidebar { width: 240px; flex: none; background: var(--sidebar); color: var(--sidebar-fg); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh; }
.side-brand { display: flex; align-items: center; gap: .55rem; padding: 1.1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-brand .drop { fill: #60A5FA; } .side-brand .brand-name { color: #fff; }
.side-nav { flex: 1; padding: .75rem .6rem; display: flex; flex-direction: column; gap: .2rem; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: .7rem; width: 100%; background: transparent; border: none; color: var(--sidebar-fg);
  padding: .6rem .7rem; border-radius: 8px; cursor: pointer; font: 500 .92rem var(--font-ui); text-align: left; }
.nav-item svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }
.nav-item:hover:not(:disabled) { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item.is-soon { opacity: .45; cursor: default; }
.nav-sep { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: #64789e; padding: .9rem .7rem .3rem; }
.side-foot { padding: .9rem 1rem; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: .5rem; }
.side-user { font-size: .8rem; color: #93a4c4; word-break: break-all; }
/* Log out sits on the dark sidebar, so the default (dark) ghost button is
   invisible — give it a light outline + text that reads against the navy. */
.side-foot .btn-ghost { color: #E6ECF7; border-color: rgba(255,255,255,.24); background: transparent; }
.side-foot .btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.4); }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.scrim { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 40; }

/* --- top bar --- */
.topbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .7rem 1.25rem; background: var(--panel);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; box-shadow: var(--shadow); }
.hamburger { display: none; }
.view-title { font-size: 1.1rem; color: var(--heading); margin: 0; font-weight: 700; }
.controls { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-left: auto; }
.ctl { font-size: .72rem; color: var(--muted); display: flex; flex-direction: column; gap: .2rem; font-weight: 500; }
select { background: #fff; color: var(--fg); border: 1px solid var(--border); border-radius: 8px; padding: .4rem .55rem; min-height: 40px; font: 500 .9rem var(--font-ui); cursor: pointer; }
.conn { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; color: var(--muted); }
.conn-led { width: 9px; height: 9px; border-radius: 50%; background: var(--idle); }
.conn.live .conn-led { background: var(--ok); box-shadow: 0 0 0 3px rgba(21,128,61,.18); } .conn.live .conn-txt { color: var(--ok); }

/* --- content + shared --- */
.content { padding: 1.25rem; max-width: 1440px; width: 100%; margin: 0 auto; }
.updated { text-align: right; font-size: .78rem; color: var(--muted); margin-top: 1rem; }
.empty { color: var(--muted); padding: 2rem; text-align: center; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* --- KPI row (scheme + overview summaries) --- */
.summary { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.scheme-title { margin: 0 0 1rem; font-size: 1.2rem; color: var(--heading); }
.scheme-code { color: var(--muted); font-weight: 500; font-size: .9rem; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.kpi { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: .7rem .85rem; }
.kpi-val { display: block; font-size: 1.5rem; font-weight: 600; color: var(--heading); }
.kpi-val.bad { color: var(--bad); } .kpi-val.idle { color: var(--idle); }
.kpi-lbl { display: block; font-size: .8rem; color: var(--muted); margin-top: .2rem; }

/* --- scheme cards --- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.ph-card { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--idle); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); cursor: pointer; transition: box-shadow .15s, transform .15s; }
.ph-card:hover { box-shadow: 0 6px 18px rgba(15,23,42,.12); transform: translateY(-1px); }
.ph-card.status-ok { border-left-color: var(--ok); } .ph-card.status-fault { border-left-color: var(--bad); } .ph-card.status-stale { border-left-color: var(--idle); }
.ph-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .85rem; }
.ph-name { font-weight: 600; color: var(--heading); } .ph-code { color: var(--muted); font-size: .78rem; margin-left: .4rem; }
.badge { font-size: .74rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); } .badge-bad { background: var(--bad-bg); color: var(--bad); } .badge-idle { background: var(--idle-bg); color: var(--idle); }

/* --- shared status chip (colour + icon + label; never colour alone) --- */
.schip { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; font-size: .78rem; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.schip-ic { font-size: .72rem; line-height: 1; }
/* Five DISTINCT colours — red / amber / green / blue / grey — plus icon + label. */
.schip-fault   { background: var(--bad-bg);    color: var(--bad); }
.schip-warning { background: var(--accent-bg); color: var(--accent); }
.schip-ok      { background: var(--ok-bg);     color: var(--ok); }
.schip-idle    { background: var(--info-bg);   color: var(--info); }
.schip-offline { background: var(--idle-bg);   color: var(--idle); border: 1px dashed var(--muted); padding: calc(.15rem - 1px) calc(.55rem - 1px); }
.ph-devices { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .9rem; }
.d-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.d-name { color: var(--muted); font-size: .86rem; }
.pill { font-size: .76rem; font-weight: 600; padding: .16rem .55rem; border-radius: 999px; }
.pill-on { background: var(--ok-bg); color: var(--ok); } .pill-off { background: var(--idle-bg); color: var(--idle); }
.pill-bad { background: var(--bad-bg); color: var(--bad); } .pill-info { background: var(--info-bg); color: var(--info); }
.phases { display: flex; gap: .28rem; }
.phase { width: 24px; text-align: center; font: 700 .72rem var(--font-ui); border-radius: 6px; padding: .12rem 0; }
.phase.on { background: var(--ok-bg); color: var(--ok); } .phase.off { background: var(--bad-bg); color: var(--bad); }
.tag { font-size: .72rem; color: var(--muted); margin-left: .3rem; }
.chip { display: inline-block; font-size: .7rem; padding: .12rem .45rem; border-radius: 999px; margin-right: .25rem; font-weight: 600; }
.chip-warn { background: var(--warning-bg, #fef3c7); color: var(--warning, #b45309); }
.phase-breakdown { margin-top: .75rem; border-top: 1px solid var(--border); padding-top: .75rem; }
.phase-breakdown-head { font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: .4rem; }
.phase-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.phase-bar-head { font-size: .78rem; margin-bottom: .18rem; }
.phase-bar-track { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.phase-bar-fill { height: 100%; border-radius: 999px; transition: width .3s; }
.phase-bar-foot { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.sparklines { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-top: .5rem; }
.sparkline-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .2rem; }
.sparkline-label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.sparkline-value { font-size: .95rem; font-weight: 700; color: var(--fg); font-family: var(--font-mono); }
.sparkline-chart { height: 42px; }
.ph-water { display: flex; justify-content: space-between; gap: .5rem; border-top: 1px solid var(--border); padding-top: .75rem; }
.wstat { text-align: center; flex: 1; } .wval { display: block; font-weight: 600; font-size: .98rem; } .wlbl { display: block; font-size: .72rem; color: var(--muted); margin-top: .15rem; }
.ph-foot { font-size: .74rem; color: var(--muted); margin-top: .7rem; }

/* --- data table (block view + overview) --- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--panel); }
table.data th, table.data td { padding: .6rem .7rem; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.data th { font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--bg); position: sticky; top: 0; cursor: pointer; user-select: none; }
table.data th .arrow { color: var(--primary); }
table.data tbody tr { cursor: pointer; } table.data tbody tr:hover { background: #f5f8fd; }
table.data td.n { text-align: right; }
.rowstatus { display: inline-flex; align-items: center; gap: .4rem; }
.rdot { width: 9px; height: 9px; border-radius: 50%; } .rdot.ok { background: var(--ok); } .rdot.fault { background: var(--bad); } .rdot.stale { background: var(--idle); }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.ctl-check { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--muted); cursor: pointer; padding: .35rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.ctl-check input { margin: 0; }
.tr-stats { display: flex; gap: 1rem; flex-wrap: wrap; margin: 0 0 1rem; }
.tr-stat { flex: 1 1 130px; padding: .7rem .9rem; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.tr-stat-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .2rem; }
.tr-stat-value { font-size: 1.15rem; font-weight: 700; font-family: var(--font-mono); color: var(--fg); }
.tr-stats-empty { color: var(--muted); font-size: .85rem; padding: 1rem 0; }
.tr-incident-legend { margin-top: .6rem; font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.tr-inc-swatch { display: inline-block; width: 14px; height: 10px; border-radius: 2px; vertical-align: middle; }
.tr-inc-swatch.critical { background: rgba(220, 38, 38, 0.3); }
.tr-inc-swatch.warning  { background: rgba(217, 119, 6, 0.3); }
.chart-outlier-note { font-size: .78rem; color: var(--warning, #B45309); margin-top: .5rem; padding: .35rem .55rem; background: var(--warning-bg, #FEF3C7); border-radius: 6px; }

/* Power availability intra-day heat-strip (UX polish B, 2026-07-31) */
.power-heat { display: flex; flex-direction: column; gap: 4px; margin: .5rem 0 .3rem; }
.heat-row { display: flex; align-items: center; gap: .6rem; }
.heat-day { font-size: .72rem; color: var(--muted); font-weight: 600; width: 52px; text-align: right; letter-spacing: .02em; }
.heat-cells { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; flex: 1; min-width: 0; height: 22px; position: relative; }
.heat-cell { display: block; height: 100%; border-radius: 3px; cursor: default; }
.heat-cell-nd { background: #F1F5F9; width: 14px; height: 14px; display: inline-block; vertical-align: middle; border-radius: 2px; }
.heat-ruler-line { height: 12px; position: relative; }
.heat-ruler-mark { position: absolute; top: 0; transform: translateX(-50%); font-size: .68rem; color: var(--muted); font-family: var(--font-mono); }
.heat-legend { display: flex; align-items: center; gap: .5rem; font-size: .72rem; color: var(--muted); margin-top: .6rem; padding-left: 60px; flex-wrap: wrap; }
.heat-legend-gradient { display: inline-block; width: 80px; height: 10px; border-radius: 3px; background: linear-gradient(to right, rgb(184,74,10), rgb(92,116,87)); }
.heat-legend-nd { display: inline-flex; align-items: center; gap: .3rem; margin-left: .8rem; }
.heat-total { width: 46px; flex: none; text-align: right; font-size: .72rem; font-family: var(--font-mono); color: var(--fg); }
.heat-total-head { color: var(--muted); font-family: inherit; font-size: .66rem; }
.heat-total-wide { width: 136px; white-space: nowrap; }
.heat-warn { color: var(--bad); margin-left: .35rem; font-weight: 600; }
/* Pump + chlorinator: two bands per hour (pump on top, chlorinator below) */
.heat-cells-duo { height: 30px; }
.heat-duo { display: grid; grid-template-rows: 3fr 2fr; gap: 1px; background: transparent; }
.heat-duo i { display: block; border-radius: 2px; }
.heat-duo-flag { outline: 2px solid var(--bad); outline-offset: -1px; }
.heat-chl { color: #0D9488; }
.gw-panel h3 { font-size: .9rem; }
.gw-now { display: flex; gap: 1.2rem; flex-wrap: wrap; align-items: baseline; margin: .3rem 0 .4rem; font-size: .8rem; }
.gw-val { font-weight: 600; font-family: var(--font-mono); }
.gw-lbl { color: var(--muted); }
.gw-ok { color: var(--ok, #15803d); }
.gw-warn { color: var(--warning, #b45309); }
.gw-bad { color: var(--bad, #b91c1c); }

/* 17a: forced first-login password change modal */
.pwd-modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; }
.pwd-modal { background: var(--panel, #fff); border-radius: 12px; box-shadow: 0 20px 60px -10px rgba(15, 23, 42, 0.35); padding: 1.8rem; max-width: 420px; width: 100%; }
.pwd-modal h3 { margin: 0 0 .35rem; color: var(--fg); font-size: 1.15rem; }
.pwd-modal .pwd-hint { color: var(--muted); font-size: .85rem; margin: 0 0 1.1rem; line-height: 1.4; }
.pwd-modal form { display: flex; flex-direction: column; gap: .7rem; }
.pwd-modal label { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; color: var(--muted); font-weight: 600; }
.pwd-modal input { border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem; font: 400 .95rem var(--font-ui); }
.pwd-modal input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.pwd-msg { border-radius: 6px; padding: .5rem .7rem; font-size: .8rem; }
.pwd-msg-err { background: var(--bad-bg, #FEE2E2); color: var(--bad, #B91C1C); }
.pwd-msg-ok  { background: var(--ok-bg,  #DCFCE7); color: var(--ok,  #166534); }
.pwd-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .3rem; }
.filters input, .filters select { min-height: 40px; }
.filters input { border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; font: 400 .9rem var(--font-ui); }

/* --- pumphouse detail --- */
.detail-top { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: .4rem; background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: .4rem .7rem; cursor: pointer; color: var(--fg); font: 500 .88rem var(--font-ui); }
.detail-title h2 { margin: 0; color: var(--heading); } .detail-title .crumb { color: var(--muted); font-size: .85rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 1rem; align-items: start; }
.card-pad { padding: 1.1rem 1.25rem; }
.card-pad h3 { margin: 0 0 .8rem; font-size: 1rem; color: var(--heading); }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px dashed var(--border); font-size: .9rem; }
.kv:last-child { border-bottom: none; } .kv .k { color: var(--muted); }
.chart-box { position: relative; height: 300px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; flex-wrap: wrap; }
.chl-stats { display: flex; gap: 1.2rem; margin-top: .8rem; }
.chl-stats .s { text-align: center; } .chl-stats .sv { font: 600 1.15rem var(--font-ui); font-variant-numeric: tabular-nums; } .chl-stats .sl { font-size: .74rem; color: var(--muted); }
.chl-form { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.chl-form label { font-size: .72rem; color: var(--muted); display: flex; flex-direction: column; gap: .2rem; }
.chl-form input { min-height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: .4rem .55rem; font: 400 .9rem var(--font-ui); }

/* --- notification bell + nav badge --- */
.nav-badge { margin-left: auto; background: var(--bad); color: #fff; font-size: .68rem; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; }
.bell-wrap { position: relative; }
.bell-btn { position: relative; }
.bell-badge { position: absolute; top: -2px; right: -2px; background: var(--bad); color: #fff; font-size: .62rem; font-weight: 700; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--panel); }
.bell-panel { position: absolute; right: 0; top: calc(100% + .5rem); width: 340px; max-width: 88vw; max-height: 420px; overflow: auto; z-index: 60; padding: 0; }
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: .7rem .9rem; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--heading); position: sticky; top: 0; background: var(--panel); }
.linkbtn { background: none; border: none; color: var(--primary); cursor: pointer; font: 500 .8rem var(--font-ui); padding: 0; }
.bell-list { display: flex; flex-direction: column; }
.bell-item { display: flex; gap: .6rem; padding: .7rem .9rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.bell-item:hover { background: var(--bg); }
.bell-item.unread { background: var(--info-bg); } .bell-item.unread:hover { filter: brightness(.98); }
.bell-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: .35rem; flex: none; background: var(--idle); }
.bell-dot.active { background: var(--bad); } .bell-dot.acknowledged { background: var(--accent); } .bell-dot.resolved { background: var(--ok); }
.bell-msg { font-size: .88rem; color: var(--fg); } .bell-meta { font-size: .72rem; color: var(--muted); margin-top: .15rem; }

/* --- alert rule form --- */
.rule-form { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.rule-form label { font-size: .72rem; color: var(--muted); display: flex; flex-direction: column; gap: .2rem; }
.rule-form input { min-height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: .4rem .55rem; font: 400 .9rem var(--font-ui); }

/* --- admin panel --- */
.admin-tabs { display: flex; gap: .4rem; align-items: center; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.atab { background: transparent; border: none; border-bottom: 2px solid transparent; padding: .55rem .9rem; cursor: pointer; font: 600 .9rem var(--font-ui); color: var(--muted); }
.atab:hover { color: var(--fg); }
.atab.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-subpills { display: flex; gap: .35rem; margin: .1rem 0 .9rem; flex-wrap: wrap; }
.apill { background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: .3rem .8rem; cursor: pointer; font: 600 .8rem var(--font-ui); color: var(--muted); }
.apill:hover { color: var(--fg); }
.apill.active { color: #fff; background: var(--primary); border-color: var(--primary); }
.admin-empty { padding: 2rem 1.5rem; border: 1px dashed var(--border); border-radius: 8px; text-align: center; }
.admin-empty .ae-title { font-weight: 600; color: var(--fg); font-size: 1rem; margin-bottom: .3rem; }
.admin-empty .ae-hint { color: var(--muted); font-size: .85rem; margin-bottom: .8rem; max-width: 44ch; margin-left: auto; margin-right: auto; }
.admin-hint { margin-left: auto; font-size: .78rem; color: var(--muted); }
.crumb-bar { font-size: .9rem; color: var(--muted); margin: .3rem 0 .2rem; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.crumb-bar a, a.link { color: var(--primary); cursor: pointer; }
.crumb-bar a:hover, a.link:hover { text-decoration: underline; }
.crumb-bar span { color: var(--border); }
.lnk { color: var(--primary); font-weight: 600; }
table.data tbody tr:hover .lnk { text-decoration: underline; }

/* --- dashboard drill-down navigation --- */
.dash-top { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: space-between; margin-bottom: .5rem; }
.crumbs { display: flex; align-items: center; gap: .1rem; flex-wrap: wrap; }
.crumb-chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: .25rem .6rem; cursor: pointer; text-align: left; transition: background-color .12s, border-color .12s; }
.crumb-chip:hover { background: var(--info-bg); border-color: var(--secondary); }
.crumb-kicker { font-size: .62rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.crumb-name { font-size: .9rem; font-weight: 600; color: var(--heading); }
.crumb-sep { color: var(--muted); margin: 0 .15rem; }
.level-head { margin: .2rem 0 1rem; }
.level-title { margin: 0; font-size: 1.15rem; color: var(--heading); }
.level-hint { margin: .35rem 0 0; font-size: .82rem; color: var(--muted); background: var(--info-bg); border-radius: 8px; padding: .45rem .65rem; display: inline-block; }
/* jump-to search */
.dash-jump { position: relative; flex: 1; min-width: 240px; max-width: 420px; }
.dash-jump .jump-ic { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 2; pointer-events: none; }
#jump-input { width: 100%; padding: .5rem .7rem .5rem 2rem; border: 1px solid var(--border); border-radius: 8px; font: 400 .9rem var(--font-ui); min-height: 40px; background: #fff; }
#jump-input:focus { outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
.jump-list { position: absolute; left: 0; right: 0; top: calc(100% + .3rem); z-index: 60; max-height: 320px; overflow: auto; padding: .25rem; }
.jump-row { display: flex; flex-direction: column; width: 100%; text-align: left; background: transparent; border: none; border-radius: 6px; padding: .45rem .55rem; cursor: pointer; }
.jump-row:hover { background: var(--info-bg); }
.jump-name { font-size: .9rem; font-weight: 500; color: var(--fg); }
.jump-meta { font-size: .74rem; color: var(--muted); }
.jump-empty { padding: .6rem; color: var(--muted); font-size: .85rem; }
/* sidebar level sub-tabs */
.nav-sub { display: flex; flex-direction: column; gap: .1rem; margin: .1rem 0 .3rem .3rem; padding-left: .7rem; border-left: 1px solid rgba(255,255,255,.12); }
.nav-subitem { text-align: left; background: transparent; border: none; color: var(--sidebar-fg); font: 500 .84rem var(--font-ui); padding: .35rem .6rem; border-radius: 6px; cursor: pointer; opacity: .85; }
.nav-subitem:hover { background: rgba(255,255,255,.08); color: #fff; opacity: 1; }
.nav-subitem.active { background: var(--sidebar-active); color: #fff; opacity: 1; }

/* --- command-center Home --- */
.home-band { display: grid; grid-template-columns: repeat(7, 1fr); gap: .6rem; margin-bottom: 1rem; }
.home-kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: .7rem .8rem; box-shadow: var(--shadow); }
.home-kpi-fault { background: var(--bad-bg); border-color: #F2CFCF; }
.home-kpi-offline { background: var(--idle-bg); }
.home-kpi-warning { background: var(--accent-bg); border-color: #ECDCA6; }
.home-kpi-val { display: block; font-size: 1.5rem; font-weight: 700; color: var(--heading); font-variant-numeric: tabular-nums; }
.home-kpi-sub { font-size: .95rem; font-weight: 500; color: var(--muted); }
.home-kpi-lbl { display: block; font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.home-kpi-delta { display: block; font-size: .72rem; color: var(--accent); margin-top: .1rem; }
.home-phead { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); }
.home-phead h3 { margin: 0; font-size: 1rem; color: var(--heading); }
.home-link { font-size: .82rem; font-weight: 600; color: var(--primary); cursor: pointer; }
.home-link:hover { text-decoration: underline; }
.att-list { display: flex; flex-direction: column; }
.att-row { display: flex; align-items: center; gap: .8rem; padding: .7rem 1.1rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.att-row:last-child { border-bottom: none; } .att-row:hover { background: var(--bg); }
.att-main { flex: 1; min-width: 0; } .att-name { font-weight: 600; color: var(--heading); } .att-meta { font-size: .8rem; color: var(--muted); }
.att-loc { font-size: .72rem; color: var(--muted); margin-top: .05rem; letter-spacing: .01em; }
.row-loc { font-size: .72rem; color: var(--muted); margin-top: .1rem; letter-spacing: .01em; }
.bell-loc { font-size: .68rem; color: var(--muted); margin-top: .1rem; }
.att-view { font-size: .8rem; color: var(--primary); font-weight: 600; white-space: nowrap; }
.att-ack { background: var(--bad); color: #fff; border: none; border-radius: 6px; padding: .3rem .7rem; font: 600 .78rem var(--font-ui); cursor: pointer; white-space: nowrap; }
.att-ack:hover:not(:disabled) { filter: brightness(1.1); }
.att-ack:disabled { opacity: .5; cursor: default; }
.att-ackd { font-size: .74rem; color: var(--muted); font-style: italic; }

/* --- quick-add pumphouse wizard (modal) --- */
.qa-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.qa-scrim { position: absolute; inset: 0; background: rgba(15,23,42,.5); }
.qa-card { position: relative; background: var(--panel); width: min(720px, 92vw); max-height: 90vh; overflow: auto; border-radius: var(--radius); box-shadow: 0 10px 40px rgba(15,23,42,.25); }
.qa-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.qa-close { background: transparent; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); line-height: 1; padding: 0 .3rem; }
.qa-close:hover { color: var(--fg); }
.qa-body { padding: 1rem 1.25rem 1.25rem; }
.qa-form { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.qa-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; color: var(--muted); }
.qa-form input, .qa-form select { min-height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: .4rem .55rem; font: 400 .9rem var(--font-ui); background: #fff; }
.qa-form input + input { margin-top: .3rem; }  /* stack code under name on the "new *" rows */
@media (max-width: 640px) { .qa-form { grid-template-columns: 1fr; } }
.home-two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

/* --- responsive --- */
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .home-band { grid-template-columns: repeat(3, 1fr); }
  .home-two { grid-template-columns: 1fr; }
}
/* Sidebar stays FIXED and visible on desktop + tablet; it only becomes an
   off-canvas drawer on true mobile (<640px), where auto-hide is expected. */
@media (max-width: 640px) {
  .sidebar { position: fixed; left: 0; top: 0; height: 100dvh; z-index: 50; transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .shell:not(.nav-open) .sidebar { transform: translateX(-100%); }
  .hamburger { display: inline-flex; }
  .content { padding: .9rem; } .kpi-row { grid-template-columns: repeat(2, 1fr); } .controls { gap: .6rem; }
}
@media (min-width: 641px) { .scrim { display: none !important; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Opt-in desktop notifications line at the bottom of the bell menu */
.bell-push { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .6rem .9rem; border-top: 1px solid var(--border); font-size: .78rem; color: var(--muted); }
.bell-push-lbl { flex: 1; min-width: 150px; }
.bell-push .linkbtn { font-size: .78rem; }

/* Broker & devices: keep the Login column (Issue / Revoke) in view when the table is wider than the panel */
.login-col { position: sticky; right: 0; background: var(--panel); box-shadow: -8px 0 8px -8px rgba(15,23,42,.18); min-width: 150px; }
table.data th.login-col { background: var(--bg); }
