/* Component $ Comparison — Ritchie-Smith Feeds.
   Layout: every tab is a "board" — farm panel (− / + boxes) on the left, results on the right
   (headline number, component bars, tiles, line-by-line table). The Present / TV view is the
   same board, full screen and scaled to the screen width.
   Theme: dark is the house look (it matches Present); the sun button switches to light for
   bright sunlight. The TV view always stays dark. */

/* ---------- tokens ---------- */
:root, .tv {
  --bg:#070c08; --bg-top:#0d1a0f;
  --glow-a:rgba(61,122,40,0.32); --glow-b:rgba(250,187,19,0.09);
  --card:rgba(255,255,255,0.045); --card-solid:#111811; --well:rgba(0,0,0,0.28);
  --line:rgba(255,255,255,0.09); --line-strong:rgba(255,255,255,0.28);
  --text:#F2F5EF; --text-2:#A9BCA6; --muted:#71866e;
  --good:#6FCF4A; --on-good:#0b1a0b; --bad:#FF7A6B; --hero-glow:rgba(111,207,74,0.25);
  --gold:#fabb13; --gold-bg:#fabb13; --gold-ink:#1a1405; --gold-soft:rgba(250,187,19,0.10); --gold-edge:rgba(250,187,19,0.5);
  --btn-bg:rgba(255,255,255,0.07); --btn-bg-hover:rgba(255,255,255,0.16); --btn-fg:#ffffff;
  --header-bg:rgba(16,90,47,0.6); --header-fg:#ffffff; --header-fg-2:rgba(255,255,255,0.78);
  --brand:#105a2f;
  /* component colours, checked for colour-blind separation on this background */
  --c-bf:#bf8a18; --c-pr:#2a7a36; --c-los:#5a96d8;
  --c-today:#5d6e5a;
  --font-body:"Open Sans","Segoe UI",system-ui,sans-serif;
  --font-mono:"IBM Plex Mono",ui-monospace,Consolas,monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg:#f4f3ee; --bg-top:#fbfaf6;
  --glow-a:rgba(16,90,47,0.07); --glow-b:rgba(207,147,65,0.08);
  --card:#ffffff; --card-solid:#ffffff; --well:#f0efe8;
  --line:rgba(16,40,20,0.12); --line-strong:rgba(16,40,20,0.32);
  --text:#10140f; --text-2:#4b5849; --muted:#7a8577;
  --good:#1c7a41; --on-good:#ffffff; --bad:#b3312f; --hero-glow:transparent;
  --gold:#8a5b00; --gold-bg:#fabb13; --gold-ink:#1a1405; --gold-soft:rgba(250,187,19,0.14); --gold-edge:rgba(176,122,18,0.55);
  --btn-bg:#ffffff; --btn-bg-hover:#f0efe8; --btn-fg:#10140f;
  --header-bg:#105a2f; --header-fg:#ffffff; --header-fg-2:rgba(255,255,255,0.8);
  --c-bf:#c99420; --c-pr:#1f6e34; --c-los:#3d86d6;
  --c-today:#9aa596;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* el.hidden always wins over a component's display */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  font-family: var(--font-body); font-size: 14px; line-height: 1.4;
  background:
    radial-gradient(1100px 650px at 80% 0%, var(--glow-a), transparent 65%),
    radial-gradient(900px 600px at 0% 100%, var(--glow-b), transparent 60%),
    linear-gradient(170deg, var(--bg-top) 0%, var(--bg) 70%) fixed, var(--bg);
}
h1, h2 { margin: 0; }
button { font-family: inherit; }
code { font-family: var(--font-mono); font-size: 0.92em; }
.good { color: var(--good); } .bad { color: var(--bad); } .flat { color: var(--muted); }

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 24px; background: var(--header-bg); color: var(--header-fg);
  border-bottom: 3px solid var(--gold-bg);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo-plate { display: flex; align-items: center; background: #fff; border-radius: 7px; padding: 3px 9px; flex: 0 0 auto; }
.brand-logo { height: 32px; width: auto; display: block; }
.brand-text { min-width: 0; }
.brand-text h1 { font-size: 19px; font-weight: 800; line-height: 1.15; letter-spacing: -0.01em; }
.brand-sub { display: block; font-size: 12px; color: var(--header-fg-2); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.topbar-btn, .topbar-icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgba(255,255,255,0.35); background: rgba(255,255,255,0.08); color: #fff;
  border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.topbar-icon-btn { padding: 6px; border-radius: 50%; }
.topbar-btn:hover, .topbar-icon-btn:hover { background: rgba(255,255,255,0.18); }
.topbar-btn.accent { background: var(--gold-bg); border-color: var(--gold-bg); color: var(--gold-ink); }
.topbar-btn.accent:hover { filter: brightness(1.08); }
.topbar-btn svg, .topbar-icon-btn svg { width: 17px; height: 17px; }
.icon-moon { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }
:root[data-theme="light"] .icon-sun { display: none; }

/* ---------- page, tabs, prices ---------- */
.page { max-width: 1340px; margin: 0 auto; padding: 18px 24px 48px; font-size: 14px; }
.nav-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.tabs {
  flex: 1; display: flex; gap: 4px; padding: 4px;
  background: var(--well); border: 1px solid var(--line); border-radius: 14px;
}
.tabs button {
  flex: 1 1 0; min-width: 0; border: none; background: transparent; color: var(--text-2);
  font-size: 14px; font-weight: 700; padding: 10px 8px; border-radius: 10px; cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--gold-bg); color: var(--gold-ink); }
.tabs button:focus-visible, .chip:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  background: var(--card); border: 1px solid var(--line); color: var(--text-2);
  border-radius: 999px; padding: 9px 16px; font-size: 13px; cursor: pointer;
}
.chip strong { color: var(--text); font-family: var(--font-mono); font-weight: 600; }
.chip:hover, .chip[aria-expanded="true"] { border-color: var(--gold-edge); }
.chip-caret { width: 15px; height: 15px; transition: transform 0.2s; }
.chip[aria-expanded="true"] .chip-caret { transform: rotate(180deg); }
.card-head-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.btn-hide {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--btn-bg); color: var(--text);
  font-size: 13px; font-weight: 700; padding: 5px 12px 5px 9px; border-radius: 999px;
}
.btn-hide svg { width: 15px; height: 15px; }
.btn-hide:hover { background: var(--btn-bg-hover); }
.btn-hide:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.pill { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); }

.card { background: var(--card-solid); border: 1px solid var(--line); border-radius: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 16px 20px 0; }
.card-head h2 { font-size: 16px; font-weight: 700; }
.btn-link { border: none; background: none; color: var(--gold); font-size: 13px; font-weight: 700; cursor: pointer; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.note { font-size: 12px; color: var(--muted); margin: 10px 20px 16px; }
.prices-panel { margin-bottom: 18px; background: var(--card); }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px 12px; padding: 12px 20px 0; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field-label em { font-weight: 400; font-style: normal; color: var(--muted); }
.input-wrap {
  display: flex; align-items: center; background: var(--well);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 10px; min-width: 0;
}
.input-wrap:focus-within { border-color: var(--gold); }
.input-wrap .pre, .input-wrap .post { font-family: var(--font-mono); font-size: 13px; color: var(--muted); flex: 0 0 auto; }
.input-wrap .pre { margin-right: 3px; }
.input-wrap .post { margin-left: 4px; }
input.num, input.text {
  flex: 1 1 auto; min-width: 0; width: 100%; border: none; background: transparent; outline: none;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 600;
  color: var(--text); padding: 8px 0;
}
input.text { font-family: var(--font-body); font-weight: 400; }
input.num::placeholder { color: var(--muted); font-weight: 400; }

/* ======================================================================
   Board components (shared by every tab and the Present / TV view)
   ====================================================================== */
.sw { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 0.2em; flex: 0 0 auto; vertical-align: -0.05em; }
.sw-bf, .seg-bf { background: var(--c-bf); }
.sw-pr, .seg-pr { background: var(--c-pr); }
.sw-los, .seg-los { background: var(--c-los); }
.sw-quota { background: var(--c-pr); }
.sw-incentive { background: var(--c-bf); }

.tv-body { display: grid; grid-template-columns: minmax(0, 27em) minmax(0, 1fr); gap: 1.6em; align-items: start; }

/* farm panel */
.tv-farm {
  background: var(--card); border: 1px solid var(--line); border-radius: 1.2em;
  padding: 1.4em; display: flex; flex-direction: column; gap: 1.3em; min-width: 0;
}
.tv-farm-head, .tv-hero-label, .tv-tile-label, .tv-chart-title, .tv-pair-head, .tv-sub-head {
  font-size: 0.82em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-2);
}
.tv-sub-head { margin-bottom: -0.6em; }
.tv-farm-top { display: flex; align-items: center; justify-content: space-between; gap: 0.6em; flex-wrap: wrap; }
.tv-reset {
  display: inline-flex; align-items: center; gap: 0.4em; min-width: 0;
  border: 1px solid var(--gold-edge); background: var(--gold-soft); color: var(--gold);
  font-family: inherit; font-size: 0.9em; font-weight: 700; padding: 0.45em 0.85em; border-radius: 999px; cursor: pointer; touch-action: manipulation;
}
.tv-reset svg { width: 1.1em; height: 1.1em; flex: 0 0 auto; }
.tv-reset:hover { filter: brightness(1.15); }
.tv-reset:active { transform: scale(0.96); }
.tv-reset:focus-visible, .tv-btn:focus-visible, .tv-seg-toggle button:focus-visible, .tv-select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.tv-step { display: block; }
.tv-step-label { display: block; color: var(--text-2); font-weight: 600; margin-bottom: 0.4em; }
.tv-step-label em { font-style: normal; font-weight: 400; color: var(--muted); }
.tv-step-row { display: flex; align-items: center; gap: 0.6em; min-width: 0; }
.tv-step-unit { color: var(--text-2); flex: 0 0 auto; }
/* Typeable value boxes */
.tv-step-val {
  flex: 1 1 0; min-width: 0; width: 100%; text-align: center;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; color: inherit;
  background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0; outline: none; padding: 0.05em 0;
}
.tv-step-val:hover { border-bottom-color: var(--line-strong); }
.tv-step-val:focus { border-bottom-color: var(--gold); background: var(--gold-soft); }
.tv-step-val::placeholder { color: var(--muted); }
.tv-step-row .tv-step-val { font-size: 2.3em; }
.tv-step.invalid .tv-step-val, .tv-mini.invalid .tv-step-val { border-bottom-color: var(--bad); }
.tv-btn {
  width: 2.7em; height: 2.7em; flex: 0 0 auto; border-radius: 50%;
  border: 1.5px solid var(--line-strong); background: var(--btn-bg); color: var(--btn-fg);
  font-size: 1.1em; font-weight: 700; cursor: pointer; line-height: 1; touch-action: manipulation;
}
.tv-btn:hover { background: var(--btn-bg-hover); }
.tv-btn:active { transform: scale(0.94); }
.tv-btn.sm { width: 2.2em; height: 2.2em; }
/* Each component: its name on one line, then [today] → [what if] */
.tv-pair { display: flex; flex-direction: column; gap: 0.5em; }
.tv-pair-head, .tv-pair-row { display: grid; grid-template-columns: minmax(0, 1fr) 1.2em minmax(0, 1fr); align-items: center; gap: 0.25em 0.4em; }
.tv-pair-head span:first-child { display: none; }
.tv-pair-head span { text-align: center; }
.tv-pair-row { margin-bottom: 0.4em; }
.tv-comp { grid-column: 1 / -1; font-weight: 700; display: flex; align-items: center; gap: 0.5em; }
.tv-mini { display: flex; align-items: center; gap: 0.2em; min-width: 0; background: var(--well); border-radius: 999px; padding: 0.3em; border: 1px solid var(--line); }
.tv-mini .tv-step-val { font-size: 1.2em; }   /* room for a full 4-decimal test like 4.4264 */
.tv-pct { font-family: var(--font-mono); color: var(--text-2); flex: 0 0 auto; margin: 0 0.1em 0 -0.1em; }
.tv-mini.hot { border-color: var(--gold-edge); box-shadow: 0 0 0 0.25em var(--gold-soft); }
.tv-mini.hot .tv-step-val, .tv-mini.hot .tv-pct { color: var(--gold); }
.tv-arrow { color: var(--muted); text-align: center; }
.tv-hint, .tv-note { margin: 0; color: var(--muted); font-size: 0.92em; }
.tv-note:empty { display: none; }
.tv-note { color: var(--gold); }
.tv-note.bad { color: var(--bad); }
.tv-pricing { display: flex; flex-direction: column; gap: 0.9em; padding-top: 1.2em; border-top: 1px solid var(--line); }
.tv-seg-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3em; padding: 0.3em; background: var(--well); border-radius: 0.8em; border: 1px solid var(--line); }
.tv-seg-toggle.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tv-seg-toggle button {
  border: none; background: transparent; color: var(--text-2); font-family: inherit; font-size: 1em; font-weight: 700;
  padding: 0.65em 0.3em; border-radius: 0.6em; cursor: pointer; touch-action: manipulation; min-width: 0;
}
.tv-seg-toggle button small { display: block; font-size: 0.75em; font-weight: 600; opacity: 0.8; margin-top: 0.1em; }
.tv-seg-toggle button[aria-checked="true"] { background: var(--gold-bg); color: var(--gold-ink); }
.tv-weights { display: flex; flex-direction: column; gap: 0.5em; }
.tv-wrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: center; gap: 0.6em; }
.tv-wrow .tv-comp { grid-column: auto; }
.tv-price-list { display: flex; flex-direction: column; gap: 0.35em; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tv-price-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 1.2em auto; align-items: center; gap: 0.5em; }
.tv-price-row > span:first-child { font-family: var(--font-body); font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 0.45em; min-width: 0; }
.tv-select {
  width: 100%; font-family: var(--font-body); font-size: 1.05em; font-weight: 600; color: var(--text);
  background: var(--well); border: 1px solid var(--line-strong); border-radius: 0.7em; padding: 0.6em 0.7em;
}

/* results */
.tv-main { display: flex; flex-direction: column; gap: 1.5em; min-width: 0; }
.tv-hero { padding: 0.2em 0 0; }
.tv-hero-value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700;
  font-size: 4.6em; line-height: 1.05; letter-spacing: -0.03em; margin-top: 0.1em;
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 0.3em;
}
.tv-hero-value.good { color: var(--good); text-shadow: 0 0 0.6em var(--hero-glow); }
.tv-hero-value.bad { color: var(--bad); }
.tv-hero-value.flat { color: var(--text-2); }
.tv-hero-value.plain { color: var(--text); }
.hero-unit { font-family: var(--font-body); font-size: 0.26em; font-weight: 600; letter-spacing: 0; color: var(--text-2); }
.tv-hero-sub { font-family: var(--font-mono); font-size: 1.2em; color: var(--text-2); margin-top: 0.3em; }

.tv-chart, .tv-card { background: var(--card); border: 1px solid var(--line); border-radius: 1.2em; padding: 1.3em 1.5em; min-width: 0; }
.tv-chart-head, .tv-card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6em 1em; flex-wrap: wrap; margin-bottom: 1em; }
.tv-chart-title.sub { margin: 1.4em 0 0.8em; }
.tv-legend { display: flex; gap: 1.2em; color: var(--text); font-weight: 600; flex-wrap: wrap; }
.tv-legend span { display: inline-flex; align-items: center; gap: 0.45em; }
.tv-bar-row { display: grid; grid-template-columns: 7em minmax(0, 1fr) 7.5em; align-items: center; gap: 1em; margin: 0.7em 0; }
.tv-bar-name { font-weight: 700; color: var(--text-2); min-width: 0; overflow-wrap: anywhere; line-height: 1.2; }
.tv-bar-name.hot { color: var(--gold); }
.tv-bar { display: flex; gap: 2px; height: 3em; min-width: 0; }
.tv-seg {
  display: flex; align-items: center; justify-content: center; overflow: hidden; min-width: 0;
  transition: width 0.45s cubic-bezier(.2,.8,.2,1); cursor: default;
}
.tv-seg:first-child { border-radius: 0.35em 0 0 0.35em; }
.tv-seg:last-child { border-radius: 0 0.35em 0.35em 0; }
.tv-seg b { font-family: var(--font-mono); font-weight: 600; font-size: 1.05em; color: #fff; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,0.45); }
.tv-seg:hover { filter: brightness(1.15); }
.tv-bar-total { font-family: var(--font-mono); font-weight: 700; font-size: 1.15em; text-align: right; white-space: nowrap; }
.tv-chart-foot, .tv-card-note { color: var(--muted); font-size: 0.85em; margin: 0.8em 0 0; }
.tv-card-head .tv-card-note { margin: 0; }

.tv-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1em; }
.tv-tile { background: var(--card); border: 1px solid var(--line); border-radius: 1em; padding: 1em 1.2em; min-width: 0; }
.tv-tile-val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.8em; margin-top: 0.25em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-unit { font-family: var(--font-body); font-size: 0.5em; font-weight: 600; color: var(--text-2); margin-left: 0.3em; }
.tv-tile-d { font-family: var(--font-mono); font-weight: 600; margin-top: 0.3em; display: flex; align-items: center; gap: 0.2em; min-height: 1.3em; }
.tv-tile-d svg { width: 1em; height: 1em; flex: 0 0 auto; }
.tv-tile-d.good { color: var(--good); } .tv-tile-d.bad { color: var(--bad); } .tv-tile-d.flat { color: var(--muted); }

.tv-tip {
  position: fixed; z-index: 80; pointer-events: none; max-width: 22em;
  background: var(--text); color: var(--card-solid); font-size: 13px; font-weight: 600;
  padding: 0.5em 0.8em; border-radius: 0.5em; box-shadow: 0 0.4em 1.4em rgba(0,0,0,0.35);
}

/* herd size card */
.herd-empty { margin: 0; color: var(--text-2); }
.herd-empty b { color: var(--gold); }
.herd-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1em; }
.herd-stat { background: var(--well); border-radius: 0.8em; padding: 0.9em 1.1em; min-width: 0; }
.herd-val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.9em; margin-top: 0.2em; white-space: nowrap; }
.herd-sub { color: var(--text-2); font-size: 0.9em; margin-top: 0.3em; }
.herd-more { display: block; font-family: var(--font-mono); font-weight: 700; color: var(--gold); font-size: 1.05em; margin-bottom: 0.1em; }
.herd-ok { display: block; font-weight: 700; color: var(--good); margin-bottom: 0.1em; }

/* pricing split: What if boxes are dimmed while "Today's tests" are being priced */
#boardSplit.tests-cur .tv-mini.hot { opacity: 0.45; box-shadow: none; }
#boardSplit.tests-cur .tv-mini.hot:focus-within, #boardSplit.tests-cur .tv-mini.hot:hover { opacity: 1; }

/* filling quota: until the farm is entered the layout stays, blank; the gauge has no markers yet */
#boardFill.fill-empty .pos-move, #boardFill.fill-empty .pos-mark { display: none; }

/* filling quota: shipping entry */
.ship-entry { display: flex; flex-direction: column; gap: 0.9em; }
.ship-entry .tv-sub-head { margin-bottom: -0.3em; }
.ship-calc { margin: -0.6em 0 0; font-family: var(--font-mono); font-size: 0.9em; color: var(--text-2); }
.ship-calc:empty { display: none; }
.ship-calc b { color: var(--gold); }

/* filling quota: credit position gauge (−15 … +5 days) */
.pos-gauge { padding: 1.6em 0.4em 0; }
.pos-track { position: relative; height: 1.1em; border-radius: 999px; background: var(--well); }
.pos-zone { position: absolute; top: 0; bottom: 0; }
.pos-zone.under { left: 0; width: 75%; border-radius: 999px 0 0 999px; background: linear-gradient(90deg, rgba(255,122,107,0.28), transparent); }
.pos-zone.over { left: 75%; right: 0; border-radius: 0 999px 999px 0; background: linear-gradient(90deg, transparent, var(--gold-soft)); }
.pos-zero { position: absolute; left: 75%; top: -0.3em; bottom: -0.3em; width: 2px; background: var(--line-strong); }
.pos-move { position: absolute; top: 0.3em; height: 0.5em; border-radius: 999px; transition: left 0.45s, width 0.45s; }
.pos-move.down { background: var(--bad); } .pos-move.up { background: var(--good); }
.pos-mark { position: absolute; top: 50%; width: 1.1em; height: 1.1em; margin: -0.55em 0 0 -0.55em; border-radius: 50%; border: 2px solid var(--card-solid); transition: left 0.45s; }
.pos-mark b { position: absolute; bottom: 1.5em; left: 50%; transform: translateX(-50%); font-size: 0.75em; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.pos-mark.label-below b { bottom: auto; top: 1.5em; }
.pos-gauge:has(.label-below) .pos-scale { margin-top: 1.6em; }
.pos-mark.start { background: var(--c-today); }
.pos-mark.end { background: var(--text); }
.pos-mark.end.under { background: var(--bad); } .pos-mark.end.over { background: var(--gold-bg); }
.pos-scale { display: grid; grid-template-columns: 75fr 0 25fr; margin-top: 0.6em; font-family: var(--font-mono); font-size: 0.8em; color: var(--text-2); }
.pos-scale span:nth-child(2) { transform: translateX(-50%); }
.pos-scale span:last-child { text-align: right; }
.pos-scale small { display: block; font-family: var(--font-body); color: var(--muted); }
.pos-lines { display: grid; grid-template-columns: repeat(auto-fit, minmax(13em, 1fr)); gap: 0.6em; margin-top: 1.2em; }
.pos-line { background: var(--well); border-radius: 0.7em; padding: 0.7em 0.9em; display: flex; flex-direction: column; gap: 0.2em; min-width: 0; }
.pos-line span { color: var(--text-2); font-size: 0.9em; }
.pos-line b { font-family: var(--font-mono); }
.pos-line b.good { color: var(--good); } .pos-line b.bad { color: var(--bad); }

/* filling quota: outcomes and ways to fill */
.outcomes, .ways { display: flex; flex-direction: column; }
.outcome, .way { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1em; align-items: center; padding: 0.8em 0; border-bottom: 1px solid var(--line); }
.outcome:last-child, .way:last-child { border-bottom: none; }
.outcome.extra { border-top: 1px dashed var(--line-strong); }
.outcome-title { font-weight: 700; }
.outcome-desc { color: var(--text-2); font-size: 0.92em; margin-top: 0.15em; }
.outcome-desc b { color: var(--gold); font-family: var(--font-mono); }
.outcome-val { font-family: var(--font-mono); font-weight: 700; font-size: 1.35em; text-align: right; white-space: nowrap; }
.outcome-val small { display: block; font-family: var(--font-body); font-size: 0.6em; font-weight: 600; color: var(--muted); white-space: normal; max-width: 16em; margin-left: auto; }
.outcome-val.good { color: var(--good); } .outcome-val.bad { color: var(--bad); }
.way-val { font-family: var(--font-mono); font-weight: 700; color: var(--gold); text-align: right; max-width: 18em; }

/* line-by-line table */
.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 0.55em 0.6em; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.tbl thead th { font-size: 0.78em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); white-space: nowrap; }
.tbl thead th.hot { color: var(--gold); }
.tbl tbody th { text-align: left; font-weight: 600; color: var(--text-2); }
.tbl tbody th .sw { margin-right: 0.45em; }
.tbl td { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td .v { display: block; }
.tbl td .v.muted { color: var(--muted); font-family: var(--font-body); font-size: 0.9em; }
.tbl td .d:empty { display: none; }
.tbl td .d { display: inline-flex; align-items: center; gap: 0.15em; font-size: 0.85em; font-weight: 600; }
.tbl td .d svg { width: 0.95em; height: 0.95em; }
.tbl td .d.good { color: var(--good); } .tbl td .d.bad { color: var(--bad); } .tbl td .d.flat { color: var(--muted); }
.tbl .t-input td { color: var(--gold); font-weight: 600; }
.tbl .t-group th { font-size: 0.78em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding-top: 1.2em; }
.tbl .t-strong th, .tbl .t-strong td { color: var(--text); font-weight: 700; }
.tbl .t-strong td .v { font-size: 1.08em; }
.tbl tr:last-child th, .tbl tr:last-child td { border-bottom: none; }

/* quota & tank */
.hbars { display: flex; flex-direction: column; gap: 0.7em; }
.hbar { display: grid; grid-template-columns: minmax(0, 12em) minmax(0, 1fr) 6.5em; align-items: center; gap: 0.9em; }
.hbars.compact { gap: 0.35em; }
.hbars.compact .hbar { grid-template-columns: minmax(0, 15em) minmax(0, 1fr) 4em; font-size: 0.95em; }
.hbar-name { color: var(--text-2); font-weight: 600; min-width: 0; }
.hbar-track { height: 1.6em; background: var(--well); border-radius: 0.35em; overflow: hidden; }
.hbars.compact .hbar-track { height: 1.1em; }
.hbar-fill { display: block; height: 100%; border-radius: 0.35em; transition: width 0.45s cubic-bezier(.2,.8,.2,1); }
.hbar-val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; white-space: nowrap; }
.b-today .hbar-fill { background: var(--c-today); }
.b-need .hbar-fill { background: var(--c-bf); }
.b-need.alt .hbar-fill { background: repeating-linear-gradient(135deg, var(--c-bf) 0 6px, transparent 6px 9px), var(--well); }
.b-tank.ok .hbar-fill { background: var(--good); }
.b-tank.short .hbar-fill { background: var(--bad); }
.b-cost .hbar-fill { background: var(--c-today); }
.b-cost.feed .hbar-fill { background: var(--c-bf); }
.b-cost.feed .hbar-name { color: var(--text); }

.vbars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0.5em; height: 15em; align-items: end; }
.q-col { display: flex; flex-direction: column; align-items: stretch; height: 100%; min-width: 0; }
.q-top { font-family: var(--font-mono); font-size: 0.8em; font-weight: 700; color: var(--gold); text-align: center; min-height: 1.3em; white-space: nowrap; }
.q-stack { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.q-base, .q-inc { display: block; transition: height 0.45s cubic-bezier(.2,.8,.2,1); }
.q-base { background: var(--c-pr); border-radius: 0 0 0.25em 0.25em; }
.q-inc { background: var(--c-bf); border-radius: 0.25em 0.25em 0 0; }
.q-inc[style*="height: 0%"] + .q-base { border-radius: 0.25em; }
.q-col.chosen .q-stack { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 0.3em; }
.q-lab { font-size: 0.78em; color: var(--text-2); text-align: center; margin-top: 0.5em; line-height: 1.1; }
.q-lab small { display: block; color: var(--muted); font-size: 0.9em; }

#quotaTable tr.peak th, #quotaTable tr.peak td { background: var(--gold-soft); }
#quotaTable tr.peak th::after { content: " ●"; color: var(--gold); font-size: 0.7em; }
.cell-input { display: inline-flex; align-items: center; width: 5.5em; padding: 0 0.5em; background: var(--well); border: 1px solid var(--line-strong); border-radius: 0.5em; }
.cell-input:focus-within { border-color: var(--gold); }
.cell-input input.num { font-size: 0.95em; padding: 0.3em 0; text-align: right; }
.cell-input .post { font-family: var(--font-mono); font-size: 0.85em; color: var(--muted); margin-left: 0.2em; }

/* cost of production */
.cop { display: flex; flex-direction: column; gap: 1.5em; }
.cop-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 1.5em; align-items: end; }
.cop-hero .tv-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cop-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.5em; align-items: start; }
.cop-split { display: flex; gap: 2px; height: 3em; }
.cop-split span { display: flex; align-items: center; padding: 0 0.8em; overflow: hidden; min-width: 0; }
.cop-split b { font-family: var(--font-mono); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-cash { background: var(--c-today); color: #fff; border-radius: 0.35em 0 0 0.35em; }
.cs-left { background: var(--good); color: var(--on-good); border-radius: 0 0.35em 0.35em 0; }
.cop-table tr.section th { padding-top: 1.2em; font-size: 0.78em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.cop-table tr.line th { font-weight: 400; color: var(--text); padding-left: 1em; }
.cop-table tr.total th, .cop-table tr.total td { font-weight: 700; color: var(--text); background: var(--well); }
.cop-table th { white-space: normal; }

/* ---------- buttons + print dialog ---------- */
.btn {
  font-size: 14px; font-weight: 700; padding: 9px 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--btn-bg); color: var(--text);
}
.btn:hover { background: var(--btn-bg-hover); }
.btn.primary { background: var(--gold-bg); border-color: var(--gold-bg); color: var(--gold-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { width: 100%; max-width: 440px; box-shadow: 0 12px 40px rgba(0,0,0,0.4); }
.modal-body { padding: 12px 20px 0; display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 20px; }
.print-options { display: flex; flex-direction: column; gap: 8px; }
.print-option { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.print-option input { accent-color: var(--gold-bg); width: 16px; height: 16px; margin: 0; }
.note-plain { font-size: 12.5px; color: var(--muted); margin: 0; }
.print-sheet { display: none; }
/* "A new version is ready" bar, shown by the offline copy (sw.js) */
.update-bar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 100;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  background: var(--card); color: var(--text); border: 1px solid var(--gold-edge); border-radius: 12px;
  padding: 10px 12px 10px 16px; box-shadow: 0 8px 30px rgba(0,0,0,0.35); font-size: 14px;
}
.update-bar button {
  border: none; background: var(--gold-bg); color: var(--gold-ink); font: inherit; font-weight: 700;
  padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
@media print { .update-bar { display: none; } }

/* ======================================================================
   Present / TV view: the same board, full screen, always dark,
   scaled from the screen width so it fills a 1080p TV or a laptop.
   ====================================================================== */
body.presenting { overflow: hidden; }
body.presenting > .topbar, body.presenting > .page { display: none; }
.tv {
  position: fixed; inset: 0; z-index: 50; overflow: auto;
  display: flex; flex-direction: column;
  color: var(--text); font-family: var(--font-body);
  /* scaled from the screen width AND height, so a TV, a laptop or a browser window that isn't full screen all fill edge to edge */
  font-size: clamp(11px, min(1.02vw, 1.8vh), 48px);
  background:
    radial-gradient(1200px 700px at 78% 18%, rgba(61,122,40,0.35), transparent 65%),
    radial-gradient(900px 600px at 8% 100%, rgba(250,187,19,0.10), transparent 60%),
    linear-gradient(160deg, #0d1a0f 0%, #070c08 100%);
}
.tv-top {
  display: flex; align-items: center; gap: 1.4em; padding: 1.1em 2.2em;
  border-bottom: 0.2em solid var(--gold-bg); background: rgba(16,90,47,0.55);
}
.tv-logo { height: 2.6em; width: auto; display: block; }
.tv-title { flex: 1; min-width: 0; }
.tv-title h1 { font-size: 2em; font-weight: 800; letter-spacing: -0.01em; line-height: 1.1; }
.tv-title span { color: var(--text-2); font-size: 1em; }
.tv-exit {
  border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.06); color: #fff;
  border-radius: 0.6em; padding: 0.5em; cursor: pointer; display: flex;
}
.tv-exit svg { width: 1.5em; height: 1.5em; }
.tv-exit:hover { background: rgba(255,255,255,0.16); }
@media (min-width: 901px) {
  /* title centred on the screen: logo left, title middle, exit right */
  .tv-top { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .tv-top .brand-logo-plate { justify-self: start; }
  .tv-title { text-align: center; }
  .tv-exit { justify-self: end; }
}
.tv #boardTv { flex: 1; display: flex; flex-direction: column; }
.tv #boardTv > .tv-body { flex: 1; }   /* the board fills the screen height, no empty band at the bottom */
.tv .tv-body { grid-template-columns: minmax(0, 30em) minmax(0, 1fr); gap: 2em; padding: 2em 2.2em 2.2em; align-items: stretch; }
.tv .tv-farm { padding: 1.6em; gap: 1.6em; }
.tv .tv-hint { margin-top: auto; }
.tv .tv-step-row .tv-step-val { font-size: 2.6em; }
.tv .tv-mini .tv-step-val { font-size: 1.45em; }
.tv .tv-hero-value { font-size: 6.4em; }
.tv .tv-hero-sub { font-size: 1.35em; }
.tv .tv-bar { height: 3.2em; }
.tv .tv-bar-row { grid-template-columns: 5.5em minmax(0, 1fr) 8.5em; }
.tv .tv-bar-total { font-size: 1.25em; }
.tv .tv-tile-val { font-size: 2em; }

/* Present board: 1 the farm today, 2 try a change, 3 milk pricing | story, three tiles, slim bars */
.present .tv-farm { gap: 1.2em; }
.present .tv-farm-top { align-items: flex-start; }
.farm-id { display: flex; flex-direction: column; gap: 0.35em; min-width: 0; flex: 1 1 12em; }
.farm-badge { align-self: flex-start; display: inline-flex; align-items: center; gap: 0.4em; font-size: 0.8em; font-weight: 700; padding: 0.3em 0.75em; border-radius: 999px; }
.farm-badge.avg { background: var(--btn-bg); color: var(--text-2); border: 1px solid var(--line-strong); }
.farm-badge.own { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-edge); }
.farm-name-input {
  width: 100%; min-width: 0; font-family: var(--font-body); font-size: 1.35em; font-weight: 800; color: var(--text);
  background: transparent; border: none; border-bottom: 2px solid transparent; outline: none; padding: 0.05em 0;
}
.farm-name-input::placeholder { color: var(--muted); font-weight: 600; font-size: 0.8em; }
.farm-name-input:hover { border-bottom-color: var(--line-strong); }
.farm-name-input:focus { border-bottom-color: var(--gold); }
.step { display: flex; flex-direction: column; gap: 0.7em; }
.step-head { display: flex; align-items: center; gap: 0.6em; }
.step-head .step-btn { margin-left: auto; font-size: 0.8em; padding: 0.35em 0.75em; }
.step-num { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; background: var(--gold-bg); color: var(--gold-ink); font-weight: 800; font-size: 0.85em; flex: 0 0 auto; }
.start-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6em; }
.start-cell { display: block; background: var(--well); border: 1px solid var(--line); border-radius: 0.8em; padding: 0.45em 0.6em; text-align: center; cursor: text; min-width: 0; }
.start-cell:focus-within { border-color: var(--gold); }
.start-cell.invalid { border-color: var(--bad); }
.start-cell .lab { display: block; font-size: 0.78em; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; }
.start-cell .lab em { font-style: normal; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--muted); }
.start-cell .cell-row { display: flex; align-items: baseline; justify-content: center; gap: 0.2em; min-width: 0; }
.start-cell .tv-step-val { flex: 0 1 auto; width: 4.2em; font-size: 1.55em; font-weight: 700; text-align: right; border-bottom: none; }
.start-cell .unit { font-size: 0.85em; color: var(--text-2); font-weight: 600; flex: 0 0 auto; }
.change-list { display: flex; flex-direction: column; gap: 0.7em; }
.change-row { display: grid; grid-template-columns: minmax(0, 7em) minmax(0, 1fr) auto; align-items: center; gap: 0.6em; }
.change-name { font-weight: 700; display: flex; align-items: center; gap: 0.5em; min-width: 0; }
.delta-step { display: flex; align-items: center; gap: 0.3em; min-width: 0; background: var(--well); border: 1px solid var(--gold-edge); box-shadow: 0 0 0 0.25em var(--gold-soft); border-radius: 999px; padding: 0.3em; }
.delta-step .tv-step-val { font-size: 1.35em; font-weight: 700; color: var(--gold); }
.delta-step.invalid .tv-step-val { border-bottom-color: var(--bad); }
.change-result { font-family: var(--font-mono); color: var(--text-2); text-align: right; white-space: nowrap; }
.change-result b { color: var(--text); }
.change-result b.up { color: var(--gold); }
.change-result b.down { color: var(--text-2); }
.delta-step .tv-pct { color: var(--gold); }
/* Steps 1-2-3 spread down the full height with a line between each, so each one reads on its own */
.present .tv-farm { justify-content: space-between; }
.present .step { gap: 0.9em; }
.present .step + .step, .present .step-last { padding-top: 1.3em; border-top: 1px solid var(--line); }
.present .step-last { gap: 0.8em; }
.present .tv-seg-toggle button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.story { font-size: 1.6em; font-weight: 700; line-height: 1.3; max-width: 28em; text-wrap: balance; }
.story b { color: var(--gold); }
.present .tv-hero-value { margin-top: 0.15em; }
.tv .present .tv-hero-value { font-size: 7.6em; }
.tv .present .story { font-size: 1.85em; }
.tv .present .tv-hero-sub { font-size: 1.5em; font-family: var(--font-body); }
.present .tv-hero-sub b { color: var(--text); font-weight: 700; }
/* Hero on the left, "try it on your phone" QR card on the right */
.present .tv-hero-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5em; }
.present .tv-hero-row .tv-hero { flex: 1 1 auto; min-width: 0; }
.share-card { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0.5em; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 1em; padding: 0.8em 0.8em 0.7em; }
.share-card img { width: 8.5em; height: 8.5em; display: block; border-radius: 0.4em; background: #fff; padding: 0.35em; }
.share-text { font-size: 0.85em; color: var(--text-2); line-height: 1.3; max-width: 10em; }
.share-text b { display: block; color: var(--gold); font-size: 1.1em; }
/* Example mode when nobody has touched it for a while: a small label so no one mistakes it for a real farm */
.tv-attract { display: flex; align-items: center; gap: 0.7em; align-self: flex-start; font-size: 0.95em; font-weight: 700;
  color: var(--gold-ink); background: var(--gold-bg); border-radius: 999px; padding: 0.35em 1em; margin: -0.6em 0 -0.4em; }
.tv-attract[hidden] { display: none; }
.tv-attract .attract-hint { font-weight: 600; opacity: 0.75; }
.attract-dot { width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--gold-ink); animation: attract-pulse 1.4s ease-in-out infinite; }
@keyframes attract-pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .attract-dot { animation: none; } }
.present .tv-main { justify-content: space-between; }
.present .tv-tiles.four { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: auto 0; gap: 1.2em; }
.present .tv-tiles.four .tv-tile { padding: 1.5em 1.3em; }
.present .tv-tiles.four .tv-tile-val { font-size: 2.45em; }
.present .tv-tiles.four .tv-tile-d { font-size: 1.2em; }
.present .tv-tiles.four .tile-sub2 { font-size: 0.9em; }
@media (min-width: 901px) and (max-width: 1500px) {
  /* still four across on laptops, a little smaller, so the board fits without scrolling */
  .present .tv-tiles.four { gap: 0.8em; }
  .present .tv-tiles.four .tv-tile { padding: 1em 1em; }
  .present .tv-tiles.four .tv-tile-val { font-size: 1.8em; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  .present .tv-tiles.four .tv-tile-val { font-size: 1.55em; }
}
.tile-sub2 { font-size: 0.85em; color: var(--muted); margin-top: 0.15em; }
.tile-sub2 .or-line { display: block; margin-top: 0.25em; color: var(--text-2); }
.tile-sub2 .or-line b { color: var(--text); font-family: var(--font-mono); }
.present .tv-chart.slim { padding: 1em 1.5em; }
.present .tv-chart.slim .tv-chart-head { margin-bottom: 0.5em; }
.present .tv-chart.slim .tv-bar { height: 2.4em; }
.present .tv-chart.slim .tv-bar-row { margin: 0.4em 0; }
.present .tv-chart.slim .tv-seg b { font-size: 0.9em; }
.present .tv-chart.slim .tv-bar-total { font-size: 1.05em; }
/* the change bar slides in when a change is first entered */
.present .tv-bar-row.appear { animation: bar-in 0.45s cubic-bezier(.2,.8,.2,1); }
@keyframes bar-in { from { opacity: 0; transform: translateY(0.6em); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .present .tv-bar-row.appear { animation: none; } }
.tv .present.tv-body { padding-top: 1.5em; padding-bottom: 1.5em; }
.tv .present .tv-farm { padding: 1.3em 1.5em; }

/* ---------- responsive ---------- */
@media (min-width: 1400px) {
  .page { font-size: 15px; }
}
@media (max-width: 1100px) {
  .cop-hero, .cop-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .page .tv-body { grid-template-columns: minmax(0, 1fr); }
  .tv-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-row { flex-wrap: wrap; }
  .tabs { flex: 1 1 100%; order: 2; }
}
@media (max-width: 900px) {
  .tv { font-size: 14px; }
  .tv .tv-body { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 16px; }
  .tv-top { padding: 10px 16px; gap: 8px 12px; flex-wrap: wrap; }
  .tv-top .brand-logo-plate { order: 1; }
  .tv-exit { order: 2; margin-left: auto; }
  .tv-title { order: 3; flex: 1 1 100%; }
  .tv-title h1 { font-size: 1.3em; }
  .tv .tv-farm { padding: 1.1em; gap: 1.1em; }
  .tv .tv-hero-value { font-size: 3.4em; }
  .tv .tv-tiles { grid-template-columns: 1fr 1fr; }
  .tv .tv-bar-row { grid-template-columns: 4.5em 1fr 6.5em; gap: 0.6em; }
  .tv-legend { gap: 0.9em; }
  .present .tv-tiles.four { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8em; }
  .present .tv-tiles.four .tv-tile { padding: 1em 1.1em; }
  .present .tv-tiles.four .tv-tile-val { font-size: 1.6em; }
  .story, .tv .present .story { font-size: 1.25em; }
  .tv .present .tv-hero-value { font-size: 3.4em; }
  .tv .present .tv-hero-sub { font-size: 1.1em; }
  .share-card { display: none; }   /* on a phone they already have it */
}
@media (max-width: 640px) {
  .tv-hero-value { font-size: 3.2em; }
  .tv-bar-row { grid-template-columns: 5em minmax(0, 1fr) 6em; gap: 0.6em; }
  .tv-chart, .tv-card { padding: 1em; }
  .hbar { grid-template-columns: minmax(0, 1fr) 6em; }
  .hbar .hbar-track { grid-column: 1 / -1; grid-row: 2; }
  .hbars.compact .hbar { grid-template-columns: minmax(0, 1fr) 4em; }
  .cop-hero .tv-tiles { grid-template-columns: minmax(0, 1fr); }
  .herd-grid { grid-template-columns: minmax(0, 1fr); }
  .outcome, .way { grid-template-columns: minmax(0, 1fr); gap: 0.4em; }
  .outcome-val, .way-val { text-align: left; max-width: none; }
  .outcome-val small { margin-left: 0; }
  .pos-scale small { display: none; }
  .vbars { gap: 0.25em; height: 12em; }
  .q-lab { font-size: 0.7em; }
  .q-top { font-size: 0.7em; }
}
@media (max-width: 520px) {
  /* Logo + buttons on the first line, title on its own line below */
  .topbar { padding: 8px 16px 10px; flex-wrap: wrap; row-gap: 6px; }
  .brand { display: contents; }
  .brand-logo-plate { order: 1; }
  .topbar-actions { order: 2; gap: 6px; }
  .brand-text { order: 3; flex: 1 1 100%; }
  .brand-logo { height: 26px; }
  .brand-text h1 { font-size: 16px; }
  .brand-sub { font-size: 11.5px; }
  .topbar-btn span { display: none; }
  .topbar-btn { padding: 7px; border-radius: 50%; }
  .page { padding: 14px 16px 32px; }
  .tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .tabs button:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .tabs button { font-size: 13px; padding: 9px 4px; }
  .chip { flex: 1 1 100%; justify-content: center; }
  .tv-farm { padding: 1.1em; }
  .page .tv-tile-val { font-size: 1.45em; }
  .tbl th, .tbl td { padding: 0.5em 0.35em; }
  .tbl tbody th { font-size: 0.95em; }
  .field-grid { grid-template-columns: 1fr 1fr; padding: 10px 14px 0; }
  #quotaTable { font-size: 0.86em; }
  #quotaTable th, #quotaTable td { padding: 0.5em 0.25em; }
  #quotaTable tbody th { white-space: nowrap; }
  #quotaTable thead th { white-space: normal; }
  .cell-input { width: 4.4em; }
  .note { margin: 10px 14px 12px; }
  .card-head { padding: 12px 14px 0; }
}
@media (max-width: 420px) {
  /* Present: test name above its change box so the box gets the full width */
  .change-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 0.35em; }
  .change-name { grid-column: 1 / -1; }
  .start-cell .tv-step-val { font-size: 1.35em; }
  .brand-logo { height: 22px; }
  .brand-logo-plate { padding: 3px 7px; }
  .topbar-actions { gap: 4px; }
  .topbar-btn, .topbar-icon-btn { padding: 6px; }
  .tv-logo { height: 2em; }
  .tv-title span { display: none; }
  .tv-pair-head, .tv-pair-row { grid-template-columns: minmax(0, 1fr) 0.9em minmax(0, 1fr); gap: 0.25em 0.3em; }
  .tv-mini { padding: 0.2em; }
  .tv-btn.sm { width: 2em; height: 2em; }
  .tv-mini .tv-step-val, .tv .tv-mini .tv-step-val { font-size: 1.2em; }
  .tv-step-row .tv-step-val, .tv .tv-step-row .tv-step-val { font-size: 2.1em; }
  .tv-tile-val, .tv .tv-tile-val { font-size: 1.5em; }
  .tv-seg-toggle.three button { font-size: 0.9em; }
}
@media (max-width: 380px) {
  .tv .tv-body { padding: 12px; }
  .tv-farm, .tv .tv-farm { padding: 0.9em 0.8em; }
  .tv-mini { gap: 0.1em; }
  .tv-btn.sm { width: 1.8em; height: 1.8em; }
  .tv-mini .tv-step-val, .tv .tv-mini .tv-step-val { font-size: 1.05em; }
  .brand-sub { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tv-seg, .hbar-fill, .q-base, .q-inc { transition: none; }
}

/* ======================================================================
   Printing: only the summary sheet, letter landscape, always on white
   ====================================================================== */
@page { size: letter landscape; margin: 0.35in 0.45in; }
@media print {
  * { print-color-adjust: exact !important; -webkit-print-color-adjust: exact !important; }
  html, body { background: #fff !important; }
  body > *:not(#printSheet) { display: none !important; }
  .print-sheet { display: block !important; color: #000; font-family: var(--font-body); font-size: 10.5px; }
}
.ps-page { break-inside: avoid; }
.ps-break { break-before: page; page-break-before: always; }
.ps-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 0 10px; border-bottom: 2px solid #105a2f; margin-bottom: 8px; }
.ps-logo { height: 46px; width: auto; display: block; }
.ps-head-meta { text-align: right; }
.ps-title { font-size: 18px; font-weight: 800; color: #105a2f; }
.ps-farm { font-size: 12.5px; font-weight: 700; margin-top: 2px; }
.ps-date { font-family: var(--font-mono); font-size: 10px; color: #555; margin-top: 2px; }
.ps-farmline { font-size: 11px; color: #333; margin: 0 0 8px; }
.ps-farmline b { font-family: var(--font-mono); }
.ps-tiles { display: flex; gap: 10px; margin-bottom: 10px; }
.ps-tile { flex: 1; border: 1px solid #ccc; border-left: 4px solid #999; border-radius: 6px; padding: 6px 10px; }
.ps-tile.good { border-left-color: #1c7a41; } .ps-tile.bad { border-left-color: #b3312f; }
.ps-tile-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #555; }
.ps-tile-val { font-family: var(--font-mono); font-size: 17px; font-weight: 700; margin-top: 2px; }
.ps-tile.good .ps-tile-val { color: #1c7a41; } .ps-tile.bad .ps-tile-val { color: #b3312f; }
.ps-tile-sub { font-family: var(--font-mono); font-size: 10.5px; color: #333; }
.ps-main { display: block; }
.ps-main.with-side { display: grid; grid-template-columns: minmax(0, 1fr) 3in; gap: 14px; align-items: start; }
.ps-table { width: 100%; border-collapse: collapse; }
.ps-table th, .ps-table td { padding: 3px 6px; border-bottom: 1px solid #ddd; text-align: right; white-space: nowrap; }
.ps-table thead th { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #555; border-bottom: 1.5px solid #105a2f; vertical-align: bottom; }
.ps-table thead th small { display: block; font-weight: 400; text-transform: none; letter-spacing: 0; }
.ps-table thead th.ps-split, .ps-table td:nth-child(5), .ps-table td:nth-child(6) { background: #f6f3ea; }
.ps-table tbody th { text-align: left; font-weight: 400; }
.ps-table td { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ps-table .ps-input td { color: #1c6a8a; font-weight: 600; }
.ps-table .ps-group th { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #555; padding-top: 7px; background: none; }
.ps-table .ps-strong th, .ps-table .ps-strong td { font-weight: 700; }
.ps-table .ps-d.good { color: #1c7a41; } .ps-table .ps-d.bad { color: #b3312f; }
.ps-box { border: 1px solid #ccc; border-radius: 6px; padding: 8px 10px; }
.ps-box h3 { font-size: 12px; margin: 0 0 6px; color: #105a2f; }
.ps-box p { font-size: 9.5px; color: #555; margin: 6px 0 0; }
.ps-kv { width: 100%; border-collapse: collapse; }
.ps-kv th, .ps-kv td { padding: 3px 0; border-bottom: 1px solid #eee; font-size: 10.5px; }
.ps-kv th { text-align: left; font-weight: 400; } .ps-kv td { text-align: right; font-family: var(--font-mono); font-weight: 600; }
.ps-foot { margin-top: 10px; padding-top: 6px; border-top: 1px solid #ccc; font-size: 9px; color: #555; line-height: 1.45; }
.ps-cop-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.ps-cop th, .ps-cop td { padding: 2px 6px; }
.ps-cop th { white-space: normal; }
.ps-cop-sum { margin-top: 14px; }
.ps-fill { margin-bottom: 10px; }
.ps-fill tbody th { white-space: normal; font-weight: 600; }
.ps-fill tbody th small { display: block; font-weight: 400; color: #555; font-size: 9.5px; }
.ps-fill td { vertical-align: top; }
.ps-fill .ps-note { font-family: var(--font-body); font-size: 9.5px; color: #555; white-space: normal; text-align: left; }
.ps-tile-sub { white-space: normal; }

/* print dialog: a note under an option */
.print-option > span { display: flex; flex-direction: column; }
.print-option-sub { font-size: 12px; color: var(--muted); }
.print-option input:disabled + span { color: var(--muted); }
