/* PasaControl. Pensado para leerse al sol: texto casi negro sobre blanco
   (AAA), un solo color de acción (azul de señal de carretera), botones de
   56 px o más. Radios: 12 px en todo salvo los chips, que son píldoras. */
:root {
  --bg: #f4f6f8;
  --surface: #fff;
  --ink: #0e1116;
  --ink-2: #353c45;
  --line: #8a94a1;
  --line-soft: #d5dae1;
  --accent: #0a4aa0;
  --accent-ink: #fff;
  --accent-press: #073a7e;
  --accent-soft: #e3ecf8;
  --err: #a50e1e;
  --err-bg: #fdecee;
  --warn-ink: #3a2a00;
  --warn-bg: #ffe9a6;
  --ok: #0a5a28;
  --r: 12px;
  --tap: 3.25rem; /* 58 px */
  --ease: cubic-bezier(.2, 0, 0, 1);
  color-scheme: light dark;
  font: 112.5%/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1014;
    --surface: #171b21;
    --ink: #f3f5f8;
    --ink-2: #c9cfd8;
    --line: #7d8794;
    --line-soft: #343b45;
    --accent: #8fbaff;
    --accent-ink: #061630;
    --accent-press: #b3d0ff;
    --accent-soft: #162a47;
    --err: #ffa3ad;
    --err-bg: #3a1218;
    --warn-ink: #ffe28c;
    --warn-bg: #3a2c00;
    --ok: #8fe3ab;
  }
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); text-underline-offset: .2em; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.2; text-wrap: balance; }
h1:focus { outline: none; }
h2 { font-size: 1.25rem; line-height: 1.25; }
.sub { color: var(--ink-2); font-size: .85rem; }
.muted { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.slot { display: contents; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

#app { max-width: 34rem; margin: 0 auto; }
.view { padding: 1rem 1rem 2rem; display: grid; gap: 1.25rem; }
.loading { padding: 2rem 1rem; color: var(--ink-2); }

/* ── Botones ── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  width: 100%; min-height: var(--tap); padding: .75rem 1.25rem;
  border: 2px solid var(--accent); border-radius: var(--r);
  background: var(--surface); color: var(--accent);
  font: inherit; font-weight: 700; text-align: center; text-decoration: none;
  cursor: pointer; transition: transform 120ms var(--ease), background-color 120ms var(--ease);
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:active { background: var(--accent-press); }
.btn.ink { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn.big { min-height: 6.5rem; font-size: 1.4rem; flex-direction: column; gap: .15rem; letter-spacing: .01em; }
.btn.big small { font-size: .85rem; font-weight: 500; letter-spacing: 0; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn .ico { width: 1.4em; height: 1.4em; flex: none; }
.btn.big .ico { width: 1.6rem; height: 1.6rem; }
.stack { display: grid; gap: .5rem; }
.stack .link { justify-self: center; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .5rem; }
.link {
  display: inline-flex; align-items: center; min-height: 3rem; padding: 0 .25rem;
  background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: .2em; cursor: pointer;
}
.ico { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Cabecera ── */
.back {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 3rem; margin: -.25rem 0 -.75rem -.25rem;
  padding: 0 .5rem 0 .25rem; color: var(--ink); font-weight: 600; text-decoration: none; justify-self: start;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.1rem; }
.brand img { width: 2rem; height: 2rem; border-radius: 8px; }

/* ── Avisos ── */
.banner { padding: .85rem 1rem; border-radius: var(--r); font-weight: 600; }
.banner.err { background: var(--err-bg); color: var(--err); }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.ok { color: var(--ok); padding: 0; display: flex; gap: .4rem; align-items: center; justify-content: center; }
.banner.big { font-size: 1.25rem; padding: 1.1rem; text-align: center; }

/* ── Tarjetas (solo donde hay jerarquía real) ── */
.card { background: var(--surface); border: 2px solid var(--line-soft); border-radius: var(--r); padding: 1rem; display: grid; gap: .75rem; }
.today { border-color: var(--ink); }
.today .plate { font-size: 1.6rem; font-weight: 800; letter-spacing: .03em; }

/* ── Formularios ── */
form { display: grid; gap: 1.75rem; }
section.block { display: grid; gap: 1rem; }
section.block > header { display: grid; gap: .1rem; border-top: 2px solid var(--line-soft); padding-top: 1.25rem; }
form > section.block:first-of-type > header { border-top: 0; padding-top: 0; }
.field { display: grid; gap: .35rem; position: relative; }
.field label, .label { font-weight: 600; }
.opt { font-weight: 400; color: var(--ink-2); margin-left: .35rem; font-size: .85rem; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: .7rem .85rem;
  border: 2px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid var(--accent-soft); outline-offset: 0; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--err); }
input::placeholder { color: var(--ink-2); opacity: .8; }
.err:empty { display: none; }
.err { color: var(--err); font-weight: 600; font-size: .95rem; }
.hint { color: var(--ink-2); font-size: .85rem; }
.pair { display: grid; grid-template-columns: 9rem 1fr; gap: .75rem; align-items: end; }
.pair .err { min-height: 0; }
.check { display: flex; align-items: center; gap: .75rem; min-height: 3rem; font-weight: 500; }
.check input { width: 1.6rem; height: 1.6rem; min-height: 0; margin: 0; accent-color: var(--accent); flex: none; }
.place { display: grid; gap: .75rem; }
.place > .label { font-size: 1.05rem; }
.shipment { display: grid; gap: 1.25rem; }
.shipment + .shipment { border-top: 2px dashed var(--line-soft); padding-top: 1.25rem; }
.shipment-head { display: flex; justify-content: space-between; align-items: center; }

/* Botones de elección (fecha, unidad, motivo) */
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr)); gap: .5rem; }
.seg.two { grid-template-columns: 1fr 1fr; }
.seg button, .chip {
  min-height: var(--tap); padding: .5rem .4rem; border: 2px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  transition: transform 120ms var(--ease);
}
.seg button:active, .chip:active { transform: scale(.97); }
.seg button[aria-pressed="true"], .chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { border-radius: 999px; min-height: 3rem; padding: .5rem 1.1rem; }

/* Sugerencias de la agenda */
.suggest { display: grid; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.suggest:empty { display: none; }
.suggest button {
  width: 100%; min-height: var(--tap); padding: .5rem .85rem; text-align: left;
  border: 2px solid var(--accent); border-radius: var(--r); background: var(--accent-soft); color: var(--ink);
  font: inherit; cursor: pointer;
}
.suggest button b { display: block; }
.suggest button span { color: var(--ink-2); font-size: .85rem; }

details.more > summary {
  display: flex; align-items: center; min-height: var(--tap); cursor: pointer;
  font-weight: 700; color: var(--accent); list-style: none;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "+"; width: 1.5rem; font-size: 1.4rem; line-height: 1; }
details.more[open] > summary::before { content: "\2212"; }
details.more > div { display: grid; gap: 1rem; padding-bottom: .5rem; }

/* Botón fijo abajo */
.bar {
  position: sticky; bottom: 0; z-index: 2; margin: 0 -1rem -2rem;
  padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 2px solid var(--line-soft);
  display: grid; gap: .5rem;
}

/* ── Inicio ── */
.v-home { gap: 1rem; padding-top: 1.25rem; }
.home-nav { display: flex; justify-content: center; gap: 2rem; padding-top: .5rem; }

/* ── Listas ── */
.list { display: grid; margin: 0; padding: 0; list-style: none; border-top: 2px solid var(--line-soft); }
.list > li { border-bottom: 2px solid var(--line-soft); }
.list a.item { display: grid; gap: .15rem; padding: .85rem .25rem; min-height: var(--tap); color: var(--ink); text-decoration: none; }
.item b { font-size: 1.05rem; }
.item .when { color: var(--ink-2); font-size: .9rem; font-weight: 600; }
.list .line { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; padding: .6rem .25rem; }
dl.data { display: grid; gap: .85rem; margin: 0; }
.card dl.data { gap: .5rem; }
dl.data dt { font-size: .85rem; color: var(--ink-2); font-weight: 600; }
dl.data dd { margin: 0; }

/* ── QR ── */
.qr { display: block; width: min(78vw, 20rem); height: auto; aspect-ratio: 1; margin: 0 auto; background: #fff; image-rendering: pixelated; border-radius: 4px; }

/* ── Listo: marca de confirmación (≤300 ms) ── */
.v-done { text-align: center; gap: .9rem; }
.v-done .qr { width: min(60vw, 34vh); }
.v-done .row, .v-done .card { text-align: left; }
.done-mark { width: 3.5rem; height: 3.5rem; margin: 0 auto; color: var(--ok); }
.done-mark circle { fill: none; stroke: currentColor; stroke-width: 2; }
.done-mark path { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: no-preference) {
  .done-mark { animation: pop 200ms var(--ease) both; }
  .done-mark path { stroke-dasharray: 20; animation: draw 160ms var(--ease) 120ms both; }
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes draw { from { stroke-dashoffset: 20; } }

/* ── Modo inspección: siempre blanco y negro, pase lo que pase con el tema ── */
body.is-inspect { background: #fff; }
.v-inspect {
  position: fixed; inset: 0; z-index: 10; overflow-y: auto;
  background: #fff; color: #000; color-scheme: light;
  padding: calc(.5rem + env(safe-area-inset-top)) 1rem calc(1rem + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: .75rem; text-align: center;
}
.v-inspect > * { flex-shrink: 0; }
.v-inspect .close {
  align-self: flex-end; width: 4rem; height: 4rem; display: grid; place-items: center;
  border: 3px solid #000; border-radius: 50%; background: #fff; color: #000; cursor: pointer;
}
.v-inspect .close .ico { width: 2rem; height: 2rem; stroke-width: 2.5; }
.v-inspect .qr { width: min(85vw, 62vh); border-radius: 0; }
.v-inspect .plate { font-size: 2.2rem; font-weight: 800; letter-spacing: .04em; line-height: 1.1; }
.v-inspect .date { font-size: 1.4rem; font-weight: 700; }
.v-inspect .meta { font-size: 1rem; color: #222; }
.v-inspect .nav { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 26rem; }
.v-inspect .arrow {
  width: 4.5rem; height: 4.5rem; display: grid; place-items: center; border: 3px solid #000; border-radius: var(--r);
  background: #fff; color: #000; cursor: pointer;
}
.v-inspect .arrow .ico { width: 2.25rem; height: 2.25rem; stroke-width: 2.5; }
.v-inspect .arrow[disabled] { opacity: .25; }
.v-inspect .count { font-size: 1.2rem; font-weight: 700; }
.v-inspect .banner.warn { background: #ffe066; color: #000; width: 100%; max-width: 26rem; }
.v-inspect .btn { background: #fff; color: #000; border-color: #000; max-width: 26rem; }
.v-inspect a { color: #000; }

.help { display: grid; gap: .5rem; margin: 0; padding-left: 1.25rem; }
input.code { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
