/* Task Helper — the TRAFFIC tab on a task (job-intake.md §48; TR-1, lane TASK HELPER TRAFFIC). Copyright Rapid Surveys Pty Ltd.
 * App tokens only (--bg --card --ink --muted --line --accent --accent-ink --ok --err), so light + dark follow the page. Namespaced .tr-.
 * Phone first (360 px): nothing scrolls the page sideways; touch targets ≥ 44 px. */
.tr-pane { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 16px; min-width: 0; }
.tr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tr-grow { flex: 1; min-width: 0; }
.tr-hint { margin: 0; font-size: 13px; color: var(--muted); }
.tr-msg { margin: 0; font-size: 14px; }
.tr-msg.err { color: var(--err); }
.tr-msg.ok { color: var(--ok); }
.tr-btn, .tr-ghost, .tr-chip { width: auto; margin: 0; min-height: 44px; padding: 0 14px; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; }
.tr-btn { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); }
.tr-ghost { border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.tr-chip { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 500; font-size: 14px; }
.tr-chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tr-btn:disabled, .tr-ghost:disabled, .tr-chip:disabled { opacity: .5; cursor: not-allowed; }
.tr-danger { color: var(--err) !important; }
.tr-btn:focus-visible, .tr-ghost:focus-visible, .tr-chip:focus-visible, .tr-dev:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tr-select { min-height: 44px; max-width: 100%; margin: 0; font-size: 16px; }

/* the layout's status strip */
.tr-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.tr-strip b { font-size: 15px; overflow-wrap: anywhere; }
.tr-pill { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); }
.tr-pill.planning { border-color: #b45309; color: #b45309; }
.tr-pill.in_place { border-color: var(--ok); color: var(--ok); }
.tr-pill.warn { border-color: #b45309; color: #b45309; }

/* the map marker + its bar (drawn on the MAIN map — traffic-map.js) */
.tr-mapbar { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 600; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.tr-mapbar p { flex: 1 1 100%; margin: 0; font-size: 14px; }
.tr-mk { background: none; border: 0; }
.tr-mk svg { display: block; overflow: visible; }
.tr-mk .s { fill: #b45309; stroke: #fff; stroke-width: 2; }
.tr-mk .d { fill: #334155; stroke: #fff; stroke-width: 2; }
.tr-mk .a { fill: #111827; stroke: #fff; stroke-width: 1; }
.tr-mk .t { font: 700 11px system-ui, sans-serif; fill: #111827; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.tr-mk.covered .s, .tr-mk.covered .d { fill: #64748b; }
.tr-mk.removed { opacity: .35; }
.tr-mk.sel .s, .tr-mk.sel .d { stroke: var(--accent); stroke-width: 4; }
/* TR-4a-1: close in, the sign's picture stands above its dot (the dot stays on the spot) */
.tr-mk.pic { overflow: visible; }
.tr-mkp { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); line-height: 0; filter: drop-shadow(0 1px 1px rgba(0,0,0,.45)); pointer-events: none; }
.tr-mk.covered .tr-mkp { opacity: .45; }
.tr-mk.sel .tr-mkp { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* the list of signs + devices */
.tr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tr-dev { display: flex; align-items: center; gap: 10px; width: 100%; margin: 0; min-height: 56px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); text-align: left; font: inherit; cursor: pointer; }
.tr-dev[aria-current="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tr-dev.removed { opacity: .6; }
.tr-no { flex: none; min-width: 34px; font-weight: 700; }
.tr-th { flex: none; width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--bg); }
.tr-dev-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tr-dev-txt b { overflow-wrap: anywhere; font-weight: 600; }
.tr-dev-txt span { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

/* the selected device's card */
.tr-card { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); display: flex; flex-direction: column; gap: 8px; }
.tr-card h4 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.tr-cardhead { display: flex; align-items: center; gap: 12px; }
.tr-card img.tr-photo { width: 100%; max-height: 260px; object-fit: contain; border-radius: 8px; background: var(--bg); }
.tr-facts { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; font-size: 14px; }
.tr-facts dt { color: var(--muted); }
.tr-facts dd { margin: 0; overflow-wrap: anywhere; }

/* signed copies + history */
.tr-sec { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.tr-sec h4 { margin: 0 0 6px; font-size: 15px; }
.tr-copies { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tr-copies li { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 14px; }
.tr-copies a { min-height: 44px; display: inline-flex; align-items: center; color: var(--accent); font-weight: 600; }
.tr-hist { list-style: none; margin: 0; padding: 0; font-size: 13px; display: grid; gap: 4px; }
.tr-hist li { overflow-wrap: anywhere; }

/* sheets (bottom on a phone, centred on a computer) */
.tr-ov { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.45); }
.tr-sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; margin: 0;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; background: var(--bg); color: var(--ink); display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 640px) { .tr-ov { align-items: flex-start; padding-top: 6vh; } .tr-sheet { border-radius: 16px; } }
.tr-sheet h3 { margin: 0; font-size: 18px; }
.tr-f { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.tr-f > span { color: var(--muted); font-size: 13px; }
.tr-f input, .tr-f select, .tr-f textarea { width: 100%; max-width: 100%; margin: 0; font-size: 16px; min-height: 44px; }
.tr-f textarea { min-height: 80px; }
.tr-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tr-err { color: var(--err); font-size: 13px; min-height: 0; }
.tr-err:empty { display: none; }
.tr-pick { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.tr-pick button { width: 100%; margin: 0; min-height: 44px; padding: 6px 10px; border: 0; border-bottom: 1px solid var(--line); background: var(--card); color: var(--ink); text-align: left; font: inherit; cursor: pointer; }
.tr-pick li:last-child button { border-bottom: 0; }
.tr-pick button[aria-pressed="true"] { background: var(--bg); box-shadow: inset 4px 0 0 var(--accent); font-weight: 600; }
.tr-pick small { color: var(--muted); }
/* TR-4a-1: sign pictures — a grid in the picker, a small one on the list, a bigger one on the card */
.tr-pic { flex: none; display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.tr-pic svg, .tr-pic img { display: block; }
.tr-pic.big { float: right; margin: 0 0 6px 10px; }
.tr-pick.tr-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: 46vh; padding: 4px; gap: 4px; border-radius: 10px; }
.tr-pick.tr-grid button { display: flex; align-items: center; gap: 8px; min-height: 56px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.tr-pick.tr-grid li:last-child button { border-bottom: 1px solid var(--line); }
@media (max-width: 480px) { .tr-pick.tr-grid { grid-template-columns: 1fr; } }
.tr-pick.tr-grid button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
.tr-pick .tr-gh { grid-column: 1 / -1; padding: 6px 4px 0; font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* the camera */
.tr-cam { position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 60vh; border-radius: 12px; overflow: hidden; background: #000; }
.tr-cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tr-read { position: absolute; left: 8px; right: 8px; top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.tr-read span { padding: 4px 8px; border-radius: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; font-weight: 600; }
.tr-read span.bad { background: rgba(185,28,28,.85); }
.tr-shutter { position: absolute; left: 50%; bottom: 14px; width: 72px; height: 72px; margin: 0 0 0 -36px; border-radius: 50%; border: 4px solid #fff; background: rgba(255,255,255,.35); cursor: pointer; }
.tr-shutter:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.tr-shot { width: 100%; max-height: 220px; object-fit: contain; border-radius: 10px; background: var(--bg); }
.tr-dial { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tr-arrow { display: flex; align-items: center; justify-content: center; gap: 12px; }
.tr-arrow svg { width: 72px; height: 72px; }
.tr-arrow svg path { fill: var(--ink); }
@media (prefers-reduced-motion: no-preference) { .tr-arrow svg { transition: transform .15s ease-out; } }

/* TR-2b: on the MAIN map — the bar sits above Leaflet's panes (z ≤ 700) and with its controls; the sign's card */
.leaflet-container > .tr-mapbar { z-index: 1000; }
.tr-pop { font-size: 14px; line-height: 1.35; max-width: 240px; overflow-wrap: anywhere; }

/* the company Traffic screen (TR-3, public/traffic/company.js) — its own copy of the full-screen look, not another lane's classes */
.tr-screen.overlay { display: block; background: var(--bg); overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
html.tr-open, html.tr-open body { overflow: hidden; }
.tr-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; min-height: 56px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; background: var(--ink); color: #fff; }
.tr-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tr-titles h2 { margin: 0; font-size: 18px; line-height: 1.25; color: #fff; text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; outline: none; }
.tr-co { font-size: 12px; color: #9aa6b5; overflow-wrap: anywhere; }
.tr-back { width: auto; flex: none; margin: 0; min-height: 44px; min-width: 44px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; }
.tr-back:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tr-wrap { max-width: 960px; margin: 0 auto; padding: 12px 16px 96px; }
.tr-check { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 8px; min-height: 36px; font-size: 14px; cursor: pointer; }
.tr-check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
fieldset.tr-sec { margin: 0; }

/* TR-2c: the signed copy the Diary pointed at */
.tr-copies li.tr-hit { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
/* TR-4a-1: the company's sign library */
.tr-gh2 { margin: 12px 0 4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tr-pick.tr-lib { max-height: none; }
.tr-sigprev { min-height: 100px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line); border-radius: 10px; margin: 6px 0; background: repeating-conic-gradient(#0000 0 25%, rgba(127,127,127,.12) 0 50%) 0 0 / 16px 16px; }
.tr-attr { margin-top: 10px; font-size: .8rem; }
/* TR-4a-2: the per-layout list on the main map (like MAP's Plans) */
.tr-lays { background: var(--card, #fff); }
.tr-lays-btn { position: relative; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border: 0; background: var(--card, #fff); color: #111827; cursor: pointer; border-radius: 4px; }
.tr-lays-n { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px; background: #b45309; color: #fff; font: 700 10px/16px system-ui, sans-serif; }
.tr-lays-n:empty { display: none; }
.tr-lays-panel { width: min(300px, calc(100vw - 80px)); max-height: 50vh; overflow-y: auto; padding: 6px 8px; border-top: 1px solid var(--line, #e2e8f0); background: var(--card, #fff); color: var(--ink, #111827); font: 13px/1.35 system-ui, sans-serif; }
.tr-lays-h { margin: 2px 0 6px; font-weight: 700; }
.tr-lays-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--line, #e2e8f0); }
.tr-lays-row:last-child { border-bottom: 0; }
.tr-lays-row label { flex: 1; min-width: 0; display: flex; gap: 6px; align-items: flex-start; min-height: 32px; cursor: pointer; }
.tr-lays-row small { color: var(--muted, #64748b); }
.tr-lays-fit { flex: none; min-height: 32px; padding: 0 10px; border: 1px solid var(--line, #e2e8f0); border-radius: 6px; background: var(--card, #fff); color: inherit; cursor: pointer; }
.tr-vals { align-items: center; }
.tr-lays[hidden] { display: none; }
.tr-lays-btn svg { display: block; width: 18px; height: 18px; flex: none; }
.tr-lays-row input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; }
.tr-lays-row label > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tr-lays .tr-lays-fit { width: auto; margin: 0; }
.tr-lays .tr-lays-btn { margin: 0; }
/* TR-4a-2: a signed copy opened from the Diary */
.tr-copyframe { display: block; width: 100%; height: min(70vh, 720px); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
a.tr-btn, a.tr-ghost { display: inline-flex; align-items: center; text-decoration: none; }
/* TR-4b: leaders (the true spot → a drag-able label with the picture out of scale) + the direction handle */
.tr-leader { stroke: #111827; stroke-opacity: .8; }
.tr-lbl { background: none; border: 0; }
.tr-lbl > .tr-lblp, .tr-lbl > .tr-lblt { pointer-events: none; }
.tr-lbl { display: flex !important; align-items: center; gap: 4px; width: max-content !important; height: auto !important; padding: 3px 6px 3px 3px; border-radius: 8px; background: rgba(255,255,255,.94); box-shadow: 0 1px 4px rgba(0,0,0,.35); cursor: grab; transform-origin: 0 0; }
.tr-lbl.covered { opacity: .55; }
.tr-lblp { line-height: 0; }
.tr-lblt { font: 700 12px/1.2 system-ui, sans-serif; color: #111827; white-space: nowrap; }
.tr-popacts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tr-popacts .tr-chip { min-height: 36px; width: auto; margin: 0; }
.tr-turnh { display: flex !important; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent, #2563eb); color: #fff; font: 700 18px/1 system-ui, sans-serif; box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: grab; }
.tr-turnray { stroke: var(--accent, #2563eb); stroke-dasharray: 4 4; }
.tr-mapnote { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 1000; max-width: calc(100% - 32px); padding: 8px 12px; border-radius: 8px; background: #7f1d1d; color: #fff; font: 13px/1.35 system-ui, sans-serif; }
.tr-linkbtn { border: 0; padding: 0; background: none; color: var(--accent, #2563eb); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; min-height: 32px; }
.tr-dangerbtn { background: #b91c1c; border-color: #b91c1c; }
