h1:focus {
    outline: none;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

/* ============================================================
   TercerFlota — sistema de diseño
   ============================================================ */

:root {
    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-border: #e3e5eb;
    --color-text: #1f2430;
    --color-text-muted: #6b7280;

    --color-primary: #0d9488;
    --color-primary-hover: #0f766e;
    --color-primary-bg: #e6f6f4;

    --color-danger: #dc2626;
    --color-danger-bg: #fdecea;
    /* Texto de badge rojo: ≥5.9:1 sobre --color-danger-bg. */
    --color-danger-text: #b91c1c;

    /* Ámbar: el texto (badge, valores) usa --color-warning; los rellenos (barra, puntos) --color-warning-fill. */
    --color-warning: #b45309;
    --color-warning-bg: #fff7e6;
    --color-warning-fill: #f59e0b;

    --color-success: #15803d;
    --color-success-bg: #eafaf0;

    --color-falta: #6d28d9;
    --color-falta-bg: #f3e8ff;

    --color-navbar-bg: #1c2333;
    --color-navbar-text: #cbd3e6;
    --color-navbar-text-active: #ffffff;

    --radius: 8px;
    --radius-sm: 5px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);

    --duration-fast: 120ms;
    --duration-default: 200ms;
    --duration-slow: 320ms;
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

h1, h2, h3 {
    font-family: inherit;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 1.25rem;
}

h2 {
    font-size: 1.1rem;
    font-weight: 650;
    color: var(--color-text);
    margin: 2rem 0 0.75rem;
    text-transform: none;
    letter-spacing: -0.005em;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.6rem;
}

a {
    color: var(--color-primary);
}

/* ---------- Layout ---------- */

main.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 4rem;
}

/* ---------- Navbar ---------- */

.navbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    background: var(--color-navbar-bg);
    padding: 0.6rem 1.5rem;
    min-height: 56px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--color-navbar-text-active);
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    flex-wrap: wrap;
}

.navbar-links a {
    color: var(--color-navbar-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}

.navbar-links a:hover {
    color: var(--color-navbar-text-active);
    background: rgba(255, 255, 255, 0.08);
}

.navbar-links a.active {
    color: var(--color-navbar-text-active);
    background: var(--color-primary);
}

.navbar-logout {
    margin: 0;
}

.nav-toggle {
    display: none;
}

.nav-toggle-btn {
    display: none;
}

/* Below 640px the link list becomes a collapsible menu behind a hamburger
   button (pure CSS checkbox toggle — no JS/interactivity needed, so it
   works instantly even before the SignalR circuit connects). Above that
   width .nav-toggle-btn stays display:none and the links show inline as
   normal, matching desktop. */
@media (max-width: 640px) {
    .nav-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        margin-left: auto;
        color: var(--color-navbar-text-active);
        border-radius: var(--radius-sm);
        cursor: pointer;
    }

    .nav-toggle-btn:hover {
        background: rgba(255, 255, 255, 0.08);
    }

    .navbar-links {
        display: none;
        order: 4;
        flex: 0 0 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
    }

    .nav-toggle:checked ~ .navbar-links {
        display: flex;
    }

    .navbar-links a {
        padding: 0.65rem 0.8rem;
    }
}

/* ---------- Buttons ---------- */

button, .btn {
    display: inline-block;
    font: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    cursor: pointer;
    transition: transform 120ms var(--ease-out), background-color 150ms var(--ease-out), border-color 150ms var(--ease-out);
}

button:hover, .btn:hover {
    border-color: var(--color-primary);
}

button:active, .btn:active {
    transform: scale(0.97);
}

button:focus-visible, .btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible,
a:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Un solo primario relleno por pantalla: el submit se rellena solo dentro de un modal o del login
   (fuera de ahí, p.ej. Exportar, es un botón secundario). */
.modal-acciones button[type="submit"],
.login-box button[type="submit"] {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.modal-acciones button[type="submit"]:hover,
.login-box button[type="submit"]:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

/* Confirmación de una acción destructiva (borrar, dar de baja, quitar). */
button.btn-danger {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}

button.btn-danger:hover {
    background: #991b1b;
    border-color: #991b1b;
}

/* Disparador de una acción destructiva: sin relleno, solo el texto en rojo. */
.btn-link-danger {
    color: var(--color-danger);
}

.btn-link-danger:hover {
    border-color: var(--color-danger);
}

/* Acciones secundarias (Exportar, etc.): blanco con borde, sin el teal del primario. */
.btn-secondary {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover {
    background: #f1f3f5;
    border-color: var(--color-border);
}

.btn svg, button svg {
    vertical-align: -3px;
}

.btn-secondary svg {
    margin-right: 0.35rem;
}

/* Acciones de fila: chicas y sin borde; la acción principal de la fila (Subir/Renovar)
   suma .btn-secondary para que se vea. */
.btn-sm {
    font-size: 0.82rem;
    padding: 0.3rem 0.6rem;
    background: transparent;
    border-color: transparent;
}

.btn-sm:hover {
    background: #f1f3f5;
    border-color: transparent;
}

.btn-sm.btn-secondary {
    background: var(--color-surface);
    border-color: var(--color-border);
}

.btn-sm.btn-secondary:hover {
    background: #f1f3f5;
    border-color: var(--color-border);
}

/* Borrar / Dar de baja en fila conservan el hover rojo. */
.btn-sm.btn-link-danger:hover {
    background: var(--color-danger-bg);
    border-color: var(--color-danger);
}

.confirmacion-texto {
    display: block;
    white-space: normal;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

button.btn-ghost, .navbar .btn-ghost {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--color-navbar-text);
}

button.btn-ghost:hover, .navbar .btn-ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}

/* ---------- Forms ---------- */

form {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
}

.navbar form,
.modal-dialog form {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
}

/* Loose flex-wrap left fields ragged and let the action buttons land next
   to whichever field happened to leave room in its row. A real 2-column
   grid keeps every field the same width and puts buttons on their own
   row every time, regardless of how many fields precede them. */
.modal-dialog form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 0.9rem 1rem;
}

@media (max-width: 480px) {
    .modal-dialog form {
        grid-template-columns: 1fr;
    }
}

.modal-dialog form .validation-errors {
    grid-column: 1 / -1;
    margin: 0;
    padding-left: 1.1rem;
}

/* Encabezado estándar de las listas: título a la izquierda, acción primaria a la derecha. */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-header h1 {
    margin: 0;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.field input, .field select {
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--color-text);
}

/* Tables scroll horizontally instead of breaking the page layout on small screens */
.table-wrap {
    position: relative;
    overflow-x: auto;
    margin: 0 0 1.5rem;
}

.table-wrap table.data {
    margin: 0;
}

/* A wide table cut off at a narrow viewport looked broken, not scrollable —
   this hints "there's more to the right" without needing JS to track scroll
   position. Scoped to mobile only: desktop tables rarely overflow. */
@media (max-width: 640px) {
    .table-wrap::after {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 20px;
        background: linear-gradient(to right, transparent, rgba(31, 36, 48, 0.12));
        pointer-events: none;
    }
}

input, select, textarea {
    font: inherit;
    font-size: 0.9rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    min-width: 140px;
    transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.22);
}

input::placeholder {
    color: #9aa1af;
}

/* ---------- Combobox (empresa, persona) ---------- */
/* Abre/cierra sin transición: se usa muchas veces al día y en interacciones
   tan frecuentes la animación estorba más de lo que aporta. */

.combobox {
    position: relative;
    min-width: 200px;
}

.combobox-input {
    width: 100%;
    min-width: 0;
}

.combobox-list {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    width: max-content;
    min-width: 100%;
    max-width: 320px;
    max-height: 260px;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.combobox-list li {
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--color-text);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.combobox-list li:hover,
.combobox-list li.resaltado {
    background: var(--color-primary-bg);
}

.combobox-list li.activo {
    font-weight: 600;
}

/* ---------- Tables ---------- */

table.data {
    border-collapse: collapse;
    width: 100%;
    margin: 0 0 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

table.data th, table.data td {
    padding: 0.65rem 0.9rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

table.data th {
    background-color: #fafbfc;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

table.data tbody tr {
    transition: background-color 120ms var(--ease-out);
}

table.data tbody tr:last-child td {
    border-bottom: none;
}

table.data tbody tr:hover {
    background-color: #f7f8fa;
}

table.data tr.inactivo td {
    color: var(--color-text-muted);
}

table.data td, .kpi-value {
    font-variant-numeric: tabular-nums;
}

table.data a {
    text-decoration: none;
    font-weight: 500;
}

table.data a:hover {
    text-decoration: underline;
}

table.data th.acciones,
table.data td.acciones {
    text-align: right;
    white-space: nowrap;
}

td.acciones > * + * {
    margin-left: 0.25rem;
}

/* ---------- KPI cards ---------- */

/* Conteos neutros del tablero, en una línea bajo el título. */
.resumen-flota {
    margin: -0.75rem 0 1rem;
}

/* Fila A del tablero: las tres alertas (vencidos, faltantes, por vencer). */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.kpi-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.25rem;
    opacity: 0;
    transform: translateY(6px);
    animation: rise var(--duration-slow) var(--ease-out) forwards;
}

/* Left accent stripe only where it carries meaning: an overdue/upcoming count. */
.kpi-card.kpi-danger {
    border-left: 4px solid var(--color-danger);
}

.kpi-card.kpi-warning {
    border-left: 4px solid var(--color-warning-fill);
}

.kpi-card.kpi-falta {
    border-left: 4px solid var(--color-falta);
}

a.kpi-link {
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
    transition: box-shadow 150ms var(--ease-out), translate 150ms var(--ease-out);
}

/* "translate" y no "transform": la animación de entrada (rise) retiene transform con forwards. */
a.kpi-link:hover {
    box-shadow: var(--shadow-md);
    translate: 0 -1px;
}

.kpi-ver {
    align-self: flex-end;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

a.kpi-link:hover .kpi-ver {
    color: var(--color-primary);
}

.kpi-grid .kpi-card:nth-child(1) { animation-delay: 0ms; }
.kpi-grid .kpi-card:nth-child(2) { animation-delay: 50ms; }
.kpi-grid .kpi-card:nth-child(3) { animation-delay: 100ms; }
.kpi-grid .kpi-card:nth-child(4) { animation-delay: 150ms; }
.kpi-grid .kpi-card:nth-child(5) { animation-delay: 200ms; }
.kpi-grid .kpi-card:nth-child(6) { animation-delay: 250ms; }
.kpi-grid .kpi-card:nth-child(7) { animation-delay: 300ms; }
.kpi-grid .kpi-card:nth-child(8) { animation-delay: 350ms; }

@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.kpi-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
    margin-bottom: 0.35rem;
}

.kpi-value {
    display: block;
    font-size: 2.25rem;
    line-height: 1.15;
    font-weight: 700;
    color: var(--color-text);
}

.kpi-card.kpi-danger .kpi-value {
    color: var(--color-danger);
}

.kpi-card.kpi-warning .kpi-value {
    color: var(--color-warning);
}

.kpi-card.kpi-falta .kpi-value {
    color: var(--color-falta);
}

/* ---------- Dashboard: salud de flota, columnas ---------- */

/* Fila B: tarjeta ancha con el % en regla a la izquierda y la barra + leyenda a la derecha. */
.flota-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.flota-card h2 {
    margin: 0 0 0.5rem;
}

.flota-cuerpo {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 2rem;
}

.flota-porcentaje {
    margin: 0;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.flota-porcentaje strong {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.flota-detalle {
    flex: 1 1 280px;
    min-width: 0;
}

.flota-detalle .leyenda {
    margin-bottom: 0;
}

/* Tramos separados por 2px de fondo (no solo por color); cada tramo crece según su cantidad. */
.salud-flota {
    display: flex;
    gap: 2px;
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--color-surface);
    margin: 0 0 0.75rem;
}

.salud-segmento {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 100%;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.salud-segmento.salud-ambar {
    color: var(--color-text);
}

.salud-verde { background: var(--color-success); }
.salud-ambar { background: var(--color-warning-fill); }
.salud-rojo { background: var(--color-danger); }
.salud-violeta { background: var(--color-falta); }

.leyenda {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.leyenda-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.leyenda-punto {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dashboard-columnas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.dashboard-columnas .table-wrap {
    margin-bottom: 0;
}

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    vertical-align: middle;
    white-space: nowrap;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

/* Glifo de EstadoBadge (✕ ! reloj ✓): el estado no depende solo del color. */
.badge svg {
    flex: none;
    vertical-align: 0;
}

.badge-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-falta {
    background: var(--color-falta-bg);
    color: var(--color-falta);
}

.badge-primary {
    background: var(--color-primary-bg);
    color: var(--color-primary-hover);
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge-neutral {
    background: #eef0f3;
    color: var(--color-text-muted);
}

/* ---------- Toasts ---------- */

.toast-host {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1100; /* por encima del modal (1000): un error al guardar tiene que verse */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(320px, calc(100vw - 2rem));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    animation: toast-in var(--duration-default) var(--ease-out);
}

.toast-saliendo {
    animation: toast-out var(--duration-default) var(--ease-out) forwards;
}

.toast-exito {
    background: var(--color-success);
}

.toast-error {
    background: var(--color-danger);
}

.toast > span {
    flex: 1;
}

.toast-cerrar {
    border: none;
    background: none;
    color: inherit;
    padding: 0 0.15rem;
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0.85;
}

.toast-cerrar:hover {
    opacity: 1;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

/* ---------- Modal ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    opacity: 0;
    animation: modal-backdrop-in var(--duration-default) var(--ease-out) forwards;
}

.modal-dialog {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    opacity: 0;
    transform: scale(0.95);
    animation: modal-in var(--duration-slow) var(--ease-out) forwards;
}

.modal-dialog:focus-visible {
    outline: none;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    text-transform: none;
    color: var(--color-text);
}

.modal-close {
    border: none;
    background: none;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    color: var(--color-text-muted);
}

.modal-close:hover {
    color: var(--color-text);
    border-color: transparent;
}

/* The form inside a modal reuses the same flex-wrap layout as a standalone
   form, so with certain field counts/widths the action buttons ended up
   sharing a row with the last field instead of getting their own line —
   forcing them onto a full-width row (with a divider) makes it consistent
   regardless of how many fields precede them. */
.modal-acciones {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.modal-backdrop-saliendo {
    opacity: 1;
    animation: modal-backdrop-out var(--duration-fast) var(--ease-out) forwards;
}

.modal-dialog-saliendo {
    opacity: 1;
    transform: scale(1);
    animation: modal-out var(--duration-fast) var(--ease-out) forwards;
}

@keyframes modal-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes modal-backdrop-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes modal-out {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

/* ---------- Messages ---------- */

.error {
    background-color: var(--color-danger-bg);
    border: 1px solid #f3c6c1;
    color: #7a2a22;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    margin: 0 0 1rem;
    font-size: 0.9rem;
}

.status {
    background-color: var(--color-success-bg);
    border: 1px solid #bfe8cd;
    color: var(--color-success);
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    margin: 0 0 1rem;
    font-size: 0.9rem;
}

.aviso {
    background-color: var(--color-primary-bg);
    border: 1px solid #a7e3dc;
    color: var(--color-text);
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
}

.aviso a {
    font-weight: 600;
}

/* ---------- Manual ---------- */

.manual {
    max-width: 720px;
}

.manual section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}

.manual section h2 {
    margin-top: 0;
}

.manual ul, .manual ol {
    padding-left: 1.25rem;
    line-height: 1.7;
}

.ayuda {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-top: -0.75rem;
    margin-bottom: 1rem;
}

/* ---------- Login ---------- */

.empty-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-navbar-bg);
    overflow: hidden;
}

/* Shared brand motif with the portal: a moving road, since San Pío is a
   trucking fleet. Appears only at the two "gateway" moments (choosing a
   system, logging in) — not inside the working app itself. Scoped to the
   login hero panel (not the whole viewport) now that login is a split layout. */
.road {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 10px;
    background: #12172a;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
    pointer-events: none;
}

.road::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    transform: translateY(-50%);
    background: repeating-linear-gradient(90deg, #f5c542 0 20px, transparent 20px 42px);
    animation: road-move 2.6s linear infinite;
}

@keyframes road-move {
    to { background-position: 46px 0; }
}

.login-shell {
    display: flex;
    width: 100%;
    max-width: 920px;
    margin: 2rem;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(10px);
    animation: rise var(--duration-slow) var(--ease-out) forwards;
}

.login-hero {
    position: relative;
    flex: 1 1 46%;
    background: linear-gradient(160deg, #1c2333, #10141f);
    color: #eef1f8;
    padding: 3rem 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.login-hero h2 {
    color: #fff;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0 0 0.5rem;
}

.login-hero > p {
    color: #aab2cc;
    margin: 0 0 1.75rem;
    font-size: 0.95rem;
}

.login-features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.login-features li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    color: #d7dcee;
}

.login-features svg {
    flex: none;
    color: var(--color-primary);
}

.login-panel {
    flex: 1 1 54%;
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
}

.login-box {
    width: 100%;
    max-width: 300px;
    text-align: left;
}

.login-mark {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.login-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-primary-bg);
    color: var(--color-primary);
}

.login-box h1 {
    margin-bottom: 0.35rem;
}

.login-subtitle {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin: 0 0 1.5rem;
}

.login-box form {
    display: block;
    border: none;
    box-shadow: none;
    padding: 0;
}

.login-box .field {
    margin-bottom: 0.9rem;
}

.login-box input {
    display: block;
    width: 100%;
}

.login-box button[type="submit"] {
    width: 100%;
    padding: 0.65rem;
    margin-top: 0.25rem;
}

@media (max-width: 760px) {
    .login-hero {
        display: none;
    }

    .login-shell {
        max-width: 360px;
        box-shadow: none;
    }

    .login-panel {
        padding: 2rem 1.5rem;
    }
}

/* ---------- Tercerizados ---------- */

.campo-ancho {
    grid-column: 1 / -1;
}

.field-check {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.9rem;
    color: var(--color-text);
}

/* Cabecera de ficha: tarjeta con migas, identificador + estado, subtítulo y acciones. */
.ficha-header {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.migas {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 0.35rem;
}

.migas a {
    color: var(--color-text-muted);
    text-decoration: none;
}

.migas a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.ficha-header-linea {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.ficha-titulo {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.ficha-titulo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    overflow-wrap: anywhere;
}

.ficha-titulo h1.chapa {
    font-variant-numeric: tabular-nums;
}

.badge-lg {
    font-size: 0.85rem;
    padding: 0.3rem 0.7rem;
}

.ficha-subtitulo {
    color: var(--color-text-muted);
    margin: 0.35rem 0 0;
}

.ficha-acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* "Qué le falta" en la ficha del vehículo: todo lo que lo deja fuera de regla, con su botón Subir. */
.que-falta {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.5rem;
    margin-bottom: 1.25rem;
}

.que-falta h2 {
    margin: 0 0 0.6rem;
}

.que-falta-lista {
    list-style: none;
    margin: 0;
    padding: 0;
}

.que-falta-lista li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--color-border);
}

.que-falta-lista li:first-child {
    border-top: none;
}

.que-falta-texto {
    flex: 1;
    min-width: 12rem;
}

/* Pendientes filtrado por empresa: a quién llamar. */
.contacto-empresa {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
}

.btn-whatsapp {
    margin-left: 0.5rem;
    padding: 0.3rem 0.7rem;
}

.todo-en-regla {
    color: var(--color-success);
    font-weight: 600;
    margin: 0;
}

.ficha-datos {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.35rem 1rem;
    margin: 0 0 1.5rem;
}

.ficha-datos dt {
    font-weight: 600;
    color: var(--color-text-muted);
}

.ficha-datos dd {
    margin: 0;
}

.panel-docs {
    margin-top: 1.5rem;
}

.panel-docs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.texto-muted {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.error-campo {
    color: var(--color-danger);
    font-size: 0.9rem;
    margin: 0;
}

.lista-archivos {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.9rem;
}

/* Selector de archivos: el input nativo ("Choose Files", en inglés) queda oculto pero enfocable;
   el label hace de zona de clic. */
.visualmente-oculto {
    position: absolute;
    width: 1px;
    height: 1px;
    min-width: 0;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 1.5px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: border-color 150ms var(--ease-out), background-color 150ms var(--ease-out);
}

.dropzone:hover,
.dropzone:focus-within {
    border-color: var(--color-primary);
    background: var(--color-primary-bg);
    color: var(--color-text);
}

.dropzone-deshabilitado {
    opacity: 0.6;
    cursor: default;
}

.contador-archivos {
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
}

.lista-elegidos {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--color-text);
}

.lista-elegidos li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.3rem 0.3rem 0.6rem;
    background: #f7f8fa;
    border-radius: var(--radius-sm);
}

.lista-elegidos-nombre {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-quitar {
    border: none;
    background: none;
    padding: 0.1rem 0.45rem;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--color-text-muted);
}

.btn-quitar:hover {
    color: var(--color-danger);
}

.aviso-vence {
    display: inline-block;
    margin-left: 0.3rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.archivo-link {
    display: block;
    word-break: break-all;
}

.historial {
    margin: 0 0 1.5rem;
}

.historial summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.filtros-linea {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

form.exportar {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    gap: 0.5rem;
}

/* Exportaciones a la derecha de los filtros. */
.filtros-linea .exportar {
    margin-left: auto;
}

/* ---------- Celular (<640px) ---------- */

@media (max-width: 640px) {
    /* Tablero: alertas en 2 columnas; la tercera ocupa la fila entera para no dejar hueco. */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .kpi-alertas .kpi-card:nth-child(3) {
        grid-column: 1 / -1;
    }

    .kpi-card {
        padding: 0.75rem 1rem;
    }

    .kpi-value,
    .flota-porcentaje strong {
        font-size: 1.5rem;
    }

    /* Tablas como tarjetas apiladas: principal + estado en la primera línea, el resto
       debajo en gris con su rótulo (data-label), las acciones a todo el ancho. */
    table.data.responsive,
    table.data.responsive tbody {
        display: block;
    }

    table.data.responsive thead {
        display: none;
    }

    table.data.responsive tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.2rem 0.75rem;
        align-items: center;
        padding: 0.75rem 0.9rem;
        border-bottom: 1px solid var(--color-border);
    }

    table.data.responsive tbody tr:last-child {
        border-bottom: none;
    }

    table.data.responsive td {
        grid-column: 1 / -1;
        padding: 0;
        border: none;
        font-size: 0.85rem;
        color: var(--color-text-muted);
    }

    table.data.responsive td.celda-principal {
        grid-column: 1;
        grid-row: 1;
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--color-text);
    }

    table.data.responsive td.celda-estado {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
        text-align: right;
    }

    table.data.responsive td[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: 600;
    }

    table.data.responsive td[data-label]:empty {
        display: none;
    }

    table.data.responsive td.acciones {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 0.4rem;
        text-align: left;
        white-space: normal;
    }

    table.data.responsive td.acciones > * {
        flex: 1 1 auto;
        margin-left: 0;
        text-align: center;
    }

    table.data.responsive td.acciones .btn-sm {
        padding: 0.55rem 0.8rem;
    }

    /* Ya no hay nada que desplazar a la derecha. */
    .table-wrap:has(table.responsive)::after {
        display: none;
    }

    /* Subir / Renovar a todo el ancho. */
    .panel-docs-header {
        flex-wrap: wrap;
    }

    .panel-docs-header .btn-primary {
        flex: 1 1 100%;
    }

    .que-falta-lista .btn {
        flex: 1 1 100%;
        text-align: center;
        padding: 0.55rem 0.8rem;
    }
}
