/* Turkey Bush App. Phone first, one hand, gloves, bright sun. */
:root {
  --bg: #f4f1e8; --card: #ffffff; --ink: #1b1f1a; --muted: #5b6157; --line: #d9d4c4;
  --green: #1d4d2f; --green-2: #2f6b43; --green-soft: #e3efe2;
  --amber: #a35a00; --amber-soft: #fff1d6; --red: #a4161a; --red-soft: #fde2e1;
  --blue: #0b57d0; --blue-soft: #dce8fd;
  --tap: 60px; --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-size: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.35; min-height: 100vh; overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
h1, h2, h3 { margin: 0; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 8px 14px; background: var(--green); color: #fff; }
.top h1 { flex: 1; font-size: 1.15rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who, .pill, .iconbtn { min-height: 48px; border: 0; border-radius: 999px; padding: 0 14px; font-weight: 600; }
.who { background: #fff; color: var(--green); width: 48px; padding: 0; font-size: 1.2rem; font-weight: 800; }
.pill { background: #fff; color: var(--green); white-space: nowrap; }
.pill.waiting { background: var(--amber-soft); color: var(--amber); }
.pill.off { background: rgba(255,255,255,.16); color: #fff; }
.pill.bad { background: var(--red-soft); color: var(--red); }
.iconbtn { background: transparent; color: #fff; padding: 0 8px; min-width: 48px; display: grid; place-items: center; }

/* ---------- layout ---------- */
main { padding: 12px 12px calc(var(--tap) + 110px + var(--safe-b)); max-width: 640px; margin: 0 auto; outline: none; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 0 var(--line); }
.card h2 { font-size: 1rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; text-transform: none; }
.big { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.sub { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.spacer { height: 8px; }
.label { display: block; font-weight: 700; margin: 4px 0 8px; }
.hint { color: var(--muted); font-size: .9rem; font-weight: 400; }
.warn { background: var(--amber-soft); color: #5c3400; border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.err { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.ok { background: var(--green-soft); color: var(--green); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }

/* ---------- buttons ---------- */
.btn { min-height: var(--tap); border: 2px solid var(--green); background: #fff; color: var(--green); border-radius: 12px;
  font-weight: 700; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.primary { background: var(--green); color: #fff; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; }
.btn:active, .chip:active, .step button:active { transform: scale(.97); }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.action { min-height: 96px; border-radius: var(--radius); border: 0; background: var(--green); color: #fff; font-weight: 800; font-size: 1.05rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.action svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* the Save bar sits above the tabs, in thumb reach */
.savebar { position: fixed; left: 0; right: 0; bottom: calc(68px + var(--safe-b)); z-index: 4; padding: 10px 12px;
  background: linear-gradient(to top, var(--bg) 75%, rgba(244,241,232,0)); }
.savebar .btn { width: 100%; max-width: 616px; margin: 0 auto; display: flex; min-height: 68px; font-size: 1.15rem; }

/* ---------- chips / segmented ---------- */
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.chips.wide { grid-template-columns: repeat(2, 1fr); }
.chips.three { grid-template-columns: repeat(3, 1fr); }
.chip { min-height: var(--tap); border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 6px 10px; font-weight: 700;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; }
.chip small { font-weight: 500; color: var(--muted); font-size: .82rem; }
.chip.center { align-items: center; text-align: center; }
.chip[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 2px var(--blue); }
.chip[aria-pressed="true"] small { color: #1b3d7a; }
.chip.mob { border-style: dashed; border-color: #8a6a22; }
.chip.short small { color: var(--amber); font-weight: 700; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; border: 2px solid var(--green); border-radius: 12px; overflow: hidden; }
.seg button { min-height: 56px; border: 0; background: #fff; color: var(--green); font-weight: 700; }
.seg button + button { border-left: 2px solid var(--green); }
.seg button[aria-pressed="true"] { background: var(--green); color: #fff; }
.grouphead { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 6px; }
.grouphead h3 { font-size: 1rem; }
.grouphead button { min-height: 44px; border: 0; background: transparent; color: var(--blue); font-weight: 700; padding: 0 8px; }

/* ---------- stepper ---------- */
.step { display: grid; grid-template-columns: 72px 1fr 72px; gap: 8px; align-items: center; }
.step button { min-height: 68px; border-radius: 12px; border: 2px solid var(--green); background: #fff; color: var(--green); font-size: 2rem; font-weight: 800; line-height: 1; }
.step .val { text-align: center; font-size: 2.1rem; font-weight: 800; }
.step input.val { width: 100%; border: 0; background: transparent; min-height: 68px; }
.hayrow { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.hayrow:last-child { border-bottom: 0; }
.hayrow .name { font-weight: 800; font-size: 1.1rem; }
.hayrow .step { grid-template-columns: 64px 64px 64px; }
.hayrow .step button { min-height: 64px; }
.hayrow .step .val { font-size: 1.9rem; }
.hayrow.on .name { color: var(--green); }

/* ---------- inputs ---------- */
input[type=text], input[type=number], input[type=date], input[type=url], input[type=password], textarea, input[inputmode] {
  width: 100%; min-height: var(--tap); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; font-size: 1.1rem; }
input:focus, textarea:focus { outline: 3px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
textarea { min-height: 96px; resize: vertical; }
input.bignum { font-size: 2rem; font-weight: 800; text-align: center; }
details.more { margin-top: 4px; }
details.more > summary { min-height: var(--tap); display: flex; align-items: center; font-weight: 700; color: var(--green); cursor: pointer; list-style: none; }
details.more > summary::before { content: "+"; display: inline-grid; place-items: center; width: 32px; height: 32px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--green); }
details.more[open] > summary::before { content: "–"; }
.photo { display: flex; gap: 10px; align-items: center; }
.photo img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; }
.filebtn input { position: absolute; width: 1px; height: 1px; opacity: 0; }

/* ---------- map ---------- */
.mapwrap { overflow: auto; border-radius: 12px; background: #e9e4d4; -webkit-overflow-scrolling: touch; }
.mapwrap svg { display: block; width: 100%; height: auto; }
.mapwrap.zoom svg { width: 220%; }
.map polygon { stroke: #fff; stroke-width: 1.5; cursor: pointer; }
.map polygon.sel { stroke: var(--blue); stroke-width: 4; }
.map polygon.mob { stroke: #5a3d00; stroke-width: 2.5; stroke-dasharray: 6 4; }
.map polygon.sel.mob { stroke: var(--blue); stroke-dasharray: none; }
.map text { font-size: 15px; font-weight: 700; fill: #1b1f1a; paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 3px; pointer-events: none; text-anchor: middle; }
.map text.d { font-weight: 600; font-size: 13px; }
.map circle.me { fill: var(--blue); stroke: #fff; stroke-width: 3; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list button { width: 100%; min-height: var(--tap); border: 0; background: transparent; text-align: left; padding: 10px 2px;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.list .t { font-weight: 700; }
.list .m { color: var(--muted); font-size: .88rem; grid-column: 1; }
.list .s { grid-row: 1 / span 2; grid-column: 2; font-size: .8rem; font-weight: 700; border-radius: 999px; padding: 4px 10px; }
.s.sent { background: var(--green-soft); color: var(--green); }
.s.waiting { background: var(--amber-soft); color: var(--amber); }
.s.rejected { background: var(--red-soft); color: var(--red); }

/* ---------- gps ---------- */
.gps { display: flex; gap: 12px; align-items: center; }
.gps .dot { width: 16px; height: 16px; border-radius: 50%; background: var(--muted); flex: none; }
.gps .dot.live { background: var(--blue); animation: pulse 1.4s infinite; }
.gps .dot.good { background: #2e8b3a; }
.gps .dot.warn { background: var(--amber); }
@keyframes pulse { 50% { opacity: .35; } }
.gpscell { font-size: 1.6rem; font-weight: 800; }

/* ---------- tabs ---------- */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs a { min-height: 68px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-weight: 700; font-size: .9rem; }
.tabs svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--green); background: var(--green-soft); }

/* ---------- toast & modal ---------- */
#toast { position: fixed; left: 12px; right: 12px; top: calc(env(safe-area-inset-top, 0px) + 72px); z-index: 20; display: flex; justify-content: center; pointer-events: none; }
#toast .t { background: #1b1f1a; color: #fff; border-radius: 14px; padding: 14px 16px; font-weight: 600; max-width: 600px; box-shadow: 0 6px 24px rgba(0,0,0,.25);
  display: flex; gap: 12px; align-items: center; pointer-events: auto; }
#toast .t button { min-height: 48px; border: 0; border-radius: 10px; background: #fff; color: #1b1f1a; font-weight: 800; padding: 0 14px; }
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 18px 14px calc(18px + var(--safe-b)); max-height: 92vh; overflow: auto; }
.sheet h2 { font-size: 1.3rem; margin-bottom: 10px; }
.sheet .btns { display: grid; gap: 10px; margin-top: 14px; }
.qr { background: #fff; padding: 12px; border-radius: 12px; display: grid; place-items: center; }
.qr svg { width: 260px; height: 260px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .95rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.small { font-size: .85rem; }
