:root {
  color-scheme: dark;
  --bg: #0d1210;
  --surface: #151d19;
  --surface-2: #1b2520;
  --surface-3: #222e28;
  --line: #2a352f;
  --ink: #e9f0ec;
  --muted: #88a094;
  --accent: #3ddc84;
  --accent-dark: #2bb86c;
  --accent-soft: rgba(61, 220, 132, 0.12);
  --warn: #e6b24a;
  --warn-soft: rgba(230, 178, 74, 0.14);
  --bad: #e9706a;
  --bad-soft: rgba(233, 112, 106, 0.14);
  --info: #62b6d6;
  --radius: 16px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 80% -10%, #14201b 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: url("marijuana-leaves.jpg");
  background-repeat: repeat;
  background-size: 350px auto;
  opacity: 0.2;
  pointer-events: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
}

.hidden {
  display: none;
}

/* ---------- shell ---------- */
.app {
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 22px 60px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 0;
  margin-bottom: 22px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: radial-gradient(circle at 35% 30%, var(--accent), var(--accent-dark));
  box-shadow: 0 0 16px rgba(61, 220, 132, 0.5);
}

.brand-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--muted);
}

.brand-text strong {
  color: var(--ink);
}

.topnav {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 4px;
  border-radius: 999px;
}

.topnav-item {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  padding: 7px 16px;
  border-radius: 999px;
  font-weight: 550;
  transition: all 0.15s ease;
}

.topnav-item:hover {
  color: var(--ink);
}

.topnav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ghost-button:hover {
  border-color: var(--accent);
}

.ghost-button.danger:hover {
  border-color: var(--bad);
  color: var(--bad);
}

.primary-button {
  border: none;
  cursor: pointer;
  font-weight: 600;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #06120c;
  padding: 10px 18px;
  border-radius: 11px;
  box-shadow: 0 6px 18px rgba(61, 220, 132, 0.25);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(61, 220, 132, 0.35);
}

.mini-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  padding: 5px 11px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.mini-button:hover {
  border-color: var(--accent);
}

.mini-button.danger:hover {
  border-color: var(--bad);
  color: var(--bad);
}

.icon-button {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
}

.icon-button:hover {
  color: var(--bad);
  background: var(--bad-soft);
}

.link-button {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fade 0.18s ease;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head h1 {
  font-size: 26px;
}

.page-head p {
  margin: 4px 0 0;
}

.banner {
  background: var(--warn-soft);
  border: 1px solid rgba(230, 178, 74, 0.3);
  color: #f0d39a;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 18px;
  font-size: 14px;
}

/* ---------- panels ---------- */
.panel {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h4 {
  font-size: 15px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
}

.chip b {
  color: var(--ink);
  font-weight: 600;
}

.chip.ok {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.chip.warn {
  background: var(--warn-soft);
  border-color: transparent;
  color: var(--warn);
}

.chip.bad {
  background: var(--bad-soft);
  border-color: transparent;
  color: var(--bad);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 7px;
  background: var(--accent);
  vertical-align: middle;
}

.dot.ok {
  background: var(--accent);
}

.dot.warn {
  background: var(--warn);
}

.dot.bad {
  background: var(--bad);
}

.stage-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
}

.score-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.score-badge.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.score-badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.score-badge.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

/* ---------- rooms grid ---------- */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  display: grid;
  gap: 5px;
  min-height: 96px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.metric-card b {
  color: var(--ink);
  font-size: 24px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric-card small {
  color: var(--muted);
  line-height: 1.35;
}

.metric-card.ok {
  border-color: rgba(61, 220, 132, 0.35);
}

.metric-card.bad {
  border-color: rgba(233, 112, 106, 0.4);
}

.alert-panel {
  grid-column: 1 / -1;
}

.alert-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.alert-list li {
  display: grid;
  gap: 3px;
  border-left: 3px solid var(--warn);
  background: rgba(13, 18, 16, 0.42);
  border-radius: 9px;
  padding: 9px 11px;
}

.alert-list li b {
  font-size: 13.5px;
}

.alert-list li span {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 820px) {

  .dashboard-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }
}

.room-card {
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 14px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.room-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.room-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.room-card-top h3 {
  font-size: 17px;
  margin-bottom: 7px;
}

.room-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.room-card-stats span {
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface-3);
  padding: 4px 9px;
  border-radius: 8px;
}

.add-card {
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  border-style: dashed;
  min-height: 120px;
}

.add-card:hover {
  color: var(--accent);
}

.add-plus {
  font-size: 28px;
  display: block;
}

/* ---------- room workspace ---------- */
.room-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.back-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 10px;
}

.back-button:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.room-title {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.room-title h1 {
  font-size: 23px;
}

.inline-stage {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.inline-stage select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 10px;
}

.room-top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Room workspace = a hero band (tent + lighting | station tabs + readout +
   log form) over a masonry of secondary cards. The hero's two columns are
   each multi-element stacks so they balance in height; the cards below tile
   into self-balancing columns so variable-height panels never leave the
   ragged voids that one tall stacked column produced. */
.room-layout {
  display: grid;
  gap: 16px;
  align-items: start;
}

.room-hero {
  display: grid;
  grid-template-columns: minmax(360px, 1.3fr) minmax(320px, 1fr);
  gap: 16px;
  align-items: start;
}

.room-stage-col,
.room-log-col {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}

.room-log-col .station-tabs {
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
}

.room-cards {
  column-width: 340px;
  column-gap: 16px;
}

.room-cards > * {
  break-inside: avoid;
  margin: 0 0 16px;
  width: 100%;
}

@media (max-width: 980px) {
  .room-hero {
    grid-template-columns: 1fr;
  }
}

/* scene */
.room-viz {
  position: relative;
  width: 100%;
  min-height: 280px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  background: linear-gradient(180deg, #0d1210 0%, #080b0a 100%);
}

/* tent interior: highly detailed dark metallic Mylar grid background pattern */
.room-viz.tent {
  height: min(62vh, 540px);
  width: 100%;
  max-width: 100%;
  min-height: 360px;
  margin: 0;
  background: #070908;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.9);
  border-color: #16201b;
  perspective: 1000px;
}

/* full-scene SVG: the entire tent (structure, lamp, plants, substrate) is one
   perspective drawing in centimetre user units */
.room-viz.tent svg.grow-scene { display: block; width: 100%; height: 100%; }
.grow-scene text { font-family: inherit; user-select: none; pointer-events: none; }
.grow-scene rect.scene-stage { cursor: pointer; }
.grow-scene rect.scene-stage.sel { stroke: var(--accent); stroke-width: 1; fill: rgba(61, 220, 132, 0.04); }
.grow-scene .fixture-cell { cursor: pointer; }
.grow-scene .fixture-cell:hover rect { stroke: var(--accent); }
.grow-scene .fixture-cell:hover polygon { stroke: var(--accent); }
/* arrange mode: dashed accent outline; the picked light gets a solid outline */
.grow-scene .fixture-cell.arrange polygon { stroke: rgba(61, 220, 132, 0.6); stroke-dasharray: 2 1.4; }
.grow-scene .fixture-cell.arrange.from polygon { stroke: var(--accent); stroke-width: 1.3; stroke-dasharray: none; filter: drop-shadow(0 0 4px rgba(61, 220, 132, 0.7)); }
.grow-scene .lamp-handle { cursor: ns-resize; touch-action: none; }
.grow-scene .lamp-handle:hover rect { stroke: var(--accent); }
.grow-scene .lamp-handle text { pointer-events: none; }
.grow-scene .light-bar.dragging { filter: drop-shadow(0 0 5px rgba(61, 220, 132, 0.6)); }
.grow-scene .lamp-target-svg { cursor: pointer; }
.grow-scene .svg-substrate { cursor: pointer; }
.grow-scene .svg-substrate.sel rect { stroke: var(--accent); }
.grow-scene .scrog-net {
  cursor: pointer;
  filter: drop-shadow(0 0 4px rgba(61, 220, 132, 0.22));
}
.grow-scene .scrog-net:hover polygon {
  stroke: var(--accent);
  filter: drop-shadow(0 0 5px rgba(61, 220, 132, 0.45));
}
.grow-scene .plant-sway {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: sway var(--wind-duration, 5.5s) ease-in-out infinite;
}
.grow-scene .svg-plant:nth-child(even) .plant-sway { animation-delay: -2.75s; }
.grow-scene .svg-plant:nth-child(3n) .plant-sway { animation-duration: calc(var(--wind-duration, 5.5s) * 1.25); }
.room-viz[style*="--wind-duration:0s"] .plant-sway { animation: none !important; }
.grow-scene .svg-fan-blades {
  transform-box: fill-box;
  transform-origin: center;
  animation: spin 1.2s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .grow-scene .plant-sway, .grow-scene .svg-fan-blades { animation: none !important; }
}

/* Recessed back wall in 3D depth */
.tent-back-wall {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 32px;
  bottom: 78px;
  /* sits right above the receding floor back edge */
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.01) 0px, rgba(255, 255, 255, 0.01) 1px, transparent 1px, transparent 8px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.01) 0px, rgba(255, 255, 255, 0.01) 1px, transparent 1px, transparent 8px),
    radial-gradient(100% 45% at 50% 5%, rgba(var(--light-color-rgb, 255, 255, 255), 0.08), transparent 75%),
    linear-gradient(180deg, #141f1a 0%, #0d1210 50%, #060908 100%);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.85);
  border: 1px solid #1c2621;
  z-index: 1;
}

/* Receding 3D floor trapezoid */
.tent-floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 38px;
  height: 40px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.015) 0px, rgba(255, 255, 255, 0.015) 1px, transparent 1px, transparent 10px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.015) 0px, rgba(255, 255, 255, 0.015) 1px, transparent 1px, transparent 10px),
    linear-gradient(180deg, #141c18, #0a0d0b);
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%);
  border-top: 1px solid #1c2a21;
  z-index: 2;
}

.tent-post {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  z-index: 12;
  background: linear-gradient(90deg, #2b3a32, #18231e, #0e1512);
}

.tent-post.left {
  left: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.tent-post.right {
  right: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.tent-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  z-index: 15;
  background: linear-gradient(180deg, #1b2621, #0f1613);
  border-bottom: 1px solid #1c2621;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
}

.duct {
  width: 48px;
  height: 14px;
  border-radius: 2px;
  background:
    repeating-linear-gradient(90deg, transparent 0 3px, rgba(0, 0, 0, 0.4) 3px 4px),
    linear-gradient(180deg, #7c7c7c 0%, #dedede 25%, #6e6e6e 70%, #3a3a3a 100%);
  border: 1px solid #666;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.carbon-filter {
  width: 36px;
  height: 18px;
  border-radius: 3px;
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.2) 0 1.5px, transparent 1.5px 3px),
    linear-gradient(180deg, #3d3d3d 0%, #1a1a1a 100%);
  border: 1px solid #484848;
  position: relative;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.carbon-filter::before,
.carbon-filter::after {
  content: "";
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 3px;
  background: #555;
}

.carbon-filter::before {
  left: -2px;
  border-radius: 1px 0 0 1px;
}

.carbon-filter::after {
  right: -2px;
  border-radius: 0 1px 1px 0;
}

.tent-eq-label {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
}

/* Brushed aluminum multi-bar grow light panel */
.light-bar {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 60%;
  z-index: 8;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid #28372e;
  background: linear-gradient(180deg, #1b2620, #0c120f);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 15px rgba(var(--light-color-rgb, 255, 255, 255), 0.1);
  transition: bottom 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* rope-ratchet hanging straps from the ceiling rail to the lamp; they ride
   with the bar automatically and fill the void above it */
.light-bar::before,
.light-bar::after {
  content: "";
  position: absolute;
  bottom: 100%;
  width: 5px;
  height: 900px;
  z-index: -1;
  background:
    repeating-linear-gradient(180deg, #2c3a31 0 7px, #1a241e 7px 14px);
  border-left: 1px solid rgba(0, 0, 0, 0.5);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}
.light-bar::before { left: 16%; }
.light-bar::after { right: 16%; }

.fixture-grid {
  display: grid;
  gap: 6px;
}

.fixture {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 4px;
  border: 1px solid #1a251f;
  background: #080c0a;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

.fixture::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: #222;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.fixture:active {
  transform: scale(0.96);
}

.fixture.off {
  opacity: 0.45;
}

.fixture.on::after {
  background: #ffffff;
  box-shadow: 0 0 6px #ffffff;
}

.fixture.on.warm {
  background: linear-gradient(135deg, #ffa751, #ffe259);
  color: #3b2000;
  border-color: #ffc275;
  box-shadow: 0 0 16px rgba(255, 175, 75, 0.75);
}

.fixture.on.cool {
  background: linear-gradient(135deg, #2193b0, #6dd5ed);
  color: #00303b;
  border-color: #61d5f1;
  box-shadow: 0 0 16px rgba(109, 213, 237, 0.7);
}

/* Volumetric screen-blended light beam */
.light-cone {
  position: absolute;
  left: 14%;
  right: 14%;
  z-index: 3;
  pointer-events: none;
  mix-blend-mode: screen;
  filter: blur(8px);
  transition: bottom 0.45s ease, height 0.45s ease, opacity 0.3s ease;
  clip-path: polygon(28% 0, 72% 0, 100% 100%, 0 100%);
}

/* Drifting volumetric mist/particles */
.tent-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  overflow: hidden;
}

.particle {
  position: absolute;
  bottom: -10px;
  width: 3px;
  height: 3px;
  background: rgba(var(--light-color-rgb, 255, 255, 255), 0.35);
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(var(--light-color-rgb, 255, 255, 255), 0.7);
  opacity: 0;
  animation: floatUp 8s linear infinite;
}

.room-viz.lights-off .particle {
  display: none;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) translateX(0) scale(0.5);
    opacity: 0;
  }

  10% {
    opacity: 0.5;
  }

  90% {
    opacity: 0.5;
  }

  100% {
    transform: translateY(-320px) translateX(var(--drift, 20px)) scale(1.2);
    opacity: 0;
  }
}

.particle.p1 {
  left: 22%;
  animation-delay: 0s;
  --drift: 15px;
  animation-duration: 7s;
}

.particle.p2 {
  left: 46%;
  animation-delay: 2.2s;
  --drift: -20px;
  animation-duration: 9.5s;
}

.particle.p3 {
  left: 68%;
  animation-delay: 4.1s;
  --drift: 10px;
  animation-duration: 8s;
}

.particle.p4 {
  left: 33%;
  animation-delay: 1.3s;
  --drift: -15px;
  animation-duration: 11s;
}

.particle.p5 {
  left: 58%;
  animation-delay: 3.2s;
  --drift: 25px;
  animation-duration: 6.5s;
}

.particle.p6 {
  left: 78%;
  animation-delay: 5.4s;
  --drift: -10px;
  animation-duration: 7.8s;
}

.particle.p7 {
  left: 28%;
  animation-delay: 6.2s;
  --drift: 30px;
  animation-duration: 8.7s;
}

.particle.p8 {
  left: 62%;
  animation-delay: 7.1s;
  --drift: -30px;
  animation-duration: 10s;
}

/* Industrial ventilation tag */
.viz-fan {
  position: absolute;
  top: 6px;
  right: 12px;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--info);
  background: rgba(13, 19, 16, 0.85);
  border: 1px solid #222f28;
  border-radius: 20px;
  padding: 3px 9px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.viz-fan-icon {
  width: 15px;
  height: 15px;
  display: block;
}

.fan-blades-group {
  transform-origin: 12px 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Glassmorphism HUD hotspots with glowing indicator status */
.viz-hotspot {
  position: absolute;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(11, 17, 14, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 12px;
  cursor: pointer;
  color: var(--ink);
  font-size: 11px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.viz-hotspot b {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.viz-hotspot small {
  color: var(--muted);
  font-size: 10px;
}

.viz-hotspot:hover {
  border-color: var(--accent);
  background: rgba(17, 26, 21, 0.9);
  box-shadow: 0 0 12px rgba(61, 220, 132, 0.25), 0 6px 20px rgba(0, 0, 0, 0.45);
  transform: translateY(-1.5deg) scale(1.02);
}

.viz-hotspot.sel {
  border-color: var(--accent);
  background: rgba(61, 220, 132, 0.12);
  box-shadow: 0 0 16px rgba(61, 220, 132, 0.25), inset 0 0 5px rgba(61, 220, 132, 0.15);
}

/* Plant stage zone (interior canopy) */
.scene-stage {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 32px;
  bottom: 38px;
  z-index: 6;
  cursor: pointer;
  overflow: hidden; /* clips the lamp straps at the ceiling rail */
}

.scene-stage.sel {
  outline: none;
  border: 1px solid var(--accent);
  border-radius: 8px;
  box-shadow: inset 0 0 15px rgba(61, 220, 132, 0.15), 0 0 15px rgba(61, 220, 132, 0.12);
}

/* height ruler up the left wall — reinforces the to-scale view */
.scene-ruler { position: absolute; left: 0; top: 0; bottom: 0; width: 38px; z-index: 2; pointer-events: none; }
.ruler-tick { position: absolute; left: 0; width: 9px; border-bottom: 1px solid rgba(136, 160, 148, 0.3); }
.ruler-tick.major { width: 15px; border-bottom-color: rgba(136, 160, 148, 0.55); }
.ruler-tick.major i {
  position: absolute; left: 18px; top: -6px; font-style: normal;
  font-size: 9.5px; font-weight: 600; color: rgba(136, 160, 148, 0.65); letter-spacing: 0.02em;
}

/* in-tent climate monitor (control unit) */
.tent-monitor {
  position: absolute; top: 9%; right: 14px; z-index: 9;
  display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  border-radius: 8px; border: 1px solid #28372e; cursor: pointer;
  background: linear-gradient(180deg, #131c17, #0a0f0c);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.tent-monitor:hover { border-color: var(--accent); }
.tent-monitor.sel { border-color: var(--accent); box-shadow: 0 0 12px rgba(61, 220, 132, 0.2); }
.mon-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.mon-cell small { font-size: 8.5px; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); }
.mon-cell b { font-size: 11px; font-variant-numeric: tabular-nums; color: #b7e6c9; text-shadow: 0 0 6px rgba(61, 220, 132, 0.35); white-space: nowrap; }
.mon-cell b.bad { color: #f0a09b; text-shadow: 0 0 6px rgba(233, 112, 106, 0.4); }
.mon-cell b.warn { color: #e6cb8f; text-shadow: 0 0 6px rgba(230, 178, 74, 0.35); }
.mon-led { width: 6px; height: 6px; border-radius: 50%; }
.mon-led.ok { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.mon-led.warn { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.mon-led.bad { background: var(--bad); box-shadow: 0 0 6px var(--bad); animation: led-blink 1.1s steps(2) infinite; }
@keyframes led-blink { 50% { opacity: 0.25; } }
@media (max-width: 560px) { .tent-monitor { display: none; } }

.plant {
  position: absolute;
  z-index: 6;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  transition: height 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.plant-svg {
  height: 100%;
  width: auto;
  display: block;
  transform-origin: bottom center;
  animation: sway var(--wind-duration, 5.5s) ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
}

.room-viz.lights-on .plant-svg {
  filter: drop-shadow(0 0 6px rgba(var(--light-color-rgb, 255, 255, 255), 0.3)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
}

.room-viz[style*="--wind-duration:0s"] .plant-svg {
  animation: none !important;
}

.plant:nth-child(even) .plant-svg {
  animation-delay: -2.75s;
}

.plant:nth-child(3n) .plant-svg {
  animation-duration: 6.5s;
}

@keyframes sway {

  0%,
  100% {
    transform: rotate(-1.5deg);
  }

  50% {
    transform: rotate(1.5deg);
  }
}

.plant-overflow {
  position: absolute;
  right: 6px;
  bottom: 22px;
  z-index: 7;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  background: rgba(11, 16, 13, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 3px 8px;
  border-radius: 20px;
}

.plant-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.plant-zone-tag {
  position: absolute;
  left: 50%;
  bottom: calc(7% + 8px); /* sits just above the substrate band of the SVG scene */
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 7;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(11, 16, 13, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 3px 10px;
  border-radius: 20px;
}

/* diagnose tool */
.dx-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.dx-search { flex: 1; min-width: 200px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 13px; font-size: 14px; }
.dx-room { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.dx-cats { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 12px; }
.dx-cat { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.dx-cat:hover { border-color: var(--accent); }
.dx-cat.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.dx-context { margin-bottom: 14px; }
.dx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.dx-card { display: flex; flex-direction: column; text-align: left; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; overflow: hidden; transition: border-color 0.15s ease, transform 0.1s ease; padding: 0; }
.dx-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.dx-card.likely { border-color: rgba(233, 112, 106, 0.5); box-shadow: 0 0 0 1px rgba(233, 112, 106, 0.25); }
.dx-thumb { position: relative; width: 100%; aspect-ratio: 16 / 10; background: linear-gradient(160deg, #16211b, #0d1310); display: grid; place-items: center; overflow: hidden; }
.dx-leaf-svg { width: 64%; height: 64%; opacity: 0.9; }
.dx-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dx-photo.missing { display: none; }
.dx-count { position: absolute; top: 7px; right: 7px; z-index: 2; background: rgba(11, 16, 13, 0.82); border: 1px solid rgba(255, 255, 255, 0.12); color: #cfe0d6; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.dx-card { position: relative; }
/* modal gallery */
.dx-img-count { position: absolute; bottom: 7px; right: 9px; background: rgba(11, 16, 13, 0.82); color: #cfe0d6; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.dx-modal-hero { position: relative; }
.dx-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; margin-bottom: 4px; scrollbar-width: thin; }
.dx-strip-thumb { flex: 0 0 auto; width: 54px; height: 40px; padding: 0; border: 2px solid transparent; border-radius: 7px; overflow: hidden; cursor: pointer; background: #0d1310; }
.dx-strip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dx-strip-thumb:hover { border-color: var(--line); }
.dx-strip-thumb.active { border-color: var(--accent); }
.dx-modal-hero { cursor: zoom-in; }
.dx-zoom-hint { position: absolute; bottom: 7px; left: 9px; background: rgba(11, 16, 13, 0.82); color: #cfe0d6; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; pointer-events: none; }
/* full-size image lightbox — shows the image at its natural pixel size,
   scrollable when larger than the viewport */
.dx-lightbox { position: fixed; inset: 0; z-index: 90; overflow: auto; text-align: center; white-space: nowrap; animation: dx-fade 0.12s ease; }
.dx-lightbox::after { content: ""; display: inline-block; height: 100%; vertical-align: middle; }
@keyframes dx-fade { from { opacity: 0; } to { opacity: 1; } }
.dx-lightbox-backdrop { position: fixed; inset: 0; z-index: 0; background: rgba(0, 0, 0, 0.93); cursor: zoom-out; }
.dx-lightbox-img { position: relative; z-index: 1; display: inline-block; vertical-align: middle; margin: 24px; max-width: none; max-height: none; border-radius: 4px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.8); }
.dx-lightbox-close { position: fixed; top: 16px; right: 18px; z-index: 2; width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.dx-lightbox-close:hover { background: rgba(0, 0, 0, 0.9); }
.dx-card-body { display: grid; gap: 5px; padding: 11px 12px 13px; }
.dx-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dx-card-top b { font-size: 13.5px; }
.dx-card-body .chip { justify-self: start; }
.dx-card-body p { margin: 2px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.dx-modal { max-width: 460px; }
.dx-modal-hero { width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.dx-modal-hero .dx-thumb { aspect-ratio: 16 / 9; }
.dx-modal-tags { display: flex; gap: 7px; margin: 4px 0 12px; }
.dx-section { margin-bottom: 12px; }
.dx-section b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 3px; }
.dx-section p { margin: 0; font-size: 13.5px; line-height: 1.5; }
.dx-fix { padding: 11px 13px; border-radius: 10px; background: var(--accent-soft); border: 1px solid rgba(61, 220, 132, 0.25); }
.dx-fix b { color: var(--accent); }

/* start-a-grow wizard */
.wizard-steps { display: flex; gap: 8px; margin: 10px 0 16px; }
.wiz-step {
  display: flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 600;
}
.wiz-step b {
  display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%;
  background: var(--surface-3); font-size: 10.5px;
}
.wiz-step.active { border-color: var(--accent); color: var(--accent); }
.wiz-step.active b { background: var(--accent); color: #0d1210; }
.wiz-step.done { color: var(--ink); }
.wiz-step.done b { background: var(--accent-soft); color: var(--accent); }
.wizard-summary {
  display: grid; gap: 4px; padding: 11px 13px; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid rgba(61, 220, 132, 0.25); font-size: 13px;
}
.wizard-summary b { color: var(--accent); }

/* room plants panel */
.room-plant-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.room-plant-row {
  display: grid; grid-template-columns: minmax(60px, auto) auto 1fr auto; align-items: center; gap: 10px;
  padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px; background: rgba(13, 18, 16, 0.45);
  font-size: 12.5px;
}
.quick-plant-input {
  flex: 1; min-width: 110px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 9px; font-size: 12.5px;
}

/* plants registry */
.chip.info { background: rgba(98, 182, 214, 0.14); color: var(--info); border-color: rgba(98, 182, 214, 0.3); }
.plant-status-select {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 7px; font-size: 12px; cursor: pointer;
}
.plant-status-select:hover { border-color: var(--accent); }
.plants-stats { margin-bottom: 16px; }

/* playbook + today */
.today-panel { border-color: rgba(61, 220, 132, 0.3); }
.today-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.today-card { display: grid; gap: 6px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.today-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.today-card-head .link-button { padding: 0; font-size: 13.5px; }
.pb-focus { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.pb-targets { display: flex; flex-wrap: wrap; gap: 6px; }
.pb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.pb-list li { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: rgba(13, 18, 16, 0.45); }
.pb-list li div { display: grid; gap: 1px; }
.pb-list li b { font-size: 12.5px; }
.pb-list li span { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.pb-list.compact li { padding: 5px 8px; }
.pb-list .mini-button { flex-shrink: 0; }
.pb-watch { display: grid; gap: 6px; margin-top: 4px; }
.pb-watch > b { font-size: 12px; color: var(--warn); }
.pb-list.small li { border-color: rgba(230, 178, 74, 0.25); }

/* trends */
.trend-rows { display: grid; gap: 8px; }
.trend-row { display: grid; grid-template-columns: minmax(110px, 1fr) 120px auto; align-items: center; gap: 12px; }
.trend-label { display: grid; gap: 1px; }
.trend-label b { font-size: 12.5px; }
.trend-label small { font-size: 11px; color: var(--muted); }
.spark { width: 120px; height: 30px; display: block; border: 1px solid var(--line); border-radius: 6px; background: rgba(13, 18, 16, 0.5); }

.form-hint {
  align-self: end;
  padding-bottom: 8px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}

/* Volumetric substrate roots cross-section */
.viz-substrate {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 38px;
  z-index: 7;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background:
    repeating-radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.01) 0px, rgba(255, 255, 255, 0.01) 2px, transparent 2px, transparent 5px),
    linear-gradient(180deg, #1f180e 0%, #151009 100%);
  color: #cdb78f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  overflow: hidden;
  border-top: 1px solid #2e2417;
  transition: all 0.2s ease;
}

.viz-substrate:hover {
  background: linear-gradient(180deg, #2a2013 0%, #1c150c 100%);
  border-top-color: var(--accent);
}

.viz-substrate.sel {
  border-top-color: var(--accent);
  box-shadow: inset 0 0 10px rgba(61, 220, 132, 0.15);
}

.moisture-fill {
  position: absolute;
  left: -50%;
  right: -50%;
  bottom: 0;
  border-radius: 42%;
  background: linear-gradient(180deg, rgba(61, 220, 132, 0.14) 0%, rgba(43, 184, 108, 0.32) 100%);
  animation: wave 12s linear infinite;
  transform-origin: 50% 50%;
  pointer-events: none;
  transition: height 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes wave {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.viz-substrate span {
  position: relative;
  z-index: 8;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.viz-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .plant-svg {
    animation: none;
  }

  .moisture-fill {
    animation: none;
  }
}

.slider {
  width: 100%;
  accent-color: var(--accent);
}

.rec-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 13.5px;
  line-height: 1.45;
}

.timing-card {
  display: grid;
  gap: 6px;
  line-height: 1.4;
}

.timing-card b {
  font-size: 14px;
}

.timing-card span {
  color: var(--ink);
  font-size: 13.5px;
}

.stage-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
}

.stage-node {
  display: grid;
  gap: 2px;
  min-width: 92px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.stage-node b {
  font-size: 12px;
}

.stage-node small {
  color: var(--muted);
  font-size: 11px;
}

.stage-node.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.training-panel {
  border-color: rgba(61, 220, 132, 0.24);
}

.training-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.training-card {
  display: grid;
  gap: 4px;
  padding: 10px 11px;
  border: 1px solid rgba(61, 220, 132, 0.18);
  border-radius: 10px;
  background: rgba(61, 220, 132, 0.06);
}

.training-card b {
  font-size: 12px;
  color: var(--accent);
}

.training-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.transition-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.transition-summary div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.transition-summary span {
  color: var(--muted);
  font-size: 12px;
}

.transition-summary b {
  color: var(--ink);
}

.fan-suggest {
  margin-top: 10px;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid rgba(61, 220, 132, 0.25);
  display: grid;
  gap: 6px;
}

.fan-suggest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.fan-suggest-head b {
  color: var(--accent);
}

/* station tabs */
.station-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}

.station-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  padding: 9px 11px;
  border-radius: 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.station-tab:hover {
  border-color: var(--accent);
}

.station-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.station-tab b {
  font-size: 12.5px;
}

.station-tab small {
  color: var(--muted);
  font-size: 11.5px;
}

/* tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.data-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table td.now {
  font-weight: 650;
}

.row-actions {
  display: flex;
  gap: 6px;
}

/* forms */
label {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.log-form label,
.room-edit-form label,
#batchForm label,
#inventoryForm label,
#taskForm label,
#harvestForm label,
fieldset label {
  margin-bottom: 2px;
}

input,
select {
  width: 100%;
  margin-top: 5px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.log-form {
  display: grid;
  gap: 11px;
}

.log-form .primary-button,
#batchForm .primary-button,
#inventoryForm .primary-button,
#taskForm .primary-button,
#harvestForm .primary-button {
  margin-top: 4px;
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 16px;
  align-items: start;
}

.wide-split {
  grid-template-columns: minmax(300px, 380px) 1fr;
}

@media (max-width: 820px) {
  .split {
    grid-template-columns: 1fr;
  }
}

.split form {
  display: grid;
  gap: 11px;
}

.setpoint-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

fieldset.panel {
  border: 1px solid var(--line);
}

legend {
  color: var(--accent);
  font-weight: 600;
  padding: 0 6px;
}

.data-tools {
  display: grid;
  gap: 12px;
}

/* logs list */
.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.log-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.log-list li:last-child {
  border-bottom: none;
}

.log-time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  min-width: 92px;
}

.log-meas {
  flex: 1;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-log-rail {
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow: hidden;
}

.room-log-rail.panel {
  padding: 14px;
}

/* in the masonry, the activity feed is just another card — cap it so it
   scrolls internally instead of becoming one giant column */
.room-cards .room-log-rail {
  max-height: 560px;
}

.log-days {
  display: grid;
  gap: 14px;
  overflow-y: auto;
  padding-right: 4px;
}

.log-day {
  display: grid;
  gap: 8px;
}

.log-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  padding: 0 2px;
}

.log-day-head b {
  color: var(--ink);
  font-size: 13px;
}

.log-entry {
  position: relative;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(13, 18, 16, 0.5);
  padding: 10px 34px 10px 10px;
}

.log-entry::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.log-entry.log-lights::before {
  background: #e6b24a;
}

.log-entry.log-feed::before {
  background: #62b6d6;
}

.log-entry.log-root::before {
  background: #b88957;
}

.log-entry.log-plant::before {
  background: #d37adf;
}

.log-entry.log-other::before {
  background: var(--muted);
}

.log-entry-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.log-entry time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.log-entry p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.log-entry small {
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.log-entry .icon-button {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 10;
  pointer-events: auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
}

.log-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(61, 220, 132, 0.25);
}

.log-tag.log-lights {
  color: #f0d39a;
  background: rgba(230, 178, 74, 0.13);
  border-color: rgba(230, 178, 74, 0.28);
}

.log-tag.log-feed {
  color: #9bd8ef;
  background: rgba(98, 182, 214, 0.13);
  border-color: rgba(98, 182, 214, 0.3);
}

.log-tag.log-root {
  color: #d8b58f;
  background: rgba(184, 137, 87, 0.14);
  border-color: rgba(184, 137, 87, 0.32);
}

.log-tag.log-plant {
  color: #edb1f3;
  background: rgba(211, 122, 223, 0.13);
  border-color: rgba(211, 122, 223, 0.28);
}

.log-tag.log-other {
  color: var(--muted);
  background: rgba(136, 160, 148, 0.12);
  border-color: rgba(136, 160, 148, 0.24);
}

.empty-log-rail {
  min-height: 160px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
}

/* modal */
#modalRoot {
  display: none;
}

#modalRoot.open {
  display: block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 40;
}

.modal {
  position: fixed;
  z-index: 41;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, calc(100vw - 32px));
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.modal h2 {
  margin-bottom: 16px;
  font-size: 19px;
}

.modal-x {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 22px;
}

.room-edit-form {
  display: grid;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* toast */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: all 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.storage-warning {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  background: var(--warn-soft);
  border-top: 1px solid rgba(230, 178, 74, 0.4);
  color: #f0d39a;
  padding: 11px 20px;
  font-size: 13px;
  text-align: center;
}

.storage-warning code {
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 6px;
  border-radius: 6px;
}

/* Detailed Guide Styles inside Modal */
.dx-divider {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}

.dx-detailed-guide {
  margin-top: 16px;
}

.dx-detailed-guide b {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 8px;
}

.dx-guide-content p {
  margin: 0 0 10px;
  font-size: 13.5px;
  line-height: 1.55;
  color: #d1dcd4;
}

.dx-guide-content h3 {
  margin: 16px 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.dx-guide-content h4 {
  margin: 12px 0 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
}

.dx-guide-content ul {
  margin: 0 0 10px 18px;
  padding: 0;
  list-style-type: disc;
}

.dx-guide-content li {
  margin-bottom: 5px;
  font-size: 13.5px;
  line-height: 1.5;
  color: #d1dcd4;
}

.dx-guide-content blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-style: italic;
}

.dx-guide-content blockquote p {
  margin: 0;
}

.dx-guide-content table.dx-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 12.5px;
}

.dx-guide-content table.dx-table th, 
.dx-guide-content table.dx-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
}

.dx-guide-content table.dx-table th {
  background: var(--surface-2);
  font-weight: 700;
}

.dx-detail-img-container {
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.dx-detail-img {
  width: 100%;
  height: auto;
  display: block;
}

/* --- glossary tooltips ---------------------------------------------------- */

.term-help {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  margin-left: 5px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  background: rgba(136, 160, 148, 0.16);
  border: 1px solid rgba(136, 160, 148, 0.32);
  cursor: help;
  position: relative;
  vertical-align: middle;
  user-select: none;
}

.term-help:hover,
.term-help:focus {
  color: var(--accent);
  border-color: rgba(61, 220, 132, 0.45);
  outline: none;
}

.term-help::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(3px);
  width: 250px;
  padding: 9px 11px;
  border-radius: 9px;
  background: #0d1813;
  border: 1px solid rgba(61, 220, 132, 0.3);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  color: #d7e6dd;
  font-size: 12px;
  font-weight: 450;
  line-height: 1.45;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 80;
}

.term-help:hover::after,
.term-help:focus::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* tables clip tooltips less if the badge sits in the first column; nudge the
   bubble right when it would cross the panel's left edge */
td:first-child .term-help::after,
.trend-label .term-help::after {
  left: 0;
  transform: translateX(0) translateY(3px);
}

td:first-child .term-help:hover::after,
td:first-child .term-help:focus::after,
.trend-label .term-help:hover::after,
.trend-label .term-help:focus::after {
  transform: translateX(0) translateY(0);
}

.glossary-panel {
  margin-top: 14px;
}

.glossary-list {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 10px 18px;
}

.glossary-item dt {
  font-weight: 700;
  font-size: 12.5px;
  text-transform: capitalize;
  color: var(--accent);
}

.glossary-item dd {
  margin: 2px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

/* --- watering & ripeness stations ----------------------------------------- */

.log-entry.log-water::before {
  background: #4cc9f0;
}

.log-tag.log-water {
  color: #a5e3f7;
  background: rgba(76, 201, 240, 0.13);
  border-color: rgba(76, 201, 240, 0.3);
}

.log-entry.log-ripen::before {
  background: #e89a5d;
}

.log-tag.log-ripen {
  color: #f3c49e;
  background: rgba(232, 154, 93, 0.14);
  border-color: rgba(232, 154, 93, 0.3);
}

/* --- today checklist & task checkboxes ------------------------------------ */

.today-checklist .today-task {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.today-checklist .today-task label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.today-checklist input[type="checkbox"],
.task-check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.task-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

tr.task-done td b {
  text-decoration: line-through;
  opacity: 0.55;
}

/* --- responsive shell ----------------------------------------------------- */

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.panel,
.room-card,
.metric-card,
.today-card,
.dx-card,
fieldset {
  min-width: 0;
}

.rooms-grid,
.dx-grid,
.today-grid,
.setpoint-grid,
.glossary-list {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--card-min, 260px)), 1fr));
}

.dx-grid {
  --card-min: 250px;
}

.setpoint-grid {
  --card-min: 280px;
}

.glossary-list {
  --card-min: 290px;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px 12px;
  }

  .topnav {
    order: 3;
    flex: 1 0 100%;
    min-width: 0;
    overflow-x: auto;
    border-radius: 14px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .topnav-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .topbar-actions {
    margin-left: auto;
    flex: 0 0 auto;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-head > * {
    max-width: 100%;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 0 12px 42px;
  }

  .topbar {
    position: static;
    margin-bottom: 14px;
    padding: 10px 0 12px;
  }

  .brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 8px;
  }

  .brand-text {
    font-size: 16px;
  }

  .topnav {
    gap: 3px;
    padding: 4px;
  }

  .topnav-item {
    padding: 8px 12px;
    font-size: 13px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .ghost-button,
  .primary-button {
    padding: 9px 12px;
  }

  .page-head {
    gap: 10px;
    margin-bottom: 14px;
  }

  .page-head h1 {
    font-size: 22px;
    overflow-wrap: anywhere;
  }

  .panel {
    padding: 14px;
    border-radius: 13px;
  }

  .panel-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .dashboard-grid,
  .result-grid,
  .form-row,
  .transition-summary {
    grid-template-columns: 1fr;
  }

  .rooms-grid,
  .dx-grid,
  .today-grid,
  .setpoint-grid,
  .glossary-list {
    --card-min: 100%;
  }

  .room-card {
    padding: 14px;
  }

  .room-card-top,
  .today-card-head,
  .fan-suggest-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .room-top {
    align-items: stretch;
    gap: 10px;
  }

  .room-title,
  .inline-stage,
  .room-top-right {
    width: 100%;
  }

  .room-title h1 {
    font-size: 21px;
    overflow-wrap: anywhere;
  }

  .inline-stage {
    align-items: flex-start;
    flex-direction: column;
  }

  .room-top-right {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .room-top-right .ghost-button,
  .room-top-right .primary-button,
  .back-button {
    flex: 1 1 140px;
  }

  .room-layout,
  .split,
  .wide-split,
  .viz-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .room-entry,
  .room-log-rail {
    position: static;
  }

  .room-log-rail {
    max-height: none;
  }

  .room-viz {
    min-height: 240px;
  }

  .room-viz.tent {
    width: 100%;
    min-height: 300px;
    height: min(68vh, 480px);
  }

  .viz-side .station-tabs,
  .station-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .station-tab {
    padding: 8px 9px;
  }

  .station-tab small {
    overflow-wrap: anywhere;
  }

  .dx-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dx-search,
  .dx-room,
  .quick-plant-input {
    min-width: 0;
  }

  .dx-modal-tags,
  .wizard-steps,
  .chip-row {
    flex-wrap: wrap;
  }

  .room-plant-row,
  .trend-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .room-plant-row .chip,
  .room-plant-row .plant-status-select,
  .room-plant-row .mini-button {
    justify-self: start;
  }

  .spark {
    width: 100%;
  }

  .pb-list li,
  .today-checklist .today-task,
  .log-list li,
  .log-entry-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .log-time {
    min-width: 0;
  }

  .log-meas {
    white-space: normal;
  }

  .modal {
    inset: 10px;
    width: auto;
    max-height: none;
    transform: none;
    top: 10px;
    left: 10px;
    padding: 16px;
    border-radius: 14px;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-actions > button {
    flex: 1 1 130px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    text-align: center;
  }

  .storage-warning {
    padding: 10px 12px;
  }
}

@media (max-width: 560px) {
  .topbar-actions .ghost-button {
    padding: 8px 10px;
    font-size: 13px;
  }

  .panel:has(.data-table),
  .dx-guide-content {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table,
  .dx-guide-content table.dx-table {
    min-width: 520px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 7px;
  }

  .row-actions {
    flex-wrap: wrap;
  }

  .viz-side .station-tabs,
  .station-tabs {
    grid-template-columns: 1fr;
  }

  .room-viz.tent {
    min-height: 280px;
    height: min(62vh, 420px);
  }

  .tent-monitor {
    display: none;
  }

  .plant-zone-tag,
  .tent-eq-label {
    white-space: normal;
  }

  .dx-lightbox {
    white-space: normal;
  }

  .dx-lightbox-img {
    margin: 12px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 84px);
    object-fit: contain;
  }

  .term-help::after,
  td:first-child .term-help::after,
  .trend-label .term-help::after {
    position: fixed;
    left: 12px;
    right: 12px;
    top: 72px;
    bottom: auto;
    width: auto;
    transform: none;
  }

  .term-help:hover::after,
  .term-help:focus::after,
  td:first-child .term-help:hover::after,
  td:first-child .term-help:focus::after,
  .trend-label .term-help:hover::after,
  .trend-label .term-help:focus::after {
    transform: none;
  }
}

/* --- cloud sync chip & connect dialog ------------------------------------- */

.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  border: 1px solid rgba(136, 160, 148, 0.3);
  background: rgba(136, 160, 148, 0.1);
  color: var(--muted);
  white-space: nowrap;
}

.sync-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.sync-chip.ok {
  color: #7ee2a8;
  border-color: rgba(61, 220, 132, 0.35);
  background: rgba(61, 220, 132, 0.1);
}

.sync-chip.locked {
  color: #f0c46a;
  border-color: rgba(230, 178, 74, 0.4);
  background: rgba(230, 178, 74, 0.12);
  animation: syncPulse 2s ease-in-out infinite;
}

.sync-chip.off {
  color: #ef8d8d;
  border-color: rgba(239, 110, 110, 0.4);
  background: rgba(239, 110, 110, 0.1);
}

@keyframes syncPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.sync-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 7, 0.7);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 18px;
}

.sync-modal {
  width: min(420px, 100%);
  background: #101b14;
  border: 1px solid rgba(61, 220, 132, 0.25);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sync-modal h3 {
  margin: 0;
  font-size: 18px;
}

.sync-modal p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.sync-modal-error {
  color: #ef8d8d !important;
  font-weight: 600;
}

.sync-modal input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid rgba(136, 160, 148, 0.35);
  background: rgba(8, 14, 11, 0.8);
  color: var(--ink);
  font-size: 15px;
  letter-spacing: 0.4px;
}

.sync-modal input:focus {
  outline: none;
  border-color: rgba(61, 220, 132, 0.55);
}

.sync-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 720px) {
  .sync-chip { font-size: 11px; padding: 5px 9px; }
}
