/* Central Matafuegos — estilo propio sobre Bootstrap 5 (paleta Sistematizar: azul #0052cc, naranja #c62828). */
:root {
    --marca: #0052cc;
    --marca-oscuro: #003d99;
    --acento: #c62828;
    --fondo: #f4f6fa;
    --lateral: #0f1f3d;
    --lateral-texto: #c9d3e6;
    --ancho-lateral: 236px;
    --bs-primary: #0052cc;
    --bs-primary-rgb: 0, 82, 204;
    --bs-link-color: #0052cc;
    --bs-link-color-rgb: 0, 82, 204;
}

body { background: var(--fondo); font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
.btn-primary { --bs-btn-bg: var(--marca); --bs-btn-border-color: var(--marca); --bs-btn-hover-bg: var(--marca-oscuro); --bs-btn-hover-border-color: var(--marca-oscuro); --bs-btn-active-bg: var(--marca-oscuro); }
.btn-acento { --bs-btn-color: #fff; --bs-btn-bg: var(--acento); --bs-btn-border-color: var(--acento); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #e85a26; --bs-btn-hover-border-color: #e85a26; }

/* ---------- estructura: menú lateral + contenido ---------- */
.app { display: flex; min-height: 100vh; }
.lateral {
    width: var(--ancho-lateral); background: var(--lateral); color: var(--lateral-texto);
    flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040;
    transition: transform .2s ease;
}
.lateral .marca { display: flex; align-items: center; gap: .55rem; padding: 1rem 1.1rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.lateral .marca .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--acento); display: grid; place-items: center; color: #fff; }
.lateral .empresa { padding: .6rem 1.1rem; font-size: .8rem; color: #8fa3c7; }
.lateral .seccion { padding: .9rem 1.1rem .3rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #6f84ab; }
.lateral a.item { display: flex; align-items: center; gap: .65rem; padding: .5rem 1.1rem; color: var(--lateral-texto); text-decoration: none; border-left: 3px solid transparent; font-size: .93rem; }
.lateral a.item:hover { background: rgba(255,255,255,.05); color: #fff; }
.lateral a.item.activo { background: rgba(0,82,204,.35); color: #fff; border-left-color: var(--acento); }
.lateral a.item i { font-size: 1.05rem; width: 1.2rem; text-align: center; }

.contenido { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.barra { background: #fff; border-bottom: 1px solid #e3e8f0; padding: .55rem 1rem; display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 1030; }
.barra .titulo-barra { font-weight: 600; color: #344563; }
.pie { margin-top: auto; padding: .75rem 1rem; font-size: .78rem; color: #7a869a; display: flex; gap: .6rem; align-items: center; }
.velo { display: none; }

@media (max-width: 991.98px) {
    .lateral { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
    .lateral.abierto { transform: none; }
    .velo.visible { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1035; }
}

/* ---------- tarjetas, tablas, listados ---------- */
.card { border: 1px solid #e3e8f0; border-radius: .7rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; font-weight: 600; }
.tarjeta-numero { display: block; padding: 1rem; text-decoration: none; color: inherit; }
.tarjeta-numero .valor { font-size: 1.9rem; font-weight: 700; line-height: 1; }
.tarjeta-numero .rotulo { font-size: .85rem; color: #5e6c84; }
.tarjeta-numero:hover { background: #f8faff; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #5e6c84; background: #f8f9fc; white-space: nowrap; }
.table td { vertical-align: middle; }
.col-copiar { width: 34px; padding-left: .5rem !important; padding-right: 0 !important; }
.btn-copiar { border: 0; background: transparent; color: #97a0af; padding: 0 .2rem; }
.btn-copiar:hover { color: var(--marca); }
th.ordenable { cursor: pointer; user-select: none; }
th.ordenable:hover { color: var(--marca); }
th.ordenable::after { content: "\2195"; opacity: .25; margin-left: .3rem; font-size: .8em; }
th[aria-sort="ascending"]::after { content: "\2191"; opacity: .9; }
th[aria-sort="descending"]::after { content: "\2193"; opacity: .9; }
.paginador { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; padding: .6rem .9rem; border-bottom: 1px solid #eef1f6; font-size: .85rem; color: #5e6c84; }
.paginador select { width: auto; display: inline-block; }
.solapas .nav-link { color: #42526e; }
.solapas .nav-link.active { font-weight: 600; color: var(--marca); }
.solapas .badge { font-weight: 500; }
/* Último recordatorio: violeta = retiro (equipo en el taller), verde azulado = anual (recarga). */
.badge-retiro { background: #7c3aed; color: #fff; }
.badge-anual { background: #0f766e; color: #fff; }
.foto-planilla { max-height: 60vh; }
.totales { font-size: .88rem; color: #42526e; }
.totales strong { color: #172b4d; }
.form-check-input.toggle-activo { width: 1.25rem; height: 1.25rem; cursor: pointer; }
.cargando { opacity: .55; pointer-events: none; transition: opacity .15s; }

/* ---------- detalle de nota ---------- */
.estado-chip { font-size: .8rem; }
.item-modificado { font-size: .78rem; color: #8a6d00; }
.item-reprogramado { font-size: .78rem; color: #8a6d00; }
.decision { display: none; }
.decision.visible { display: block; }
.fila-cancelada td { color: #97a0af; }
.fila-cancelada td.producto { text-decoration: line-through; }
.w-cant { width: 6.5rem; }
.w-fecha { width: 9.5rem; }
.w-camion { min-width: 9rem; }

/* ---------- armado de hoja ---------- */
.lista-recorrido .list-group-item { display: flex; align-items: center; gap: .6rem; }
.lista-recorrido .orden { width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--marca); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.candidata { cursor: default; }
.candidata.elegida { opacity: .45; }
.cantidad-parcial { display: none; }
.cantidad-parcial.visible { display: inline-block; }

/* ---------- login ---------- */
.login-fondo { min-height: 100vh; background: linear-gradient(135deg, #0f1f3d 0%, #0052cc 100%); display: flex; align-items: center; justify-content: safe center; padding: 1.5rem; }
.login-caja { width: 100%; max-width: 430px; }
.login-caja .card { border: 0; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-marca { color: #fff; text-align: center; margin-bottom: 1.25rem; }
.login-marca .logo { width: 52px; height: 52px; border-radius: 14px; background: var(--acento); display: inline-grid; place-items: center; font-size: 1.6rem; color: #fff; }
.acceso-rapido { max-width: 760px; width: 100%; }
.paso { display: none; }
.paso.visible { display: block; }
.oculto { display: none !important; }

/* ---------- aviso flotante (toast) ---------- */
.toast-fijo {
    position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%) translateY(150%);
    background: #172b4d; color: #fff; padding: .65rem 1.1rem; border-radius: .5rem; z-index: 2000;
    box-shadow: 0 8px 24px rgba(0,0,0,.25); transition: transform .25s ease; max-width: 90vw; font-size: .93rem;
}
.toast-fijo.visible { transform: translateX(-50%) translateY(0); }
.toast-fijo.error { background: #c9372c; }
.toast-fijo.ok { background: #1f845a; }

/* Ver recorrido de la hoja de ruta (mapa Leaflet) */
.mapa-recorrido { height: calc(100vh - 200px); min-height: 420px; border-radius: .7rem; border: 1px solid #e3e8f0; }
.marcador-num span { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
    background: #e8590c; color: #fff; font-weight: 700; font-size: .78rem; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
.lista-paradas { max-height: calc(100vh - 200px); overflow-y: auto; }
.parada-link { border: 0; background: transparent; padding: 3px 0; text-align: left; width: 100%; font-size: .88rem; }
.parada-link:hover { color: #e8590c; }
.parada-link .num { display: inline-block; min-width: 24px; text-align: center; border-radius: 12px; background: #fff0e6;
    color: #e8590c; font-weight: 700; font-size: .75rem; }

/* ---- Celular: las tablas se ven como tarjetas (pedido de Miguel 2026-11-30) ----
   app.js le pone a cada celda data-label con el nombre de su columna (también a filas que llegan por AJAX). La celda con el
   dato principal (.celda-titulo) va arriba como título; las que no tienen columna con nombre (copiar, elegir, botones) van
   en una línea de íconos. Las que tienen campos (fecha, camión, disponible…) muestran el nombre arriba y el campo a lo ancho. */
@media (max-width: 767.98px) {
    .table-responsive:has(> table.tabla-tarjetas) { overflow: visible; }
    table.tabla-tarjetas, table.tabla-tarjetas > tbody, table.tabla-tarjetas > tbody > tr, table.tabla-tarjetas > tbody > tr > td { display: block; width: 100%; }
    table.tabla-tarjetas > thead { display: none; }
    table.tabla-tarjetas > tbody > tr { position: relative; background: #fff; border: 1px solid #e3e8f0; border-radius: .7rem;
        margin: 0 0 .6rem; padding: .5rem .75rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
    table.tabla-tarjetas > tbody > tr.fila-cancelada { opacity: .65; }
    table.tabla-tarjetas > tbody > tr > td { display: flex; justify-content: space-between; align-items: center; gap: .75rem;
        border: 0; padding: .3rem 0; text-align: right !important; white-space: normal !important; }
    table.tabla-tarjetas > tbody > tr > td[data-label]::before { content: attr(data-label); flex: 0 0 38%; text-align: left;
        font-size: .78rem; font-weight: 600; color: #64748b; }
    table.tabla-tarjetas > tbody > tr > td:empty, table.tabla-tarjetas > tbody > tr > td.vacia { display: none; }
    /* celdas con campos: el nombre arriba y el campo a todo el ancho */
    table.tabla-tarjetas > tbody > tr > td.con-campos { display: block; text-align: left !important; }
    table.tabla-tarjetas > tbody > tr > td.con-campos[data-label]::before { display: block; margin-bottom: .25rem; }
    table.tabla-tarjetas > tbody > tr > td.con-campos > .form-control, table.tabla-tarjetas > tbody > tr > td.con-campos > .form-select,
    table.tabla-tarjetas > tbody > tr > td.con-campos > form > .form-select, table.tabla-tarjetas > tbody > tr > td.con-campos .input-group {
        width: 100% !important; max-width: none !important; }
    table.tabla-tarjetas > tbody > tr > td.con-campos .input-group > .form-control { flex: 1 1 auto; width: 1% !important; max-width: none !important; }
    /* el dato principal como título de la tarjeta */
    table.tabla-tarjetas > tbody > tr > td.celda-titulo { display: block; text-align: left !important; font-size: 1rem; padding-right: 4.5rem; }
    table.tabla-tarjetas > tbody > tr > td.celda-titulo::before { display: none; }
    /* copiar / elegir / botones sin nombre de columna: arriba a la derecha */
    table.tabla-tarjetas > tbody > tr > td.celda-icono { position: absolute; top: .45rem; width: auto; padding: 0; }
    table.tabla-tarjetas > tbody > tr > td.celda-icono.i0 { right: .6rem; }
    table.tabla-tarjetas > tbody > tr > td.celda-icono.i1 { right: 2.6rem; }
    table.tabla-tarjetas > tbody > tr > td.celda-icono.i2 { right: 4.6rem; }
    /* sin título (ej. ítems de una nota nueva): lugar arriba para los íconos, así no pisan el primer campo */
    table.tabla-tarjetas > tbody > tr:has(> td.celda-icono):not(:has(> td.celda-titulo)) { padding-top: 2.9rem; }
    table.tabla-tarjetas > tbody > tr.sin-datos { border-style: dashed; }
    table.tabla-tarjetas > tbody > tr.sin-datos > td { display: block; text-align: center !important; }
    table.tabla-tarjetas > tbody > tr.sin-datos > td::before { display: none; }
    /* ordenar desde el celular (los encabezados no se ven): el selector que arma list-tools.js */
    .paginador .orden-celular { display: flex !important; }
}
.orden-celular { display: none !important; align-items: center; gap: .4rem; }
/* Pantallas táctiles: botones, casillas y opciones del tamaño del dedo */
@media (pointer: coarse) {
    .btn-sm, .btn-group-sm > .btn { min-height: 38px; min-width: 38px; }
    .form-check-input { width: 1.35em; height: 1.35em; }
    .form-control-sm, .form-select-sm { min-height: 38px; font-size: .95rem; }
    .form-check { min-height: 1.9rem; padding-top: .15rem; }
}

/* Ícono de matafuego (no hay uno en Bootstrap Icons): toma el color del texto. */
.ic-matafuego { display: inline-block; width: 1em; height: 1.25em; vertical-align: -.25em; background-color: currentColor;
    -webkit-mask: url(../img/matafuego.svg) center / contain no-repeat; mask: url(../img/matafuego.svg) center / contain no-repeat; }
