/* Camión — hoja única. Mobile-first: en el teléfono, barra de pestañas abajo;
   desde 900px, barra lateral oscura a la izquierda.

   El tema sigue al sistema salvo que se elija uno a mano: <html data-theme="light|dark">
   (ver app.js). Por eso el bloque oscuro aparece dos veces. */

:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f2f5f9;
  --surface-3: #e7ecf3;
  --borde: #e2e7ef;
  --borde-fuerte: #cbd3df;
  --texto: #0f172a;
  --texto-2: #4a5669;
  --texto-3: #7d8aa0;
  --acento: #2563eb;
  --acento-hover: #1d4ed8;
  --acento-suave: #eaf1fe;
  --acento-texto: #1d4ed8;
  --anillo: rgba(37, 99, 235, .28);
  --ok: #047857;
  --ok-suave: #e5f6ee;
  --alerta: #b45309;
  --alerta-suave: #fdf3e1;
  --error: #c62828;
  --error-suave: #fdeded;
  --dato: #2563eb;           /* marcas de gráficos: validado contra --surface */

  --lateral: #0f172a;
  --lateral-2: #1b2539;
  --lateral-texto: #aab6c8;
  --lateral-fuerte: #f8fafc;
  --lateral-borde: #1f2a3e;

  --sombra: 0 1px 2px rgba(15, 23, 42, .05);
  --sombra-media: 0 2px 6px rgba(15, 23, 42, .06), 0 10px 24px rgba(15, 23, 42, .06);
  --sombra-alta: 0 12px 40px rgba(15, 23, 42, .22);
  --brillo: rgba(255, 255, 255, .45);
  --r: 14px;
  --r-sm: 10px;
  --r-xs: 7px;
  --nav-h: 64px;
  --lateral-w: 248px;
  --fuente: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1120;
    --surface: #151c28;
    --surface-2: #1a2231;
    --surface-3: #222c3d;
    --borde: #243044;
    --borde-fuerte: #334157;
    --texto: #e7ecf4;
    --texto-2: #a5b1c3;
    --texto-3: #6f7d93;
    --acento: #4f8ff7;
    --acento-hover: #6ea2f9;
    --acento-suave: #172540;
    --acento-texto: #8db5fb;
    --anillo: rgba(79, 143, 247, .38);
    --ok: #4ade80;
    --ok-suave: #12291d;
    --alerta: #fbbf24;
    --alerta-suave: #2e2410;
    --error: #f87171;
    --error-suave: #331a1c;
    --dato: #3b82f6;
    --lateral: #080d18;
    --lateral-2: #151e30;
    --lateral-borde: #182236;
    --sombra: 0 1px 2px rgba(0, 0, 0, .35);
    --sombra-media: 0 2px 6px rgba(0, 0, 0, .3), 0 10px 24px rgba(0, 0, 0, .25);
    --sombra-alta: 0 12px 40px rgba(0, 0, 0, .6);
    --brillo: rgba(255, 255, 255, .05);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #151c28;
  --surface-2: #1a2231;
  --surface-3: #222c3d;
  --borde: #243044;
  --borde-fuerte: #334157;
  --texto: #e7ecf4;
  --texto-2: #a5b1c3;
  --texto-3: #6f7d93;
  --acento: #4f8ff7;
  --acento-hover: #6ea2f9;
  --acento-suave: #172540;
  --acento-texto: #8db5fb;
  --anillo: rgba(79, 143, 247, .38);
  --ok: #4ade80;
  --ok-suave: #12291d;
  --alerta: #fbbf24;
  --alerta-suave: #2e2410;
  --error: #f87171;
  --error-suave: #331a1c;
  --dato: #3b82f6;
  --lateral: #080d18;
  --lateral-2: #151e30;
  --lateral-borde: #182236;
  --sombra: 0 1px 2px rgba(0, 0, 0, .35);
  --sombra-media: 0 2px 6px rgba(0, 0, 0, .3), 0 10px 24px rgba(0, 0, 0, .25);
  --sombra-alta: 0 12px 40px rgba(0, 0, 0, .6);
  --brillo: rgba(255, 255, 255, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--fuente);
  background: var(--bg);
  color: var(--texto);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 680; letter-spacing: -.015em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--acento-texto); }
:focus-visible { outline: 3px solid var(--anillo); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Arranque y carga ---------- */
.cargando::after {
  content: ""; position: fixed; inset: 0;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='20' r='16' fill='none' stroke='%232563eb' stroke-width='4' stroke-linecap='round' stroke-dasharray='70 30'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 20 20' to='360 20 20' dur='.9s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E") center no-repeat;
}

/* Esqueleto mientras carga una pantalla: la forma de lo que viene, no un texto. */
.esqueleto { display: grid; gap: 14px; }
.esqueleto .bloque {
  border-radius: var(--r); background-color: var(--surface-3);
  background-image: linear-gradient(90deg, transparent, var(--brillo), transparent);
  background-size: 200% 100%; animation: brillo 1.3s ease-in-out infinite;
}
.esqueleto .titulo { height: 34px; width: 38%; border-radius: var(--r-xs); }
.esqueleto .fila-kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.esqueleto .fila-kpis .bloque { height: 96px; }
.esqueleto .grande { height: 320px; }
/* Al cambiar un filtro, lo anterior queda a la vista, atenuado, hasta que llega lo nuevo. */
.actualizando { opacity: .5; pointer-events: none; transition: opacity .15s; }
@keyframes brillo { from { background-position: 200% 0 } to { background-position: -200% 0 } }

/* ---------- Estructura ---------- */
.layout { min-height: 100vh; }
main {
  padding: 18px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
  max-width: 1240px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
}
/* El chofer no tiene barra de pestañas: su pantalla no deja hueco abajo. */
.layout:not(.con-lateral) main { padding-bottom: calc(env(safe-area-inset-bottom) + 28px); max-width: 640px; }

/* Encabezado de pantalla */
.encabezado {
  display: flex; align-items: flex-end; gap: 12px;
  margin: 4px 0 20px; flex-wrap: wrap;
}
.encabezado h1 { font-size: 24px; line-height: 1.2; }
/* El título se queda a la izquierda y las acciones se van a la derecha. */
.encabezado > div:first-child { flex: 1 1 160px; min-width: 0; }
.subtitulo { color: var(--texto-2); font-size: 13.5px; margin-top: 3px; }
@media (min-width: 900px) { .encabezado h1 { font-size: 28px; } }

/* ---------- Navegación: pestañas abajo (teléfono) ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--borde);
  padding: 0 4px env(safe-area-inset-bottom);
}
nav.tabs .marca-lateral, nav.tabs .grupo, nav.tabs .pie-lateral, nav.tabs .solo-lateral { display: none; }
nav.tabs a, nav.tabs .mas {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 8px 2px; text-decoration: none; color: var(--texto-3);
  font-size: 11px; font-weight: 600; min-height: var(--nav-h);
  background: none; border: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent; position: relative;
}
nav.tabs a svg, nav.tabs .mas svg { width: 23px; height: 23px; }
nav.tabs a.activo, nav.tabs .mas.activo { color: var(--acento-texto); }
nav.tabs a.activo::before, nav.tabs .mas.activo::before {
  content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--acento);
}

/* ---------- Navegación: barra lateral (escritorio) ---------- */
@media (min-width: 900px) {
  .layout.con-lateral { display: grid; grid-template-columns: var(--lateral-w) minmax(0, 1fr); }
  main { padding: 30px 36px 48px; }
  nav.tabs {
    position: sticky; top: 0; bottom: auto; height: 100vh; overflow-y: auto;
    flex-direction: column; border-top: 0; padding: 18px 14px 14px; gap: 2px;
    background: var(--lateral); color: var(--lateral-texto);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  nav.tabs .marca-lateral, nav.tabs .pie-lateral { display: flex; }
  nav.tabs .grupo { display: block; }
  nav.tabs a.solo-lateral { display: flex; }
  nav.tabs .solo-movil { display: none; }
  nav.tabs a {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 9px 12px; border-radius: var(--r-sm); font-size: 14px; font-weight: 550;
    min-height: 0; color: var(--lateral-texto); transition: background .12s, color .12s;
  }
  nav.tabs a svg { width: 19px; height: 19px; opacity: .85; }
  nav.tabs a:hover:not(.activo) { background: var(--lateral-2); color: var(--lateral-fuerte); }
  nav.tabs a.activo { background: var(--lateral-2); color: var(--lateral-fuerte); }
  nav.tabs a.activo svg { color: #7fb0ff; opacity: 1; }
  nav.tabs a.activo::before {
    top: 9px; bottom: 9px; left: -14px; right: auto; width: 3px; height: auto;
    border-radius: 0 3px 3px 0; background: #7fb0ff;
  }
}
.marca-lateral { align-items: center; gap: 11px; padding: 4px 8px 20px; }
.marca-lateral .logo {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 19px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}
.marca-lateral b { display: block; color: var(--lateral-fuerte); font-size: 15.5px; letter-spacing: -.01em; }
.marca-lateral span { display: block; font-size: 12px; color: var(--lateral-texto); }
nav.tabs .grupo {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--lateral-texto); opacity: .6; padding: 16px 12px 6px;
}
.pie-lateral {
  margin-top: auto; flex-direction: column; gap: 10px;
  border-top: 1px solid var(--lateral-borde); padding-top: 14px;
}
.usuario-lateral { display: flex; align-items: center; gap: 10px; padding: 2px 6px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--lateral-2); color: var(--lateral-fuerte); font-weight: 700; font-size: 14px;
  text-transform: uppercase;
}
.usuario-lateral .nombre { color: var(--lateral-fuerte); font-weight: 600; font-size: 13.5px; }
.usuario-lateral .rol { font-size: 12px; }
.acciones-lateral { display: flex; gap: 6px; }
.acciones-lateral button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px; border-radius: var(--r-xs); border: 1px solid var(--lateral-borde);
  background: transparent; color: var(--lateral-texto); font-size: 12.5px; font-weight: 550;
  cursor: pointer;
}
.acciones-lateral button:hover { background: var(--lateral-2); color: var(--lateral-fuerte); }
.acciones-lateral svg { width: 15px; height: 15px; }

/* Hoja "Más" del teléfono */
.hoja-mas { display: grid; gap: 8px; }
.hoja-mas a, .hoja-mas button {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 13px 12px; border-radius: var(--r-sm); border: 1px solid var(--borde);
  background: var(--surface); color: var(--texto); text-decoration: none;
  font-size: 15px; font-weight: 600; cursor: pointer; text-align: left;
}
.hoja-mas a:hover, .hoja-mas button:hover { background: var(--surface-2); }
.hoja-mas svg { width: 20px; height: 20px; color: var(--texto-2); flex: none; }
.hoja-mas .detalle { margin-left: auto; color: var(--texto-3); font-size: 13.5px; font-weight: 550; }
.hoja-mas .usuario { display: flex; align-items: center; gap: 11px; padding: 0 2px 8px; color: var(--texto-2); font-size: 13.5px; }
.hoja-mas .usuario .avatar { background: var(--acento-suave); color: var(--acento-texto); }
.hoja-mas .usuario b { color: var(--texto); display: block; font-size: 15px; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface); border: 1px solid var(--borde);
  border-radius: var(--r); box-shadow: var(--sombra);
  padding: 18px; margin-bottom: 16px;
}
.card > h2 { font-size: 15.5px; margin-bottom: 14px; }

/* KPIs */
/* 210px es lo que ocupa un importe como "$ 10.954.365,24": más angosto, se corta. */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 16px; }
@media (min-width: 900px) { .kpis.tres { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--borde);
  border-radius: var(--r); padding: 15px 16px 14px; box-shadow: var(--sombra);
}
.kpi .rotulo { font-size: 12.5px; color: var(--texto-2); font-weight: 600; }
.kpi .valor {
  font-size: 23px; font-weight: 720; margin-top: 6px; line-height: 1.15;
  letter-spacing: -.025em; font-variant-numeric: tabular-nums;
}
.kpi .pie { font-size: 12.5px; color: var(--texto-3); margin-top: 5px; }
/* El estado va en una franja y en el color del número; el pie lo dice en
   palabras, así nunca depende sólo del color. */
.kpi.positivo, .kpi.negativo { padding-left: 19px; }
.kpi.positivo::before, .kpi.negativo::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.kpi.positivo::before { background: var(--ok); }
.kpi.negativo::before { background: var(--error); }
.kpi.positivo .valor { color: var(--ok); }
.kpi.negativo .valor { color: var(--error); }
/* El número que se mira primero: ocupa el ancho y va más grande. */
.kpi.destacado { grid-column: 1 / -1; padding: 18px 20px 17px 23px; }
.kpi.destacado .valor { font-size: 34px; }

/* En el teléfono cada indicador es una fila: rótulo a la izquierda, importe a
   la derecha. En dos columnas los importes grandes no entran. */
@media (max-width: 560px) {
  .kpis { gap: 8px; grid-template-columns: 1fr; }
  .kpi:not(.destacado) {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: center;
    padding: 12px 14px;
  }
  .kpi.positivo:not(.destacado), .kpi.negativo:not(.destacado) { padding-left: 17px; }
  .kpi:not(.destacado) .rotulo { grid-column: 1; }
  .kpi:not(.destacado) .pie { grid-column: 1; margin-top: 1px; }
  .kpi:not(.destacado) .valor {
    grid-column: 2; grid-row: 1 / span 2; margin: 0; font-size: 19px; text-align: right; white-space: nowrap;
  }
}

/* ---------- Tablas que en el teléfono se vuelven tarjetas ---------- */
.tabla-envoltorio { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
th {
  text-align: left; font-size: 12px;
  color: var(--texto-2); font-weight: 650; padding: 10px 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--borde); white-space: nowrap;
}
th:first-child { border-top-left-radius: var(--r-xs); }
th:last-child { border-top-right-radius: var(--r-xs); }
td { padding: 12px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clicable { cursor: pointer; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 720px) {
  table, thead, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody tr {
    background: var(--surface); border: 1px solid var(--borde);
    border-radius: var(--r-sm);
    padding: 12px 14px; margin-bottom: 10px;
  }
  tbody tr:hover { background: var(--surface); }
  tbody tr.clicable:active { background: var(--surface-2); }
  td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
  td::before {
    content: attr(data-rotulo); color: var(--texto-3); font-size: 12.5px;
    font-weight: 600; flex-shrink: 0;
  }
  td.num { text-align: right; }
  td[data-rotulo=""]::before { display: none; }
  /* Lo destacado (cliente, nombre) encabeza la tarjeta aunque en la tabla vaya segundo. */
  tbody tr { display: flex; flex-direction: column; }
  td.destacada { order: -1; font-weight: 650; font-size: 15.5px; padding-bottom: 8px; }
  td.destacada::before { display: none; }
  /* Una lista ya es una pila de tarjetas: la tarjeta que la envuelve sobra. */
  .card:has(> .tabla-envoltorio) {
    background: transparent; border: 0; box-shadow: none; padding: 0 !important;
  }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 8px 15px; border-radius: var(--r-sm);
  border: 1px solid var(--borde-fuerte);
  background: var(--surface); color: var(--texto); font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--sombra);
  transition: background .12s, border-color .12s, box-shadow .12s, transform .06s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--anillo); }
.btn.primario { background: var(--acento); border-color: var(--acento); color: #fff; }
.btn.primario:hover { background: var(--acento-hover); border-color: var(--acento-hover); }
.btn.peligro { color: var(--error); border-color: color-mix(in srgb, var(--error) 45%, var(--borde)); background: var(--surface); }
.btn.peligro:hover { background: var(--error-suave); }
.btn.chico { min-height: 32px; padding: 5px 11px; font-size: 13px; border-radius: var(--r-xs); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn.chico svg { width: 15px; height: 15px; }

/* Solapas de una pantalla: control segmentado */
.segmentos {
  display: flex; gap: 2px; padding: 3px; margin: 4px 0 16px;
  background: var(--surface-3); border-radius: var(--r-sm);
  overflow-x: auto; scrollbar-width: none; max-width: 100%; width: fit-content;
}
.segmentos::-webkit-scrollbar { display: none; }
.segmentos button {
  flex: none; padding: 7px 14px; border-radius: var(--r-xs); border: 0;
  background: transparent; color: var(--texto-2); font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.segmentos button:hover { color: var(--texto); }
.segmentos button.activo { background: var(--surface); color: var(--texto); box-shadow: var(--sombra-media); }
.segmentos .cuenta {
  display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 6px;
  border-radius: 999px; background: var(--surface-2); color: var(--texto-2);
  font-size: 11.5px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums;
}
.segmentos button.activo .cuenta { background: var(--acento-suave); color: var(--acento-texto); }

/* Botón flotante en el teléfono */
.fab {
  position: fixed; right: 18px; z-index: 45;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--acento); color: #fff; border: 0;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--acento) 45%, transparent);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform .12s;
}
.fab:active { transform: scale(.95); }
.fab svg { width: 26px; height: 26px; }
@media (min-width: 900px) { .fab { display: none; } }
.solo-escritorio { display: none !important; }
@media (min-width: 900px) { .solo-escritorio { display: inline-flex !important; } }

/* ---------- Formularios ---------- */
.campos { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.campo { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.campo.ancho { grid-column: 1 / -1; }
.campo label { font-size: 13px; font-weight: 600; color: var(--texto-2); }
.campo input, .campo select, .campo textarea {
  min-height: 42px; padding: 9px 12px; border: 1px solid var(--borde-fuerte); border-radius: var(--r-sm);
  background-color: var(--surface); width: 100%; min-width: 0;
  transition: border-color .12s, box-shadow .12s;
}
.campo select {
  appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8aa0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.campo input:hover, .campo select:hover, .campo textarea:hover { border-color: var(--texto-3); }
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: 0; border-color: var(--acento); box-shadow: 0 0 0 3px var(--anillo);
}
.campo input[type="checkbox"], label input[type="checkbox"] { min-height: 0; accent-color: var(--acento); }
.campo .ayuda { font-size: 12.5px; color: var(--texto-3); }
.campo.error input, .campo.error select { border-color: var(--error); }
fieldset { border: 0; padding: 0; margin: 0; }

/* Filtros: una fila sobre el listado */
.filtros {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 16px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--borde); border-radius: var(--r);
  box-shadow: var(--sombra);
}
.filtros .campo { flex: 1 1 140px; }
.filtros .campo label { font-size: 12px; }
.filtros .campo input, .filtros .campo select { min-height: 38px; padding-top: 7px; padding-bottom: 7px; }
.filtros > .btn { min-height: 38px; }

/* ---------- Etiquetas de estado: punto + palabra, nunca sólo color ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; line-height: 1.4;
}
.tag.realizado, .tag.facturado, .tag.cobrado, .tag.anulado, .tag.vencido, .tag.pendiente,
.tag.en_custodia, .tag.acreditado, .tag.rechazado { padding-left: 8px; }
.tag.realizado::before, .tag.facturado::before, .tag.cobrado::before,
.tag.anulado::before, .tag.vencido::before, .tag.pendiente::before,
.tag.en_custodia::before, .tag.acreditado::before, .tag.rechazado::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none;
}
.tag.realizado { background: var(--surface-3); color: var(--texto-2); }
.tag.facturado { background: var(--alerta-suave); color: var(--alerta); }
.tag.cobrado { background: var(--ok-suave); color: var(--ok); }
.tag.anulado { background: var(--error-suave); color: var(--error); text-decoration: line-through; }
.tag.vencido { background: var(--error-suave); color: var(--error); }
.tag.pendiente { background: var(--alerta-suave); color: var(--alerta); }
.tag.en_custodia { background: var(--acento-suave); color: var(--acento-texto); }
.tag.acreditado { background: var(--ok-suave); color: var(--ok); }
.tag.rechazado { background: var(--error-suave); color: var(--error); }
.tag.plata { background: var(--surface-2); color: var(--texto-2); font-weight: 550; }

/* ---------- Modal ---------- */
.fondo-modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(8, 13, 24, .55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: aparecer .16s ease;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
@media (min-width: 700px) { .fondo-modal { align-items: center; padding: 24px; } }
.modal {
  display: flex; flex-direction: column;
  background: var(--surface); width: 100%; max-width: 620px; max-height: 94vh;
  border-radius: 20px 20px 0 0; box-shadow: var(--sombra-alta);
  animation: subir .22s cubic-bezier(.2, .8, .3, 1);
}
@media (min-width: 700px) { .modal { border-radius: 18px; max-height: 90vh; } }
/* Manija en el teléfono: dice "esto es una hoja que sube". */
.modal::before {
  content: ""; align-self: center; width: 38px; height: 4px; border-radius: 4px;
  background: var(--borde-fuerte); margin-top: 8px; flex: none;
}
@media (min-width: 700px) { .modal::before { display: none; } }
.modal-cabecera {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px 12px 20px; flex: none;
  border-bottom: 1px solid var(--borde);
}
.modal-cabecera h2 { font-size: 17.5px; margin-right: auto; }
.cerrar-modal {
  width: 34px; height: 34px; border-radius: 50%; border: 0; flex: none;
  display: grid; place-items: center; background: var(--surface-2); color: var(--texto-2); cursor: pointer;
}
.cerrar-modal:hover { background: var(--surface-3); color: var(--texto); }
.cerrar-modal svg { width: 17px; height: 17px; }
.modal form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-cuerpo { padding: 18px 20px 8px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.modal .acciones {
  display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; flex: none;
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--borde);
}
.modal .acciones .btn { flex: 1 1 auto; min-height: 46px; }
@media (min-width: 700px) {
  .modal .acciones { padding-bottom: 14px; }
  .modal .acciones .btn { flex: 0 0 auto; min-height: 40px; }
}
@keyframes aparecer { from { opacity: 0 } }
@keyframes subir { from { transform: translateY(24px); opacity: .4 } }

/* ---------- Avisos (toast) ---------- */
#toast-host {
  position: fixed; z-index: 80; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  display: flex; flex-direction: column; gap: 8px; width: max-content; max-width: 92vw;
}
.layout:not(.con-lateral) ~ #toast-host { bottom: calc(env(safe-area-inset-bottom) + 20px); }
@media (min-width: 900px) { #toast-host { bottom: 24px; left: auto; right: 24px; transform: none; } }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: #111a2b; color: #f1f5f9; padding: 11px 16px 11px 12px; border-radius: var(--r-sm);
  box-shadow: var(--sombra-alta); font-size: 14px; font-weight: 520; animation: subir .2s;
  border: 1px solid rgba(255, 255, 255, .06);
}
.toast .icono-toast {
  width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: rgba(255, 255, 255, .14); font-size: 13px; font-weight: 800;
}
.toast.ok .icono-toast { background: #16a34a; color: #fff; }
.toast.error .icono-toast { background: #dc2626; color: #fff; }

/* ---------- Varios ---------- */
.vacio { text-align: center; padding: 44px 20px; color: var(--texto-3); }
.vacio .icono {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center;
  font-size: 30px; background: var(--surface-2);
}
.vacio p { margin: 12px 0 18px; color: var(--texto-2); font-size: 14.5px; }
.error-caja {
  background: var(--error-suave); color: var(--error); padding: 11px 14px;
  border-radius: var(--r-sm); font-size: 13.5px; margin-bottom: 14px; font-weight: 520;
  border: 1px solid color-mix(in srgb, var(--error) 25%, transparent);
}
.fila { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.crece { flex: 1; }
.silencio { color: var(--texto-3); }
.positivo { color: var(--ok); }
.negativo { color: var(--error); }
hr.separador { border: 0; border-top: 1px solid var(--borde); margin: 18px 0; }

/* Totales de una lista */
.totales {
  display: flex; gap: 20px; flex-wrap: wrap; padding: 12px 15px;
  background: var(--surface-2); border-radius: var(--r-sm); margin-top: 12px;
  font-size: 13.5px; color: var(--texto-2);
}
.totales b { font-variant-numeric: tabular-nums; color: var(--texto); }

/* ---------- Barras (gastos por tipo en el resumen) ---------- */
/* Una sola serie: un solo color (--dato) y sin leyenda. Nombre, importe y
   porcentaje van escritos en tinta de texto; la barra sólo muestra la proporción. */
.barras { display: grid; gap: 2px; }
.barra {
  display: grid; grid-template-columns: minmax(96px, 150px) minmax(0, 1fr) auto; align-items: center;
  gap: 14px; padding: 8px; border-radius: var(--r-xs); font-size: 14px;
}
.barra:hover { background: var(--surface-2); }
.barra .nombre { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra .pista { height: 18px; }
.barra .relleno {
  height: 100%; min-width: 3px; max-width: 100%;
  background: var(--dato); border-radius: 0 4px 4px 0;
}
.barra .cifra { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.barra .cifra small { display: block; color: var(--texto-3); font-size: 12px; }
@media (max-width: 560px) {
  .barra { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; }
  .barra .pista { grid-column: 1 / -1; grid-row: 2; height: 12px; }
}

/* ---------- Login ---------- */
.login-pantalla {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 22px;
  background:
    radial-gradient(1000px 520px at 15% -10%, color-mix(in srgb, var(--acento) 16%, transparent), transparent 60%),
    radial-gradient(800px 480px at 110% 110%, color-mix(in srgb, var(--acento) 10%, transparent), transparent 60%),
    var(--bg);
}
.login-caja { width: 100%; max-width: 390px; }
.login-caja .marca { text-align: center; margin-bottom: 24px; }
.login-caja .marca .emoji {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 18px; display: grid; place-items: center;
  font-size: 32px; background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 10px 28px rgba(37, 99, 235, .35);
}
.login-caja .marca h1 { font-size: 27px; margin-top: 16px; }
.login-caja .marca p { color: var(--texto-2); margin: 4px 0 0; font-size: 14.5px; }
.login-caja .card { padding: 24px; box-shadow: var(--sombra-media); border-radius: 18px; }
.login-caja .btn.primario { min-height: 46px; font-size: 15px; }

/* ---------- Elegir de un toque (pantalla del chofer) ---------- */
/* Un <select> en el teléfono esconde las opciones detrás de un menú; acá se ven
   todas juntas y se elige tocando una sola vez. */
.opciones { display: grid; gap: 8px; grid-template-columns: 1fr; }
.opciones.grilla { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
/* En el teléfono nunca más de dos por fila: entran etiquetas como
   "Estacionamiento" sin partirse. */
@media (max-width: 560px) {
  .opciones.grilla { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.opcion {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: 56px;
  border: 1.5px solid var(--borde); border-radius: var(--r-sm);
  background: var(--surface); cursor: pointer;
  transition: border-color .12s, background .12s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
}
.opciones.grilla .opcion {
  flex-direction: column; justify-content: center; gap: 6px;
  padding: 14px 4px; text-align: center;
}
.opcion input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.opcion .emoji { font-size: 25px; line-height: 1; }
.opcion .texto { min-width: 0; }
.opcion .titulo { display: block; font-weight: 650; font-size: 14px; }
.opcion .pie { display: block; font-size: 12px; color: var(--texto-3); margin-top: 1px; }
.opcion:hover { border-color: var(--borde-fuerte); }
.opcion.elegida { border-color: var(--acento); background: var(--acento-suave); box-shadow: 0 0 0 1px var(--acento); }
.opcion.elegida .titulo { color: var(--acento-texto); }
.opcion:focus-within { box-shadow: 0 0 0 3px var(--anillo); }

/* Importe: es el dato que más se mira y el que más se equivoca. */
.campo-monto { position: relative; }
.campo-monto .signo {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 23px; font-weight: 600; color: var(--texto-3); pointer-events: none;
}
.campo .campo-monto input {
  padding: 14px 13px 14px 36px; font-size: 27px; font-weight: 720;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.campo-monto input::-webkit-outer-spin-button,
.campo-monto input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Atajos de fecha: casi siempre es hoy. */
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 9px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 650;
  border: 1.5px solid var(--borde); background: var(--surface); color: var(--texto-2);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.chip.elegido { border-color: var(--acento); background: var(--acento-suave); color: var(--acento-texto); }

/* Foto del ticket: un <input type=file> crudo no se entiende. */
.zona-foto {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  padding: 14px; border: 1.5px dashed var(--borde-fuerte); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--texto-2); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.zona-foto:hover { border-color: var(--acento); }
.zona-foto .marca {
  display: grid; place-items: center; flex: none; width: 48px; height: 48px;
  border-radius: 12px; background: var(--surface);
}
.zona-foto svg { width: 24px; height: 24px; flex: none; color: var(--acento-texto); }
.zona-foto img { width: 48px; height: 48px; flex: none; object-fit: cover; border-radius: 12px; }
.zona-foto .titulo { display: block; font-weight: 650; font-size: 14.5px; color: var(--texto); }
.zona-foto .pie { display: block; font-size: 12.5px; margin-top: 1px; }
.zona-foto.cargada { border-style: solid; border-color: var(--ok); background: var(--ok-suave); }
.zona-foto.cargada svg, .zona-foto.cargada .titulo, .zona-foto.cargada .pie { color: var(--ok); }

/* Resultado de la lectura automática del ticket, debajo de la foto. */
.lectura { margin-top: 8px; font-size: 13px; color: var(--texto-2); }
.lectura:empty { display: none; }
.lectura.aviso { color: var(--alerta); }
.completado { box-shadow: 0 0 0 3px var(--ok-suave); }

/* Campos que sólo aplican a veces (litros, odómetro): agrupados y con rótulo. */
.subbloque {
  grid-column: 1 / -1; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  padding: 13px 14px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--borde);
}
.subbloque > .rotulo { grid-column: 1 / -1; font-size: 12.5px; font-weight: 700; color: var(--texto-2); }

/* ---------- Lista de gastos del chofer ---------- */
.dia + .dia { margin-top: 6px; }
.dia-rotulo {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 12px 10px 7px; font-size: 12.5px; font-weight: 700; color: var(--texto-2);
}
.dia-rotulo b { color: var(--texto); font-variant-numeric: tabular-nums; }
.gasto { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-top: 1px solid var(--borde); }
.gasto .icono {
  width: 42px; height: 42px; border-radius: 12px; flex: none; display: grid; place-items: center;
  font-size: 21px; line-height: 1; background: var(--surface-2);
}
.gasto .centro { flex: 1; min-width: 0; }
.gasto .centro .titulo { font-weight: 650; }
.gasto .centro .meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--texto-3); margin-top: 3px;
}
/* Con el importe y los botones al lado queda poco ancho: la etiqueta puede
   partirse en dos líneas, pero nunca cortarse. */
.gasto .centro .meta .tag { white-space: normal; }
.gasto .derecha { text-align: right; }
.gasto .derecha .importe { font-weight: 720; font-variant-numeric: tabular-nums; }
.gasto .derecha .litros { font-size: 12px; color: var(--texto-3); }
.gasto .acciones-gasto { display: flex; gap: 6px; flex: none; }
.gasto .btn.chico { min-width: 38px; min-height: 36px; padding: 6px 8px; box-shadow: none; }
@media (max-width: 560px) {
  .gasto { gap: 10px; padding: 11px 4px; }
  .gasto .icono { width: 36px; height: 36px; font-size: 18px; border-radius: 10px; }
  .gasto .acciones-gasto { flex-direction: column; gap: 5px; }
  .gasto .btn.chico { min-width: 34px; min-height: 30px; padding: 4px 6px; }
}
