/* ==========================================================================
   public/admin.css - the StreamSense admin pages' single stylesheet.
   --------------------------------------------------------------------------
   Served statically and linked by every EJS admin view (layout, tenants,
   sites, sensors, data sources, mapping, alerts, users, Overview, login).
   Every page shares a 4/8/12/16/24 px spacing scale, one type scale and one
   set of buttons, badges, cards and tables. Class names are the ones the
   views use; if a page looks wrong, fix it here, not with inline styles.
   The file is ordered base -> components -> page-specific -> the later
   visual refresh, which overrides tokens and a few rules above it.
   ========================================================================== */

:root {
  --navy: #0f3d5c; --navy-dark: #0b2e46; --navy-soft: #eaf2f8; --navy-line: #cfe0ea;
  --bg: #f3f5f7; --card: #ffffff; --line: #e3e8ed; --line-soft: #eef1f4;
  --text: #1c2733; --text-2: #4a5866; --muted: #5f6b77; --faint: #626e7a;
  --ok-bg: #e6f4ea; --ok: #1e6b3a; --warn-bg: #fff3dc; --warn: #8a5a00;
  --danger-bg: #fdecea; --danger: #a3241c; --info-bg: #eaf2f8; --info: #1a5f8c;
  --neutral-bg: #eef1f4; --neutral: #55636f;
  --radius: 8px; --radius-sm: 6px; --shadow: 0 1px 2px rgba(16, 32, 48, 0.06), 0 1px 6px rgba(16, 32, 48, 0.04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--navy); }
code { font-family: var(--mono); font-size: 12.5px; background: var(--neutral-bg); padding: 1px 5px; border-radius: 4px; }
.mono { font-family: var(--mono); font-size: 13px; }
.small { font-size: 12.5px; color: var(--muted); }

/* --- top bar: brand, tenant links, account controls ------------------------ */
.topbar { display: flex; justify-content: space-between; align-items: center; background: var(--navy); color: #fff; padding: 0 24px; height: 52px; }
.topbar-left { display: flex; align-items: center; gap: 20px; }
.topbar .brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 16px; letter-spacing: 0.1px; }
.topbar-link { color: #cfe0ea; font-size: 13px; font-weight: 600; text-decoration: none; }
.topbar-link:hover { color: #fff; }
.logout-form { display: flex; align-items: center; gap: 14px; margin: 0; }
.user-email { color: #cfe0ea; font-size: 13px; }
.logout-form button { background: transparent; border: 1px solid rgba(255,255,255,0.5); color: #fff; padding: 5px 12px; font-size: 13px; }
.logout-form button:hover { background: rgba(255,255,255,0.12); }

.content { max-width: 1120px; margin: 0 auto; padding: 20px 24px 48px; }

/* --- headings, ledes, hints and section titles ----------------------------- */
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.2px; margin: 4px 0 6px; line-height: 1.25; }
h1 small { font-weight: 500; color: var(--muted); font-size: 15px; margin-left: 6px; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 10px; line-height: 1.3; }
h2 .badge { margin-left: 6px; vertical-align: 2px; }
h3 { font-size: 14px; font-weight: 700; margin: 0 0 6px; }
.lede, .muted-note { color: var(--muted); font-size: 13.5px; line-height: 1.55; margin: 0 0 18px; max-width: 860px; }
.hint { color: var(--text-2); font-size: 13px; line-height: 1.55; margin: 0 0 12px; max-width: 900px; }
.card .hint:last-child, .card .muted-note:last-child { margin-bottom: 0; }
span.muted-note, td .muted-note, .badge .muted-note { display: inline; margin: 0; }
.section-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin: 14px 0 6px; }

/* --- breadcrumbs and tenant tabs ---------------------------------------- */
.crumbs { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.crumbs a { color: var(--navy); text-decoration: none; font-weight: 600; }
.crumbs a:hover { text-decoration: underline; }
.tenant-tabs { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 22px; flex-wrap: wrap; }
.tenant-tab { padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 4px 4px 0 0; }
.tenant-tab:hover { color: var(--navy); background: #e9eef2; }
.tenant-tab.is-active { color: var(--navy); border-bottom-color: var(--navy); }
.tenant-tab.tab-right { margin-left: auto; }

/* --- cards -------------------------------------------------------------- */
.card, section { background: var(--card); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); border: 1px solid var(--line-soft); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head .card-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* --- key/value strip: the at-a-glance row at the top of a page -------------- */
.kv-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 24px; margin: 2px 0 18px; }
.kv-strip label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.kv-strip > div > div { font-size: 15px; color: var(--text); line-height: 1.4; }
.kv-strip .big { font-size: 22px; font-weight: 700; line-height: 1.1; }
.kv-strip .sub { color: var(--muted); font-size: 13px; }

/* --- buttons ------------------------------------------------------------ */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; background: var(--navy); color: #fff; }
button:hover, .btn:hover { background: var(--navy-dark); }
button.btn-secondary, .btn-secondary, .actions-row button, .row-actions button, .row-actions .btn { background: var(--navy-soft); color: var(--navy); border-color: var(--navy-line); }
button.btn-secondary:hover, .btn-secondary:hover, .actions-row button:hover, .row-actions button:hover { background: #dcebf5; }
button.danger, .row-actions button.danger { background: var(--danger-bg); color: var(--danger); border-color: #f3c3bd; }
button.danger:hover, .row-actions button.danger:hover { background: #f9d9d5; }
button.btn-small, .btn-small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-cancel { background: #fff; color: var(--text-2); border-color: #ccd3d9; }
.btn-cancel:hover { background: var(--bg); }
.btn-link { color: var(--navy); font-weight: 600; text-decoration: none; }
.btn-link:hover { text-decoration: underline; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0; }
.actions-row form { margin: 0; }
.actions-row .actions-note { color: var(--muted); font-size: 13px; margin-left: 4px; }

/* --- badges and status pills (ok / warn / danger / info / neutral) ---------- */
.badge, .status-pill, .pending, .mode-badge { font-family: var(--font); display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); vertical-align: middle; }
.badge.ok, .status-pill.ok, .status-pill.status-active, .mode-badge.mode-upload { background: var(--ok-bg); color: var(--ok); }
.badge.warn, .status-pill.warn, .pending { background: var(--warn-bg); color: var(--warn); }
.badge.danger, .status-pill.danger, .badge.on { background: var(--danger-bg); color: var(--danger); }
.badge.orange, .status-pill.orange { background: #ffedd5; color: #c2410c; }
.badge.loading, .badge.info, .mode-badge.mode-external_url { background: var(--info-bg); color: var(--info); }
.badge.pending, .badge.off, .status-pill.status-inactive, .mode-badge.mode-default { background: var(--neutral-bg); color: var(--neutral); }
.status-pill { text-transform: capitalize; }
h2 .badge { font-size: 11.5px; }

/* --- flash messages: notice, warning and error boxes ------------------------ */
.notice, .error-box, .warn-box, .error { padding: 10px 14px; border-radius: var(--radius-sm); margin: 0 0 16px; font-size: 13.5px; line-height: 1.5; border: 1px solid transparent; }
.notice { background: var(--ok-bg); border-color: #bfe0ca; color: #1e5c33; }
.error-box, .error { background: var(--danger-bg); border-color: #f3c3bd; color: var(--danger); }
.warn-box { background: var(--warn-bg); border-color: #ecd9ab; color: #7a5605; }
.notice ul, .error-box ul, .warn-box ul { margin: 6px 0 0; padding-left: 20px; }

/* --- tables, row actions and expandable detail cells ------------------------ */
.table-wrap { overflow-x: auto; }
table, .data-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
th, .data-table th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--line); font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; }
td, .data-table td { padding: 10px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; vertical-align: middle; line-height: 1.45; }
.data-table tbody tr:hover { background: #fafbfc; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table.small td { font-size: 13px; padding: 8px 10px; }
.data-table tr.row-warn td { background: #fff7e6; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap, th.nowrap { white-space: nowrap; }
.site-cell { line-height: 1.3; min-width: 200px; }
.site-cell .site-id { display: block; font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 1px; }
.row-actions { white-space: nowrap; text-align: right; width: 1%; }
.row-actions form { display: inline-block; margin: 0 0 0 6px; }
.row-actions button, .row-actions .btn { height: 30px; padding: 0 10px; font-size: 12.5px; min-width: 0; }
.col-manage { text-align: right; white-space: nowrap; }
.col-manage a + a { margin-left: 14px; }
.detail-cell { max-width: 420px; }
.detail-cell, .detail-cell * { overflow-wrap: anywhere; word-break: break-word; }
.detail-more > summary { cursor: pointer; color: var(--navy); font-weight: 600; list-style: none; }
.detail-more > summary::-webkit-details-marker { display: none; }
.detail-more > summary::before { content: "\25B8"; display: inline-block; margin-right: 5px; color: var(--faint); }
.detail-more[open] > summary::before { content: "\25BE"; }
.detail-count { color: var(--faint); font-weight: 400; }
.detail-full { margin-top: 8px; max-height: 240px; overflow: auto; background: #f7f9fa; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; font-family: var(--mono); font-size: 11.5px; line-height: 1.5; color: var(--text-2); }

/* --- forms: inputs, field grids, form sections and actions ------------------ */
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], select, textarea { font: inherit; font-size: 14px; color: var(--text); background: #fff; border: 1px solid #ccd3d9; border-radius: var(--radius-sm); padding: 0 10px; height: 34px; }
textarea { height: auto; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #7fb2d4; outline-offset: -1px; border-color: #7fb2d4; }
input:read-only, input:disabled { background: var(--bg); color: var(--text-2); }
input[type=file] { font-size: 13px; }
input[type=checkbox] { width: 16px; height: 16px; vertical-align: middle; margin: 0 6px 0 0; }
.form-section { border: 0; margin: 0 0 18px; padding: 0; min-width: 0; }
.form-section > legend { padding: 0; margin: 0 0 8px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea { width: 100%; }
.field .hint { font-size: 12px; color: var(--muted); margin: 0; }
.field .unit { font-size: 11.5px; color: var(--faint); font-weight: 500; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field-group { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-group.wide { grid-column: 1 / -1; }
.field-group label { display: flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text-2); flex-wrap: wrap; }
.field-group input, .field-group select { width: 100%; }
.field-group input[type=checkbox] { width: auto; }
.field-group .small { font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.inline-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.new-tenant-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
/* state picker in the Add Tenant dialog: chips for the chosen states, a search box and a menu of matches */
.state-picker { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; cursor: text; min-height: 42px; }
.state-picker:focus-within { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(20, 60, 90, 0.12); }
.state-chips { display: contents; }
.state-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--info-bg); color: var(--info); border-radius: 20px; padding: 3px 6px 3px 10px; font-size: 13px; line-height: 1.4; white-space: nowrap; }
.state-chip b { font-weight: 700; }
.chip-x { background: transparent; border: 0; color: inherit; font-size: 16px; line-height: 1; padding: 0 4px; height: auto; cursor: pointer; opacity: .7; }
.chip-x:hover { background: transparent; opacity: 1; }
.state-picker input { flex: 1; min-width: 160px; border: 0; outline: 0; padding: 4px 2px; font-size: 14px; background: transparent; box-shadow: none; }
.state-menu { flex-basis: 100%; margin: 2px -8px -6px; border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 var(--radius-sm) var(--radius-sm); max-height: 200px; overflow-y: auto; }
.state-item { padding: 8px 12px; font-size: 13.5px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.state-item b { width: 26px; font-weight: 700; }
.state-item:hover, .state-item.active { background: var(--neutral-bg); }
.advanced { margin-top: 4px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.advanced > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--navy); }
.advanced .form-grid { margin-top: 12px; }
.tz-picker { font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.tz-picker select { height: 30px; font-size: 13px; }

/* --- info icon with hover tooltip ------------------------------------------- */
.info-icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; background: #dbe4ea; color: #4a5c6c; font-size: 10px; font-style: italic; font-family: Georgia, serif; font-weight: 700; line-height: 1; cursor: help; margin-left: 4px; vertical-align: middle; flex-shrink: 0; }
.info-icon .tooltip { display: none; position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%); width: 260px; background: var(--text); color: #fff; font-size: 12px; font-style: normal; font-family: inherit; font-weight: 400; line-height: 1.45; padding: 9px 11px; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,0.2); z-index: 30; text-align: left; }
.info-icon:hover .tooltip, .info-icon:focus .tooltip { display: block; }

/* --- data source cards (one per external feed on the Data Sources page) ----- */
.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 4px; }
.source-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fbfcfd; display: flex; flex-direction: column; }
.source-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.source-card-head h3 { margin: 0; font-size: 14.5px; display: flex; align-items: center; }
.source-blurb { margin: 0 0 6px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.source-current { margin: 0 0 8px; font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }
.source-form { margin-top: 6px; display: flex; flex-direction: column; flex: 1 1 auto; }
.source-form .field-grid { margin-bottom: 14px; }
.source-form > button { margin-top: auto; align-self: flex-start; }
.detected { margin: 4px 0 8px; padding: 7px 9px; border: 1px solid #d6e0e6; border-radius: var(--radius-sm); background: #f6fafc; font-size: 12px; line-height: 1.45; }

/* --- issues list: the Problems Found card -------------------------------- */
.issue { padding: 14px 0; border-top: 1px solid var(--line-soft); }
.issue:first-of-type { border-top: 0; padding-top: 4px; }
.issue-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.issue-head b { font-size: 14.5px; }
.issue-head .issue-where { color: var(--muted); font-size: 13px; }
.issue-body { margin: 5px 0 0; font-size: 13.5px; color: var(--text-2); max-width: 900px; line-height: 1.5; }
.issue-body i { color: var(--muted); }
.issue-detail { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.issue-sites { margin: 8px 0 0; }
.issue-sites .data-table { margin: 0; }
.issue-sites .data-table td { padding: 6px 8px; font-size: 13px; border-bottom-color: var(--line-soft); }
.issue-sites .data-table tr:last-child td { border-bottom: 0; }
.issues-notes { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.issues-notes .issue { padding: 8px 0; border: 0; }
.issues-notes .issue-head b { font-size: 13.5px; font-weight: 600; }

/* --- toggle switch (reading forwarding) and the danger zone ----------------- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 6px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { position: relative; width: 46px; height: 26px; border-radius: 26px; background: #ccd3d9; transition: background 0.15s ease; flex-shrink: 0; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 0.15s ease; }
.switch input:checked + .switch-track { background: #c0392b; }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid #7fb2d4; outline-offset: 2px; }
.switch-label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.switch.is-disabled { cursor: not-allowed; opacity: 0.55; }
.switch input:disabled + .switch-track { background: var(--line); }
.danger-zone { border: 1px solid #f3c3bd; background: #fffaf9; border-radius: var(--radius); padding: 14px 16px; }
.danger-zone h3 { margin: 0 0 4px; font-size: 14px; color: var(--danger); }

/* Local Copy Of State Data card: per-state download progress bars */
.state-dl { border-top: 1px solid var(--line-soft); padding: 10px 0 4px; }
.state-dl:first-of-type { border-top: 0; }
.state-dl-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.state-dl-layers { display: grid; gap: 4px; }
.state-dl-layer { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.state-dl-bar { display: block; height: 8px; background: var(--neutral-bg); border-radius: 4px; overflow: hidden; }
.state-dl-bar i { display: block; height: 100%; background: var(--navy); border-radius: 4px; }
@media (max-width: 720px) { .state-dl-layer { grid-template-columns: 80px 1fr; } .state-dl-layer .mono { grid-column: 2; } }

/* --- modal dialog (native <dialog>) ---------------------------------------- */
dialog.modal { width: min(660px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.28); color: var(--text); background: #fff; }
dialog.modal::backdrop { background: rgba(15, 33, 48, 0.45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-close { background: transparent; border: 0; color: var(--faint); font-size: 22px; line-height: 1; padding: 0 4px; height: auto; }
.modal-close:hover { background: transparent; color: var(--text); }
.modal-body { padding: 18px 20px; max-height: min(70vh, 620px); overflow-y: auto; }
dialog.modal .form-actions { padding: 0 20px 18px; border-top: 0; }

/* --- login page ------------------------------------------------------------ */
.login-box { max-width: 380px; margin: 64px auto; background: #fff; padding: 28px; border-radius: 10px; box-shadow: var(--shadow); border: 1px solid var(--line-soft); }
.login-box h1 { margin: 0 0 16px; font-size: 20px; }
.login-box label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.login-box input { width: 100%; margin-top: 5px; display: block; }
.login-box button { width: 100%; margin-top: 4px; }

/* --- <details> used as "show more" ----------------------------------------- */
details > summary { cursor: pointer; }
details.plain > summary { color: var(--navy); font-weight: 600; font-size: 13px; }

/* --- data sources: files in use and the coverage tabs ----------------------- */
.files-in-use { margin: 0 0 12px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.file-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.file-row:last-child { border-bottom: 0; }
.file-main { min-width: 0; overflow-wrap: anywhere; line-height: 1.4; }
.file-main .small { display: block; }
#cov-tabs button { height: 28px; }

/* paged lists (sensors, readings): list meta line, pager, inline search, file help */
.list-meta{display:flex;justify-content:space-between;align-items:center;gap:12px;margin:2px 0 10px;font-size:13px;color:var(--text-2)}
.list-meta-bottom{margin:10px 0 0}
.pager{display:inline-flex;align-items:center;gap:14px;font-size:13px}
.pager a{color:var(--navy);text-decoration:none;font-weight:600}
.pager a:hover{text-decoration:underline}
.pager .is-off{color:var(--faint)}
.pager-where{color:var(--text-2)}
.inline-search{display:inline-flex;align-items:center;gap:6px}
.file-help{margin-top:8px;padding:8px 10px;background:var(--neutral-bg);border-radius:var(--radius-sm);font-size:12px;color:var(--text-2)}
.file-help ul{margin:4px 0 0;padding-left:18px}
.file-help li{margin:2px 0}
/* problem groups list their sites as chips */
.issue-sites-chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.site-chip{display:inline-block;padding:2px 9px;border:1px solid var(--line);border-radius:999px;background:var(--card);font-size:12.5px;color:var(--text);cursor:default}
.site-chip .mono{color:var(--muted);font-size:11px}

/* site page: two-column layout, key/value table, date-range tools, water-level chart */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.kv-table td:first-child { color: var(--text-2); width: 45%; }
.range-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.range-tools .btn-small { display: inline-flex; align-items: center; text-decoration: none; }
.range-tools form { margin-left: 8px; }
.range-tools input[type=date] { height: 28px; padding: 0 6px; font-size: 12.5px; }
.wl-chart { width: 100%; }
.wl-chart svg { display: block; }
tr.is-flagged td { color: var(--muted); }
.site-link { color: var(--text); text-decoration: none; font-weight: 600; }
.site-link:hover { color: var(--navy); text-decoration: underline; }
a.site-chip { text-decoration: none; cursor: pointer; }
a.site-chip:hover { border-color: var(--navy-line); background: var(--navy-soft); color: var(--navy); }

/* phone layout (<= 720px). The header keeps one line (brand, then the account controls); long tool rows
   scroll sideways inside their card instead of spilling out; tables scroll inside their wrap. */
.topbar .brand { white-space: nowrap; }
.card-head .card-tools { flex-wrap: wrap; row-gap: 8px; max-width: 100%; }
.cov-tabs-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 720px) {
  .topbar { padding: 0 14px; height: 48px; }
  .topbar-left { gap: 12px; min-width: 0; }
  .topbar .brand { font-size: 15px; }
  .topbar-link { display: none; }                 /* the tenant tab bar has View Live Map */
  .user-email { display: none; }                   /* the account is on the Users page */
  .logout-form button { padding: 5px 10px; }
  .content { padding: 14px 14px 40px; }
  h1 { font-size: 22px; }
  .lede, .muted-note { font-size: 13px; margin-bottom: 14px; }
  .tenant-tabs { gap: 0; margin-bottom: 16px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tenant-tabs::-webkit-scrollbar { display: none; }
  .tenant-tab { padding: 10px 11px; font-size: 13.5px; white-space: nowrap; flex: 0 0 auto; }
  .tenant-tab.tab-right { margin-left: auto; padding-right: 4px; }
  .card, section { padding: 14px; }
  .card-head { align-items: flex-start; }
  .card-head h2 { flex: 1 1 100%; }
  .card-head .card-tools { margin-left: 0; width: 100%; }
  #cov-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  #cov-tabs::-webkit-scrollbar { display: none; }
  #cov-tabs .btn-small { flex: 0 0 auto; }
  #cov-map { height: 300px !important; }
  .cov-legend { gap: 10px 14px !important; }
  .kv-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
  .kv-strip .big { font-size: 20px; }
  .actions-row { gap: 8px; }
  .actions-row form, .actions-row button { width: 100%; }
  .actions-row .actions-note { flex-basis: 100%; }
  .source-grid { grid-template-columns: 1fr; }
  .inline-search { flex-wrap: wrap; }
  .inline-search input[type=search] { min-width: 0 !important; flex: 1 1 100%; }
  .range-tools form { margin-left: 0; width: 100%; }
  .range-tools input[type=date] { flex: 1 1 40%; min-width: 0; }
  .list-meta { flex-wrap: wrap; }
  .row-actions { white-space: normal; }
  .row-actions form { margin: 2px 0 2px 4px; }
  .data-table th, .data-table td { padding: 8px 8px; }
  .two-col { gap: 14px; }
}
@media (max-width: 400px) {
  .topbar .brand { font-size: 14px; }
  .kv-strip { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .hide-sm { display: none !important; }
  .data-table .mono { font-size: 12px; }
  .card-tools .inline-search { width: 100%; }
  .card-tools .inline-search input[type=search] { flex: 1 1 60%; }
  .card-tools .inline-search button { flex: 0 0 auto; }
  #add-sensor-btn { width: 100%; }
}

/* guided column-mapping page: numbered steps, source/target pickers, sample chips */
.map-step-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.map-step-head h2 { margin: 0; }
.map-step-head .badge { margin-left: auto; white-space: nowrap; }
.step-no { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.map-pick { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 18px; align-items: start; }
@media (max-width: 720px) { .map-pick { grid-template-columns: 1fr; } .map-step-head { flex-wrap: wrap; } .map-step-head .badge { margin-left: 38px; } }
.map-preview { background: var(--neutral-bg); border-radius: var(--radius-sm); padding: 10px 12px; min-height: 58px; }
.sample-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sample-chip { display: inline-block; padding: 2px 8px; background: var(--card); border: 1px solid var(--line); border-radius: 4px; font-family: var(--mono); font-size: 12px; max-width: 100%; overflow-wrap: anywhere; }
.file-row .file-status { margin-top: 3px; }
.map-actions { display: flex; align-items: center; justify-content: flex-end; gap: 18px; margin: 0 0 24px; }

/* station page: camera image, photo grid, field notes */
.kv-strip.kv-wrap { flex-wrap: wrap; row-gap: 14px; }
.cam img { max-width: 100%; max-height: 420px; border-radius: 6px; display: block; background: #eef1f4; }
.cam-tools { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.cam-tools input[type=range] { flex: 1; min-width: 120px; }
.section-title .small { text-transform: none; letter-spacing: 0; font-weight: 400; }   /* units and counts beside a section title read as written */
.st-charts { display: block; }   /* one column: every chart the full width of the card, all on the same time window */
.st-title { margin-bottom: 2px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; height: 130px; object-fit: cover; border-radius: 4px; display: block; background: #eef1f4; }
.photo-grid input { width: 100%; margin-top: 4px; box-sizing: border-box; }
.note { border-top: 1px solid #eef1f4; padding: 10px 0; }
.note:first-of-type { border-top: 0; }
.note-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-remove { margin-left: auto; }
.note-body { white-space: pre-wrap; margin-top: 6px; }
button.btn-link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
/* alerts page: inline forms in table cells, scrollable checkbox lists */
td .inline-form { display: inline-flex; margin: 0 4px 0 0; }
.check-list { display: flex; flex-direction: column; gap: 4px; max-height: 150px; overflow: auto; }
label.check { display: flex; align-items: center; gap: 6px; font-weight: normal; }
label.check input { width: auto; margin: 0; }
[hidden] { display: none !important; }
select[multiple] { height: auto; min-height: 120px; }
/* public/charts.js chart tooltip and modal; readings table icon buttons and annotations */
.ssc { position: relative; }
.ssc-tip { position: absolute; pointer-events: none; background: #fff; border: 1px solid #d5dce3; border-radius: 6px; padding: 6px 8px; font-size: 12px; box-shadow: 0 4px 14px rgba(15,61,92,.15); white-space: nowrap; z-index: 5; }
.ssc-when { color: #6b7784; }
.ssc-val { font-weight: 700; color: #0f3d5c; font-size: 13px; }
.ssc-sub { color: #6b7784; }
.ssc-note { color: #6e3a8a; white-space: normal; max-width: 260px; }
.ssc-flag { color: #c47a00; font-weight: 600; font-size: 11px; }
.ssc-modal { position: fixed; inset: 0; background: rgba(15,30,45,.55); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 24px; }
.ssc-box { background: #fff; border-radius: 10px; width: min(1200px, 100%); max-height: 100%; overflow: auto; padding: 14px 18px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.ssc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 15px; }
.ssc-close { margin-left: auto; background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: #6b7784; padding: 0 4px; }
.ssc-help { margin: 6px 0 0; }
.icon-btn { background: none; border: 1px solid #d5dce3; border-radius: 4px; width: 22px; height: 22px; line-height: 18px; padding: 0; font-size: 15px; cursor: pointer; color: #1a5f8c; }
.icon-btn:hover { background: #eef4f8; }
.icon-btn.danger-x { color: #a3241c; border-color: #efd0cd; }
.icon-btn.danger-x:hover { background: #fbeceb; }
.ann-cell { text-align: center; }
.ann-head { text-align: center; }
.ann-cell .ann { display: flex; align-items: flex-start; gap: 4px; margin-bottom: 3px; text-align: left; }
.ann-cell .ann-plus { display: inline-block; margin: 0 auto; }
.ann-cell .ann-x { display: inline; margin: 0; }
.ann-cell .ann-x .icon-btn { width: 16px; height: 16px; line-height: 13px; font-size: 12px; border: 0; color: #93a0ab; }
td.row-x form { margin: 0; }

/* ==========================================================================
   Visual refresh. Same class names and layout; overrides the tokens above with
   a crisper type face (Inter), a brand mark, softer cards, a cleaner tab bar
   and tables. Then the Overview page's own pieces.
   ========================================================================== */
:root { --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; --bg: #f4f6f9; --line: #e2e8ee; --line-soft: #edf1f5;
  --brand: #0e6ba8; --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06); }
body { font-family: var(--font); font-size: 14px; letter-spacing: -0.006em; -webkit-font-smoothing: antialiased; }
.topbar { background: linear-gradient(90deg, #0b3d5c, #0d4c72); height: 56px; box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 2px 10px rgba(11, 46, 70, .18); }
.topbar .brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(150deg, #16a3c8, #0e6ba8); display: inline-grid; place-items: center; box-shadow: 0 1px 0 rgba(255,255,255,.25) inset; }
.logout-form button { border-radius: 8px; height: 32px; }
.content { max-width: 1180px; padding-top: 24px; }
h1 { font-size: 26px; letter-spacing: -0.02em; }
h2 { letter-spacing: -0.01em; }
.crumbs { font-size: 12.5px; }
.tenant-tabs { gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tenant-tab { font-size: 13.5px; font-weight: 600; padding: 10px 12px; border-radius: 8px 8px 0 0; border-bottom-width: 2px; }
.tenant-tab:hover { background: #eaf0f5; }
.tenant-tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.card, section { border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
button, .btn { border-radius: var(--radius-sm); font-weight: 600; }
.logout-form button:hover { background: rgba(255,255,255,.12); }
th, .data-table th { font-size: 11px; letter-spacing: .05em; color: #6b7784; background: #f8fafc; border-bottom: 1px solid var(--line); }
.data-table tbody tr:hover { background: #f6f9fc; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], select, textarea { border-radius: var(--radius-sm); }
.badge, .status-pill { font-weight: 600; }
.kv-strip .big { letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* Overview page: status tiles (colour via --c, same groups as client/status.js), KPI strip, open-alert list */
.ov-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 0 0 18px; flex-wrap: wrap; }
.ov-head h1 { margin: 0 0 2px; }
.ov-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.ov-tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 4px; height: auto; min-height: 92px; padding: 14px 16px; text-align: left;
  background: #fff !important; color: var(--text) !important; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer; white-space: normal; overflow: hidden; }
.ov-tile::before { content: ''; position: absolute; left: 0; top: 0; right: 0; height: 3px; background: var(--c); }
.ov-tile b { font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ov-tile span { font-size: 12.5px; font-weight: 500; color: var(--text-2); line-height: 1.3; }
.ov-tile.zero b { color: var(--faint); }
.ov-tile:hover { border-color: #c9d6e1; }
.ov-tile.on { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
.ov-kpis .kv-strip { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 18px; }
.ov-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 20%, transparent); }
.ov-list { display: flex; flex-direction: column; gap: 6px; }
.ov-item { display: block; padding: 9px 12px; border: 1px solid var(--line-soft); border-left: 3px solid #f5a623; border-radius: 8px; text-decoration: none; color: var(--text); }
.ov-item:hover { background: #f6f9fc; }
.ov-item b { display: block; font-size: 13.5px; } .ov-item span { display: block; font-size: 12.5px; color: var(--text-2); } .ov-item em { display: block; font-style: normal; font-size: 12px; color: var(--muted); }
.ov-kind-flood_stage { border-left-color: #e5484d; } .ov-kind-suspect { border-left-color: #9b8cff; }
.ov-skel { border-radius: 10px; min-height: 92px; background: linear-gradient(90deg, #eef2f6 0%, #f7f9fb 50%, #eef2f6 100%); background-size: 200% 100%; animation: ov-shimmer 1.3s ease-in-out infinite; border: 0; }
@keyframes ov-shimmer { 0% { background-position: 150% 0 } 100% { background-position: -50% 0 } }
@media (max-width: 860px) { .ov-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* phone fixes: nothing wider than the screen; the header and the demo bar wrap */
@media (max-width: 720px) {
  .logout-form { gap: 10px; }
  .logout-form .help-link { margin-right: 0 !important; }
  .demo-bar { gap: 8px 12px; font-size: 13px; }
  .demo-bar form { flex-wrap: wrap; width: 100%; }
  .demo-bar select { flex: 1 1 150px; min-width: 0; }
  :not(.table-wrap) > table.data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ov-head { align-items: flex-start; }
  .ov-head-tools .btn { height: 32px; }
  .kv-strip > div { min-width: 0; }
  .ov-tile:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: center; gap: 10px; }
  .ov-tile:last-child:nth-child(odd) b { font-size: 22px; }
}

/* --- site page tabs (views/site.ejs): sections of one site, under the summary strip ---------------------- */
.site-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 4px 0 18px; position: sticky; top: 0; z-index: 5; background: var(--bg, #f4f7fa); padding-top: 6px; }
.site-tab { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0; margin-bottom: -1px; padding: 9px 12px; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.site-tab:hover { color: var(--navy); background: #eaf0f5; }
.site-tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.site-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.site-pane > .card:first-child { margin-top: 0; }
@media (max-width: 720px) { .site-tabs { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; } .site-tabs::-webkit-scrollbar { display: none; } .site-tab { padding: 9px 10px; } }

/* --- Model tab: engineering detail folded under one heading (views/model.ejs) ----------------------------- */
.eng-fold { margin-top: 22px; }
.eng-fold > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius, 12px); background: var(--card, #fff); box-shadow: var(--shadow); font-weight: 650; font-size: 16px; }
.eng-fold > summary::-webkit-details-marker { display: none; }
.eng-fold > summary::before { content: "\25B8"; color: var(--muted); font-size: 13px; transition: transform .15s; }
.eng-fold[open] > summary::before { transform: rotate(90deg); }
.eng-fold > summary .small { font-weight: 500; color: var(--muted); }
.eng-fold[open] > summary { margin-bottom: 16px; }
