/* One-column field tool: big targets for a phone held in a truck cab, ticket types colored like carbon-copy form plies. */
:root {
  --bg: #eef1ed;
  --surface: #ffffff;
  --ink: #16201b;
  --muted: #59655e;
  --line: #ccd4cd;
  --accent: #0e6b45;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe5;
  --warn: #8a5300;
  --warn-soft: #fbedd3;
  --bad: #b3261e;
  --bad-soft: #fbe1de;
  --ply-fuel: #f6d3de;
  --ply-load: #f5e59c;
  --ply-unload: #d3e5f6;
  --ply-ink: #16201b;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1512; --surface: #18201c; --ink: #e7ede9; --muted: #9ba79f; --line: #2d3832;
    --accent: #3cbf85; --accent-ink: #04130c; --accent-soft: #173326;
    --warn: #f0b45a; --warn-soft: #3a2a10; --bad: #ff8a80; --bad-soft: #3d1a17;
    --ply-fuel: #5a2a3a; --ply-load: #5a4e14; --ply-unload: #1f3d5a; --ply-ink: #f1f4f2;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1512; --surface: #18201c; --ink: #e7ede9; --muted: #9ba79f; --line: #2d3832;
  --accent: #3cbf85; --accent-ink: #04130c; --accent-soft: #173326;
  --warn: #f0b45a; --warn-soft: #3a2a10; --bad: #ff8a80; --bad-soft: #3d1a17;
  --ply-fuel: #5a2a3a; --ply-load: #5a4e14; --ply-unload: #1f3d5a; --ply-ink: #f1f4f2;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: calc(10px + env(safe-area-inset-top, 0px)) 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--accent); color: var(--accent-ink);
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark {
  font-weight: 800; letter-spacing: 0.06em; font-size: 15px;
  border: 2px solid currentColor; border-radius: 6px; padding: 2px 6px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { font-size: 13px; opacity: 0.85; }
.bar .link { color: var(--accent-ink); }
.bar-actions { display: flex; align-items: center; gap: 18px; }

.wrap {
  max-width: 34rem; margin: 0 auto;
  padding-block: 20px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.screen { display: flex; flex-direction: column; gap: 16px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 0; }
.hint { color: var(--muted); font-size: 0.92rem; margin: 0; }
.error {
  margin: 0; padding: 10px 12px; border-radius: 8px;
  background: var(--bad-soft); color: var(--bad); font-weight: 600;
}
.link {
  background: none; border: 0; padding: 6px 0; cursor: pointer;
  color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.back { align-self: flex-start; }

/* Name list */
.name-list { display: grid; gap: 10px; }
.name-list button {
  min-height: 60px; text-align: left; padding: 0 18px;
  font-size: 1.15rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer;
}
.name-list button:active { background: var(--accent-soft); }

/* PIN */
.pin-dots { display: flex; gap: 16px; justify-content: center; padding: 8px 0; }
.pin-dots i {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--ink); display: block;
}
.pin-dots i.on { background: var(--ink); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 22rem; width: 100%; margin: 0 auto; }
.keypad button {
  height: 64px; font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.keypad button:active { background: var(--accent-soft); }
.keypad.busy { opacity: 0.5; pointer-events: none; }

/* Form */
form { display: flex; flex-direction: column; gap: 18px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label, legend {
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  padding: 0; margin-bottom: 6px;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="text"], input:not([type]), input[type="date"], input[type="password"], select {
  width: 100%; min-height: 54px; padding: 10px 14px;
  font-size: 1.2rem; font-family: var(--mono); letter-spacing: 0.02em;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
input[type="date"], select { font-family: var(--font); font-size: 1.05rem; }
input:disabled { opacity: 0.7; }
select { appearance: none; -webkit-appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.job-fields { display: flex; flex-direction: column; gap: 18px; }

/* One box per ticket the job needs */
.slots { display: flex; flex-direction: column; gap: 12px; }
.slot {
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--ply-load); border-radius: var(--radius);
}
.slot.ready { border-left-color: var(--accent); }
.slot-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.slot-name { font-weight: 700; font-size: 1.1rem; }
.slot-state { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.slot.ready .slot-state { color: var(--accent); }
.slot .camera { min-height: 54px; font-size: 1rem; }

.adding {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn);
}
.adding strong { color: var(--ink); }
.money { position: relative; display: block; }
.money > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 1.2rem; color: var(--muted); }
.money input { padding-left: 32px; }
.types { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.type { position: relative; cursor: pointer; }
.type input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.type span {
  display: flex; align-items: center; justify-content: center; min-height: 56px;
  border-radius: 10px; border: 2px solid var(--line); background: var(--surface);
  font-weight: 700; font-size: 1.05rem;
}
.type-fuel input:checked + span { background: var(--ply-fuel); }
.type-job input:checked + span, .type-load input:checked + span { background: var(--ply-load); }
.type-unload input:checked + span { background: var(--ply-unload); }
.type input:checked + span { border-color: var(--ink); color: var(--ply-ink); box-shadow: inset 0 0 0 1px var(--ink); }
.type input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.camera {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 64px; border-radius: var(--radius);
  border: 2px dashed var(--accent); color: var(--accent); background: var(--accent-soft);
  font-weight: 700; font-size: 1.1rem; cursor: pointer;
}
.camera svg { width: 28px; height: 28px; fill: currentColor; }
.camera.busy { opacity: 0.6; pointer-events: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.pages:empty { display: none; }
.page { position: relative; margin: 0; }
.page img {
  display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
}
.page figcaption { font-size: 0.8rem; color: var(--muted); text-align: center; margin-top: 4px; }
.page button {
  position: absolute; top: 4px; right: 4px; width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 1.1rem; cursor: pointer;
}

.page button.rotate { top: auto; right: auto; bottom: 30px; left: 4px; font-size: 1.3rem; }

.primary {
  min-height: 60px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
  font-size: 1.2rem; font-weight: 700; cursor: pointer;
}
.primary:disabled { opacity: 0.4; cursor: not-allowed; }

.banner {
  padding: 12px 14px; border-radius: 10px; font-weight: 600;
  background: var(--warn-soft); color: var(--warn);
}
.result {
  padding: 16px; border-radius: var(--radius); display: flex; flex-direction: column; gap: 6px;
  background: var(--accent-soft); border: 1px solid var(--accent);
}
.result.queued { background: var(--warn-soft); border-color: var(--warn); }
.result strong { font-size: 1.15rem; }
.result code, .history-list code { font-family: var(--mono); font-size: 0.82rem; word-break: break-all; }

.history { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history-list li {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.history-list .what { font-weight: 600; min-width: 0; }
.history-list .when { color: var(--muted); font-size: 0.85rem; grid-column: 1; }
.history-list .actions { grid-column: 1 / -1; display: flex; gap: 16px; }
.chip {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; grid-row: 1; grid-column: 2;
}
.chip.sent { background: var(--accent-soft); color: var(--accent); }
.chip.waiting { background: var(--warn-soft); color: var(--warn); }
.chip.problem { background: var(--bad-soft); color: var(--bad); }
.chip.missing { background: var(--warn-soft); color: var(--warn); }
.history-list li.needs { border-color: var(--warn); }
.history-list .err { grid-column: 1 / -1; color: var(--bad); font-size: 0.88rem; }

.preview-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 10px 14px; border-radius: 10px; font-size: 0.9rem; margin-bottom: 16px;
  background: var(--surface); border: 1px dashed var(--muted); color: var(--muted);
}
.preview-bar label { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); }

@media (prefers-reduced-motion: no-preference) {
  .result { animation: rise 0.25s ease-out; }
  @keyframes rise { from { transform: translateY(6px); opacity: 0.4; } to { transform: none; opacity: 1; } }
}

/* Help */
.help { gap: 12px; }
.help details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; }
.help summary { min-height: 56px; display: flex; align-items: center; font-weight: 700; font-size: 1.05rem; cursor: pointer; }
.help details[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.help details > :last-child { margin-bottom: 14px; }
.help ol { margin: 0 0 8px; padding-left: 1.3em; display: flex; flex-direction: column; gap: 8px; }
.help p { margin: 8px 0; }
.help a { color: var(--accent); font-weight: 600; }
#job-find { font-family: var(--font); font-size: 1.05rem; min-height: 50px; }
