/* ============================================================
   Dialed — visual foundation
   Green, warm, roomy. One stylesheet, no framework.
   Class names are stable; density-compact + mobile follow.
   ============================================================ */

:root {
  /* brand */
  --brand: #2f7a4f;
  --brand-dark: #1f5537;
  --brand-darker: #163f28;
  --brand-soft: #e9f4ee;
  --brand-tint: #f3f9f5;

  /* ink & surfaces */
  --ink: #17201b;
  --ink-2: #35423b;
  --muted: #6b756e;
  --line: #e2e7e3;
  --line-strong: #cfd6d0;
  --surface: #ffffff;
  --surface-2: #f5f7f5;
  --bg: #f7f8f6;

  /* status */
  --danger: #b23a3a;
  --danger-soft: #fbeae9;
  --warn: #9a6510;
  --warn-soft: #fbf1de;
  --ok: var(--brand-dark);
  --ok-soft: var(--brand-soft);

  /* shape */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --shadow: 0 1px 2px rgba(20, 40, 28, .05), 0 2px 8px rgba(20, 40, 28, .04);
  --shadow-lg: 0 4px 14px rgba(20, 40, 28, .09);
  --ring: 0 0 0 3px var(--brand-soft);

  /* spacing scale */
  --sp-1: .35rem;
  --sp-2: .6rem;
  --sp-3: .9rem;
  --sp-4: 1.25rem;
  --sp-5: 1.75rem;
  --sp-6: 2.5rem;

  font-size: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-dark); text-underline-offset: 2px; }
a:hover { color: var(--brand-darker); }

.wrap { max-width: 1060px; margin: 0 auto; padding: var(--sp-5) var(--sp-4) var(--sp-6); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: .7rem var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 800; font-size: 1.2rem; letter-spacing: -.01em;
  color: var(--brand-darker); text-decoration: none;
}
.brand-dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.nav { display: flex; gap: .15rem; flex-wrap: wrap; align-items: center; }
.nav a {
  padding: .45rem .8rem; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.is-here { background: var(--brand-soft); color: var(--brand-darker); font-weight: 650; }

.nav-user { display: flex; align-items: center; gap: .6rem; font-size: .88rem; color: var(--muted); }
.nav-user > span { font-weight: 600; color: var(--ink-2); }

/* ---------- headings & page head ---------- */
h1 { font-size: 1.7rem; line-height: 1.2; letter-spacing: -.02em; margin: var(--sp-4) 0 var(--sp-1); }
h2 { font-size: 1.15rem; letter-spacing: -.01em; margin: 0 0 var(--sp-2); }
h3 { font-size: .95rem; margin: 0 0 var(--sp-2); }
.muted { color: var(--muted); }
.hint { font-size: .8rem; color: var(--muted); }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  margin: var(--sp-3) 0 var(--sp-4);
}
.page-head p.muted { margin: .1rem 0 0; }
.page-head h1 { margin: 0; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card.empty { color: var(--muted); text-align: center; padding: var(--sp-5); }
.card.flush { padding: 0; overflow: hidden; }

/* coloured callouts (replaces inline styles on the dashboard etc.) */
.callout { border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-3); box-shadow: var(--shadow); border: 1px solid; }
.callout.ok { background: var(--brand-tint); border-color: var(--brand-soft); }
.callout.warn { background: var(--warn-soft); border-color: #eedcb4; }
.callout.danger { background: var(--danger-soft); border-color: #f2cfcd; }
.callout strong { color: var(--ink); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .16rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .01em;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line);
}
.badge.ok { background: var(--brand-soft); color: var(--brand-darker); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  cursor: pointer; white-space: nowrap;
  padding: .6rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-size: .92rem; font-weight: 600; text-decoration: none;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .04s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(20,40,28,.12); }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #eccbc9; background: var(--surface); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand-dark); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.sm { padding: .35rem .65rem; font-size: .82rem; font-weight: 600; border-radius: var(--radius-xs); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- forms ---------- */
form.inline { display: inline; }

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: var(--sp-3); }
.field label { font-size: .82rem; font-weight: 650; color: var(--ink-2); }
input, select, textarea { font: inherit; color: var(--ink); }
.field input, .field select, .field textarea,
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], select, textarea {
  padding: .55rem .65rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  max-width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus,
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.field .hint { font-size: .78rem; color: var(--muted); font-weight: 400; }

.checkline { display: inline-flex; align-items: center; gap: .45rem; font-size: .9rem; margin-bottom: .4rem; cursor: pointer; }
.checkline input { accent-color: var(--brand); width: 1rem; height: 1rem; }

.error-banner, .error-inline {
  background: var(--danger-soft); color: var(--danger);
  padding: .7rem .9rem; border-radius: var(--radius-sm);
  margin-bottom: var(--sp-3); font-size: .9rem; border: 1px solid #f2cfcd;
}

.filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: flex-end; margin-bottom: var(--sp-4); }
.filters .field { margin-bottom: 0; min-width: 9rem; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: .7rem 0; border-top: 1px solid var(--line);
}
.list li:first-child { border-top: 0; }
.list-main { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.list-main strong { font-weight: 650; }
.list-main .muted { font-size: .85rem; }
.list-side { color: var(--muted); font-size: .86rem; white-space: nowrap; font-weight: 600; }
.list-side.danger { color: var(--danger); }
.list-side.warn { color: var(--warn); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table-wrap table { border: 0; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table th, table td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); }
table tr:last-child td { border-bottom: 0; }
table th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; background: var(--surface-2); }
table tbody tr:hover { background: var(--brand-tint); }

/* ---------- auth ---------- */
.auth-wrap { max-width: 400px; margin: 4rem auto; padding: 0 1rem; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow-lg); }
.auth-brand { text-align: center; margin-bottom: 1.4rem; }
.auth-links { text-align: center; margin-top: 1.2rem; font-size: .9rem; }

/* ---------- misc bits ---------- */
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.dot { width: .55rem; height: .55rem; border-radius: 50%; display: inline-block; background: var(--line-strong); }
.dot.on { background: var(--brand); }

/* big number + label, for the dashboard */
.statrow { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.stat { flex: 1; min-width: 7rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--sp-3); }
.stat .n { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.stat .l { font-size: .78rem; color: var(--muted); margin-top: .25rem; }
.stat.hot .n { color: var(--danger); }
.stat.warm .n { color: var(--warn); }

/* ============================================================
   Editors  (rebuilt in the UX pass — labelled, roomy)
   ============================================================ */

/* A repeating editable record. Wraps into labelled controls, not a jammed row. */
.rec {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: var(--sp-3);
  margin-bottom: var(--sp-2);
}
.rec + .rec { margin-top: 0; }
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-2) var(--sp-3); align-items: end; }
.rec-grid .f { display: flex; flex-direction: column; gap: .25rem; }
.rec-grid .f > span { font-size: .74rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.rec-grid .f input, .rec-grid .f select { width: 100%; padding: .45rem .55rem; }
.rec-grid .f.wide { grid-column: 1 / -1; }
.rec-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--line); }
.rec-title { font-weight: 700; font-size: .95rem; }

/* legacy inline-edit row — kept working, just less cramped */
.row-edit { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .8rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.row-edit:first-of-type { border-top: 0; }
.row-edit .mini { font-size: .82rem; color: var(--muted); display: inline-flex; align-items: center; gap: .3rem; }
.row-edit input, .row-edit select { padding: .4rem .5rem; border: 1px solid var(--line-strong); border-radius: var(--radius-xs); }
.row-edit input[type="number"] { min-width: 3.5rem; }

.matrix td, .matrix th { text-align: center; white-space: nowrap; }
.matrix td:first-child, .matrix th:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
.cell-1 { background: var(--brand-soft); font-weight: 700; color: var(--brand-darker); }
.cell-2 { background: color-mix(in srgb, var(--brand-soft) 55%, var(--surface)); color: var(--brand-darker); }
.cell-3 { background: var(--surface-2); color: var(--ink); }
.cell-4 { background: var(--warn-soft); color: var(--warn); }

.subcard { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--sp-3); margin: var(--sp-2) 0; background: var(--surface-2); }

/* collapsible stage blocks */
.stage-block { border: 1px solid var(--line); border-radius: var(--radius-sm); margin: var(--sp-2) 0; background: var(--surface); overflow: hidden; }
.stage-block > summary { cursor: pointer; padding: .7rem .9rem; display: flex; gap: .6rem; align-items: baseline; list-style: none; font-weight: 600; }
.stage-block > summary::-webkit-details-marker { display: none; }
.stage-block > summary::before { content: '▸'; color: var(--muted); }
.stage-block[open] > summary::before { content: '▾'; }
.stage-block[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.person-block > summary { font-size: 1.02rem; align-items: center; }
.person-block > summary .badge { font-weight: 600; }
.person-block .list-main a { text-decoration: none; }
.person-block .list-main a:hover strong { text-decoration: underline; }
.stage-body { padding: var(--sp-3); }

/* setup hub */
.setup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.setup-card {
  display: block; padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
  transition: border-color .12s, transform .06s, box-shadow .12s;
}
.setup-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow-lg); color: var(--ink); }
.setup-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .35rem; }
.setup-card-head strong { font-size: 1rem; }
.setup-card .muted { font-size: .84rem; }

/* week strip on the dashboard */
.weekstrip { display: flex; gap: .5rem; }
.ws-day {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: .2rem;
  padding: .55rem .3rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  text-decoration: none; color: var(--ink); font-size: .72rem;
  transition: border-color .12s, box-shadow .12s;
}
.ws-day:hover { border-color: var(--brand); box-shadow: var(--shadow); color: var(--ink); }
.ws-dow { color: var(--muted); font-weight: 700; letter-spacing: .03em; }
.ws-num { font-size: .82rem; font-weight: 600; }
.ws-bar { width: 62%; height: 40px; background: var(--surface-2); border-radius: 4px; display: flex; align-items: flex-end; overflow: hidden; }
.ws-bar > span { width: 100%; background: currentColor; display: block; border-radius: 4px 4px 0 0; }
.ws-meta { color: var(--muted); font-weight: 600; }
.heat-green { color: #3f9b63; } .heat-amber { color: #c98a1e; } .heat-red { color: #c0392b; } .heat-none { color: #d4dcd6; }
.heat-green.ws-day, td.heat-green, .heatcal a.heat-green { background: #eef7f1; }
.heat-amber.ws-day, td.heat-amber, .heatcal a.heat-amber { background: #fbf3e3; }
.heat-red.ws-day, td.heat-red, .heatcal a.heat-red { background: #fbe9e7; }
.heatcal a.heat-red .hc-m { color: var(--danger); font-weight: 700; }

/* calendar heat month */
.heatcal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heatcal .hc-h { font-size: .72rem; color: var(--muted); text-align: center; font-weight: 700; padding: .25rem 0; letter-spacing: .03em; }
.heatcal a {
  min-height: 68px; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: .35rem;
  text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: .12rem; font-size: .74rem;
  transition: border-color .12s, box-shadow .12s;
}
.heatcal a:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.heatcal a.today { outline: 2px solid var(--brand); outline-offset: -1px; }
.heatcal a.muted-day { opacity: .45; }
.heatcal .hc-n { font-weight: 700; }
.heatcal .hc-m { color: var(--muted); font-size: .7rem; margin-top: auto; }

/* task progress control */
.progress-ctl { display: inline-flex; gap: .25rem; align-items: center; flex-wrap: wrap; }
.btn.prog { padding: .2rem .45rem; min-width: 1.7rem; font-size: .82rem; font-weight: 700; }
.btn.prog.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-darker); }
.btn.prog.done.on { background: var(--brand); color: #fff; }

/* calendar — room gantt */
.gantt { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.gantt table { border-collapse: collapse; }
.gantt th, .gantt td { border: 1px solid var(--line); padding: 0; font-size: .7rem; }
.gantt td.rn, .gantt th.rn {
  position: sticky; left: 0; background: var(--surface); font-weight: 650;
  padding: .35rem .6rem; min-width: 118px; text-align: left; z-index: 2;
}
.gantt th.rn { background: var(--surface-2); }
.gantt .daycell { width: 22px; height: 32px; text-align: center; color: var(--muted); vertical-align: top; }
.gantt .bar {
  color: #fff; height: 30px; line-height: 30px; white-space: nowrap; overflow: visible;
  display: block; padding-left: 4px; font-weight: 600; border-radius: 4px;
}
.gantt .bar.clone, .gantt .bar.seed { background: #6fae86; }
.gantt .bar.veg { background: #4f9d72; }
.gantt .bar.flower { background: var(--brand); }
.gantt .bar.dry, .gantt .bar.harvest { background: #b9862f; }
.gantt .bar.other { background: #7c8a82; }
.gantt td.today { background: var(--brand-soft); box-shadow: inset 2px 0 0 var(--brand); }

/* calendar month nav strip */
.month-nav { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.month-nav strong { font-size: 1.05rem; min-width: 11rem; text-align: center; }

/* calendar: "Stretch" breaks out of the centred column; "Fullscreen" fills the screen */
.cal-stage.is-wide {
  width: min(96vw, 1700px);
  margin-left: calc(50% - min(48vw, 850px));
}
.cal-stage.is-wide .gantt .daycell { width: 30px; }
.cal-stage:fullscreen {
  width: 100vw; height: 100vh; margin: 0; padding: var(--sp-4);
  background: var(--bg); overflow: auto; box-sizing: border-box;
}
.cal-stage:fullscreen .gantt .daycell { width: 34px; height: 40px; }
.cal-stage:fullscreen .heatcal a { min-height: 96px; font-size: .8rem; }
@media (max-width: 900px) { .cal-stage.is-wide { width: auto; margin-left: 0; } }

/* ============================================================
   Density: Compact
   ============================================================ */
body.density-compact { font-size: 15px; }
body.density-compact .wrap { padding: var(--sp-3) var(--sp-3) var(--sp-5); }
body.density-compact .card { padding: var(--sp-3); margin-bottom: var(--sp-2); border-radius: 10px; }
body.density-compact h1 { font-size: 1.4rem; margin: var(--sp-3) 0 .2rem; }
body.density-compact h2 { font-size: 1.02rem; margin-bottom: .4rem; }
body.density-compact .page-head { margin-bottom: var(--sp-3); }
body.density-compact .list li { padding: .45rem 0; }
body.density-compact .btn { padding: .45rem .75rem; font-size: .88rem; }
body.density-compact .btn.sm { padding: .25rem .5rem; }
body.density-compact .field { margin-bottom: var(--sp-2); }
body.density-compact table th, body.density-compact table td { padding: .38rem .5rem; }
body.density-compact .subcard, body.density-compact .rec { padding: var(--sp-2); margin: .4rem 0; }
body.density-compact .stage-body { padding: var(--sp-2); }
body.density-compact .setup-card { padding: var(--sp-3); }

/* ============================================================
   Narrow screens / phones
   ============================================================ */
@media (max-width: 560px) {
  .wrap { padding: var(--sp-3) .7rem 2.5rem; }
  .topbar { flex-wrap: wrap; gap: .4rem .6rem; padding: .6rem .75rem; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: .15rem; }
  .nav a { white-space: nowrap; }
  .nav-user { font-size: .82rem; gap: .45rem; }
  .page-head { flex-direction: column; align-items: flex-start; gap: .4rem; }
  h1 { font-size: 1.4rem; }
  .card { padding: var(--sp-3); }
  .btn { padding: .55rem .9rem; }               /* keep tap targets ~44px */
  .weekstrip { overflow-x: auto; }
  .weekstrip .ws-day { min-width: 46px; }
  .heatcal { gap: 3px; }
  .heatcal a { min-height: 56px; font-size: .68rem; }
  .row-edit { gap: .4rem .55rem; }
  .rec-grid { grid-template-columns: 1fr 1fr; }
  .gantt-row { grid-template-columns: 5rem 1fr; }
}
