/* Spray Manager - one stylesheet, no build step. */
:root {
  /* Graphite neutrals. Red, amber and green mean REI, PHI and clear only;
     the one accent is spray-tank blue, for links and selection. Actions are ink. */
  --bg: #f6f6f5;
  --surface: #ffffff;
  --surface-2: #f3f3f2;
  --ink: #18181a;
  --muted: #56565c;
  --faint: #76767c;
  --line: rgba(24, 24, 26, .09);
  --line-strong: rgba(24, 24, 26, .2);
  --brand: #1d5f8a;
  --brand-dark: #154a6c;
  --brand-tint: #eaf1f6;
  --danger: #b42318;
  --danger-tint: #fcebe9;
  --warn: #8f5500;
  --warn-tint: #fdf3e2;
  --info: #45454b;
  --info-tint: #f1f1f0;
  --success: #1f7038;
  --success-tint: #e7f3ea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 8px; font-weight: 600; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
.icon { flex: none; vertical-align: -3px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .88em; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: none; background: var(--bg); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand strong { display: block; font-size: 14px; line-height: 18px; font-weight: 600; }
.brand small { display: block; font-size: 12px; line-height: 16px; color: var(--faint); }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--ink); color: #fff; flex: none; }
.sidebar nav { padding: 12px 12px 16px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 8px; color: var(--muted); font-size: 14px; transition: background-color .15s var(--ease), color .15s var(--ease); }
.nav-link .icon { color: var(--faint); }
.nav-link:hover { background: rgba(24, 24, 26, .045); color: var(--ink); text-decoration: none; }
.nav-link.active { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, .04); }
.nav-link.active .icon { color: var(--ink); }
.nav-label { padding: 0 10px; margin: 20px 0 6px; font-size: 12px; line-height: 16px; color: var(--faint); }
.nav-group { margin-bottom: 4px; }
.nav-link.soon { color: var(--faint); cursor: default; }
.nav-link.soon em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--faint); }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.who { font-size: 13px; font-weight: 500; line-height: 18px; }
.who small { display: block; font-weight: 400; font-size: 12px; line-height: 16px; color: var(--faint); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 32px; background: var(--bg); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .menu-btn { display: none; }
.search { flex: 1; max-width: 480px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 12px; color: var(--faint); }
.search:focus-within { border-color: var(--brand); outline: 3px solid rgba(29, 95, 138, .15); }
.search input[type=search] { border: 0; outline: 0; padding: 0; min-height: 36px; background: transparent; }
.search input:focus { outline: 0; }
.search kbd { font: 11px/16px var(--mono); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--faint); }
.topbar-cta { margin-left: auto; }
.side-cta { padding: 4px 12px 0; }
.side-cta .btn { width: 100%; }
.content { padding: 28px 32px 48px; max-width: 1480px; width: 100%; }
.scrim { display: none; }
.toast { position: fixed; z-index: 50; right: 1.25rem; bottom: 1.25rem; display: flex; gap: .5rem; align-items: center; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.16); font-weight: 500; animation: toast-in .3s var(--ease), toast-out .3s var(--ease) 4s forwards; }
.toast .icon { color: #7fcf98; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(12px); opacity: 0; visibility: hidden; } }

@media (min-width: 901px) { .topbar .topbar-cta { display: none; } }
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 20; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .menu-btn { display: inline-flex; }
  .search kbd { display: none; }
  .topbar-cta span { display: none; }
  .content { padding: 20px 16px 48px; }
  /* Bigger touch targets on phones */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=password], input[type=search], input:not([type]), select, textarea { min-height: 44px; font-size: 16px; }
  .nav-link { height: 40px; }
  .toast { left: 1rem; right: 1rem; bottom: 1rem; }
}

/* ---------- page header ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 72ch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.crumbs { font-size: 13px; color: var(--faint); margin-bottom: 4px; }

/* ---------- cards / layout ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.split > *, .grid > * { min-width: 0; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.sticky { position: sticky; top: 1rem; }
@media (max-width: 1100px) { .sticky { position: static; } }

.stat { padding: 16px 20px; }
.stat .label { font-size: 13px; line-height: 20px; color: var(--muted); }
.stat .value { font-size: 28px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1; margin-top: 8px; letter-spacing: -.01em; }
.stat .value small { font-size: 14px; color: var(--muted); letter-spacing: 0; }
.stat .sub { font-size: 13px; line-height: 20px; color: var(--faint); margin-top: 6px; }

.module-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
.tile { display: flex; gap: .75rem; align-items: flex-start; padding: 1rem; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--brand); }
.tile .tile-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--surface-2); color: var(--muted); flex: none; }
.tile.soon { opacity: .6; }
.tile.soon .tile-icon { background: var(--surface-2); color: var(--faint); }
.tile strong { display: block; }
.tile small { display: block; line-height: 1.35; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  line-height: 1.2; white-space: nowrap; min-height: 36px;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .12s var(--ease);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:focus-visible, .nav-link:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: #2c2c30; }
.btn-danger { color: var(--danger); border-color: rgba(180, 35, 24, .3); }
.btn-danger:hover { background: var(--danger-tint); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 0 10px; font-size: 13px; min-height: 32px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline-form { display: inline; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.link-btn.danger { color: var(--danger); }

/* ---------- alerts & badges ---------- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: var(--success-tint); border-color: rgba(31, 112, 56, .2); color: var(--success); }
.alert-error, .alert-danger { background: var(--danger-tint); border-color: rgba(180, 35, 24, .2); color: var(--danger); }
.alert-info { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.alert-warn { background: var(--warn-tint); border-color: rgba(143, 85, 0, .2); color: var(--warn); }
.warn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.warn-list li { display: flex; gap: 8px; padding: 8px 12px; border-radius: 8px; font-size: 13px; line-height: 20px; }
.warn-list li .icon { margin-top: 2px; }
.warn-list li .icon { margin-top: 1px; }
.warn-list .w-danger { background: var(--danger-tint); color: var(--danger); }
.warn-list .w-warn { background: var(--warn-tint); color: var(--warn); }
.warn-list .w-info { background: var(--surface-2); color: var(--muted); }
.badge { display: inline-block; padding: 0 8px; border-radius: 6px; font-size: 12px; line-height: 20px; font-weight: 500; white-space: nowrap; }
.badge-green { background: var(--success-tint); color: var(--success); }
.badge-blue { background: var(--brand-tint); color: var(--brand-dark); }
.badge-grey { background: var(--surface-2); color: var(--muted); }
.badge-red { background: var(--danger-tint); color: var(--danger); }
.badge-amber { background: var(--warn-tint); color: var(--warn); }
/* Signature: signal words and restricted-use marks set like the boxed panel on a
   pesticide label. Square, ink, printed in capitals the way labels print them. */
.sig, .rup { display: inline-block; vertical-align: 1px; padding: 0 4px; border: 1.5px solid currentColor; border-radius: 2px; font-size: 10.5px; line-height: 14px; font-weight: 600; letter-spacing: .04em; color: var(--ink); background: transparent; }
.sig-danger { color: var(--danger); }
.rup { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-weight: 400; font-size: 12px; line-height: 16px; color: var(--faint); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafaf9; }
.table .row-link { color: var(--ink); font-weight: 500; }
.table tfoot td { font-weight: 500; background: var(--surface-2); border-top: 1px solid var(--line); }
.table-compact td, .table-compact th { padding: 6px 10px; }
.empty { padding: 32px 16px; text-align: center; color: var(--faint); }

/* ---------- forms ---------- */
label { display: block; font-weight: 500; font-size: 13px; line-height: 20px; margin-bottom: 4px; }
.field { margin-bottom: 16px; }
.field .help { font-size: 12px; line-height: 16px; color: var(--faint); margin-top: 6px; }
input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=password], input[type=search], input[type=url], input:not([type]), select, textarea {
  width: 100%; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--ink); font: inherit; font-size: 14px; min-height: 36px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(29, 95, 138, .15); border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--ink); vertical-align: -3px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(192px, 1fr)); gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 500px) { .form-grid .span-2 { grid-column: auto; } }
fieldset { border: 0; padding: 0; margin: 0; }
.form-section { padding: 20px; border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; }
.form-section > h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 20px; background: var(--surface-2); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.input-unit { display: flex; align-items: stretch; }
.input-unit input { border-radius: 8px 0 0 8px; min-width: 0; }
.input-unit span { display: grid; place-items: center; padding: 0 .6rem; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 8px 8px 0; background: var(--surface-2); color: var(--faint); font-size: 13px; white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.filters .field { margin: 0; min-width: 140px; }
.filters input[type=search] { min-width: 220px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 12px; color: var(--muted); font-size: 14px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--ink); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs .count { font: 12px var(--mono); color: var(--faint); margin-left: 6px; }

/* ---------- planner ---------- */
.farm-list { display: flex; flex-direction: column; gap: .5rem; max-height: 560px; overflow-y: auto; padding-right: .25rem; }
.farm { border: 1px solid var(--line); border-radius: 8px; }
.farm.has-sel { border-color: rgba(29, 95, 138, .35); background: #fbfcfd; }
.farm-head { display: flex; align-items: center; gap: .6rem; padding: .5rem .7rem; cursor: pointer; user-select: none; }
.farm-head .farm-name { font-weight: 500; flex: 1; }
.farm-head .farm-meta { font-size: .8rem; color: var(--muted); }
.farm-head .chev { transition: transform .15s; color: var(--faint); }
.farm.open .chev { transform: rotate(90deg); }
.farm-blocks { display: none; padding: .25rem .7rem .6rem 2.2rem; }
.farm.open .farm-blocks { display: block; }
.block-row { display: grid; grid-template-columns: 22px 1fr 110px; gap: .5rem; align-items: center; padding: .2rem 0; }
.block-row label { margin: 0; font-weight: 400; }
.block-row input[type=number] { min-height: 32px; padding: .3rem .5rem; text-align: right; }
.block-row .ac { font-size: .8rem; color: var(--muted); }

.lines-table td { vertical-align: middle; }
.lines-table input, .lines-table select { min-height: 34px; padding: .35rem .5rem; }
.lines-table .prod-name.invalid { border-color: var(--danger); }
.lines-table .prod-meta { font-size: .78rem; color: var(--muted); margin-top: .2rem; line-height: 1.35; }
.lines-table .rate-cell { width: 170px; }
.lines-table .basis-cell { width: 120px; }
@media (max-width: 800px) {
  .lines-table thead { display: none; }
  .lines-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
  .lines-table td { border: 0; padding: .1rem .25rem; }
  .lines-table td:first-child { grid-column: 1 / -1; }
  .lines-table .rate-cell, .lines-table .basis-cell { width: auto; }
  .lines-table td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--faint); }
}

.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px 2px 8px; font-size: 13px; }
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 .2rem; font-size: 1rem; line-height: 1; }

.summary .sum-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .1rem 1rem; }
.summary .sum-stats div { padding: 8px 0; border-bottom: 1px solid var(--line); }
.summary .k { font-size: 12px; line-height: 16px; color: var(--faint); }
.summary .v { font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 2px; }
.summary .v small { font-weight: 400; }
.summary h3 { margin: 20px 0 8px; font-size: 13px; font-weight: 600; color: var(--ink); }
.ppe-list { margin: 0; padding-left: 1.1rem; font-size: .9rem; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; font-size: .92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.rei-banner { display: flex; align-items: center; gap: .75rem; padding: .8rem 1rem; border-radius: var(--radius); background: var(--danger-tint); border: 1px solid #f2c4bf; color: var(--danger); margin-bottom: 1rem; }
.rei-banner strong { display: block; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.timeline li { padding: .35rem 0; border-bottom: 1px dashed var(--line); color: var(--muted); }
.timeline li b { color: var(--ink); font-weight: 500; }

/* ---------- login ---------- */
body.bare { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.bare-wrap { width: 100%; max-width: 420px; }
.bare-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; font-size: 17px; margin-bottom: 20px; }

/* =================== UX round 2 =================== */
.small-text { font-size: .82rem; }
.grow { flex: 1; }
.filters.card { padding: .85rem 1rem; margin-bottom: 1rem; }
input.invalid, textarea.invalid { border-color: var(--danger); outline-color: rgba(180, 35, 24, .25); }
a.rei-banner { text-decoration: none; }
a.rei-banner:hover { filter: brightness(.98); }
.stat-link { color: var(--ink); display: block; }
.stat-link:hover { text-decoration: none; border-color: var(--line-strong); }
.row-inactive td { opacity: .55; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.card-foot { border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; justify-content: space-between; }
.foot-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.warn-list .w-ok { background: var(--success-tint); color: var(--success); }

/* sticky table headers inside a scroll box + sortable headers */
.table-scroll { overflow: auto; max-height: calc(100vh - 230px); }
.table-scroll thead th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--line); }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--ink); }
th.sort::after { content: " \2195"; opacity: .3; font-size: .9em; }
th.sort[data-dir=asc]::after { content: " \2191"; opacity: .9; }
th.sort[data-dir=desc]::after { content: " \2193"; opacity: .9; }

/* chips & quick filters */
.chip-btn { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip-btn:hover { border-color: var(--ink); text-decoration: none; }
.chip-btn.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chips-row, .type-chips { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-bottom: .75rem; font-size: .85rem; }
.type-chips { margin-bottom: 1rem; }

/* planner */
.step { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font: 12px var(--mono); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .85rem; }
.section-head h3 { margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg-btn { border: 0; background: var(--surface); padding: .35rem .8rem; font: inherit; font-size: .88rem; cursor: pointer; display: inline-flex; gap: .3rem; align-items: center; color: var(--muted); }
.seg-btn + .seg-btn { border-left: 1px solid var(--line-strong); }
.seg-btn.active { background: var(--surface-2); color: var(--ink); font-weight: 500; }
.seg-btn[disabled] { opacity: .4; cursor: not-allowed; }
.field-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.field-tools input[type=search] { max-width: 220px; }
.field-tools select { width: auto; max-width: 220px; }
.block-count { font-size: .85rem; margin-bottom: .5rem; }
.field-map { height: 420px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: .75rem; }
.farm-list.compact { max-height: 260px; }
.program-pick { gap: .5rem; }
.program-pick select { width: auto; min-width: 220px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; box-shadow: 0 -1px 0 var(--line); }
.combo-host { overflow: visible; }
.combo { position: relative; }
.combo-list { position: absolute; z-index: 40; left: 0; top: calc(100% + 4px); width: min(560px, 85vw); max-height: 340px; overflow-y: auto; margin: 0; padding: .25rem; list-style: none; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.combo-list li { padding: .45rem .6rem; border-radius: 7px; cursor: pointer; line-height: 1.3; }
.combo-list li small { display: block; color: var(--muted); font-size: .76rem; margin-top: .1rem; }
.combo-list li.active, .combo-list li:hover { background: var(--surface-2); }
.combo-list li.none { color: var(--muted); cursor: default; }
.combo-list .uses { font-size: .7rem; color: var(--faint); }
.prod-meta-wrap { font-size: .78rem; color: var(--muted); margin-top: .25rem; line-height: 1.35; }
@media (max-width: 800px) { .lines-table td.prod-cell { grid-column: 1 / -1; } }

/* review dialog */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(560px, 92vw); box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.modal::backdrop { background: rgba(24, 24, 26, .4); }
.modal-body { padding: 1.25rem 1.4rem; }
.modal-body h2 { display: flex; gap: .5rem; align-items: center; color: var(--danger); }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* programs */
.program-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .9rem; }
.program-card { display: flex; flex-direction: column; gap: .4rem; padding: 1rem 1.1rem; color: var(--ink); }
.program-card:hover { text-decoration: none; border-color: var(--line-strong); }
.program-card.inactive { opacity: .6; }
.program-top { display: flex; justify-content: space-between; gap: .5rem; }
.program-lines { list-style: none; margin: .25rem 0; padding: 0; font-size: .9rem; }
.program-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--line); }

/* calendar */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .6rem; }
.cal-day { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-height: 260px; display: flex; flex-direction: column; }
.cal-day.today { border-color: var(--ink); }
.cal-day.past { background: var(--surface-2); }
.cal-day.drop { background: var(--brand-tint); border-style: dashed; }
.cal-head { position: relative; padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
.cal-date span { font-size: 12px; color: var(--faint); }
.cal-date strong { font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
.cal-add { position: absolute; top: .45rem; right: .45rem; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; color: var(--muted); }
.cal-add:hover { background: var(--surface-2); color: var(--ink); }
.wx { margin-top: .3rem; font-size: .74rem; line-height: 1.3; padding: .3rem .4rem; border-radius: 6px; background: var(--surface-2); }
.wx-short { font-weight: 500; }
.wx-ok { background: var(--success-tint); color: var(--success); }
.wx-caution { background: var(--warn-tint); color: var(--warn); }
.wx-poor { background: var(--danger-tint); color: var(--danger); }
.cal-items { padding: .45rem; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.cal-card { display: block; padding: .45rem .5rem; border-radius: 8px; border: 1px solid var(--line); border-left: 3px solid var(--brand); background: var(--surface); color: var(--ink); font-size: 13px; line-height: 18px; }
.cal-card:hover { text-decoration: none; box-shadow: var(--shadow); }
.cal-card[draggable] { cursor: grab; }
.cal-card.dragging { opacity: .4; }
.cal-card.st-completed { border-left-color: var(--line-strong); background: var(--surface-2); }
.cal-card.st-in_progress { border-left-color: var(--warn); }
.cal-card-top { display: flex; justify-content: space-between; gap: .25rem; align-items: center; margin-bottom: .15rem; }
.cal-card .badge { font-size: .65rem; padding: 0 .35rem; }
.cal-products { color: var(--muted); }
@media (max-width: 1100px) { .calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .calendar { grid-template-columns: 1fr; } .cal-day { min-height: 0; } }

/* field status board */
.status-legend { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.st-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 6px; font-weight: 500; font-size: 13px; }
.st-pill.st-rei { background: var(--danger-tint); color: var(--danger); }
.st-pill.st-phi { background: var(--warn-tint); color: var(--warn); }
.st-pill.st-clear { background: var(--success-tint); color: var(--success); }
.status-mini { display: flex; gap: .35rem; flex-wrap: wrap; margin: .5rem 0; }
.status-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.status-map { height: 640px; border-radius: 12px; border: 1px solid var(--line); position: sticky; top: 4.5rem; }
.status-map[hidden] + .status-grid { grid-column: 1 / -1; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; }
.status-card { border-radius: 10px; padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid #3f9a5c; background: var(--surface); font-size: 13px; }
.status-card.st-rei { border-left-color: #d0362a; background: #fff8f7; }
.status-card.st-phi { border-left-color: #d98e04; background: #fffbf3; }
.status-top { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.status-top strong { font-size: 15px; font-weight: 500; }
.st-word { font-size: 12px; font-weight: 500; }
.st-rei .st-word { color: var(--danger); }
.st-phi .st-word { color: var(--warn); }
.st-clear .st-word { color: var(--success); }
.status-until { margin-top: .25rem; }
.status-detail, .status-today { color: var(--muted); font-size: .78rem; margin-top: .2rem; }
.status-today { color: var(--brand); font-weight: 500; }
@media (max-width: 1000px) { .status-layout { grid-template-columns: 1fr; } .status-map { position: static; height: 380px; } }
body.tv { background: #141415; color: #ededed; }
body.tv .content { max-width: none; padding: 20px 24px; }
body.tv .page-head p, body.tv .muted { color: #a1a1a6; }
body.tv .page-head h1 { font-size: 36px; font-weight: 500; }
body.tv .status-card { background: #19191b; border-color: rgba(237, 237, 237, .08); color: #ededed; font-size: 17px; }
body.tv .status-card.st-rei { background: #2e1716; border-left-color: #e5484d; }
body.tv .status-card.st-phi { background: #2b2210; border-left-color: #e0a12a; }
body.tv .status-card.st-clear { border-left-color: #4cc38a; }
body.tv .status-detail { color: #a1a1a6; }
body.tv .st-rei .st-word { color: #f2777a; }
body.tv .st-phi .st-word { color: #eab44f; }
body.tv .st-clear .st-word { color: #4cc38a; }
body.tv .status-top strong { font-size: 1.3rem; }
body.tv .status-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
body.tv .status-map { height: calc(100vh - 140px); top: 1rem; }
body.tv .st-pill { font-size: 1rem; }

/* phone field screen */
.field-screen { max-width: 640px; margin: 0 auto; }
.fs-head { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; margin-bottom: 1rem; }
.fs-head h1 { margin: .15rem 0; font-size: 1.35rem; }
.fs-mix .table td, .fs-mix .table th { padding: .55rem .6rem; }
.fs-amt { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mix-no { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font: 12px var(--mono); }
.fs-safety { border-top: 1px solid var(--line); font-size: .9rem; display: flex; flex-direction: column; gap: .25rem; }
.btn-huge { width: 100%; min-height: 64px; font-size: 1.15rem; border-radius: 12px; margin: 1rem 0 .25rem; }
.fs-progress { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; font-size: .95rem; }
.fs-h { font-size: 1rem; margin: 1.1rem 0 .5rem; }
.fs-blocks { display: flex; flex-direction: column; gap: .45rem; }
.fs-block { display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 58px; padding: .6rem .8rem; border: 2px solid var(--line-strong); border-radius: 12px; background: var(--surface); font: inherit; text-align: left; cursor: pointer; color: var(--ink); }
.fs-block .fs-check { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line-strong); color: transparent; flex: none; }
.fs-block.done { border-color: rgba(31, 112, 56, .45); background: var(--success-tint); }
.fs-block.done .fs-check { background: var(--success); border-color: var(--success); color: #fff; }
.fs-block-name { flex: 1; }
.fs-block-ac { font-weight: 500; color: var(--muted); white-space: nowrap; }
.fs-finish { margin-top: 1.25rem; }
.fs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fs-done { text-align: center; margin-bottom: 1rem; }
.fs-done-icon { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--success); color: #fff; margin-bottom: .5rem; }
.fs-rei { font-size: 1.05rem; color: var(--danger); }
.lines-table td.prod-cell { min-width: 230px; }
.lines-table td.rate-cell { min-width: 140px; }
.lines-table td.basis-cell { min-width: 118px; }
.lines-table .prod-name { width: 100%; font-weight: 500; }
.fs-grid .span-2 { grid-column: 1 / -1; }
.fs-finish .card-head { flex-wrap: wrap; }
.status-grid { align-items: start; }
.btn-group { flex-wrap: wrap; max-width: 100%; }
@media (max-width: 600px) { .page-head .actions { width: 100%; } .page-head .actions > .btn, .page-head .actions > .btn-group { flex: 1 1 auto; } }

/* ---- install / updates pages ---- */
.checklist { list-style: none; padding: 0; margin: .75rem 0 1rem; font-size: .9rem; }
.checklist li { padding: .15rem 0; }
.checklist .ok { color: var(--success); }
.checklist .bad { color: var(--danger); font-weight: 500; }
.checklist .meh { color: var(--faint); }
pre.log { margin: 0; max-height: 260px; overflow: auto; font: 12px/1.45 var(--mono); white-space: pre-wrap; word-break: break-word; color: var(--muted); }
.version-tag { display: block; font-size: 11px; color: var(--faint); font-family: var(--mono); }

.void-form { display: flex; gap: .4rem; flex-wrap: wrap; }
.void-form input { flex: 1 1 14rem; min-width: 0; }
.fs-notes { margin-top: .35rem; padding: .5rem .6rem; background: var(--warn-tint); border-radius: 6px; }

/* Concentrate / TRV */
.linklike { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; cursor: pointer; font: inherit; }
.trv-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.trv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; }
.trv-grid label { font-size: .85rem; display: flex; flex-direction: column; gap: .25rem; }
.trv-out { margin: .6rem 0 .3rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.conc-tag { display: inline-block; border: 1px solid var(--line-strong); color: var(--ink); border-radius: 4px; padding: 0 5px; font: 12px/18px var(--mono); }

/* Bulletins Live! Two */
.check-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .35rem .9rem; }
.check-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .75rem; display: grid; gap: .25rem; }
.blt-box { margin-top: 1rem; border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; background: var(--surface-2); }
.blt-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.blt-head .btn:first-of-type { margin-left: auto; }
.blt-limits { font-size: .85rem; color: var(--warn); margin: .2rem 0; }
.blt-cov td { vertical-align: top; }
.blt-grid td small { display: block; }
.blt-line { margin: .4rem 0 0; font-size: .9em; }

/* Sprayer calibration */
.text-danger { color: var(--danger); }
.calib-nozzles input { width: 100%; min-width: 70px; }
.calib-nozzles td:first-child { width: 2rem; }
.calib-bad { border-color: var(--danger) !important; background: var(--danger-tint); }
.calib-verdict { font-weight: 500; margin: 8px 0 4px; }
.calib-verdict.ok { color: var(--success); }
.calib-verdict.bad { color: var(--danger); }
.calib-notes { margin: 0 0 .5rem; padding-left: 1.1rem; color: var(--danger); font-size: .86rem; }

/* Inventory */
.inv-lines select, .inv-lines input { width: 100%; }
.inv-lines td:first-child { min-width: 220px; }
#inv-count .inv-type th { background: var(--surface-2); font-size: 12px; color: var(--muted); }
.input-unit select { border-radius: 0 8px 8px 0; border-left: 0; width: auto; }

/* Home: field status board */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.home-side { display: flex; flex-direction: column; gap: 16px; }
.home-side .card { margin: 0; }
.board { margin: 0; }
.board .card-head { flex-wrap: wrap; row-gap: 4px; }
.board .card-head h2 { white-space: nowrap; }
.board-sum { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.board-sum .dot { margin-right: -6px; }
.board-link { margin-left: 4px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.dot-rei { background: var(--danger); }
.dot-phi { background: #c27c0e; }
.dot-clear { background: #3f9a5c; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; padding: 16px 20px 20px; }
.board-grid .empty { grid-column: 1 / -1; }
.farm-tile { display: flex; flex-direction: column; gap: 4px; min-height: 72px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); transition: border-color .15s var(--ease), background-color .15s var(--ease); }
.farm-tile:hover { text-decoration: none; border-color: var(--line-strong); }
.ft-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ft-name { font-weight: 500; }
.ft-when { font-size: 13px; line-height: 20px; color: var(--faint); }
.ft-when b { font-weight: 600; font-variant-numeric: tabular-nums; }
.farm-tile.ft-rei { background: var(--danger-tint); border-color: rgba(180, 35, 24, .22); }
.farm-tile.ft-rei .ft-when { color: var(--danger); }
.farm-tile.ft-phi { background: var(--warn-tint); border-color: rgba(143, 85, 0, .22); }
.farm-tile.ft-phi .ft-when { color: var(--warn); }
@media (max-width: 900px) { .home-grid { grid-template-columns: 1fr; } .home-side { flex-direction: row; } .home-side .card { flex: 1; } }
@media (max-width: 500px) { .home-side { flex-direction: column; } .board-grid { grid-template-columns: 1fr 1fr; padding: 12px; } .farm-tile { min-height: 0; padding: 10px 12px; } .ft-when.ft-plain { display: none; } }

/* Plan page: mix sheet, set like the sheet taped inside the shed door */
.mix-sheet { margin: 0 20px 16px; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.mix-sheet-head { display: flex; justify-content: space-between; gap: 12px; padding: 8px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.mix-sheet-head .mono { font-size: 12px; }
.mix-steps { list-style: none; margin: 0; padding: 0; }
.mix-step { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 52px; padding: 8px 14px; border-top: 1px solid var(--line); }
.mix-step:first-child { border-top: 0; }
.mix-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 4px; border: 1px solid var(--line-strong); font: 12px var(--mono); color: var(--muted); }
.mix-what { font-weight: 500; }
.mix-amt { text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.mix-amt b { font-size: 22px; line-height: 1.1; font-weight: 600; font-variant-numeric: tabular-nums; }
.mix-amt small { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.mix-water .mix-what { font-weight: 400; color: var(--muted); }
.mix-water .mix-amt { font-size: 13px; color: var(--muted); }
@media (max-width: 500px) { .mix-sheet { margin: 0 12px 12px; } .mix-amt b { font-size: 18px; } }

/* Reports */
.filter-note { align-self: center; font-size: 13px; }
.hist-block .card-head { align-items: flex-start; }
.hist-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.hist-clear { text-align: right; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; }
.hist-clear b { font-size: 18px; line-height: 1.2; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.hist-clear small { font-size: 12px; color: var(--faint); }
.hist-clear.is-late b { color: var(--danger); }

/* Pest models */
.model-figs { display: flex; gap: 32px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.model-figs .label { font-size: 13px; color: var(--muted); }
.model-figs .sub { font-size: 13px; color: var(--faint); margin-top: 4px; }
.model-fig { font-size: 28px; font-weight: 500; line-height: 1; margin-top: 8px; font-variant-numeric: tabular-nums; }
.model-note { font-size: 13px; }
.model-credit { margin-top: 16px; font-size: 12px; color: var(--faint); }
.cal-model { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; background: var(--warn-tint); color: var(--warn); font-size: 12px; font-weight: 500; }
.cal-model:hover { text-decoration: none; }
.model-alert .model-fig { color: var(--warn); }
.row-fc td { color: var(--muted); }
