/* Repartidor — pensado para usarse con una mano, a pleno sol y con prisa. */
:root {
  --bg: #f3f4f1;
  --card: #ffffff;
  --ink: #12161c;
  --muted: #5b6470;
  --line: #dcdfd8;
  --accent: #0b6e4f;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ea;
  --warn: #a15c00;
  --warn-soft: #fdf0d5;
  --bad: #b42318;
  --bad-soft: #fde6e3;
  --info-soft: #e6eefb;
  --info: #1d4f9c;
  --radius: 14px;
  --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1215; --card: #191e23; --ink: #eef1ee; --muted: #9aa5ae; --line: #2a3138;
    --accent: #2fb886; --accent-ink: #06231a; --accent-soft: #12352a;
    --warn: #f1b453; --warn-soft: #3a2c10; --bad: #ff8577; --bad-soft: #40191a;
    --info-soft: #162a47; --info: #8db8ff;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.top {
  position: sticky; top: 0; z-index: 500; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--accent); color: var(--accent-ink);
}
.top-title { display: flex; flex-direction: column; line-height: 1.15; }
.top-title span { font-size: .8rem; opacity: .85; text-transform: capitalize; }
.top-deadline { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; font-size: .95rem; }
.top-deadline small { display: block; font-weight: 500; opacity: .85; font-size: .75rem; }

main { padding: 12px 12px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; outline: none; }
main.map-mode { padding: 0; max-width: none; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 600; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs[hidden] { display: none; }
.tabs button {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: .72rem; color: var(--muted); cursor: pointer;
}
.tabs .ico { font-size: 1.25rem; line-height: 1; }
.tabs button[aria-current="page"] { color: var(--accent); font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.banner { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; font-weight: 600; }
.banner small { display: block; font-weight: 400; margin-top: 2px; }
.banner.ok { background: var(--accent-soft); color: var(--accent); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.info { background: var(--info-soft); color: var(--info); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; cursor: pointer;
  text-decoration: none; color: var(--ink);
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.big { width: 100%; min-height: 76px; font-size: 1.15rem; }
.btn.sm { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .grow { flex: 1 1 0; min-width: 0; }
.stack > * + * { margin-top: 10px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.badge.prio { background: var(--info-soft); color: var(--info); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.neutral { background: var(--line); color: var(--ink); }

/* Parada */
.stop { padding: 0; overflow: hidden; }
.stop > summary { list-style: none; display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; cursor: pointer; }
.stop > summary::-webkit-details-marker { display: none; }
.stop .num {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  background: var(--accent-soft); color: var(--accent); font-variant-numeric: tabular-nums;
}
.stop.next .num { background: var(--accent); color: var(--accent-ink); }
.stop.out .num { background: var(--bad-soft); color: var(--bad); }
.stop.done .num { background: var(--line); color: var(--muted); }
.stop .addr { font-weight: 700; overflow-wrap: anywhere; }
.stop .sub { color: var(--muted); font-size: .875rem; }
.stop .eta { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.stop .eta small { display: block; font-weight: 500; color: var(--muted); font-size: .72rem; }
.stop .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.stop .body { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.stop.next { border: 2px solid var(--accent); }
.pkg { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.pkg:last-of-type { border-bottom: 0; }
.pkg .who { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pkg .who small { display: block; color: var(--muted); }
.pkg.closed .who { color: var(--muted); text-decoration: line-through; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.actions .wide { grid-column: 1 / -1; }

/* Formularios */
label.field { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); }
label.field input, label.field select, label.field textarea, .input {
  display: block; width: 100%; max-width: 100%; min-width: 0; margin-top: 4px; min-height: 46px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); font-weight: 400; color: var(--ink);
}
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.days { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.days label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .85rem; color: var(--muted); font-weight: 600; min-width: 0; }
.days input { flex: 0 1 112px; min-width: 0; min-height: 44px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }

/* Cola de fotos */
.scan { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.scan:last-child { border-bottom: 0; }
.scan .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.scan.busy .dot { background: var(--info); animation: pulse 1s infinite; }
.scan.ok .dot { background: var(--accent); }
.scan.warn .dot { background: var(--warn); }
.scan.bad .dot { background: var(--bad); }
.scan .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .scan.busy .dot { animation: none; } }
.counter { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.counter b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.counter span { font-size: .78rem; color: var(--muted); }

/* Mapa */
#map { height: calc(100dvh - 58px - var(--tabs-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom)); width: 100%; background: var(--line); }
.pin {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 800 12px system-ui, sans-serif;
  background: #0b6e4f; color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45);
}
.pin.next { background: #f59e0b; color: #1a1300; width: 36px; height: 36px; font-size: 14px; }
.pin.out { background: #b42318; }
.pin.done { background: #8a939b; }
.pin.none { background: #1d4f9c; }
.pin.me { background: #2563eb; width: 18px; height: 18px; }
.pin.depot { background: #12161c; border-radius: 6px; }

/* Asistente */
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 12px; font-size: .85rem; cursor: pointer; color: var(--ink); }

dialog { border: 0; border-radius: var(--radius); padding: 16px; width: min(560px, calc(100vw - 24px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h3 { margin: 0 0 10px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 2000; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; }
.login { max-width: 360px; margin: 12vh auto 0; }
:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
