/*
  Meristem Grow: Hydroponic greenhouse dashboard stylesheet
  Botanical laboratory instrumentation sheet aesthetic: crisp white-sage paper,
  chlorophyll ink, botanical emerald, nutrient amber, and hydration cobalt.
*/

:root {
  /* Core palette */
  --bg: #f6f8f4;
  --surface: #ffffff;
  --surface-tint: #eef3eb;
  --surface-hover: #e6eee1;
  --ink: #17261c;
  --ink-muted: #465a4d;
  --ink-subtle: #5d7264;
  --emerald: #2e7d4f;
  --emerald-deep: #1e5937;
  --emerald-soft: rgba(46, 125, 79, 0.11);
  --amber: #b45309;
  --amber-ink: #8a3b08;
  --amber-soft: rgba(180, 83, 9, 0.1);
  --cobalt: #2563eb;
  --cobalt-ink: #1d4ed8;
  --cobalt-soft: rgba(37, 99, 235, 0.1);

  /* Lines and borders */
  --line: #d4ddd0;
  --line-strong: #b4c2ae;

  /* Typography */
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-pill: 999px;

  /* Transitions */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 160ms;
}

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

html {
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  accent-color: var(--emerald);
  scrollbar-color: var(--line-strong) var(--bg);
  scrollbar-width: thin;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--ink);
  font-size: 0.9375rem;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background-color: var(--emerald);
  color: #ffffff;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 5px;
  border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-subtle);
}

:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--space-2);
  background: var(--ink);
  color: #ffffff;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  z-index: 100;
}

.skip-link:focus {
  left: var(--space-4);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3,
p,
ul,
dl,
dd {
  margin: 0;
}

/* Top Status Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(246, 248, 244, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-strong);
}

.top-bar-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--emerald);
  border-radius: var(--radius-md);
  background: var(--emerald-soft);
  color: var(--emerald);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-text h1 {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.facility-code {
  font-size: 0.78rem;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}

/* 4-Bay Greenhouse Selector */
.bay-selector {
  display: flex;
  align-items: stretch;
  background: var(--surface-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
  flex-wrap: wrap;
}

.bay-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 7px 12px;
  min-height: 38px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.bay-tab:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.bay-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.bay-tab-code {
  font-size: 0.74rem;
  color: var(--ink-subtle);
}

.bay-tab.is-active .bay-tab-code {
  color: var(--emerald);
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-nominal {
  background-color: var(--emerald);
}

.status-warning {
  background-color: var(--amber);
}

.status-advisory {
  background-color: var(--cobalt);
}

/* Top Controls */
.top-controls {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.facility-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8rem;
}

.meta-label {
  color: var(--ink-subtle);
  font-weight: 500;
}

.alert-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--amber-soft);
  color: var(--amber-ink);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(180, 83, 9, 0.25);
}

.alert-pill.is-clear {
  background: var(--emerald-soft);
  color: var(--emerald-deep);
  border-color: rgba(46, 125, 79, 0.25);
}

.override-lock-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 7px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--emerald);
  background: var(--emerald-soft);
  color: var(--emerald-deep);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.override-lock-btn:hover {
  background: rgba(46, 125, 79, 0.2);
}

.override-lock-btn .lock-icon-closed {
  display: none;
}

.override-lock-btn[aria-pressed="true"] {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber-ink);
}

.override-lock-btn[aria-pressed="true"] .lock-icon-open {
  display: none;
}

.override-lock-btn[aria-pressed="true"] .lock-icon-closed {
  display: block;
}

/* Main Instrumentation Sheet */
.sheet-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.sheet-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  scroll-margin-top: 84px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
}

.section-title-group {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.section-head h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.cultivar-tag,
.section-meta {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* Telemetry Deck (Signature Moment) */
.telemetry-deck {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
}

.telemetry-main {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.telemetry-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.segmented-group {
  display: inline-flex;
  background: var(--surface-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 10px;
  min-height: 30px;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.seg-btn:hover {
  color: var(--ink);
}

.seg-btn.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line);
}

.stream-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-tint);
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.stream-btn.is-live {
  border-color: rgba(46, 125, 79, 0.35);
  background: var(--emerald-soft);
  color: var(--emerald-deep);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-subtle);
}

.stream-btn.is-live .pulse-dot {
  background: var(--emerald);
  animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.85);
  }
}

/* Metric Toggles */
.metric-toggle-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-wrap: wrap;
}

.metric-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 11px;
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  cursor: pointer;
  opacity: 0.58;
  transition: opacity var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.metric-toggle.is-active {
  opacity: 1;
  color: var(--ink);
  border-color: var(--line-strong);
}

.metric-toggle:hover {
  opacity: 1;
}

.swatch {
  width: 12px;
  height: 3px;
  border-radius: 2px;
}

.swatch-vpd { background: var(--emerald); }
.swatch-co2 { background: var(--ink); }
.swatch-ph { background: var(--amber); }
.swatch-ec { background: var(--cobalt); }

.metric-toggle-name {
  font-weight: 700;
}

.metric-toggle-val {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.focus-metric-wrap {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.inline-select {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  min-height: 34px;
  cursor: pointer;
}

/* Telemetry SVG Chart */
.chart-frame {
  position: relative;
  padding: var(--space-4) var(--space-5) var(--space-3);
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chart-readout-strip {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: 0.76rem;
  padding-bottom: var(--space-3);
  color: var(--ink-muted);
}

.readout-time {
  color: var(--ink);
  font-weight: 600;
}

.readout-vpd { color: var(--emerald-deep); }
.readout-co2 { color: var(--ink); }
.readout-ph { color: var(--amber-ink); }
.readout-ec { color: var(--cobalt-ink); }

.telemetry-svg {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
  cursor: crosshair;
}

.svg-grid line {
  stroke: var(--line);
  stroke-width: 1;
}

.svg-target-band {
  fill: rgba(46, 125, 79, 0.1);
}

.svg-target-band.band-co2 { fill: rgba(23, 38, 28, 0.08); }
.svg-target-band.band-ph { fill: rgba(180, 83, 9, 0.1); }
.svg-target-band.band-ec { fill: rgba(37, 99, 235, 0.1); }

.svg-target-line {
  stroke: var(--emerald);
  stroke-width: 1.4;
  stroke-dasharray: 5 4;
}

.svg-target-line.band-co2 { stroke: var(--ink); }
.svg-target-line.band-ph { stroke: var(--amber); }
.svg-target-line.band-ec { stroke: var(--cobalt); }

.series-line {
  fill: none;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity var(--dur) var(--ease);
}

.series-vpd { stroke: var(--emerald); }
.series-co2 { stroke: var(--ink); }
.series-ph { stroke: var(--amber); }
.series-ec { stroke: var(--cobalt); }

.series-dot {
  stroke: var(--surface);
  stroke-width: 1.75;
}

.svg-axis-labels text {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--ink-subtle);
}

.svg-crosshair {
  stroke: var(--ink-subtle);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

/* Telemetry Summary Strip */
.telemetry-summary-strip {
  margin-top: auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.summary-cell {
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 1px solid var(--line);
}

.summary-cell:last-child {
  border-right: none;
}

.summary-name {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.summary-reading {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
}

.summary-delta {
  font-size: 0.75rem;
  font-weight: 600;
}

.summary-delta.is-good { color: var(--emerald-deep); }
.summary-delta.is-warn { color: var(--amber-ink); }

/* Right Setpoint Calibrator */
.setpoint-panel {
  display: flex;
  flex-direction: column;
}

.calibrator-state {
  font-size: 0.76rem;
  color: var(--emerald-deep);
  font-weight: 600;
}

.panel-note {
  padding: var(--space-3) var(--space-5);
  font-size: 0.8rem;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.setpoint-list {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  flex: 1;
}

.setpoint-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setpoint-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.setpoint-row-head label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}

.setpoint-output {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--emerald-deep);
}

.slider-control {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  gap: var(--space-2);
}

.step-btn {
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-tint);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}

.step-btn:hover:not(:disabled) {
  background: var(--surface-hover);
}

.step-btn:disabled,
input[type="range"]:disabled,
select:disabled,
button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

input[type="range"] {
  width: 100%;
  margin: 0;
  cursor: pointer;
}

.setpoint-bounds {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 0.72rem;
  color: var(--ink-subtle);
}

.setpoint-actions {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--line);
}

.btn-primary,
.btn-secondary,
.btn-cobalt,
.btn-subtle,
.btn-link {
  appearance: none;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.btn-primary {
  flex: 1;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--emerald);
  background: var(--emerald);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--emerald-deep);
}

.btn-secondary {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-tint);
}

.btn-cobalt {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--cobalt);
  background: var(--cobalt);
  color: #ffffff;
}

.btn-cobalt:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn-subtle {
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-tint);
  color: var(--ink);
  font-size: 0.78rem;
}

.btn-subtle:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn-link {
  border: none;
  background: transparent;
  color: var(--cobalt);
  padding: 5px 6px;
  font-size: 0.78rem;
}

.btn-link:hover {
  text-decoration: underline;
}

.action-feedback {
  min-height: 28px;
  padding: 0 var(--space-5) var(--space-3);
  font-size: 0.74rem;
  color: var(--emerald-deep);
}

/* Lab Tables (Ledger & Alert Log) */
.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.lab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.lab-table th,
.lab-table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.lab-table th {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--bg);
  white-space: nowrap;
}

.lab-table th.num,
.lab-table td.num {
  text-align: right;
  white-space: nowrap;
}

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

.ledger-row {
  cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}

.ledger-row:hover {
  background: var(--surface-tint);
}

.ledger-row.is-selected {
  background: rgba(46, 125, 79, 0.08);
}

.sub-cell {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin-top: 1px;
}

.state-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

.state-nominal {
  background: var(--emerald-soft);
  color: var(--emerald-deep);
}

.state-warning {
  background: var(--amber-soft);
  color: var(--amber-ink);
}

.state-advisory {
  background: var(--cobalt-soft);
  color: var(--cobalt-ink);
}

/* Operations Deck */
.ops-deck {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
}

.ops-column {
  display: flex;
  flex-direction: column;
}

.schedule-column {
  border-right: 1px solid var(--line);
}

.schedule-visual {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.schedule-legend {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-bottom: var(--space-2);
}

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
}

.swatch-light {
  background: rgba(46, 125, 79, 0.3);
  border: 1px solid var(--emerald);
}

.swatch-water {
  background: var(--cobalt);
}

.schedule-svg {
  width: 100%;
  height: auto;
  display: block;
}

.ops-controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  flex: 1;
}

.control-block {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.control-block:first-child {
  border-right: 1px solid var(--line);
}

.control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.control-head h3 {
  font-size: 0.9rem;
  font-weight: 700;
}

.toggle-chip {
  appearance: none;
  padding: 4px 10px;
  min-height: 30px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-tint);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

.toggle-chip.is-on {
  border-color: rgba(46, 125, 79, 0.4);
  background: var(--emerald-soft);
  color: var(--emerald-deep);
}

.status-inline {
  font-size: 0.74rem;
  color: var(--cobalt);
  font-weight: 600;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.field-row label {
  color: var(--ink);
  font-weight: 500;
}

.flush-row {
  margin-top: auto;
  padding-top: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.flush-timer {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

/* Harvest Readiness Tracker */
.harvest-totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.harvest-totals strong {
  color: var(--ink);
}

.harvest-list {
  list-style: none;
  padding: 0;
}

.harvest-item {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.harvest-item:last-child {
  border-bottom: none;
}

.harvest-item.is-harvested {
  background: var(--bg);
  opacity: 0.78;
}

.harvest-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.lot-code {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--emerald-deep);
  margin-right: var(--space-2);
}

.lot-crop {
  font-size: 0.88rem;
  margin-right: var(--space-2);
}

.lot-bay {
  font-size: 0.78rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.lot-yield {
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
}

.progress-track {
  height: 7px;
  background: var(--surface-tint);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid var(--line);
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 260ms var(--ease);
}

.fill-emerald { background: var(--emerald); }
.fill-amber { background: var(--amber); }
.fill-cobalt { background: var(--cobalt); }

.harvest-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.lot-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* Alert Log */
.alert-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.alert-table tr.is-acknowledged {
  color: var(--ink-subtle);
  background: rgba(246, 248, 244, 0.55);
}

.ack-stamp {
  font-size: 0.76rem;
  color: var(--ink-subtle);
}

/* Footer */
.sheet-footer {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 var(--space-5) var(--space-7);
}

.sheet-footer-inner {
  border-top: 1px solid var(--line);
  padding-top: var(--space-4);
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--ink-subtle);
}

/* Modal Dialog */
.lab-modal {
  width: min(480px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  box-shadow: 0 20px 50px rgba(23, 38, 28, 0.18);
}

.lab-modal::backdrop {
  background: rgba(23, 38, 28, 0.42);
  backdrop-filter: blur(2px);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-tint);
  color: var(--ink);
  cursor: pointer;
}

.modal-specs {
  padding: var(--space-4) var(--space-5);
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: var(--space-2) var(--space-3);
  font-size: 0.84rem;
}

.modal-specs dt {
  color: var(--ink-muted);
  font-weight: 600;
}

.modal-specs dd {
  color: var(--ink);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--line);
  background: var(--bg);
}

/* Responsive Breakpoints */
@media (min-width: 1181px) {
  .telemetry-deck .section-head,
  .ops-deck .section-head {
    min-height: 68px;
  }
}

@media (max-width: 1180px) {
  .telemetry-deck {
    grid-template-columns: 1fr;
  }

  .telemetry-main {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .ops-deck {
    grid-template-columns: 1fr;
  }

  .schedule-column {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 780px) {
  .top-bar {
    position: static;
  }

  .top-bar-inner {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
  }

  .top-controls {
    width: 100%;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .override-lock-btn {
    width: 100%;
    justify-content: center;
  }

  .sheet-shell {
    padding: var(--space-3);
    gap: var(--space-4);
  }

  .sheet-section {
    scroll-margin-top: 16px;
  }

  .section-head {
    padding: var(--space-3) var(--space-4);
  }

  .metric-toggle-bar,
  .chart-frame,
  .setpoint-list,
  .setpoint-actions,
  .panel-note,
  .schedule-visual,
  .control-block,
  .harvest-totals,
  .harvest-item {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .bay-selector {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bay-tab {
    min-height: 44px;
    justify-content: space-between;
  }

  .telemetry-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-cell:nth-child(2) {
    border-right: none;
  }

  .summary-cell:nth-child(1),
  .summary-cell:nth-child(2) {
    border-bottom: 1px solid var(--line);
  }

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

  .control-block:first-child {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .focus-metric-wrap {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }

  .lot-bay {
    display: block;
    margin-top: 2px;
  }

  /* Compact ledger table with sticky first column on mobile */
  #bay-ledger-table th,
  #bay-ledger-table td {
    padding: 10px 12px;
    font-size: 0.8rem;
  }

  #bay-ledger-table th:first-child,
  #bay-ledger-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
    border-right: 1px solid var(--line);
    min-width: 138px;
  }

  #bay-ledger-table th:first-child {
    background: var(--bg);
  }

  #bay-ledger-table .ledger-row.is-selected td:first-child {
    background: #eef5f0;
  }

  /* Stacked card layout for alert log on mobile */
  .alert-table thead {
    display: none;
  }

  .alert-table,
  .alert-table tbody {
    display: block;
    width: 100%;
  }

  .alert-table tr {
    display: grid;
    grid-template-columns: auto auto auto minmax(0, 1fr);
    gap: 6px 10px;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--line);
  }

  .alert-table tbody tr:last-child {
    border-bottom: none;
  }

  .alert-table td {
    display: block;
    padding: 0;
    border-bottom: none;
  }

  .alert-table td:nth-child(1) {
    font-size: 0.75rem;
    color: var(--ink-muted);
  }

  .alert-table td:nth-child(3) {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--emerald-deep);
  }

  .alert-table td:nth-child(4) {
    font-weight: 600;
    font-size: 0.82rem;
    text-align: right;
  }

  .alert-table td:nth-child(5) {
    grid-column: 1 / -1;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--ink-muted);
    margin-top: 2px;
  }

  .alert-table td:nth-child(6) {
    grid-column: 1 / -1;
    text-align: left;
    margin-top: 4px;
  }

  .alert-table td[colspan] {
    grid-column: 1 / -1;
    text-align: left;
  }

  .step-btn,
  .seg-btn,
  .btn-primary,
  .btn-secondary,
  .btn-cobalt,
  .btn-subtle,
  .override-lock-btn {
    min-height: 44px;
  }

  .step-btn {
    width: 44px;
  }

  .slider-control {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
