/* Mikvah dashboard v3 — plain CSS, RTL, mobile-first. "Calm instrument panel" (UX review 2026-11-12):
   white cards with a 1 px border (shadows vanish in sunlight), status = colour + icon + word + 4 px stripe,
   numbers stay ink when OK, 4-pt spacing, radius 12, Heebo with tabular numerals. */
:root {
  --bg: #EEF1F4;
  --card: #FFFFFF;
  --soft: #F7F9FA;
  --ink: #15212C;
  --ink-2: #3A4754;
  --muted: #4A5866;
  --line: #DDE2E7;
  --line-2: #EEF1F4;
  --border: #B9C3CC;
  --accent: #0B6470;
  --accent-dark: #084A53;
  --accent-soft: #E2EEF0;
  --ok: #1F7A4D;
  --ok-ink: #155C39;
  --ok-soft: #E3F2EA;
  --warn: #B26A00;
  --warn-ink: #8A4B00;
  --warn-soft: #FDF0DC;
  --bad: #B42318;
  --bad-ink: #9B1C12;
  --bad-soft: #FBE7E5;
  --stale-ink: #5F6B78;
  --stale-soft: #E9EDF1;
  --acid: #B7791F;
  --radius: 12px;
  --header: 56px;
  --tabbar: 56px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
button, input { font-family: inherit; font-size: inherit; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.c-ok { color: var(--ok-ink); }
.c-warn { color: var(--warn-ink); }
.c-bad { color: var(--bad-ink); }
.c-accent { color: var(--accent); }
.c-mute { color: var(--stale-ink); }

.skip {
  position: absolute; inset-inline-start: 8px; top: -60px;
  background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 60;
}
.skip:focus { top: 8px; }

/* ---------------------------------------------------------------- header (56 px, one row) */
.top {
  position: sticky; top: 0; z-index: 30;
  height: var(--header);
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { margin: 0; font-size: 18px; font-weight: 800; white-space: nowrap; }
.brand a { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.conn {
  flex: 1 1 auto; min-width: 0;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.conn .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--stale-ink); }
.conn-ok { color: var(--ok-ink); } .conn-ok .dot { background: var(--ok); }
.conn-warn { color: var(--warn-ink); } .conn-warn .dot { background: var(--warn); border-radius: 2px; }
.conn-bad { color: var(--bad-ink); } .conn-bad .dot { background: var(--bad); border-radius: 2px; transform: rotate(45deg); }

.icon-btn {
  flex: none; min-width: 44px; min-height: 44px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.icon-btn svg, .tab svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-btn .lbl { display: none; }
.icon-btn.btn-stop { background: var(--bad); border-color: var(--bad); color: #fff; }
.icon-btn.btn-stop:disabled { background: #C98B85; border-color: #C98B85; }
.icon-btn:disabled { cursor: not-allowed; }
@media (min-width: 480px) { #stopBtn .lbl { display: inline; } }
@media (min-width: 900px) { .icon-btn .lbl { display: inline; } }
@media (max-width: 899px) { .hide-phone, #userPill { display: none !important; } }

/* ---------------------------------------------------------------- tabs: bottom bar on phones, header on desktop */
.tabs {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 44px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
  border-top: 3px solid transparent;
}
.tab[aria-current=page] { color: var(--accent); font-weight: 700; border-top-color: var(--accent); }
@media (min-width: 900px) {
  .tabs {
    position: static; height: auto; padding: 0; border: none; background: none;
    display: flex; gap: 4px; margin-inline: 8px;
  }
  .tab { flex-direction: row; gap: 6px; padding: 0 12px; border-radius: 10px; border: none; font-size: 15px; }
  .tab[aria-current=page] { background: var(--accent-soft); }
  .top { padding: 0 20px; }
}

/* ---------------------------------------------------------------- page */
.wrap {
  max-width: 1360px; margin: 0 auto;
  padding: 8px 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 24px);
  display: flex; flex-direction: column; gap: 12px;
}
@media (min-width: 900px) { .wrap { padding: 16px 20px 40px; gap: 16px; } }
.main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.view { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
@media (max-width: 699px) { #view-now { gap: 6px; } .pits { gap: 6px !important; } .pit .m-value { font-size: 24px; } }
@media (min-width: 900px) { .view { gap: 16px; } }
.view-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.view-head h2 { margin: 0; font-size: 20px; font-weight: 700; }
.back { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; font-weight: 500; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  min-width: 0; display: flex; flex-direction: column; gap: 12px;
}
.card h2 { margin: 0; font-size: 20px; font-weight: 700; }
.h3 { margin: 0; font-size: 16px; font-weight: 700; }
.card p { margin: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 12px; }
@media (min-width: 900px) { .grid2 { gap: 16px; } }
.note { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--stale-soft); font-size: 14px; color: var(--ink-2); }
.note-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.err { margin: 0; color: var(--bad-ink); background: var(--bad-soft); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.foot { text-align: center; overflow-wrap: anywhere; margin: 0; }
.soon-line { text-align: center; margin: 4px 0 0; }

/* ---------------------------------------------------------------- buttons */
.btn {
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; text-align: center;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, .sw:focus-visible, input:focus-visible, summary:focus-visible, .tab:focus-visible, .pit-head:focus-visible, .seg-btn:focus-visible, .step-btn:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--border); font-weight: 500; }
.btn-ghost:hover:not(:disabled) { background: var(--soft); }
.btn-outline { background: #fff; color: var(--accent); border-color: var(--accent); }
.btn-stop { background: var(--bad); color: #fff; }
.btn-light { background: #fff; color: var(--bad-ink); border-color: #F2C4BF; }
.link-btn {
  align-self: flex-start; min-height: 44px; margin: -8px 0; padding: 0 4px; border: none; background: none;
  color: var(--accent); font-weight: 700; font-size: 14px; cursor: pointer;
}
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg-btn {
  min-height: 44px; padding: 0 14px; border-radius: 10px; font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--ink);
}
.seg-btn[aria-pressed=true] { border-color: var(--ink); background: var(--ink); color: #fff; font-weight: 700; }
.pit-seg .seg-btn { flex: 1 1 0; }
@media (min-width: 700px) { .pit-seg .seg-btn { flex: 0 0 auto; } }

/* ---------------------------------------------------------------- pills, badges, icons */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.pill-neutral { background: var(--stale-soft); color: var(--ink-2); }
.pill-warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.badge {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge-ok { color: var(--ok-ink); background: var(--ok-soft); }
.badge-warn { color: var(--warn-ink); background: var(--warn-soft); }
.badge-bad { color: var(--bad-ink); background: var(--bad-soft); }
.badge-stale, .badge-unknown { color: var(--stale-ink); background: var(--stale-soft); }
.ico { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico .fill { fill: currentColor; stroke: none; }
.ico .knock { stroke: #fff; }
.ico-ok { color: var(--ok); } .ico-warn { color: var(--warn-ink); } .ico-bad { color: var(--bad); }
.ico-stale, .ico-unknown { color: var(--stale-ink); }
.badge .ico { color: currentColor; }

/* ---------------------------------------------------------------- emergency stop banner, toast */
.estop {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius); background: var(--bad-soft); color: var(--bad-ink);
  border: 1px solid #F2C4BF; border-inline-start: 4px solid var(--bad);
}
.estop strong { font-size: 16px; }
.estop p { margin: 2px 0 0; font-size: 14px; }
.toast {
  position: fixed; inset-inline: 16px; z-index: 40; max-width: 720px; margin-inline: auto;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px);
  padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 15px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(21, 33, 44, 0.18);
}
@media (min-width: 900px) { .toast { bottom: 16px; } }
.toast.ok { background: var(--ok-ink); }
.toast.bad { background: var(--bad-ink); }

/* ---------------------------------------------------------------- login */
.login { max-width: 560px; }
.google-row { margin: 0 0 12px; }
.google-btn { min-height: 44px; max-width: 320px; display: flex; justify-content: flex-start; overflow: hidden; }
.google-btn svg { width: 18px; height: 18px; } /* if Google's styles fail, the logo stays small */
/* Not logged in: only the login card (owner 2026-11-12: "the first page shows nothing, only the login"). */
body.locked #tabs, body.locked #connPill, body.locked #stopBtn, body.locked #estopBanner, body.locked #userPill,
body.locked #unlockBtn, body.locked #logoutBtn, body.locked .view, body.locked #bottomNav { display: none !important; }
body.locked .login { margin: 6vh auto 0; }
.google-row .or-line { margin-top: 12px; }
#googleMsg.err { color: var(--bad, #A4161A); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 14px; font-weight: 500; }
.hint { font-size: 13px; color: var(--muted); }
input[type=text], input[type=password] {
  min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 16px; background: #fff; color: var(--ink); width: 100%;
}
input:disabled { background: var(--soft); color: var(--ink-2); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; flex: none; }

/* ---------------------------------------------------------------- home: verdict, alerts */
.verdict {
  display: flex; align-items: center; gap: 8px; line-height: 1.3;
  padding: 7px 12px; border-radius: var(--radius); font-size: 16px; font-weight: 700;
  background: var(--card); border: 1px solid var(--line); border-inline-start: 4px solid var(--stale-ink);
}
.verdict-ok { border-inline-start-color: var(--ok); }
.verdict-warn { border-inline-start-color: var(--warn); }
.verdict-bad { border-inline-start-color: var(--bad); background: var(--bad-soft); color: var(--bad-ink); }
.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.alert {
  display: flex; align-items: center; gap: 8px; line-height: 1.25;
  padding: 5px 10px; border-radius: 10px; background: var(--card); border: 1px solid var(--line);
  border-inline-start: 4px solid var(--warn);
}
.alert-bad { border-inline-start-color: var(--bad); }
.alert-body { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; column-gap: 8px; align-items: baseline; }
.alert-text { font-size: 14px; font-weight: 500; }
.alert-act { font-size: 12px; color: var(--muted); }
@media (max-width: 699px) { .alert-act { flex-basis: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }
.alert-time { flex: none; font-size: 12px; color: var(--muted); }
.alert-empty { list-style: none; color: var(--muted); font-size: 14px; padding: 4px 0; }

/* ---------------------------------------------------------------- home: pit cards */
.pits { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 700px) { .pits { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
@media (min-width: 1200px) { .pits { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
.pit {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  border-inline-start: 4px solid var(--stale-ink);
  padding: 0 12px 8px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
@media (max-width: 699px) { .pit { padding-bottom: 6px; gap: 3px; } }
.pit.st-ok { border-inline-start-color: var(--ok); }
.pit.st-warn { border-inline-start-color: var(--warn); }
.pit.st-bad { border-inline-start-color: var(--bad); }
.pit-head {
  display: flex; align-items: center; gap: 8px; min-height: 44px;
  color: var(--ink); text-decoration: none; border-radius: 8px;
}
.pit-title { margin: 0; font-size: 18px; font-weight: 800; white-space: nowrap; }
.pit-head .pr-state { flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pit-head .chev { color: var(--muted); }
.pit-vals { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.metric { display: flex; flex-direction: column; min-width: 0; }
.m-label { font-size: 12px; font-weight: 500; color: var(--muted); align-self: flex-start; margin-top: 2px; }
.m-target { font-size: 11px; color: var(--muted); white-space: nowrap; }
.m-target:empty { display: none; }
@media (max-width: 899px) { .pit .m-target { display: none; } }
.m-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.m-value { font-size: 26px; font-weight: 800; line-height: 1.1; color: var(--ink); white-space: nowrap; }
@media (max-width: 359px) { .pit .m-value { font-size: 22px; } .pit .spark-box { display: none; } }
@media (min-width: 900px) { .pit .m-row { flex-wrap: wrap; } .pit .spark-box { flex-basis: 100%; margin: 2px 0 0; } }
.mx-temp .m-value { font-size: 18px; font-weight: 700; line-height: 1.6; }
.trend { font-size: 15px; font-weight: 700; color: var(--ink-2); }
.trend:empty { display: none; }
.spark-box { margin-inline-start: auto; display: inline-flex; line-height: 0; }
.m-age { font-size: 11px; color: var(--muted); }
.m-age:empty { display: none; }
.metric.st-warn .m-value { color: var(--warn-ink); }
.metric.st-bad .m-value { color: var(--bad-ink); }
.metric.st-stale .m-value { color: var(--stale-ink); text-decoration: underline dashed 1px; text-underline-offset: 4px; }
.metric.st-bad .m-age { color: var(--bad-ink); font-weight: 500; }
.pit-foot { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-2); min-width: 0; }
.pr-filter { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; flex: none; }
.meter { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.meter-txt { display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; }
.meter-label { color: var(--muted); }
.meter-num { font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.meter-bar { height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter-fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; }
.meter.hi .meter-fill { background: var(--warn); }
.pit-why { margin: 0; font-size: 12px; font-weight: 500; line-height: 1.3; }
.pit-note { margin: 0; font-size: 12px; color: var(--ink-2); }
.supplies { display: flex; flex-wrap: wrap; gap: 6px; }
.sup {
  flex: 1 1 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0;
  padding: 5px 8px; border-radius: 10px; background: var(--card); border: 1px solid var(--line);
}
.sup .badge { max-width: 100%; white-space: normal; }
.sup-name { font-size: 12px; font-weight: 500; color: var(--muted); }
@media (min-width: 700px) {
  .supplies { display: flex; flex-wrap: wrap; }
  .sup { flex-direction: row; align-items: center; gap: 6px; padding: 6px 10px; }
  .sup-name { font-size: 13px; color: var(--ink); }
}
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.chip-neutral { background: var(--stale-soft); color: var(--stale-ink); }

/* sparklines */
.spark { display: block; overflow: visible; }
.spark-band { fill: rgba(31, 122, 77, 0.14); }
.spark-line { fill: none; stroke: var(--ink-2); stroke-width: 1.5; stroke-linejoin: round; }
.spark-dot { fill: var(--ink-2); }
.spark-last { fill: var(--ink); }
.spark-empty { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 3; }
.spark-bg { fill: #F4F6F8; }
.spark-empty-txt { font-size: 10px; fill: var(--muted); font-family: 'Heebo', system-ui, sans-serif; }

/* ---------------------------------------------------------------- pit detail */
.pd-values { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pd-v { display: flex; flex-direction: column; min-width: 0; }
.pd-num { font-size: 32px; font-weight: 800; line-height: 1.15; }
.pd-num.small-num { font-size: 22px; line-height: 1.6; }
.pd-v.st-warn .m-value { color: var(--warn-ink); }
.pd-v.st-bad .m-value { color: var(--bad-ink); }
.pd-v.st-stale .m-value { color: var(--stale-ink); }
.kv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.kv-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.kv-list li:last-child { border-bottom: none; }
.kv-list .pv { font-weight: 700; text-align: left; }
#pdMeters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; font-size: 13px; }
.pd-lab { display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline; }
#pdMeters .meter-bar { height: 6px; }
.badge.pit-badge { font-size: 12px; }
#pdBadge:empty { display: none; }

/* ---------------------------------------------------------------- history */
.hist-state { margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; background: var(--stale-soft); color: var(--ink-2); }
.hs-bad { background: var(--bad-soft); color: var(--bad-ink); }
.hs-warn { background: var(--warn-soft); color: var(--warn-ink); }
.hs-ok { background: var(--ok-soft); color: var(--ok-ink); }
.hs-link { font-weight: 700; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 8px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.kpi-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.kpi-value { font-size: 26px; font-weight: 800; line-height: 1.15; }
.kpi-sub { font-size: 12px; color: var(--ink-2); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 4px; vertical-align: -1px; }
.key-cl { background: var(--accent); }
.key-acid { background: var(--acid); }
.chart-box { min-width: 0; }
.ch-wrap { width: 100%; }
.ch { display: block; width: 100%; touch-action: pan-y; }
.ch-readout { font-size: 13px; color: var(--ink-2); min-height: 20px; margin-bottom: 4px; }
.ch-stats { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.ch-bg { fill: #FAFBFC; }
.ch-grid { stroke: #E4E8EC; stroke-width: 1; }
.ch-tick { font-size: 10px; fill: var(--muted); font-family: 'Heebo', system-ui, sans-serif; }
.ch-label { font-size: 11px; font-weight: 700; fill: var(--ink-2); font-family: 'Heebo', system-ui, sans-serif; }
.ch-empty { font-size: 12px; fill: var(--muted); font-family: 'Heebo', system-ui, sans-serif; }
.ch-band { fill: rgba(31, 122, 77, 0.13); }
.ch-limit { stroke: var(--bad-ink); stroke-width: 1; stroke-dasharray: 4 3; }
.ch-sp { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 3; }
.ch-shade { fill: rgba(95, 107, 120, 0.14); }
.ch-line { fill: none; stroke: var(--ink-2); stroke-width: 1.8; stroke-linejoin: round; }
.ch-line.c-ph, .ch-line.c-cl { stroke: var(--accent); }
.ch-line.c-orp { stroke: #3A4754; }
.ch-line.c-acid { stroke: var(--acid); }
.ch-line.c-temp { stroke: var(--warn-ink); }
.ch-area { stroke: none; fill: rgba(11, 100, 112, 0.14); }
.ch-area.c-acid { fill: rgba(183, 121, 31, 0.18); }
.ch-dot { fill: var(--ink-2); }
.ch-cross { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 2; }
.ch-cross-dot { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.ch-bar { fill: var(--accent); }
.ch-bar2, .ch-bar.c-acid { fill: var(--acid); }
.ch-bar-g.dim rect:not(.ch-hit) { opacity: 0.35; }
.ch-bar-g:focus { outline: none; }
.ch-bar-g:focus .ch-hit { fill: rgba(11, 100, 112, 0.08); }
.ch-hit { fill: transparent; }
.ch-mark { fill: var(--bad-ink); }
.ch-range { stroke: var(--ink-2); stroke-width: 3; stroke-linecap: round; }
.ch-range-dot { fill: var(--accent); }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: 56px minmax(0, 1fr) 84px; align-items: center; gap: 8px; font-size: 14px; }
.hbar-name { font-weight: 500; }
.hbar-track { height: 14px; border-radius: 4px; background: var(--line-2); overflow: hidden; display: block; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.hbar-val { text-align: left; font-weight: 700; }
.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ev { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.ev-text { flex: 1 1 auto; min-width: 0; }
.ev-time { font-size: 12px; color: var(--muted); }
.ev-day { list-style: none; font-size: 12px; font-weight: 700; color: var(--muted); padding: 10px 0 2px; }

/* ---------------------------------------------------------------- settings */
.set-groups { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.set-group { border: 1px solid var(--line); border-radius: 10px; }
.set-group > summary {
  min-height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  font-size: 16px; font-weight: 700; cursor: pointer; list-style: none;
}
.set-group > summary::-webkit-details-marker { display: none; }
.set-group > summary::after {
  content: ''; margin-inline-start: auto; width: 8px; height: 8px;
  border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); margin-top: -4px;
}
.set-group[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.sg-note { font-size: 12px; font-weight: 500; color: var(--muted); }
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 16px; padding: 4px 12px 14px; margin: 0; }
.set-grid.one { grid-template-columns: 1fr; padding: 0; }
.set-plain-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; padding: 4px 12px 14px; }
.set-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.set-field label { font-size: 14px; font-weight: 500; }
.set-plain { font-size: 20px; font-weight: 700; }
.set-line { display: flex; align-items: center; gap: 8px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.step-btn {
  width: 44px; height: 44px; flex: none; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; color: var(--ink); font-size: 22px; font-weight: 700; line-height: 1; cursor: pointer;
}
.step-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.stepper input { width: 104px; text-align: center; font-size: 22px; font-weight: 700; padding: 0 6px; }
.set-unit { font-size: 13px; color: var(--muted); }
.set-hint { display: none; font-size: 12px; color: var(--muted); }
.set-field:focus-within .set-hint, .set-field.has-error .set-hint { display: block; }
.set-field.is-dirty input { border-color: var(--warn-ink); background: #FFFBF3; }
.set-field input[aria-invalid=true] { border-color: var(--bad-ink); }
.set-status { font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.set-status:empty { display: none; }
.set-status.st-dirty { color: var(--warn-ink); }
.set-status.st-dirty::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.set-status.st-pending { color: var(--accent); }
.set-status.st-pending::before {
  content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.set-status.st-ok { color: var(--ok-ink); }
.set-status.st-ok::before { content: '✓'; font-weight: 800; }
.set-status.st-fail { color: var(--bad-ink); }
.set-status.st-fail::before { content: '×'; font-weight: 800; font-size: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.save-bar {
  position: sticky; z-index: 20; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 8px);
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; padding-inline-start: 16px;
  border-radius: 12px; background: var(--ink); color: #fff; box-shadow: 0 6px 20px rgba(21, 33, 44, 0.25);
}
@media (min-width: 900px) { .save-bar { bottom: 16px; } }
.save-count { flex: 1 1 auto; font-size: 15px; font-weight: 700; }
.save-bar .btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.5); }

/* On/off rows (switch rows, relays, inputs) */
.io {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px; border-radius: 10px; background: var(--soft); min-height: 56px;
}
.io-text { display: flex; flex-direction: column; min-width: 0; }
.io-name { font-weight: 500; }
.io-state { font-size: 13px; color: var(--muted); }
.io.on .io-state { color: var(--ok-ink); font-weight: 700; }
.io.unknown .io-state { color: var(--stale-ink); }
.io-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 8px; }
.sw { position: relative; flex: none; width: 56px; height: 44px; border: none; background: transparent; cursor: pointer; padding: 0; }
.sw::before { content: ''; position: absolute; inset: 8px 0; border-radius: 999px; background: #C9D1D8; transition: background 0.15s; }
.sw::after {
  content: ''; position: absolute; top: 11px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: inset-inline-start 0.15s;
}
.sw[aria-pressed=true]::before { background: var(--ok); }
.sw[aria-pressed=true]::after { inset-inline-start: 31px; }
.sw.pending::before { background: #CFE3E6; }
.sw:disabled { cursor: not-allowed; opacity: 0.55; }

/* Key/value list (controller) */
.kv { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- dialogs */
dialog {
  border: none; border-radius: 16px; padding: 0; max-width: min(92vw, 520px); width: 100%;
  box-shadow: 0 12px 40px rgba(21, 33, 44, 0.25); color: var(--ink);
}
dialog::backdrop { background: rgba(21, 33, 44, 0.45); }
.dlg { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg h2 { margin: 0; font-size: 20px; }
.dlg p { margin: 0; }
@media (max-width: 599px) {
  dialog.sheet { margin: auto 0 0; max-width: 100%; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.review-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.review-item { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 8px 10px; border-radius: 10px; background: var(--soft); font-size: 14px; }
.review-item.risky { background: var(--warn-soft); }
.review-name { font-weight: 500; }
.review-chg { font-weight: 800; }
.review-risk { flex-basis: 100%; font-size: 12px; color: var(--warn-ink); font-weight: 500; }
.review-warn { font-size: 14px; color: var(--warn-ink); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .sw::before, .sw::after { transition: none; }
  .set-status.st-pending::before { animation: none; }
}

/* ================================================================ v3.1 — review round 2 + owner feedback */

/* "בטיפול" (being corrected) and "מידע" (e.g. dosing off): neither green nor amber. */
.badge-treat { color: #0A5560; background: #DCEEF1; }
.badge-info { color: #34506B; background: #E6EDF4; }
.ico-treat { color: var(--accent); } .ico-info { color: #34506B; }
.pit.st-treat { border-inline-start-color: var(--accent); }
.pit.st-info { border-inline-start-color: #6F8AA3; }
.verdict-treat { border-inline-start-color: var(--accent); }
.verdict-info { border-inline-start-color: #6F8AA3; }
.verdict-unknown { border-inline-start-color: var(--stale-ink); }

/* Last values while the controller is offline */
.meter.stale .meter-fill { background: var(--stale-ink); opacity: 0.5; }
.meter.stale .meter-num { color: var(--stale-ink); }
#setForm.is-stale input, #setForm.is-stale .set-plain { color: var(--stale-ink); }
.note-stale { background: var(--warn-soft); color: var(--warn-ink); }

/* Header: viewer / control state visible on phones; short e-stop label under 480 px */
.mode { display: none; }
.icon-btn .lbl-short { display: none; }
@media (max-width: 899px) {
  .mode-btn { flex-direction: column; gap: 0; padding: 2px 6px; }
  .mode-btn svg { width: 18px; height: 18px; }
  .mode { display: block; font-size: 10px; font-weight: 700; line-height: 1.1; }
  #unlockBtn .mode { color: var(--ink-2); }
  #logoutBtn .mode { color: var(--accent); }
  #logoutBtn { border-color: var(--accent); }
}
@media (max-width: 479px) { #stopBtn .lbl-short { display: inline; } }
@media (max-width: 359px) { .brand { display: none; } }
.t-label { display: none; }

/* The toast never covers the save bar */
body.has-savebar .toast { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 80px); }
@media (min-width: 900px) { body.has-savebar .toast { bottom: 88px; } }

/* The review sheet carries its own e-stop (the header one is behind the modal) */
.review-stop { width: 100%; margin-top: 4px; }

.spark-note { margin: 0; }
.ch-vgrid { stroke: #EEF1F4; }
@media (max-width: 1099px) { #nowChartCard { display: none; } }

/* ---------------------------------------------------------------- desktop home (≥1100 px) */
@media (min-width: 1100px) {
  #view-now {
    display: grid; align-items: start; column-gap: 20px; row-gap: 10px;
    grid-template-columns: minmax(0, 3fr) minmax(340px, 2fr);
    grid-template-areas: "pits verdict" "pits alerts" "pits more" "pits chart" "supplies chart";
    grid-template-rows: auto auto auto 1fr auto;
  }
  #verdict { grid-area: verdict; }
  #alertList { grid-area: alerts; }
  #alertMore { grid-area: more; margin: -4px 0; }
  #pits { grid-area: pits; align-self: stretch; grid-auto-rows: 1fr; }
  .pit-foot { margin-top: auto; }
  .top { padding-inline: max(20px, calc((100% - 1640px) / 2)); }
  #view-now .supplies { grid-area: supplies; flex-direction: row; flex-wrap: wrap; gap: 8px; }
  #nowChartCard { grid-area: chart; align-self: stretch; }
  #nowChartCard.empty { align-self: start; }
  #view-now .sup { flex: 0 0 auto; flex-direction: row; align-items: center; gap: 10px; min-height: 44px; padding: 6px 14px; }
  #view-now .sup-name { font-size: 14px; color: var(--ink); }
  .now-seg .seg-btn { min-width: 64px; }

  /* 2×2 large pit cards */
  #pits.pits { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .pit { padding: 4px 18px 16px; gap: 10px; }
  .pit-head { flex-wrap: wrap; row-gap: 0; min-height: 52px; }
  .pit-title { font-size: 22px; }
  .pit-head .pr-state { order: 5; flex-basis: 100%; white-space: normal; overflow: visible; font-size: 14px; font-weight: 500; color: var(--ink-2); padding-bottom: 2px; }
  .pit-vals { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(72px, auto); gap: 16px; }
  .pit .metric { display: grid; grid-template-columns: auto 1fr; column-gap: 6px; align-items: baseline; }
  .pit .m-row { display: contents; }
  .pit .m-label { grid-column: 1; grid-row: 1; margin: 0; }
  .pit .m-target { grid-column: 2; grid-row: 1; display: block; }
  .pit .m-target:empty { display: none; }
  .pit .m-value { grid-column: 1 / -1; grid-row: 2; font-size: 36px; line-height: 1.15; }
  .pit .trend { grid-column: 2; grid-row: 2; justify-self: end; font-size: 18px; }
  .pit .spark-box { grid-column: 1 / -1; grid-row: 3; margin: 4px 0 0; flex-basis: auto; }
  .pit .m-age { grid-column: 1 / -1; grid-row: 4; }
  .pit .mx-temp .t-label { display: inline; }
  .pit .mx-temp .m-value { font-size: 24px; line-height: 1.5; }
  .pit-foot { font-size: 13px; gap: 16px; }
  .meter-bar { height: 6px; }
  .pit-why { font-size: 14px; }

  /* secondary text: darker and at least 13 px */
  .m-label, .m-target, .m-age, .meter-label, .alert-act, .alert-time, .sup-name, .kpi-label, .kpi-sub,
  .set-hint, .ch-readout, .ch-stats, .muted, .small, .io-state, .hint { font-size: 13px; color: var(--ink-2); }
  .alert-text { font-size: 15px; }
  .verdict { font-size: 17px; padding: 10px 14px; }
}
@media (min-width: 1600px) { .wrap { max-width: 1680px; } }
