/* Grow — the new overview. Self-contained: shares nothing with style.css. */

:root {
  --bg: #08090d;
  --bg-2: #0d0f15;
  --surface: #12141c;
  --surface-2: #181b25;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #eef1f6;
  --text-2: #b8bfcc;
  --muted: #7b8496;
  --faint: #4b5262;

  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --water: #60a5fa;
  --night: #a78bfa;

  --veg: #34d399;
  --stretch: #a78bfa;
  --bulk: #fbbf24;
  --finish: #fb7185;
  --empty: #64748b;

  --r-xl: 22px;
  --r-lg: 16px;
  --r-md: 12px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 40px -24px rgba(0, 0, 0, 0.8);
  --num: "Space Grotesk", "Inter", system-ui, sans-serif;
  color-scheme: dark;
}
[data-theme="light"] {
  /* Soft light: blue-grey paper instead of white, so it does not glare,
     with the same blue / green / amber / violet as the dark theme. */
  --bg: #e6ebf2;
  --bg-2: #dde3ec;
  --surface: #f1f4f8;
  --surface-2: #e9eef5;
  --line: rgba(32, 56, 96, 0.10);
  --line-2: rgba(32, 56, 96, 0.18);
  --text: #18212f;
  --text-2: #364357;
  --muted: #5d6a7e;
  --faint: #8d99ab;
  --good: #0f9f6e;
  --warn: #c7790a;
  --bad: #d23c3c;
  --water: #2f6fd6;
  --night: #7353d6;
  --veg: #0f9f6e;
  --stretch: #7353d6;
  --bulk: #c7790a;
  --finish: #cf3f68;
  --empty: #7a8699;
  --shadow: 0 1px 2px rgba(24, 33, 47, 0.05), 0 10px 26px -18px rgba(24, 33, 47, 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* ===== Navigation: a rail on the left, a tab bar on phones ===== */
.nav {
  position: fixed; inset: 0 auto 0 0;
  width: 84px;
  display: flex; flex-direction: column; align-items: center;
  gap: 4px;
  padding: 16px 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  z-index: 20;
}
.nav-logo img { width: 40px; height: 40px; border-radius: 12px; display: block; margin-bottom: 14px; }
.nav-item {
  width: 68px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 0 8px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 11px; font-weight: 500;
  background: none; border: 0; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item:hover { color: var(--text); background: var(--surface); }
.nav-item.active { color: var(--text); background: var(--surface-2); }
.nav-item.active svg { color: var(--water); }
.nav-spacer { flex: 1; }

/* ===== Page: on a computer the whole farm fits one screen ===== */
.page {
  margin-left: 84px;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 14px 18px 12px;
  gap: 10px;
}
.head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  flex: 0 0 auto;
}
.head-left { display: flex; align-items: baseline; gap: 14px; }
.head h1 { margin: 0; font: 700 22px/1.1 var(--num); letter-spacing: -0.03em; }
.head-kicker { color: var(--muted); font-size: 13px; font-weight: 500; }
.head-stats { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stat {
  display: flex; align-items: baseline; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 6px 13px;
}
.stat-v { font: 600 16px/1 var(--num); letter-spacing: -0.02em; }
.stat-v small { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-l { color: var(--muted); font-size: 12px; }
.stat.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); cursor: pointer; }
.stat.bad .stat-v { color: var(--bad); }

.rooms {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  gap: 8px;
}
.loading { color: var(--muted); padding: 40px 0; }
.foot { display: none; }

/* ===== One room = one row ===== */
.room {
  --accent: var(--water);
  flex: 1 1 0; min-height: 132px;
  display: grid;
  grid-template-columns: 210px minmax(220px, 0.9fr) minmax(0, 3.6fr) minmax(130px, 0.62fr);
  gap: 10px;
  padding: 10px 10px 10px 16px;
  position: relative;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 11%, transparent), transparent 32%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.room::before {
  content: ""; position: absolute; left: 6px; top: 12px; bottom: 12px;
  width: 4px; border-radius: 99px; background: var(--accent);
}
/* One accent for every room: blue (grower's choice). */

/* column 1: who / what / lights / equipment */
.r-info { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.r-name-row { display: flex; align-items: center; gap: 8px; }
.room-name { font: 700 20px/1 var(--num); letter-spacing: -0.03em; white-space: nowrap; }
.r-name-row .icon-btn { margin-left: auto; }
.r-stage { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 99px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}
.dayline { color: var(--muted); font-size: 12px; white-space: nowrap; }
.dayline b { color: var(--text); font-weight: 600; }
.lights { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.lights b { color: var(--text); font-weight: 600; }
.lights .li { font-size: 12px; width: 18px; text-align: center; }
.equip { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }
.first-night { display: flex; align-items: center; gap: 5px; color: var(--water); font-size: 12px; font-weight: 500; margin: 2px 0 6px; cursor: help; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 3px 9px;
  font-size: 11.5px; color: var(--text-2);
  white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.dot.bad { background: var(--bad); }
.icon-btn {
  font-size: 11.5px; font-weight: 600; color: var(--text-2);
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 9px; padding: 3px 9px; cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }

/* column 2: climate gauges */
.climate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; min-width: 0; }
.gauge {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px 4px 5px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; min-width: 0;
}
.gauge svg { width: 100%; max-width: 92px; height: auto; display: block; overflow: visible; }
.g-track { stroke: var(--line-2); }
.g-band  { stroke: color-mix(in srgb, var(--good) 45%, transparent); }
.g-dot   { stroke: var(--surface-2); stroke-width: 3; }
.g-num { margin-top: -30px; text-align: center; font: 600 18px/1 var(--num); letter-spacing: -0.03em; }
.g-num small { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 1px; }
.g-lbl { font-size: 11px; color: var(--muted); margin-top: 9px; white-space: nowrap; }
.g-tgt { font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.gauge.off .g-num { color: var(--warn); }
.gauge.na  .g-num { color: var(--faint); }

/* column 3: the 4 tables */
.tables { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; min-width: 0; }
.tile {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 7px 10px 6px;
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.tile:hover { border-color: var(--line-2); background: color-mix(in srgb, var(--text) 3%, var(--surface-2)); }
.tile-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.tile-top .ph { justify-self: end; }
.tile-id { font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.ph {
  font-size: 10px; font-weight: 700; letter-spacing: .03em;
  padding: 1px 7px; border-radius: 99px;
  background: var(--line); color: var(--muted);
}
.ph-P0 { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.ph-P1 { background: color-mix(in srgb, var(--water) 18%, transparent); color: var(--water); }
.ph-P2 { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.ph-P3 { background: color-mix(in srgb, var(--night) 18%, transparent); color: var(--night); }
.tile-mid { display: flex; align-items: flex-end; gap: 8px; flex: 1; min-height: 0; }
.tile-vwc { font: 600 24px/1 var(--num); letter-spacing: -0.03em; white-space: nowrap; }
.tile-vwc small { font-size: 12px; color: var(--muted); font-weight: 500; }
.spark { flex: 1; min-width: 0; height: 100%; max-height: 64px; min-height: 26px; display: block; margin-top: 4px; }
.spark path.l { fill: none; stroke: var(--water); stroke-width: 1.6; }
.spark path.a { fill: color-mix(in srgb, var(--water) 14%, transparent); stroke: none; }
/* FC line in the small chart: bright enough to read at a glance. */
.spark line { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 4 3; opacity: .9; }
.spark line.edge { stroke: var(--warn); opacity: .75; }
.tile-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); gap: 4px; margin-top: 4px; white-space: nowrap; }
.tile-meta b { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-meta .hi { color: var(--warn); }
.tile.offline { cursor: default; opacity: .5; }
.tile.offline .tile-mid { align-items: center; justify-content: center; color: var(--faint); font-size: 12px; }
.no-sensors {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--muted); font-size: 12.5px;
  border: 1px dashed var(--line-2); border-radius: 14px;
  padding: 10px 14px;
}

/* column 4: the room's water tank */
.tank {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 7px 11px;
  display: flex; flex-direction: column; justify-content: space-between;
  min-width: 0; position: relative; overflow: hidden;
  cursor: pointer;
}
.tank:hover { border-color: var(--line-2); }
/* needs mixing today (server/tank_forecast.py) - the same plan as the Feed page */
@keyframes tank-need { 0%, 100% { box-shadow: 0 0 0 0 transparent; }
                       50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 60%, transparent); } }
@keyframes tank-blink { 50% { opacity: .3; } }
.tank.need { border-color: var(--warn); animation: tank-need 1.2s ease-in-out infinite; }
.tank-mix { font-size: 11px; font-weight: 700; color: var(--warn); margin-top: 3px; animation: tank-blink 1.2s ease-in-out infinite; }
.tank .fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--water) 22%, transparent), color-mix(in srgb, var(--water) 8%, transparent));
  border-top: 1.5px solid color-mix(in srgb, var(--water) 60%, transparent);
  transition: height .5s;
}
.tank.low .fill  { background: color-mix(in srgb, var(--warn) 16%, transparent); border-top-color: var(--warn); }
.tank.crit .fill { background: color-mix(in srgb, var(--bad) 18%, transparent); border-top-color: var(--bad); }
.tank > *:not(.fill) { position: relative; }
.tank-t { font-size: 11.5px; font-weight: 600; color: var(--text-2); display: flex; justify-content: space-between; gap: 6px; }
.tank-pct { font: 600 13px/1 var(--num); color: var(--text); }
.tank-big { font: 600 22px/1 var(--num); letter-spacing: -0.03em; }
.tank-big small { font-size: 11px; color: var(--muted); font-weight: 500; }
.tank-s { font-size: 11px; color: var(--muted); line-height: 1.3; }
.tank-s b { color: var(--text-2); font-weight: 600; }
.tank .first-night { margin: 5px 0 0; font-size: 11px; line-height: 1.25; align-items: flex-start; }
.tank .first-night .ico { margin-top: 1px; flex: 0 0 auto; }

/* ===== Alerts popover list ===== */
.alert-list { display: flex; flex-direction: column; gap: 6px; max-width: 360px; }
.alert-chip {
  font-size: 12.5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 10px;
}

/* ===== Toasts, dialogs, drawer, popover ===== */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--surface); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 12px; padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow);
  transform: translateY(8px); opacity: 0; transition: all .2s; max-width: 360px;
}
.toast.in { transform: none; opacity: 1; }
.toast.ok { border-left: 3px solid var(--good); }
.toast.bad { border-left: 3px solid var(--bad); }

.dlg-back, .drw-back {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(3, 5, 10, 0.55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .2s;
}
.dlg-back { z-index: 80; display: grid; place-items: center; padding: 16px; }
.dlg-back.in, .drw-back.in { opacity: 1; }
.dlg {
  width: min(400px, 100%);
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 18px; padding: 20px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.6);
}
.dlg-title { font: 600 17px/1.3 var(--num); }
.dlg-text { color: var(--text-2); margin-top: 8px; font-size: 13.5px; }
.dlg-input { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.dlg-input input {
  flex: 1; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font: 600 16px var(--num);
}
.dlg-input span { color: var(--muted); }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.btn {
  border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 13px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); cursor: pointer;
}
.btn.primary { background: var(--text); color: var(--bg); border-color: transparent; }
.btn.danger  { background: var(--bad); color: #fff; border-color: transparent; }
.btn.ghost   { background: transparent; }

/* Panels open as a window in the middle of the screen (full screen on phones).
   Centred with grid, not transform, so a full-screen chart inside still
   covers the whole screen. */
.drw-back { display: grid; place-items: center; padding: 3vh 2vw; }
.drw {
  position: relative;
  width: min(940px, 100%); max-height: 94vh;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 22px;
  box-shadow: 0 40px 90px -30px rgba(0,0,0,.7);
  transform: translateY(10px) scale(.98); transition: transform .2s;
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
}
.drw-back.in .drw { transform: none; }
.drw .tp-head { border-radius: 22px 22px 0 0; }
body.no-scroll { overflow: hidden; }

.pop {
  position: fixed; z-index: 90; min-width: 240px; max-width: 320px;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 14px; padding: 6px; box-shadow: 0 24px 50px -16px rgba(0,0,0,.6);
}
.pop-item {
  display: flex; gap: 10px; align-items: flex-start; width: 100%;
  background: none; border: 0; border-radius: 10px; padding: 8px 10px;
  text-align: left; cursor: pointer; color: var(--text);
}
.pop-item:hover { background: var(--surface-2); }
.pop-item.danger .pop-t { color: var(--bad); }
.pop-ico { width: 20px; text-align: center; flex: 0 0 auto; }
.pop-t { display: block; font-weight: 600; font-size: 13px; }
.pop-d { display: block; font-size: 11.5px; color: var(--muted); }
.pop-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* ===== Smaller computers: still one screen, tighter ===== */
@media (max-width: 1350px) and (min-width: 1001px) {
  .room { grid-template-columns: 180px minmax(200px, 0.9fr) minmax(0, 3.4fr) minmax(112px, 0.6fr); }
  .g-tgt { display: none; }
}
/* Short screens: let it scroll rather than crush the cards */
@media (max-height: 760px) and (min-width: 1001px) {
  .page { height: auto; min-height: 100vh; }
  .room { flex: 0 0 auto; height: 140px; }
}

/* ===== Tablets and phones: rooms stack, the page scrolls ===== */
@media (max-width: 1000px) {
  .page { height: auto; }
  .rooms { gap: 12px; }
  .room {
    flex: 0 0 auto;
    grid-template-columns: 1fr;
    padding: 14px 12px 12px 18px;
    background:
      radial-gradient(120% 50% at 0% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
      var(--surface);
  }
  .room::before { top: 14px; bottom: 14px; }
  .equip { margin-top: 4px; }
  .tables { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { min-height: 96px; }
  .tank { min-height: 70px; }
  .gauge svg { max-width: 110px; }
  .g-num { margin-top: -36px; font-size: 21px; }
}
@media (max-width: 760px) {
  .nav {
    inset: auto 0 0 0; width: auto; height: calc(64px + env(safe-area-inset-bottom));
    flex-direction: row; justify-content: space-around;
    padding: 6px 6px env(safe-area-inset-bottom);
    border-right: 0; border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg-2) 88%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  }
  .nav-logo, .nav-spacer, .nav-item[href="index.html"], #theme-btn { display: none; }
  .nav-item { width: auto; flex: 1; padding: 6px 0; font-size: 10.5px; }
  .page { margin-left: 0; padding: 14px 12px 90px; }
  .head-left { flex-direction: column; gap: 2px; }
  .head-stats { width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .stat { flex: 0 0 auto; }
  .drw-back { padding: 0; }
  .drw { width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; }
  .drw .tp-head { border-radius: 0; }
}

/* ===== Panels (table, timed irrigation, room log) ===== */
.tp-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 18px 20px 14px;
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.tp-title { font: 700 22px/1.15 var(--num); letter-spacing: -0.03em; display: flex; align-items: center; gap: 10px; }
.tp-title .ph { font-size: 11px; padding: 2px 9px; }
.tp-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.tp-head-btns { display: flex; gap: 8px; align-items: center; }
.tp-x { width: 36px; padding: 8px 0; }

.tp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 16px 20px 4px; }
.tp-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.tp-kl { color: var(--muted); font-size: 11.5px; }
.tp-kv { font: 600 22px/1.2 var(--num); letter-spacing: -0.03em; margin-top: 2px; white-space: nowrap; }
.tp-kv small { font-size: 12px; color: var(--muted); font-weight: 500; }
.tp-ks { color: var(--faint); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-kpi.warn .tp-kv { color: var(--warn); }

.tp-sec { padding: 16px 20px 6px; }
.tp-sec h3 { margin: 0 0 10px; font: 600 14px/1.2 "Inter", sans-serif; color: var(--text-2); }
.tp-sec-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { background: none; border: 0; color: var(--muted); font-weight: 600; font-size: 12px; padding: 5px 10px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--line-2); }
.tp-legend { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tp-legend button, .tp-leg-irr {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); background: none; border: 1px solid transparent;
  border-radius: 99px; padding: 3px 9px; cursor: pointer;
}
.tp-legend button.on { color: var(--text); border-color: var(--line-2); background: var(--surface); }
.tp-legend i, .tp-leg-irr i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.tp-leg-irr { cursor: default; }
.tp-leg-irr i { width: 2px; height: 11px; background: color-mix(in srgb, var(--water) 55%, transparent); }

.tp-chart { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.tp-chart svg { display: block; width: 100%; height: 260px; touch-action: pan-y; cursor: crosshair; }
.tp-grid { stroke: var(--line); }
.tp-tick { fill: var(--faint); font-size: 10.5px; font-family: "Inter", sans-serif; }
.tp-irr { stroke: color-mix(in srgb, var(--water) 35%, transparent); stroke-width: 1.5; }
.tp-fc { stroke: var(--muted); stroke-dasharray: 4 4; opacity: .7; }
.tp-lfc { stroke: var(--night); stroke-dasharray: 2 4; stroke-width: 1.5; opacity: .9; }
.tp-lfc-t { fill: var(--night); }
.tp-ks .lfc { color: var(--night); cursor: help; }
.tp-edge { stroke: var(--warn); stroke-dasharray: 4 4; opacity: .8; }
.tp-edge-t { fill: var(--warn); }
.tp-cross { stroke: var(--text-2); stroke-width: 1; opacity: .6; }
.tp-tip {
  display: none; position: absolute; top: 10px; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 7px 10px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap;
}
.tp-tip-t { color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.tp-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.tp-empty { color: var(--muted); font-size: 13px; padding: 14px; text-align: center; }

.tp-day { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; overflow: hidden; }
.tp-day summary {
  display: flex; justify-content: space-between; padding: 9px 12px; cursor: pointer; font-weight: 600; font-size: 13px;
  list-style: none;
}
.tp-day summary::-webkit-details-marker { display: none; }
.tp-day-s { color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tp-day-s .ph { font-size: 10.5px; }
.tp-lit b { color: var(--water); font: 600 14px var(--num); }
.tp-nolit { color: var(--faint); font-size: 12px; font-weight: 500; }
.tp-day summary { gap: 10px; align-items: center; }
.tp-shots { padding: 0 12px 8px; }
.tp-shots div {
  display: grid; grid-template-columns: 54px 44px 50px 66px 1fr; gap: 8px;
  font-size: 12.5px; padding: 4px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
.tp-src { color: var(--muted); text-align: right; }

.tp-ev { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.tp-ev:first-child { border-top: 0; }
.tp-ev-t { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tp-ev-l { font-size: 13px; font-weight: 600; text-transform: none; }
.tp-ev-d { font-size: 12px; color: var(--muted); margin-top: 1px; word-break: break-word; }

/* forms inside panels */
.form { display: flex; flex-direction: column; gap: 14px; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer;
}
.switch-row b { display: block; font-size: 14px; }
.switch-row small { color: var(--muted); font-size: 12px; }
.switch-row input { display: none; }
.switch { width: 44px; height: 26px; border-radius: 99px; background: var(--line-2); position: relative; flex: 0 0 auto; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch-row input:checked + .switch { background: var(--good); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.form-grid label {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
  color: var(--muted); font-size: 12.5px;
}
.form-grid input {
  width: 64px; margin-left: auto; text-align: right;
  background: transparent; border: 0; color: var(--text); font: 600 17px var(--num);
}
.form-grid input:focus { outline: none; }
.ti-preview { color: var(--text-2); font-size: 13px; background: var(--surface); border: 1px dashed var(--line-2); border-radius: 12px; padding: 10px 12px; }

@media (max-width: 760px) {
  .tp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 14px 0; }
  .tp-sec { padding: 14px 14px 6px; }
  .tp-head { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
}

.ico { flex: 0 0 auto; vertical-align: -0.15em; }
.lights .li { display: inline-flex; }
.tank-t { align-items: center; }
.tank-t .ico { color: var(--water); margin-right: 2px; }
.room-menu { display: inline-flex; align-items: center; padding: 3px 6px; }
#tp-actions { display: inline-flex; align-items: center; gap: 4px; }
.tp-x { display: inline-flex; align-items: center; justify-content: center; }
.pop-ico { color: var(--muted); display: inline-flex; padding-top: 1px; }
.pop-item:hover .pop-ico { color: var(--text); }

/* ===== Settings panels ===== */
button.chip { cursor: pointer; font: inherit; font-size: 11.5px; }
button.chip:hover { border-color: var(--line-2); color: var(--text); }
.form-h { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.form-grid select, .form-grid input.wide, .form-grid input[type="date"] {
  margin-left: auto; background: transparent; border: 0; color: var(--text);
  font: 600 14px "Inter", sans-serif; text-align: right; min-width: 0;
}
.form-grid input.wide { width: 60%; font-family: var(--num); }
.form-grid select:focus, .form-grid input:focus { outline: none; }
.form-grid select option { background: var(--surface); color: var(--text); }
.form-grid label:focus-within { border-color: var(--water); }
.plug-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.plug-card .switch-row, .plug-card .form-grid label { background: var(--surface-2); }
.plug-card-h { display: flex; align-items: center; gap: 8px; }
.plug-card-h .tp-sub { margin: 0 0 0 auto; }
.chips-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.chips-pick input { display: none; }
.chips-pick span { display: inline-block; padding: 7px 16px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--muted); font-weight: 600; cursor: pointer; }
.chips-pick input:checked + span { background: var(--water); border-color: var(--water); color: #fff; }
.fl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.fl-grid div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; }
.fl-grid span { color: var(--muted); font-size: 11.5px; }
.fl-grid b { font: 600 17px var(--num); }
.fl-grid b.run { color: var(--water); }
.btn:disabled { opacity: .4; cursor: default; }
.rows div { display: grid; grid-template-columns: 1.2fr .8fr .6fr .8fr; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; font-variant-numeric: tabular-nums; }
.rows div:first-child { border-top: 0; }
.rows b { text-align: right; }
.fc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fc-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; text-align: left; cursor: pointer; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.fc-btn:hover { border-color: var(--water); }
.fc-btn span { color: var(--muted); font-size: 12px; }
.fc-btn b { font: 600 22px var(--num); }
.fc-btn small { color: var(--faint); font-size: 11px; }

/* ===== Full-screen chart ===== */
.tp-fs-title { display: none; font: 700 20px/1.2 var(--num); letter-spacing: -0.02em; }
.tp-fs-title .tp-sub { font: 500 12.5px "Inter", sans-serif; margin-left: 6px; }
.tp-fs-btn { display: inline-flex; align-items: center; justify-content: center; padding: 5px 8px; margin-left: 2px; }
.tp-sec.fs {
  position: fixed; inset: 0; z-index: 95;
  background: var(--bg);
  padding: 18px 22px 22px;
  display: flex; flex-direction: column;
}
.tp-sec.fs .tp-fs-title { display: block; margin-right: auto; }
.tp-sec.fs .tp-sec-h { margin-bottom: 12px; }
.tp-sec.fs .tp-chart { flex: 1; min-height: 0; }
.tp-sec.fs .tp-chart svg { height: 100%; }
@media (max-width: 760px) { .tp-sec.fs { padding: 12px 10px calc(14px + env(safe-area-inset-bottom)); } }

.tp-reset { position: absolute; top: 8px; right: 8px; padding: 4px 10px; font-size: 12px; }
.tp-legend { row-gap: 4px; }

/* VPD: share of today in the target band (under the VPD gauge) */
.g-day {
  margin-top: 4px; padding: 2px 8px; border-radius: 99px; border: 0; cursor: pointer;
  font: 600 10.5px "Inter", sans-serif; white-space: nowrap;
  background: var(--surface); color: var(--text-2);
}
.g-day.good { color: var(--good); background: color-mix(in srgb, var(--good) 13%, transparent); }
.g-day.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.g-day.bad  { color: var(--bad);  background: color-mix(in srgb, var(--bad) 13%, transparent); }

/* ===== Room climate chart (click a room's gauges) ===== */
.climate[data-climate] { cursor: pointer; }
.climate[data-climate] .gauge { transition: border-color .15s; }
.climate[data-climate]:hover .gauge { border-color: var(--line-2); }
.cl-legend { cursor: default; }
.cl-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-right: 12px; }
.cl-legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--text-2); }
.cl-legend i.dash { border-top-style: dashed; }
.cl-legend i.ac { border-top: 1.5px dotted var(--text-2); }
.cl-legend i.cl-band { height: 9px; border: 0; border-radius: 2px; background: color-mix(in srgb, var(--good) 35%, transparent); }
.cl-legend i.cl-night { height: 9px; border: 1px solid var(--line-2); border-radius: 2px; background: var(--bg-2); }
.cl-good { color: var(--good); } .cl-warn { color: var(--warn); } .cl-bad { color: var(--bad); }
.tp-kv .cl-src, .cl-src { font-size: 15px; }

/* ===== Text stays inside its box (grower 7.11) ===== */
.gauge { overflow: hidden; min-height: 0; justify-content: flex-start; }
.gauge svg { flex: 1 1 auto; min-height: 0; width: auto; max-width: min(92px, 100%); max-height: 100%; }
.g-num, .g-lbl, .g-tgt { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 0 auto; }
.g-day { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 10px; padding: 1px 7px; flex: 0 0 auto; }
.tile { overflow: hidden; }
.tile-id { white-space: nowrap; }
.tile-top { min-width: 0; }
.tile-vwc { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tile-mid { flex: 1 1 0; min-height: 0; overflow: hidden; }
.tile-mid .spark { height: 100%; min-height: 0; }
.tile-meta { flex: 0 0 auto; overflow: hidden; }
.tile-meta span { overflow: hidden; text-overflow: ellipsis; }
.tank-t > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-info { overflow: hidden; }
.equip { overflow: hidden; }

/* narrow boxes: shorter words instead of cut-off numbers */
.gauge { container-type: inline-size; }
@container (max-width: 84px) { .gd-l { display: none; } }
.tile { container-type: inline-size; }
.tile-meta i { font-style: normal; }
.tm-s { display: none; }
@container (max-width: 200px) { .tm-l { display: none; } .tm-s { display: inline; } }
.tank { container-type: inline-size; }
@container (max-width: 125px) { .tank-w { display: none; } }
.tank-t { white-space: nowrap; overflow: hidden; }
/* short screens: a room grows to fit its column instead of cutting it */
@media (max-height: 760px) and (min-width: 1001px) {
  .room { height: auto; min-height: 140px; }
}
.tank-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tank-pct { flex: 0 0 auto; }
