/* Mowing Tracker -- Jonathan Creek brand (jonathan-creek-brand skill):
   Deep Lake #12464F anchors, Slate #7E919A is the accent gray, Copper
   #945D38 is the one warm counterpoint (header accent bar, a single badge),
   Fog #E9EAEC is the ground, Mist #D3D8DA is for surfaces and lines only.
   Montserrat only; weight carries the hierarchy.

   The zone colors are deliberately NOT brand colors: they sit on top of
   satellite imagery, where only a clear green -> yellow -> red fade reads at
   a glance from a mower seat. The fade itself is computed in
   js/mowing-core.js (growthColor) and handed to CSS as --growth-fade for
   legends; it's used for the map, legends and status dots/pills/bars only --
   never for the page chrome. */

:root {
  --deep-lake: #12464F;
  --deep-lake-700: #0e3940;
  --slate: #7E919A;
  --copper: #945D38;
  --fog: #E9EAEC;
  --mist: #D3D8DA;

  --bg: var(--fog);
  --surface: #F4F6F6;
  --surface-2: #ECEFF0;
  --ink: var(--deep-lake);
  --ink-soft: #46636A;
  --line: var(--mist);
  --label: #5C7378;
  --focus: var(--slate);
  --danger: #a63d32;

  --zone-never: #c9ced1;
  --growth-fade: linear-gradient(to right, #31b45f, #f2c53d, #e2493f);
  --zone-outline: #F4F6F6;
  --zone-preview: #7fd4ff;
  --zone-fresh-ink: #1d6b39;
  --zone-soon-ink: #8a5a00;
  --zone-due-ink: #a3261f;

  --header-h: 60px;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(18, 70, 79, .22);
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b2a30;
    --surface: #123a41;
    --surface-2: #17444c;
    --ink: var(--fog);
    --ink-soft: #b8c4c8;
    --line: #2a5259;
    --label: #9fb0b6;
    --danger: #f08b7f;
    --zone-fresh-ink: #7fe0a2;
    --zone-soon-ink: #ffd27a;
    --zone-due-ink: #ff9b93;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b2a30;
  --surface: #123a41;
  --surface-2: #17444c;
  --ink: var(--fog);
  --ink-soft: #b8c4c8;
  --line: #2a5259;
  --label: #9fb0b6;
  --danger: #f08b7f;
  --zone-fresh-ink: #7fe0a2;
  --zone-soon-ink: #ffd27a;
  --zone-due-ink: #ff9b93;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -.01em; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

.eyebrow, .label {
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: 11px;
  font-weight: 700;
  color: var(--label);
  margin: 0;
}

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

/* ------------------------------------------------------------- Buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-block { width: 100%; }
.btn-primary { background: var(--deep-lake); color: var(--fog); }
.btn-primary:hover { background: var(--slate); }
/* On a dark surface Deep Lake disappears: Slate with dark ink instead. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary { background: var(--slate); color: var(--deep-lake-700); }
  :root:not([data-theme="light"]) .btn-primary:hover { background: #93a4ac; }
}
:root[data-theme="dark"] .btn-primary { background: var(--slate); color: var(--deep-lake-700); }
:root[data-theme="dark"] .btn-primary:hover { background: #93a4ac; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid currentColor; }
/* The one big "yes" -- a zone-green so it matches what the zone turns. */
.btn-go { background: #1d7a42; color: #F4F6F6; }
.btn-go:hover { filter: brightness(1.08); }
.btn-big { min-height: 60px; font-size: 16px; }
.btn-small { min-height: 40px; padding: 0 12px; font-size: 12px; }

/* On the dark header: Slate background, dark ink. */
.btn-header { background: var(--slate); color: var(--deep-lake-700); min-height: 42px; padding: 0 14px; }
.btn-header:hover { background: #93a4ac; }
.btn-icon { padding: 0; width: 42px; }

.btn-close {
  width: 44px; height: 44px;
  display: inline-grid; place-items: center;
  background: var(--surface-2);
  border: 0; border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  flex: none;
}

/* -------------------------------------------------------------- Header -- */

.topbar {
  position: relative;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--header-h);
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  background: var(--deep-lake) url("../assets/jonathan-creek-ripple.svg") center / 100% 100% no-repeat;
  color: var(--fog);
  border-bottom: 4px solid;
  border-image: linear-gradient(to right, var(--copper) 0%, rgba(148, 93, 56, 0) 100%) 1;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 34px; height: auto; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 18px; line-height: 1.1; color: var(--fog); }
.brand-sub {
  font-size: 12px; font-weight: 600; line-height: 1.25;
  color: rgba(233, 234, 236, .78);
}
.topbar-spacer { flex: 1; }

/* --------------------------------------------------------------- Setup -- */

.setup {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--deep-lake) url("../assets/jonathan-creek-ripple.svg") center top / 100% 220px repeat-y;
}
.setup-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 18px;
  padding: 28px 22px 24px;
  box-shadow: var(--shadow);
  border-top: 5px solid var(--copper);
  text-align: center;
}
.setup-logo { width: 96px; height: auto; margin: 0 auto 10px; display: block; }
.setup-card h1 { font-size: 26px; margin: 4px 0 6px; }
.setup-sub { color: var(--ink-soft); margin: 0 0 18px; font-size: 15px; }
.setup-step { text-align: left; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--label); }
.field input, .field select, .input {
  min-height: 52px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  font-size: 18px;
}
.field input:focus, .input:focus { border-color: var(--slate); outline: none; box-shadow: 0 0 0 3px rgba(126, 145, 154, .35); }
.form-error { color: var(--danger); font-size: 14px; font-weight: 600; min-height: 1.2em; margin: -4px 0 12px; }
.form-error:empty { margin: 0; min-height: 0; }

/* ----------------------------------------------------------------- Map -- */

.crew-page { overflow: hidden; }
.map-shell { height: 100dvh; display: flex; flex-direction: column; }
.map-wrap { position: relative; flex: 1; min-height: 0; }
.map { position: absolute; inset: 0; background: #1d2b2e; }

.legend {
  position: absolute;
  z-index: 800;
  top: 10px; left: 10px;
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(14, 57, 64, .82);
  color: var(--fog);
  font-size: 12px; font-weight: 600;
  pointer-events: none;
  max-width: calc(100% - 20px);
}
.legend { align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; border: 2px solid rgba(244, 246, 246, .85); }
.dot.is-never { background: var(--zone-never); border-style: dashed; border-color: var(--slate); }
/* The green -> yellow -> red fade, for legends. */
.fade-bar { display: inline-block; width: 72px; height: 10px; border-radius: 5px; background: var(--growth-fade); border: 1.5px solid rgba(244, 246, 246, .85); flex: none; }

.banner {
  position: absolute; z-index: 850;
  top: 48px; left: 10px; right: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fff4dc;
  color: #5c3d00;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow);
}

.empty-card {
  position: absolute; z-index: 850;
  left: 16px; right: 16px; top: 30%;
  max-width: 380px; margin: 0 auto;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
.empty-card h2 { font-size: 20px; margin-bottom: 6px; }
.empty-card p { margin: 0; color: var(--ink-soft); }

.map-fab {
  position: absolute; z-index: 850;
  right: 10px; bottom: 98px;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--surface);
  color: var(--deep-lake);
  box-shadow: var(--shadow);
  cursor: pointer;
}
:root[data-theme="dark"] .map-fab { color: var(--fog); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .map-fab { color: var(--fog); } }
.map-fab.is-active { color: #1a73e8; }

/* Zone name on hover (admin page only; the crew map has no labels). */
.leaflet-tooltip.zone-label {
  background: rgba(14, 57, 64, .86);
  color: #F4F6F6;
  border: 0;
  border-radius: 8px;
  padding: 4px 9px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
  font-family: var(--font);
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}
.leaflet-tooltip.zone-label::before { display: none; }
.leaflet-container { font-family: var(--font); }
.leaflet-control-zoom a { width: 40px !important; height: 40px !important; line-height: 40px !important; font-size: 20px !important; }
.leaflet-bottom.leaflet-right { margin-bottom: 150px; }
.admin-page .leaflet-bottom.leaflet-right { margin-bottom: 0; }

/* --------------------------------------------------------------- Sheet -- */

.sheet {
  position: fixed; z-index: 1100;
  left: 0; right: 0; bottom: 0;
  max-height: 85dvh;
  overflow-y: auto;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .28);
  animation: sheet-up .2s ease-out;
}
@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; width: 440px; transform: translateX(-50%); bottom: 16px; border-radius: 20px; animation: none; }
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 10px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-title { font-size: 24px; line-height: 1.15; margin-top: 6px; overflow-wrap: anywhere; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase;
}
/* Background is the zone's fade color (set inline); dark ink reads on all of it. */
.pill-growth { color: #0e3940; }
.pill-growth.is-never { background: var(--surface-2); color: var(--ink-soft); }
.pill-never { background: var(--surface-2); color: var(--ink-soft); }

.growth { margin-bottom: 14px; }
.growth-labels { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; gap: 10px; }
.growth-countdown { font-weight: 800; font-size: 17px; }
.growth-track { height: 14px; border-radius: 7px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.growth-bar { height: 100%; border-radius: 7px; transition: width .4s ease; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 12px; }
.facts dd { margin: 2px 0 0; font-weight: 600; font-size: 15px; }
.sheet-note {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 12px;
  padding: 8px 8px 8px 12px;
  min-height: 52px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 14px; font-weight: 600;
  color: var(--ink-soft);
}
.sheet-note > span:first-child { flex: 1; min-width: 150px; }
.sheet-note .btn { flex: none; min-height: 44px; }
.sheet-note .note-actions { display: flex; gap: 8px; flex: none; }
/* "Undo the cut marked today 3:16 PM by Trevor?" */
.sheet-note.is-confirming { background: rgba(166, 61, 50, .12); color: var(--ink); }
.sheet-note.is-confirming > span:first-child { flex-basis: 100%; }

.when-row { display: grid; gap: 8px; }
/* "Matt marked this zone cut today 3:39 PM. Was that the same mowing?" */
.same-ask { display: grid; gap: 10px; }
.same-text { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 600; font-size: 15px; }
.when-input { width: 100%; min-height: 52px; font-size: 17px; }

.confirm { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 10px; }
.confirm-q { margin: 0 0 2px; font-size: 18px; font-weight: 700; text-align: center; }
.confirm-q.is-note { font-size: 15px; font-weight: 600; color: var(--ink-soft); }

/* -------------------------------------------------------------- Drawer -- */

.drawer {
  position: fixed; z-index: 1100;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 100%);
  display: flex; flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding-top: env(safe-area-inset-top);
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 20px; }
.zone-list { list-style: none; margin: 0; padding: 0 0 calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; }
.zone-row {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  min-height: 64px;
  padding: 10px 16px;
  border: 0; border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.zone-row:hover { background: var(--surface-2); }
.zone-row .dot { width: 16px; height: 16px; }
.zone-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.zone-row-name { font-weight: 700; overflow-wrap: anywhere; }
.zone-row-sub { font-size: 13px; color: var(--ink-soft); }
.zone-row-when { font-size: 13px; font-weight: 800; text-align: right; flex: none; max-width: 40%; }
.when-fresh { color: var(--zone-fresh-ink); }
.when-soon { color: var(--zone-soon-ink); }
.when-due, .when-never { color: var(--zone-due-ink); }

/* ---------------------------------------------------------------- Menu -- */

.menu {
  position: fixed; z-index: 1200;
  top: calc(var(--header-h) + env(safe-area-inset-top) + 4px);
  right: 10px;
  width: min(300px, calc(100% - 20px));
  padding: 6px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.menu-who { margin: 6px 10px 8px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.menu-item {
  display: flex; align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 0; border-radius: 8px;
  background: transparent;
  text-align: left;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-danger { color: var(--danger); }

/* --------------------------------------------------------------- Toast -- */

.toast {
  position: fixed; z-index: 1300;
  left: 12px; right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 460px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 16px;
  min-height: 56px;
  border-radius: 12px;
  background: var(--deep-lake-700);
  color: var(--fog);
  box-shadow: var(--shadow);
  font-weight: 600;
}
.toast span { flex: 1; }
.toast-btn {
  min-height: 44px; padding: 0 16px;
  border: 0; border-radius: 8px;
  background: var(--slate); color: var(--deep-lake-700);
  font-weight: 800; letter-spacing: .1em; text-transform: uppercase; font-size: 13px;
  cursor: pointer;
}

/* =============================================================== Admin == */

.admin-page { min-height: 100dvh; }
.admin-page .topbar { position: sticky; top: 0; }
.admin-main { max-width: 1100px; margin: 0 auto; padding: 18px 16px 48px; display: grid; gap: 18px; }
.admin-grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .admin-grid { grid-template-columns: 1.2fr 1fr; align-items: start; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}
.card-head { margin-bottom: 12px; }
.card-head h2 { font-size: 19px; }
.card-head p { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }
/* Dot-and-rule divider opening each section. */
.rule { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.rule::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--slate); flex: none; }
.rule::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.admin-map { position: relative; height: 420px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
@media (max-width: 600px) { .admin-map { height: 320px; } }
.admin-map .map { position: absolute; inset: 0; }
.admin-legend { margin-top: 10px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.admin-legend span { display: inline-flex; align-items: center; gap: 6px; }

.steps { margin: 0 0 14px; padding-left: 20px; font-size: 14px; color: var(--ink-soft); }
.steps li { margin-bottom: 6px; }
.steps strong { color: var(--ink); }

.file-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 110px;
  padding: 16px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
}
.file-drop:hover, .file-drop.is-over { border-color: var(--slate); background: var(--surface-2); }
.file-drop small { font-weight: 500; color: var(--ink-soft); }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.diff { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--surface-2); }
.diff h3 { font-size: 16px; margin-bottom: 8px; }
.diff-group { margin: 8px 0; font-size: 14px; }
.diff-group strong { display: block; }
.diff-group ul { margin: 4px 0 0; padding-left: 18px; }
.diff-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; padding: 8px 6px;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--label);
  border-bottom: 1.5px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr.is-selected td { background: var(--surface-2); }
.cell-name { font-weight: 700; overflow-wrap: anywhere; }
.cell-sub { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.cycle-input { width: 74px; min-height: 40px; padding: 0 8px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--bg); font-size: 15px; }
.muted { color: var(--ink-soft); }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { flex: 1; min-width: 180px; margin: 0; }
.status-line { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.status-warn { color: var(--danger); }
.copy-row { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; font-size: 14px; }
.copy-row code { background: var(--surface-2); padding: 6px 10px; border-radius: 8px; overflow-wrap: anywhere; }
details.retired { margin-top: 12px; }
details.retired summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--ink-soft); min-height: 40px; display: flex; align-items: center; }
.admin-toast { bottom: 20px; }

.login-screen {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: var(--deep-lake) url("../assets/jonathan-creek-ripple.svg") center top / 100% 220px repeat-y;
}
