/* Smart Controller demo — dark controller-display theme skinned with the
 * official John Deere Fuel Design System (v5) color tokens and Open Sans.
 * Source: John Deere Fuel Design System PDF, Colors + Typography sections. */

:root {
    /* -------- Fuel brand colors -------- */
    --jd-green:            #367c2b; /* John Deere Green — selected, links, primary success */
    --jd-yellow:           #ffde00; /* John Deere Yellow — primary action button */
    --jd-construction-yl:  #f2a900; /* Construction Yellow */
    --jd-charcoal:         #54585a; /* Construction Charcoal */

    /* -------- Fuel gray scale -------- */
    --gray-1000: #1b1b1b; /* Body copy */
    --gray-900:  #333333; /* Labels */
    --gray-800:  #454545; /* Secondary text */
    --gray-700:  #666666; /* Tertiary text, default icon */
    --gray-600:  #767676; /* Sub text */
    --gray-500:  #919191;
    --gray-400:  #b3b3b3; /* Disabled text, dark borders */
    --gray-300:  #cccccc; /* Dividers */
    --gray-200:  #dddddd; /* Light dividers */
    --gray-100:  #f0f0f0; /* App backgrounds */
    --gray-50:   #f7f7f7; /* Hover backgrounds */
    --white:     #ffffff;

    /* -------- Fuel alert colors -------- */
    --alert-success:    #367c2b;
    --alert-success-bg: #f4f8f4;
    --alert-warning:    #f99700;
    --alert-warning-bg: #fef6ea;
    --alert-error:      #c21020;
    --alert-error-bg:   #fdf6f6;
    --alert-info:       #005db1;
    --alert-info-bg:    #f3f7fb;

    /* -------- Dark controller-display surface (inverse theme for the device face) -------- */
    --bg:        #1b1b1b;      /* Gray 1000, used as the display bezel */
    --bg-2:      #262626;      /* Slightly lifted panel */
    --panel:     #2e2e2e;      /* Card / modal */
    --panel-2:   #3a3a3a;      /* Nested surface */
    --line:      #4a4a4a;      /* Divider inside dark surfaces */
    --text:      #ffffff;      /* Inverse text on dark */
    --text-dim:  #b3b3b3;      /* Gray 400 — secondary text on dark */
    --text-dim-2:#919191;      /* Gray 500 — tertiary on dark */

    /* Semantic accents used throughout the run screen */
    --accent-primary: var(--jd-green);      /* selected / good / success */
    --accent-action:  var(--jd-yellow);     /* primary CTA */
    --accent-warn:    var(--alert-warning); /* off-rate / warning */
    --accent-danger:  var(--alert-error);   /* error / over-target */
    --accent-info:    var(--alert-info);    /* neutral info */

    /* Field / sprayer art */
    --coverage: rgba(54, 124, 43, 0.55);    /* JD Green translucent */
    --sprayer: var(--jd-yellow);
    --field-brown: #6b5844;
    --field-green: #556b3b;
    --danger: var(--alert-error);

    --radius: 8px;      /* Fuel uses 8px on cards / inputs */
    --radius-lg: 12px;  /* larger surfaces */
    --gap: 14px;

    /* Fuel typography stack: Open Sans + system fallback */
    --font-display: 'Open Sans', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;

    /* Solid HUD panel background — kept opaque so the tiles / legend /
     * section bar / run controls stay legible regardless of what's under. */
    --overlay-bg: rgba(31, 30, 28, 0.85);
}

* { box-sizing: border-box; }

/* Always honor the hidden attribute, even when we set display on the same
 * element elsewhere (this fixed a bug where the run screen wouldn't hide on
 * mobile because a media query overrode display). */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: #000;
    color: var(--text);
    font-family: var(--font-display);
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

/* Concept banner — fixed at the very top of the viewport across all
   screens so external reviewers can never miss that this is not a
   released product. Kept intentionally slim so it doesn't steal much
   vertical space from the .display frame below. */
:root { --concept-banner-h: 26px; }
.concept-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--concept-banner-h);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--jd-yellow, #ffde00);
    color: #1a1a1a;
    font-family: var(--font-display);
    font-size: 11px;
    line-height: 1;
    letter-spacing: 0.4px;
    z-index: 9999;
    padding: 0 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
    /* iPhone safe area — keep the banner clear of the notch. */
    padding-top: env(safe-area-inset-top, 0);
    height: calc(var(--concept-banner-h) + env(safe-area-inset-top, 0px));
}
.concept-banner .cb-tag {
    background: #1a1a1a;
    color: var(--jd-yellow, #ffde00);
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    letter-spacing: 0.8px;
}
.concept-banner .cb-body {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 480px) {
    .concept-banner .cb-body {
        font-size: 10px;
        letter-spacing: 0.2px;
    }
}

/* Fixed 16:9 display frame, scales to viewport */
.display {
    position: relative;
    width: 100vw;
    /* Below the concept banner (which is calc(banner-h + safe-area-top)). */
    height: calc(100vh - var(--concept-banner-h) - env(safe-area-inset-top, 0px));
    height: calc(100dvh - var(--concept-banner-h) - env(safe-area-inset-top, 0px));
    margin-top: calc(var(--concept-banner-h) + env(safe-area-inset-top, 0px));
    max-width: calc(100vh * 16 / 9);
    max-height: calc(100vw * 9 / 16);
    margin-left: auto;
    margin-right: auto;
    background: var(--bg);
    overflow: hidden;
    border: 1px solid #000;
}

/* Screens stack in the same slot; only the active one is visible */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-start;      /* was center — center clipped tall cards */
    justify-content: center;
    padding: 5vh 5vw;
    overflow-y: auto;             /* let the whole screen scroll when the
                                     card (e.g. the edit form with the
                                     three-step nozzle picker) is taller
                                     than the viewport, so the Save button
                                     at the bottom is always reachable. */
}
.screen[hidden] { display: none; }

/* -------------- Field backdrop (used on setup screens) --------------
 * Per Fuel guidance: use grays for structure, brand colors sparingly and
 * intentionally. Replaced the old brown "field" texture with a clean dark
 * gray surface anchored by a subtle JD Green brand glow. */
.field-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(1200px 700px at 15% -10%, rgba(54, 124, 43, 0.22), transparent 60%),
        radial-gradient(900px  600px at 110% 110%, rgba(54, 124, 43, 0.10), transparent 55%),
        linear-gradient(180deg, #1b1b1b 0%, #262626 100%);
}
/* Subtle grid overlay to hint at "display" surface without competing with content */
.field-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at 50% 50%, black 40%, transparent 85%);
    -webkit-mask-image: radial-gradient(ellipse at 50% 50%, black 40%, transparent 85%);
    pointer-events: none;
}

/* -------------- Modal / cards -------------- */
.modal, .card {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 40px 44px;
    min-width: 480px;
    max-width: 720px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.55);
    /* Auto-margin so short cards float in the middle of the viewport,
     * but long cards (edit form) start at the top and scroll normally. */
    margin: auto;
}

.modal { text-align: center; }
.modal-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--jd-green);
    color: var(--white);
    font-size: 40px;
    display: grid;
    place-items: center;
    margin: 0 auto 20px;
}
.modal-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}
.modal-sub {
    color: var(--text-dim);
    margin-bottom: 28px;
    font-size: 18px;
}

.card-eyebrow {
    color: var(--jd-yellow);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
}
.card-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 22px;
}
.card-title.big { font-size: 38px; }

.detected-list {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    display: grid;
    gap: 10px;
}
.detected-list li {
    display: flex;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--panel-2);
    border-radius: 8px;
    font-size: 17px;
}
.detected-list .k { color: var(--text-dim); }
.detected-list .v { font-weight: 600; }
.detected-list.compact li { padding: 8px 12px; font-size: 15px; }

.card-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 8px;
}

/* -------------- Buttons (Fuel Design System) -------------- */
.btn {
    appearance: none;
    border: none;
    font-family: inherit;
    font-size: 17px;
    font-weight: 600; /* Fuel: Semi Bold on buttons */
    padding: 14px 26px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
    color: var(--text);
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible {
    outline: 2px solid var(--jd-green);
    outline-offset: 2px;
}
/* Primary = JD Yellow with dark text, per Fuel */
.btn.primary {
    background: var(--jd-yellow);
    color: var(--gray-1000);
}
.btn.primary:hover { background: #f5d500; }
.btn.primary.stop,
.btn.primary.off {
    background: var(--alert-error);
    color: var(--white);
}
.btn.ghost {
    background: transparent;
    border: 1px solid var(--gray-400);
    color: var(--text);
}
.btn.ghost:hover {
    background: rgba(255,255,255,0.04);
    border-color: var(--white);
}
/* Brand-forward ghost: green outline + green label, per Fuel link/selected color */
.btn.ghost.brand {
    border-color: var(--jd-green);
    color: var(--jd-green);
}
.btn.ghost.brand:hover {
    background: rgba(54, 124, 43, 0.12);
    color: var(--white);
    border-color: var(--jd-green);
}
.btn.large { padding: 20px 40px; font-size: 20px; }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn.icon-only {
    padding: 8px;
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
}

/* -------------- Idle / landing screen (Fuel brand-forward) -------------- */
.idle-hint {
    position: relative;
    text-align: center;
    color: var(--text);
    max-width: 520px;
    padding: 0 24px;
}
/* Brand mark: JD Green droplet with yellow inner accent */
.brand-mark {
    position: relative;
    width: 76px;
    height: 76px;
    margin: 0 auto 20px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--jd-green);
    box-shadow: 0 8px 32px rgba(54, 124, 43, 0.45);
    color: var(--white);
    font-size: 36px;
    line-height: 1;
}
.brand-mark::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--jd-yellow);
    box-shadow: 0 0 0 3px rgba(255, 222, 0, 0.25);
}
/* Product wordmark — Fuel typography scale h1 (24px) is too small at splash size;
 * uses t-shirt "3xl" (30px) upgraded slightly for a device idle screen. */
.brand {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.2px;
    line-height: 1.1;
    margin-bottom: 10px;
    color: var(--white);
}
.brand-eyebrow {
    color: var(--jd-green);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 12px;
}
.hint-text {
    color: var(--gray-400); /* Fuel gray-400 = accessible secondary on dark */
    font-size: 18px;
    line-height: 1.5;
    margin: 0 0 28px;
}
/* Landing action row — the two mode buttons sit side-by-side on desktop,
 * stack on narrow screens. */
.idle-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.idle-actions .btn {
    min-width: 200px;
}
.idle-mode-hint {
    max-width: 460px;
    margin: 8px auto 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--gray-400);
}
.idle-mode-hint strong {
    color: var(--white);
    font-weight: 600;
}

/* -------------- Edit form -------------- */
.form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 22px;
    margin-bottom: 28px;
}
.form label {
    display: flex;
    flex-direction: column;
    font-size: 14px;
    color: var(--text-dim);
    gap: 6px;
}
.form select, .form input {
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 12px;
    font-size: 16px;
    font-family: inherit;
}
.form select:focus, .form input:focus {
    outline: 2px solid var(--jd-green);
    outline-offset: 1px;
}

/* Nozzle picker — two-step visual picker (family → color/orifice).
 * Family cards each show an SVG illustrating the family's spray character
 * (fine dots for XR, air-induction bubbles for AIC/AIXR/TTI). Color cards
 * show the ISO color chip + tip icon.
 * The whole `<label>` that wraps the picker spans both grid columns. */
.form label:has(.nozzle-picker) { grid-column: span 2; }
.nozzle-picker { display: block; }
.nozzle-step-label {
    font-size: 12px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin: 12px 0 6px;
}
/* Make picker row (step 1). Small pill-like cards — a brand list, not a
 * full-height picture card like the family row. */
.nozzle-make-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.nozzle-make-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 14px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease;
    min-width: 120px;
}
.nozzle-make-card:hover:not(.disabled)  { border-color: rgba(255,255,255,0.25); }
.nozzle-make-card:active:not(.disabled) { transform: scale(0.98); }
.nozzle-make-card.selected {
    border-color: var(--jd-green);
    background: rgba(54, 124, 43, 0.14);
    box-shadow: 0 0 0 2px rgba(54, 124, 43, 0.35) inset;
}
.nozzle-make-card:focus-visible {
    outline: 2px solid var(--jd-green);
    outline-offset: 2px;
}
.nozzle-make-card.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.nozzle-make-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}
.nozzle-make-tag {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.nozzle-empty {
    color: var(--text-dim);
    font-size: 13px;
    padding: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px dashed var(--line);
    border-radius: 8px;
}
.nozzle-family-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}
.nozzle-family-card {
    display: grid;
    grid-template-rows: 88px auto auto auto;
    justify-items: center;
    text-align: center;
    padding: 10px 8px 12px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease;
}
.nozzle-family-card:hover  { border-color: rgba(255,255,255,0.25); }
.nozzle-family-card:active { transform: scale(0.98); }
.nozzle-family-card.selected {
    border-color: var(--jd-green);
    background: rgba(54, 124, 43, 0.14);
    box-shadow: 0 0 0 2px rgba(54, 124, 43, 0.35) inset;
}
.nozzle-family-card:focus-visible {
    outline: 2px solid var(--jd-green);
    outline-offset: 2px;
}
.nozzle-family-icon { width: 88px; height: 88px; }
.nozzle-family-key {
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0.4px;
    margin-top: 4px;
}
.nozzle-family-name {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}
.nozzle-family-tag {
    font-size: 10px;
    color: var(--text-dim);
    background: rgba(255,255,255,0.06);
    border-radius: 4px;
    padding: 2px 6px;
    margin-top: 4px;
}
.nozzle-family-blurb {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text);
}
.nozzle-family-blurb .fb-line { color: var(--text); }
.nozzle-family-blurb .fb-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 6px;
    color: var(--text-dim);
    font-size: 11px;
}
.nozzle-family-blurb .fb-facts b { color: var(--text); }
.nozzle-color-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}
.nozzle-color-card {
    display: grid;
    grid-template-columns: 10px 36px 1fr;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease;
}
.nozzle-color-card:hover  { border-color: rgba(255,255,255,0.25); }
.nozzle-color-card:active { transform: scale(0.98); }
.nozzle-color-card.selected {
    border-color: var(--jd-green);
    background: rgba(54, 124, 43, 0.14);
    box-shadow: 0 0 0 2px rgba(54, 124, 43, 0.35) inset;
}
.nozzle-color-card:focus-visible {
    outline: 2px solid var(--jd-green);
    outline-offset: 2px;
}
.nozzle-color-chip {
    width: 10px;
    height: 36px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.4);
}
.nozzle-color-icon { width: 36px; height: 36px; }
.nozzle-color-name {
    grid-column: 3;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nozzle-color-code {
    grid-column: 3;
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* -------------- Nozzle recommender -------------- */
.nozzle-recommend { margin-bottom: 10px; }
.nozzle-recommend-panel {
    margin-top: 10px;
    background: rgba(255, 222, 0, 0.06);   /* JD yellow tint */
    border: 1px solid rgba(255, 222, 0, 0.30);
    border-radius: 10px;
    padding: 12px;
}
.nozzle-recommend-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.nrp-title { font-weight: 700; color: var(--text); font-size: 13px; }
.nrp-title span { color: var(--jd-yellow); }
.nrp-inputs { display: flex; gap: 12px; flex-wrap: wrap; }
.nrp-speed {
    color: var(--text-dim);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.nrp-speed input { width: 64px; }

/* Label rate + carrier guidance strip (product rate, carrier band,
   your-target chip, and warning banner if below carrier minimum). */
.nrp-label {
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.nrp-label-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.nrp-chip {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    color: var(--text);
}
.nrp-chip b { color: var(--text-dim); font-weight: 600; margin-right: 4px; }
.nrp-label-note {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.4;
}
.nrp-warn {
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(255, 165, 0, 0.10);
    border: 1px solid rgba(255, 165, 0, 0.35);
    border-radius: 6px;
    font-size: 11px;
    color: #f5c56a;
}
.nozzle-recommend-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}
@media (min-width: 640px) {
    .nozzle-recommend-list { grid-template-columns: repeat(3, 1fr); }
}
.nozzle-rec-card {
    display: block;
    text-align: left;
    padding: 10px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    color: inherit;
    font-family: inherit;
    transition: border-color 0.12s ease, transform 0.08s ease;
}
.nozzle-rec-card:hover  { border-color: rgba(255,255,255,0.25); }
.nozzle-rec-card:active { transform: scale(0.98); }
.nozzle-rec-card.best {
    border-color: var(--jd-green);
    box-shadow: 0 0 0 2px rgba(54, 124, 43, 0.35) inset;
}
.nozzle-rec-card.oor {
    opacity: 0.7;
    border-style: dashed;
}
.nrc-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--text);
    font-size: 13px;
}
.nrc-rank {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    background: rgba(54, 124, 43, 0.25);
    color: var(--jd-green);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}
.nozzle-rec-card:not(.best) .nrc-rank {
    background: rgba(255,255,255,0.06);
    color: var(--text-dim);
}
.nrc-chip {
    width: 8px;
    height: 22px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.4);
    display: inline-block;
}
.nrc-name { flex: 1; }
.nrc-meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
}
.nrc-meta.mono { font-family: 'Consolas', 'Menlo', monospace; }
.nozzle-recommend-note {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.45;
}

/* -------------- Calibration progress -------------- */
.progress {
    height: 14px;
    border-radius: 10px;
    background: var(--panel-2);
    overflow: hidden;
    margin-bottom: 10px;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--jd-green), #4e9a3f);
    transition: width 0.4s ease;
}
.cal-step {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 18px;
}
.cal-log {
    list-style: none;
    padding: 0;
    margin: 0;
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 13px;
    color: var(--text-dim);
    max-height: 160px;
    overflow: hidden;
}
.cal-log li { padding: 3px 0; }
.cal-log li.ok::before { content: '✓ '; color: var(--jd-green); }
.cal-log li.wait::before { content: '· '; color: var(--text-dim); }

/* Wider variant of .card for screens that host richer diagnostic content
 * (calibration panel, done-screen performance recap). Same look, more
 * horizontal room so tables/grids don't get squeezed. */
.card.wide { max-width: 860px; }
.card-sub {
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.45;
    margin: -14px 0 20px 0;
}

/* Pre-flight sanity check on the Verify screen. A colored list of quick
 * physics-based validations (nozzle envelope, tank runway, product+nozzle
 * compatibility) so the operator catches misconfigured jobs BEFORE spending
 * time on calibration. */
.preflight {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 18px 0 22px 0;
}
.preflight-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-dim);
    font-weight: 700;
    margin-bottom: 8px;
}
.preflight-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.preflight-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.02);
    border-left: 3px solid var(--text-dim);
    font-size: 13px;
    line-height: 1.4;
}
.preflight-item.good { border-left-color: var(--jd-green); }
.preflight-item.warn { border-left-color: var(--alert-warning, #f0a500); }
.preflight-item.err  { border-left-color: var(--alert-error,   #d64545); }
.preflight-icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--white);
    margin-top: 1px;
}
.preflight-item.good .preflight-icon { background: var(--jd-green); }
.preflight-item.warn .preflight-icon { background: var(--alert-warning, #f0a500); }
.preflight-item.err  .preflight-icon { background: var(--alert-error,   #d64545); }
.preflight-body { flex: 1; }
.preflight-headline { font-weight: 700; color: var(--text); }
.preflight-detail  { color: var(--text-dim); margin-top: 2px; }

/* Tank-mix plan panel. Explains, using the selected product's label rate
 * and crop, exactly how much product goes into the tank, how much water
 * fills the rest, and (if a field size was entered) how much total product
 * to bring and how many tank fills the job will take. Rendered on both
 * the Edit screen (live as inputs change) and the Verify screen (review). */
.mixplan {
    background: rgba(55, 124, 43, 0.08);
    border: 1px solid rgba(55, 124, 43, 0.35);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 14px 0 18px 0;
}
.mixplan:empty { display: none; }
.mixplan-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--jd-green);
    font-weight: 700;
    margin-bottom: 4px;
}
.mixplan-sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 10px;
    line-height: 1.4;
}
.mixplan-source-fallback { color: var(--alert-warning, #f0a500); font-weight: 600; }
.mixplan-note {
    font-size: 12px;
    color: var(--alert-warning, #f0a500);
    background: rgba(240, 165, 0, 0.08);
    border-left: 3px solid var(--alert-warning, #f0a500);
    padding: 6px 8px;
    border-radius: 4px;
    margin: 0 0 10px 0;
    line-height: 1.4;
}
.mixplan-recipe {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.mixplan-row {
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    padding: 8px 10px;
}
.mixplan-row-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    font-weight: 700;
}
.mixplan-row-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}
.mixplan-row-detail {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 1px;
}
.mixplan-row.product { border-left: 3px solid var(--jd-green); }
.mixplan-row.water   { border-left: 3px solid #4ea3d9; }
.mixplan-job {
    border-top: 1px dashed rgba(255,255,255,0.15);
    padding-top: 10px;
    margin-top: 4px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.mixplan-job .mixplan-row-label { color: var(--jd-yellow); }
.mixplan-empty {
    font-size: 12px;
    color: var(--text-dim);
    font-style: italic;
}

/* Rich diagnostic cards on the Calibration screen. Each step captures a
 * value + spec range and can be expanded to show a plain-English "what
 * this checks / what to do if it's off" block. */
.cal-diag {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cal-diag-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border-color 0.2s ease;
}
.cal-diag-item.warn { border-color: rgba(240, 165, 0, 0.55); }
.cal-diag-item.err  { border-color: rgba(214, 69, 69, 0.55); }
.cal-diag-item.running { opacity: 0.65; }
.cal-diag-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    cursor: pointer;
}
.cal-diag-status {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--panel-2);
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 700;
}
.cal-diag-item.good .cal-diag-status { background: var(--jd-green);          color: var(--white); }
.cal-diag-item.warn .cal-diag-status { background: var(--alert-warning, #f0a500); color: var(--white); }
.cal-diag-item.err  .cal-diag-status { background: var(--alert-error,   #d64545); color: var(--white); }
.cal-diag-item.running .cal-diag-status {
    background: var(--panel-2);
    color: var(--jd-green);
    animation: calSpin 1.0s linear infinite;
}
@keyframes calSpin { to { transform: rotate(360deg); } }
.cal-diag-name { flex: 1; font-weight: 700; font-size: 14px; color: var(--text); }
.cal-diag-value {
    flex: 0 0 auto;
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 13px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.cal-diag-item.warn .cal-diag-value,
.cal-diag-item.err  .cal-diag-value { color: var(--text); }
.cal-diag-chev {
    flex: 0 0 auto;
    color: var(--text-dim);
    font-size: 12px;
    transition: transform 0.2s ease;
}
.cal-diag-item.expanded .cal-diag-chev { transform: rotate(90deg); }
.cal-diag-detail {
    display: none;
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
    padding: 6px 0 4px 30px;
}
.cal-diag-item.expanded .cal-diag-detail { display: block; }
.cal-diag-detail .cal-diag-spec {
    color: var(--text);
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 12px;
    display: block;
    margin-top: 4px;
}
.cal-diag-detail .cal-diag-fix {
    color: var(--text);
    margin-top: 6px;
    display: block;
}

/* Post-run performance diagnostic on the Done screen. A grid of small
 * metric cards (rate accuracy %, off-rate time, overlap %, avg pressure)
 * plus a one-line coaching recommendation. */
.run-diag {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 18px 0 22px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.run-diag-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-dim);
    font-weight: 700;
}
.run-diag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}
.run-diag-metric {
    background: rgba(0,0,0,0.25);
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-left: 3px solid var(--text-dim);
}
.run-diag-metric.good { border-left-color: var(--jd-green); }
.run-diag-metric.warn { border-left-color: var(--alert-warning, #f0a500); }
.run-diag-metric.err  { border-left-color: var(--alert-error,   #d64545); }
.run-diag-metric-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    font-weight: 700;
}
.run-diag-metric-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.run-diag-metric-detail {
    font-size: 11px;
    color: var(--text-dim);
}
.run-diag-reco {
    background: rgba(54, 124, 43, 0.10);
    border: 1px solid rgba(54, 124, 43, 0.5);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text);
    line-height: 1.4;
}
.run-diag-reco::before {
    content: '💡 ';
}
.run-diag-reco.hidden { display: none; }

/* -------------- Send to Operations Center (Done screen + modal) --------------
 * Card-in-card on the Done screen that lets the operator sign in with
 * their John Deere account and push the completed job to Operations
 * Center as a Work Plan. The full flow runs in a modal (opsModal in
 * app.js): sign-in → org pick → field pick → sending → success. Today
 * it's a scripted mock (no data leaves the device) so the UX is fully
 * exercised while the developer.deere.com credentials are in review;
 * only opsSignIn() and opsPostWorkPlan() swap to real fetch() later. */
.ops-send {
    background: rgba(255, 222, 0, 0.05);
    border: 1px solid rgba(255, 222, 0, 0.35);
    border-radius: 8px;
    padding: 14px;
    margin: 18px 0 12px 0;
    text-align: center;
}
.ops-send-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
    color: var(--jd-yellow);
    margin-bottom: 6px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
/* Mode chip riding next to the section title. Two variants:
 *   DEMO  (default): amber pill, tells shared viewers no real data flows.
 *   LIVE  (live=1 flag set): red pill, warns the operator that sign-in
 *   will actually touch Operations Center. Only visible on this device
 *   after opsEnableLiveMode() sets localStorage.smartControllerLiveMode. */
.ops-mode-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    background: rgba(240, 165, 0, 0.20);
    color: var(--alert-warning, #f0a500);
    border: 1px solid rgba(240, 165, 0, 0.55);
    vertical-align: 1px;
}
.ops-mode-chip.live {
    background: rgba(214, 69, 69, 0.20);
    color: var(--alert-error, #d64545);
    border-color: rgba(214, 69, 69, 0.60);
}
.ops-send-mock-note {
    margin-top: 12px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-dim);
    padding: 8px 10px;
    background: rgba(240, 165, 0, 0.06);
    border: 1px dashed rgba(240, 165, 0, 0.35);
    border-radius: 6px;
    text-align: left;
}
.ops-send-mock-note.hidden { display: none; }
.ops-send-sub {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.4;
    margin-bottom: 12px;
}
.ops-send-sub.success {
    color: var(--text);
}
.ops-jd-mark {
    display: inline-block;
    background: var(--jd-yellow);
    color: var(--jd-green);
    font-weight: 800;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-right: 6px;
    letter-spacing: 0.5px;
    vertical-align: 1px;
}
.ops-send-badge {
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(54, 124, 43, 0.15);
    border: 1px solid rgba(54, 124, 43, 0.5);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-variant-numeric: tabular-nums;
}
.ops-send-badge .ops-send-badge-id {
    font-family: 'Consolas', 'Menlo', monospace;
    color: var(--jd-green);
    font-weight: 700;
}

/* Modal overlay covering the whole viewport with a scrim + centered card. */
.ops-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 20px;
    animation: opsFadeIn 0.18s ease;
}
@keyframes opsFadeIn { from { opacity: 0; } to { opacity: 1; } }
.ops-modal[hidden] { display: none; }
.ops-modal-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 22px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}
.ops-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
}
.ops-modal-close:hover { color: var(--text); }
.ops-modal-eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--jd-yellow);
    font-weight: 700;
    margin-bottom: 4px;
}
.ops-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
}
.ops-modal-body {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    margin-bottom: 16px;
}
.ops-modal-body .muted { color: var(--text-dim); font-size: 12px; }
.ops-modal-body .stepnote {
    background: rgba(255,255,255,0.03);
    border-left: 3px solid var(--jd-yellow);
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-dim);
    margin: 10px 0;
    line-height: 1.4;
}
.ops-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.ops-modal-actions .btn { min-width: 120px; }
.ops-modal-mock-badge {
    margin-top: 14px;
    text-align: center;
    font-size: 10px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--alert-warning, #f0a500);
    font-weight: 700;
}
.ops-modal-mock-badge.live {
    color: var(--alert-error, #d64545);
}

/* Pickable list rows (orgs, fields) inside the modal. */
.ops-list {
    list-style: none;
    margin: 0 0 14px 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ops-list-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
    color: var(--text);
    transition: border-color 0.15s ease, background 0.15s ease;
}
.ops-list-item:hover,
.ops-list-item.selected {
    border-color: var(--jd-green);
    background: rgba(54, 124, 43, 0.10);
}
.ops-list-item .ops-list-sub {
    font-size: 11px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
.ops-list-item .ops-list-mapped {
    background: rgba(54, 124, 43, 0.20);
    color: var(--jd-green);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

/* Spinner for the "Sending Work Plan…" step. */
.ops-spinner {
    display: block;
    width: 36px;
    height: 36px;
    border: 3px solid var(--line);
    border-top-color: var(--jd-green);
    border-radius: 50%;
    animation: opsSpin 0.9s linear infinite;
    margin: 12px auto 6px auto;
}
@keyframes opsSpin { to { transform: rotate(360deg); } }
.ops-progress-log {
    list-style: none;
    padding: 0;
    margin: 12px 0 0 0;
    font-size: 12px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
.ops-progress-log li {
    padding: 3px 0;
    display: flex;
    gap: 8px;
    align-items: center;
}
.ops-progress-log li::before {
    content: '';
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
}
.ops-progress-log li.done::before { background: var(--jd-green); }
.ops-progress-log li.done { color: var(--text); }

/* -------------- Product picker (EPA PPIS typeahead) --------------
 * Free-text search over a local PPIS-derived catalog. As the operator
 * types, we filter by product name / EPA reg. no. / active ingredient
 * and show a suggestions dropdown. Selection populates the selected-
 * product card underneath with everything needed for spray-record
 * documentation (EPA reg no, registrant, signal word, RUP flag, AIs). */
.product-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}
.product-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.product-input-wrap .product-input {
    flex: 1;
    padding-right: 40px;
}
.product-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    color: var(--text-dim);
}
.product-suggestions {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    max-height: 320px;
    overflow-y: auto;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.product-suggestions[hidden] { display: none !important; }
.product-suggestion {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.product-suggestion:last-child { border-bottom: 0; }
.product-suggestion:hover,
.product-suggestion.active {
    background: rgba(54, 124, 43, 0.15);
}
.product-suggestion-line1 {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-weight: 700;
    color: var(--text);
    font-size: 14px;
}
.product-suggestion-line1 mark {
    background: rgba(255, 222, 0, 0.3);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}
.product-suggestion-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(214, 69, 69, 0.25);
    color: #ffb3b3;
    border: 1px solid rgba(214, 69, 69, 0.5);
}
.product-suggestion-line2 {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.product-suggestion-line2 .mono {
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
    letter-spacing: 0.3px;
}
.product-suggestion-empty {
    padding: 12px 14px;
    color: var(--text-dim);
    font-size: 13px;
    font-style: italic;
}

.product-selected {
    background: rgba(54, 124, 43, 0.10);
    border: 1px solid rgba(54, 124, 43, 0.5);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.product-selected-head {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}
.product-selected-name {
    font-weight: 700;
    color: var(--text);
    font-size: 15px;
}
.product-selected-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(214, 69, 69, 0.25);
    color: #ffb3b3;
    border: 1px solid rgba(214, 69, 69, 0.5);
}
.product-selected-meta {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.product-selected-meta.mono {
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}
.product-selected-meta .dot-sep { color: rgba(255,255,255,0.3); }
.product-selected-ai {
    font-size: 12px;
    color: var(--text);
    background: rgba(0,0,0,0.25);
    border-radius: 4px;
    padding: 6px 8px;
    line-height: 1.35;
}
.product-source {
    font-size: 11px;
    color: var(--text-dim);
}
.product-source a { color: var(--text-dim); text-decoration: underline; }

/* -------------- RUN PAGE -------------- */
.screen.run { padding: 0; align-items: stretch; justify-content: stretch; }

.field-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #4a5b30 0%, #3d4b28 100%);
}

.run-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 22px;
    background: linear-gradient(180deg, rgba(0,0,0,0.65), rgba(0,0,0,0));
    z-index: 3;
}
.run-title {
    font-size: 22px;
    font-weight: 700;
}
.run-sub {
    color: var(--text-dim);
    font-size: 15px;
    flex: 1;
}

/* Target-speed HUD — upper-center of the run screen.
 * Colors track the coverage map's rate bands via a data-band attribute:
 *   good  = on target (JD Green)
 *   under = current speed a bit low → over-applying (Fuel warning)
 *   over  = current speed a bit high → under-applying (Fuel info blue)
 *   severe = badly off in either direction (Fuel error red for over-app,
 *            deeper info blue for under-app)
 *   idle  = neutral (no motion / no signal)
 */
.target-speed-hud {
    position: absolute;
    top: 66px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 22px 12px;
    min-width: 220px;
    background: rgba(27, 27, 27, 0.9);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(6px);
    z-index: 3;
    box-shadow: 0 0 0 0 transparent;
    transition: background 0.25s ease, border-color 0.25s ease,
                box-shadow 0.4s ease, color 0.25s ease;
}
.tsh-label {
    color: var(--gray-400);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}
.tsh-value {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 30px;
    font-weight: 700;
    color: var(--white);
    line-height: 1.05;
}
.tsh-value .unit {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-400);
    letter-spacing: 0.5px;
}
.tsh-delta {
    font-size: 12px;
    color: var(--gray-400);
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-top: 2px;
    min-height: 14px;
}

/* On-target — JD Green */
.target-speed-hud[data-band="good"] {
    background: rgba(54, 124, 43, 0.9);
    border-color: transparent;
    box-shadow: 0 0 0 3px rgba(54, 124, 43, 0.25);
}
.target-speed-hud[data-band="good"] .tsh-label,
.target-speed-hud[data-band="good"] .tsh-delta,
.target-speed-hud[data-band="good"] .unit { color: rgba(255,255,255,0.85); }

/* Over-applying (speed too low) — Fuel warning orange */
.target-speed-hud[data-band="under"] {
    background: rgba(249, 151, 0, 0.85);
    border-color: transparent;
    box-shadow: 0 0 0 3px rgba(249, 151, 0, 0.25);
    animation: hudPulse 1.8s ease-in-out infinite;
}
.target-speed-hud[data-band="under"] .tsh-label,
.target-speed-hud[data-band="under"] .tsh-delta,
.target-speed-hud[data-band="under"] .unit { color: rgba(27,27,27,0.85); }
.target-speed-hud[data-band="under"] .tsh-value { color: var(--gray-1000); }

/* Severe over-application (speed way too low) — Fuel error red */
.target-speed-hud[data-band="severe-over"] {
    background: rgba(194, 16, 32, 0.9);
    border-color: transparent;
    box-shadow: 0 0 0 3px rgba(194, 16, 32, 0.25);
    animation: hudPulse 1.4s ease-in-out infinite;
}
.target-speed-hud[data-band="severe-over"] .tsh-label,
.target-speed-hud[data-band="severe-over"] .tsh-delta,
.target-speed-hud[data-band="severe-over"] .unit { color: rgba(255,255,255,0.85); }

/* Under-applying (speed too high) — Fuel info blue, lighter */
.target-speed-hud[data-band="over"] {
    background: rgba(0, 93, 177, 0.35);
    border-color: rgba(0, 93, 177, 0.9);
    box-shadow: 0 0 0 3px rgba(0, 93, 177, 0.15);
}
/* Severe under-application (speed way too high) — Fuel info blue, saturated */
.target-speed-hud[data-band="severe-under"] {
    background: rgba(0, 93, 177, 0.85);
    border-color: transparent;
    box-shadow: 0 0 0 3px rgba(0, 93, 177, 0.25);
    animation: hudPulse 1.4s ease-in-out infinite;
}
.target-speed-hud[data-band="severe-under"] .tsh-label,
.target-speed-hud[data-band="severe-under"] .tsh-delta,
.target-speed-hud[data-band="severe-under"] .unit { color: rgba(255,255,255,0.85); }

@keyframes hudPulse {
    0%, 100% { filter: brightness(1); }
    50%      { filter: brightness(1.12); }
}

.tiles {
    position: absolute;
    top: 66px;
    right: 22px;
    display: grid;
    grid-template-columns: repeat(2, 190px);
    gap: 12px;
    z-index: 3;
}
.tile {
    background: var(--overlay-bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    backdrop-filter: blur(6px);
}
.tile.primary-tile {
    grid-column: span 2;
    background: rgba(54, 124, 43, 0.95); /* JD Green */
    border-color: transparent;
}
.tile-label {
    color: var(--text-dim);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 6px;
}
.tile.primary-tile .tile-label { color: rgba(255,255,255,0.85); }
.tile-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.tile.primary-tile .tile-value { font-size: 40px; color: #fff; }
.tile-value .unit {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
}
.tile.primary-tile .unit { color: rgba(255,255,255,0.8); }

.tile-sub {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: 0.3px;
}
.tile-sub span { color: var(--text); font-weight: 600; }

/* Off-rate visual on the applied-rate tile when pressure is clamped */
.tile.off-rate {
    background: rgba(249, 151, 0, 0.35); /* Fuel warning bg */
    border-color: var(--alert-warning);
    animation: offRatePulse 1.6s ease-in-out infinite;
}
@keyframes offRatePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(249, 151, 0, 0.55); }
    50%      { box-shadow: 0 0 0 8px rgba(249, 151, 0, 0); }
}

/* Real-time tank gauge — spans both tile columns so the fuel bar and
 * runout stats have room to read at a glance. The bar color-codes with
 * the fill fraction: green → amber → red as the tank drains. */
.tile.tank-gauge {
    grid-column: span 2;
    padding: 12px 16px 14px;
}
.tile.tank-gauge .tile-value {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 24px;
}
.tank-pct {
    margin-left: auto;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}
.tank-bar {
    margin-top: 8px;
    height: 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.45);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.tank-bar-fill {
    height: 100%;
    width: 100%;
    background: var(--jd-green);
    transition: width 0.25s ease, background 0.25s ease;
    border-radius: 5px 0 0 5px;
}
.tank-gauge[data-level="warn"] .tank-bar-fill { background: var(--alert-warning); }
.tank-gauge[data-level="low"]  .tank-bar-fill { background: var(--alert-error); }
.tank-gauge[data-level="warn"] .tank-pct { color: var(--alert-warning); }
.tank-gauge[data-level="low"]  .tank-pct {
    color: var(--alert-error);
    animation: tankPulse 1.4s ease-in-out infinite;
}
@keyframes tankPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.55; }
}
.tank-stats {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.tank-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tank-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
}
.tank-stat-val {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    transition: color 0.3s ease, opacity 0.3s ease;
}
/* When the operator stops or shuts off the master, we HOLD the last
 * flowing time/distance/passes values instead of blanking them — but
 * dim them slightly so the operator sees they are a reference from
 * the last active spray, not live. */
.tank-gauge[data-stale="1"] .tank-stat-val { color: var(--text-dim); opacity: 0.75; }
.tank-gauge[data-stale="1"] .tank-stat-label::after { content: ' · last'; opacity: 0.7; }

/* Coverage-color legend on the run page.
 * Sits above the section-bar in the bottom-left of the map, out of the
 * fixed sprayer's path in the heading-up driver's-seat view. */
.rate-legend {
    position: absolute;
    bottom: 172px;
    left: 22px;
    background: var(--overlay-bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: var(--text);
    z-index: 3;
    min-width: 200px;
    backdrop-filter: blur(6px);
}
.legend-title {
    color: var(--text-dim);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 4px;
}
.legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.15);
}

.section-bar {
    position: absolute;
    bottom: 96px;
    left: 22px;
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    background: var(--overlay-bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    z-index: 3;
}
.section-chip {
    width: 44px;
    height: 28px;
    border-radius: 6px;
    background: #555;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,0.7);
    transition: background 0.15s ease;
}
.section-chip.on { background: var(--jd-green); color: var(--white); }
.section-chip.off { background: #4a4842; }

.insights {
    position: absolute;
    top: 66px;   /* below the run-header bar */
    left: 22px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 3;
    max-width: 320px;
    pointer-events: none;   /* insights are read-only; don't block map drags */
}
.insight {
    background: rgba(27, 27, 27, 0.9);
    border-left: 3px solid var(--alert-info);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text);
    animation: slideIn 0.3s ease;
    max-width: 100%;
    pointer-events: auto;
}
.insight.good { border-left-color: var(--jd-green); }
.insight.warn { border-left-color: var(--alert-warning); }
.insight.err  { border-left-color: var(--alert-error); }
@keyframes slideIn {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.run-controls {
    position: absolute;
    bottom: 22px;
    left: 22px;
    right: 22px;
    display: flex;
    gap: 16px;
    align-items: center;
    z-index: 3;
    flex-wrap: wrap;
}
.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--overlay-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.run-controls-label {
    color: var(--text-dim);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-right: 6px;
}
.run-controls .btn.primary {
    margin-left: auto;
    background: var(--jd-green);
    color: var(--white);
}
.run-controls .btn.primary:hover { background: #2a6222; }
.run-controls .btn.primary.off {
    background: var(--alert-error);
    color: var(--white);
}

/* -------------- Touch / mobile ergonomics -------------- */
button, select, input {
    touch-action: manipulation; /* kill iOS double-tap-to-zoom on buttons */
}
.field-canvas {
    touch-action: pan-y;        /* let vertical swipes scroll; canvas owns any horizontal gestures */
}

/* -------------- GPS status pill (Drive-for-real mode) -------------- */
.gps-status {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(27, 27, 27, 0.85);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
    letter-spacing: 0.5px;
    color: var(--text);
    z-index: 4;
    backdrop-filter: blur(6px);
    pointer-events: none;
    margin-top: 46px; /* nudge below the run header */
}
.gps-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--jd-green);
    box-shadow: 0 0 6px currentColor;
    animation: gpsPulse 1.8s ease-in-out infinite;
}
.gps-status[data-kind="warn"]  { border-color: var(--alert-warning); }
.gps-status[data-kind="warn"]  .gps-dot { background: var(--alert-warning); color: var(--alert-warning); }
.gps-status[data-kind="error"] { border-color: var(--alert-error); }
.gps-status[data-kind="error"] .gps-dot { background: var(--alert-error); color: var(--alert-error); }
.gps-status[data-kind="acquiring"] { border-color: var(--alert-info); }
.gps-status[data-kind="acquiring"] .gps-dot { background: var(--alert-info); color: var(--alert-info); }
@keyframes gpsPulse {
    0%, 100% { opacity: 1;    transform: scale(1);   }
    50%      { opacity: 0.55; transform: scale(0.8); }
}

/* Satellite imagery attribution pill (Esri terms of use require attribution).
 * Bottom-right corner of the canvas so it doesn't overlap the sprayer view. */
.map-attribution {
    position: absolute;
    right: 12px;
    bottom: 8px;
    padding: 3px 8px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 4px;
    color: #eee;
    font-size: 10px;
    z-index: 3;
    pointer-events: auto;
}
.map-attribution a { color: #fff; text-decoration: underline; }
.map-attribution[hidden] { display: none !important; }

/* Zoom controls stack — sits mid-height on the LEFT edge of the run
 * screen so it doesn't cover the HUD tiles that live on the right
 * (target rate, applied, flow, pressure, speed, tank). Big tap targets
 * so it works one-handed on a phone mounted to the Gator. */
.zoom-controls {
    position: absolute;
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 4;
}
.zoom-controls[hidden] { display: none !important; }
.zoom-controls .btn {
    background: var(--overlay-bg);
    border: 1px solid var(--line);
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
    backdrop-filter: blur(6px);
}
.zoom-controls #btn-zoom-reset {
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
}

/* Settings panel — slides in from the right edge over the run screen.
 * Uses the same overlay-alpha token as the HUD tiles so the panel matches
 * the operator's chosen transparency. Content is a scrollable list of
 * settings rows; each row has a label, current value, control, and hint. */
.settings-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 340px;
    max-width: 92vw;
    background: rgb(20 20 20 / 0.94);
    border-left: 1px solid var(--line);
    box-shadow: -8px 0 30px rgba(0,0,0,0.4);
    z-index: 10;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(8px);
}
.settings-panel[hidden] { display: none !important; }
.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
}
.settings-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}
.settings-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.settings-row-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
.settings-row-label {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}
.settings-row-value {
    color: var(--jd-yellow);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.settings-row-hint {
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1.35;
}
/* Range slider — JD-green track + thumb, keeps focus ring visible. */
.settings-row input[type="range"] {
    width: 100%;
    accent-color: var(--jd-green);
    cursor: pointer;
}

/* Grouping inside the settings panel so unrelated settings (Machine,
 * Display, etc.) get an obvious header instead of one long list. */
.settings-section { display: flex; flex-direction: column; gap: 10px; }
.settings-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--text-dim);
    font-weight: 700;
    border-bottom: 1px solid var(--line);
    padding-bottom: 6px;
}

/* Machine identification card — read-only summary of the VIN/CAN lookup */
.machine-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.machine-card-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
}
.machine-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--jd-green);
    box-shadow: 0 0 6px rgba(54, 124, 43, 0.7);
}
.machine-dot.pending {
    background: var(--alert-warning, #f0a500);
    box-shadow: 0 0 6px rgba(240, 165, 0, 0.7);
    animation: pulseDot 1.2s ease-in-out infinite;
}
.machine-dot.err {
    background: var(--alert-error, #d64545);
    box-shadow: 0 0 6px rgba(214, 69, 69, 0.7);
}
@keyframes pulseDot {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}
.machine-details {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    margin: 0;
    font-size: 13px;
}
.machine-details dt {
    color: var(--text-dim);
    font-weight: 600;
}
.machine-details dd {
    margin: 0;
    color: var(--text);
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.machine-details dd.mono {
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 12px;
    letter-spacing: 0.5px;
}

/* Work summary — reverse-chronological list of completed jobs shown
 * under Settings. Each item is a compact card with the product used,
 * total gallons applied, area covered, and job duration. */
.ws-count {
    color: var(--text-dim);
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    font-size: 11px;
    margin-left: 4px;
}
.work-summary {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.work-summary-empty {
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1.4;
    padding: 10px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px dashed var(--line);
    border-radius: 6px;
}
.work-summary-empty[hidden] { display: none !important; }
.work-summary-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
}
.ws-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ws-item-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.ws-item-when {
    font-size: 12px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
.ws-mode {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
}
.ws-mode-real {
    background: rgba(54, 124, 43, 0.25);
    color: #b7e4a8;
    border: 1px solid rgba(54, 124, 43, 0.5);
}
.ws-mode-sim {
    background: rgba(255, 222, 0, 0.15);
    color: #ffde00;
    border: 1px solid rgba(255, 222, 0, 0.4);
}
.ws-item-product {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}
.ws-item-meta {
    font-size: 11px;
    color: var(--text-dim);
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}
.ws-item-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    margin-top: 2px;
}
.ws-item-stats > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
    font-size: 12px;
}
.ws-stat-label { color: var(--text-dim); }
.ws-stat-value {
    color: var(--text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
#btn-work-summary-clear {
    align-self: flex-end;
    font-size: 11px;
    padding: 4px 10px;
    color: var(--text-dim);
}

/* As-applied coverage thumbnail inside a work-summary card. */
.ws-item-map {
    margin-top: 6px;
    background: #1a2318;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    line-height: 0;
}
.ws-item-map img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 220px;
    object-fit: contain;
    background: #1a2318;
}

/* As-applied coverage block on the Done screen. */
.done-map {
    margin-top: 14px;
    padding: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.done-map-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}
.done-map img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: contain;
    background: #1a2318;
    border-radius: 6px;
}
.done-map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-dim);
}
.done-map-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.dm-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.4);
}
.dm-under   { background: rgb(  0,  93, 177); }
.dm-on      { background: rgb( 54, 124,  43); }
.dm-over    { background: rgb(249, 151,   0); }
.dm-overlap { background: rgb(194,  16,  32); }

/* GPS acquiring overlay — full-canvas darken while waiting for first fix */
.gps-acquiring {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(10, 12, 14, 0.72);
    backdrop-filter: blur(4px);
    z-index: 5;
    color: var(--text);
    text-align: center;
    padding: 24px;
}
.gps-acquiring[hidden], .gps-status[hidden] { display: none !important; }
.gps-acquiring-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.gps-acquiring-sub {
    max-width: 380px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-400);
    margin-bottom: 6px;
}

/* -------------- Responsive: phones & small tablets -------------- */
@media (max-width: 900px), (max-height: 560px) {
    /* Drop the 16:9 letterbox — fill the viewport, allow vertical scroll if content exceeds it */
    html, body {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        height: auto;
        min-height: 100%;
    }
    .display {
        width: 100%;
        height: auto;
        min-height: 100dvh;
        max-width: none;
        max-height: none;
        border: none;
    }
    .screen {
        position: relative;
        inset: auto;
        min-height: 100dvh;
    }

    /* Setup screens: tighter cards, single-column forms */
    .screen {
        padding: 3vh 4vw;
    }
    .modal, .card {
        min-width: 0;
        max-width: 100%;
        padding: 22px 20px;
    }
    .card-title { font-size: 22px; }
    .card-title.big { font-size: 28px; }
    .modal-title { font-size: 24px; }
    .form {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .detected-list li { font-size: 15px; padding: 10px 12px; }
    .btn { font-size: 16px; padding: 12px 20px; }
    .btn.large { padding: 16px 28px; font-size: 18px; }

    /* -------- Run page: top-to-bottom flow, no absolute positioning -------- */
    .screen.run {
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        overflow: visible;
        min-height: 100dvh;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .screen.run > * {
        position: static !important;
        transform: none !important;
        inset: auto !important;
    }
    .run-header {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        background: rgba(0,0,0,0.7);
        z-index: auto;
    }
    .run-title { font-size: 17px; }
    .run-sub {
        font-size: 11px;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Target-speed HUD on mobile — full-width strip under header */
    .target-speed-hud {
        margin: 8px 8px 0;
        min-width: 0;
        width: auto;
        padding: 8px 14px 10px;
    }
    .tsh-value { font-size: 24px; }
    .tsh-label { font-size: 10px; letter-spacing: 1.2px; }
    .tsh-delta { font-size: 11px; }

    .tiles {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 8px 8px 4px;
    }
    .tile { padding: 8px 10px; }
    .tile.primary-tile { grid-column: span 3; padding: 10px 12px; }
    .tile-label { font-size: 10px; letter-spacing: 1px; }
    .tile-value { font-size: 20px; }
    .tile.primary-tile .tile-value { font-size: 26px; }
    .tile-value .unit { font-size: 11px; }
    .tile-sub { font-size: 10px; margin-top: 2px; }

    /* Canvas: predictable height on mobile so the whole page can scroll */
    .field-canvas {
        display: block;
        width: 100%;
        height: 45vh;
        min-height: 220px;
        flex: 0 0 auto;
    }

    /* Section chips + legend + insights in a horizontal strip below the map */
    .section-bar {
        margin: 6px 8px;
        justify-content: flex-start;
        overflow-x: auto;
    }
    .rate-legend {
        margin: 6px 8px;
        min-width: 0;
        font-size: 11px;
    }
    .legend-row { font-size: 11px; }
    .insights {
        margin: 6px 8px;
        max-width: none;
    }
    .insight { font-size: 12px; }

    /* Bottom controls: wrap, big fingers */
    .run-controls {
        padding: 8px 8px calc(12px + env(safe-area-inset-bottom));
        gap: 8px;
        background: rgba(0,0,0,0.7);
    }
    .control-group { padding: 4px 8px; }
    .run-controls-label { font-size: 11px; margin-right: 4px; }
    .run-controls .btn { padding: 12px 14px; font-size: 15px; }
    .run-controls .btn.primary { margin-left: 0; }

    /* Speed / Pressure / Stop / Start move off the bottom and onto the
     * left edge of the map, stacked vertically. Each `.control-group`
     * keeps its buttons in a horizontal row, but the two groups sit
     * one above the other over the field canvas. `.map-wrap` is
     * injected at load by wireRunControlsPlacement() as a positioning
     * context for the overlay, and torn down on breakpoint change so
     * desktop keeps its bottom-bar layout. */
    .screen.run > .map-wrap {
        /* Two constraints combined:
         *   1. Beat `.screen.run > * { position: static !important }`
         *      — `!important` beats non-`!important` regardless of
         *      specificity, so we must also mark this `!important`.
         *   2. Match its 0,2,0 specificity — a bare
         *      `.map-wrap !important` (0,1,0) still loses the tiebreak
         *      between two `!important` declarations. `.screen.run > .map-wrap`
         *      is 0,3,0 so it wins both battles.
         *
         * Without this the wrap goes static, the absolutely-positioned
         * .run-controls inside walks up to .screen.run for its
         * positioning ancestor, and `top: 50%` lands the buttons in
         * the middle of the whole page — right on top of the Target
         * Rate / As Applied tiles. */
        position: relative !important;
        width: 100%;
        flex: 0 0 auto;
        isolation: isolate;
    }
    /* Canvas is `position: absolute; inset: 0` in the base rule so on
     * desktop it fills the whole `.screen.run`. Once we lift it into
     * `.map-wrap` it stops being a direct child of `.screen.run` and
     * the `position: static !important` blanket rule stops applying,
     * which would let the base absolute positioning collapse the wrap
     * to 0px and slide every mobile tile up under the header. Pin it
     * back into normal flow here so the wrap gets its 45vh height. */
    .map-wrap .field-canvas {
        position: static;
        inset: auto;
        display: block;
        width: 100%;
        height: 45vh;
        min-height: 220px;
    }
    .map-wrap .run-controls {
        position: absolute;
        left: 8px;
        top: 50%;
        transform: translateY(-50%);
        right: auto;
        bottom: auto;
        width: auto;
        max-width: 60%;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 0;
        background: transparent;
        z-index: 3;
    }
    .map-wrap .run-controls .control-group {
        /* Stack the buttons within each group vertically so the
         * overlay is a narrow strip at the map's left edge instead
         * of a horizontal bar that eats half the field. Label sits
         * on top of the button column. */
        flex-direction: column;
        align-items: stretch;
        padding: 4px 6px;
        gap: 4px;
        background: rgba(27,27,27,0.85);
        border: 1px solid var(--line);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }
    .map-wrap .run-controls-label {
        font-size: 10px;
        letter-spacing: 0.8px;
        margin: 0 0 2px;
        text-align: center;
    }
    .map-wrap .run-controls .btn {
        padding: 6px 8px;
        font-size: 13px;
        min-width: 34px;
    }

    /* Zoom triad is hidden on mobile - pinch-to-zoom on the canvas
     * covers the same interaction. A "Reset zoom" row in Settings
     * exists as an escape hatch if pinch leaves the operator at an
     * extreme scale. */
    .zoom-controls { display: none !important; }

    /* Target-speed HUD + Master share the top row on mobile, each
     * taking half the width. Wrapper is injected at load by
     * positionMasterButton() and torn down on breakpoint change so
     * desktop keeps the original absolute-centered pill + inline
     * master in .run-controls. */
    .tsh-master-row {
        display: flex;
        gap: 8px;
        margin: 8px 8px 0;
        align-items: stretch;
    }
    .tsh-master-row .target-speed-hud {
        position: static !important;
        transform: none !important;
        left: auto !important;
        top: auto !important;
        margin: 0 !important;
        flex: 1 1 0;
        min-width: 0;
        width: auto;
    }
    .tsh-master-row #btn-master {
        /* Take up the other half of the row, matching target-speed-hud's
         * shape so the pair reads as one row of equal-weight controls. */
        position: static;
        transform: none;
        top: auto;
        left: auto;
        flex: 1 1 0;
        min-width: 0;
        width: auto;
        height: auto;
        margin: 0;
        border-radius: var(--radius-lg);
        padding: 8px 14px;
        font-size: 15px;
        font-weight: 700;
        line-height: 1.15;
        letter-spacing: 0.4px;
        text-transform: uppercase;
        border: 1px solid var(--line);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: none;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        white-space: normal;
        z-index: auto;
    }
}

/* Very narrow phones (portrait): compress tiles further */
@media (max-width: 480px) {
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .tile.primary-tile { grid-column: span 2; }
}
