/* =====================================================================
   DIMAP - estilos v1.3
   Naranja = accion | Verde = cumplido / dinero | Azul = navegacion / ruta
   Texto negro. Mobile first con dos densidades:
     - Movil/tablet: controles 44px, texto de campos 16px (evita zoom en iOS)
     - Escritorio (>= 900px): controles 38px, texto base 15px
   Escala tipografica: 13 / 15 / 16 / 19 / 26 (titulos en Barlow Condensed 600)
   ===================================================================== */
:root {
  --orange: #F08A1C;
  --orange-strong: #D66F00;
  --orange-soft: #FFF1E0;
  --green: #1D8A4C;
  --green-soft: #E3F4EA;
  --blue: #1756A3;
  --blue-soft: #E6EFFA;
  --red: #C62828;
  --red-soft: #FDECEC;
  --ink: #000000;
  --ink-2: #3B4552;
  --line: #CFD8E2;
  --line-soft: #E4E9EF;
  --bg: #F2F5F8;
  --surface: #FFFFFF;
  --head-bg: #F6F8FA;

  --font: "Atkinson Hyperlegible", "Segoe UI", Roboto, Arial, sans-serif;
  --font-num: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;

  /* Escala */
  --fs-xs: .8125rem;   /* 13 */
  --fs-sm: .875rem;    /* 14 */
  --fs-base: 1rem;     /* 16 movil / 15 escritorio (via html) */
  --fs-h3: 1.0625rem;
  --fs-h2: 1.25rem;
  --fs-h1: 1.625rem;
  --fs-kpi: 1.625rem;
  --fs-input: 16px;    /* fijo: evita zoom automatico en iOS */

  /* Densidad */
  --ctl-h: 44px;
  --ctl-h-sm: 36px;
  --r-sm: 6px;
  --r-md: 10px;
  --gap: 14px;
  --pad: 14px;
  --topbar-h: 56px;
  --tabbar-h: 62px;
}

@media (min-width: 900px) {
  :root {
    --fs-h1: 1.75rem;
    --fs-kpi: 1.75rem;
    --fs-input: 14px;
    --ctl-h: 38px;
    --ctl-h-sm: 30px;
    --gap: 16px;
    --pad: 18px;
    --topbar-h: 52px;
  }
  html { font-size: 15px; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}
h1, h2, h3 { font-family: var(--font-num); font-weight: 600; line-height: 1.15; margin: 0 0 .5em; letter-spacing: .005em; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
p { margin: 0 0 .75em; }
a { color: var(--blue); }
small, .small { font-size: var(--fs-xs); color: var(--ink-2); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------------- Barra superior ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--gap);
  background: var(--surface);
  border-bottom: 3px solid var(--blue);
}
.brand { font-family: var(--font-num); font-weight: 700; font-size: 1.4rem; color: var(--blue); letter-spacing: .05em; text-decoration: none; }
.brand-role { font-size: var(--fs-sm); color: var(--ink-2); border-left: 1px solid var(--line); padding-left: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-spacer { flex: 1; }
.topbar-user { font-size: var(--fs-sm); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) { .topbar-user { display: none; } .topbar { gap: 8px; } }
.icon-btn {
  position: relative; min-width: 40px; height: 40px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
  font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
.icon-btn:hover { background: var(--head-bg); }
.icon-btn svg { width: 20px; height: 20px; }
@media (min-width: 900px) { .icon-btn { min-width: 36px; height: 36px; } .icon-btn svg { width: 18px; height: 18px; } }
.bell-count {
  position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 4px;
  border-radius: 10px; background: var(--orange); color: var(--ink);
  font-family: var(--font-num); font-weight: 700; font-size: .75rem; line-height: 19px; text-align: center;
}

/* ---------------- Layout ---------------- */
.page { max-width: 1240px; margin: 0 auto; padding: var(--gap) var(--gap) calc(var(--gap) * 2); }
body.has-tabbar .page { padding-bottom: calc(var(--tabbar-h) + 28px); }
.view { display: none; }
.view.active { display: block; }
.head-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; justify-content: space-between; margin-bottom: var(--gap); }
.head-row h1, .head-row h2 { margin: 0; }
.head-row .field { margin: 0; }
.head-row .row { gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.row > * { flex: 1 1 160px; }
.row > .shrink { flex: 0 0 auto; align-self: flex-end; }
.row > .check.shrink { margin-bottom: 12px; }
.head-row .row { align-items: flex-end; }
.grid-2 { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); margin-bottom: var(--gap); }
.grid-2 > * { min-width: 0; }
.grid-2 > .panel { margin-bottom: 0; }
.stack > * + * { margin-top: 12px; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid-2.wide-left { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: var(--pad);
  margin-bottom: var(--gap);
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; margin-bottom: 12px; }
.panel.flat { background: transparent; border: 0; padding: 0; }
.divider { border: 0; border-top: 1px solid var(--line-soft); margin: var(--gap) 0; }

/* ---------------- Barra de pestañas (inferior en movil, superior en escritorio) ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: var(--tabbar-h);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: none; font: inherit; font-size: .75rem; color: var(--ink-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-top: 3px solid transparent; cursor: pointer; min-width: 0;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button[aria-selected="true"] { border-top-color: var(--blue); color: var(--ink); font-weight: 700; }
@media (min-width: 900px) {
  .tabbar { position: sticky; top: var(--topbar-h); bottom: auto; height: 44px; justify-content: center; gap: 4px; border-top: 0; border-bottom: 1px solid var(--line); }
  .tabbar button { flex: 0 0 auto; flex-direction: row; padding: 0 14px; font-size: var(--fs-sm); gap: 7px; border-top: 0; border-bottom: 3px solid transparent; }
  .tabbar button:hover { color: var(--ink); background: var(--head-bg); }
  .tabbar button[aria-selected="true"] { border-bottom-color: var(--blue); }
  .tabbar button svg { width: 17px; height: 17px; }
  body.has-tabbar .page { padding-bottom: calc(var(--gap) * 2); }
}

/* Pestañas en linea (dentro de una vista) */
.seg { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: var(--gap); }
.seg button {
  flex: 0 0 auto; min-height: var(--ctl-h); padding: 0 12px; border: 0; background: none; font: inherit; font-size: var(--fs-sm); color: var(--ink-2);
  border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"] { border-bottom-color: var(--orange); color: var(--ink); font-weight: 700; }

/* ---------------- Formularios ---------------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field label, .field .label { font-weight: 700; font-size: var(--fs-xs); }
.field .hint { font-size: .75rem; color: var(--ink-2); }
input, select, textarea {
  width: 100%; min-height: var(--ctl-h); padding: 6px 10px;
  font-family: inherit; font-size: var(--fs-input); line-height: 1.3; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm);
}
select { padding-right: 28px; }
textarea { min-height: 84px; resize: vertical; padding-top: 8px; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--blue); }
input:hover, select:hover, textarea:hover { border-color: #B6C2CF; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 2px solid var(--blue-soft); }
.field.error input, .field.error select, .field.error textarea, .is-error { border-color: var(--red); background: var(--red-soft); }
.field-msg { font-size: var(--fs-xs); color: var(--red); font-weight: 700; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: var(--ctl-h); cursor: pointer; font-size: var(--fs-sm); }

/* Selector cumple / no cumple */
.choice { display: flex; gap: 6px; flex-wrap: wrap; }
.choice label {
  flex: 1 1 100px; min-height: var(--ctl-h); display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 2px solid var(--line); border-radius: var(--r-sm); cursor: pointer; font-weight: 700; font-size: var(--fs-sm); background: var(--surface);
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 4px; }
.choice label:has(input[value="cumple"]:checked) { border-color: var(--green); background: var(--green-soft); }
.choice label:has(input[value="no_cumple"]:checked) { border-color: var(--red); background: var(--red-soft); }
.choice label:has(input[value=""]:checked) { border-color: var(--ink-2); background: var(--line-soft); }

/* ---------------- Botones ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--ctl-h); padding: 0 16px;
  font-family: inherit; font-size: var(--fs-sm); font-weight: 700; color: var(--ink); text-decoration: none; line-height: 1.2;
  background: var(--orange); border: 1px solid var(--orange-strong); border-radius: var(--r-sm);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--orange-strong); }
.btn.green { background: var(--green); border-color: #166E3C; color: #fff; }
.btn.green:hover { background: #166E3C; }
.btn.blue { background: var(--surface); border-color: var(--blue); color: var(--blue); }
.btn.blue:hover { background: var(--blue-soft); }
.btn.ghost { background: var(--surface); border-color: var(--line); }
.btn.ghost:hover { background: var(--head-bg); border-color: #B6C2CF; }
.btn.danger { background: var(--surface); border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { min-height: var(--ctl-h-sm); padding: 0 10px; font-size: var(--fs-xs); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.small svg { width: 15px; height: 15px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.busy { opacity: .55; cursor: not-allowed; }
.btn.busy::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions.end { justify-content: flex-end; }

/* ---------------- Estados / badges ---------------- */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; line-height: 1.5; color: var(--ink); background: var(--line-soft); white-space: nowrap;
}
.badge.green, .badge.cumple, .badge.completo, .badge.entregado, .badge.aprobada, .badge.visitada, .badge.ganada, .badge.cerrado, .badge.liquidada { background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.badge.orange, .badge.borrador, .badge.preparando, .badge.parcial, .badge.enviada, .badge.en_proceso, .badge.programado, .badge.media { background: var(--orange-soft); box-shadow: inset 0 0 0 1px var(--orange-strong); }
.badge.blue, .badge.recibido, .badge.listo, .badge.entregado_ruta, .badge.abierta, .badge.pendiente, .badge.convertida, .badge.baja { background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
.badge.red, .badge.no_cumple, .badge.no_entregado, .badge.rechazada, .badge.cancelado, .badge.emergencia, .badge.perdida, .badge.alta { background: var(--red-soft); box-shadow: inset 0 0 0 1px var(--red); }

/* ---------------- Listas con franja de estado ---------------- */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
  padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--line-soft); border-left: 4px solid var(--line);
  border-radius: var(--r-sm); margin-bottom: 6px;
}
.item.s-green { border-left-color: var(--green); }
.item.s-orange { border-left-color: var(--orange); }
.item.s-blue { border-left-color: var(--blue); }
.item.s-red { border-left-color: var(--red); }
.item-main { min-width: 0; flex: 1; font-size: var(--fs-sm); }
.item-title { font-weight: 700; font-size: .9375rem; }
.item-meta { font-size: var(--fs-xs); color: var(--ink-2); }
.item ul { font-size: var(--fs-sm); }
.item .actions { margin-top: 8px; }
.item.clickable { cursor: pointer; }
.item.clickable:hover { border-color: var(--line); background: #FBFCFD; }
.empty { padding: 20px 16px; text-align: center; border: 1px dashed var(--line); border-radius: var(--r-md); background: var(--surface); font-size: var(--fs-sm); }
.empty p { margin: 0 0 10px; }
.empty p:last-child { margin-bottom: 0; }

/* ---------------- Linea de ruta (elemento distintivo) ---------------- */
.route { list-style: none; margin: 0; padding: 0 0 0 32px; position: relative; }
.route::before {
  content: ""; position: absolute; left: 12px; top: 18px; bottom: 18px; width: 4px;
  background: var(--blue); border-radius: 2px;
}
.stop { position: relative; padding: 4px 0 12px; }
.stop::before {
  content: ""; position: absolute; left: -28px; top: 13px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 4px solid var(--blue);
}
.stop.visiting::before { background: var(--orange); border-color: var(--orange-strong); animation: pulse 1.6s ease-in-out infinite; }
.stop.visited::before { background: var(--green); border-color: var(--green); }
.stop.visited::after {
  content: ""; position: absolute; left: -22px; top: 18px; width: 8px; height: 5px;
  border-left: 3px solid #fff; border-bottom: 3px solid #fff; transform: rotate(-45deg);
}
.stop-card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 12px 14px; }
.stop.visiting .stop-card { border: 2px solid var(--orange); }
.stop-name { font-family: var(--font-num); font-size: 1.25rem; font-weight: 600; line-height: 1.15; margin-bottom: 2px; }
.stop-order { font-family: var(--font-num); font-weight: 600; color: var(--blue); margin-right: 6px; }
.stop-card .item-meta { font-size: var(--fs-sm); }

/* ---------------- KPIs y graficas ---------------- */
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: var(--gap); }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line-soft); border-top: 3px solid var(--blue); border-radius: var(--r-md); padding: 10px 14px 12px; min-width: 0; }
.kpi.orange { border-top-color: var(--orange); }
.kpi.green { border-top-color: var(--green); }
.kpi.red { border-top-color: var(--red); }
.kpi-value { font-family: var(--font-num); font-size: var(--fs-kpi); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-label { font-size: var(--fs-xs); color: var(--ink-2); margin-top: 4px; line-height: 1.3; }

.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(84px, 32%) 1fr auto; gap: 10px; align-items: center; font-size: var(--fs-sm); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: block; height: 10px; background: var(--line-soft); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--blue); border-radius: 5px; min-width: 2px; }
.bar-fill.green { background: var(--green); }
.bar-fill.orange { background: var(--orange); }
.bar-value { font-family: var(--font-num); font-weight: 600; font-size: 1rem; min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; }
td .bars .bar-row { grid-template-columns: 1fr auto; }
td .bars .bar-label { display: none; }

.cols { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 6px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; min-width: 0; }
.col-bar { width: 100%; max-width: 36px; background: var(--blue); border-radius: 3px 3px 0 0; position: relative; }
.col-bar .col-sale { position: absolute; left: 0; right: 0; bottom: 0; background: var(--green); border-radius: 3px 3px 0 0; }
.col-val { font-family: var(--font-num); font-weight: 600; font-size: .9375rem; }
.col-lbl { font-size: .6875rem; color: var(--ink-2); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: var(--fs-xs); margin-top: 8px; color: var(--ink-2); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--blue); }
.legend .l-green::before { background: var(--green); }

/* ---------------- Tablas ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--r-md); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2); background: var(--head-bg); white-space: nowrap; }
tbody tr:hover td { background: #FAFBFD; }
td.r, th.r { text-align: right; }
td.num, .r.num { font-family: var(--font-num); font-size: 1rem; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tr.sub td { background: var(--head-bg); font-size: var(--fs-xs); }
tfoot td { font-weight: 700; background: var(--head-bg); }
td select { min-height: var(--ctl-h-sm); padding-top: 2px; padding-bottom: 2px; }
td .qty button, td .qty input { min-height: 34px; }

/* ---------------- Totales de documento ---------------- */
.totals { margin-left: auto; max-width: 340px; font-size: var(--fs-sm); }
.totals div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 6px; font-family: var(--font-num); font-size: 1.375rem; font-weight: 600; }

/* ---------------- Catalogo (categoria > subtipo > producto) ---------------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 8px; font-size: var(--fs-sm); }
.crumbs button { border: 0; background: none; color: var(--blue); font: inherit; text-decoration: underline; cursor: pointer; padding: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  min-height: var(--ctl-h); padding: 0 14px; border: 1px solid var(--blue); border-radius: 999px; background: var(--surface);
  font: inherit; font-size: var(--fs-sm); color: var(--ink); cursor: pointer;
}
.chip:hover { background: var(--blue-soft); }
.chip b { font-family: var(--font-num); margin-left: 6px; color: var(--blue); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.qty button { width: 34px; min-height: var(--ctl-h); border: 0; background: var(--line-soft); font-size: 1.1rem; font-weight: 700; cursor: pointer; color: var(--ink); }
.qty input { width: 56px; min-height: var(--ctl-h); border: 0; border-radius: 0; text-align: center; padding: 4px; }

/* ---------------- Mapa ---------------- */
.map { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--line-soft); }
.map iframe { display: block; width: 100%; height: 210px; border: 0; }
.map-foot { display: flex; justify-content: space-between; gap: 8px; padding: 7px 12px; font-size: var(--fs-xs); background: var(--surface); flex-wrap: wrap; }
.gps-state { font-size: var(--fs-sm); padding: 7px 10px; border-radius: var(--r-sm); background: var(--blue-soft); margin-top: 6px; }
.gps-state.ok { background: var(--green-soft); }
.gps-state.warn { background: var(--orange-soft); }

/* ---------------- Firma y fotos ---------------- */
.sign-box { position: relative; border: 2px dashed var(--ink-2); border-radius: var(--r-md); background: #fff; touch-action: none; }
.sign-box canvas { display: block; width: 100%; height: 180px; cursor: crosshair; }
.sign-box .sign-line { position: absolute; left: 20px; right: 20px; bottom: 40px; border-bottom: 1px solid var(--line); pointer-events: none; }
.sign-box .sign-hint { position: absolute; left: 20px; bottom: 14px; font-size: var(--fs-xs); color: var(--ink-2); pointer-events: none; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; }
.photos img { width: 76px; height: 76px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------------- Avisos ---------------- */
.banner {
  padding: 10px 14px; border-radius: var(--r-md); margin-bottom: 10px;
  border: 1px solid var(--line-soft); border-left: 4px solid var(--blue); background: var(--blue-soft);
  font-size: var(--fs-sm); line-height: 1.45;
}
.banner.orange { border-left-color: var(--orange); background: var(--orange-soft); }
.banner.green { border-left-color: var(--green); background: var(--green-soft); }
.banner.red { border-left-color: var(--red); background: var(--red-soft); }
.banner strong { display: block; font-size: .9375rem; margin-bottom: 2px; }
.banner .btn { margin-left: 6px; }
.banner .actions { margin-top: 8px; }
#d-alerts, #open-visit { margin-bottom: var(--gap); }
#d-alerts .banner { margin-bottom: 0; }
#d-alerts:not(:empty) { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
#d-alerts:empty, #open-visit:empty { margin-bottom: 0; }

/* ---------------- Toast ---------------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 14px); transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; width: min(92vw, 420px); }
@media (min-width: 900px) { #toast { bottom: 20px; left: auto; right: 20px; transform: none; } }
.toast {
  padding: 10px 14px; border-radius: var(--r-md); background: var(--surface); color: var(--ink); font-size: var(--fs-sm);
  border: 1px solid var(--line); border-left: 5px solid var(--blue); box-shadow: 0 8px 24px rgba(10, 30, 60, .16);
  animation: toast-in .18s ease-out;
}
.toast.ok { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--orange); }

/* ---------------- Modal ---------------- */
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(8, 20, 40, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--surface); width: 100%; max-width: 680px; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  border-radius: 14px 14px 0 0; padding: 0 var(--pad) var(--pad);
  animation: sheet-in .2s ease-out;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  padding: var(--pad) 0 10px; margin-bottom: 8px; border-bottom: 1px solid var(--line-soft);
}
.modal-head h2 { margin: 0; font-size: var(--fs-h2); }
@media (min-width: 760px) {
  .modal-back { align-items: center; padding: 24px; }
  .modal { border-radius: 12px; }
}

/* Notificaciones */
.notif-list .item.unread { border-left-color: var(--orange); background: #FFFBF5; }

/* ---------------- Login ---------------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--gap); background: var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 14px; padding: 26px 24px; border-top: 5px solid var(--blue); }
.login-brand { font-family: var(--font-num); font-size: 2.75rem; font-weight: 700; color: var(--blue); letter-spacing: .06em; line-height: 1; margin: 0; }
.login-sub { margin: 6px 0 20px; font-size: var(--fs-sm); color: var(--ink-2); }
.login-stripes { display: flex; gap: 6px; margin-bottom: 16px; }
.login-stripes span { height: 5px; flex: 1; border-radius: 3px; background: var(--orange); }
.login-stripes span:nth-child(2) { background: var(--green); }
.login-stripes span:nth-child(3) { background: var(--blue); }
.login-card .btn { min-height: 44px; font-size: .9375rem; }

/* ---------------- Animaciones ---------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(240, 138, 28, .55); } 50% { box-shadow: 0 0 0 7px rgba(240, 138, 28, 0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .topbar, .tabbar, .actions, #toast, .no-print { display: none !important; }
  body { background: #fff; }
  .panel { border: 0; }
}

/* Sin espacio sobrante al final de paneles y formularios */
.panel > :last-child, .panel > .row:last-child > .field, .panel > form:last-child > :last-child { margin-bottom: 0; }
