/* DPG Customer Portal: sage base with DPG blue/leaf accents. */

@font-face {
  font-family: "Inter";
  src: url("../vendor/inter/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #eef2ec;
  --bg-deep: #e3e9e1;
  --surface: #ffffff;
  --surface-2: #f6f8f4;
  --surface-sage: #e9f0ea;
  --ink: #1c3631;
  --ink-2: #4b605a;
  --ink-3: #7b8c86;
  --line: #dde5de;
  --line-2: #cbd6cd;

  --teal: #1f7a78;
  --teal-ink: #145e5c;
  --teal-soft: #dbece9;
  --water: #4fb3d9;
  --water-deep: #2a8fbf;
  --dpg-blue: #1b5aa6;
  --dpg-leaf: #57a83b;
  --amber: #b7791f;
  --amber-soft: #fbf0dc;
  --idle: #9aa7a2;

  --prod-n: #20b92a;
  --prod-p: #005bff;
  --prod-k: #ff2f17;
  --prod-m: #fe8c23;
  --prod-a: #ecd510;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(28, 54, 49, .06), 0 1px 1px rgba(28, 54, 49, .04);
  --shadow-2: 0 10px 30px -12px rgba(28, 54, 49, .22), 0 2px 6px rgba(28, 54, 49, .06);
  --shadow-3: 0 30px 80px -20px rgba(18, 40, 36, .45);
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --gutter: clamp(16px, 3vw, 32px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--teal) 55%, transparent); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.noscript { padding: 24px; text-align: center; color: var(--ink-2); }

/* ---- Boot ---------------------------------------------------------------- */

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 22px; }
.boot__logo { width: 72px; height: 72px; animation: boot-pulse 1.8s ease-in-out infinite; }
.boot__bar { width: 140px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; position: relative; }
.boot__bar::after {
  content: ""; position: absolute; inset: 0; width: 40%; border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--dpg-leaf));
  animation: boot-slide 1.1s ease-in-out infinite;
}
@keyframes boot-pulse { 50% { transform: scale(1.05); } }
@keyframes boot-slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ---- Buttons & inputs ---------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn--primary:hover { background: var(--teal-ink); border-color: var(--teal-ink); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn svg { width: 18px; height: 18px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }
.icon-btn svg { width: 18px; height: 18px; }

.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  /* 16px, not the body's 15px: Safari on iPhone zooms the whole page in when a field with smaller
     text gets focus, and stays zoomed afterwards. */
  font-size: 16px;
}
.input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }

.select {
  appearance: none; -webkit-appearance: none;
  min-height: 40px; padding: 0 38px 0 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background-color: var(--surface);
  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 1.5l5 5 5-5' fill='none' stroke='%234b605a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  font-weight: 600; font-size: 14px; max-width: 100%; text-overflow: ellipsis;
}
.select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }
/* The same iPhone zoom applies to dropdowns. On touch screens and phone widths they get 16px too;
   with a mouse they keep the smaller size. */
@media (pointer: coarse), (max-width: 749px) {
  .select { font-size: 16px; }
}
.select--site { background-color: var(--surface-sage); border-color: transparent; color: var(--teal-ink); min-width: 220px; }
.select--customer { min-width: 200px; max-width: 280px; }
.topbar__site { display: flex; gap: 8px; min-width: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 12px;
  border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.chip--water { background: var(--teal-soft); color: var(--teal-ink); border-color: transparent; }
.chip--warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.dot--live { position: relative; }
.dot--live::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid currentColor;
  opacity: 0; animation: ping 1.8s ease-out infinite;
}
@keyframes ping { 0% { transform: scale(.4); opacity: .7; } 100% { transform: scale(1.4); opacity: 0; } }

.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }

/* ---- Login --------------------------------------------------------------- */

.login {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr);
  background: var(--bg);
}
.login__art {
  position: relative; overflow: hidden;
  background: radial-gradient(120% 90% at 30% 10%, #f7faf4 0%, #e5ede3 55%, #d8e3d6 100%);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 12px; padding: 40px;
}
.login__art svg.scene { align-self: center; width: 112%; height: auto; margin-left: -6%; }
.login__brand { position: relative; display: flex; align-items: center; gap: 14px; z-index: 1; }
.login__brand img { width: 52px; height: 52px; }
.login__brand-name { font-weight: 800; letter-spacing: .02em; font-size: 18px; }
.login__brand-sub { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.login__tagline { position: relative; z-index: 1; max-width: 460px; }
.login__tagline h2 { font-size: clamp(26px, 3vw, 38px); line-height: 1.1; }
.login__tagline p { margin-top: 10px; color: var(--ink-2); }
.login__panel { display: grid; place-items: center; padding: 40px var(--gutter); background: var(--surface); }
.login__card { width: 100%; max-width: 380px; display: grid; gap: 22px; }
.login__card-logo { display: none; width: 64px; height: 64px; }
.login__card h1 { font-size: 26px; line-height: 1.15; }
.login__card .lede { color: var(--ink-2); margin-top: 6px; }
.login form { display: grid; gap: 16px; }
.login .btn--primary { min-height: 48px; font-size: 15px; }
.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  font-size: 14px; background: var(--amber-soft); color: #7a4f12;
}
.alert--error { background: #fbe6e2; color: #8e2f1f; }
.alert--info { background: var(--teal-soft); color: var(--teal-ink); }
.login__demo { font-size: 13px; color: var(--ink-3); border-top: 1px solid var(--line); padding-top: 16px; }
.login__demo code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; color: var(--ink-2); }

/* ---- Top bar ------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 10px var(--gutter);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-width: 0; }
.brand img { width: 40px; height: 40px; flex: none; }
.brand__name { font-weight: 800; font-size: 16px; letter-spacing: .02em; line-height: 1.1; }
.brand__sub { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }
.topbar__spacer { flex: 1; }
.topbar__clock { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.topbar__user { display: flex; align-items: center; gap: 8px; }
.topbar__username { font-size: 13px; font-weight: 600; color: var(--ink-2); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__user .btn { white-space: nowrap; }

/* When the pickers don't fit beside the brand, clock and user, they get their own row
   (employees have two pickers, so they need the room sooner). */
@media (max-width: 1279px) {
  .topbar--two-pickers { flex-wrap: wrap; row-gap: 10px; }
  .topbar--two-pickers .topbar__site { order: 5; flex-basis: 100%; }
  .topbar--two-pickers .select--site, .topbar--two-pickers .select--customer { flex: 1 1 0; min-width: 0; max-width: 360px; }
}
@media (max-width: 999px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar__site { order: 5; flex-basis: 100%; }
  .select--site, .select--customer { flex: 1 1 0; min-width: 0; max-width: 360px; }
}

/* "Show a field running" demo switch (demorunning.js): only for the customer the config names.
   Amber marks everything simulated, so it never reads as the teal of real running water. */
.demo-switch {
  display: inline-flex; align-items: center; gap: 9px; min-height: 40px; padding: 0 14px 0 5px;
  border-radius: 999px; border: 1px dashed color-mix(in srgb, var(--amber) 45%, var(--line-2));
  background: var(--surface); text-align: left; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.demo-switch[hidden] { display: none; }
.demo-switch:hover { border-color: var(--amber); }
.demo-switch:focus-visible { outline: 3px solid color-mix(in srgb, var(--amber) 60%, transparent); outline-offset: 2px; }
.demo-switch__tag {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 9px 0 7px; border-radius: 999px;
  background: var(--amber-soft); color: #8a5a12; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
}
.demo-switch__tag svg { width: 13px; height: 13px; }
.demo-switch__track {
  position: relative; flex: none; width: 36px; height: 20px; border-radius: 999px;
  background: var(--line-2); transition: background .2s;
}
.demo-switch__thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(28, 54, 49, .3); transition: transform .2s;
}
.demo-switch__text { display: grid; line-height: 1.15; }
.demo-switch__field { font-size: 13px; font-weight: 700; color: var(--ink); }
.demo-switch__state { font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.demo-switch[aria-checked="true"] { background: var(--amber-soft); border-style: solid; border-color: var(--amber); }
.demo-switch[aria-checked="true"] .demo-switch__track { background: var(--amber); }
.demo-switch[aria-checked="true"] .demo-switch__thumb { transform: translateX(16px); }
.demo-switch[aria-checked="true"] .demo-switch__tag { background: var(--amber); color: #fff; }
.demo-switch[aria-checked="true"] .demo-switch__state { color: #8a5a12; }

/* The marker on every view of the simulated field: page head, cards, scene and dashboard tile. */
.demo-flag {
  display: inline-flex; align-items: center; gap: 5px; vertical-align: middle; width: max-content;
  padding: 2px 9px 2px 6px; border-radius: 999px; border: 1px dashed var(--amber);
  background: var(--amber-soft); color: #8a5a12; font-size: 11.5px; font-weight: 700; letter-spacing: 0; line-height: 1.4;
}
.demo-flag[hidden] { display: none; }
.demo-flag svg { width: 13px; height: 13px; flex: none; }
.card__title .demo-flag { margin-left: 8px; }
.demo-flag--chip { min-height: 30px; padding: 0 12px 0 9px; font-size: 13px; }
.demo-flag--chip svg { width: 15px; height: 15px; }
.demo-flag--scene {
  position: absolute; top: 14px; left: 16px; padding: 5px 12px 5px 9px; font-size: 13px;
  border-style: solid; box-shadow: var(--shadow-2); pointer-events: none;
}
.demo-flag--scene svg { width: 15px; height: 15px; }

/* ---- Page ---------------------------------------------------------------- */

.page { max-width: 1440px; margin: 0 auto; padding: 22px var(--gutter) 48px; display: grid; gap: 20px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(26px, 3.2vw, 36px); line-height: 1.1; margin-top: 6px; }
.page-head__meta { color: var(--ink-3); font-size: 14px; margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-head__chips { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); border: 1px solid var(--line); }
.card__head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; padding: 18px 20px 6px; }
.card__title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.card__sub { font-size: 13px; color: var(--ink-3); }
.card__body { padding: 8px 20px 20px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.layout__main { display: grid; gap: 20px; min-width: 0; }
.side { display: grid; gap: 20px; align-content: start; }

/* Field overview: one tile per field */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 16px; }
.field-tile {
  display: grid; gap: 10px; align-content: start; text-align: left;
  padding: 16px 18px 18px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-1);
  transition: border-color .15s, box-shadow .2s, transform .2s;
}
.field-tile:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.field-tile.is-running { border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); background: linear-gradient(180deg, var(--teal-soft), var(--surface) 70%); }
.field-tile__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.field-tile__name { font-size: 18px; font-weight: 750; line-height: 1.2; overflow-wrap: anywhere; }
.field-tile__status {
  display: inline-flex; align-items: center; gap: 7px; flex: none; min-height: 26px; padding: 0 10px;
  border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line);
}
.field-tile__status .dot { color: var(--idle); }
.field-tile.is-running .field-tile__status { background: var(--teal); color: #fff; border-color: transparent; }
.field-tile.is-running .field-tile__status .dot { color: #fff; }
.field-tile__meta { font-size: 13.5px; color: var(--ink-2); margin-top: -4px; }
.field-tile__foot { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-height: 22px; }
.field-tile__flow { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.field-tile.is-running .field-tile__flow { font-size: 20px; font-weight: 750; color: var(--teal-ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.field-tile__flow small { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-left: 3px; }
.field-tile__sets { font-size: 12.5px; color: var(--teal-ink); font-weight: 600; text-align: right; }

/* Employee's customer list: the dashboard's tiles, one per customer, under a search box and a
   sort control. A tile hidden by the search must really go: `display: grid` above would
   otherwise win over the hidden attribute. */
.field-tile[hidden] { display: none; }
.customer-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.customer-tools__search { flex: 1 1 240px; max-width: 420px; min-height: 40px; border-radius: 999px; padding: 0 18px; }
@media (max-width: 749px) {
  /* On a phone the search box and the sort control each take the full width. */
  .customer-tools__search { flex-basis: 100%; max-width: none; }
  .customer-tools .select { flex: 1 1 100%; }
}
.customer-tile .level-bar { margin-top: 2px; }
.customer-none { color: var(--ink-3); font-size: 14px; padding: 8px 2px; }

/* Dashboard groups: fields first, then water treatment */
.group { display: grid; gap: 12px; }
.group-title { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }

/* Every dashboard tile, field or water treatment, is the same height. */
.fields .field-tile { min-height: var(--tile-h, 148px); }

/* Water-treatment tile: up to two products, each with its total gallons and a level bar,
   sitting at the bottom of the tile like a field tile's water bar and flow. */
.wt-tile { grid-template-rows: auto 1fr; }
.wt-products { display: grid; gap: 7px; align-content: end; }
.wt-product { display: grid; gap: 3px; min-width: 0; }
.wt-product__top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; }
.wt-product__name { font-weight: 600; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wt-product__gal { flex: none; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.wt-product__gal b { font-size: 15px; font-weight: 750; color: var(--ink); }
.level-bar { height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; }
.level-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--water-deep), var(--water)); }

/* Scene */
.scene-card { position: relative; overflow: hidden; padding: 0; background: #eef3ec; }
.scene-card .scene { width: 100%; height: auto; }
.scene-card__legend {
  position: absolute; left: 20px; bottom: 14px; font-size: 12px; color: var(--ink-3);
  display: flex; gap: 14px; flex-wrap: wrap; pointer-events: none;
}
.scene-card__legend span { display: inline-flex; align-items: center; gap: 6px; }
.scene-card__legend i { width: 18px; height: 4px; border-radius: 2px; display: inline-block; }

/* Field-now panel: water, pH and flow */
.now { padding: 16px; display: grid; gap: 14px; }
.now__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.now__title { font-weight: 700; font-size: 15px; }
.mainline { background: var(--surface-sage); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.mainline__row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.mainline__label { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.mainline__state { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.mainline__ph { text-align: right; }
.mainline__ph b { font-size: 26px; line-height: 1; letter-spacing: -0.02em; }
.mainline__foot { font-size: 12px; color: var(--ink-2); }
.flowbar { height: 10px; border-radius: 6px; background: #c9dedd; overflow: hidden; position: relative; }
/* The dashes move inside a fixed stripe (background-position, not transform), and
   both ends fade out, so the bar always ends cleanly whatever the animation phase. */
.flowbar::after {
  content: ""; position: absolute; inset: 2px 3px; opacity: 0;
  background: repeating-linear-gradient(90deg, var(--water-deep) 0 14px, transparent 14px 30px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
}
.is-running .flowbar { background: #bfe3ef; }
.is-running .flowbar::after { opacity: .9; animation: flow-x 1s linear infinite; }
@keyframes flow-x { from { background-position-x: 0; } to { background-position-x: 30px; } }

.gauge-row { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: center; }
.gauge { width: 120px; height: 92px; }
.gauge__value { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.gauge__unit { font-size: 12px; color: var(--ink-3); font-weight: 600; margin-top: 4px; }
.ph-scale { height: 6px; border-radius: 3px; position: relative; margin-top: 8px;
  background: linear-gradient(90deg, #e2543d, #f2a33a 28%, #e8d84a 42%, #67b957 50%, #3d9fb5 64%, #3c5fb8 82%, #5a3ea8); }
.ph-scale i { position: absolute; top: -4px; width: 4px; height: 14px; border-radius: 2px; background: var(--ink); transform: translateX(-2px); transition: left .6s; }

/* Sets */
.sets { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.set {
  display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; font-size: 14px; transition: background .2s;
}
.set .dot { color: var(--line-2); }
.set__usage { font-weight: 700; font-variant-numeric: tabular-nums; }
.set__usage small { font-weight: 500; color: var(--ink-3); font-size: 12px; margin-left: 3px; }
.set.is-running { background: var(--teal-soft); color: var(--teal-ink); }
.set.is-running .dot { color: var(--teal); }
.set.is-hover { background: var(--surface-2); }
.set.is-running.is-hover { background: #cfe6e2; }
.footnote { font-size: 12px; color: var(--ink-3); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.empty { color: var(--ink-3); font-size: 14px; padding: 6px 0; }

/* Report actions */
.actions { display: grid; gap: 10px; padding: 14px; }
.action {
  display: grid; grid-template-columns: 44px 1fr 20px; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.action:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.action__icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-sage); color: var(--teal-ink); }
.action__icon svg { width: 22px; height: 22px; }
.action__title { font-weight: 700; font-size: 14.5px; }
.action__sub { font-size: 12.5px; color: var(--ink-3); }
.action__arrow { color: var(--ink-3); }
.action[disabled] { opacity: .6; cursor: default; transform: none; box-shadow: none; }

/* Tanks */
/* One row per box (up to 6 tanks); 5–6 split 3 + 3 when narrow, 2 per row on phones. */
.tanks-wrap { container-type: inline-size; }
.tanks { --cols: 6; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 220px)); gap: 14px; }
.tanks[data-count="1"] { --cols: 1; }
.tanks[data-count="2"] { --cols: 2; }
.tanks[data-count="3"] { --cols: 3; }
.tanks[data-count="4"] { --cols: 4; }
.tanks[data-count="5"] { --cols: 5; }
@container (max-width: 820px) { .tanks[data-count="5"], .tanks[data-count="6"] { --cols: 3; } }
@container (max-width: 520px) { .tanks.tanks { --cols: 2; gap: 10px; } }
.tank-card {
  position: relative; display: grid; justify-items: center; gap: 2px; text-align: center;
  padding: 16px 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  transition: border-color .15s, box-shadow .2s, transform .2s;
}
.tank-card:hover, .tank-card.is-hover { border-color: var(--line-2); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.tank-card svg.tank { width: min(116px, 100%); height: auto; aspect-ratio: 120 / 140; margin-bottom: 6px; }
/* Water-treatment pair (500 gal and up): two totes side by side. */
.tank-card svg.tank.tank--pair { width: min(200px, 100%); aspect-ratio: 218 / 140; }
.tank-card__name { font-weight: 700; font-size: 14px; line-height: 1.25; }
.tank-card__gal { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tank-card__gal small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 3px; }
.tank-card__of { font-size: 12.5px; color: var(--ink-3); }
.tank-card__pump { margin-top: 8px; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.tank-card__pump.is-running { color: var(--teal); }
.tank-card__pump svg { width: 18px; height: 18px; }

/* Status line under the scene on small screens */
.stats { display: none; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat__label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.stat__value { font-size: 20px; font-weight: 750; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat__value small { font-size: 12px; color: var(--ink-3); font-weight: 600; margin-left: 2px; }
.stat--running { background: var(--teal-soft); border-color: transparent; }
.stat--running .stat__value { color: var(--teal-ink); }

.footer { color: var(--ink-3); font-size: 12px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---- Dialogs ------------------------------------------------------------- */

.dialog {
  border: none; padding: 0; border-radius: 20px; width: min(1180px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); box-shadow: var(--shadow-3); background: var(--surface-2); color: var(--ink);
}
.dialog::backdrop { background: rgba(22, 40, 36, .42); backdrop-filter: blur(3px); }
.dialog[open] { display: grid; grid-template-rows: auto auto minmax(0, 1fr); animation: dialog-in .22s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); background: var(--surface); }
.dialog__title { font-size: 20px; font-weight: 750; }
.dialog__sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.dialog__controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 22px; background: var(--surface); border-bottom: 1px solid var(--line); }
.dialog__body { padding: 18px 22px 22px; overflow: auto; min-height: 0; }
.dialog__body--flush { padding: 0; }

/* The PDF view (Usage report, Lab results; pdfView in ui.js): a dialog that fills the window,
   the PDF taking everything below the controls. */
.dialog--wide { width: calc(100vw - 32px); max-width: 1800px; height: calc(100vh - 32px); max-height: calc(100vh - 32px); }
.dialog--wide .dialog__body--flush { display: flex; flex-direction: column; overflow: hidden; }
.pdf-panel { flex: 1; min-height: 0; display: flex; }
.pdf-frame { flex: 1; width: 100%; min-height: 0; border: 0; display: block; background: #fff; }
.lab-list { padding: 0; max-width: 640px; margin: 0 auto; }
.lab-list .action { color: inherit; text-decoration: none; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tab {
  display: grid; gap: 2px; align-content: center; text-align: left; max-width: 190px; min-height: 52px;
  padding: 7px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
}
.tab:hover { border-color: var(--ink-3); }
.tab__label { font-size: 13px; font-weight: 650; line-height: 1.25; }
.tab__date { font-size: 12px; color: var(--ink-3); }
.tab[aria-selected="true"] { background: var(--teal); border-color: transparent; color: #fff; }
.tab[aria-selected="true"] .tab__date { color: rgba(255, 255, 255, .82); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 7px;
}
.seg button[aria-pressed="true"] { color: #fff; border-color: transparent; background: var(--seg-color, var(--teal)); }
.seg button .swatch { width: 9px; height: 9px; border-radius: 50%; background: var(--seg-color, var(--teal)); }
.seg button[aria-pressed="true"] .swatch { background: #fff; }
.controls-label { font-size: 12px; font-weight: 700; color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; margin-right: 2px; }
.control-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--teal); }

.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.chart { width: 100%; height: min(58vh, 520px); min-height: 320px; }
.chart-note { font-size: 12px; color: var(--ink-3); margin-top: 10px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.data-table th:first-child { text-align: left; }
.data-table thead th { position: sticky; top: 0; background: var(--surface); color: var(--ink-3); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.data-table tbody th { font-weight: 600; color: var(--ink-2); }
.loading { display: grid; place-items: center; min-height: 320px; color: var(--ink-3); gap: 12px; font-size: 14px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--teal); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Admin: update code from GitHub -------------------------------------- */

.dialog--narrow { width: min(760px, calc(100vw - 32px)); }
.controls-note { font-size: 12.5px; color: var(--ink-3); flex: 1 1 260px; }
.admin-pull { display: grid; gap: 18px; }
.admin-pull__result { display: grid; gap: 10px; }
.admin-pull__result:empty { display: none; }
.admin-pull__result .loading { min-height: 120px; }
.admin-pull__change { font-size: 14px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; font-size: 14px; }
.kv dt { color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.mono, .git-output { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: 13px; }
code.mono { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.commit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; overflow-wrap: anywhere; }
.git-output {
  margin: 0; padding: 12px 14px; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink-2);
}

/* ---- Lab results: AI overview and questions ------------------------------ */
/* Only used inside the Lab results dialog (panels/labresults.js and its modules). Small text
   here uses --ink-2 rather than --ink-3 so it keeps AA contrast on white and on the sage. */

.pdf-panel[hidden], .lab-ov[hidden], .lab-viewbar[hidden] { display: none; }
.lab-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* Positioned, so screen-reader-only text deep in the overview (position: absolute) is held here
   instead of stretching the <dialog> and making it scroll. */
.lab-ov, .lab-table-wrap { position: relative; }
.lab-viewbar { flex-basis: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.lab-viewbar__note { font-size: 12.5px; color: var(--ink-2); }

/* Two-option switch: native radios, drawn as one pill. */
.switch { display: inline-flex; gap: 2px; margin: 0; padding: 3px; min-inline-size: 0; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface-2); }
.switch__option { position: relative; display: inline-flex; }
.switch__input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.switch__option span {
  display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 650; color: var(--ink-2); transition: background .15s, color .15s;
}
.switch__option span svg { width: 16px; height: 16px; }
.switch__option:hover .switch__input:not(:checked) + span { color: var(--ink); background: var(--surface); }
.switch__input:checked + span { background: var(--teal); color: #fff; box-shadow: var(--shadow-1); }
.switch__input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--teal) 55%, transparent); outline-offset: 2px; }

/* Overview layout: the report on the left, the question box beside it on wide screens. */
.lab-ov--scroll { flex: 1; min-height: 0; overflow: auto; background: var(--bg); overscroll-behavior: contain; }
.lab-ov__grid { display: grid; gap: 20px; padding: 20px 22px 28px; max-width: 1560px; margin: 0 auto; }
.lab-ov--phone .lab-ov__grid { padding: 0; gap: 16px; }
.lab-ov__main { display: grid; gap: 18px; min-width: 0; align-content: start; }
.lab-ov__main > .loading { min-height: 260px; }
.lab-ov__aside { min-width: 0; }
@media (min-width: 1200px) {
  /* The panel is its own width (the grid column follows it), so it can animate: 380 px, or twice
     that while the user works in it (.lab-ask-wide on the dialog, labresults.js), always leaving
     the report at least 440 px. cqw is the grid's own width. */
  .lab-ov--scroll.has-ask .lab-ov__grid { grid-template-columns: minmax(0, 1fr) auto; align-items: start; container-type: inline-size; }
  .lab-ov--scroll.has-ask .lab-ov__aside { position: sticky; top: 20px; width: 380px; transition: width .28s cubic-bezier(.2, .7, .2, 1); }
  .lab-ask-wide .lab-ov--scroll.has-ask .lab-ov__aside { width: min(760px, calc(100cqw - 460px)); }
  .lab-ov--scroll .lab-ask__widen { display: inline-grid; }
  .lab-ov--scroll .lab-ask { max-height: max(360px, calc(100vh - 290px)); overflow: auto; overscroll-behavior: contain; }
  .lab-ov--scroll .lab-ov__jump { display: none; }
}
.lab-ov .eyebrow { color: var(--ink-2); }
.lab-ov__head { display: grid; gap: 4px; }
.lab-ov__title { font-size: 22px; font-weight: 750; line-height: 1.2; }
.lab-ov__meta { font-size: 13.5px; color: var(--ink-2); }
.lab-ov__meta--note { color: var(--teal-ink); font-weight: 600; }
.lab-ov__jump {
  justify-self: start; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid transparent; background: var(--teal-soft); color: var(--teal-ink); font-weight: 650; font-size: 13.5px;
}
.lab-ov__jump svg { width: 16px; height: 16px; }
.lab-ov__jump:hover { border-color: color-mix(in srgb, var(--teal) 40%, transparent); }
.lab-ov__error { display: grid; justify-items: center; gap: 14px; padding: 56px 16px; color: var(--ink-2); text-align: center; font-size: 14px; }

.lab-card { overflow: hidden; }
.lab-card .card__head { padding: 16px 18px 4px; }
.lab-card__sub { font-size: 13px; color: var(--ink-2); }
.lab-card__body { display: grid; gap: 12px; padding: 8px 18px 18px; min-width: 0; }
.lab-note { font-size: 12.5px; color: var(--ink-2); }

/* AI summary */
.lab-summary { display: grid; gap: 10px; padding: 18px 20px; border-color: #d3e3d6; background: linear-gradient(180deg, #f3f8f1, var(--surface) 70%); }
.lab-summary__tag {
  justify-self: start; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--teal-ink); background: var(--teal-soft);
}
.lab-summary__tag svg { width: 14px; height: 14px; }
.lab-summary__lead { font-size: 16.5px; font-weight: 600; line-height: 1.45; }
.lab-summary__points { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; }
.lab-summary__points li::marker { color: var(--dpg-leaf); }
.lab-summary__fine { font-size: 12px; color: var(--ink-2); padding-top: 10px; border-top: 1px solid var(--line); }

/* Against target: one strip per analyte */
.lab-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--ink-2); }
.lab-legend li { display: inline-flex; align-items: center; gap: 6px; }
.strip-key { width: 16px; height: 16px; flex: none; }
.strip-key--wide { width: 22px; }
.lab-strips { display: grid; container-type: inline-size; }
.lab-strips__group { margin: 12px 0 0; font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.lab-strip-row {
  display: grid; grid-template-columns: 150px minmax(0, 1fr) 150px; gap: 6px 18px; align-items: center;
  padding: 8px 0 4px; border-top: 1px solid var(--line);
}
.lab-strips__group + .lab-strip-row { border-top: 0; }
.lab-strip-row__label { display: grid; gap: 1px; min-width: 0; }
.lab-strip-row__analyte { font-size: 15px; font-weight: 700; }
.lab-strip-row__name { font-size: 12.5px; color: var(--ink-2); }
.lab-strip-row__counts { display: grid; gap: 2px; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lab-strip-row__in b { font-size: 14px; color: var(--ink); }
.lab-strip-row__out { display: flex; flex-wrap: wrap; gap: 2px 10px; font-weight: 650; }
.lab-strip-row__out .is-low, .lab-tip__status.is-low { color: #8a5200; }
.lab-strip-row__out .is-high, .lab-tip__status.is-high { color: #6a2fae; }
.lab-tip__status.is-in_range { color: var(--teal-ink); }
.strip-wrap { min-width: 0; width: 100%; }
.strip { display: block; width: 100%; overflow: visible; }
.strip__target { font-family: var(--font); font-size: 11px; font-weight: 600; }
.strip__dot { outline: none; }
.strip__ring { stroke: var(--ink); stroke-width: 2; opacity: 0; transition: opacity .12s; }
.strip__dot:hover .strip__ring { opacity: .35; }
.strip__dot:focus-visible .strip__ring { opacity: 1; }
.strip__dots.is-anim .strip__pop { animation: strip-in .75s cubic-bezier(.2, .8, .2, 1) both; animation-delay: var(--d, 0ms); }
@keyframes strip-in { from { opacity: 0; transform: translateX(var(--from, 0)) scale(.4); } }

.lab-tip {
  position: fixed; z-index: 5; display: grid; gap: 2px; max-width: 260px; padding: 10px 12px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px -12px rgba(28, 54, 49, .35);
  font-size: 12.5px; color: var(--ink-2);
}
.lab-tip[hidden] { display: none; }
.lab-tip__name { font-size: 13px; font-weight: 700; color: var(--ink); }
.lab-tip__value { margin-top: 4px; }
.lab-tip__value b { font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.lab-tip__status { font-weight: 650; }

/* Over time */
.lab-trend__controls { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.lab-ov .controls-label { color: var(--ink-2); }
.lab-trend__controls .select { max-width: 100%; }
.lab-trend__chart { width: 100%; height: 380px; }
.lab-trend__error { min-height: 160px; }

/* All readings: scrolls inside its own box; the sample column and the header stay put. */
.lab-table-wrap { overflow: auto; max-height: min(70vh, 640px); border-top: 1px solid var(--line); overscroll-behavior: contain; }
.lab-table-wrap:focus-visible { outline-offset: -3px; }
.lab-table { min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.lab-table th, .lab-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.lab-table thead th {
  position: sticky; top: 0; z-index: 2; vertical-align: bottom; background: var(--surface-2);
  font-weight: 600; color: var(--ink-2); border-bottom-color: var(--line-2);
}
.lab-table thead th > span { display: block; }
.lab-table__group { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; }
.lab-table__analyte { font-size: 13px; font-weight: 700; color: var(--ink); }
.lab-table__unit { font-size: 11.5px; font-weight: 500; }
.lab-table__target { font-size: 11px; font-weight: 600; color: var(--teal-ink); }
.lab-table .lab-table__sample {
  position: sticky; left: 0; z-index: 1; min-width: 150px; max-width: 220px; white-space: normal; text-align: left;
  background: var(--surface); box-shadow: 1px 0 0 var(--line);
}
.lab-table thead .lab-table__sample { z-index: 3; background: var(--surface-2); }
.lab-table tbody th { font-weight: 600; color: var(--ink); }
.lab-table__id { display: block; font-size: 11.5px; font-weight: 500; color: var(--ink-2); }
.lab-table .lab-table__meta { text-align: left; color: var(--ink-2); }
.lab-table td.is-low { background: #fdf1dc; color: #7a4800; font-weight: 650; }
.lab-table td.is-high { background: #f1eafb; color: #5b2797; font-weight: 650; }
.lab-table td.is-muted, .lab-table td.is-empty { color: var(--ink-2); }
.lab-table__flag { margin-left: 4px; font-size: 10px; }
.lab-table tbody tr:hover > :not(.is-low):not(.is-high) { background: #f3f7f3; }

/* Notes from reading the PDF */
.lab-notes summary {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; list-style: none;
  font-size: 15px; font-weight: 700;
}
.lab-notes summary::-webkit-details-marker { display: none; }
.lab-notes summary::before {
  content: ""; width: 7px; height: 7px; margin: 0 2px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2);
  transform: rotate(-45deg); transition: transform .15s;
}
.lab-notes[open] summary::before { transform: rotate(45deg); }
.lab-notes__count { padding: 0 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-size: 12px; color: var(--ink-2); }
.lab-notes__body { display: grid; gap: 8px; padding: 0 18px 16px; font-size: 13.5px; color: var(--ink-2); }
.lab-notes__body ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.lab-notes__body h4 { margin: 6px 0 0; font-size: 13px; color: var(--ink); }

/* Question box */
.lab-ask {
  display: flex; flex-direction: column; gap: 12px; min-height: 0; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.lab-ask > * { flex-shrink: 0; }
/* When the box scrolls (wide desktop), its header stays at the top, so the widen arrow and Clear
   are always in reach. */
.lab-ov--scroll .lab-ask__head { position: sticky; top: -16px; z-index: 1; margin: -16px -16px 0; padding: 16px 16px 10px; background: var(--surface); border-bottom: 1px solid transparent; }
.lab-ask__head { display: flex; align-items: center; gap: 10px; }
.lab-ask__badge {
  flex: none; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--teal-soft), #e4f0da); color: var(--teal-ink);
}
.lab-ask__badge svg { width: 20px; height: 20px; }
.lab-ask__title { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; }
.lab-ask__sub { font-size: 12.5px; color: var(--ink-2); }
.lab-ask__reset { margin-left: auto; min-height: 32px; padding: 0 10px; font-size: 12.5px; }
.lab-ask__reset[hidden] + .lab-ask__widen { margin-left: auto; }
/* The arrow that widens or narrows the panel; shown only in the wide desktop layout. It points
   left (grow that way) when narrow and right when wide. */
.lab-ask__widen { display: none; flex: none; width: 34px; height: 34px; }
.lab-ask__widen svg { transition: transform .28s; }
.lab-ask__widen[aria-expanded="true"] svg { transform: rotate(180deg); }
.lab-ask__reset[hidden], .lab-ask__intro[hidden] { display: none; }
.lab-ask__intro { padding: 10px 12px; border-radius: 12px; background: var(--surface-sage); font-size: 13.5px; color: var(--ink-2); }
.lab-ask__thread { display: flex; flex-direction: column; gap: 10px; }
.lab-ask__thread:empty { display: none; }
.lab-ask__msg { flex: none; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.lab-ask__msg--q { margin-left: 28px; background: var(--teal-soft); color: var(--teal-ink); border-bottom-right-radius: 4px; }
.lab-ask__msg--a { margin-right: 8px; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.lab-ask__msg--error { margin-right: 8px; background: #fbe6e2; color: #8e2f1f; }
.lab-ask__msg--pending { display: flex; align-items: center; gap: 10px; margin-right: 8px; background: var(--surface-2); border: 1px dashed var(--line-2); color: var(--ink-2); font-size: 13px; }
.lab-ask__who { margin-bottom: 3px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.lab-ask__msg--a .lab-ask__who { color: var(--ink-2); }
.lab-ask__text { white-space: pre-wrap; overflow-wrap: anywhere; }
.lab-ask__dots { display: inline-flex; gap: 4px; flex: none; }
.lab-ask__dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); animation: ask-dot 1.2s ease-in-out infinite; }
.lab-ask__dots i:nth-child(2) { animation-delay: .15s; }
.lab-ask__dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ask-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.lab-ask__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lab-ask__chip {
  min-height: 32px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--teal-ink); font-size: 12.5px; font-weight: 600; line-height: 1.3; text-align: left;
}
.lab-ask__chip:hover { border-color: var(--teal); background: var(--teal-soft); }
.lab-ask__chip[disabled] { opacity: .55; cursor: default; }
.lab-ask__common { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.lab-ask__subhead { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.lab-ask__wait { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.lab-ask__wait .spinner { width: 16px; height: 16px; border-width: 2px; }
.lab-ask__empty { font-size: 13px; color: var(--ink-2); }
.lab-ask__form { display: grid; gap: 6px; }
.lab-ask__label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.lab-ask__row { display: flex; gap: 8px; }
.lab-ask__input { flex: 1; min-width: 0; min-height: 44px; }
.lab-ask__input:disabled { background: var(--surface-2); color: var(--ink-2); }
.lab-ask__send { flex: none; min-height: 44px; }
.lab-ask__fine { font-size: 12px; color: var(--ink-2); }

/* Sites filter (labsites.js): a button that states the choice and opens a checklist. It sits on
   the Overview/PDF row on desktop and at the top of the overview on phones. */
.lab-sites { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.lab-sites[hidden] { display: none; }
.lab-sites__anchor { position: relative; min-width: 0; }
.lab-sites__btn { min-height: 38px; padding: 0 12px; gap: 7px; max-width: 260px; }
.lab-sites__btn > span:not(.lab-sites__caret) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lab-sites__btn svg { width: 16px; height: 16px; flex: none; }
.lab-sites__caret svg { transform: rotate(-90deg); transition: transform .15s; }
.lab-sites__btn[aria-expanded="true"] .lab-sites__caret svg { transform: rotate(90deg); }
.lab-sites.is-filtered .lab-sites__btn { background: var(--teal-soft); border-color: color-mix(in srgb, var(--teal) 45%, transparent); color: var(--teal-ink); }
.lab-sites__pop {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; display: grid; gap: 6px;
  width: min(300px, calc(100vw - 32px)); max-height: min(60vh, 440px); overflow: auto; overscroll-behavior: contain; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-2);
}
.lab-sites__pop[hidden] { display: none; }
.lab-sites__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 4px 6px; border-bottom: 1px solid var(--line); }
.lab-sites__title { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.lab-sites__shortcuts { display: flex; gap: 4px; }
.lab-sites__link { padding: 4px 8px; border: 0; border-radius: 8px; background: none; font-size: 13px; font-weight: 650; color: var(--teal-ink); }
.lab-sites__link:hover { background: var(--teal-soft); }
.lab-sites__group, .lab-sites__list { display: grid; gap: 2px; }
.lab-sites__item { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 4px 8px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.lab-sites__item:hover { background: var(--surface-2); }
.lab-sites__item--all { font-weight: 650; }
.lab-sites__check { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--teal); }
.lab-sites__item.is-missing { color: var(--ink-2); }
.lab-sites__missing { margin-left: auto; font-size: 12px; font-style: italic; color: var(--ink-2); }
.lab-sites__fine { padding: 6px 4px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-2); }
.lab-phone-sites { margin-bottom: 14px; }
/* While the filter is on, the parts it doesn't change say so in one quiet line. */
.lab-filter-note { padding: 6px 10px; border-radius: 8px; background: var(--teal-soft); font-size: 12.5px; color: var(--teal-ink); }
.lab-filter-note[hidden] { display: none; }
.lab-ov__filtered { display: contents; }
.lab-empty { display: grid; justify-items: center; gap: 12px; padding: 40px 16px; text-align: center; font-size: 14px; color: var(--ink-2); }

/* Phones: a bar to get back to the list; each strip's label sits above the strip. */
.lab-list button.action { width: 100%; }
.lab-phone-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.lab-phone-bar__back { padding-left: 8px; }
/* Strip rows stack (label and counts above the strip) when their own card is narrow: on a phone,
   and on a laptop while the questions panel is wide. */
@container (max-width: 640px) {
  .lab-strip-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .lab-strip-row__counts { grid-column: 2; grid-row: 1; justify-items: end; text-align: right; }
  .lab-strip-row__out { justify-content: flex-end; }
  .lab-strip-row .strip-wrap { grid-column: 1 / -1; }
}
@media (max-width: 749px) {
  .lab-trend__chart { height: 340px; }
  .lab-table .lab-table__sample { min-width: 120px; max-width: 160px; }
  .lab-summary { padding: 16px; }
  .lab-summary__lead { font-size: 15.5px; }
}

/* ---- Toast --------------------------------------------------------------- */

.toasts { position: fixed; z-index: 60; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 16px; font-size: 14px; box-shadow: var(--shadow-2); display: flex; gap: 10px; align-items: center; justify-content: space-between; animation: toast-in .25s ease-out; }
.toast a, .toast button { color: #bfe9e3; font-weight: 700; background: none; border: 0; padding: 0; text-decoration: underline; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---- Scene SVG ----------------------------------------------------------- */

.scene text { font-family: var(--font); }
.scene .sway { transform-box: fill-box; transform-origin: 50% 100%; animation: sway var(--sway-dur, 7s) ease-in-out infinite alternate; animation-delay: var(--sway-delay, 0s); }
@keyframes sway { from { transform: rotate(-1.4deg); } to { transform: rotate(1.4deg); } }
.scene .cloud { animation: drift var(--drift, 90s) linear infinite; }
@keyframes drift { from { transform: translateX(-260px); } to { transform: translateX(1460px); } }

.scene .pipe-flow { opacity: 0; transition: opacity .6s; }
.scene .is-flowing .pipe-flow,
.scene .pipe-flow.is-flowing { opacity: 1; animation: pipe-flow .9s linear infinite; }
@keyframes pipe-flow { to { stroke-dashoffset: -36; } }
.scene .inj-flow { opacity: 0; transition: opacity .6s; }
.scene .inj-flow.is-flowing { opacity: 1; animation: pipe-flow 1.3s linear infinite; }

.scene .set-wet { opacity: 0; transition: opacity .8s; }
.scene .set.is-running .set-wet { opacity: 1; animation: wet 3.2s ease-in-out infinite; }
.scene .set.is-running .set-outline { opacity: .9; stroke-dasharray: 10 7; animation: march 1.6s linear infinite; }
@keyframes wet { 50% { opacity: .55; } }
@keyframes march { to { stroke-dashoffset: -34; } }
.scene .drip { opacity: 0; }
.scene .set.is-running .drip { animation: drip var(--drip-dur, 2.4s) ease-in-out infinite; animation-delay: var(--drip-delay, 0s); }
@keyframes drip { 0%, 100% { opacity: 0; transform: translateY(-3px); } 40% { opacity: .95; } 70% { opacity: 0; transform: translateY(2px); } }
.scene .set-label rect { transition: fill .3s; }
.scene .set.is-running .set-label rect { fill: var(--teal); }
.scene .set.is-running .set-label text { fill: #fff; }
.scene .set-label .live { opacity: 0; }
.scene .set.is-running .set-label .live { opacity: 1; animation: blink 1.6s ease-in-out infinite; }
.scene .set.is-hover .set-outline { opacity: 1; }
.scene .set-outline { opacity: 0; transition: opacity .2s; }
@keyframes blink { 50% { opacity: .25; } }

.pump rect, .pump ellipse { transition: fill .4s; }
.pump .stroke { transform-box: fill-box; }
.pump.is-pumping .stroke { animation: pump-stroke .7s ease-in-out infinite alternate; }
@keyframes pump-stroke { from { transform: translateX(0); } to { transform: translateX(-1.6px); } }
.scene .led { transition: fill .4s; }
.scene .tank-node { transition: transform .25s, filter .25s; }
.scene .tank-node.is-hover { filter: drop-shadow(0 0 6px rgba(31, 122, 120, .55)); }

svg.tank .liquid-wave { animation: wave 3.2s linear infinite; }
@keyframes wave { from { transform: translateX(0); } to { transform: translateX(-40px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0s !important; }
  .scene .cloud { display: none; }
}

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .side { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}

@media (max-width: 980px) {
  .login { grid-template-columns: 1fr; }
  .login__art { display: none; }
  .login__card-logo { display: block; }
}

/* The spec's 750 px breakpoint: phone layout */
@media (max-width: 749px) {
  body { font-size: 14.5px; }
  .topbar { flex-wrap: wrap; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .topbar__clock, .topbar__username, .brand__sub { display: none; }
  .brand img { width: 34px; height: 34px; }
  .topbar__site { order: 5; flex-basis: 100%; }
  .select--site, .select--customer { flex: 1 1 0; width: 100%; min-width: 0; max-width: none; }
  /* The demo switch gets its own row under the pickers. */
  .demo-switch { order: 6; flex-basis: 100%; }
  .demo-flag--scene { top: 10px; left: 10px; padding: 3px 10px 3px 7px; font-size: 12px; }
  .page { padding-top: 16px; gap: 16px; }
  .side { grid-template-columns: 1fr; }
  .now { display: none; }
  .stats { display: grid; }
  .tank-card { padding: 14px 8px 12px; }
  .tank-card svg.tank { width: min(96px, 100%); }
  .scene-card__legend { display: none; }
  .dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .dialog__head, .dialog__controls, .dialog__body { padding-left: 16px; padding-right: 16px; }
  .chart { height: 58vh; min-height: 300px; }
}

/* ---- Download usage reports (all fields, one ZIP; panels/summaryzip.js) ------
   The button sits beside the chips on the All fields dashboard; the dialog is small,
   and a sheet at the bottom of the screen on phones instead of the full-screen dialog. */
.page-head__side { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.page-head__tools:empty { display: none; }
.dialog--zip { width: min(520px, calc(100vw - 32px)); }
.zip-dialog { display: grid; gap: 16px; }
.zip-dialog__season .select { flex: 1 1 240px; min-width: 0; max-width: 100%; }
.zip-dialog__summary { color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.zip-dialog__actions { display: flex; justify-content: flex-end; }
@media (max-width: 749px) {
  .page-head__side { justify-content: flex-start; }
  .dialog.dialog--zip { width: 100vw; height: fit-content; max-height: 100dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .dialog--zip .dialog__body { padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .zip-dialog__actions .btn { flex: 1; min-height: 48px; }
}
