/* app.css — Sistema visual del taxímetro.
   Concepto: un instrumento de a bordo. El importe se lee en un visor de siete segmentos, como en
   un taxímetro de verdad (ámbar sobre negro de noche, LCD de día para leerse a pleno sol); el resto
   es interfaz iOS sobria: listas agrupadas, poca decoración, jerarquía tipográfica clara y objetivos
   táctiles grandes para usar de un vistazo. */

/* =========================================================================================
   Tokens
   ========================================================================================= */

:root {
  color-scheme: dark;
  /* Superficies (de más profunda a más elevada) */
  --fondo: #08090b;
  --capa: #121519;
  --capa-2: #1b1f25;
  --capa-3: #262b33;
  --linea: rgb(255 255 255 / 0.075);
  --linea-2: rgb(255 255 255 / 0.14);
  /* Texto */
  --texto: #eef1f4;
  --texto-2: #9ca5af;
  --texto-3: #6b7480;
  /* Marca y estados (como la luz del techo del taxi) */
  --ambar: #ffbf1f;
  --sobre-ambar: #1c1400;
  --tinta: #ffbf1f;
  --verde: #33d17a;
  --sobre-verde: #03270f;
  --rojo: #ff5249;
  --naranja: #ff9d2e;
  --azul: #57a8ff;
  --segmento: #2c323b;
  --interruptor: #39404a;
  /* Visor */
  --visor-fondo: #040506;
  --visor-on: #ffbf1f;
  --visor-off: rgb(255 191 31 / 0.075);
  --visor-borde: rgb(255 255 255 / 0.06);
  --visor-hondo: rgb(0 0 0 / 0.45);
  --visor-brillo: drop-shadow(0 0 9px rgb(255 170 20 / 0.38));
  /* Medidas */
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --r-xl: 26px;
  --barra: 52px;
  --pestanas: 56px;
  --lado: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --sombra: 0 14px 36px rgb(0 0 0 / 0.5);
  --fuente: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fuente-titulo: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-tema="claro"] {
  color-scheme: light;
  --fondo: #f0f1f3;
  --capa: #ffffff;
  --capa-2: #e8eaee;
  --capa-3: #dcdfe4;
  --linea: rgb(12 16 22 / 0.08);
  --linea-2: rgb(12 16 22 / 0.16);
  --texto: #0d1014;
  --texto-2: #586170;
  --texto-3: #8a929c;
  --ambar: #ffb81a;
  --tinta: #9a5800;
  --verde: #12924a;
  --sobre-verde: #ffffff;
  --rojo: #db2d26;
  --naranja: #cf6a00;
  --azul: #1f6fd6;
  --segmento: #ffffff;
  --interruptor: #d7dae0;
  --visor-fondo: #d6dccd;
  --visor-on: #13170f;
  --visor-off: rgb(19 23 15 / 0.075);
  --visor-borde: rgb(0 0 0 / 0.12);
  --visor-hondo: rgb(0 0 0 / 0.13);
  --visor-brillo: none;
  --sombra: 0 14px 36px rgb(16 24 40 / 0.14);
}

/* =========================================================================================
   Base
   ========================================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Lo que se enfoca o se desplaza a la vista queda fuera de las barras fijas */
  scroll-padding-top: calc(var(--barra) + env(safe-area-inset-top) + 8px);
  scroll-padding-bottom: calc(var(--pestanas) + env(safe-area-inset-bottom) + 96px);
}

body {
  margin: 0;
  min-height: 100dvh;
  padding-top: calc(var(--barra) + env(safe-area-inset-top));
  padding-bottom: calc(var(--pestanas) + env(safe-area-inset-bottom));
  background: var(--fondo);
  color: var(--texto);
  font: 400 17px/1.4 var(--fuente);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* =========================================================================================
   Barra superior: luz de estado, módulo de tarifa, GPS y hora
   ========================================================================================= */

.barra {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(var(--barra) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--lado) 0;
  background: color-mix(in srgb, var(--fondo) 84%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--linea);
}

.barra-der { display: flex; align-items: center; gap: 14px; margin-left: auto; }

.luz {
  --c: var(--verde);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 34px;
  padding: 0 15px 0 13px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 15%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 34%, transparent);
  color: var(--c);
  font: 800 14px/1 var(--fuente-titulo);
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.luz::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px 1px currentColor;
}
.luz.ocupado { --c: var(--rojo); }
.luz.pausa { --c: var(--naranja); }
.luz.pagar { --c: var(--azul); }

/* En vertical la tarifa ya se ve en el selector; el módulo de la barra solo aparece en horizontal */
#estado-tarifa { display: none; }

.modulo {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 7px;
  border-radius: 9px;
  background: var(--capa-2);
  box-shadow: inset 0 0 0 1px var(--linea-2);
  font: 800 14px/1 var(--fuente-titulo);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.gps {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--texto-2);
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.gps .ico { width: 17px; height: 17px; color: var(--texto-3); }
.gps.ok .ico { color: var(--verde); fill: var(--verde); }
.gps.debil .ico, .gps.buscando .ico { color: var(--naranja); }
.gps.error, .gps.error .ico { color: var(--rojo); }
.gps.buscando .ico { animation: latido 1.4s ease-in-out infinite; }
@keyframes latido { 50% { opacity: 0.25; } }

.reloj { font: 650 15px/1 var(--fuente-titulo); font-variant-numeric: tabular-nums; }

/* Aviso de arranque fallido: aparece a los 6 s si la app no lo ha retirado, o al momento si hay un error */
.fallo-carga {
  position: fixed;
  inset: auto 16px calc(var(--pestanas) + env(safe-area-inset-bottom) + 16px);
  z-index: 40;
  padding: 16px 18px;
  border-radius: var(--r-l);
  background: #4a1512;
  color: #fff;
  box-shadow: var(--sombra);
  font-size: 15px;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  animation: mostrar-fallo 0.3s 6s forwards !important;
}
.fallo-carga.visible { opacity: 1; visibility: visible; animation: none !important; }
.fallo-carga p { margin-top: 6px; color: #ffd9d6; overflow-wrap: anywhere; }
@keyframes mostrar-fallo { to { opacity: 1; visibility: visible; } }

/* =========================================================================================
   Avisos: una línea, icono de color según la gravedad y una acción
   ========================================================================================= */

.avisos {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 760px;
  margin: 0 auto;
  padding: 10px var(--lado) 0;
}
.avisos:empty { display: none; }

.aviso {
  --c: var(--azul);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 6px 6px 6px 12px;
  border-radius: var(--r-m);
  background: var(--capa);
  box-shadow: inset 0 0 0 1px var(--linea);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
}
.aviso > .ico { width: 20px; height: 20px; color: var(--c); }
.aviso-texto { flex: 1; min-width: 0; }
.aviso-accion {
  flex: none;
  padding: 8px 8px;
  border: 0;
  background: none;
  color: var(--tinta);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.aviso-cerrar { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border: 0; background: none; color: var(--texto-3); }
.aviso-cerrar .ico { width: 18px; height: 18px; }
.aviso-error { --c: var(--rojo); background: color-mix(in srgb, var(--rojo) 13%, var(--capa)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rojo) 38%, transparent); }
.aviso-aviso { --c: var(--naranja); }

/* =========================================================================================
   Estructura, títulos y secciones agrupadas (estilo iOS)
   ========================================================================================= */

main { max-width: 760px; margin: 0 auto; padding: 12px var(--lado) 28px; }

.vista { display: flex; flex-direction: column; gap: 20px; animation: aparecer 0.18s ease-out; }
@keyframes aparecer { from { opacity: 0; transform: translateY(4px); } }

.titulo-grande { margin: 6px 2px -6px; font: 800 32px/1.1 var(--fuente-titulo); letter-spacing: -0.02em; }

.pila { display: flex; flex-direction: column; gap: 12px; }
.pila:empty { display: none; }
.fila { display: flex; gap: 10px; }
.fila > * { flex: 1; }

.seccion { display: flex; flex-direction: column; gap: 8px; }
.seccion-titulo {
  padding: 0 16px;
  color: var(--texto-3);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.seccion-nota { padding: 0 16px; color: var(--texto-3); font-size: 13px; line-height: 1.4; }
.nota { padding: 0 4px; color: var(--texto-3); font-size: 13px; line-height: 1.45; }

.grupo {
  border-radius: var(--r-l);
  background: var(--capa);
  box-shadow: inset 0 0 0 1px var(--linea);
  overflow: hidden;
}

.celda {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 10px 16px;
  font-size: 17px;
}
.grupo > .celda:not(:first-child)::before,
.grupo > .rapidos + .celda::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  border-top: 1px solid var(--linea);
}
.celda:focus-within { background: color-mix(in srgb, var(--texto) 4%, transparent); }
.celda-etiqueta { flex: 1; min-width: 0; }
.celda-valor {
  flex: 0 1 58%;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--texto-2);
  font-size: 17px;
  text-align: right;
}
.celda-valor.celda-num { flex: 0 0 auto; width: 6.2em; }
.celda-valor:focus { color: var(--texto); }
.celda-valor::placeholder { color: var(--texto-3); }
select.celda-valor { -webkit-appearance: none; appearance: none; text-align-last: right; cursor: pointer; }
.celda-select::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin: -4px 2px 0 -4px;
  border-right: 2px solid var(--texto-3);
  border-bottom: 2px solid var(--texto-3);
  transform: rotate(45deg);
}
.celda-unidad { flex: none; min-width: 2.4em; color: var(--texto-3); font-size: 15px; }
.celda-nota { min-height: 0; padding-top: 10px; padding-bottom: 12px; color: var(--texto-3); font-size: 14px; }
.celda-boton {
  justify-content: center;
  width: 100%;
  border: 0;
  background: none;
  color: var(--tinta);
  font-weight: 650;
}
.celda-boton.peligro { color: var(--rojo); }
.celda-acciones { gap: 8px; }
.celda-acciones .btn { flex: 1; min-height: 42px; font-size: 15px; }
.celda-bloque { flex-direction: column; align-items: stretch; }

/* Interruptor estilo iOS */
.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 31px;
  background: var(--interruptor);
  cursor: pointer;
  transition: background 0.2s;
}
.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgb(0 0 0 / 0.3);
  transition: transform 0.2s cubic-bezier(0.3, 0.7, 0.4, 1);
}
.switch:checked { background: var(--verde); }
.switch:checked::before { transform: translateX(20px); }

/* Control segmentado */
.segmentado {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-m);
  background: var(--capa-2);
}
.segmentado button {
  min-height: 46px;
  border: 0;
  border-radius: 11px;
  background: none;
  color: var(--texto-2);
  font-size: 15px;
  font-weight: 650;
}
.segmentado button[aria-pressed="true"] {
  background: var(--segmento);
  color: var(--texto);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.25), inset 0 0 0 1px var(--linea);
}

/* Contador − n + */
.paso { display: inline-flex; align-items: center; flex: none; border-radius: 12px; background: var(--capa-2); }
.paso button { display: grid; place-items: center; width: 44px; height: 40px; border: 0; background: none; }
.paso button:disabled { opacity: 0.3; }
.paso .ico { width: 18px; height: 18px; stroke-width: 2.4; }
.paso output { min-width: 22px; font-weight: 750; font-variant-numeric: tabular-nums; text-align: center; }

/* =========================================================================================
   Botones
   ========================================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--r-m);
  background: var(--capa-2);
  color: var(--texto);
  font-size: 17px;
  font-weight: 650;
  transition: transform 0.08s ease, filter 0.08s ease;
}
.btn:active { transform: scale(0.97); filter: brightness(1.12); }
.btn:disabled { opacity: 0.35; pointer-events: none; }
.btn .ico { width: 20px; height: 20px; }
.btn-xl {
  min-height: 76px;
  border-radius: var(--r-l);
  font: 800 21px/1 var(--fuente-titulo);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.btn-xl .ico { width: 24px; height: 24px; }
.btn-verde { background: var(--verde); color: var(--sobre-verde); }
.btn-rojo { background: var(--rojo); color: #fff; }
.btn-neutro { background: var(--capa-3); }
.btn-texto { min-height: 44px; padding: 0 10px; background: none; color: var(--tinta); }
.btn-texto.rojo { color: var(--rojo); }
.btn-icono { width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 50%; }
:root:not([data-tema="claro"]) .btn-xl.btn-verde { box-shadow: 0 12px 30px -14px rgb(51 209 122 / 0.7); }
:root:not([data-tema="claro"]) .btn-xl.btn-rojo { box-shadow: 0 12px 30px -14px rgb(255 82 73 / 0.7); }
.btn .ico-relleno { fill: currentColor; stroke: none; }

/* Botones fijos sobre las pestañas (acción principal siempre a mano) */
.acciones-fijas {
  position: sticky;
  bottom: calc(var(--pestanas) + env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: -8px 0 -14px;
  padding: 16px 0 14px;
  background: linear-gradient(to bottom, transparent, var(--fondo) 18px);
}

/* =========================================================================================
   Taxímetro
   ========================================================================================= */

.vista-taximetro {
  min-height: calc(100dvh - var(--barra) - var(--pestanas) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 40px);
  justify-content: space-between;
  gap: 14px;
}
.tx-zona { display: flex; flex-direction: column; gap: 14px; }

.selector-tarifa {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 10px;
  max-width: 100%;
  min-height: 44px;
  padding: 6px 12px 6px 6px;
  border: 0;
  border-radius: 999px;
  background: var(--capa);
  box-shadow: inset 0 0 0 1px var(--linea);
  font-size: 16px;
  font-weight: 650;
}
.selector-tarifa .modulo { min-width: 32px; height: 32px; border-radius: 999px; background: var(--ambar); color: var(--sobre-ambar); box-shadow: none; }
.selector-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selector-tarifa > .ico { width: 18px; height: 18px; color: var(--texto-3); }

.etiqueta {
  flex: none;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--capa-2);
  color: var(--texto-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* El visor: un cristal hundido con las cifras de segmentos */
.panel {
  position: relative;
  padding: 16px 18px 16px 14px;
  border-radius: var(--r-xl);
  background: var(--visor-fondo);
  box-shadow: inset 0 0 0 1px var(--visor-borde), inset 0 16px 36px var(--visor-hondo);
  overflow: hidden;
}
.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgb(255 255 255 / 0.05), transparent 42%);
  pointer-events: none;
}
.panel-cab {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-left: 4px;
  color: color-mix(in srgb, var(--visor-on) 55%, transparent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.visor { display: flex; align-items: flex-end; gap: 10px; margin-top: 12px; }
.visor-cifras { flex: 1; min-width: 0; }
.visor-cifras svg { display: block; width: 100%; height: auto; max-height: min(17vh, 150px); filter: var(--visor-brillo); }
.siete .on { fill: var(--visor-on); }
.siete .off { fill: var(--visor-off); }
.visor-euro { padding-bottom: 6px; color: var(--visor-on); font: 700 30px/1 var(--fuente-titulo); }
.panel.apagado .siete .on { fill: color-mix(in srgb, var(--visor-on) 22%, transparent); }
.panel.apagado .visor-euro { opacity: 0.25; }
.panel.apagado .visor-cifras svg { filter: none; }
.panel-pie {
  margin-top: 10px;
  padding-left: 4px;
  color: color-mix(in srgb, var(--visor-on) 72%, transparent);
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.panel-pie:empty { display: none; }

/* Lecturas: un bloque con separadores finos, sin cajas sueltas */
.lecturas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: var(--r-l);
  background: var(--capa);
  box-shadow: inset 0 0 0 1px var(--linea);
  overflow: hidden;
}
.lectura { padding: 12px 16px 13px; }
.lectura:nth-child(odd) { border-right: 1px solid var(--linea); }
.lectura:nth-child(-n + 2) { border-bottom: 1px solid var(--linea); }
.lectura dt { color: var(--texto-3); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.lectura dd {
  margin-top: 4px;
  font: 650 28px/1.05 var(--fuente-titulo);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.lectura small { margin-left: 4px; color: var(--texto-2); font-size: 15px; font-weight: 600; letter-spacing: 0; }
.precios .lectura dd { font-size: 24px; }

/* Suplementos rápidos */
.chips {
  display: flex;
  gap: 8px;
  margin: 0 calc(var(--lado) * -1);
  padding: 2px var(--lado);
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 16px 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--capa);
  box-shadow: inset 0 0 0 1px var(--linea-2);
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
}
.chip .ico { width: 18px; height: 18px; color: var(--tinta); stroke-width: 2.4; }
.chip.activo { box-shadow: inset 0 0 0 1.5px var(--ambar); }
.chip-pequeno { height: 36px; padding: 0 13px; font-size: 14px; }
.insignia {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--ambar);
  color: var(--sobre-ambar);
  font-size: 13px;
  font-weight: 800;
}

.tx-mandos { gap: 12px; }
.tx-acciones { display: flex; gap: 12px; }
.tx-acciones .btn { flex: 1; }
.tx-acciones #b-finalizar { flex: 1.5; }

/* =========================================================================================
   Cobro, presupuesto y desglose
   ========================================================================================= */

.panel-cobro .visor-cifras svg { max-height: min(13vh, 112px); }

.desglose { width: 100%; border-collapse: collapse; font-size: 15px; }
.desglose td { padding: 12px 16px; border-top: 1px solid var(--linea); vertical-align: top; }
.desglose tr:first-child td { border-top: 0; }
.desglose td:last-child { padding-left: 8px; text-align: right; white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.desglose tr.total td { font-size: 17px; font-weight: 800; }

.rapidos { display: flex; gap: 6px; padding: 0 16px 12px; overflow-x: auto; scrollbar-width: none; }
.rapidos::-webkit-scrollbar { display: none; }
.rapidos:empty { display: none; }

.resultado { border-radius: var(--r-l); background: var(--capa); box-shadow: inset 0 0 0 1px var(--linea); overflow: hidden; }
.resultado-cab { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 16px 14px; border-bottom: 1px solid var(--linea); }
.resultado-cab span { color: var(--texto-3); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.resultado-cab strong { color: var(--tinta); font: 800 36px/1 var(--fuente-titulo); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.plegable summary { display: flex; align-items: center; justify-content: space-between; list-style: none; cursor: pointer; }
.plegable summary::-webkit-details-marker { display: none; }
.plegable summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 2px solid var(--texto-3);
  border-bottom: 2px solid var(--texto-3);
  transform: rotate(45deg);
  transition: transform 0.2s;
}
.plegable[open] summary::after { transform: rotate(225deg); }
.plegable[open] summary { margin-bottom: 8px; }

.cuadro { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.cuadro th, .cuadro td { padding: 10px 8px; border-bottom: 1px solid var(--linea); text-align: right; white-space: nowrap; }
.cuadro th:first-child, .cuadro td:first-child { padding-left: 16px; text-align: left; white-space: normal; }
.cuadro th:last-child, .cuadro td:last-child { padding-right: 16px; }
.cuadro th { color: var(--texto-3); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.cuadro .modulo { min-width: 30px; height: 26px; margin-right: 6px; border-radius: 7px; font-size: 12px; }
.tabla-scroll { overflow-x: auto; }
.lista-cuadro { margin: 0; padding: 12px 16px 14px 34px; color: var(--texto-2); font-size: 14px; line-height: 1.5; border-top: 1px solid var(--linea); }
.cuadro-nota { padding: 12px 16px 14px; color: var(--texto-3); font-size: 13px; border-top: 1px solid var(--linea); }

/* =========================================================================================
   Recibo emitido
   ========================================================================================= */

.exito { display: flex; align-items: center; gap: 14px; padding: 4px 2px 0; }
.exito-icono {
  flex: none;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--verde) 18%, transparent);
  color: var(--verde);
}
.exito-icono .ico { width: 28px; height: 28px; stroke-width: 2.8; }
.exito-titulo { font: 800 25px/1.15 var(--fuente-titulo); letter-spacing: -0.015em; }
.exito-sub { margin-top: 2px; color: var(--texto-2); font-size: 16px; font-variant-numeric: tabular-nums; }
.exito-sub strong { color: var(--texto); font-weight: 750; }

.tarjeta-qr {
  align-self: center;
  width: min(100%, 320px, calc(38dvh + 40px));
  padding: 14px 14px 16px;
  border-radius: 24px;
  background: #fff;
  color: #111418;
  box-shadow: var(--sombra);
  text-align: center;
}
.qr svg { display: block; width: 100%; height: auto; }
.tarjeta-qr p { margin-top: 8px; color: #4b5563; font-size: 14px; font-weight: 600; line-height: 1.35; }

/* =========================================================================================
   Historial
   ========================================================================================= */

.mes { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mes h2 { font: 700 19px/1.2 var(--fuente-titulo); text-align: center; }
.mes .btn-icono { background: var(--capa); box-shadow: inset 0 0 0 1px var(--linea); }

.resumen { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dato { padding: 14px 16px; border-radius: var(--r-l); background: var(--capa); box-shadow: inset 0 0 0 1px var(--linea); }
.dato span { color: var(--texto-3); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.dato strong { display: block; margin-top: 4px; font: 750 28px/1.1 var(--fuente-titulo); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.dato small { display: block; margin-top: 4px; color: var(--texto-2); font-size: 13px; }
.pagos { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.pago-chip { padding: 5px 10px; border-radius: 999px; background: var(--capa); box-shadow: inset 0 0 0 1px var(--linea); color: var(--texto-2); font-size: 13px; font-weight: 600; }

.dia-cab { display: flex; justify-content: space-between; gap: 12px; padding: 0 16px; color: var(--texto-3); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

.fila-servicio {
  position: relative;
  display: grid;
  grid-template-columns: 50px 1fr auto 14px;
  align-items: center;
  gap: 2px 10px;
  width: 100%;
  padding: 12px 12px 12px 16px;
  border: 0;
  background: none;
  text-align: left;
}
.fila-servicio + .fila-servicio::before { content: ""; position: absolute; top: 0; left: 76px; right: 0; border-top: 1px solid var(--linea); }
.fila-servicio:active { background: color-mix(in srgb, var(--texto) 5%, transparent); }
.fila-servicio .hora { grid-row: 1 / span 2; align-self: start; padding-top: 1px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fila-servicio .ruta { display: -webkit-box; overflow: hidden; font-weight: 650; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.fila-servicio .meta { grid-column: 2; color: var(--texto-2); font-size: 13px; line-height: 1.5; }
.fila-servicio .importe { grid-row: 1 / span 2; grid-column: 3; font-weight: 750; font-variant-numeric: tabular-nums; }
.fila-servicio > .ico { grid-row: 1 / span 2; grid-column: 4; width: 16px; height: 16px; color: var(--texto-3); }
.fila-servicio.anulado .ruta, .fila-servicio.anulado .importe { color: var(--texto-3); text-decoration: line-through; }
.marca-estado {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--capa-2);
  color: var(--texto-2);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  vertical-align: 1px;
}
.marca-estado.rojo { background: color-mix(in srgb, var(--rojo) 18%, transparent); color: var(--rojo); }
.marca-estado.naranja { background: color-mix(in srgb, var(--naranja) 18%, transparent); color: var(--naranja); }
.vacio { padding: 28px 16px; color: var(--texto-3); text-align: center; }

/* =========================================================================================
   Ajustes
   ========================================================================================= */

.tarifa-cab { display: flex; align-items: center; gap: 12px; padding: 14px 16px 12px; }
.tarifa-cab .modulo { min-width: 42px; height: 36px; border-radius: 10px; background: var(--ambar); color: var(--sobre-ambar); box-shadow: none; font-size: 15px; }
.tarifa-cab input {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--texto);
  font: 700 19px/1.2 var(--fuente-titulo);
}

.dias { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; width: 100%; }
.dias button {
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--capa-2);
  color: var(--texto-2);
  font-size: 15px;
  font-weight: 800;
}
.dias button[aria-pressed="true"] { background: var(--ambar); color: var(--sobre-ambar); }

textarea.celda-valor {
  width: 100%;
  min-height: 140px;
  flex: 1 1 auto;
  padding: 2px 0;
  color: var(--texto);
  font: 15px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  text-align: left;
  resize: vertical;
}

.aviso-seccion {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-m);
  background: color-mix(in srgb, var(--naranja) 11%, var(--capa));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--naranja) 30%, transparent);
  font-size: 14px;
  line-height: 1.4;
}
.aviso-seccion .ico { width: 20px; height: 20px; color: var(--naranja); }

.diagnostico { color: var(--texto-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.pasos { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 0; padding-left: 20px; color: var(--texto-2); line-height: 1.4; }
.errores { display: flex; flex-direction: column; gap: 6px; padding-left: 20px; color: var(--texto-2); }

.barra-guardar {
  position: sticky;
  bottom: calc(var(--pestanas) + env(safe-area-inset-bottom) + 10px);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 16px;
  border-radius: var(--r-l);
  background: color-mix(in srgb, var(--capa-2) 92%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--sombra), inset 0 0 0 1px var(--linea-2);
}
.barra-guardar span { flex: 1; color: var(--texto-2); font-size: 14px; font-weight: 600; }
.barra-guardar .btn { min-height: 44px; }

/* =========================================================================================
   Pestañas inferiores
   ========================================================================================= */

.pestanas {
  position: fixed;
  inset: auto 0 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--pestanas) + env(safe-area-inset-bottom));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: color-mix(in srgb, var(--capa) 82%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--linea);
}
.pestanas button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: none;
  color: var(--texto-3);
  font-size: 11px;
  font-weight: 650;
}
.pestanas .ico { width: 25px; height: 25px; }
.pestanas button[aria-current="page"] { color: var(--tinta); }

/* =========================================================================================
   Hojas (diálogos que suben desde abajo) y toast
   ========================================================================================= */

.hoja {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 26px 26px 0 0;
  background: var(--capa);
  color: var(--texto);
  box-shadow: 0 -12px 40px rgb(0 0 0 / 0.4);
  overflow: auto;
  overscroll-behavior: contain;
}
.hoja[open] { animation: subir 0.28s cubic-bezier(0.2, 0.85, 0.25, 1); }
.hoja::backdrop { background: rgb(0 0 0 / 0.55); }
.hoja[open]::backdrop { animation: fundido 0.2s ease-out; }
@keyframes subir { from { transform: translateY(48px); opacity: 0.5; } }
@keyframes fundido { from { opacity: 0; } }
.hoja-asa { width: 38px; height: 5px; margin: 0 auto 16px; border-radius: 3px; background: var(--linea-2); }
.hoja h2 { margin-bottom: 8px; font: 750 22px/1.25 var(--fuente-titulo); letter-spacing: -0.01em; }
.hoja-texto { color: var(--texto-2); font-size: 16px; line-height: 1.45; }
.hoja-pie { margin-top: 14px; color: var(--texto-3); font-size: 14px; }
.hoja-botones { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.hoja-botones .btn { width: 100%; min-height: 56px; }
.hoja-botones .opcion { justify-content: flex-start; gap: 12px; padding: 0 14px; background: var(--capa-2); text-align: left; }
.opcion .modulo { background: var(--ambar); color: var(--sobre-ambar); box-shadow: none; }
.opcion-texto { display: flex; flex: 1; flex-direction: column; min-width: 0; line-height: 1.2; }
.opcion-texto small { color: var(--texto-2); font-size: 13px; font-weight: 500; }
.opcion[aria-current="true"] { box-shadow: inset 0 0 0 2px var(--ambar); }
.entrada-grande {
  width: 100%;
  min-height: 72px;
  margin-top: 12px;
  border: 0;
  border-radius: var(--r-m);
  outline: none;
  background: var(--capa-2);
  color: var(--texto);
  font: 750 38px/1 var(--fuente-titulo);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.detalle { display: flex; flex-direction: column; gap: 14px; }
.detalle .ayuda { color: var(--texto-2); font-size: 14px; }
.detalle a { color: var(--tinta); }

.toast {
  position: fixed;
  top: calc(var(--barra) + env(safe-area-inset-top) + 10px);
  left: 50%;
  z-index: 30;
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--texto);
  color: var(--fondo);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--sombra);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px) scale(0.98);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* =========================================================================================
   Horizontal: iPhone en el soporte del salpicadero
   ========================================================================================= */

@media (orientation: landscape) and (max-height: 540px) {
  :root { --barra: 46px; --pestanas: 46px; }
  .pestanas button span { display: none; }
  .titulo-grande { font-size: 26px; }
  #estado-tarifa:not([hidden]) { display: inline-grid; }
  /* Conduciendo solo importan los avisos urgentes */
  .avisos .aviso-info { display: none; }
  .avisos { padding-top: 6px; }
  main { padding-top: 8px; padding-bottom: 8px; }

  .vista-taximetro {
    display: grid;
    grid-template-columns: 1.45fr 1fr;
    align-items: center;
    gap: 16px;
    min-height: calc(100dvh - var(--barra) - var(--pestanas) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px);
  }
  body:not([data-fase="libre"]) .selector-tarifa { display: none; }
  .tx-zona, .tx-mandos { min-width: 0; }
  .tx-zona { gap: 8px; }
  .panel { padding: 10px 14px 10px 10px; }
  .visor { margin-top: 4px; }
  .visor-cifras svg { max-height: 30vh; }
  .panel-pie { margin-top: 4px; font-size: 14px; }
  .lecturas { grid-template-columns: repeat(4, 1fr); }
  .lectura { padding: 7px 12px; border: 0 !important; }
  .lectura + .lectura { border-left: 1px solid var(--linea) !important; }
  .lectura dt { font-size: 10px; }
  .lectura dd { font-size: 19px; }
  .lectura small { font-size: 12px; }
  .precios .lectura dd { font-size: 17px; }

  .tx-mandos { position: static; margin: 0; padding: 0; background: none; }
  .chips { margin: 0; padding: 0; }
  .chip { height: 42px; }
  .tx-acciones { flex-direction: column; gap: 10px; }
  .tx-acciones #b-finalizar { flex: none; }
  .btn-xl { min-height: 60px; font-size: 19px; }
}

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