/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #111110;
  --bg-secondary: #1c1c1a;
  --bg-tertiary: #262624;
  --bg-hover: #302f2c;
  --text-primary: #ede9e3;
  --text-secondary: #a8a29e;
  --text-muted: #8a857e;
  --accent: #86efac;
  --accent-dim: #4ade80;
  --accent-bg: rgba(134, 239, 172, 0.08);
  --border: #2e2d2a;
  --danger: #f87171;
  --warning: #fbbf24;
  --info: #67e8f9;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.25);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --accent-glow: rgba(134, 239, 172, 0.22);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-accent: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
  --status-active-bg: rgba(134, 239, 172, 0.12);
  --status-active-fg: #86efac;
  --status-quarantine-bg: rgba(251, 191, 36, 0.12);
  --status-quarantine-fg: #fbbf24;
  --status-destroyed-bg: rgba(248, 113, 113, 0.12);
  --status-destroyed-fg: #f87171;
  --status-distributed-bg: rgba(103, 232, 249, 0.12);
  --status-distributed-fg: #67e8f9;
  --late-color: #fb923c;
  --grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

[data-theme="light"] {
  --bg-primary: #fafaf7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f4f3ee;
  --bg-hover: #ecebe4;
  --text-primary: #0a0f0c;
  --text-secondary: rgba(10, 15, 12, 0.66);
  --text-muted: rgba(10, 15, 12, 0.58);
  --accent: #16a34a;
  --accent-dim: #15803d;
  --accent-bg: rgba(22, 163, 74, 0.08);
  --accent-glow: rgba(22, 163, 74, 0.22);
  --border: rgba(15, 23, 18, 0.08);
  --danger: #b91c1c;
  --warning: #d97706;
  --info: #0e7490;
  --shadow: 0 16px 50px -28px rgba(15, 23, 18, 0.18);
  --shadow-sm: 0 1px 3px rgba(15, 23, 18, 0.06);
  --status-active-bg: rgba(22, 163, 74, 0.08);
  --status-active-fg: #15803d;
  --status-quarantine-bg: rgba(217, 119, 6, 0.08);
  --status-quarantine-fg: #b45309;
  --status-destroyed-bg: rgba(220, 38, 38, 0.08);
  --status-destroyed-fg: #dc2626;
  --status-distributed-bg: rgba(8, 145, 178, 0.08);
  --status-distributed-fg: #0e7490;
  --late-color: #c2410c;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  background-image: var(--grain);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Loading === */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
.loading-content { text-align: center; }
.logo-text { font-family: var(--font-heading); font-size: 2.5rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.04em; }
.logo-text .accent { color: var(--accent); }
.loading-spinner {
  width: 32px; height: 32px; margin: 20px auto;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Auth Page === */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.auth-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-container h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  margin-bottom: 8px;
  letter-spacing: -0.04em;
}
.auth-container .subtitle {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 0.95rem;
}
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.auth-tabs button {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}
.auth-tabs button.active {
  background: var(--accent);
  color: #111110;
  font-weight: 600;
}

/* === Forms === */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}
.form-group textarea { resize: vertical; min-height: 80px; }

.char-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
}
.char-count.valid { color: var(--accent); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: -0.01em;
}
.btn-primary {
  background: var(--accent);
  color: #111110;
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-dim);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--accent-glow);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}
.btn-danger {
  background: rgba(248, 113, 113, 0.1);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.25);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.18); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; justify-content: center; }

/* === Layout === */
.app-layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 250px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}
.sidebar.collapsed {
  width: 0;
  border-right: none;
}
.sidebar.collapsed .sidebar-header h1,
.sidebar.collapsed .sidebar-nav,
.sidebar.collapsed .sidebar-footer {
  opacity: 0;
  pointer-events: none;
}
.sidebar.collapsed .sidebar-header {
  justify-content: center;
}
.sidebar.collapsed .sidebar-toggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 101;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  opacity: 1;
  pointer-events: auto;
  transform: rotate(180deg);
}
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header h1 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: -0.03em;
}
.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius);
  transition: all 0.2s;
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.sidebar-nav {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 400;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 500;
  border-left: 2px solid var(--accent);
}
.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }
.nav-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: currentColor;
  opacity: 0.85;
}
.nav-item.active .nav-item-icon { opacity: 1; }
.nav-item-label { flex: 1; min-width: 0; }
.nav-section {
  margin-top: 4px;
}
.nav-section-label {
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 14px 14px 4px;
  letter-spacing: 0.08em;
  font-weight: 600;
  font-family: var(--font-heading);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}
.nav-section-label:hover {
  color: var(--text-secondary);
}
.nav-section-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.nav-section-label.collapsed .nav-section-arrow {
  transform: rotate(-90deg);
}
.nav-section-text { flex: 1; }
.nav-section-items {
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.25s ease;
}
.nav-section-items.collapsed {
  max-height: 0;
}
.page-info-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}
.page-info-icon {
  color: var(--accent);
  font-size: 1.1rem;
  flex-shrink: 0;
  line-height: 1.3;
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}
.sidebar-footer .user-name {
  color: var(--text-primary);
  font-weight: 500;
  display: block;
}
.sidebar-footer .user-role {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: capitalize;
}
.logout-btn {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  padding: 0;
}
.logout-btn:hover { text-decoration: underline; }

.main-content {
  flex: 1;
  margin-left: 250px;
  padding: 32px 36px;
  transition: margin-left 0.25s ease;
}
.sidebar.collapsed ~ .main-content {
  margin-left: 0;
}

/* === Page Header === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.page-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* === Stats Cards === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  font-family: var(--font-heading);
}
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--text-primary);
  letter-spacing: -0.03em;
}
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }

/* === Stage Pipeline === */
.pipeline-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
}
.pipeline-section h3 {
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pipeline-flow {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 4px;
}
.pipeline-stage {
  flex: 1;
  min-width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.pipeline-stage-inner {
  width: 100%;
  padding: 14px 6px;
  text-align: center;
  border-radius: var(--radius);
  transition: all 0.2s;
  position: relative;
}
.pipeline-stage-inner:hover {
  transform: translateY(-2px);
}
.pipeline-stage-clickable .pipeline-stage-inner:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.pipeline-stage-count {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}
.pipeline-stage-name {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  line-height: 1.2;
}
.pipeline-stage-days {
  font-size: 0.65rem;
  margin-top: 4px;
  opacity: 0.7;
  font-family: var(--font-mono);
}
.pipeline-arrow {
  display: flex;
  align-items: center;
  color: var(--accent-dim);
  font-size: 0.9rem;
  flex-shrink: 0;
  padding: 0 2px;
}
.pipeline-total-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 16px;
  background: var(--bg-tertiary);
}
.pipeline-total-segment {
  height: 100%;
  transition: width 0.4s ease;
}

/* === Dashboard Grid === */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}
.dash-grid > * {
  min-width: 0;
}
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* === Status Breakdown === */
.status-breakdown {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.status-breakdown h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
}
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.status-row:last-child { border-bottom: none; }
.status-row-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-row-value {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* === Activity Feed === */
.activity-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
}
.activity-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
}
.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  flex-shrink: 0;
}
.activity-text {
  flex: 1;
  font-size: 0.88rem;
}
.activity-text strong { color: var(--text-primary); }
.activity-text .activity-comment {
  display: block;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 2px;
  font-style: italic;
}
.activity-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* === Data Table === */
.table-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-toolbar {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.table-toolbar input,
.table-toolbar select {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
}
.table-toolbar input { flex: 1; min-width: 200px; }
.table-toolbar input:focus,
.table-toolbar select:focus { border-color: var(--accent); }

table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}
tr:hover td { background: var(--bg-hover); }
tr { cursor: pointer; }
.mono { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: -0.02em; }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.status-badge {
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.status-active { background: var(--status-active-bg); color: var(--status-active-fg); }
.status-quarantine { background: var(--status-quarantine-bg); color: var(--status-quarantine-fg); }
.status-destroyed { background: var(--status-destroyed-bg); color: var(--status-destroyed-fg); }
.status-distributed { background: var(--status-distributed-bg); color: var(--status-distributed-fg); }

/* === Plant Detail === */
.plant-header {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}
.plant-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}
.plant-info h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  margin-bottom: 4px;
  letter-spacing: -0.03em;
}
.plant-qr-code {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--accent);
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.plant-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.plant-meta-item {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.plant-meta-item strong {
  color: var(--text-primary);
}
.plant-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* === Stage Stepper === */
.stage-stepper {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  overflow-x: auto;
}
.stage-stepper h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
}
.stepper-track {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: max-content;
}
.stepper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  position: relative;
}
.stepper-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  border: 2px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  z-index: 1;
}
.stepper-step.completed .stepper-circle {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg-primary);
}
.stepper-step.current .stepper-circle {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.3);
}
.stepper-name {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
  max-width: 80px;
}
.stepper-step.completed .stepper-name,
.stepper-step.current .stepper-name {
  color: var(--text-primary);
}
.stepper-line {
  width: 30px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
}
.stepper-line.completed { background: var(--accent); }

/* === Audit Trail === */
.audit-trail {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.audit-trail h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
}
.audit-entry {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.audit-entry:last-child { margin-bottom: 0; }
.audit-entry-backdated {
  border-left: 3px solid var(--warning);
}
.audit-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}
.audit-transition {
  font-size: 0.88rem;
  font-weight: 500;
}
.audit-arrow { color: var(--text-muted); margin: 0 6px; }
.audit-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.audit-comment {
  font-size: 0.88rem;
  color: var(--text-secondary);
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* === QR Display === */
.qr-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.qr-display img {
  width: 160px;
  height: 160px;
  border-radius: var(--radius);
  background: white;
  padding: 8px;
}

/* Latest Photo in Plant Header */
.plant-latest-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.plant-latest-photo img {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  transition: opacity 0.15s;
}
.plant-latest-photo img:hover {
  opacity: 0.85;
}
.plant-latest-photo-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 180px;
}
.plant-latest-photo-placeholder {
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Photo Lightbox */
.photo-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: pointer;
  padding: 20px;
}
.photo-lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 90vw;
  max-height: 90vh;
}
.photo-lightbox-content img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
}
.photo-lightbox-caption {
  color: #fff;
  font-size: 0.9rem;
  text-align: center;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 64px rgba(0,0,0,0.4);
}
.modal h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* === Transition Warning Banners === */
.transition-banner {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
}
.transition-banner-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.transition-banner-content {
  flex: 1;
}
.transition-banner-content strong {
  display: block;
  margin-bottom: 4px;
}
.transition-banner-content p {
  margin-bottom: 8px;
}
.transition-banner-meta {
  display: flex;
  gap: 16px;
  font-size: 0.82rem;
  opacity: 0.85;
}
.transition-pdf-ref {
  margin-top: 8px;
  font-size: 0.78rem;
  font-style: italic;
  opacity: 0.75;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.transition-early {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--warning);
}
.transition-late {
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.3);
  color: var(--late-color);
}
.transition-special {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--info);
}
.transition-blocked {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
}
.btn-warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.btn-warning:hover { background: rgba(245, 158, 11, 0.3); }
.btn-warning:disabled { opacity: 0.5; cursor: not-allowed; }
.warning-label { color: var(--warning) !important; }
.days-warning { color: var(--warning); }
.days-blocked { color: var(--danger); }
.days-expected {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: 4px;
}
.attention-section {
  background: var(--bg-secondary);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.attention-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--info);
}
.attention-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  cursor: pointer;
}
.attention-item:last-child { border-bottom: none; }
.attention-item:hover { color: var(--accent); }
.attention-days {
  font-family: var(--font-mono);
  color: var(--info);
  font-size: 0.82rem;
}
.audit-warning-block {
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid var(--warning);
  padding: 8px 12px;
  margin-top: 8px;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: pre-line;
}

/* === Overdue Alert === */
.overdue-section {
  background: var(--bg-secondary);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
}
.overdue-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--danger);
}
.overdue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  cursor: pointer;
}
.overdue-item:last-child { border-bottom: none; }
.overdue-item:hover { color: var(--accent); }
.overdue-days {
  font-family: var(--font-mono);
  color: var(--danger);
  font-size: 0.82rem;
}

/* === Stages Reference === */
.stage-ref-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.stage-ref-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.stage-ref-header .stage-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--bg-primary);
}
.stage-ref-header h4 { font-size: 1rem; }
.stage-ref-duration {
  margin-left: auto;
  min-width: 130px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
}
.stage-ref-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* === Scanner === */
.scanner-container {
  max-width: 500px;
  margin: 0 auto;
}
.scanner-video-wrap {
  position: relative;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 1;
  margin-bottom: 20px;
}
.scanner-video-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scanner-crosshair {
  width: 200px;
  height: 200px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  opacity: 0.6;
}
.scanner-status {
  text-align: center;
  padding: 12px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.scanner-manual {
  margin-top: 20px;
  text-align: center;
}
.scanner-manual input {
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1rem;
  text-align: center;
  letter-spacing: 2px;
  width: 220px;
  outline: none;
}
.scanner-manual input:focus { border-color: var(--accent); }
.scanner-manual p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* === Quick Actions === */
.quick-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state p { margin-top: 8px; }

/* === Error Message === */
.error-msg {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.success-msg {
  background: rgba(74, 222, 128, 0.1);
  color: var(--accent);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
}

/* === Top Bar (Alert Bell) === */
.top-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 8px;
}
.alert-bell {
  position: relative;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 7px 10px;
  border-radius: var(--radius);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
}
.alert-bell-icon { display: inline-flex; align-items: center; }
.alert-bell:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.alert-bell-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  font-family: var(--font-mono);
}

/* === Critical Banner === */
.critical-banner {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--danger);
}
.critical-banner a {
  color: var(--danger);
  text-decoration: underline;
}
.banner-dismiss {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  opacity: 0.7;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
}
.banner-dismiss:hover { opacity: 1; background: rgba(239, 68, 68, 0.08); }

/* === Alerts Panel === */
.alerts-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 900;
}
.alerts-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 90vw;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 901;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.25s ease;
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.alerts-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.alerts-panel-header h3 { font-size: 1.1rem; }
.alerts-panel-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
}
.alerts-panel-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.alerts-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.alert-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border-left: 3px solid var(--border);
}
.alert-card:last-child { margin-bottom: 0; }
.alert-critical { border-left-color: var(--danger); }
.alert-warning { border-left-color: var(--warning); }
.alert-info { border-left-color: var(--info); }
.alert-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.alert-card-type {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.alert-critical .alert-card-type { color: var(--danger); }
.alert-warning .alert-card-type { color: var(--warning); }
.alert-info .alert-card-type { color: var(--info); }
.alert-card-plant {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.alert-card-detail {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.alert-card .btn-sm {
  font-size: 0.78rem;
  padding: 4px 10px;
}

/* === Strain Dashboard === */
.strain-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
}
.strain-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.strain-section h3:hover { color: var(--text-primary); }
.strain-matrix {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.strain-matrix th {
  padding: 8px 10px;
  font-size: 0.72rem;
  text-align: center;
  white-space: nowrap;
}
.strain-matrix td {
  padding: 8px 10px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.strain-matrix td:first-child {
  text-align: left;
  font-family: var(--font-body);
  font-weight: 500;
}
.strain-cell {
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}
.strain-cell:hover {
  background: var(--bg-hover);
  transform: scale(1.1);
}
.strain-cell.dimmed {
  opacity: 0.3;
}

/* === Environmental Readings === */
.env-readings {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.env-reading {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.env-reading .env-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.env-reading .env-value {
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 600;
}
.audit-env-data {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 0.8rem;
}
.audit-env-data span {
  color: var(--text-muted);
}
.audit-env-data strong {
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* === Environmental Fields in Advance Modal === */
.env-fields-section {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}
.env-fields-section h4 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.env-fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.env-field-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.env-field-group input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  outline: none;
}
.env-field-group input:focus { border-color: var(--accent); }

/* === Lab Reports === */
.lab-reports-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}
.lab-reports-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.lab-reports-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lab-report-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  gap: 12px;
}
.lab-report-info {
  flex: 1;
  min-width: 0;
}
.lab-report-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lab-report-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.lab-report-notes {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 2px;
}
.lab-attach-link {
  color: var(--info);
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.lab-attach-link:hover { text-decoration: underline; }

/* === Bulk Register Preview === */
.bulk-preview {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.6;
}

/* === Danger Text === */
.danger-text { color: var(--danger); }

/* === Mobile Bottom Nav === */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 4px 0;
  padding-bottom: env(safe-area-inset-bottom, 4px);
}
.mobile-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.68rem;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 48px;
  justify-content: center;
}
.mobile-nav-item .nav-icon { font-size: 1.2rem; }
.mobile-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}
.mobile-nav-item.active {
  color: var(--accent);
}
.mobile-nav-item:hover { color: var(--text-primary); }

/* === Mobile Quick Advance Bottom Sheet === */
.mobile-bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.bottom-sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.bottom-sheet {
  position: relative;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}
.bottom-sheet h3 {
  font-size: 1.2rem;
  margin-bottom: 16px;
}
.quick-advance-btn {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  min-height: 56px;
  justify-content: center;
}
.quick-advance-success {
  text-align: center;
  padding: 32px 0;
}
.quick-advance-success .checkmark {
  font-size: 3rem;
  margin-bottom: 12px;
}
.quick-advance-success p {
  font-size: 1rem;
  color: var(--text-secondary);
}

/* === Bulk Advance === */
.bulk-selection-bar {
  position: fixed;
  bottom: 0;
  left: 250px;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--accent);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 90;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
}
.bulk-summary-group {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.bulk-summary-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.bulk-summary-items {
  margin-top: 8px;
  max-height: 120px;
  overflow-y: auto;
}
.bulk-summary-item {
  padding: 4px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.bulk-summary-item:last-child {
  border-bottom: none;
}
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--bg-tertiary);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: solid var(--bg-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === Theme Toggle === */
.theme-toggle {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
  padding: 0;
}
.theme-toggle svg { display: block; }
.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

[data-theme="light"] .stepper-step.current .stepper-circle {
  box-shadow: 0 0 12px rgba(22, 163, 74, 0.25);
}
[data-theme="light"] .bulk-selection-bar {
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}

html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color 0.3s, color 0.3s, border-color 0.3s !important;
}

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-bottom: 80px;
  }
  .mobile-nav { display: block; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .plant-header-top { flex-direction: column; }
  .table-toolbar { flex-direction: column; }
  .table-toolbar input { min-width: 100%; }

  /* Larger touch targets */
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 36px; }
  .nav-item { min-height: 44px; }

  /* Card-based table on mobile */
  .table-container table thead { display: none; }
  .table-container table,
  .table-container table tbody,
  .table-container table tr,
  .table-container table td {
    display: block;
    width: 100%;
  }
  .table-container table tr {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    position: relative;
  }
  .table-container table td {
    padding: 3px 0;
    border-bottom: none;
    font-size: 0.85rem;
  }
  .table-container table td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: block;
  }

  /* Full-screen modals on mobile */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    max-width: 100%;
    max-height: 100%;
    border-radius: 16px 16px 0 0;
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  }

  /* Alerts panel full width */
  .alerts-panel { width: 100%; max-width: 100%; }

  /* Pipeline scroll hint */
  .pipeline-flow { padding-bottom: 8px; }

  /* Env fields single column */
  .env-fields-grid { grid-template-columns: 1fr; }

  /* Bulk bar above mobile nav */
  .bulk-selection-bar {
    left: 0;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }

  /* Strain matrix smaller text */
  .strain-matrix th { font-size: 0.65rem; padding: 6px 4px; }
  .strain-matrix td { font-size: 0.75rem; padding: 6px 4px; }

  /* Page header stack on mobile */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header .plant-actions,
  .page-header > div { width: 100%; }
  .page-header .btn { width: 100%; }

  /* Analytics responsive */
  .analytics-tabs { flex-wrap: wrap; }
  .analytics-metrics-row { flex-direction: column; }
  .funnel-layout { flex-direction: column; }
  .funnel-losses { border-left: none; border-top: 1px solid var(--border); padding-left: 0; padding-top: 16px; }
  .analytics-filters { flex-direction: column; }
  .analytics-filters select { width: 100%; }
}

/* === Analytics === */
.analytics-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 4px 4px 6px;
}
.analytics-section-label + .analytics-tabs { margin-bottom: 16px; }
.analytics-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
}
.analytics-tab {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}
.analytics-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.analytics-tab.active {
  background: var(--accent);
  color: #111110;
  font-weight: 600;
}

.analytics-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}
.analytics-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.analytics-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.analytics-filters select {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  min-width: 180px;
}
.analytics-filters select:focus { border-color: var(--accent); }

.analytics-metrics-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.analytics-metric {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.metric-value {
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* Risk tiles — larger € KPI cards on Risk tab */
.risk-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.risk-tile {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.risk-tile-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.risk-tile-value {
  font-size: 1.55rem;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.risk-tile-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.risk-tile.risk-danger { border-left-color: var(--danger); }
.risk-tile.risk-danger .risk-tile-value { color: var(--danger); }
.risk-tile.risk-warning { border-left-color: var(--warning); }
.risk-tile.risk-warning .risk-tile-value { color: var(--warning); }
.risk-tile.risk-total {
  border-left-color: var(--accent);
  background: var(--bg-secondary);
}
.risk-tile.risk-total .risk-tile-value { color: var(--accent); }

/* Environmental chart containers */
.env-charts-section,
.stage-duration-section {
  margin-bottom: 24px;
}
.env-charts-section .u-wrap {
  min-height: 60px;
  overflow: hidden;
}
.env-charts-section .u-wrap .u-legend {
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.env-timelapse {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.env-timelapse-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 3px 8px;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.1;
  cursor: pointer;
}
.env-timelapse-btn:hover { color: var(--text); }
.env-timelapse-btn.is-active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}
.env-timelapse-range { font-weight: 600; }
.env-timelapse-bucket { font-size: 0.66rem; opacity: 0.7; }

/* Funnel layout */
.funnel-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.funnel-container {
  flex: 2;
  min-width: 0;
}
.funnel-losses {
  flex: 1;
  min-width: 200px;
  border-left: 1px solid var(--border);
  padding-left: 24px;
}
.loss-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.loss-item:last-child { border-bottom: none; }
.loss-stage {
  font-size: 0.85rem;
  font-weight: 500;
  display: block;
  margin-bottom: 4px;
}
.loss-counts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Strain comparison table */
.strain-comparison-table {
  width: 100%;
  border-collapse: collapse;
}
.strain-comparison-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.strain-comparison-table td {
  padding: 10px 12px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}
.strain-comparison-table tr:hover td { background: var(--bg-hover); }

/* ============================================================
   NEW FEATURE STYLES
   Genetics | Spaces | Products | POS | Traceability |
   Harvest/Drying | Tabs | Messages | Empty States | Responsive
   ============================================================ */

/* === Radio buttons in modals === */
input[type="radio"] {
  appearance: auto;
  -webkit-appearance: auto;
  width: auto !important;
  height: auto !important;
}

/* === Success Message === */
.success-msg {
  background: rgba(74, 222, 128, 0.1);
  color: var(--accent);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
  border: 1px solid rgba(74, 222, 128, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
}
.success-msg::before {
  content: '\2713';
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

/* === Empty States (Enhanced) === */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
  display: block;
}
.empty-state h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 360px;
  margin: 0 auto 20px;
  line-height: 1.6;
}
.empty-state .btn {
  margin-top: 4px;
}

/* === Section Tabs (.section-tabs) === */
.section-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  overflow-x: auto;
}
.section-tab {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
  text-align: center;
}
.section-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.section-tab.active {
  background: var(--accent);
  color: #111110;
  font-weight: 600;
}
.section-tab .tab-count {
  display: inline-block;
  margin-left: 6px;
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}
.section-tab.active .tab-count {
  background: rgba(0, 0, 0, 0.2);
}

/* ============================================================
   1. GENETICS CATALOG
   ============================================================ */

/* --- Section Header with accent border --- */
.genetics-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--accent);
}
.genetics-section-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}
.genetics-section-header .section-count {
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-weight: 400;
}

/* --- Strain Cards --- */
.strain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.strain-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.strain-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* Type indicator gradient bar at top of card */
.strain-card-type-bar {
  height: 4px;
  width: 100%;
}
.strain-card-type-bar.indica {
  background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}
.strain-card-type-bar.sativa {
  background: linear-gradient(90deg, #f97316, #fb923c);
}
.strain-card-type-bar.hybrid {
  background: linear-gradient(90deg, #22c55e, #4ade80);
}
.strain-card-type-bar.ruderalis {
  background: linear-gradient(90deg, #6b7280, #9ca3af);
}

.strain-card-body {
  padding: 16px;
}
.strain-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.strain-card-breeder {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.strain-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* Strain type badge */
.strain-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.strain-type-badge.indica {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}
.strain-type-badge.sativa {
  background: rgba(249, 115, 22, 0.15);
  color: #fb923c;
}
.strain-type-badge.hybrid {
  background: rgba(74, 222, 128, 0.15);
  color: var(--accent);
}
.strain-type-badge.ruderalis {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
}

/* Difficulty badges */
.difficulty-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.difficulty-badge.easy {
  background: rgba(74, 222, 128, 0.15);
  color: var(--accent);
}
.difficulty-badge.moderate {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}
.difficulty-badge.hard {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}
.difficulty-badge.expert {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

.strain-card-stats {
  display: flex;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}
.strain-card-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.strain-card-stat .stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.strain-card-stat .stat-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

.strain-card-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
}

/* --- Breeder Cards --- */
.breeder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.breeder-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.breeder-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.breeder-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.breeder-card-flag {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.breeder-card-info {
  flex: 1;
  min-width: 0;
}
.breeder-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breeder-card-country {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.breeder-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
}
.breeder-card-stats {
  display: flex;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.breeder-card-stat {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.breeder-card-stat strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
}
.breeder-card-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

/* Utility: two-column form row */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ============================================================
   2. SPACES / LOCATIONS (Tree View)
   ============================================================ */

.spaces-tree {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* --- Room Cards (top level) --- */
.room-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.room-card:hover {
  box-shadow: var(--shadow);
}
.room-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.room-card-header:hover {
  background: var(--bg-hover);
}
.room-card-header h4 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.room-card-header .room-icon {
  font-size: 1.1rem;
}
.room-card-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s;
  padding: 4px;
}
.room-card-toggle.expanded {
  transform: rotate(180deg);
}
.room-card-body {
  padding: 0;
}
.room-card-meta {
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.room-card-meta strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* --- Zone Level --- */
.zone-level {
  padding-left: 20px;
  border-left: 3px solid var(--accent);
  margin-left: 20px;
  position: relative;
}
.zone-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.zone-item:last-child {
  border-bottom: none;
}
.zone-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 50%;
  width: 16px;
  height: 2px;
  background: var(--accent);
}
.zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.zone-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Zone pill badge */
.zone-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.zone-pill.veg {
  background: rgba(59, 130, 246, 0.12);
  color: var(--info);
}
.zone-pill.flower {
  background: rgba(168, 85, 247, 0.12);
  color: #a855f7;
}
.zone-pill.dry {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}
.zone-pill.cure {
  background: rgba(236, 72, 153, 0.12);
  color: #ec4899;
}
.zone-pill.mother {
  background: rgba(74, 222, 128, 0.12);
  color: var(--accent);
}

/* --- Tray Level --- */
.tray-level {
  padding-left: 20px;
  border-left: 2px dashed var(--border);
  margin-left: 16px;
  margin-top: 8px;
}
.tray-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
}

/* Tray chip */
.tray-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.tray-chip:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text-primary);
}
.tray-chip .tray-count {
  background: var(--bg-primary);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
}
.tray-chip.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}

/* Connecting lines between tree levels */
.tree-connector {
  position: relative;
  padding-left: 20px;
}
.tree-connector::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.tree-connector::after {
  content: '';
  position: absolute;
  left: 0;
  top: 20px;
  width: 16px;
  height: 2px;
  background: var(--border);
}
.tree-connector:last-child::before {
  bottom: calc(100% - 20px);
}

/* ============================================================
   3. PRODUCTS / PROCESSING
   ============================================================ */

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--accent);
  padding: 20px;
  transition: transform 0.2s, box-shadow 0.3s, border-color 0.2s;
  position: relative;
  overflow: hidden;
}
.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(74, 222, 128, 0.1), var(--shadow);
}

/* Product type accent colors */
.product-card.type-flower { border-left-color: #a855f7; }
.product-card.type-extract { border-left-color: #f59e0b; }
.product-card.type-edible { border-left-color: #22c55e; }
.product-card.type-topical { border-left-color: #3b82f6; }
.product-card.type-preroll { border-left-color: #ec4899; }
.product-card.type-tincture { border-left-color: #14b8a6; }

.product-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}
.product-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}
.product-card-sku {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 2px;
}

/* Product type badge */
.product-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.product-type-badge.type-flower {
  background: rgba(168, 85, 247, 0.12);
  color: #a855f7;
}
.product-type-badge.type-extract {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}
.product-type-badge.type-edible {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
}
.product-type-badge.type-topical {
  background: rgba(59, 130, 246, 0.12);
  color: var(--info);
}
.product-type-badge.type-preroll {
  background: rgba(236, 72, 153, 0.12);
  color: #ec4899;
}
.product-type-badge.type-tincture {
  background: rgba(20, 184, 166, 0.12);
  color: #14b8a6;
}

.product-card-details {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.product-card-detail {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.product-card-detail .detail-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.product-card-detail .detail-value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

/* Stock level indicator bar */
.stock-level {
  margin-top: 12px;
}
.stock-level-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.78rem;
}
.stock-level-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.stock-level-value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}
.stock-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}
.stock-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.4s ease, background-color 0.3s;
}
.stock-bar-fill.stock-medium {
  background: var(--warning);
}
.stock-bar-fill.stock-low {
  background: var(--danger);
}

/* Low stock warning state */
.product-card.low-stock {
  border-color: rgba(239, 68, 68, 0.3);
}
.product-card.low-stock::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-left: 24px solid transparent;
  border-top: 24px solid var(--danger);
}
.low-stock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  animation: pulse-subtle 2s ease-in-out infinite;
}
@keyframes pulse-subtle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Product card action buttons row */
.product-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

/* Form row variants */
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

/* Modal header with flex layout */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h3 {
  margin: 0;
}

/* Lab result card */
.lab-result-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
}
.lab-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.lab-result-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.lab-result-lab {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.lab-result-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.lab-result-cert {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Badge color variants */
.badge-thc {
  background: rgba(74, 222, 128, 0.15);
  color: var(--accent);
}
.badge-cbd {
  background: rgba(59, 130, 246, 0.15);
  color: var(--info);
}
.badge-terps {
  background: rgba(232, 121, 249, 0.15);
  color: #e879f9;
}
.badge-muted {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}
.badge-accent {
  background: var(--accent-bg);
  color: var(--accent);
}

/* Checkbox label inline layout */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* No-results text for empty modals */
.text-muted {
  color: var(--text-muted);
}

/* Product source detail */
.product-card-source {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   4. DISTRIBUTIONS
   ============================================================ */

.distribution-status-pending {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
}
.distribution-status-shipped {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
}
.distribution-status-acknowledged {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ============================================================
   4b. FACILITY MAP
   ============================================================ */

/* === Facility Map === */
.map-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.map-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.map-header-left h2 { margin: 0; }
.map-header-actions {
  display: flex;
  gap: 8px;
}
.map-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.88rem;
}
.map-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  height: calc(100vh - 150px);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.map-container {
  background: var(--bg-primary);
  overflow: hidden;
  cursor: grab;
  position: relative;
}
.map-container:active { cursor: grabbing; }
.map-toolbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.toolbar-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-right: 2px;
}
.map-tool {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 14px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}
.map-tool:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
  background: var(--bg-secondary);
}
.map-tool.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}
.map-tool-danger {
  color: var(--danger) !important;
}
.map-tool-danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}
.map-tool:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.toolbar-separator {
  width: 1px;
  background: var(--border);
  margin: 0 6px;
  align-self: stretch;
}

/* Sidebar */
.map-sidebar {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 0;
}
.map-sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.map-sidebar-section:last-child { border-bottom: none; }
.map-sidebar-heading {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.map-sidebar-stats {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
}
.map-stat {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  margin-right: 6px;
}
.map-stat:last-child { margin-right: 0; }
.map-stat-val {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.map-stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Capacity bar */
.map-capacity-bar-wrapper { margin-top: 4px; }
.map-capacity-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.map-capacity-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}
.map-capacity-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}

/* Element tree */
.map-tree { font-size: 0.82rem; }
.map-tree-room { margin-bottom: 4px; }
.map-tree-zone { padding-left: 16px; }
.map-tree-tray { padding-left: 32px; }
.map-tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.map-tree-clickable {
  cursor: pointer;
  transition: background 0.15s;
}
.map-tree-clickable:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.map-tree-icon { font-size: 0.9rem; flex-shrink: 0; }
.map-tree-cap {
  font-size: 0.72rem;
  font-family: var(--font-body);
  color: var(--text-muted);
  margin-left: auto;
}
.map-tree-bar {
  width: 100%;
  height: 3px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  margin-top: 3px;
  overflow: hidden;
}
.map-tree-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}

/* Legend */
.map-legend-items { display: flex; flex-direction: column; gap: 2px; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Tray grid modal */
.tray-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.tray-modal-header h3 { margin: 0; }
.tray-modal-cap {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: var(--font-body);
}
.tray-modal-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}
.tray-modal-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}
.tray-capacity-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 4px 0 8px;
}
.tray-grid {
  display: grid;
  gap: 4px;
}
.tray-cell {
  aspect-ratio: 1;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 60px;
  min-height: 60px;
}
.tray-cell-occupied {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}
.tray-cell-occupied:hover {
  border-color: var(--text-muted);
  background: var(--bg-secondary);
}
.tray-cell-empty {
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
}
.tray-cell-empty:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.tray-cell-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-bottom: 4px;
}
.tray-cell-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.tray-cell-status {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.tray-cell-plus {
  font-size: 1.2rem;
  color: var(--text-muted);
  line-height: 1;
}
.tray-cell-hint {
  font-size: 0.6rem;
  color: var(--border);
  margin-top: 2px;
}

/* Plant picker */
.plant-picker-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 8px;
}
.plant-picker-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.plant-picker-item:last-child { border-bottom: none; }
.plant-picker-item:hover { background: var(--bg-tertiary); }
.plant-picker-placed { opacity: 0.6; }
.plant-picker-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}
.plant-picker-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Plant cell actions */
.plant-cell-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Minimap */
.map-minimap {
  width: 260px;
  height: 160px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Tooltip */
.map-plant-tooltip {
  position: absolute;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.78rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  line-height: 1.5;
}

/* Zoom controls */
.map-zoom-controls {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  align-items: center;
  z-index: 10;
}
.map-zoom-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  border-radius: var(--radius);
  cursor: pointer;
}
.map-zoom-btn[data-action="fit"] {
  width: auto;
  padding: 0 10px;
  font-size: 0.75rem;
}
.map-zoom-level {
  min-width: 44px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  user-select: none;
}

@media (max-width: 768px) {
  .map-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .map-container {
    min-height: 400px;
  }
  .map-sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .tray-cell { min-width: 48px; min-height: 48px; }
}

/* Traceability lookup card */
.trace-lookup-card {
  max-width: 600px;
}
.trace-lookup-card h3 {
  margin-bottom: 16px;
}
.trace-lookup-form {
  display: flex;
  gap: 8px;
}
.trace-lookup-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  outline: none;
}
.trace-results-container {
  margin-top: 24px;
}

/* Sales History modal */
.modal-wide {
  max-width: 700px;
}
.modal-scroll {
  max-height: 400px;
  overflow-y: auto;
}
/* Trace event / sale rows in trace results */
.trace-event-row {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.trace-event-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.trace-sale-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.trace-event-scroll {
  max-height: 300px;
  overflow-y: auto;
}

/* ============================================================
   5. TRACEABILITY (Timeline)
   ============================================================ */

.trace-timeline {
  max-width: 720px;
  position: relative;
  padding-left: 32px;
}

/* Vertical connecting line */
.trace-timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

/* Timeline node */
.trace-node {
  position: relative;
  margin-bottom: 24px;
}
.trace-node:last-child {
  margin-bottom: 0;
}

/* Node dot (colored circle) */
.trace-node-dot {
  position: absolute;
  left: -32px;
  top: 18px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 3px solid var(--accent);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.trace-node-dot::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* Step-specific dot colors */
.trace-node.step-seed .trace-node-dot { border-color: #22c55e; }
.trace-node.step-seed .trace-node-dot::after { background: #22c55e; }
.trace-node.step-clone .trace-node-dot { border-color: #14b8a6; }
.trace-node.step-clone .trace-node-dot::after { background: #14b8a6; }
.trace-node.step-veg .trace-node-dot { border-color: #3b82f6; }
.trace-node.step-veg .trace-node-dot::after { background: #3b82f6; }
.trace-node.step-flower .trace-node-dot { border-color: #a855f7; }
.trace-node.step-flower .trace-node-dot::after { background: #a855f7; }
.trace-node.step-harvest .trace-node-dot { border-color: #f59e0b; }
.trace-node.step-harvest .trace-node-dot::after { background: #f59e0b; }
.trace-node.step-dry .trace-node-dot { border-color: #f97316; }
.trace-node.step-dry .trace-node-dot::after { background: #f97316; }
.trace-node.step-cure .trace-node-dot { border-color: #ec4899; }
.trace-node.step-cure .trace-node-dot::after { background: #ec4899; }
.trace-node.step-test .trace-node-dot { border-color: #6366f1; }
.trace-node.step-test .trace-node-dot::after { background: #6366f1; }
.trace-node.step-package .trace-node-dot { border-color: #8b5cf6; }
.trace-node.step-package .trace-node-dot::after { background: #8b5cf6; }
.trace-node.step-distribute .trace-node-dot { border-color: #06b6d4; }
.trace-node.step-distribute .trace-node-dot::after { background: #06b6d4; }
.trace-node.step-destroy .trace-node-dot { border-color: var(--danger); }
.trace-node.step-destroy .trace-node-dot::after { background: var(--danger); }

/* Section card with left border */
.trace-node-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-left: 3px solid var(--accent);
  padding: 16px 20px;
  transition: box-shadow 0.2s;
}
.trace-node-card:hover {
  box-shadow: var(--shadow);
}

/* Step-specific card left borders */
.trace-node.step-seed .trace-node-card { border-left-color: #22c55e; }
.trace-node.step-clone .trace-node-card { border-left-color: #14b8a6; }
.trace-node.step-veg .trace-node-card { border-left-color: #3b82f6; }
.trace-node.step-flower .trace-node-card { border-left-color: #a855f7; }
.trace-node.step-harvest .trace-node-card { border-left-color: #f59e0b; }
.trace-node.step-dry .trace-node-card { border-left-color: #f97316; }
.trace-node.step-cure .trace-node-card { border-left-color: #ec4899; }
.trace-node.step-test .trace-node-card { border-left-color: #6366f1; }
.trace-node.step-package .trace-node-card { border-left-color: #8b5cf6; }
.trace-node.step-distribute .trace-node-card { border-left-color: #06b6d4; }
.trace-node.step-destroy .trace-node-card { border-left-color: var(--danger); }
.trace-node.step-events .trace-node-dot { border-color: #6b7280; }
.trace-node.step-events .trace-node-dot::after { background: #6b7280; }
.trace-node.step-events .trace-node-card { border-left-color: #6b7280; }

.trace-node.step-qc .trace-node-dot { border-color: #6366f1; }
.trace-node.step-qc .trace-node-dot::after { background: #6366f1; }
.trace-node.step-qc .trace-node-card { border-left-color: #6366f1; }
.trace-node.step-product .trace-node-dot { border-color: #8b5cf6; }
.trace-node.step-product .trace-node-dot::after { background: #8b5cf6; }
.trace-node.step-product .trace-node-card { border-left-color: #8b5cf6; }

.trace-summary-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
}
.trace-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}
.trace-kpi-value {
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}
.trace-kpi-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.trace-event-comment {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 4px;
}
.env-data {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.trace-node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.trace-node-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}
.trace-node-date {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.trace-node-body {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.trace-node-meta {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}
.trace-meta-item {
  color: var(--text-muted);
}
.trace-meta-item strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* Chain connector (visual bridge between nodes) */
.trace-chain-connector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 4px 0;
  margin-left: -21px;
  color: var(--text-muted);
  font-size: 0.75rem;
  position: relative;
  z-index: 1;
}
.trace-chain-connector::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.trace-chain-connector-line {
  flex: 1;
  height: 1px;
  background: var(--border);
  max-width: 60px;
}

/* ============================================================
   6. HARVEST / DRYING
   ============================================================ */

/* Calculation boxes */
.calc-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.calc-box-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}
.calc-box-header .calc-icon {
  font-size: 1.1rem;
}
.calc-box.highlight {
  border-color: rgba(74, 222, 128, 0.3);
  background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(74, 222, 128, 0.03) 100%);
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.calc-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.calc-field label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Weight fields with unit labels */
.weight-input-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}
.weight-input-group:focus-within {
  border-color: var(--accent);
}
.weight-input-group input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  outline: none;
}
.weight-input-group .weight-unit {
  padding: 8px 12px;
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

/* Calc result highlight */
.calc-result {
  background: var(--accent-bg);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}
.calc-result-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.calc-result-value {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

/* Moisture loss indicator */
.moisture-indicator {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.moisture-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.moisture-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.moisture-percentage {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
}
.moisture-percentage.optimal {
  color: var(--accent);
}
.moisture-percentage.warning {
  color: var(--warning);
}
.moisture-percentage.danger {
  color: var(--danger);
}
.moisture-bar {
  height: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.moisture-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease, background-color 0.3s;
}
.moisture-bar-fill.optimal {
  background: var(--accent);
}
.moisture-bar-fill.warning {
  background: var(--warning);
}
.moisture-bar-fill.danger {
  background: var(--danger);
}
/* Target zone marker on moisture bar */
.moisture-bar-target {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--text-primary);
  z-index: 1;
}
.moisture-bar-target::after {
  content: attr(data-target);
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Harvest summary cards */
.harvest-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.harvest-summary-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}
.harvest-summary-card .summary-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.harvest-summary-card .summary-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.harvest-summary-card.accent .summary-value {
  color: var(--accent);
}

/* ============================================================
   7. RESPONSIVE (New Feature Breakpoints)
   ============================================================ */

@media (max-width: 768px) {
  /* Product grid single column */
  .product-grid {
    grid-template-columns: 1fr;
  }

  /* Strain and breeder grids */
  .strain-grid {
    grid-template-columns: 1fr;
  }
  .breeder-grid {
    grid-template-columns: 1fr;
  }

  /* Section tabs scroll */
  .section-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .section-tab {
    min-width: 100px;
    flex: 0 0 auto;
  }

  /* Spaces tree adjustments */
  .zone-level {
    padding-left: 12px;
    margin-left: 12px;
  }
  .tray-level {
    padding-left: 12px;
    margin-left: 8px;
  }
  .room-card-header {
    padding: 12px 16px;
  }
  .room-card-meta {
    padding: 10px 16px;
    flex-wrap: wrap;
  }

  /* Traceability timeline */
  .trace-timeline {
    padding-left: 24px;
  }
  .trace-timeline::before {
    left: 7px;
  }
  .trace-node-dot {
    left: -24px;
    width: 16px;
    height: 16px;
  }
  .trace-node-dot::after {
    width: 6px;
    height: 6px;
  }
  .trace-node-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .trace-node-meta {
    flex-direction: column;
    gap: 4px;
  }

  /* Harvest/Drying */
  .calc-grid {
    grid-template-columns: 1fr;
  }
  .harvest-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Genetics section header stacks */
  .genetics-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  /* Smaller calc boxes */
  .calc-result {
    flex-direction: column;
    text-align: center;
    gap: 4px;
  }

  /* Tray chips wrap */
  .tray-list {
    gap: 6px;
  }
  .tray-chip {
    font-size: 0.72rem;
    padding: 4px 10px;
  }

  /* Harvest summary single col */
  .harvest-summary-grid {
    grid-template-columns: 1fr;
  }

  /* Strain card stats wrap */
  .strain-card-stats {
    flex-wrap: wrap;
  }

  /* Analytics two-col responsive */
  .analytics-two-col { grid-template-columns: 1fr; }
}

/* ============================================================
   ANALYTICS ENHANCEMENTS
   ============================================================ */

/* Donut chart */
.donut-container {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}
.donut-legend-item strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
}
.donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Histogram */
.histogram-container {
  min-height: 160px;
  padding: 8px 0;
}

/* Two-column layout for side-by-side charts */
.analytics-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* Score badge */
.score-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-mono);
}
.score-high { background: var(--status-active-bg); color: var(--status-active-fg); }
.score-mid { background: var(--status-quarantine-bg); color: var(--status-quarantine-fg); }
.score-low { background: var(--status-destroyed-bg); color: var(--status-destroyed-fg); }

/* Stock level badges */
.stock-critical { background: var(--status-destroyed-bg); color: var(--status-destroyed-fg); }
.stock-low { background: var(--status-quarantine-bg); color: var(--status-quarantine-fg); }
.stock-ok { background: var(--status-active-bg); color: var(--status-active-fg); }

/* Environment out-of-range highlight */
.env-cell-warn { color: var(--warning) !important; font-weight: 600; }

/* Global search */
.search-bar { position: relative; margin-right: 12px; }
.search-bar .search-input {
  background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 12px; font-size: 0.85rem; color: var(--text-primary); width: 220px;
  font-family: var(--font-body); transition: border-color 0.15s;
}
.search-bar .search-input:focus { outline: none; border-color: var(--accent); }
.search-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: var(--radius); margin-top: 4px;
  max-height: 360px; overflow-y: auto; z-index: 1000; box-shadow: var(--shadow);
}
.search-category { padding: 6px 12px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; }
.search-result-item {
  padding: 8px 12px; cursor: pointer; font-size: 0.85rem; color: var(--text-primary);
  border-bottom: 1px solid var(--border); transition: background 0.1s;
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-item:last-child { border-bottom: none; }

/* Custody pending badge */
.custody-pending-badge {
  background: var(--danger); color: #fff; font-size: 0.7rem; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; display: inline-flex;
  align-items: center; justify-content: center; padding: 0 5px; margin-left: 6px;
}

/* Custody transfer card */
.custody-transfer-card {
  background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 8px; font-size: 0.88rem;
}

/* Photo grid */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-top: 12px; }
.photo-thumb {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--border); cursor: pointer; transition: transform 0.15s;
}
.photo-thumb:hover { transform: scale(1.05); }
.photo-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.photo-list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; background: var(--bg-tertiary); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.photo-download-link {
  color: var(--accent); text-decoration: none; font-size: 0.88rem; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.photo-download-link:hover { text-decoration: underline; }

/* Destruction detail */
.destruction-detail { background: var(--bg-tertiary); border-left: 3px solid var(--danger); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 8px; }

/* Recall severity badges */
.recall-severity-voluntary { background: var(--status-quarantine-bg); color: var(--status-quarantine-fg); }
.recall-severity-mandatory { background: var(--status-destroyed-bg); color: var(--status-destroyed-fg); }
.recall-severity-urgent { background: #7f1d1d; color: #fca5a5; }

/* Public trace */
.public-trace-container {
  max-width: 600px; margin: 40px auto; padding: 24px; background: var(--bg-secondary);
  border-radius: var(--radius); border: 1px solid var(--border);
}

/* Reconciliation waterfall bar */
.recon-waterfall-bar { position: relative; height: 24px; border-radius: var(--radius); overflow: hidden; background: var(--bg-tertiary); }
.recon-bar-segment { position: absolute; top: 0; left: 0; height: 100%; border-radius: var(--radius); transition: width 0.3s; }

/* === Onboarding Wizard === */
.wizard-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg-primary);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.wizard-header {
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px 24px 18px; border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.wizard-header-titles {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.wizard-header h2 { margin: 0; font-size: 1.05rem; color: var(--text-primary); letter-spacing: -0.01em; }

/* Skip-anywhere escape route. Visually subdued so it doesn't compete with
   the primary navigation buttons in the footer. */
.wiz-skip-link {
  background: none; border: 0; padding: 6px 8px; cursor: pointer;
  color: var(--text-muted); font-size: 0.82rem; font-weight: 500;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.wiz-skip-link:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.wiz-skip-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Two-phase named progress. Replaces the row of 11 unlabeled dots. */
.wiz-progress {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  align-items: start;
}
.wiz-phase { min-width: 0; opacity: 0.55; transition: opacity 0.2s; }
.wiz-phase-active { opacity: 1; }
.wiz-phase-done { opacity: 0.85; }
.wiz-phase-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.wiz-phase-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  font-size: 0.7rem; font-weight: 600;
  background: var(--bg-tertiary); color: var(--text-muted);
  border: 1px solid var(--border);
}
.wiz-phase-active .wiz-phase-num { background: var(--accent); color: var(--bg-primary); border-color: var(--accent); }
.wiz-phase-done .wiz-phase-num { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.wiz-phase-title {
  font-size: 0.78rem; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em;
}
.wiz-phase-active .wiz-phase-title { color: var(--text-primary); }
.wiz-phase-track {
  display: flex; gap: 4px;
}
.wiz-seg {
  flex: 1; min-width: 0; position: relative;
  height: 4px; border-radius: 4px;
  background: var(--bg-tertiary);
  transition: background 0.2s;
}
.wiz-seg.active { background: var(--accent); }
.wiz-seg.done { background: var(--accent); opacity: 0.55; }
.wiz-seg-label {
  position: absolute; top: 8px; left: 0;
  font-size: 0.7rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
  transition: color 0.2s;
}
.wiz-seg.active .wiz-seg-label { color: var(--text-primary); font-weight: 500; }
.wiz-phase-pending .wiz-seg-label { color: var(--text-muted); }
/* Reserve space so the body doesn't shift when labels render. */
.wiz-phase-track { margin-bottom: 22px; }

@media (max-width: 720px) {
  .wiz-progress { grid-template-columns: 1fr; gap: 14px; }
  .wiz-seg-label { font-size: 0.65rem; }
}

.wizard-footer-meta { color: var(--text-muted); font-size: 0.8rem; }
.wiz-time-hint { color: var(--text-muted); }

/* Inline error banner for validation. Auto-dismisses after 6s. */
.wiz-inline-error {
  background: rgba(248, 113, 113, 0.08);
  border-left: 3px solid var(--danger);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  line-height: 1.45;
}
.wiz-inline-error[hidden] { display: none; }
.wizard-body {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr;
  overflow: hidden;
}
.wizard-form-panel {
  padding: 32px; overflow-y: auto;
  border-right: 1px solid var(--border);
}
.wizard-preview-panel {
  background: var(--bg-secondary); overflow: hidden;
  display: flex; flex-direction: column;
}
.wizard-preview-panel .preview-label {
  padding: 12px 16px; font-size: 0.8rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.wizard-preview-panel #wizard-konva-container {
  flex: 1; min-height: 0;
}
.wizard-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}
.wizard-footer .wizard-nav-btns { display: flex; gap: 8px; }

/* Wizard welcome — redesigned to anchor a first-time admin: what Greenly
   does, why these steps matter, and a 1-click size preset shortcut. */
.wizard-welcome {
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
  text-align: left; max-width: 640px; margin: 0 auto;
}
.wizard-welcome h2 {
  font-size: 1.9rem; margin-bottom: 12px; color: var(--text-primary);
  letter-spacing: -0.02em; line-height: 1.1;
}
.wiz-welcome-lead {
  color: var(--text-secondary);
  font-size: 1rem; line-height: 1.55;
  margin-bottom: 22px;
}
.wiz-welcome-points {
  list-style: none; padding: 0; margin: 0 0 28px 0;
  display: flex; flex-direction: column; gap: 12px;
}
.wiz-welcome-points li {
  position: relative; padding: 12px 14px 12px 36px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem; line-height: 1.5;
  color: var(--text-secondary);
}
.wiz-welcome-points li::before {
  content: ''; position: absolute; left: 14px; top: 17px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-bg);
}
.wiz-welcome-points strong { color: var(--text-primary); font-weight: 600; }

.wiz-welcome-presets { margin-bottom: 20px; }
.wiz-presets-label {
  font-size: 0.82rem; color: var(--text-muted);
  margin-bottom: 10px; font-weight: 500;
}
.wiz-presets-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
@media (max-width: 540px) {
  .wiz-presets-grid { grid-template-columns: 1fr; }
}
.wiz-preset-card {
  text-align: left; padding: 14px 16px; cursor: pointer;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-family: inherit;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.wiz-preset-card:hover {
  border-color: var(--accent); background: var(--bg-tertiary);
  transform: translateY(-1px);
}
.wiz-preset-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wiz-preset-title {
  font-size: 0.95rem; font-weight: 600; color: var(--text-primary);
}
.wiz-preset-meta {
  font-size: 0.78rem; color: var(--accent); font-weight: 500;
}
.wiz-preset-desc {
  font-size: 0.8rem; color: var(--text-muted); line-height: 1.4;
}
.wiz-preset-card.wiz-preset-blank { border-style: dashed; }
.wiz-preset-card.wiz-preset-blank .wiz-preset-meta { color: var(--text-muted); }

.wiz-welcome-footnote {
  font-size: 0.78rem; color: var(--text-muted); line-height: 1.5;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: 8px;
  margin-top: 8px;
}

/* Compliance profile card on the review step */
.wiz-compliance-card {
  margin: 18px 0 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.wiz-compliance-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 14px 16px;
  background: var(--accent-bg);
  border-bottom: 1px solid var(--border);
}
.wiz-compliance-eyebrow {
  font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); margin-bottom: 4px;
}
.wiz-compliance-name {
  font-size: 1rem; font-weight: 600; color: var(--text-primary);
  line-height: 1.3;
}
.wiz-compliance-jur {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 500;
  background: var(--bg-tertiary); color: var(--text-secondary);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.wiz-compliance-body { padding: 14px 16px; }
.wiz-compliance-lab {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.85rem; color: var(--text-muted);
  padding-bottom: 10px; margin-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}
.wiz-compliance-lab strong { color: var(--text-primary); font-weight: 600; }
.wiz-compliance-rules {
  list-style: none; padding: 0; margin: 0 0 12px 0;
  display: flex; flex-direction: column; gap: 6px;
}
.wiz-compliance-rules li {
  font-size: 0.85rem; color: var(--text-secondary);
  padding-left: 16px; position: relative; line-height: 1.5;
}
.wiz-compliance-rules li::before {
  content: '✓'; position: absolute; left: 0; top: 0;
  color: var(--accent); font-weight: 600; font-size: 0.85rem;
}
.wiz-compliance-rules strong { color: var(--text-primary); font-weight: 600; }
.wiz-compliance-foot {
  font-size: 0.78rem; color: var(--text-muted); line-height: 1.5;
}

/* Collapsible hierarchy on the review step */
.wiz-hierarchy-details {
  margin-top: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.wiz-hierarchy-details summary {
  padding: 12px 14px;
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
  display: flex; align-items: center; gap: 8px;
}
.wiz-hierarchy-details summary::-webkit-details-marker { display: none; }
.wiz-hierarchy-details summary::before {
  content: '▸';
  font-size: 0.7rem; color: var(--text-muted);
  transition: transform 0.2s;
}
.wiz-hierarchy-details[open] summary::before { transform: rotate(90deg); }
.wiz-hierarchy-details summary:hover { color: var(--text-primary); }
.wiz-hierarchy-list {
  padding: 4px 14px 14px;
  border-top: 1px solid var(--border);
}
.wiz-hierarchy-room { margin-top: 10px; }
.wiz-hierarchy-room-name {
  font-size: 0.88rem; font-weight: 600; color: var(--text-primary);
  margin-bottom: 4px;
}
.wiz-hierarchy-zone {
  padding-left: 14px; font-size: 0.82rem;
  color: var(--text-secondary); margin-top: 4px;
}
.wiz-hierarchy-tray {
  padding-left: 14px; font-size: 0.8rem;
  color: var(--text-muted); margin-top: 2px;
}
.wiz-hierarchy-meta {
  color: var(--text-muted); font-size: 0.78rem; font-style: italic;
}

/* Facility tray cards */
.facility-tray-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.facility-tray-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.facility-tray-card:hover {
  border-color: var(--accent);
}
.facility-tray-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}
.facility-tray-header strong {
  flex: 1;
}
.facility-tray-occ {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
}
.facility-tray-occ.tray-half { color: var(--warning); }
.facility-tray-occ.tray-full { color: var(--accent); }
.facility-tray-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.facility-tray-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}
.facility-tray-bar-fill.tray-half { background: var(--warning); }
.facility-tray-bar-fill.tray-full { background: var(--accent); }
.facility-tray-grid {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* Cell context menu */
.cell-menu-item {
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-primary);
}
.cell-menu-item:hover {
  background: var(--bg-hover);
}
.cell-menu-danger {
  color: var(--danger);
}
.place-plant-row:hover {
  background: var(--bg-hover);
}

/* Mini tray grid */
.mini-tray-grid-wrap {
  max-height: 360px;
  overflow-y: auto;
  margin-top: 8px;
}
.mini-tray-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.mini-tray-cap {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.mini-tray-grid .tray-cell {
  min-width: 0;
  min-height: 0;
  aspect-ratio: auto;
}
.tray-cell-selected {
  border-color: var(--accent) !important;
  background: var(--accent-bg) !important;
  color: var(--accent) !important;
  font-weight: 600;
}
.tray-cell-empty:hover {
  border-color: var(--accent) !important;
  background: var(--accent-bg) !important;
}

/* Wizard tour steps */
.wizard-tour-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 400px;
  gap: 16px;
}
.wizard-tour-icon {
  font-size: 3rem;
  line-height: 1;
}
.wizard-tour-content {
  max-width: 480px;
  text-align: left;
  line-height: 1.7;
  color: var(--text-secondary);
}
.wizard-tour-content h3 {
  text-align: center;
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 1.3rem;
}
.wizard-tour-content strong {
  color: var(--accent);
}
.wizard-tour-content p {
  margin-bottom: 8px;
}
.wizard-tour-progress {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Wizard form elements */
.wizard-section-title {
  font-size: 1.2rem; font-weight: 600; margin-bottom: 16px; color: var(--text-primary);
}
.wizard-subtitle {
  font-size: 0.9rem; color: var(--text-muted); margin-bottom: 20px;
}
.wizard-input-row {
  display: flex; gap: 12px; align-items: center; margin-bottom: 12px;
}
.wizard-input-row input {
  flex: 1; padding: 8px 12px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); font-size: 0.9rem;
}
.wizard-input-row input:focus { outline: none; border-color: var(--accent); }
.wizard-input-row .row-label {
  font-size: 0.8rem; color: var(--text-muted); min-width: 24px; text-align: right;
}
.wizard-count-control {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
}
.wizard-count-control label { font-size: 0.9rem; color: var(--text-primary); }
.wizard-count-control input[type="number"] {
  width: 70px; padding: 8px; text-align: center;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); font-size: 1rem;
}
.wizard-count-control input[type="number"]:focus { outline: none; border-color: var(--accent); }

/* Tray config grid */
.wizard-tray-config {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.wizard-tray-config .tray-header {
  font-weight: 600; font-size: 0.9rem; margin-bottom: 10px; color: var(--text-primary);
}
.wizard-tray-config .tray-dims {
  display: flex; gap: 8px; align-items: center;
}
.wizard-tray-config .tray-dims input {
  width: 60px; padding: 6px; text-align: center;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); font-size: 0.85rem;
}
.wizard-tray-config .tray-dims input:focus { outline: none; border-color: var(--accent); }
.wizard-tray-config .tray-dims span { color: var(--text-muted); font-size: 0.85rem; }
.wizard-tray-capacity {
  font-size: 0.8rem; color: var(--accent); margin-top: 6px;
}
.wizard-tray-config .tray-body {
  display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap;
}
.wizard-tray-config .tray-controls { flex: 1; min-width: 200px; }
.wizard-tray-mini-preview {
  flex: 0 0 auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.wizard-tray-mini-preview .mini-caption {
  font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.04em; text-transform: uppercase;
}
.wizard-tray-mini-grid {
  display: grid;
  gap: 1px;
  padding: 4px;
  background: var(--bg-tertiary);
  border-radius: 4px;
}
.wizard-tray-mini-grid > div {
  background: #a855f740;
  border-radius: 1px;
}

/* Info banner shown at the top of each wizard step */
.wizard-info-banner {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.5;
}
.wizard-info-banner strong { color: var(--accent); }
.wizard-info-banner .examples {
  display: block;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Grouped sections in zones/trays steps (one block per room/zone) */
.wizard-room-section, .wizard-zone-section {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.wizard-room-section .room-section-header,
.wizard-zone-section .zone-section-header {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 0.95rem; color: var(--text-primary);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.wizard-zone-section .zone-section-header { font-size: 0.88rem; }
.wizard-zone-section .zone-section-header .zone-path-room {
  color: var(--text-muted); font-weight: 500;
}
.wizard-count-inline {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: 0.85rem;
}
.wizard-count-inline label { color: var(--text-muted); }
.wizard-count-inline input[type="number"] {
  width: 60px; padding: 4px 6px; text-align: center;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); font-size: 0.85rem;
}
.wizard-count-inline input[type="number"]:focus { outline: none; border-color: var(--accent); }

/* Wizard summary */
.wizard-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px;
  margin-bottom: 24px;
}
.wizard-stat-card {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.wizard-stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.wizard-stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* Wizard confirm / creating */
.wizard-confirm {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 300px; text-align: center;
}
.wizard-confirm .spinner-large {
  width: 48px; height: 48px; border: 4px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin-bottom: 16px;
}
.wizard-confirm h3 { color: var(--text-primary); margin-bottom: 8px; }
.wizard-confirm p { color: var(--text-muted); }
.wizard-success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive: stack form/preview vertically on small screens */
@media (max-width: 900px) {
  .wizard-body { grid-template-columns: 1fr; }
  .wizard-form-panel { border-right: none; border-bottom: 1px solid var(--border); max-height: 50vh; }
  .wizard-preview-panel { min-height: 300px; }
}

/* === Sensor Data Cards === */
.sensor-live-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}
.sensor-data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.sensor-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.sensor-card-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}
.sensor-card-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.sensor-card-unit {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 2px;
}
.sensor-card-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.sensor-status-active {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--status-active-bg);
  color: var(--status-active-fg);
}
.sensor-status-inactive {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}
.sensor-status-error {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--status-quarantine-bg);
  color: var(--status-quarantine-fg);
}
@media (max-width: 768px) {
  .sensor-data-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* AI Recommendation of the Day */
.ai-recommendation-box {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(74, 222, 128, 0.05) 100%);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.ai-recommendation-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.ai-recommendation-icon {
  font-size: 1.2rem;
  color: var(--accent);
}
.ai-recommendation-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}
.ai-recommendation-cached {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 9999px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}
.ai-recommendation-text {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* === Grow Optimization Styles === */

/* VPD sensor card zones */
.sensor-card-optimal {
  border: 1px solid rgba(74, 222, 128, 0.4) !important;
  background: rgba(74, 222, 128, 0.08) !important;
}
.sensor-card-acceptable {
  border: 1px solid rgba(245, 158, 11, 0.4) !important;
  background: rgba(245, 158, 11, 0.08) !important;
}
.sensor-card-stress {
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
  background: rgba(239, 68, 68, 0.08) !important;
}
.vpd-zone-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 9999px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  margin-left: 4px;
}
.sensor-card-optimal .vpd-zone-badge { background: rgba(74,222,128,0.2); color: #4ade80; }
.sensor-card-acceptable .vpd-zone-badge { background: rgba(245,158,11,0.2); color: #f59e0b; }
.sensor-card-stress .vpd-zone-badge { background: rgba(239,68,68,0.2); color: #ef4444; }
.vpd-range-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Alert bell */
.alert-bell {
  display: inline-flex;
  align-items: center;
  position: relative;
}
.alert-badge {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Alerts panel */
.alerts-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 3000;
  box-shadow: -4px 0 20px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.2s ease;
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.alert-item {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--border);
}
.alert-critical { border-left-color: var(--danger); }
.alert-warning { border-left-color: var(--warning); }
.alert-info { border-left-color: var(--info); }

/* Feeding entries */
.feed-entry {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.feed-entry:last-child { border-bottom: none; }
.feed-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.feed-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.feed-metrics span {
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 4px;
}
.feed-nutrients {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Weight curve */
.weight-curve-section {
  margin-top: 8px;
}

/* IPM entries */
.ipm-entry {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.ipm-entry:last-child { border-bottom: none; }
.ipm-pest-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  font-size: 0.82rem;
  font-weight: 600;
}

/* Cost summary */
.cost-summary-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.cost-category-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Plant Chat Panel */
.plant-chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2999;
}
.plant-chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 3000;
  box-shadow: -4px 0 20px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.2s ease;
}
.plant-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.plant-chat-header h3 {
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.plant-chat-header-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.plant-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
  gap: 12px;
}
.chat-empty-state-icon {
  font-size: 2.5rem;
  opacity: 0.5;
}
.chat-empty-state-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.chat-empty-state-hint {
  font-size: 0.82rem;
  line-height: 1.5;
}
.chat-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chat-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--bg-primary);
  border-bottom-right-radius: 4px;
}
.chat-assistant {
  align-self: flex-start;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.chat-user .chat-message-time {
  text-align: right;
  color: rgba(255,255,255,0.6);
}
.plant-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  align-items: flex-end;
}
.plant-chat-input-area textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.4;
  max-height: 120px;
  min-height: 40px;
}
.plant-chat-input-area textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.plant-chat-input-area .chat-send-btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--bg-primary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.plant-chat-input-area .chat-send-btn:hover {
  background: var(--accent-dim);
}
.plant-chat-input-area .chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.chat-typing-dots {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}
.chat-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: chatDotPulse 1.4s ease-in-out infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatDotPulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* Mobile FAB */
#fab-container {
  display: none;
}
@media (max-width: 768px) {
  #fab-container {
    display: block;
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 1500;
  }
  .fab-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    font-size: 1.8rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
  }
  .fab-btn:active { transform: scale(0.9); }
  .fab-menu {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    animation: fabSlideUp 0.2s ease;
  }
  @keyframes fabSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .fab-option {
    padding: 10px 16px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    font-size: 0.88rem;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }
  .fab-option:active { background: var(--bg-tertiary); }

  /* Alerts panel full width on mobile */
  .alerts-panel { width: 100%; }
  /* Chat panel full width on mobile */
  .plant-chat-panel { width: 100%; }
}

/* ============================================================
   DESIGN OVERHAUL — Organic, warm, distinctive character
   ============================================================ */

/* Headings everywhere get the display font */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

/* Cards get softer, warmer shadows and subtle border treatment */
.pipeline-section,
.status-breakdown,
.activity-section,
.analytics-card,
.strain-section,
.lab-reports-section,
.stage-stepper,
.audit-trail,
.plant-header,
.table-container,
.room-card,
.product-card,
.attention-section,
.overdue-section {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

/* Sidebar gets a subtle top accent */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.4;
}

/* Pipeline stages get organic-feeling rounded shapes */
.pipeline-stage-inner {
  border-radius: var(--radius-lg);
}

/* Activity dots get a slightly organic shape */
.activity-dot {
  border-radius: 3px;
  transform: rotate(45deg);
}

/* Stepper circles feel more organic with softer rings */
.stepper-step.current .stepper-circle {
  box-shadow: 0 0 0 4px var(--accent-bg), 0 0 16px rgba(134, 239, 172, 0.15);
}

/* QR display gets a subtle card-like feel */
.qr-display img {
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Table rows get warmer hover */
tr:hover td {
  background: var(--bg-hover);
}

/* Input fields get a friendlier focus state */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.table-toolbar input:focus,
.table-toolbar select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* Env reading badges are more playful */
.env-reading {
  border-radius: 8px;
}

/* Empty states feel warmer */
.empty-state-icon {
  opacity: 0.5;
  filter: saturate(0.8);
}

/* Make the loading spinner feel less mechanical */
.loading-spinner {
  border-width: 2px;
  border-top-color: var(--accent);
}

/* Active tab style - less flat, more tactile */
.section-tab.active,
.analytics-tab.active {
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Scrollbar styling for webkit */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Selection color */
::selection {
  background: rgba(134, 239, 172, 0.2);
  color: inherit;
}
[data-theme="light"] ::selection {
  background: rgba(22, 163, 74, 0.15);
}

/* Subtle link underline animation */
a:hover {
  text-decoration-color: var(--accent);
}

/* Status row gets a subtle left border on hover for scannability */
.status-row:hover {
  background: var(--bg-hover);
  border-radius: 4px;
  margin: 0 -8px;
  padding: 10px 8px;
}

/* Stage reference cards get a playful left border */
.stage-ref-card {
  border-left: 3px solid transparent;
  transition: border-color 0.2s;
}
.stage-ref-card:hover {
  border-left-color: var(--accent);
}

/* Strain card type bars get slightly rounded edges */
.strain-card-type-bar {
  height: 3px;
}

/* Alert cards feel less rigid */
.alert-card {
  border-radius: var(--radius);
  border-left-width: 3px;
}

/* Bottom sheet handle is friendlier */
.bottom-sheet-handle {
  width: 36px;
  height: 3px;
  border-radius: 2px;
  opacity: 0.5;
}

/* Pipeline total bar is slightly taller and rounder */
.pipeline-total-bar {
  height: 5px;
  border-radius: 3px;
}

/* Stock bar is slightly taller for better visibility */
.stock-bar {
  height: 5px;
  border-radius: 3px;
}

/* Tray chips are less pill-shaped, more tag-like */
.tray-chip {
  border-radius: 8px;
}

/* Zone pills are more distinctive */
.zone-pill {
  border-radius: 6px;
}

/* Pipeline background art */
.pipeline-bg-art {
  filter: grayscale(30%);
  mix-blend-mode: lighten;
}
[data-theme="light"] .pipeline-bg-art {
  mix-blend-mode: multiply;
  opacity: 0.05 !important;
}

/* === Icon system (Lucide SVG) === */
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  transition: all 0.2s;
  z-index: 2;
}
.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
  transition: all 0.15s;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.del-tray-btn.icon-btn:hover { color: var(--danger); }
.inline-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: -3px;
}
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--text-muted);
}
.sidebar-toggle svg { display: block; }
.page-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
}
.stepper-circle svg { display: block; }

/* Theme-toggle, alert-bell, banner-dismiss SVG sizing */
.theme-toggle svg,
.alert-bell svg,
.banner-dismiss svg,
.modal-close svg,
.icon-btn svg,
.nav-item-icon svg,
.nav-section-arrow svg,
.mobile-nav-icon svg {
  display: block;
  flex-shrink: 0;
}

/* Light-mode: icon-btn delete hover */
[data-theme="light"] .del-tray-btn.icon-btn:hover { color: var(--danger); background: rgba(220, 38, 38, 0.08); }

/* === Toasts === */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(400px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  font-size: 0.88rem;
  color: var(--text-primary);
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), opacity 220ms;
}
.toast-show { transform: translateX(0); opacity: 1; }
.toast-hide { transform: translateX(120%); opacity: 0; }
.toast-success { border-left-color: var(--accent); }
.toast-success .toast-icon { color: var(--accent); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info { border-left-color: var(--info); }
.toast-info .toast-icon { color: var(--info); }
.toast-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.toast-message {
  flex: 1;
  line-height: 1.45;
  min-width: 0;
  word-wrap: break-word;
}
.toast-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  flex-shrink: 0;
  margin-top: -2px;
  margin-right: -4px;
  transition: color 0.15s, background 0.15s;
}
.toast-close:hover { color: var(--text-primary); background: var(--bg-hover); }
@media (max-width: 540px) {
  .toast-container { top: auto; bottom: 80px; left: 16px; right: 16px; max-width: none; }
  .toast { transform: translateY(120%); }
  .toast-show { transform: translateY(0); }
  .toast-hide { transform: translateY(120%); }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 100ms; transform: none; }
  .toast-hide { transform: none; }
}

/* Required field marker (visual, not screen-reader-relevant; the input's `required` attr handles SR) */
.required-mark {
  color: var(--danger);
  font-weight: 600;
  margin-left: 1px;
}

/* === Button loading state === */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  cursor: progress;
}
.btn-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  color: var(--bg-primary);
  animation: btn-spin 0.7s linear infinite;
}
.btn-secondary.btn-loading::after { color: var(--text-primary); }
.btn-danger.btn-loading::after { color: #fff; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn-loading::after { animation-duration: 1.6s; }
}

/* === Breadcrumbs === */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.82rem;
  margin-bottom: 8px;
  color: var(--text-muted);
}
.breadcrumb-link {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.breadcrumb-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  text-decoration: none;
}
.breadcrumb-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.breadcrumb-sep {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  opacity: 0.6;
}
.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
  padding: 2px 4px;
}

/* Page header row (title + actions inline) */
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header-row h2 { margin: 0; }

/* === Skeleton loaders === */
.skeleton {
  display: block;
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 0%,
    var(--bg-hover) 50%,
    var(--bg-tertiary) 100%
  );
  background-size: 200% 100%;
  border-radius: 6px;
  animation: skeleton-shimmer 1.4s linear infinite;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-line { height: 12px; margin: 8px 0; }
.skeleton-line--20 { width: 20%; }
.skeleton-line--40 { width: 40%; }
.skeleton-line--60 { width: 60%; }
.skeleton-line--80 { width: 80%; }
.skeleton-line--lg { height: 22px; }

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.skeleton-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.skeleton-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.skeleton-stat {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.skeleton-chart {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  height: 240px;
  display: flex;
  align-items: stretch;
}
.skeleton-chart-inner { width: 100%; height: 100%; border-radius: 8px; }
.skeleton-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}
.skeleton-row {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.skeleton-row .skeleton-line { margin: 0; flex: 1; }
.skeleton-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
}
.skeleton-table-row {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.skeleton-table-row .skeleton-line { margin: 0; flex: 1; }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation-duration: 4s; }
}

/* === Detail page in-section tabs (sticky scroll-spy) === */
.detail-tabs {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 8px 0 6px;
  margin: -8px 0 16px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.detail-tab {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.detail-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.detail-tab.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--border-active, transparent);
}
.detail-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Section anchor offset so sticky tab bar doesn't cover the heading */
#plant-overview, #plant-stage-progress, #plant-env-chart-section,
#plant-stage-duration-section, #plant-audit-trail, #plant-lab-reports,
#batch-overview, #batch-pipeline-section, #batch-harvest-section,
#batch-drying-section, #batch-env-section, #batch-audit-section {
  scroll-margin-top: 80px;
}
