/* Farmcell admin — an app shell, not a page.
   Tokens first: every colour, radius, space and shadow used anywhere is named here, so the
   whole surface can be retuned from one block and nothing drifts into a one-off value. */
:root {
  color-scheme: light dark;

  --bg:        #f4f2ee;
  --surface:   #ffffff;
  --surface-2: #faf9f7;
  --raised:    #ffffff;
  --line:      #e4e0d9;
  --line-soft: #eeebe5;

  --ink:   #17191c;
  --ink-2: #55595f;
  --ink-3: #8b9097;

  --brand:     #3aa0f3;
  --brand-dk:  #2379c4;
  --brand-tint:#e8f3fe;
  --gold:      #ffc02e;
  --gold-dk:   #b07d00;
  --gold-tint: #fff4d9;
  --good:      #2e9e63;
  --good-tint: #e4f4ec;
  --bad:       #d9533f;
  --bad-tint:  #fbeae7;
  --field:     #4fb553;

  --r-sm: 8px;  --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --shadow-1: 0 1px 2px rgba(16,18,20,.06), 0 1px 1px rgba(16,18,20,.04);
  --shadow-2: 0 4px 16px rgba(16,18,20,.08), 0 1px 2px rgba(16,18,20,.05);
  --sidebar: 232px;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0f1113;
    --surface:   #17191c;
    --surface-2: #1c1f23;
    --raised:    #1c1f23;
    --line:      #2a2e33;
    --line-soft: #23272b;
    --ink:   #f1efec;
    --ink-2: #a8adb4;
    --ink-3: #6f757d;
    --brand-tint: #12283c;
    --gold-tint:  #33280c;
    --gold-dk:    #ffc02e;
    --good-tint:  #12291d;
    --bad-tint:   #2e1714;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 6px 22px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.mono, code, td.num, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--r-sm); }

/* ------------------------------------------------------------------ shell -- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: var(--s-5);
  padding: var(--s-5) var(--s-4);
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-2); }
.brand .mark {
  width: 30px; height: 30px; display: grid; place-items: center; font-size: 17px;
  background: var(--good-tint); border-radius: var(--r-sm);
}
.brand b { font-size: 15px; letter-spacing: -.01em; }
.brand span { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; display: block; }

.nav { display: grid; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  padding: 9px var(--s-3); border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-2); font: inherit; font-weight: 550;
  cursor: pointer; text-align: left;
}
.nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav button.on { background: var(--brand-tint); color: var(--brand-dk); }
.nav .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }

.sidebar-foot { margin-top: auto; display: grid; gap: var(--s-3); }
.acct { display: grid; gap: 1px; padding: var(--s-3); background: var(--surface-2); border-radius: var(--r-sm); }
.acct .k { font-size: 10px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); }
.acct .v { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------- main -- */
main { padding: var(--s-6) var(--s-6) var(--s-7); max-width: 1180px; width: 100%; }
.pagehead {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4);
  margin-bottom: var(--s-5); flex-wrap: wrap;
}
.pagehead h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.pagehead p { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.pagehead .right { display: flex; align-items: center; gap: var(--s-3); }
.stamp { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- controls -- */
button {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  border-radius: var(--r-sm); padding: 8px 14px; background: var(--brand); color: #fff;
  transition: filter .12s, background .12s;
}
button:hover:not(:disabled) { filter: brightness(1.05); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); box-shadow: var(--shadow-1); }
button.ghost:hover:not(:disabled) { color: var(--ink); background: var(--surface-2); }
button.gold { background: var(--gold); color: #17191c; }
button.quiet { background: transparent; color: var(--ink-3); border-color: transparent; box-shadow: none; }
button.quiet:hover:not(:disabled) { color: var(--bad); background: var(--bad-tint); }
button.sm { padding: 5px 10px; font-size: 12.5px; }

input, select {
  font: inherit; width: 100%; min-width: 0; padding: 8px 10px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
}
input:focus, select:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-tint); }
input[type="number"] { -moz-appearance: textfield; text-align: center; padding: 8px 4px; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
label.field { display: grid; gap: 4px; }
label.field > span { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

/* ------------------------------------------------------------------ cards -- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1); margin-bottom: var(--s-4);
}
.card > header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line-soft);
}
.card > header h2 { margin: 0; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.card > header .hint { font-size: 12px; color: var(--ink-3); }
.card .body { padding: var(--s-5); }
.card .body.flush { padding: 0; }

/* Six tiles as a deliberate 3x2 block. auto-fit wrapped them 5+1 at this width, and one
   orphaned card reads as a mistake rather than a layout. */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); margin-bottom: var(--s-4); }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5); box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; min-height: 96px;
}
.stat .k { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.stat .v { font-size: 28px; font-weight: 680; letter-spacing: -.02em; margin-top: auto; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ------------------------------------------------------------------- bars -- */
.bars { display: grid; gap: var(--s-2); }
.bar { display: grid; grid-template-columns: 96px 1fr 78px; align-items: center; gap: var(--s-3); font-size: 13px; }
.bar .track { background: var(--line-soft); border-radius: var(--r-pill); height: 18px; overflow: hidden; }
.bar .fill { background: var(--field); height: 100%; border-radius: var(--r-pill); min-width: 3px; transition: width .3s ease; }
.bar .n { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bar .n small { color: var(--ink-3); }

/* ------------------------------------------------------------------ table -- */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  text-align: left; padding: 10px var(--s-4); white-space: nowrap; cursor: pointer;
  font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--line); user-select: none;
}
thead th:hover { color: var(--ink); }
thead th.sorted { color: var(--ink); }
thead th.sorted::after { content: " ↓"; }
thead th.sorted.asc::after { content: " ↑"; }
tbody td { padding: 11px var(--s-4); border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
.uid { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.livedot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 6px; }

/* ------------------------------------------------------------------- pill -- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 650; white-space: nowrap;
}
.pill.live { background: var(--good-tint); color: var(--good); }
.pill.soon { background: var(--gold-tint); color: var(--gold-dk); }
.pill.off  { background: var(--line-soft); color: var(--ink-3); }

/* ---------------------------------------------------------------- seasons -- */
/* A segmented control, not two buttons: the pair is one choice with one selected, and
   showing it as a track with a moving thumb is what says "these are alternatives". */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button {
  background: transparent; color: var(--ink-3); border: 0; box-shadow: none;
  padding: 4px 12px; font-size: 12.5px; border-radius: 6px;
}
.seg button:hover:not(.on) { color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.card > header { flex-wrap: wrap; }
.card > header .seg { margin-left: auto; }

.rows { display: grid; gap: var(--s-3); }
.season {
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  padding: var(--s-4); display: grid; gap: var(--s-3);
  grid-template-columns: minmax(150px, 1.4fr) minmax(110px, 1fr) 130px 108px 108px auto;
  align-items: end;
}
.season.off { opacity: .55; }
.season .acts { display: flex; gap: var(--s-2); align-items: center; }
.dates { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
@media (max-width: 1080px) { .season { grid-template-columns: repeat(3, 1fr); } .season .acts { grid-column: span 3; } }
@media (max-width: 680px)  { .season { grid-template-columns: repeat(2, 1fr); } .season .acts { grid-column: span 2; } }

/* The same rows, denser. Inputs sit bare in the cells — the column head is the label,
   so repeating it per row (as the cards must) is wasted vertical space. */
table.grid td { padding: 8px var(--s-3); vertical-align: middle; }
table.grid input, table.grid select { padding: 6px 8px; font-size: 13px; }
table.grid .dates { grid-template-columns: 52px 52px; }
table.grid tr.off { opacity: .55; }
table.grid td.acts { white-space: nowrap; text-align: right; }
table.grid td.acts button { margin-left: var(--s-1); }
table.grid .namecell { min-width: 160px; }
table.grid .idcell { min-width: 110px; }
/* "Strawberries" is the longest crop name and was being clipped to "Strawberri…". */
table.grid .cropcell { min-width: 132px; }

/* ------------------------------------------------------------------ states -- */
.empty { padding: var(--s-7) var(--s-5); text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink-2); font-size: 15px; margin-bottom: var(--s-1); }
.banner {
  display: flex; gap: var(--s-3); align-items: flex-start;
  background: var(--bad-tint); border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
  color: var(--ink); border-radius: var(--r-md); padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4); font-size: 13px;
}
.banner b { color: var(--bad); }
.skeleton { background: var(--line-soft); border-radius: var(--r-sm); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .5 } }
.note { font-size: 12.5px; color: var(--ink-3); margin: var(--s-3) 0 0; }

/* ------------------------------------------------------------------ toast -- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 8px);
  background: var(--ink); color: var(--bg); padding: 11px 20px; border-radius: var(--r-pill);
  font-size: 13.5px; font-weight: 550; opacity: 0; pointer-events: none; z-index: 40;
  box-shadow: var(--shadow-2); transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* -------------------------------------------------------------- sign-in -- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: var(--s-5); }
.gate .card { width: min(420px, 100%); margin: 0; box-shadow: var(--shadow-2); }
.gate .body { padding: var(--s-6); text-align: center; }
.gate .mark { font-size: 34px; }
.gate h1 { font-size: 19px; margin: var(--s-3) 0 var(--s-2); letter-spacing: -.01em; }
.gate p { color: var(--ink-3); font-size: 13px; margin: 0 0 var(--s-5); }
.gate button { width: 100%; padding: 11px; }
.gate code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: var(--s-4); }
  .sidebar .nav { grid-auto-flow: column; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .acct { display: none; }
  main { padding: var(--s-4); }
}
