/* ==========================================================================
   BolFast · Sistema de diseño
   Un solo archivo: tokens, base y componentes. Sin dependencias.
   ========================================================================== */

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("../fonts/nunito-latin-wght.woff2") format("woff2-variations"),
       url("../fonts/nunito-latin-wght.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
  --brand: #0a3b74;
  --brand-strong: #062a55;
  --primary: #0e4da4;
  --primary-press: #0a3c82;
  --primary-soft: #e8f0fb;
  --primary-ink: #0a3b74;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --line: #e3e8ef;
  --line-strong: #cdd5e0;

  --ink: #0f1b2d;
  --ink-2: #44536a;
  --ink-3: #6b7a90;
  --ink-inverse: #ffffff;

  --success: #0f7b55;
  --success-soft: #e2f4eb;
  --warning: #9a5b00;
  --warning-soft: #fdf0d9;
  --danger: #c4322b;
  --danger-soft: #fbe6e4;
  --info: #1b6fb8;
  --info-soft: #e4effa;
  --neutral-soft: #edf0f5;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  --sh-1: 0 1px 2px rgba(15, 27, 45, .06), 0 1px 1px rgba(15, 27, 45, .03);
  --sh-2: 0 6px 18px rgba(15, 27, 45, .08);
  --sh-3: 0 18px 40px rgba(15, 27, 45, .18);

  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-xs: .75rem;
  --fs-sm: .875rem;
  --fs-base: 1rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.75rem;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --appbar-h: 56px;
  --tabbar-h: 64px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --page-max: 640px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #0a3b74;
    --brand-strong: #062a55;
    --primary: #2f6fe4;
    --primary-press: #255cc4;
    --primary-soft: #16263f;
    --primary-ink: #a9c8ff;

    --bg: #0b111b;
    --surface: #131b27;
    --surface-2: #182231;
    --surface-3: #1e2a3b;
    --line: #243246;
    --line-strong: #33445c;

    --ink: #e8eef7;
    --ink-2: #b3c0d2;
    --ink-3: #8595ab;

    --success: #3ccf91;
    --success-soft: #11291f;
    --warning: #f2b340;
    --warning-soft: #2e2311;
    --danger: #ff7a70;
    --danger-soft: #331716;
    --info: #6ab4ff;
    --info-soft: #132538;
    --neutral-soft: #1c2636;

    --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-2: 0 6px 18px rgba(0, 0, 0, .35);
    --sh-3: 0 18px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }

/* Transición suave entre pantallas (Chrome/Edge): mantiene la pantalla anterior
   visible hasta que la nueva esté lista, evitando destellos al navegar. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
.appbar { view-transition-name: appbar; }
.tabbar { view-transition-name: tabbar; }
::view-transition-group(appbar), ::view-transition-group(tabbar) { animation-duration: 0s; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; }
p { margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }
.bi { line-height: 1; vertical-align: -.125em; }

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

/* ---------- Estructura de la app ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(var(--appbar-h) + var(--safe-top));
  padding: var(--safe-top) 8px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s, background .2s;
}
.appbar.is-scrolled { border-bottom-color: var(--line); }
.appbar-title { flex: 1; min-width: 0; padding: 0 8px; }
.appbar-title h1 { font-size: var(--fs-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-title small { display: block; color: var(--ink-3); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--ink);
  font-size: 1.3rem;
}
.appbar-btn:active { background: var(--surface-3); }
.appbar-brand { display: flex; align-items: center; gap: 10px; padding-left: 8px; }
.appbar-brand img { width: 32px; height: auto; }

.page {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 8px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
}
body.flow-mode .page { padding-bottom: calc(96px + var(--safe-bottom)); }
body.flow-mode .tabbar { display: none; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-3);
  font-size: .72rem;
  font-weight: 800;
}
.tab i { display: grid; place-items: center; width: 56px; height: 30px; border-radius: var(--r-full); font-size: 1.25rem; transition: background .2s var(--ease), color .2s; }
.tab.is-active { color: var(--primary-ink); }
.tab.is-active i { background: var(--primary-soft); color: var(--primary-ink); }
.tab .tab-badge {
  position: absolute; top: 6px; left: calc(50% + 8px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full);
  background: var(--danger); color: #fff; font-size: .68rem; line-height: 18px; text-align: center;
}

@media (min-width: 900px) {
  .tabbar { left: 50%; right: auto; width: 480px; transform: translateX(-50%); bottom: 16px; border: 1px solid var(--line); border-radius: var(--r-xl); height: var(--tabbar-h); padding-bottom: 0; box-shadow: var(--sh-2); }
}

.netbar {
  position: sticky;
  top: calc(var(--appbar-h) + var(--safe-top));
  z-index: 39;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--ink);
  color: var(--bg);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.netbar.is-syncing { background: var(--info); color: #fff; }

/* ---------- Tipografía utilitaria ---------- */
.eyebrow { font-size: var(--fs-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.strong { font-weight: 800; }
.mono { font-variant-numeric: tabular-nums; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 4px 10px; }
.section-title h2 { font-size: var(--fs-md); }
.section-title a, .section-title button { font-size: var(--fs-sm); font-weight: 800; background: none; border: 0; color: var(--primary); padding: 6px 0; }
.stack { display: grid; gap: 12px; }
.stack-sm { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card-pad { padding: 16px; }
.card-pad-lg { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: var(--fs-base); display: flex; align-items: center; gap: 8px; }
.card-head h3 i { color: var(--primary-ink); }
a.card, button.card { display: block; width: 100%; text-align: left; color: inherit; transition: transform .15s var(--ease), box-shadow .15s; }
a.card:active, button.card:active, .pressable:active { transform: scale(.985); }

.hero {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: var(--r-xl);
  color: #fff;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(92, 150, 255, .45) 0%, rgba(92, 150, 255, 0) 55%),
    linear-gradient(150deg, #0e4da4 0%, var(--brand) 55%, var(--brand-strong) 100%);
  box-shadow: 0 16px 34px rgba(10, 59, 116, .28);
}
.hero::after {
  content: ""; position: absolute; right: -40px; bottom: -60px; width: 190px; height: 190px;
  border-radius: 50%; border: 28px solid rgba(255, 255, 255, .06);
}
.hero .eyebrow { color: rgba(255, 255, 255, .72); }
.hero h2 { font-size: var(--fs-xl); margin-top: 2px; }
.hero p { color: rgba(255, 255, 255, .82); font-size: var(--fs-sm); }

/* ---------- Botones ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-weight: 800;
  font-size: var(--fs-base);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  user-select: none;
  transition: transform .12s var(--ease), background .15s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn i { font-size: 1.15em; }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 56px; font-size: var(--fs-md); border-radius: var(--r-lg); }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 30%, transparent); }
.btn-primary:active { background: var(--primary-press); }
.btn-secondary { background: var(--primary-soft); color: var(--primary-ink); }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-success { background: var(--success); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--success) 28%, transparent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-white { background: #fff; color: var(--brand); }
.btn-glass { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .22); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; box-shadow: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid currentColor; border-color: #fff #fff transparent transparent;
  animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-outline.is-loading::after { border-color: var(--primary) var(--primary) transparent transparent; }
.btn-icon { width: 48px; padding: 0; }
.btn-icon.btn-sm { width: 38px; }

.action-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.action-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 68px; padding: 10px 6px; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font-size: var(--fs-xs); font-weight: 800;
}
.action-tile i { font-size: 1.3rem; color: var(--primary-ink); }
.action-tile:active { background: var(--surface-3); }
.action-tile.is-disabled { opacity: .45; pointer-events: none; }

/* ---------- Chips / estados ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 800; white-space: nowrap;
  background: var(--neutral-soft); color: var(--ink-2);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.chip.no-dot::before { display: none; }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-brand { background: var(--primary-soft); color: var(--primary-ink); }
.tone-glass { background: rgba(255, 255, 255, .16); color: #fff; }

/* ---------- Estadísticas y progreso ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stats.cols-2 { grid-template-columns: repeat(2, 1fr); }
.stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-width: 0; padding: 10px 10px 11px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); text-align: left;
}
button.stat { cursor: pointer; }
.stat strong { font-size: var(--fs-xl); font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .72rem; font-weight: 800; line-height: 1.2; color: var(--ink-3); max-width: 100%; hyphens: auto; }
.stats:not(.cols-3):not(.cols-2) .stat span { font-size: .68rem; letter-spacing: -.01em; }
.stat.is-active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.stat.tone-success strong { color: var(--success); }
.stat.tone-warning strong { color: var(--warning); }
.stat.tone-danger strong { color: var(--danger); }
.stat.tone-success, .stat.tone-warning, .stat.tone-danger, .stat.tone-info { background: var(--surface); color: inherit; }
.hero .stats .stat { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .14); }
.hero .stats .stat span { color: rgba(255, 255, 255, .72); }

.progress { height: 8px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--success); transition: width .6s var(--ease); }
.hero .progress { background: rgba(255, 255, 255, .18); }
.hero .progress > span { background: #fff; }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: var(--fs-sm); font-weight: 700; }

/* ---------- Listas ---------- */
.list { display: grid; gap: 10px; }
.list-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 60px; padding: 12px 16px; border: 0; background: transparent; color: inherit; text-align: left;
}
.list-row + .list-row { border-top: 1px solid var(--line); }
a.list-row:active, button.list-row:active { background: var(--surface-2); }
.list-row .icon-box { flex: none; }
.list-row .chev { color: var(--ink-3); font-size: 1rem; }
.icon-box { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--primary-soft); color: var(--primary-ink); font-size: 1.2rem; }
.icon-box.tone-success { background: var(--success-soft); color: var(--success); }
.icon-box.tone-warning { background: var(--warning-soft); color: var(--warning); }
.icon-box.tone-danger { background: var(--danger-soft); color: var(--danger); }
.icon-box.tone-info { background: var(--info-soft); color: var(--info); }
.icon-box.lg { width: 52px; height: 52px; border-radius: 16px; font-size: 1.45rem; }

/* Tarjeta de guía */
.guide {
  display: block; position: relative; padding: 14px 14px 12px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-1); color: inherit; overflow: hidden;
}
.guide::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--line-strong); }
.guide.st-pending::before { background: var(--primary); }
.guide.st-success::before { background: var(--success); }
.guide.st-warning::before { background: var(--warning); }
.guide.st-danger::before { background: var(--danger); }
.guide.st-queued::before { background: var(--info); }
.guide-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.guide-client { font-weight: 800; font-size: var(--fs-md); line-height: 1.25; }
.guide-meta { margin-top: 2px; color: var(--ink-3); font-size: var(--fs-xs); font-weight: 700; }
.guide-address { display: flex; gap: 8px; margin-top: 10px; color: var(--ink-2); font-size: var(--fs-sm); }
.guide-address i { color: var(--danger); margin-top: 2px; }
.guide-actions { display: flex; gap: 8px; margin-top: 12px; }
.guide-actions .btn { flex: 1; }
.guide-link { position: absolute; inset: 0; z-index: 1; }
.guide-actions, .guide-top .chip { position: relative; z-index: 2; }

/* ---------- Controles ---------- */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: var(--r-md); background: var(--surface-3); }
.segmented button {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; border: 0; border-radius: 11px; background: transparent;
  color: var(--ink-2); font-weight: 800; font-size: var(--fs-sm);
}
.segmented button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.segmented .count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--line); font-size: .7rem; line-height: 20px; }
.segmented button.is-active .count { background: var(--primary-soft); color: var(--primary-ink); }

.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 4px; margin: 0 -16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--r-full);
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: var(--fs-sm); font-weight: 800; color: var(--ink-2);
}
.filter.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.filter .count { opacity: .7; }

.search { position: relative; }
.search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input { padding-left: 42px; padding-right: 42px; }
.search .search-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: none; color: var(--ink-3); font-size: 1.1rem; }

.field { display: grid; gap: 6px; }
.label { font-size: var(--fs-sm); font-weight: 800; color: var(--ink-2); }
.label .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: 52px; padding: 12px 14px;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); font-size: var(--fs-md);
  transition: border-color .15s, box-shadow .15s;
  appearance: none; -webkit-appearance: none;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.select { padding-right: 42px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7a90' viewBox='0 0 16 16'%3E%3Cpath d='M1.6 5.1a.6.6 0 0 1 .85 0L8 10.65l5.55-5.55a.6.6 0 1 1 .85.85l-6 6a.6.6 0 0 1-.85 0l-6-6a.6.6 0 0 1 0-.85z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent); }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: .8; }
.is-invalid, .input.is-invalid, .textarea.is-invalid, .select.is-invalid { border-color: var(--danger) !important; }
.hint { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; }
.error-text { font-size: var(--fs-xs); color: var(--danger); font-weight: 800; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: 1.1rem; pointer-events: none; }
.input-icon > .input { padding-left: 46px; }
.input-icon > .input-action { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; background: none; color: var(--ink-3); font-size: 1.15rem; display: grid; place-items: center; border-radius: var(--r-sm); }
.input-icon.has-action > .input { padding-right: 50px; }

/* Stepper */
.stepper { display: flex; align-items: center; gap: 6px; }
.step { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--fs-xs); font-weight: 800; color: var(--ink-3); }
.step .dot { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); color: var(--ink-3); font-size: .78rem; }
.step.is-active { color: var(--ink); }
.step.is-active .dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-soft); }
.step.is-done .dot { background: var(--success); color: #fff; }
.step .bar { flex: 1; height: 2px; border-radius: 2px; background: var(--line); }
.step.is-done .bar { background: var(--success); }
.step:last-child .bar { display: none; }
.step.is-hidden { display: none; }

/* Opciones grandes (resultado de entrega, sí/no) */
.options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.option {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 104px; padding: 12px 6px; border-radius: var(--r-lg);
  border: 2px solid var(--line); background: var(--surface);
  font-weight: 800; font-size: var(--fs-sm); color: var(--ink-2); text-align: center;
  transition: border-color .15s, background .15s, transform .12s var(--ease);
}
.option i { font-size: 1.8rem; }
.option:active { transform: scale(.97); }
.option.opt-success i { color: var(--success); }
.option.opt-warning i { color: var(--warning); }
.option.opt-danger i { color: var(--danger); }
.option.is-active.opt-success { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.option.is-active.opt-warning { border-color: var(--warning); background: var(--warning-soft); color: var(--warning); }
.option.is-active.opt-danger { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

.yesno { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.yesno button {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; border-radius: var(--r-md); border: 2px solid var(--line);
  background: var(--surface); font-weight: 900; color: var(--ink-2);
}
.yesno button i { font-size: 1.2rem; }
.yesno button.is-yes { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.yesno button.is-no { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

/* Firma */
.sig {
  position: relative; border: 2px dashed var(--line-strong); border-radius: var(--r-lg);
  background: #fff; overflow: hidden; touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.sig.is-signed { border-style: solid; border-color: var(--success); }
.sig.is-invalid { border-color: var(--danger); }
.sig canvas { display: block; width: 100%; height: 220px; cursor: crosshair; }
.sig-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa6b8; font-weight: 800; pointer-events: none; }
.sig-placeholder span { display: flex; align-items: center; gap: 8px; }
.sig-line { position: absolute; left: 24px; right: 24px; bottom: 44px; border-bottom: 1.5px solid #d4dbe6; pointer-events: none; }
.sig-tools { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* Fotos */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.photo {
  position: relative; aspect-ratio: 1; border-radius: var(--r-md);
  border: 2px dashed var(--line-strong); background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--ink-3); font-size: var(--fs-xs); font-weight: 800; overflow: hidden;
}
.photo i { font-size: 1.5rem; color: var(--primary-ink); }
.photo.is-required { border-color: color-mix(in srgb, var(--primary) 55%, var(--line-strong)); }
.photo.is-invalid { border-color: var(--danger); }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo.has-image { border-style: solid; border-color: transparent; }
.photo .photo-remove {
  position: absolute; top: 6px; right: 6px; z-index: 2; width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: rgba(15, 27, 45, .72); color: #fff; display: grid; place-items: center; font-size: .9rem;
}
.photo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo.is-busy::after { content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--primary); border-right-color: transparent; animation: spin .7s linear infinite; }

.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery button { padding: 0; border: 0; border-radius: var(--r-md); overflow: hidden; aspect-ratio: 1; background: var(--surface-3); }
.gallery img { width: 100%; height: 100%; object-fit: cover; }

/* Barra de acción inferior (flujos) */
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  display: flex; gap: 10px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.bottom-bar .btn { flex: 1; }
.bottom-bar .btn-icon, .bottom-bar .btn-shrink { flex: none; }
@media (min-width: 700px) { .bottom-bar { padding-left: calc(50% - 304px); padding-right: calc(50% - 304px); } }

/* Datos clave/valor */
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.kv > div { min-width: 0; }
.kv .k { font-size: var(--fs-xs); font-weight: 800; color: var(--ink-3); }
.kv .v { font-weight: 700; overflow-wrap: anywhere; }
.kv .full { grid-column: 1 / -1; }

/* Aviso en línea */
.notice { display: flex; gap: 12px; padding: 14px; border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 600; }
.notice i { font-size: 1.2rem; flex: none; margin-top: 1px; }
.notice strong { display: block; font-weight: 800; margin-bottom: 2px; }
.notice.tone-warning { background: var(--warning-soft); color: var(--warning); }
.notice.tone-danger { background: var(--danger-soft); color: var(--danger); }
.notice.tone-info { background: var(--info-soft); color: var(--info); }
.notice.tone-success { background: var(--success-soft); color: var(--success); }
.notice p { color: var(--ink-2); }

/* ---------- Estados vacíos y carga ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 36px 20px; }
.empty .icon-box { width: 64px; height: 64px; border-radius: 20px; font-size: 1.8rem; margin-bottom: 6px; }
.empty h3 { font-size: var(--fs-md); }
.empty p { color: var(--ink-3); font-size: var(--fs-sm); max-width: 300px; }
.empty .btn { margin-top: 10px; }

.sk { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 8px; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent); animation: shimmer 1.3s infinite; }
.sk-line { height: 12px; margin: 8px 0; }
.sk-title { height: 18px; width: 55%; }
.sk-card { height: 120px; border-radius: var(--r-lg); }

/* ---------- Hoja inferior (sheet) ---------- */
.sheet { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 15, 28, .5); opacity: 0; transition: opacity .25s; }
.sheet-panel {
  position: relative; width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto;
  padding: 10px 20px calc(20px + var(--safe-bottom));
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--sh-3);
  transform: translateY(100%); transition: transform .32s var(--ease);
}
.sheet.is-open .sheet-backdrop { opacity: 1; }
.sheet.is-open .sheet-panel { transform: translateY(0); }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 14px; border-radius: var(--r-full); background: var(--line-strong); }
.sheet-icon { margin: 4px auto 14px; width: 56px; height: 56px; border-radius: 18px; font-size: 1.6rem; }
.sheet-title { font-size: var(--fs-lg); text-align: center; }
.sheet-text { margin-top: 6px; color: var(--ink-2); text-align: center; font-size: var(--fs-sm); }
.sheet-body { margin-top: 16px; }
.sheet-actions { display: grid; gap: 10px; margin-top: 20px; }
@media (min-width: 700px) {
  .sheet { align-items: center; }
  .sheet-panel { border-radius: var(--r-xl); padding-bottom: 20px; transform: translateY(24px) scale(.98); opacity: 0; transition: transform .25s var(--ease), opacity .2s; }
  .sheet.is-open .sheet-panel { transform: none; opacity: 1; }
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; top: calc(var(--safe-top) + 10px); z-index: 120; display: grid; justify-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 480px; width: 100%;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--ink); color: var(--bg); box-shadow: var(--sh-3);
  font-size: var(--fs-sm); font-weight: 700; pointer-events: auto;
  animation: toastIn .3s var(--ease);
}
.toast i { font-size: 1.15rem; }
.toast.t-success i { color: #3ccf91; }
.toast.t-error i { color: #ff8a80; }
.toast.t-warning i { color: #f2b340; }
.toast.is-leaving { animation: toastOut .25s var(--ease) forwards; }

/* ---------- Pantalla de éxito ---------- */
.success {
  position: fixed; inset: 0; z-index: 110; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 32px; text-align: center; background: var(--surface); animation: fadeIn .2s ease;
}
.success-mark { display: grid; place-items: center; width: 96px; height: 96px; border-radius: 50%; background: var(--success-soft); color: var(--success); font-size: 3rem; animation: pop .5s var(--ease); }
.success-mark.tone-info { background: var(--info-soft); color: var(--info); }
.success-mark.tone-warning { background: var(--warning-soft); color: var(--warning); }
.success h2 { font-size: var(--fs-xl); margin-top: 8px; }
.success p { color: var(--ink-2); max-width: 320px; }

/* ---------- Visor de imágenes ---------- */
.lightbox { position: fixed; inset: 0; z-index: 130; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .92); animation: fadeIn .2s; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox button { position: absolute; top: calc(var(--safe-top) + 12px); right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .16); color: #fff; font-size: 1.2rem; }

/* ---------- Deslizar para actualizar ---------- */
.ptr { display: flex; justify-content: center; height: 0; overflow: hidden; transition: height .2s; }
.ptr span { display: grid; place-items: center; width: 36px; height: 36px; margin-top: 8px; border-radius: 50%; background: var(--surface); box-shadow: var(--sh-2); color: var(--primary); }
.ptr.is-refreshing span i { animation: spin .8s linear infinite; }

/* ---------- Animaciones ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes toastIn { from { transform: translateY(-16px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-16px); opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.page > * { animation: rise .35s var(--ease) both; }
.page > *:nth-child(2) { animation-delay: .03s; }
.page > *:nth-child(3) { animation-delay: .06s; }
.page > *:nth-child(4) { animation-delay: .09s; }

/* ==========================================================================
   Inicio de sesión
   ========================================================================== */
.auth { min-height: 100dvh; display: flex; flex-direction: column; background: var(--surface); }
.auth-hero {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: calc(40px + var(--safe-top)) 24px 64px; text-align: center; color: #fff;
  background:
    radial-gradient(90% 80% at 15% 10%, rgba(92, 150, 255, .4) 0%, rgba(92, 150, 255, 0) 60%),
    linear-gradient(160deg, #0e4da4 0%, var(--brand) 60%, var(--brand-strong) 100%);
}
.auth-logo { display: grid; place-items: center; width: 132px; height: 132px; border-radius: 30px; box-shadow: 0 18px 36px rgba(3, 20, 45, .45); }
.auth-logo img { display: block; width: 132px; height: auto; }
/* El logo ya muestra el nombre: el título queda solo para lectores de pantalla */
.auth-hero h1.auth-titulo-oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.auth-hero h1 { font-size: 2rem; font-weight: 900; letter-spacing: -.02em; margin-top: 8px; }
.auth-hero p { color: rgba(255, 255, 255, .8); font-weight: 600; }
.auth-body {
  position: relative; flex: 1; margin-top: -32px; padding: 32px 24px calc(24px + var(--safe-bottom));
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.auth-form { display: grid; gap: 18px; max-width: 400px; margin: 0 auto; }
.auth-form h2 { font-size: var(--fs-xl); }
.auth-form .lead { color: var(--ink-3); font-size: var(--fs-sm); margin-top: 4px; }
.auth-foot { margin-top: 28px; text-align: center; color: var(--ink-3); font-size: var(--fs-xs); font-weight: 600; }
.link-btn { border: 0; background: none; padding: 8px; color: var(--primary); font-weight: 800; font-size: var(--fs-sm); }

@media (min-width: 900px) {
  .auth { flex-direction: row; background: var(--bg); align-items: center; justify-content: center; padding: 32px; }
  .auth-hero, .auth-body { min-height: 560px; }
  .auth-hero { flex: 0 0 380px; border-radius: var(--r-xl) 0 0 var(--r-xl); padding: 40px; }
  .auth-body { flex: 0 0 440px; margin: 0; border-radius: 0 var(--r-xl) var(--r-xl) 0; display: flex; flex-direction: column; justify-content: center; padding: 48px 44px; box-shadow: var(--sh-2); }
  .auth-hero { box-shadow: var(--sh-2); }
}

/* Leyenda compacta de estados */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; }
.legend span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.legend .l-pend::before { background: var(--primary); }
.legend .l-ok::before { background: var(--success); }
.legend .l-warn::before { background: var(--warning); }
.legend .l-bad::before { background: var(--danger); }

/* Tarjeta de guía compacta en pasos avanzados */
.is-compact .kv { display: none; }

/* Encuesta de satisfacción: QR al finalizar la entrega */
.success.success-qr { justify-content: flex-start; overflow-y: auto; padding: 28px 20px calc(24px + env(safe-area-inset-bottom)); gap: 8px; }
.success.success-qr .success-mark { width: 64px; height: 64px; font-size: 2rem; flex: none; }
.success.success-qr .encuesta-pide { font-weight: 700; color: var(--ink); }
.encuesta-qr { background: #fff; padding: 12px; border-radius: var(--r-lg); border: 1px solid var(--line); width: min(72vw, 280px); margin: 6px auto; flex: none; }
.encuesta-qr svg { display: block; width: 100%; height: auto; }
.success .encuesta-nota { font-size: var(--fs-sm); }
.encuesta-continuar { max-width: 360px; margin-top: auto; flex: none; }

/* Encuesta pública (encuesta.php) */
.enc-page { max-width: 520px; margin: 0 auto; padding: 24px 16px 40px; }
.enc-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.enc-brand img { height: 36px; width: auto; }
.enc-q { padding: 18px 16px; }
.enc-q + .enc-q { margin-top: 12px; }
.enc-q legend { font-weight: 800; font-size: var(--fs-base); margin-bottom: 4px; padding: 0; }
.enc-q .enc-ayuda { color: var(--ink-2); font-size: var(--fs-sm); margin-bottom: 12px; }
.enc-escala { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.enc-escala label { position: relative; display: block; cursor: pointer; }
.enc-escala input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.enc-op { display: grid; place-items: center; align-content: center; gap: 2px; min-height: 66px; padding: 4px 2px; border: 2px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); font-weight: 800; font-size: 1.3rem; color: var(--ink-2); transition: border-color .15s, background .15s; }
.enc-op small { font-size: .62rem; font-weight: 700; color: var(--ink-3); line-height: 1.1; text-align: center; }
.enc-escala input:focus-visible + .enc-op { outline: 3px solid var(--primary); outline-offset: 2px; }
.enc-escala input:checked + .enc-op { border-color: var(--primary); background: var(--primary); color: #fff; }
.enc-escala input:checked + .enc-op small { color: #fff; }
.enc-error { color: var(--danger); font-size: var(--fs-sm); font-weight: 700; margin-top: 8px; }
.enc-fin { text-align: center; padding: 40px 16px; }
.enc-fin .success-mark { margin: 0 auto 12px; }
