/* Shared design tokens and components for the public site and the staff dashboard. */
:root {
    --ink: #0e2730;          /* deep reservoir: text, dark surfaces */
    --ink-2: #3c5761;        /* secondary text */
    --ink-3: #6b8189;        /* muted text */
    --teal: #00788f;         /* primary action, potable */
    --teal-2: #005f72;
    --teal-tint: #e3f1f3;
    --lilac: #7357c4;        /* non-potable (purple = non-drinking water) */
    --lilac-tint: #eeeaf9;
    --amber: #c97200;
    --rose: #d0457f;
    --tag: #ffc629;          /* the yellow touch tag */
    --tag-2: #f2b100;
    --mist: #eef3f3;         /* page */
    --paper: #ffffff;
    --line: #d6e1e2;
    --line-2: #e7eeee;
    --good: #1d7f48; --good-tint: #e4f3ea;
    --warn: #a35f00; --warn-tint: #fdf1dc;
    --bad: #b93229; --bad-tint: #fbe7e5;
    --lcd: #0c1a14; --lcd-on: #7cf3a5; --lcd-off: rgba(124, 243, 165, .07);
    --radius-s: 6px; --radius: 10px; --radius-l: 16px;
    --shadow: 0 1px 2px rgba(14, 39, 48, .06), 0 6px 18px -8px rgba(14, 39, 48, .18);
    --shadow-l: 0 2px 4px rgba(14, 39, 48, .06), 0 24px 48px -18px rgba(14, 39, 48, .35);
    --font: 'Schibsted Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --ease: cubic-bezier(.22, 1, .36, 1);
    color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--mist); font-feature-settings: 'tnum' 1; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0; letter-spacing: -0.015em; }
p { margin: 0; }
a { color: var(--teal-2); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--tag); outline-offset: 2px; border-radius: 4px; }
img, svg { display: block; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; } }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 44px; padding: 0 18px; border-radius: var(--radius); border: 1px solid transparent; font-weight: 650; font-size: 15px; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s, transform .1s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-2); color: #fff; }
.btn-tag { background: var(--tag); color: var(--ink); border-color: rgba(14, 39, 48, .12); box-shadow: inset 0 -2px 0 rgba(14, 39, 48, .12); }
.btn-tag:hover { background: var(--tag-2); color: var(--ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--paper); border-color: var(--ink-3); }
.btn-quiet { background: transparent; color: var(--teal-2); padding: 0 10px; }
.btn-quiet:hover { background: var(--teal-tint); color: var(--ink); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #962820; color: #fff; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn-lg { min-height: 56px; padding: 0 24px; font-size: 17px; }
.btn-block { width: 100%; }

/* ---------- Form fields ---------- */
.field { display: grid; gap: 6px; align-content: start; }
.field > span, .field-label { font-weight: 600; font-size: 14px; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: 13px; }
.input, .select, .textarea { width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); transition: border-color .15s, box-shadow .15s; }
.textarea { min-height: 90px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: #b6c7c9; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 120, 143, .18); }
.input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 3px rgba(185, 50, 41, .12); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%233c5761' stroke-width='1.8'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 15px; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--teal); flex: none; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 13px; font-weight: 600; line-height: 20px; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.badge.good { background: var(--good-tint); color: var(--good); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }
.badge.potable { background: var(--teal-tint); color: var(--teal-2); }
.badge.nonpotable { background: var(--lilac-tint); color: #5a40a8; }
.badge.ink { background: var(--ink); color: #fff; }

/* ---------- Seven-segment display (the filling-station cabinet readout) ---------- */
.lcd { background: var(--lcd); border-radius: 12px; padding: 14px 16px 12px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06), inset 0 10px 30px rgba(0, 0, 0, .5); color: var(--lcd-on); position: relative; overflow: hidden; }
.lcd::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .14) 0 1px, transparent 1px 3px); pointer-events: none; }
.lcd-row { display: flex; align-items: flex-end; gap: 4px; }
.lcd-cur { font-weight: 700; font-size: .9em; margin-right: 6px; align-self: flex-start; opacity: .9; }
.seg { display: flex; align-items: flex-end; filter: drop-shadow(0 0 6px rgba(124, 243, 165, .35)); }
.seg svg { height: 1em; width: auto; }
.seg .on { fill: var(--lcd-on); }
.seg .off { fill: var(--lcd-off); }
.lcd-caption { font-size: 12px; letter-spacing: .02em; color: rgba(124, 243, 165, .65); margin-top: 6px; display: flex; justify-content: space-between; gap: 12px; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(9, 26, 32, .55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadeIn .2s var(--ease); }
.modal { background: var(--paper); width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; border-radius: var(--radius-l); box-shadow: var(--shadow-l); animation: popIn .28s var(--ease); }
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; position: sticky; top: 0; background: var(--paper); z-index: 2; }
.modal-head h2 { font-size: 20px; }
.modal-body { padding: 4px 20px 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line-2); position: sticky; bottom: 0; background: var(--paper); }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 0; background: transparent; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 100; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow-l); display: flex; gap: 10px; align-items: flex-start; font-size: 15px; animation: popIn .25s var(--ease); }
.toast.bad { background: var(--bad); }
.toast svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }

/* ---------- Charts (assets/js/charts.js) ---------- */
.bwc { position: relative; }
.bwc-plot { width: 100%; }
.bwc svg { overflow: visible; }
.bwc-grid { stroke: var(--line-2); stroke-width: 1; }
.bwc-base { stroke: #b9c8ca; stroke-width: 1; }
.bwc-axis { font-size: 11.5px; fill: var(--ink-3); font-family: var(--font); }
.bwc-cross { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.bwc-marker { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; }
.bwc-marker-label { fill: var(--ink-2); font-weight: 600; }
.bwc-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; font-size: 13px; color: var(--ink-2); }
.bwc-key { display: inline-flex; align-items: center; gap: 7px; }
.bwc-key i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.bwc-tip { position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; opacity: 0; transition: opacity .12s; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow); font-size: 13px; min-width: 150px; }
.bwc-tt { font-weight: 700; margin-bottom: 4px; color: var(--ink); }
.bwc-row { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.bwc-row i { width: 9px; height: 9px; border-radius: 2px; }
.bwc-row b { margin-left: auto; color: var(--ink); font-weight: 650; padding-left: 12px; }
.bwc-total { border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 4px; }
.bwc-spark { display: inline-block; vertical-align: middle; }

/* ---------- Brand mark ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-text { display: grid; line-height: 1.1; }
.brand-text b { font-size: 16px; font-weight: 750; letter-spacing: -0.01em; }
.brand-text small { font-size: 12.5px; opacity: .75; }

/* ---------- Spinner ---------- */
.spin { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
