@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #10160D;
  --bg-soft: #141C10;
  --surface: #1B2417;
  --surface-2: #232F1D;
  --border: #2E3B26;
  --border-soft: #263120;
  --text: #ECEFE4;
  --text-dim: #94A28A;
  --text-faint: #5E6C55;

  --clone: #6FD9CF;   /* clone / propagation - misty teal */
  --veg: #5FBE6B;      /* vegetative - chlorophyll green */
  --bloom: #C979E8;    /* bloom - LED purple */
  --harvest: #E3A94C;  /* harvest / cure - amber */
  --danger: #E2695F;

  --clone-dim: rgba(111,217,207,0.14);
  --veg-dim: rgba(95,190,107,0.14);
  --bloom-dim: rgba(201,121,232,0.14);
  --harvest-dim: rgba(227,169,76,0.14);

  --radius: 10px;
  --radius-sm: 6px;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 900px 500px at 15% -5%, rgba(95,190,107,0.08), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(201,121,232,0.06), transparent 60%);
  z-index: 0;
}

h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.mono { font-family: var(--font-mono); }
a { color: inherit; }
button { font-family: inherit; }
:focus-visible {
  outline: 2px solid var(--veg);
  outline-offset: 2px;
}

/* ---------- App shell ---------- */
#app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 20px;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--veg), var(--bloom));
  flex-shrink: 0;
  position: relative;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: 3px;
  background: var(--bg-soft);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.15;
}
.brand-sub {
  font-size: 10.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--veg);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-spacer { flex: 1; }
.nav-foot {
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
  margin-top: 6px;
}

.main {
  padding: 26px 34px 60px;
  overflow-x: hidden;
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 10px;
}
.topbar h1 { font-size: 22px; }
.topbar .eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 3px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--veg); background: var(--surface-2); }
.btn-primary {
  background: var(--veg);
  border-color: var(--veg);
  color: #0B1509;
  font-weight: 600;
}
.btn-primary:hover { background: #6FCB7B; border-color: #6FCB7B; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
}
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

.stat-card { display: flex; flex-direction: column; gap: 6px; }
.stat-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint);
}
.stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.stat-sub { font-size: 12px; color: var(--text-dim); }

/* ---------- Stage timeline (signature element) ---------- */
.stage-track {
  display: flex;
  height: 8px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface-2);
  position: relative;
}
.stage-seg { flex: 1; position: relative; }
.stage-seg.clone { background: var(--clone-dim); }
.stage-seg.veg { background: var(--veg-dim); }
.stage-seg.bloom { background: var(--bloom-dim); }
.stage-seg.harvest { background: var(--harvest-dim); }
.stage-seg.filled.clone { background: var(--clone); }
.stage-seg.filled.veg { background: var(--veg); }
.stage-seg.filled.bloom { background: var(--bloom); }
.stage-seg.filled.harvest { background: var(--harvest); }
.stage-dot {
  position: absolute;
  top: 50%; transform: translate(-50%, -50%);
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 2px currentColor, 0 0 10px 2px currentColor;
}
.stage-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
}
.stage-labels span.current { color: var(--text); font-weight: 600; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tag-veg { background: var(--veg-dim); color: var(--veg); }
.tag-clone { background: var(--clone-dim); color: var(--clone); }
.tag-bloom { background: var(--bloom-dim); color: var(--bloom); }
.tag-harvest { background: var(--harvest-dim); color: var(--harvest); }
.tag-active { background: var(--veg-dim); color: var(--veg); }
.tag-done { background: var(--surface-2); color: var(--text-dim); }
.tag-placeholder {
  background: none;
  border: 1px dashed var(--text-faint);
  color: var(--text-faint);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.tag-due {
  background: var(--harvest-dim);
  color: var(--harvest);
  border: 1px solid var(--harvest);
  text-transform: none;
  letter-spacing: 0;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Future-dated placeholder entries: not yet occurred */
tr.row-placeholder td {
  color: var(--text-faint);
  font-style: italic;
  background: rgba(255,255,255,0.012);
}
tr.row-placeholder:hover td { background: rgba(255,255,255,0.02); }
tr.row-placeholder .tag:not(.tag-placeholder) { opacity: 0.55; }

/* Due entries: date has arrived but not yet checked off */
tr.row-due td { background: rgba(227,169,76,0.05); }
tr.row-due:hover td { background: rgba(227,169,76,0.09); }

/* ---------- Crop cards ---------- */
.crop-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.crop-card:hover { border-color: var(--veg); transform: translateY(-1px); }
.crop-card-head { display: flex; justify-content: space-between; align-items: flex-start; }
.crop-card-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.crop-strains { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
tr:hover td { background: rgba(255,255,255,0.014); }
.num { font-family: var(--font-mono); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius); }
.table-wrap table { min-width: 640px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label {
  font-size: 11.5px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.04em;
}
input, select, textarea {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  width: 100%;
}
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--veg);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6,10,4,0.65);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto; z-index: 50;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 560px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.modal-close {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 18px; padding: 4px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty h3 { font-size: 15px; margin-bottom: 6px; color: var(--text); }
.empty p { font-size: 13px; margin: 0 0 16px; }

.section { margin-bottom: 30px; }
.section-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.section-head h2 { font-size: 16px; }
.pill-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.pill {
  padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border-soft); color: var(--text-dim);
  cursor: pointer;
}
.pill.active { background: var(--veg-dim); color: var(--veg); border-color: transparent; }

.hint { font-size: 12px; color: var(--text-faint); }
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--surface-2); border: 1px solid var(--veg);
  color: var(--text); padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 13px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity:0; transform: translateY(6px);} to {opacity:1; transform:none;} }

.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-fill { width: 100%; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--veg), var(--clone)); min-height: 3px; }
.bar-label { font-size: 10px; color: var(--text-faint); text-align: center; white-space: nowrap; }
.bar-value { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }

@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    flex-direction: row; overflow-x: auto; padding: 8px 10px;
    border-right: none; border-top: 1px solid var(--border-soft);
    z-index: 40; gap: 2px;
  }
  .brand, .nav-foot, .nav-spacer { display: none; }
  .nav-item { flex-direction: column; font-size: 10px; gap: 3px; padding: 6px 10px; white-space: nowrap; }
  .nav-item.active { box-shadow: inset 0 2px 0 var(--veg); }
  .main { padding: 20px 16px 90px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
