/* Estilos base tomados del CRM Síguelo Gestión (soporte-wialon/public/app.css) para mantener la misma apariencia.
   Lo propio de On Route está al final («Síguelo On Route»). */
:root {
  --ink: #15181D;
  --ink-2: #3A414C;
  --muted: #5B6370;
  --line: #E2E5EA;
  --line-2: #EEF0F3;
  --bg: #F4F5F7;
  --card: #FFFFFF;
  --soft: #F7F8FA;
  --marca: #FFD500;
  --marca-ambar: #FFBF00;
  --marca-naranjo: #FFAA00;
  --marca-suave: #FFF7CC;
  --marca-texto: #6B4A00;
  --amber-ink: #8A3B06;
  --amber-soft: #FEF3E2;
  --red: #B42318;
  --red-soft: #FDECEA;
  --green: #1E7B3A;
  --green-soft: #E6F4EA;
  --blue: #1E3A8A;
  --blue-soft: #E8EEFC;
  --purple: #581C87;
  --purple-soft: #F3E8FF;
  --teal: #0F5F58;
  --teal-soft: #DDF3F0;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --c-v0: #B42318;
  --c-vlow: #D97706;
  --c-com: #1D4ED8;
  --c-gps: #7E22CE;
  --c-unk: #6B7280;
  --c-sim: #0F766E;
  --menu: 236px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); min-height: 100vh; }
a { color: var(--ink); text-decoration-color: var(--marca-naranjo); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: #000; text-decoration-color: var(--ink); }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3, h4, p { margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.peq { font-size: 12px; }
.b { font-weight: 600; }
[hidden] { display: none !important; }
.oculto { display: none !important; }

/* ── Estructura: menú lateral plegable + contenido ── */
.app { display: grid; grid-template-columns: var(--menu) minmax(0, 1fr); min-height: 100vh; }
.app.plegada { --menu: 64px; }
.menu { background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.menu > * { flex-shrink: 0; } /* con muchos módulos el menú se desplaza: los títulos de grupo no se aplastan */
.menu-marca { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 6px 14px; }
.menu-marca img { height: 32px; width: auto; display: block; }
.menu-marca .marca-pin { display: none; }
.plegada .menu-marca .logo { display: none; }
.plegada .menu-marca .marca-pin { display: block; height: 34px; }
.plegada .menu-marca { flex-direction: column; gap: 10px; padding-bottom: 10px; }
.menu-grupo { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 12px 10px 4px; white-space: nowrap; overflow: hidden; }
.plegada .menu-grupo { height: 8px; padding: 0; margin: 6px 0; border-top: 1px solid var(--line-2); font-size: 0; }
.menu a.item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; white-space: nowrap; }
.menu a.item:hover { background: var(--soft); color: var(--ink); }
.menu a.item[aria-current="page"] { background: var(--marca); color: var(--ink); font-weight: 600; }
.menu a.item svg { flex-shrink: 0; }
.plegada .menu a.item span { display: none; }
.plegada .menu a.item { justify-content: center; padding: 0; }
.menu-pie { margin-top: auto; padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.menu-usuario { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: var(--soft); border: 0; width: 100%; text-align: left; cursor: pointer; }
.menu-usuario .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: var(--marca); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; flex-shrink: 0; }
.menu-usuario div { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.menu-usuario b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-usuario span { font-size: 12px; color: var(--muted); }
.plegada .menu-usuario div { display: none; }
.plegada .menu-usuario { justify-content: center; padding: 6px 0; }
.btn-plegar { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); flex-shrink: 0; }
.plegada .menu-marca { justify-content: center; }

.principal { display: flex; flex-direction: column; min-width: 0; }
.barra { height: 60px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 0 20px; position: sticky; top: 0; z-index: 50; }
.barra .titulo { font-size: 16px; font-weight: 600; white-space: nowrap; }
.buscar { flex: 1; max-width: 520px; position: relative; }
.buscar input { width: 100%; min-height: 38px; padding: 0 12px 0 36px; border-radius: 8px; border: 1px solid #D0D5DD; background: var(--soft); }
.buscar svg { position: absolute; left: 11px; top: 11px; color: var(--muted); }
.buscar-res { position: absolute; top: 44px; left: 0; right: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(20,24,30,.14); max-height: 420px; overflow: auto; z-index: 60; }
.buscar-res a { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); text-decoration: none; }
.buscar-res a:hover { background: var(--soft); }
.buscar-res a small { color: var(--muted); }
.buscar-res .tipo { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--marca-texto); }
.barra .acciones { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.barra .btn-menu-movil { display: none; } /* solo en celular (abre el menú); en escritorio el menú se pliega con su propio botón */
.contenido { padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 18px; }

/* ── Botones y controles ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid #D0D5DD; background: var(--card); font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--soft); color: var(--ink); }
.btn.primario { background: var(--marca); border-color: var(--marca-ambar); color: var(--ink); font-weight: 600; }
.btn.primario:hover { background: var(--marca-ambar); }
.btn.oscuro { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.oscuro:hover { background: #000; color: #fff; }
.btn.contorno { border: 1.5px solid var(--ink); font-weight: 600; }
.btn.peligro { color: var(--red); border-color: #F2C9C4; }
.btn.peligro:hover { background: var(--red-soft); }
.btn.peq { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.grande { min-height: 46px; padding: 0 18px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-icono { width: 36px; height: 36px; border-radius: 8px; border: 1px solid #D0D5DD; background: var(--card); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); }
.btn-icono:hover { background: var(--soft); }
.campo { min-height: 38px; padding: 0 10px; border-radius: 8px; border: 1px solid #D0D5DD; background: var(--card); font-size: 14px; max-width: 100%; }
textarea.campo { padding: 8px 10px; min-height: 76px; resize: vertical; width: 100%; }
select.campo { padding-right: 28px; }
.campo:disabled { background: var(--soft); color: var(--muted); }
.campos { display: flex; flex-wrap: wrap; gap: 12px 20px; }
.campos label, .etiqueta { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); min-width: 0; }
.campos label > .campo, .etiqueta > .campo { color: var(--ink); }
.campos label.ancho, .etiqueta.ancho { flex: 1 1 100%; }
.segmentado { display: inline-flex; background: #E6E8EC; border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmentado button { min-height: 34px; padding: 0 12px; border-radius: 8px; border: 0; background: transparent; color: var(--ink-2); font: 500 13px/1 var(--sans); cursor: pointer; }
.segmentado button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(20,24,30,.15); }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 13px; background: #C4C9D1; transition: background .15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::after { left: 21px; background: var(--marca); }
.switch input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ── Chips, estados, tarjetas ── */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.chip.ok, .chip.ins { background: var(--green-soft); color: #14532D; }
.chip.rev, .chip.info, .chip.sim { background: var(--blue-soft); color: var(--blue); }
.chip.man, .chip.aviso { background: var(--amber-soft); color: #7C2D12; }
.chip.aviso, .chip.error { padding: 2px 8px; border-radius: 999px; font-size: 12px; } /* «aviso» y «error» también son clases de bloque */
.chip.des { background: var(--purple-soft); color: var(--purple); }
.chip.error, .chip.baja, .chip.norep { background: var(--red-soft); color: #8F1B12; }
.chip.marca { background: var(--marca-suave); color: var(--marca-texto); }
.chip.teal { background: var(--teal-soft); color: var(--teal); }
.chip.sin { background: transparent; color: var(--muted); padding-left: 0; }
.pat { font-family: var(--mono); font-weight: 600; font-size: 12px; letter-spacing: .03em; background: #fff; border: 1.5px solid var(--ink); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.pat.grande { font-size: 24px; letter-spacing: .04em; padding: 2px 12px; border-width: 2px; border-radius: 6px; }
.dias { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 6px; font: 600 13px/1 var(--mono); white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.dias.d7 { background: var(--amber-soft); color: #B45309; }
.dias.d15 { background: var(--red-soft); color: var(--red); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.avatar-peq { width: 26px; height: 26px; border-radius: 50%; background: var(--line-2); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.tarjeta { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.tarjeta.pad { padding: 18px 20px; }
.bloque { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.bloque h2 { font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bloque h2 .num { font: 600 13px/1 var(--mono); background: var(--marca); border-radius: 6px; padding: 4px 7px; margin-right: 6px; }
.bloque p.ayuda, .ayuda { font-size: 13px; color: var(--muted); }
.aviso { padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.aviso.error { background: var(--red-soft); color: #7A1A12; }
.aviso.info { background: var(--amber-soft); color: var(--amber-ink); }
.aviso.ok { background: var(--green-soft); color: #14532D; }
.aviso.neutro { background: var(--soft); border: 1px solid var(--line); color: var(--ink-2); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi b { font-size: 30px; font-weight: 600; line-height: 1.1; }
.kpi small { font-size: 12px; color: var(--muted); }
.kpi small.mal { color: var(--red); font-weight: 500; }
.pagina-cab { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; }
.pagina-cab h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.pagina-cab p { font-size: 14px; color: var(--muted); margin-top: 2px; }
.pagina-cab .acciones { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.pagina-cab > div:first-child { min-width: 0; }
.columnas { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.columnas-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.columnas-3 { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr) minmax(0, 320px); gap: 18px; align-items: start; }
.filtros-fila { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filtro { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid #D0D5DD; background: var(--card); font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink); }
.filtro[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.filtro .n { font: 600 11px/1 var(--mono); padding: 3px 6px; border-radius: 6px; background: rgba(0,0,0,.08); }
.filtro[aria-pressed="true"] .n { background: rgba(255,255,255,.2); }

/* ── Tablas y listas ── */
.tabla { width: 100%; border-collapse: collapse; }
.tabla th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--soft); white-space: nowrap; }
.tabla td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; font-size: 13px; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tr.clic { cursor: pointer; }
.tabla tr.clic:hover td { background: var(--soft); }
.tabla tr[aria-selected="true"] td { background: var(--marca-suave); }
.tabla-env { overflow: auto; border-radius: 12px; }
/* Tablas junto a un panel de detalle (Pedidos, Estados de pago): con el menú abierto a 1280 px no cabían con el relleno
   normal y la columna Estado quedaba cortada (la barra de desplazamiento horizontal queda al final de la lista y no se ve). */
.columnas .tabla th, .columnas .tabla td { padding-left: 8px; padding-right: 8px; }
.columnas .tabla .barra-progreso { min-width: 56px; }
/* Botones de acción de una fila: pasan a otra línea en vez de ensanchar la tabla (Empresas del panel de la plataforma) */
.acciones-fila { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.lista-items { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line-2); background: var(--card); cursor: pointer; font: inherit; color: inherit; }
.item:hover { background: var(--soft); }
.item[aria-pressed="true"], .item.sel { background: var(--marca-suave); box-shadow: inset 4px 0 0 var(--marca); }
.item-txt { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.item-txt b { font-size: 14px; }
.item-txt span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.item-der { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.dato { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dato span:first-child { font-size: 12px; color: var(--muted); }
.dato .v { font-weight: 500; overflow-wrap: anywhere; }
.dato .v.mal { color: var(--red); }
.rejilla-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.rejilla-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.rejilla-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.historial { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.historial li { display: flex; gap: 10px; align-items: flex-start; }
.historial .marca-ev { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; background: var(--marca-naranjo); }
.historial .marca-ev.persona { background: var(--ink); }
.historial .marca-ev.error { background: var(--red); }
.historial .marca-ev.regla { background: var(--c-com); }
.historial small { display: block; font-size: 12px; color: var(--muted); }
.historial p { font-size: 13px; line-height: 1.45; }
.sec { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.sec + .sec { border-top: 1px solid var(--line); }
.sec h3 { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.sec h3.grande { font-size: 15px; color: var(--ink); }
.vacio { padding: 24px 16px; text-align: center; color: var(--muted); }

/* ── Kanban ── */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: #ECEEF1; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.col.sobre { outline: 2px dashed var(--marca-ambar); }
.col-cab { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 6px; font-weight: 600; font-size: 14px; }
.col-cab span { color: var(--muted); font-weight: 500; font-size: 13px; }
.ficha { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 7px; cursor: pointer; text-decoration: none; color: inherit; }
.ficha:hover { border-color: #B8BEC7; }
.ficha.arrastrando { opacity: .5; }
.ficha .fila { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ficha .pie { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line-2); padding-top: 8px; font-size: 12px; color: var(--muted); }
.ficha b { font-weight: 500; font-size: 14px; }

/* ── Modal ── */
.modal-fondo { position: fixed; inset: 0; background: rgba(21,24,29,.5); z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; }
.modal { background: var(--card); border-radius: 14px; width: min(720px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; max-height: calc(100vh - 80px); }
.modal.ancho { width: min(980px, 100%); }
.modal-cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-cab h2 { font-size: 17px; font-weight: 600; }
.modal-cuerpo { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.modal-pie { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000; max-width: min(560px, calc(100vw - 32px)); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.error { background: #7A1A12; }
.toast.ok { background: #14532D; }
.toast.toast-deshacer { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.toast-deshacer .toast-txt { flex: 1; min-width: 0; }
.toast-deshacer .toast-cuenta { font: 12px var(--mono); color: #AEB4BE; }
.toast-deshacer .toast-btn { background: transparent; border: 0; color: var(--marca); font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.toast-deshacer .toast-btn:hover { background: rgba(255,255,255,.08); }

/* ── Gráficos simples ── */
.barras-v { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; align-items: end; height: 180px; border-bottom: 1px solid #D0D5DD; }
.barras-v .barra { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; font-size: 12px; color: var(--ink-2); }
.barras-v .barra i { display: block; width: 100%; background: #2F5BD3; border-radius: 4px 4px 0 0; }
.barras-pie { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; font-size: 11px; color: var(--muted); text-align: center; }
.barra-h { display: grid; grid-template-columns: 180px minmax(0, 1fr) 44px; gap: 10px; align-items: center; font-size: 13px; }
.barra-h i { display: block; height: 14px; background: #2F5BD3; border-radius: 0 4px 4px 0; min-width: 2px; }
.barra-h .n { text-align: right; color: var(--ink-2); }
.barras { display: flex; align-items: flex-end; gap: 4px; height: 70px; border-bottom: 1px solid #D0D5DD; padding-bottom: 1px; }
.barras .barra { flex: 1; border-radius: 3px 3px 0 0; background: #9AA3AF; min-height: 3px; }
.barras .barra.vacia { height: 6px !important; background: #DADDE3; }
.barras .barra.cero { background: var(--red); }

/* ── Responsive (CRM) ── */
@media (max-width: 1180px) {
  .columnas, .columnas-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app.plegada { --menu: 236px; }
  .menu { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 950; transform: translateX(-100%); transition: transform .15s; box-shadow: 8px 0 24px rgba(0,0,0,.18); }
  .app.menu-abierto .menu { transform: none; }
  .plegada .menu a.item span, .plegada .menu-usuario div, .plegada .menu-marca .logo { display: initial; }
  .plegada .menu-marca { flex-direction: row; }
  .plegada .menu a.item { justify-content: flex-start; padding: 0 10px; }
  .plegada .menu-grupo { height: auto; padding: 12px 10px 4px; font-size: 11px; border: 0; }
  .btn-plegar { display: none; }
  .barra .btn-menu-movil { display: inline-flex; }
  .menu-marca .marca-pin, .plegada .menu-marca .marca-pin { display: none; }
  .barra { padding: 0 12px; }
  .barra .titulo { display: none; }
  .contenido { padding: 14px 12px 40px; }
  .columnas-2, .rejilla-3, .rejilla-4 { grid-template-columns: minmax(0, 1fr); }
  .rejilla-2 { grid-template-columns: minmax(0, 1fr); }
  .kanban { grid-auto-columns: minmax(230px, 80vw); }
  .modal-fondo { padding: 12px; }
}

/* ════════════════ Piezas de despacho (heredadas de On Mix) ════════════════ */
.reloj { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border-radius: 8px; background: var(--osc); color: #fff; font: 600 14px/1 var(--mono); white-space: nowrap; }
.reloj small { font: 500 11px/1 var(--sans); color: var(--marca); text-transform: uppercase; letter-spacing: .05em; }
.campana { position: relative; }
.campana .n { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font: 600 11px/18px var(--mono); text-align: center; }
.menu a.item .n { margin-left: auto; font: 600 11px/1 var(--mono); padding: 3px 6px; border-radius: 6px; background: var(--red); color: #fff; }
.plegada .menu a.item .n { display: none; }
.est { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 8px 2px 6px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.est i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.barra-progreso { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; min-width: 80px; }
.barra-progreso i { display: block; height: 100%; background: var(--green); border-radius: 4px; }


.tip { position: fixed; z-index: 3000; background: var(--osc); color: #fff; padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.45; pointer-events: none; max-width: 280px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.tip b { color: var(--marca); }



/* Mapa */
.mapa-env { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 0; height: calc(100vh - 60px - 120px); min-height: 460px; overflow: hidden; }
.mapa-caja { position: relative; min-height: 0; }
#mapa { position: absolute; inset: 0; }
.mapa-lado { border-left: 1px solid var(--line); overflow: auto; display: flex; flex-direction: column; }
.mapa-lado .item { padding: 10px 14px; }
.marcador { width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; color: #fff; }
.marcador svg { width: 16px; height: 16px; }
.marcador-eti { position: absolute; left: 34px; top: 6px; white-space: nowrap; font: 600 11px/1 var(--mono); background: #fff; border: 1.5px solid var(--ink); border-radius: 4px; padding: 2px 4px; color: var(--ink); }
.leaflet-container { font: 13px/1.4 var(--sans); }
.mapa-leyenda { position: absolute; z-index: 500; left: 12px; bottom: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; box-shadow: 0 4px 12px rgba(0,0,0,.12); }


@media (max-width: 1180px) {
  .mapa-env { grid-template-columns: minmax(0, 1fr); height: auto; }
  .mapa-caja { height: 460px; }
  .mapa-lado { border-left: 0; border-top: 1px solid var(--line); max-height: 360px; }
}
@media (max-width: 860px) {
  .reloj small { display: none; }
}

/* ── Aviso de modo demostración ── */
.aviso-modo { background: var(--amber-soft); color: var(--amber-ink); font-size: 13px; padding: 8px 24px; border-bottom: 1px solid var(--line); }
.aviso-modo a { color: inherit; font-weight: 600; }
.aviso-modo.soporte { background: var(--blue-soft); color: var(--blue); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Configuración ── */
.pasos { display: flex; flex-direction: column; gap: 2px; }
.paso { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.paso:last-child { border-bottom: 0; }
.paso .marca { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 600 12px/1 var(--mono); background: var(--soft); border: 1px solid var(--line); flex-shrink: 0; }
.paso.hecho .marca { background: var(--green-soft); border-color: transparent; color: var(--tx-verde); }
.paso .txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.paso .txt span { font-size: 13px; color: var(--muted); }
.lista-chequeo { max-height: 420px; overflow: auto; }
.lista-chequeo td:first-child, .lista-chequeo th:first-child { width: 36px; }

/* ── Editor de geocercas ── */
.geo-env { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: calc(100vh - 60px - 120px); min-height: 520px; overflow: hidden; }
.geo-lado { border-right: 1px solid var(--line); overflow: auto; display: flex; flex-direction: column; }
.geo-lado .item { padding: 10px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; display: flex; gap: 10px; align-items: center; }
.geo-lado .item:hover { background: var(--soft); }
.geo-lado .item[aria-selected="true"] { background: var(--marca-suave); }
.geo-lado .item .txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.geo-lado .item .txt span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.geo-lado .grupo { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 14px 14px 6px; display: flex; justify-content: space-between; align-items: center; }
.geo-form { padding: 14px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); background: var(--soft); }
.geo-mapa { position: relative; min-height: 0; }
.geo-mapa #mapa-geo { position: absolute; inset: 0; }
.geo-mapa.marcando #mapa-geo { cursor: crosshair; }
.geo-pista { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 500; background: var(--osc); color: #fff; font-size: 13px; padding: 8px 14px; border-radius: 999px; pointer-events: none; }
.geo-buscar { position: absolute; top: 12px; right: 12px; z-index: 500; width: min(340px, calc(100% - 24px)); }
.geo-buscar .buscar-res { top: 42px; }
@media (max-width: 900px) {
  .geo-env { grid-template-columns: minmax(0, 1fr); height: auto; }
  .geo-mapa { height: 460px; order: -1; }
  .geo-lado { border-right: 0; border-top: 1px solid var(--line); max-height: none; }
  .aviso-modo { padding: 8px 16px; }
}

/* ── Bitácora y acciones manuales ── */
.bitacora { list-style: none; display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; }
.bitacora li { display: grid; grid-template-columns: 48px 1fr; gap: 8px; }
.chip.manual { background: var(--blue-soft); color: var(--blue, #1D4ED8); font-size: 10px; padding: 1px 6px; }

/* ── Ingreso ── */
.pantalla-entrar { display: flex; align-items: center; justify-content: center; padding: 16px; min-height: 100vh; }
.caja-entrar { width: min(400px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.menu-usuario { cursor: pointer; border: 0; background: transparent; text-align: left; width: 100%; font: inherit; color: inherit; }
.menu-usuario:hover { background: var(--soft); }
.modal-pie.separado { justify-content: space-between; }
.modal-pie .btn svg { flex-shrink: 0; }
.campo-clave { position: relative; display: flex; }
.campo-clave .campo { flex: 1; padding-right: 44px; color: var(--ink); }
.ver-clave { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; }
.ver-clave:hover { background: var(--soft); }

html[data-solo-lectura] .solo-operar { display: none !important; }

/* ── Barras por día (reportes) ── */
.barras-dia { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; height: 220px; }
.barras-eje { display: flex; flex-direction: column; justify-content: space-between; font: 11px/1 var(--mono); color: var(--muted); text-align: right; padding-bottom: 20px; margin-top: -5px; }
.barras-area { display: flex; flex-direction: column; min-width: 0; }
.barras-plot { flex: 1; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--line); background: linear-gradient(var(--line-2) 1px, transparent 1px) 0 0 / 100% 50%; }
.barra-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; cursor: default; }
.barra-col i { display: block; background: #2A62D9; border-radius: 4px 4px 0 0; }
.barra-col:hover i { background: #1D4ED8; }
.barras-fechas { display: flex; gap: 2px; height: 20px; align-items: flex-end; }
.barras-fechas small { flex: 1 1 0; min-width: 0; font: 10px/1 var(--mono); color: var(--muted); white-space: nowrap; overflow: visible; }


/* ════════════════ Síguelo On Route ════════════════
   Medidas y colores de la maqueta aprobada (Planificar, Despacho en vivo): menú de 220 px con el logo y la pastilla
   «On Route», sin barra superior en escritorio, títulos de 22 px y botones de 38 px. */
.app { --menu: 220px; }
.menu { padding: 14px 10px; }
.menu-marca { justify-content: flex-start; gap: 8px; padding: 4px 6px 18px; }
.menu-marca img { height: 28px; }
.pastilla { background: var(--ink); color: var(--marca); font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 6px; white-space: nowrap; }
.menu a.item { min-height: 0; padding: 9px 10px; color: var(--ink); font-weight: 400; gap: 0; border: 0; width: auto; background: none; }
.menu a.item:hover { background: var(--soft); }
.menu a.item[aria-current="page"] { background: var(--marca); }
.menu a.item[aria-current="page"] { font-weight: 600; }
.menu-grupo { padding: 18px 10px 4px; }
.menu-pie .reloj { align-self: flex-start; margin: 0 4px 2px; }
.barra { display: none; }
.contenido { padding: 22px 26px 40px; gap: 14px; }
.pagina-cab { gap: 12px; }
.pagina-cab h1 { font-size: 22px; letter-spacing: 0; }
.pagina-cab .acciones .btn, .pagina-cab > .btn { min-height: 38px; }
.btn.oscuro { font-weight: 600; }
.chip.temp { font-weight: 600; padding: 3px 9px; }
.chip.temp:not(.ok):not(.error):not(.aviso) { background: var(--bg); color: var(--ink-2); }
@media (max-width: 860px) {
  .barra { display: flex; height: 52px; }
  .barra .titulo { display: inline; }
  .contenido { padding: 14px 12px 40px; }
}

/* ── Planificar el día ── */
.plan-env { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 14px; height: calc(100vh - 128px); min-height: 560px; }
.plan-mapa { position: relative; background: #E9ECEF; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.plan-mapa #mapa { position: absolute; inset: 0; }
.plan-leyenda { position: absolute; left: 14px; bottom: 14px; z-index: 500; background: #fff; border-radius: 10px; padding: 8px 12px; font-size: 12px; color: var(--ink-2); box-shadow: 0 4px 12px rgba(21,24,29,.12); }
.plan-lado { display: flex; flex-direction: column; gap: 10px; overflow: auto; min-height: 0; padding-right: 2px; }
.ruta-t { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.ruta-t.sobre, .sin-asignar.sobre { outline: 2px dashed var(--marca-ambar); outline-offset: -2px; }
.ruta-t.sel { box-shadow: 0 0 0 2px var(--c); border-color: transparent; }
.ruta-cab { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ruta-color { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex-shrink: 0; }
.ruta-cab > b { flex-grow: 1; white-space: nowrap; cursor: pointer; }
.ruta-cab .pat { font-size: 13px; border-radius: 5px; }
.ruta-cab .conductor { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.ruta-cab select.conductor { min-height: 28px; border: 0; background: transparent; color: var(--muted); padding: 0 2px; cursor: pointer; text-align: right; }
.ruta-cab .btn-icono { width: 28px; height: 28px; border: 0; }
.ruta-num { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; font-size: 12px; color: var(--muted); }
.ruta-num b { display: block; font-size: 15px; color: var(--ink); font-weight: 600; }
.carga { height: 6px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.carga i { display: block; height: 100%; background: var(--c); border-radius: 999px; }
.carga.exceso i { background: var(--red); }
.ruta-aviso { font-size: 12px; color: var(--amber-ink); background: var(--amber-soft); border-radius: 8px; padding: 6px 10px; }
.ruta-estado { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.paradas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line-2); }
.paradas li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 2px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.paradas li[draggable="true"] { cursor: grab; }
.paradas li.arrastrando { opacity: .4; }
.paradas li.fuera .hora { color: var(--amber-ink); font-weight: 600; }
.paradas .txt { min-width: 0; display: flex; flex-direction: column; }
.paradas .txt b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paradas .txt small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paradas .hora { font: 500 12px/1 var(--mono); color: var(--ink-2); text-align: right; }
.parada-n { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--c, var(--ink)); background: #fff; display: grid; place-items: center; font: 600 10px/1 var(--mono); color: var(--ink); }
.sin-asignar { background: var(--card); border: 1px dashed var(--borde-campo); border-radius: 12px; padding: 12px 16px; color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.ficha-pedido { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: var(--ink); cursor: grab; }
.ficha-pedido small { color: var(--muted); grid-column: 1 / -1; font-size: 12px; }
.ficha-pedido .motivo { color: var(--amber-ink); }
.ficha-pedido.arrastrando { opacity: .4; }
.mk-cd { width: 32px; height: 32px; border-radius: 8px; background: var(--ink); color: var(--marca); font: 700 13px/32px var(--sans); text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.mk-parada { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--c); display: grid; place-items: center; font: 700 10px/1 var(--mono); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.mk-parada.hecha { background: var(--c); color: #fff; }
.mk-parada.libre { border-style: dashed; border-color: #6B7280; }
.mk-camion { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); border: 3px solid var(--c); display: grid; place-items: center; color: var(--marca); box-shadow: 0 2px 6px rgba(0,0,0,.35); }
@media (max-width: 1180px) {
  .plan-env { grid-template-columns: minmax(0, 1fr); height: auto; }
  .plan-mapa { height: 460px; }
}

/* ── Despacho en vivo ── */
.kpis-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi-t { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.kpi-t span { display: block; color: var(--muted); font-size: 13px; }
.kpi-t b { display: block; font-size: 24px; font-weight: 700; line-height: 1.3; }
.kpi-t b.ambar { color: var(--amber-ink); }
.kpi-t.alerta { background: var(--red-soft); border-color: #F5C2BC; }
.kpi-t.alerta span { color: var(--tx-rojo); }
.kpi-t.alerta b { color: var(--red); }
.tabla.despacho th { padding: 10px 16px; }
.tabla.despacho td { padding: 12px 16px; font-size: 14px; }
.tabla.despacho tr.alerta td { background: var(--bg-rojo-tenue); }
.tabla.despacho tr.sel td:first-child { box-shadow: inset 4px 0 0 var(--c); }
.tabla.despacho td.llega { font-family: var(--mono); white-space: nowrap; }
.tabla.despacho td.llega small { font-family: var(--sans); color: var(--muted); }
.titulo-dia { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.titulo-dia .segmentado button { min-height: 28px; padding: 0 10px; }
.avance { width: 140px; height: 6px; background: var(--line-2); border-radius: 999px; overflow: hidden; margin-bottom: 4px; }
.avance i { display: block; height: 100%; background: var(--c); border-radius: 999px; }
.atrasada { color: var(--amber-ink); }
.curva-t { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.curva-t .cab { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.curva-t .cab b { flex-grow: 1; }
.grafico-temp { width: 100%; display: block; overflow: visible; }
.grafico-temp text { font-family: var(--sans); }
@media (max-width: 1000px) { .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ── Importar pedidos ── */
.soltar { border: 2px dashed var(--borde-campo); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); background: var(--soft); cursor: pointer; }
.soltar.sobre { border-color: var(--marca-ambar); background: var(--marca-suave); }
.errores-imp { max-height: 240px; overflow: auto; }
.columnas-plantilla td:first-child { font-family: var(--mono); font-size: 12px; white-space: nowrap; }

/* ── Comprobante en la intranet ── */
.foto-pod { width: 100%; max-height: 260px; object-fit: contain; background: var(--soft); border-radius: 10px; border: 1px solid var(--line); }
.plan-mapa.marcando #mapa { cursor: crosshair; }

/* Colores que antes iban fijos en las hojas propias y en los estilos en línea: ahora son tokens con el MISMO valor en
   claro (nada cambia en claro) y su versión oscura más abajo. --osc es la superficie oscura fija (garantía, cabecera
   móvil, total de la liquidación…), que en claro es igual a --ink. */
:root {
  --osc: #15181D;
  --tx-verde: #14532D; --tx-ambar: #7C2D12; --tx-rojo: #8F1B12; --tx-rojo2: #7A1A12; --tx-naranjo: #B45309; --tx-tenue-osc: #AEB4BE;
  --bg-rojo-tenue: #FFF8F7; --bg-ambar-tenue: #FFFBF3; --bg-hoy: #FFFBE5; --bg-mapa: #E8EBE4;
  --gris-0: #F8F9FA; --gris-1: #E6E8EC; --gris-1b: #ECEEF1; --gris-1c: #EEF0F3; --gris-2: #DDE2E8; --gris-2b: #E8ECEF;
  --borde-rojo: #F2C9C4; --borde-ambar: #F6D9B0; --borde-ambar2: #F6D9A8; --borde-verde: #B7DFC3; --borde-campo: #D0D5DD;
  --borde-gris: #B8BEC7; --borde-gris2: #C4C9D1; --rayas-a: #FEF3E2; --rayas-b: #FCE7C8;
}

/* ── Modo oscuro (mismo modelo que On Tow): se redefinen los tokens del CRM bajo :root[data-theme="oscuro"], que pone
   /tema.js antes de pintar. La base copiada del CRM no se edita: aquí se corrigen sus colores fijos pensados solo para
   fondo claro. El amarillo de marca (#FFD500) no cambia; los logos oficiales van sobre una placa blanca, sin recolorear. */
:root[data-theme="oscuro"] {
  --ink: #E8EBEF; --ink-2: #C5CBD3; --muted: #9AA3AF; --line: #2B323C; --line-2: #222831; --bg: #0F1216; --card: #1A1F26;
  --soft: #151A20; --marca-suave: #3A3410; --marca-texto: #FFE680; --amber-ink: #FCD9A8; --amber-soft: #3A2A12;
  --red: #F87171; --red-soft: #3B1A1A; --green: #4ADE80; --green-soft: #15301F; --blue: #A5B8F5; --blue-soft: #1B2747;
  --purple: #D8B4FE; --purple-soft: #2E1C40; --teal: #5EEAD4; --teal-soft: #12302D;
  --c-v0: #F87171; --c-vlow: #F59E0B; --c-com: #7BA0FF; --c-gps: #C084FC; --c-unk: #A3AAB5; --c-sim: #2DD4BF;
  --borde-osc: #3A424D; --tinta-sobre-marca: #15181D;
  --osc: #2B323C;
  --tx-verde: #86EFAC; --tx-ambar: #FCD9A8; --tx-rojo: #FCA5A5; --tx-rojo2: #FCA5A5; --tx-naranjo: #FBBF24; --tx-tenue-osc: #AEB4BE;
  --bg-rojo-tenue: #2A1717; --bg-ambar-tenue: #2A2214; --bg-hoy: #2E2A12; --bg-mapa: #1A1F25;
  --gris-0: #161B21; --gris-1: #252B33; --gris-1b: #252B33; --gris-1c: #20262D; --gris-2: #2B323C; --gris-2b: #2B323C;
  --borde-rojo: #6B2A26; --borde-ambar: #6B4E1F; --borde-ambar2: #6B4E1F; --borde-verde: #1F5A33; --borde-campo: #3A424D;
  --borde-gris: #4A535F; --borde-gris2: #4A535F; --rayas-a: #3A2A12; --rayas-b: #4A3516;
  color-scheme: dark;
}
:root[data-theme="oscuro"] body { background: var(--bg); color: var(--ink); }
:root[data-theme="oscuro"] a:hover { color: #fff; }
:root[data-theme="oscuro"] .btn, :root[data-theme="oscuro"] .btn-icono, :root[data-theme="oscuro"] .campo,
:root[data-theme="oscuro"] .filtro, :root[data-theme="oscuro"] .buscar input, :root[data-theme="oscuro"] .btn-plegar { border-color: var(--borde-osc); }
:root[data-theme="oscuro"] .btn.primario, :root[data-theme="oscuro"] .btn.primario:hover { color: var(--tinta-sobre-marca); border-color: var(--marca); }
:root[data-theme="oscuro"] .btn.oscuro { background: var(--marca-suave); border-color: #5C5218; color: var(--marca-texto); }
:root[data-theme="oscuro"] .btn.oscuro:hover { background: #4A4214; color: #FFF3B0; }
:root[data-theme="oscuro"] .btn.peligro { border-color: #6B2A26; }
:root[data-theme="oscuro"] .menu a.item[aria-current="page"] { color: var(--tinta-sobre-marca); }
:root[data-theme="oscuro"] .filtro[aria-pressed="true"] { background: var(--ink); color: #15181D; }
:root[data-theme="oscuro"] .filtro[aria-pressed="true"] .n { background: rgba(0,0,0,.12); }
:root[data-theme="oscuro"] .filtro .n { background: rgba(255,255,255,.08); }
:root[data-theme="oscuro"] .segmentado { background: #252B33; }
:root[data-theme="oscuro"] .segmentado button[aria-pressed="true"] { background: #39414C; box-shadow: none; }
:root[data-theme="oscuro"] .menu-usuario .avatar { background: var(--marca); color: var(--tinta-sobre-marca); }
:root[data-theme="oscuro"] .chip.ok, :root[data-theme="oscuro"] .chip.ins { color: var(--green); }
:root[data-theme="oscuro"] .chip.man, :root[data-theme="oscuro"] .chip.aviso { color: var(--amber-ink); }
:root[data-theme="oscuro"] .chip.error, :root[data-theme="oscuro"] .chip.baja, :root[data-theme="oscuro"] .chip.norep { color: var(--red); }
:root[data-theme="oscuro"] .chip.marca { background: var(--marca); color: var(--tinta-sobre-marca); }
:root[data-theme="oscuro"] .dias.d7 { color: #FBBF24; }
:root[data-theme="oscuro"] .aviso.error { color: #FECACA; } :root[data-theme="oscuro"] .aviso.ok { color: #BBF7D0; }
:root[data-theme="oscuro"] .bloque-orden.instalacion { color: #BBF7D0; } :root[data-theme="oscuro"] .bloque-orden.mantencion { color: #FCD9A8; }
/* Patente: placa chilena blanca con letras negras también en oscuro (así se ve en la calle y se lee igual). */
:root[data-theme="oscuro"] .pat { background: #fff; color: #15181D; border-color: #fff; }
:root[data-theme="oscuro"] .switch span { background: #3A424D; }
:root[data-theme="oscuro"] .switch input:checked + span { background: var(--marca); }
:root[data-theme="oscuro"] .switch input:checked + span::after { background: #15181D; }
:root[data-theme="oscuro"] .col { background: #151A20; }
:root[data-theme="oscuro"] .ficha:hover { border-color: #4A535F; }
:root[data-theme="oscuro"] .modal-fondo { background: rgba(0,0,0,.65); }
:root[data-theme="oscuro"] .modal { box-shadow: 0 20px 60px rgba(0,0,0,.6); border: 1px solid var(--line); }
:root[data-theme="oscuro"] .buscar-res { box-shadow: 0 10px 30px rgba(0,0,0,.5); }
/* Toast, pie del mapa, etiquetas y cabeceras «oscuras»: superficie oscura fija con texto claro (no se invierten). */
:root[data-theme="oscuro"] .toast, :root[data-theme="oscuro"] .pie-mapa, :root[data-theme="oscuro"] .leaflet-tooltip.etiqueta-pin,
:root[data-theme="oscuro"] .tecnico-cab { background: #2B323C; color: #F3F4F6; }
:root[data-theme="oscuro"] .toast.error { background: #7A1A12; } :root[data-theme="oscuro"] .toast.ok { background: #14532D; }
:root[data-theme="oscuro"] .barras-v, :root[data-theme="oscuro"] .barras { border-bottom-color: var(--borde-osc); }
:root[data-theme="oscuro"] .barras-v .barra i, :root[data-theme="oscuro"] .barra-h i { background: #5B83F0; }
:root[data-theme="oscuro"] .barras .barra { background: #6B7480; } :root[data-theme="oscuro"] .barras .barra.vacia { background: #2B323C; }
:root[data-theme="oscuro"] .seg.na { background: #3A424D; }
:root[data-theme="oscuro"] .mapa-caja { background: #1A1F25; }
:root[data-theme="oscuro"] .pin { border-color: #0F1216; }
:root[data-theme="oscuro"] .pin.sin { background: #0F1216; }
:root[data-theme="oscuro"] .firma-canvas { background: #fff; }
:root[data-theme="oscuro"] .paso .pend { border-color: #6B7480; }
/* Logos oficiales: nunca se recolorean; en oscuro van sobre una placa blanca. */
:root[data-theme="oscuro"] img[src*="logo-siguelo"] { background: #fff; border-radius: 8px; padding: 5px 8px; }
:root[data-theme="oscuro"] .menu-marca .marca-pin { background: #fff; border-radius: 8px; padding: 3px; }
/* Mapas: las teselas se oscurecen con un filtro suave (los marcadores y rutas quedan con su color). */
:root[data-theme="oscuro"] .leaflet-tile-pane { filter: brightness(.62) contrast(1.15) saturate(.6); }
:root[data-theme="oscuro"] .leaflet-container { background: #1A1F25; }
:root[data-theme="oscuro"] .leaflet-bar a, :root[data-theme="oscuro"] .leaflet-control-layers { background: var(--card); color: var(--ink); border-color: var(--line); }
:root[data-theme="oscuro"] .leaflet-control-attribution { background: rgba(26,31,38,.8) !important; color: var(--muted); }
:root[data-theme="oscuro"] .leaflet-control-attribution a { color: var(--ink-2); }
:root[data-theme="oscuro"] .leaflet-popup-content-wrapper, :root[data-theme="oscuro"] .leaflet-popup-tip { background: var(--card); color: var(--ink); }
/* Botón de tema en la barra superior */
.tema-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; padding: 0; }
.tema-btn:hover { color: var(--ink); border-color: var(--muted); }
/* Isla clara: documentos que se imprimen o salen en PDF (hojas) quedan claros también en oscuro: se vuelven a poner
   los tokens claros dentro de ellos. */
:root[data-theme="oscuro"] .cd-firma {
  --ink: #15181D; --ink-2: #3A414C; --muted: #5B6370; --line: #E2E5EA; --line-2: #EEF0F3; --bg: #F4F5F7; --card: #FFFFFF; --soft: #F7F8FA;
  --marca-suave: #FFF7CC; --marca-texto: #6B4A00; --amber-ink: #8A3B06; --amber-soft: #FEF3E2; --red: #B42318; --red-soft: #FDECEA;
  --green: #1E7B3A; --green-soft: #E6F4EA; --blue: #1E3A8A; --blue-soft: #E8EEFC; --purple: #581C87; --purple-soft: #F3E8FF; --teal: #0F5F58; --teal-soft: #DDF3F0;
  --osc: #15181D; --tx-verde: #14532D; --tx-ambar: #7C2D12; --tx-rojo: #8F1B12; --tx-rojo2: #7A1A12; --tx-naranjo: #B45309;
  --gris-0: #F8F9FA; --gris-1: #E6E8EC; --gris-1b: #ECEEF1; --gris-1c: #EEF0F3; --gris-2: #DDE2E8; --borde-campo: #D0D5DD; --borde-gris: #B8BEC7;
  --borde-rojo: #F2C9C4; --borde-ambar: #F6D9B0; --borde-verde: #B7DFC3; --bg-rojo-tenue: #FFF8F7; --bg-ambar-tenue: #FFFBF3;
  color-scheme: light; background: #fff; color: #15181D;
}
/* On Route en oscuro: piezas propias y de la app del conductor */
:root[data-theme="oscuro"] .cd-segmentado button { background: var(--card); }
:root[data-theme="oscuro"] .cd-segmentado button[aria-pressed="true"] { background: var(--marca); border-color: var(--marca); color: #15181D; }
:root[data-theme="oscuro"] .pastilla { background: var(--marca); color: #15181D; }
.menu-pie .tema-btn { align-self: flex-start; }
.tema-btn.tema-app { width: 32px; height: 32px; margin-left: auto; border: 1px solid #3A414C; background: transparent; color: #fff; border-radius: 8px; }
/* Marcadores y etiquetas del mapa: como en claro (blancos con letras oscuras) para leerse sobre las teselas */
:root[data-theme="oscuro"] .marcador-eti, :root[data-theme="oscuro"] .mk-parada, :root[data-theme="oscuro"] .parada-n { color: #15181D; }
:root[data-theme="oscuro"] .marcador-eti { border-color: #15181D; }
:root[data-theme="oscuro"] .mk-parada.hecha { color: #fff; }
:root[data-theme="oscuro"] .plan-mapa { background: #1A1F25; }
:root[data-theme="oscuro"] .plan-leyenda { background: var(--card); box-shadow: 0 4px 12px rgba(0,0,0,.4); }
:root[data-theme="oscuro"] .barra-col i { background: #5B83F0; } :root[data-theme="oscuro"] .barra-col:hover i { background: #7BA0FF; }
:root[data-theme="oscuro"] .mk-cd, :root[data-theme="oscuro"] .mk-camion { background: #15181D; }
/* Gráfico de temperatura en oscuro: el SVG trae colores fijos (es el mismo del comprobante, que queda claro); aquí se
   cambian por CSS solo cuando la página está en oscuro. */
:root[data-theme="oscuro"] .grafico-temp rect[fill="#FDECEA"] { fill: #3B1A1A; }
:root[data-theme="oscuro"] .grafico-temp rect[fill="#E8EEFC"] { fill: #1B2747; }
:root[data-theme="oscuro"] .grafico-temp rect[fill="#F7F8FA"] { fill: #151A20; }
:root[data-theme="oscuro"] .grafico-temp polyline[stroke="#15181D"] { stroke: #E8EBEF; }
:root[data-theme="oscuro"] .grafico-temp circle[fill="#15181D"] { fill: #E8EBEF; }
:root[data-theme="oscuro"] .grafico-temp line[stroke="#B42318"] { stroke: #F87171; }
:root[data-theme="oscuro"] .grafico-temp text[fill="#8F1B12"] { fill: #FCA5A5; }
:root[data-theme="oscuro"] .grafico-temp text { fill: #9AA3AF; }
:root[data-theme="oscuro"] .grafico-temp text[fill="#8F1B12"] { fill: #FCA5A5; }
:root[data-theme="oscuro"] .bloque h2 .num { color: #15181D; }
/* Sobre amarillo, siempre letras oscuras */
:root[data-theme="oscuro"] .cd-boton.primario { color: #15181D; }
/* Conectar la plataforma GPS (22-oct, igual que On Tow): Síguelo Pro / Síguelo Lite, botón amarillo y el token plegado */
.gps-conectar { display: flex; flex-direction: column; gap: 12px; max-width: 520px; margin-top: 6px; }
.gps-seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--soft); border: 1px solid var(--line); }
.gps-seg button { height: 40px; border: 0; border-radius: 9px; background: transparent; color: inherit; font: 600 14px var(--sans); cursor: pointer; }
.gps-seg button[aria-checked="true"] { background: var(--ink); color: var(--card); }
.gps-seg button:focus-visible { outline: 2px solid var(--marca); outline-offset: 2px; }
.gps-ir { min-height: 48px; font-size: 15px; width: 100%; }
.gps-manual { margin-top: 16px; }
.gps-manual summary { cursor: pointer; color: var(--muted); font-size: 13px; }
