:root {
  --bg: #f4f1e8;
  --surface: #fffdf7;
  --ink: #1f2a1c;
  --ink-2: #5b6656;
  --line: #ddd6c4;
  --brand: #2f4a2a;
  --brand-2: #4f7a3a;
  --accent: #c9a46a;
  --warn: #9a5b12;
  --warn-bg: #fbf0dc;
  --danger: #a03a2c;
  --focus: #3b6fd1;
  --radius: 8px;
  --panel: 380px;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); }
#app { height: 100%; }
.loading { padding: 24px; color: var(--ink-2); }

button, input, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  min-height: 36px;
}
button:hover:not(:disabled) { border-color: var(--brand-2); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--brand-2); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 4px 6px; color: var(--brand-2); text-decoration: underline; min-height: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

input, select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  background: #fff;
  width: 100%;
  min-height: 36px;
}
input[aria-invalid="true"] { border-color: var(--danger); }
label { display: block; font-size: 13px; color: var(--ink-2); }
label > input, label > select { margin-top: 3px; color: var(--ink); }

/* -------------------------------------------------- sign-in */
.auth { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  display: grid;
  gap: 12px;
}
.auth-card h2 { margin: 0; font-size: 18px; }
.auth-form { display: grid; gap: 10px; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; font-size: 14px; color: var(--ink-2); }
.auth-links .link { padding: 0; }
.auth details summary { cursor: pointer; font-weight: 550; margin-bottom: 8px; }
.auth h1 { margin: 0; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.auth h1 img { width: 32px; height: 32px; }
.auth p { margin: 0; color: var(--ink-2); }
.auth p.error { color: var(--danger); }
.auth p.ok { color: var(--brand-2); }
.error { color: var(--danger); font-size: 14px; margin: 0; }

/* -------------------------------------------------- layout */
.shell { display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px;
  background: var(--brand); color: #f3efe2;
}
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 650; white-space: nowrap; }
.topbar .brand img { width: 24px; height: 24px; }
.topbar .farm-name { color: #d9e4c8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .farm-switch { width: auto; max-width: 200px; min-height: 32px; padding: 3px 8px; background: rgba(255, 255, 255, 0.1); color: #f3efe2; border-color: rgba(243, 239, 226, 0.35); }
.topbar .farm-switch option { color: var(--ink); background: var(--surface); }
.topbar .spacer { flex: 1; }
.topbar .save { font-size: 13px; color: #d9e4c8; white-space: nowrap; }
.topbar .save.bad { color: #ffd38a; }
.topbar button { background: transparent; color: #f3efe2; border-color: rgba(243, 239, 226, 0.35); padding: 5px 10px; min-height: 32px; }
.topbar button:hover:not(:disabled) { border-color: #f3efe2; }

.workspace { display: grid; grid-template-columns: 1fr var(--panel); min-height: 0; }
.mapwrap { position: relative; min-height: 0; }
.panel { overflow-y: auto; background: var(--surface); border-left: 1px solid var(--line); padding: 0 0 40px; }

@media (max-width: 820px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: 55vh auto; overflow-y: auto; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .topbar .farm-name { display: none; }
  .topbar .farm-switch { max-width: 110px; }
}

/* -------------------------------------------------- panel */
.banner { margin: 12px 14px 0; padding: 10px 12px; background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); font-size: 14px; }
.banner .row { margin-top: 8px; }
.section { padding: 14px; border-bottom: 1px solid var(--line); }
.section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.section h2 .step { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 11px; letter-spacing: 0; }
.section h2 .done { background: var(--brand-2); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.muted { color: var(--ink-2); font-size: 13px; }
.stat { font-size: 20px; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--bg); border-radius: var(--radius); padding: 8px; }
.stats .muted { display: block; }
.results { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.results button { width: 100%; text-align: left; }
.warnings { margin: 8px 0 0; padding: 8px 10px; background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); font-size: 13px; }
.warn-title { margin: 12px 0 4px; color: var(--warn); font-weight: 600; font-size: 14px; }
.issues { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.issues button.link { color: var(--warn); text-align: left; }
.howto { margin: 0 0 12px; padding-left: 18px; font-size: 13px; color: var(--ink-2); display: grid; gap: 4px; }
.howto strong { color: var(--ink); font-weight: 600; }

.blocks { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.blocks button { width: 100%; text-align: left; display: flex; justify-content: space-between; gap: 8px; }
.blocks button[aria-current="true"] { border-color: var(--brand); background: #eef4e6; }

.selcard { margin: 12px 14px 0; padding: 12px; border: 2px solid var(--accent); border-radius: var(--radius); background: #fff; display: grid; gap: 10px; }
.selcard .warnings { margin: 0; }
.selhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.selhead h3 { margin: 0; font-size: 17px; }
.selcard h4 { margin: 4px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); }
.selcard p.muted { margin: 0; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
input.count { width: 64px; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--ink-2); }
dl.facts dd { margin: 0; }

/* -------------------------------------------------- map */
.map { position: absolute; inset: 0; overflow: hidden; background: #3a4a35; touch-action: none; user-select: none; cursor: grab; }
.map.drawing { cursor: crosshair; }
.map-tiles img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; pointer-events: none; }
.map-tiles img.missing { visibility: hidden; }
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.map-attribution { position: absolute; right: 0; bottom: 0; background: rgba(255, 253, 247, 0.85); font-size: 11px; padding: 2px 6px; color: #333; max-width: 70%; }
.map-scale { position: absolute; left: 10px; bottom: 10px; border: 2px solid #fff; border-top: 0; height: 10px; color: #fff; font-size: 11px; line-height: 0; text-shadow: 0 0 3px #000; padding-left: 4px; }
.map-ui { position: absolute; z-index: 2; }
.map-ui.zoom { right: 10px; top: 10px; display: grid; gap: 4px; }
.map-ui.zoom button { width: 36px; height: 36px; padding: 0; font-size: 20px; line-height: 1; }
.map-ui.zoom .lock { display: grid; place-items: center; margin-top: 6px; }
.map-ui.zoom .lock[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.map-ui.layer { left: 10px; top: 10px; }
.map-ui.layer select { width: auto; background: var(--surface); }
.map-ui.tools {
  left: 10px; top: 56px; display: grid; gap: 4px; padding: 4px;
  background: rgba(255, 253, 247, 0.95); border-radius: 10px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.map-ui.tools button { display: flex; align-items: center; gap: 8px; border-color: transparent; background: transparent; padding: 6px 10px; font-size: 14px; justify-content: flex-start; }
.map-ui.tools button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.map-ui.tools button svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.map-ui.tools .sep { height: 1px; background: var(--line); margin: 2px 4px; }
.map-ui.hintbar {
  left: 50%; top: 10px; transform: translateX(-50%); max-width: min(560px, calc(100% - 260px));
  background: rgba(31, 42, 28, 0.9); color: #fff; padding: 6px 8px 6px 14px; border-radius: 18px; font-size: 13px;
  display: flex; align-items: center; gap: 10px;
}
.map-ui.hintbar .actions { display: flex; gap: 6px; }
.map-ui.hintbar .actions:empty { display: none; }
.map-ui.hintbar button { min-height: 28px; padding: 3px 10px; font-size: 13px; background: rgba(255, 255, 255, 0.12); color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.map-ui.hintbar button.primary { background: #f0ce5a; color: #1f2a1c; border-color: #f0ce5a; }
.map-ui.flash { left: 50%; bottom: 36px; transform: translateX(-50%); background: var(--surface); padding: 8px 14px; border-radius: 16px; font-size: 14px; box-shadow: 0 2px 10px rgba(0,0,0,0.3); pointer-events: none; }

@media (max-width: 820px) {
  .map-ui.tools { top: auto; bottom: 30px; left: 8px; right: 8px; display: flex; overflow-x: auto; }
  .map-ui.tools button { flex-direction: column; gap: 2px; font-size: 11px; padding: 4px 8px; flex: none; }
  .map-ui.tools .sep { width: 1px; height: auto; margin: 4px 2px; flex: none; }
  .map-ui.hintbar { top: 54px; max-width: calc(100% - 20px); width: max-content; }
}

.map-svg .property { fill: rgba(240, 206, 90, 0.08); stroke: #f0ce5a; stroke-width: 2.5; }
.map-svg .area { fill: rgba(255, 255, 255, 0.05); stroke: #fff; stroke-width: 1.5; stroke-dasharray: 6 4; }
.map-svg .area.tunnel { fill: rgba(120, 180, 230, 0.18); stroke: #b9dcf7; }
.map-svg .area.selected { stroke: #ffe28a; stroke-width: 3; }
.map-svg .obstacle { fill: rgba(200, 80, 60, 0.35); stroke: #f3a08f; stroke-width: 1.5; }
.map-svg .obstacle.tree { fill: rgba(40, 110, 50, 0.45); stroke: #a9e29a; }
.map-svg .obstacle.pond { fill: rgba(60, 130, 210, 0.45); stroke: #9fd0ff; }
.map-svg .obstacle.selected { stroke: #ffe28a; stroke-width: 3; }
.map-svg .bed { fill: rgba(146, 196, 98, 0.6); stroke: #e9f5d8; stroke-width: 1; }
.map-svg .bed.guide { stroke: #f0ce5a; stroke-width: 2.5; }
.map-svg .bed.overlap { stroke: #ff4d3a; stroke-width: 2.5; }
.map-svg .bed.selected { fill: rgba(255, 226, 138, 0.85); stroke: #fff; stroke-width: 2; }
.map-svg .draft { fill: rgba(255, 255, 255, 0.15); stroke: #fff; stroke-width: 2; stroke-dasharray: 5 4; }
.map-svg .draft-bed { fill: rgba(240, 206, 90, 0.55); stroke: #fff; stroke-width: 1.5; }
.map-svg .box { fill: rgba(240, 206, 90, 0.12); stroke: #f0ce5a; stroke-width: 1.5; stroke-dasharray: 4 3; }
.map-svg .vertex { fill: #fff; stroke: #1f2a1c; stroke-width: 1.5; }
.map-svg .handle { fill: #fff; stroke: #1f2a1c; stroke-width: 2; }
.map-svg .handle.rotate { fill: #f0ce5a; }
.map-svg .handle-stem { stroke: #fff; stroke-width: 1.5; stroke-dasharray: 3 3; }
.map-svg .marker { fill: #e2553d; stroke: #fff; stroke-width: 2.5; }
.map-svg text { fill: #fff; font-size: 12px; font-weight: 600; paint-order: stroke; stroke: rgba(0, 0, 0, 0.75); stroke-width: 3px; }
.map-svg text.area-label { font-size: 14px; }
.map-svg text.bed-label { font-size: 11px; }
.map-svg text.measure { font-size: 14px; fill: #ffe28a; }

/* -------------------------------------------------- screens */
.tabs { display: flex; gap: 2px; margin-left: 8px; }
.tabs a { color: #d9e4c8; text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: 14px; white-space: nowrap; }
.tabs a:hover { background: rgba(255, 255, 255, 0.08); }
.tabs a[aria-current="page"] { background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: 600; }
@media (max-width: 820px) {
  .topbar { gap: 6px; padding: 8px 10px; }
  .topbar .brand span, .topbar .brand { font-size: 0; gap: 0; }
  .topbar .brand img { width: 26px; height: 26px; }
  .tabs { margin-left: 0; min-width: 0; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .topbar .save.quiet { display: none; }
  .topbar .save { font-size: 12px; }
}

.lockrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; margin: 4px 0 8px; border: 1px dashed var(--line); border-radius: var(--radius); font-size: 13px; color: var(--ink-2); }
.lockrow.locked { border-style: solid; background: #f1ede2; color: var(--ink); }
.lockrow button { flex: none; min-height: 30px; padding: 3px 10px; }

/* -------------------------------------------------- crops */
.crops { display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.crops-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.crops-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.crops-title h1 { margin: 0; font-size: 20px; }
.import-pill { background: #eef4e6; color: var(--brand); border-radius: 14px; padding: 4px 10px; font-size: 13px; }
.crops-body { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; min-height: 0; }
.crop-list { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.list-tools { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.filters { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
.chip { min-height: 30px; padding: 3px 10px; border-radius: 15px; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips.lists, .chips.in-lists { align-items: center; }
.chips.in-lists { margin: 4px 0 10px; }
.chip .count { opacity: 0.7; }
.chip.add { border-style: dashed; background: transparent; }
.list-bar { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; width: 100%; }
.list-bar .link { padding: 0; }
label.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: 14px; }
label.check input { width: auto; min-height: 0; margin: 0; }
.variety-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.variety-list li.empty { padding: 16px; }
.variety-item { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; text-align: left; padding: 9px 14px; background: transparent; }
.variety-item:hover { background: var(--bg); }
.variety-item[aria-current="true"] { background: #eef4e6; box-shadow: inset 3px 0 0 var(--brand); }
.vi-main { display: grid; min-width: 0; }
.vi-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vi-flags { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.flag { font-size: 11px; border-radius: 10px; padding: 1px 7px; white-space: nowrap; }
.flag.grown { background: #e2efd5; color: var(--brand); }
.flag.warn { background: var(--warn-bg); color: var(--warn); }
.list-foot { padding: 10px 14px; border-top: 1px solid var(--line); text-align: center; }
.crop-detail { overflow-y: auto; padding: 16px 20px 40px; }
.pad { padding: 8px 4px; }
.small { font-size: 12px; }
.detail-top { display: flex; justify-content: space-between; align-items: center; min-height: 20px; }
.detail-top .back { display: none; padding-left: 0; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 4px 0 10px; }
.detail-head h2 { margin: 0 0 2px; font-size: 22px; }
.detail-head p { margin: 0; }
.detail-head .link { padding: 0; }
.grow-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--ink); background: #eef4e6; border: 1px solid #cfe0bd; border-radius: 8px; padding: 8px 12px; white-space: nowrap; }
.grow-toggle input { width: 18px; height: 18px; min-height: 0; margin: 0; }
.crop-detail .banner { margin: 0 0 14px; }
.banner.ok { background: #eef4e6; color: var(--brand); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 20px; align-items: start; }
.fields { display: grid; gap: 14px; }
.fgroup { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px 12px; margin: 0; background: var(--surface); }
.fgroup legend { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); padding: 0 6px; }
.frow { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 1.3fr); gap: 2px 12px; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.frow:last-child { border-bottom: 0; }
.frow > label { color: var(--ink); font-size: 14px; }
.frow .unit { color: var(--ink-2); font-size: 12px; }
.fval { display: flex; align-items: center; gap: 6px; }
.fval input:not([type="checkbox"]), .fval select { max-width: 220px; }
.fval input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; margin: 0; }
.fhelp { grid-column: 1 / -1; margin: 0; font-size: 12px; }
.src { font-size: 11px; border-radius: 10px; padding: 1px 7px; white-space: nowrap; border: 1px solid transparent; }
.src-yours { background: #e5edfb; color: #2a4f9e; }
.src-johnnys { background: #e2efd5; color: var(--brand); }
.src-book { background: #f3e8d4; color: #7a5413; }
.src-estimate { background: #f1f1ee; color: #6b6b62; border-color: #ddd; }
.reset { font-size: 12px; padding: 2px 4px; }
.notes { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.refs { display: grid; gap: 12px; position: sticky; top: 0; }
.refbox { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: #fff; font-size: 14px; }
.refbox h3 { margin: 0 0 6px; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.refbox h3 a { font-weight: 400; color: var(--brand-2); }
.refbox p { margin: 4px 0; }
.refbox.book { background: #fbf6ec; }
.refbox.legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.container-list { list-style: none; margin: 0; padding: 0; max-height: 40vh; overflow-y: auto; display: grid; gap: 4px; }
.container-list li { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.add-container { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.add-container h3 { margin: 0; font-size: 15px; }
.import { display: grid; gap: 10px; }
.import p { margin: 0; }
.chips-field { border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 8px 12px; }
.progress { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; border: 1px solid var(--line); }
.progress span { display: block; height: 100%; background: var(--brand-2); transition: width 0.4s; }
.progress-wrap { display: grid; gap: 6px; }
.modal .card.wide { width: min(640px, 100%); }

@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: 1fr; }
  .refs { position: static; }
}
@media (max-width: 820px) {
  .crops { overflow-y: auto; }
  .crops-body { grid-template-columns: 1fr; }
  .crop-list { border-right: 0; }
  .crops:not(.showing-detail) .crop-detail { display: none; }
  .crops.showing-detail .crop-list { display: none; }
  .crops.showing-detail .crops-head { display: none; }
  .detail-top .back { display: inline-block; }
  .crop-detail { padding: 12px 14px 40px; overflow: visible; }
  .frow { grid-template-columns: 1fr; }
  .detail-head { flex-direction: column; }
}

/* -------------------------------------------------- plan */
.planscreen { display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.plan-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.plan-head .year { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: 15px; }
.plan-head .year select { width: auto; }
.plan-main { overflow-y: auto; padding: 14px 16px 60px; display: grid; gap: 16px; align-content: start; }
.plan-main h2 { font-size: 16px; margin: 0; }
.plan-main > * { min-width: 0; }
.warn-list li .link { white-space: normal; }
.plan-main h3 { font-size: 14px; margin: 6px 0; }
.row.spread { justify-content: space-between; }
.empty-plan { max-width: 520px; }
a.button { display: inline-block; padding: 7px 12px; border-radius: 6px; background: var(--brand); color: #fff; text-decoration: none; }
.plan-warnings, .plan-timeline, .plan-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.plan-warnings details { margin-top: 8px; }
.plan-warnings summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.warn-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.warn-list li { padding: 5px 8px 5px 10px; border-left: 3px solid #cbd3c2; background: var(--bg); border-radius: 0 6px 6px 0; }
.warn-list li.warning { border-left-color: var(--warn); background: var(--warn-bg); }
.warn-list li .link { text-align: left; padding: 0; color: inherit; }
.ok { color: var(--brand-2); }
.info-box { background: #eef4e6; border-radius: var(--radius); padding: 8px 10px; font-size: 14px; }

.plan-timeline .legend { gap: 10px; font-size: 12px; }
.lg::before { content: ""; display: inline-block; width: 14px; height: 10px; margin-right: 4px; border-radius: 2px; vertical-align: -1px; }
.lg.prep::before { background: repeating-linear-gradient(45deg, #c9b99a, #c9b99a 2px, #efe7d6 2px, #efe7d6 4px); }
.lg.grow::before { background: #6aa84f; opacity: 0.7; }
.lg.harvest::before { background: #2f6b20; }
.lg.buffer::before { background: #d8e3cf; }
.tl { margin-top: 10px; overflow-x: auto; }
.tl-row { display: grid; grid-template-columns: 120px minmax(640px, 1fr); align-items: stretch; border-bottom: 1px solid var(--line); }
.tl-headrow { border-bottom: 0; }
.tl-area { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); padding: 10px 0 4px; }
.tl-name { display: grid; align-content: center; padding: 4px 8px 4px 0; font-size: 13px; }
.tl-name .muted { font-size: 11px; }
.tl-track { position: relative; height: 56px; }
.tl-headrow .tl-track { height: 20px; }
.tl-months span { position: absolute; top: 2px; font-size: 11px; color: var(--ink-2); padding-left: 3px; }
.tl-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.tl-mark { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed #7aa0d6; z-index: 2; pointer-events: none; }
.tl-mark.today { border-left: 2px solid var(--danger); }
.tl-gap { position: absolute; top: 2px; bottom: 2px; min-height: 0; padding: 0; border: 1px dashed #b5c99e; background: rgba(200, 225, 170, 0.25); border-radius: 3px; z-index: 1; }
.tl-gap:hover { background: rgba(200, 225, 170, 0.6); }
.tl-bar { position: absolute; left: 0; right: 0; min-height: 0; padding: 0; border: 0; background: transparent; z-index: 3; border-radius: 0; pointer-events: none; }
.tl-bar .tl-seg { pointer-events: auto; cursor: pointer; }
.tl-bar:hover .tl-seg.grow, .tl-bar:hover .tl-seg.harvest { filter: brightness(1.1); }
.tl-bar.warn .tl-seg.grow { outline: 2px solid var(--warn); outline-offset: -2px; }
.tl-seg { position: absolute; top: 1px; bottom: 1px; border-radius: 3px; }
.tl-seg.prep { background: repeating-linear-gradient(45deg, #c9b99a, #c9b99a 2px, #efe7d6 2px, #efe7d6 4px); }
.tl-seg.grow { background: var(--c); opacity: 0.65; }
.tl-seg.harvest { background: var(--c); filter: brightness(0.75); }
.tl-seg.buffer { background: #d8e3cf; }
.tl-label { position: absolute; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 600; color: #fff; text-shadow: 0 0 2px rgba(0, 0, 0, 0.8); white-space: nowrap; padding-left: 4px; pointer-events: none; }
.tl-add { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 12px; font-size: 16px; line-height: 1; z-index: 4; opacity: 0.4; }
.tl-row:hover .tl-add, .tl-add:focus-visible { opacity: 1; }

.table-wrap { overflow-x: auto; margin-top: 8px; }
table.plantings { width: 100%; border-collapse: collapse; font-size: 14px; }
table.plantings th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: 12px; padding: 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.plantings th .link { color: inherit; padding: 0; text-decoration: none; }
table.plantings th .link[aria-pressed="true"] { color: var(--ink); text-decoration: underline; }
table.plantings td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.plantings tbody tr { cursor: pointer; }
table.plantings tbody tr:hover { background: var(--bg); }
table.plantings tr.warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
table.plantings tr.broken { opacity: 0.6; }
td.num { text-align: right; white-space: nowrap; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c); margin-right: 6px; }
.small-table { margin: 8px 0; }

.pform { display: grid; gap: 12px; }
.pform .fgroup { display: grid; gap: 8px; }
.pform .grid3 { grid-template-columns: 2fr 1fr 1fr; }
.pform input[type="range"] { padding: 0; }
.vresults { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 160px; overflow-y: auto; }
.vresults .link { text-align: left; padding: 2px 0; }
details.target { background: var(--bg); border-radius: var(--radius); padding: 6px 10px; }
details.target summary { cursor: pointer; font-size: 14px; color: var(--brand-2); }
details.target .row { margin: 8px 0; font-size: 14px; }
details.target input { width: 80px; }
.pform-preview { border: 1px solid #cfe0bd; background: #f6faf1; border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 8px; }
.pform-preview p { margin: 0; }
.timeline-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.timeline-steps li { display: grid; font-size: 14px; }
.timeline-steps li .muted { font-size: 12px; }

.map-ui.when { left: 10px; bottom: 30px; background: rgba(255, 253, 247, 0.95); border-radius: 10px; padding: 6px 10px; display: flex; align-items: center; gap: 10px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); font-size: 13px; }
.map-ui.when input[type="range"] { width: 220px; padding: 0; min-height: 0; border: 0; background: transparent; }
.when-date { white-space: nowrap; font-weight: 600; }
.map-svg .planting { stroke: rgba(255, 255, 255, 0.9); stroke-width: 1; }
.map-svg .planting.prep, .map-svg .planting.buffer { stroke-dasharray: 3 2; }
.map-svg text.planting-label { font-size: 10px; }
.map-svg .draft-plant { fill: rgba(255, 226, 138, 0.5); stroke: #ffe28a; stroke-width: 2; }
@media (max-width: 820px) {
  .map-ui.when { bottom: 96px; left: 8px; right: 8px; }
  .map-ui.when input[type="range"] { flex: 1; width: auto; }
  .tl-row { grid-template-columns: 80px minmax(560px, 1fr); }
  .plan-main { padding: 12px 10px 60px; }
  .pform .grid3 { grid-template-columns: 1fr 1fr; }
}

/* -------------------------------------------------- tasks */
.taskscreen { display: grid; grid-template-rows: auto auto 1fr; min-height: 0; }
.tasks-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.tasks-head .chips { width: auto; }
.tasks-head .year { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: 15px; }
.tasks-head .year select { width: auto; }
.sync { display: flex; flex-wrap: wrap; gap: 12px; padding: 8px 16px; background: var(--warn-bg); color: var(--warn); font-size: 14px; }
.sync .offline { font-weight: 600; }
.tasks-main { overflow-y: auto; padding: 12px 16px 60px; }
.print-title { display: none; }
.nav { margin-bottom: 10px; }
.nav .range { font-size: 16px; min-width: 150px; text-align: center; }
.day { margin-bottom: 14px; max-width: 860px; }
.day h3 { font-size: 14px; margin: 0 0 6px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.day.today h3 { color: var(--brand); }
.day.lateday h3 { color: var(--danger); }
.day .nothing { margin: 0 0 4px; }
.tasklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.task { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid #9db88a; border-radius: var(--radius); padding: 10px 12px; }
.task.late { border-left-color: var(--danger); }
.task.done { opacity: 0.6; }
.task.done .task-title { text-decoration: line-through; }
.task-check { width: 26px; height: 26px; min-height: 0; margin: 2px 0 0; accent-color: var(--brand); }
.task-title { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: baseline; font-weight: 550; }
.task-title .link { padding: 0; text-align: left; color: var(--ink); font-weight: 550; text-decoration: none; }
.task-title .link:hover { text-decoration: underline; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--ink-2); margin-top: 3px; align-items: center; }
.late-badge { color: var(--danger); font-weight: 600; }
.done-date { width: auto; min-height: 28px; padding: 2px 6px; font-size: 13px; }
.kind { font-size: 11px; font-weight: 600; border-radius: 10px; padding: 1px 8px; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.k-gh { background: #e5edfb; color: #2a4f9e; }
.k-bed { background: #f3e8d4; color: #7a5413; }
.k-plant { background: #e2efd5; color: var(--brand); }
.k-care { background: #efe6f5; color: #6b3d8a; }
.k-harvest { background: #fde4dc; color: #9b3a1c; }
.k-plan { background: #f1f1ee; color: #555; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-head { font-size: 12px; color: var(--ink-2); text-align: center; padding: 2px; }
.cal-day { display: flex; flex-direction: column; align-items: stretch; gap: 2px; min-height: 92px; padding: 4px; text-align: left; border-radius: 6px; background: var(--surface); }
.cal-day.other { opacity: 0.5; }
.cal-day.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal-num { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.cal-chip { font-size: 11px; border-radius: 4px; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.done { text-decoration: line-through; opacity: 0.6; }
.cal-more { font-size: 11px; color: var(--ink-2); }
.reminders { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.reminders li { display: flex; justify-content: space-between; gap: 8px; }
.reminder-add { display: grid; gap: 6px; margin-top: 6px; }
.reminder-add input[type="number"] { width: 80px; }
.reminder-add select { width: auto; }
@media (max-width: 820px) {
  .tasks-main { padding: 10px 10px 60px; }
  .cal-day { min-height: 64px; }
  .cal-chip { font-size: 10px; }
  .tabs a { padding: 6px 7px; font-size: 13px; }
}

/* -------------------------------------------------- records */
.recordsscreen { display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.records-main { overflow-y: auto; padding: 12px 16px 60px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }
.records-main > * { max-width: 980px; }
.card-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card-section h2 { font-size: 16px; margin: 0 0 8px; }
.harvest-form { display: grid; gap: 8px; max-width: 560px; }
.harvest-form .grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.harvest-form .primary { justify-self: start; }
.totals { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.totals li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted var(--line); padding: 3px 0; }
table.plantings tr.covered { opacity: 0.6; }
.records-main table.plantings tbody tr { cursor: default; }
.records-main table.clickable tbody tr { cursor: pointer; }
.suggestions { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.suggestions .link { padding: 0 2px; }
.precords { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; }
.precords h3 { font-size: 16px; margin: 0 0 6px; }
.precords h4 { font-size: 14px; margin: 12px 0 4px; }
.actuals { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.actuals label { display: grid; gap: 2px; }
.precords .row.add { flex-wrap: wrap; gap: 6px; align-items: center; }
.precords .row.add input[type="date"] { width: auto; }
.precords .row.add input[type="number"] { width: 90px; }
.precords .row.add select { width: auto; }
.precords .row.add input:not([type]) { flex: 1 1 160px; width: auto; }
.rec-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 2px; font-size: 14px; }
.rec-list li { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }
.rec-list li > span:first-child { flex: 1; }
.rec-list li.warn { color: var(--warn); }
.task-title .quick { min-height: 0; padding: 2px 10px; font-size: 13px; font-weight: 500; }
@media (max-width: 820px) {
  .records-main { padding: 10px 10px 60px; }
  .harvest-form .grid3 { grid-template-columns: 1fr 1fr; }
}

/* -------------------------------------------------- site admin */
.adminscreen { display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.admin-main { overflow-y: auto; padding: 12px 16px 60px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }
.admin-main > * { max-width: 1100px; }
@media (max-width: 820px) { .admin-main { padding: 10px 10px 60px; } }
.status { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 10px; padding: 1px 8px; margin-left: 6px; text-transform: uppercase; letter-spacing: 0.03em; background: #f1f1ee; color: #555; }
.status.s-active { background: #e2efd5; color: var(--brand); }
.status.s-pending { background: var(--warn-bg); color: var(--warn); }
.status.s-suspended, .status.s-declined { background: #f6e3e0; color: var(--danger); }
.adminscreen td .row { flex-wrap: wrap; gap: 4px; }
.adminscreen td button { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.modal h3 { margin: 6px 0 0; font-size: 15px; }

/* -------------------------------------------------- printing */
@media print {
  @page { margin: 12mm; }
  html, body, #app, .shell { height: auto; background: #fff; }
  .shell { display: block; }
  .topbar, .tasks-head, .sync, .nav button, .plan-head .row, .tl-add, .modal, .workspace, .crops, .records-main > .row, .suggestions button { display: none !important; }
  .taskscreen, .planscreen, .recordsscreen { display: block; }
  .tasks-main, .plan-main, .records-main { overflow: visible; padding: 0; }
  .card-section { border: 0; padding: 0; break-inside: avoid-page; }
  .table-wrap { overflow: visible; }
  .print-title { display: block; font-size: 18px; font-weight: 700; margin: 0 0 8px; }
  .task { break-inside: avoid; border: 1px solid #999; border-left-width: 4px; padding: 6px 8px; }
  .task-check { appearance: none; -webkit-appearance: none; border: 1.5px solid #333; border-radius: 3px; width: 18px; height: 18px; }
  .task-check:checked { background: #333; }
  .done-date { display: none; }
  .day { break-inside: avoid-page; }
  .plan-timeline, .plan-list, .plan-warnings { border: 0; padding: 0; }
  .tl { overflow: visible; }
  .tl-row { grid-template-columns: 70px 1fr; }
  .tl-seg, .lg::before, .kind, .swatch, .cal-chip { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .plan-warnings details:not([open]) { display: none; }
  a { color: inherit; text-decoration: none; }
}

/* -------------------------------------------------- dialogs */
.modal { position: fixed; inset: 0; background: rgba(20, 28, 18, 0.45); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal .card { width: min(460px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 12px; padding: 20px; display: grid; gap: 12px; }
.modal h2 { margin: 0; font-size: 18px; }
.people { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.people li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
