/* Sakura Driver PWA. Big targets (52 px minimum), one main action per screen. */
body.driver { background: var(--sk-bg); padding-bottom: calc(72px + env(safe-area-inset-bottom)); font-size: 16px; }
.d-header { background: var(--sk-navy-950); color: var(--sk-on-navy); border-bottom: 3px solid var(--sk-indigo-700); padding: calc(.75rem + env(safe-area-inset-top)) 1rem .75rem;
  display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 20; }
.d-header img { width: 34px; height: 34px; }
.d-header .who { flex: 1; min-width: 0; }
.d-header .who strong { display: block; font-family: var(--sk-font-heading); font-size: 1.05rem; letter-spacing: .02em; }
.d-header .who span { font-size: .8rem; color: var(--sk-on-navy-muted); }
.d-header .who .plate { font-size: .72rem; margin-left: .2rem; color: var(--sk-plate-ink); }
.conn { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; background: rgba(255,255,255,.1);
  border-radius: var(--sk-radius); padding: .3rem .6rem; min-height: 34px; color: var(--sk-on-navy); text-decoration: none; }
.conn .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sk-success-bg); box-shadow: 0 0 0 2px var(--sk-success); }
.conn.offline .dot { background: var(--sk-warning-bg); box-shadow: 0 0 0 2px var(--sk-warning); }
.d-main { padding: 1rem; max-width: 640px; margin: 0 auto; }
.d-card { background: var(--sk-surface); border: 1px solid var(--sk-border); border-radius: var(--sk-radius-lg);
  padding: 1rem; margin-bottom: .85rem; }
.d-card h2 { font-size: 1rem; margin-bottom: .35rem; }
/* Waybill strip: the reference and status of the thing on this panel */
.waybill { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin: -1rem -1rem .85rem;
  padding: .55rem 1rem; background: var(--sk-navy-950); color: var(--sk-on-navy); border-radius: var(--sk-radius-lg) var(--sk-radius-lg) 0 0; }
.waybill .ref { font-size: 1rem; letter-spacing: .02em; }
.waybill .badge { background: var(--sk-surface); }
.d-route { display: grid; grid-template-columns: 14px 1fr; gap: 0 .6rem; margin: .5rem 0 .75rem; }
.d-route .stop { font-weight: 600; font-size: 1.05rem; line-height: 1.3; }
.d-route .line { position: relative; }
.d-route .line::before { content: ""; position: absolute; left: 5px; top: .55rem; bottom: -.55rem; width: 2px; background: var(--sk-navy-900); }
.d-route .line.last::before { display: none; }
.d-route .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--sk-navy-900); background: var(--sk-surface); margin-top: .35rem; position: relative; }
.d-route .dot.end { background: var(--sk-navy-900); }
.d-route .meta { grid-column: 2; color: var(--sk-text-muted); font-size: .85rem; margin: -.1rem 0 .35rem; font-family: var(--sk-font-mono); }
.d-group { margin: 1.25rem 0 .5rem; font-size: .95rem; font-weight: 600; color: var(--sk-text); border-bottom: 2px solid var(--sk-navy-900); padding-bottom: .3rem; }
.big-figure { font-family: var(--sk-font-heading); font-size: 2.25rem; font-weight: 700; letter-spacing: -.01em; }
.d-btn { display: flex; align-items: center; justify-content: center; gap: .6rem; width: 100%; min-height: var(--sk-touch);
  border-radius: var(--sk-radius); font: inherit; font-size: 1.05rem; font-weight: 700; border: 0; cursor: pointer;
  text-decoration: none; padding: .75rem 1rem; }
.d-btn-primary { background: var(--sk-indigo-700); color: var(--sk-on-primary); }
.d-btn-secondary { background: var(--sk-surface); color: var(--sk-text); border: 1px solid var(--sk-border-strong); }
.d-btn[disabled] { opacity: .55; cursor: not-allowed; }
.d-empty { text-align: center; color: var(--sk-text-muted); padding: 2rem 1rem; }
.d-empty .ic { width: 40px; height: 40px; color: var(--sk-indigo-300); margin-bottom: .5rem; }
.d-input { width: 100%; min-height: var(--sk-touch); font-size: 1.1rem; padding: .6rem .9rem; border-radius: var(--sk-radius);
  border: 1px solid var(--sk-border-strong); background: var(--sk-surface); color: var(--sk-text); }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--sk-surface);
  border-top: 1px solid var(--sk-border); display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  min-height: 64px; color: var(--sk-text-muted); text-decoration: none; font-size: .72rem; font-weight: 600; }
.bottom-nav a.active { color: var(--sk-text); box-shadow: inset 0 3px 0 var(--sk-indigo-700); }
.bottom-nav .ic { width: 24px; height: 24px; }

.sos { position: fixed; right: 1rem; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 25; width: 64px; height: 64px;
  border-radius: 50%; background: var(--sk-sos); color: var(--sk-on-navy); border: 3px solid var(--sk-surface); font-weight: 800; font-size: .95rem;
  letter-spacing: .05em; box-shadow: var(--sk-shadow); cursor: pointer; touch-action: none;
  -webkit-user-select: none; user-select: none; }
.sos-ring { position: absolute; inset: -6px; border-radius: 50%; pointer-events: none; }

.d-auth { min-height: 100vh; background: var(--sk-navy-950); display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 1.5rem 1rem; }
.d-auth img { width: 200px; height: auto; margin-bottom: 1.5rem; }
.d-auth .d-card { width: 100%; max-width: 400px; }
.d-auth label { font-weight: 600; display: block; margin-bottom: .3rem; }
.d-auth .field { margin-bottom: 1rem; }
.d-auth .input { min-height: var(--sk-touch); font-size: 1.1rem; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body.driver { color-scheme: dark; }
}

/* M1 driver components */
.d-header .conn { flex: none; }
.outbox-count { font-weight: 700; margin-left: .25rem; }
.outbox-count:not([hidden])::before { content: "- "; }
.d-toast { position: fixed; left: 1rem; right: 1rem; top: calc(70px + env(safe-area-inset-top)); z-index: 40; background: var(--sk-navy-900);
  color: var(--sk-on-navy); padding: .85rem 1rem; border-radius: var(--sk-radius); box-shadow: var(--sk-shadow); max-width: 600px; margin: 0 auto; }
.d-toast.bad { background: var(--sk-danger); }
.sos-alarm { background: var(--sk-sos); color: var(--sk-on-navy); font-weight: 700; padding: .75rem 1rem; text-align: center; }
.d-card-link { display: block; color: inherit; text-decoration: none; }
.d-card-accent { border-left: 4px solid var(--sk-indigo-700); }
.d-card-danger { border-left: 4px solid var(--sk-danger); }
.row-link { display: flex; justify-content: space-between; align-items: center; gap: .75rem; color: inherit; text-decoration: none; padding: .35rem 0; }
.d-sub { font-size: .9rem; font-weight: 600; color: var(--sk-text-muted); margin: 1.1rem 0 .45rem; }
.d-status { display: flex; gap: .5rem; align-items: center; color: var(--sk-text-muted); margin: 0; }
.d-warn { color: var(--sk-warning); background: var(--sk-warning-bg); padding: .5rem .75rem; border-radius: var(--sk-radius-sm); margin: .5rem 0 0; font-size: .9rem; }
.neg { color: var(--sk-danger); }
.pos { color: var(--sk-success); }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.d-grid .d-btn { font-size: .95rem; padding: .6rem; }
.d-btn-ghost { background: none; color: var(--sk-indigo-700); }
.d-btn + .d-btn, form + form, .d-card form .d-btn { margin-top: .5rem; }
.d-field { margin-bottom: 1rem; }
.d-label { display: block; font-weight: 600; margin: .5rem 0 .3rem; }
.d-locked { min-height: var(--sk-touch); display: flex; align-items: center; padding: 0 .9rem; background: var(--sk-surface-2);
  border: 1px dashed var(--sk-border-strong); border-radius: var(--sk-radius); color: var(--sk-text-muted); }
.d-check { display: flex; align-items: center; gap: .75rem; min-height: var(--sk-touch); font-weight: 600; }
.d-check input, .seg input, .route-opt input, .toll-row input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--sk-indigo-700); flex: none; }
.seg { display: flex; gap: .5rem; flex-wrap: wrap; }
.seg label { flex: 1 1 140px; display: flex; align-items: center; gap: .6rem; min-height: var(--sk-touch); padding: .4rem .8rem;
  border: 1px solid var(--sk-border-strong); border-radius: var(--sk-radius); background: var(--sk-surface); font-weight: 600; }
.seg label:has(input:checked) { border-color: var(--sk-indigo-700); background: var(--sk-indigo-50); }
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
select.d-input[size] { min-height: 180px; padding: .25rem; }
select.d-input[size] option { padding: .55rem .5rem; border-bottom: 1px solid var(--sk-border); }
fieldset.step { border: 0; padding: 0; margin: 0 0 1rem; }
fieldset.step legend { font-family: var(--sk-font-heading); font-weight: 700; font-size: 1.15rem; margin-bottom: .75rem; }
.progress { height: 4px; background: var(--sk-indigo-100); border-radius: 2px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--sk-indigo-700); width: 20%; transition: width .2s; }
.wizard-nav { position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 1fr; gap: .6rem;
  background: var(--sk-bg); padding: .6rem 0; }
.wizard-nav .d-btn { margin: 0; }
.route-list, .toll-list { display: flex; flex-direction: column; gap: .5rem; }
.route-opt, .toll-row { display: flex; gap: .75rem; align-items: center; padding: .7rem .8rem; min-height: var(--sk-touch);
  border: 1px solid var(--sk-border-strong); border-radius: var(--sk-radius); background: var(--sk-surface); }
.route-opt:has(input:checked), .toll-row:has(input:checked) { border-color: var(--sk-indigo-700); background: var(--sk-indigo-50); }
.toll-country { margin: .75rem 0 .25rem; font-size: .8rem; font-weight: 600; color: var(--sk-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.toll-row span:nth-of-type(1) { flex: 1; font-weight: 600; }
.toll-row .qty { width: 56px; min-height: 44px; font-size: 1rem; text-align: center; border: 1px solid var(--sk-border-strong);
  border-radius: var(--sk-radius-sm); background: var(--sk-surface); color: var(--sk-text); }
.calc { background: var(--sk-indigo-50); border: 1px solid var(--sk-indigo-100); border-radius: var(--sk-radius); padding: .8rem;
  font-variant-numeric: tabular-nums; font-weight: 600; }
.d-more { margin-top: .75rem; }
.d-more summary { min-height: var(--sk-touch); display: flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--sk-indigo-700); cursor: pointer; }
.toll-item { padding: .75rem 0; border-bottom: 1px solid var(--sk-border); }
.toll-item:last-of-type { border-bottom: 0; }
.d-list, .d-checklist { list-style: none; padding: 0; margin: .5rem 0 0; }
.d-list li, .d-checklist li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .35rem 0; }
.d-checklist li { justify-content: flex-start; color: var(--sk-warning); }
.d-checklist li.ok { color: var(--sk-success); }
.review .dl { grid-template-columns: max-content 1fr; }
.stmt { list-style: none; margin: 0; padding: 0; }
.stmt li { display: flex; justify-content: space-between; gap: .75rem; padding: .7rem 1rem; border-top: 1px solid var(--sk-border); }
.thread { display: flex; flex-direction: column; gap: .5rem; max-height: 55vh; overflow-y: auto; padding: .25rem 0 .75rem; }
.msg { max-width: 85%; padding: .55rem .75rem; border-radius: 14px; background: var(--sk-surface-2); border: 1px solid var(--sk-border); }
.msg-me { align-self: flex-end; background: var(--sk-navy-900); color: var(--sk-on-navy); border-color: transparent; }
.msg-me .msg-at { color: inherit; opacity: .8; }
.msg-system { align-self: center; background: none; border: 0; color: var(--sk-text-muted); font-size: .85rem; max-width: 95%; text-align: center; }
.msg-who { font-size: .75rem; font-weight: 700; color: var(--sk-tagline); }
.msg-at { font-size: .7rem; color: var(--sk-text-faint); margin-top: .2rem; }
.att-img { max-width: 220px; max-height: 220px; border-radius: 10px; display: block; margin-top: .25rem; }
.att-audio { width: 240px; max-width: 100%; margin-top: .25rem; }
.composer { margin-top: .5rem; }
.composer-row { display: flex; gap: .5rem; align-items: flex-start; margin-top: .5rem; flex-wrap: wrap; }
.composer-row .d-btn { width: auto; margin: 0; }
.composer-row .voice { flex: 1; }
.composer-photo { cursor: pointer; }
.voice-btn.recording { background: var(--sk-danger-bg); color: var(--sk-danger); border-color: var(--sk-danger); }
.voice-preview audio { width: 100%; margin-top: .5rem; }
.nav-badge { position: absolute; margin-left: 22px; margin-top: -30px; background: var(--sk-sos); color: var(--sk-on-navy); border-radius: 3px;
  font-size: .65rem; padding: 0 .35rem; }
.sos-card { border-left: 6px solid var(--sk-sos); }
.crumbs a { display: inline-flex; align-items: center; gap: .25rem; min-height: 44px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dl dt { color: var(--sk-text-muted); }
.dl dd { margin: 0; font-weight: 500; }
.card-flush { padding: 0; overflow: hidden; }
.d-sheet { border: 2px solid var(--sk-indigo-700); }
.bottom-nav a { position: relative; }

/* Signature pad (proof of delivery) and inspection checklist */
.sig { width: 100%; height: 180px; border: 1px dashed var(--sk-border-strong); border-radius: var(--sk-radius); background: var(--sk-surface);
  touch-action: none; display: block; }
.insp { list-style: none; margin: 0; padding: 0; }
.insp li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .45rem 0; border-bottom: 1px solid var(--sk-border); }
.insp li:last-child { border-bottom: 0; }
.insp .seg { flex: none; gap: .35rem; }
.insp .seg label { flex: none; min-height: 44px; padding: .3rem .65rem; font-size: .9rem; }
.insp .seg label:has(input[value=defect]:checked) { border-color: var(--sk-danger); background: var(--sk-danger-bg); color: var(--sk-danger); }
.waiting { border-left: 4px solid var(--sk-warning); }

.location-note { display: flex; gap: .4rem; align-items: center; margin: .5rem 0 0; font-size: .8rem; }

/* 1.3.1 fixes (A20). Buttons that are links keep their own colours when hovered or visited: a tapped link stays
   "hovered" on a phone, and the base link hover colour made "Nothing, I'm ready" unreadable. */
a.d-btn-primary, a.d-btn-primary:hover, a.d-btn-primary:visited { color: var(--sk-on-primary); }
a.d-btn-secondary, a.d-btn-secondary:hover, a.d-btn-secondary:visited { color: var(--sk-text); }
a.d-btn-ghost:hover, a.d-btn-ghost:visited { color: var(--sk-indigo-700); }
/* The load number on the navy waybill strip: the heading takes the strip's light colour. */
.waybill h1, .waybill h2 { color: inherit; margin: 0; font-size: 1.1rem; }
/* The floating SOS button sits over the bottom right: the wizard's Back/Next bar stops short of it, and the end of
   every page can scroll clear of it. */
.d-main { padding-bottom: 88px; }
@media (max-width: 800px) { .wizard-nav { margin-right: 76px; } }
/* The driver's own SOS: sent, then seen by the office. */
.sos-mine { display: block; background: var(--sk-warning-bg); color: var(--sk-warning); font-weight: 700; padding: .75rem 1rem;
  text-align: center; text-decoration: none; }
.sos-mine.acked { background: var(--sk-success-bg); color: var(--sk-success); }
.sos-ack { display: flex; gap: .4rem; align-items: center; color: var(--sk-success); font-weight: 600; margin: .5rem 0 0; }
.outbox-count.outbox-failed { color: var(--sk-warning-bg); }
.d-checklist li.optional { color: var(--sk-text-muted); }
/* Every tappable row is at least 52 px (SPEC 13): request lists on a load, other loads on Home, statement rows. */
.d-card > a.row-link, .d-list li > a { min-height: var(--sk-touch); display: flex; align-items: center; }
.d-list li { padding: 0; }
.stmt li > a.stmt-row { display: flex; justify-content: space-between; gap: .75rem; width: 100%; min-height: var(--sk-touch);
  color: inherit; text-decoration: none; }
.stmt-todo { color: var(--sk-indigo-700); font-weight: 600; }
/* A tapped card stays "hovered" on a phone (and after Back): it keeps its text colour instead of turning link blue. */
a.d-card-link:hover, a.row-link:hover, .stmt li > a.stmt-row:hover { color: inherit; }
