/* =============================================================
   ADMIN — Sistema de diseño
   Única fuente de verdad: tokens + componentes.
   Ninguna vista define colores ni tamaños propios.
   ============================================================= */

/* ------------------------------------------------------------
   1. PALETA DEL PROYECTO  (lo único que se edita por proyecto)
   ------------------------------------------------------------ */
:root {
    --color-accent: #0d7490;   /* azul petróleo */
    --color-bg: #f4f7f9;
    --color-surface: #ffffff;
    --color-text: #111827;
    --rojo: #dc2626;
    --rojo-contraste: #fca5a5;  /* rojo legible sobre --n-900 (fondo del toast) */

    /* Rampa del acento (mismo matiz 193°) */
    --a-100: #eef9fc;
    --a-200: #d0eef6;
    --a-300: #8bd1e4;
    --a-500: #138dae;
    --a-600: #0c6179;
    --a-700: #094f62;

    /* Neutrales (tinte frío) */
    --n-100: #f8fafc;
    --n-200: #eef2f6;
    --n-300: #dde3ea;
    --n-400: #b8c0cb;
    --n-500: #94a0ae;
    --n-600: #6b7684;
    --n-700: #4b5563;
    --n-800: #333c47;
    --n-900: #1f262e;

    --color-divider: #e5e9ef;

    /* Alerta suave */
    --amb-100: #fef3c7;
    --amb-700: #92400e;

    /* Fijos */
    --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    --radius: 14px;
    --radius-sm: 10px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(17, 24, 39, .05);
    --shadow-md: 0 8px 24px rgba(17, 24, 39, .10);

    --lateral: 236px;
    --lateral-min: 68px;
    --topbar: 57px;
}

/* ------------------------------------------------------------
   2. TEMA OSCURO — mismos tokens, otros valores
   ------------------------------------------------------------ */
html[data-tema="oscuro"] {
    --color-bg: #0e1518;
    --color-surface: #141d21;
    --color-text: #e7eef1;

    --a-100: #10333f;
    --a-200: #164352;
    --a-300: #2c7c98;
    --a-500: #3aa6c6;
    --a-600: #7ecbe0;
    --a-700: #a6dcec;

    --n-100: #1a2429;
    --n-200: #232f35;
    --n-300: #2e3c43;
    --n-400: #46565f;
    --n-500: #7b8b95;
    --n-600: #9aa8b1;
    --n-700: #b8c4cb;
    --n-800: #d3dce1;
    --n-900: #eaf1f4;

    --color-divider: #243137;

    --rojo-contraste: #b91c1c;
    --amb-100: #3a2f10;
    --amb-700: #f4d06a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .5);
}

/* ------------------------------------------------------------
   3. BASE
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 13.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body, body * { font-family: var(--font); }
code, pre, .mono { font-family: var(--mono); }

h1, h2, h3, h4, h5, h6, p, ul, ol, figure { margin: 0; }
ul, ol { padding-left: 18px; }

a { color: var(--a-600); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

::selection { background: var(--a-200); color: var(--color-text); }

:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

hr {
    border: 0;
    border-top: 1px solid var(--color-divider);
    margin: var(--space-4) 0;
}

code:not(pre code) {
    background: var(--n-200);
    color: var(--a-700);
    padding: 1px 5px;
    border-radius: 5px;
    font-size: .92em;
}

pre {
    background: var(--n-900);
    color: var(--a-300);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    font-size: 12px;
    line-height: 1.55;
    overflow: auto;
    margin: 0;
}

/* Barras de scroll discretas */
* { scrollbar-width: thin; scrollbar-color: var(--n-400) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--n-400); border-radius: var(--radius-pill); border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------
   4. TIPOGRAFÍA Y JERARQUÍA
   ------------------------------------------------------------ */
.titulo-vista {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -.015em;
}

/* Kicker: rótulo de sección */
.kicker,
.panel > h3 {
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--n-500);
    margin: 0;
}

.meta { font-size: 11px; color: var(--n-500); }
.ayuda { font-size: 11.5px; color: var(--n-500); }
.txt-sec { color: var(--n-600); }
.txt-acento { color: var(--a-600); font-weight: 600; }
.txt-rojo { color: var(--rojo); font-weight: 600; }
.nowrap { white-space: nowrap; }
.derecha { text-align: right; }
.centro { text-align: center; }

/* ------------------------------------------------------------
   5. SHELL: barra lateral + topbar + contenido
   ------------------------------------------------------------ */
.shell {
    display: grid;
    grid-template-columns: var(--lateral) 1fr;
    min-height: 100dvh;
}
html[data-lateral="min"] .shell { grid-template-columns: var(--lateral-min) 1fr; }

/* --- Barra lateral --- */
.lateral {
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border-right: 1px solid var(--color-divider);
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow: hidden;
}

.lateral-marca {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: var(--topbar);
    padding: 0 var(--space-4);
    border-bottom: 1px solid var(--color-divider);
    flex-shrink: 0;
}
.lateral-marca .emblema {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--color-accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 12.5px;
    letter-spacing: -.02em;
    flex-shrink: 0;
}
.lateral-marca .nombre {
    font-weight: 800;
    font-size: 14px;
    letter-spacing: -.015em;
    white-space: nowrap;
    overflow: hidden;
}
.lateral-marca .nombre small {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--n-500);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.lateral-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) var(--space-2);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-kicker {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--n-500);
    padding: var(--space-3) var(--space-3) var(--space-1);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 9px var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--n-700);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
}
.nav-item:hover { background: var(--n-100); text-decoration: none; color: var(--color-text); }
.nav-item svg { flex-shrink: 0; }
.nav-item.activo {
    background: var(--a-100);
    color: var(--a-600);
    font-weight: 800;
}

.lateral-pie {
    border-top: 1px solid var(--color-divider);
    padding: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}
.lateral-pie .datos { min-width: 0; flex: 1; }
.lateral-pie .datos strong {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lateral-pie .datos span {
    font-size: 9.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--n-500);
}
.lateral-pie .salir { color: var(--n-500); }
.lateral-pie .salir:hover { color: var(--rojo); border-color: var(--rojo); }

/* Lateral comprimido: solo iconos, el pie se apila */
html[data-lateral="min"] .lateral-marca { justify-content: center; padding: 0; }
html[data-lateral="min"] .lateral-marca .nombre,
html[data-lateral="min"] .nav-kicker,
html[data-lateral="min"] .nav-item span,
html[data-lateral="min"] .lateral-pie .datos { display: none; }
html[data-lateral="min"] .nav-item { justify-content: center; padding: 9px 0; }
html[data-lateral="min"] .lateral-pie { flex-direction: column; gap: var(--space-2); }

/* --- Topbar --- */
.panel-principal { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-divider);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .titulo {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -.015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar .lema {
    font-size: 12px;
    color: var(--n-500);
    padding-left: var(--space-3);
    border-left: 1px solid var(--color-divider);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar .acciones {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.contenido {
    padding: var(--space-6);
    max-width: 1600px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* ------------------------------------------------------------
   6. BOTONES
   ------------------------------------------------------------ */
.btn,
.btn-sec,
.btn-mini,
.btn-icono {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    transition: background .12s, border-color .12s, color .12s;
}
.btn:hover, .btn-sec:hover, .btn-mini:hover, .btn-icono:hover { text-decoration: none; }

.btn {
    background: var(--color-accent);
    color: #fff;
    font-weight: 800;
    font-size: 13px;
    padding: 10px 18px;
}
.btn:hover { background: var(--a-600); color: #fff; }

.btn-sec {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--n-300);
    font-weight: 600;
    font-size: 13px;
    padding: 9px 16px;
}
.btn-sec:hover { border-color: var(--n-500); background: var(--n-100); color: var(--color-text); }

.btn-mini {
    background: var(--color-surface);
    color: var(--n-700);
    border-color: var(--n-300);
    font-weight: 600;
    font-size: 11.5px;
    padding: 5px 10px;
    border-radius: 8px;
    gap: 5px;
}
.btn-mini:hover { border-color: var(--n-500); background: var(--n-100); color: var(--color-text); }
.btn-mini.acento { color: var(--a-600); border-color: var(--a-200); background: var(--a-100); }
.btn-mini.acento:hover { border-color: var(--a-600); }
.btn-mini.rojo { color: var(--rojo); border-color: var(--n-300); }
.btn-mini.rojo:hover { border-color: var(--rojo); background: var(--n-100); }

.btn-icono {
    background: var(--color-surface);
    color: var(--n-600);
    border-color: var(--n-300);
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    flex-shrink: 0;
}
.btn-icono:hover { border-color: var(--n-500); color: var(--color-text); background: var(--n-100); }

/* Destructivo: SIEMPRE fantasma */
.btn.btn-rojo {
    background: transparent;
    color: var(--rojo);
    border-color: var(--rojo);
}
.btn.btn-rojo:hover { background: var(--rojo); color: #fff; }

.btn[disabled], .btn-sec[disabled], .btn-mini[disabled], .btn-icono[disabled],
.btn.deshabilitado, .btn-sec.deshabilitado, .btn-mini.deshabilitado {
    opacity: .45;
    pointer-events: none;
}

.btn-ancho { width: 100%; justify-content: center; }

/* Fila de acciones */
.acciones-fila {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}
.acciones-fila.derecha { justify-content: flex-end; }
.al-final { margin-left: auto; }
.en-linea { display: inline-flex; }

/* ------------------------------------------------------------
   7. CAMPOS DE FORMULARIO
   ------------------------------------------------------------ */
.campo-form { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.campo-form > label,
.etiqueta {
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--n-600);
}

.campo-form input[type="text"],
.campo-form input[type="email"],
.campo-form input[type="password"],
.campo-form input[type="number"],
.campo-form input[type="date"],
.campo-form input[type="file"],
.campo-form select,
.campo-form textarea,
.control {
    width: 100%;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--n-300);
    border-radius: var(--radius-sm);
    padding: 9px 11px;
    font-size: 13px;
    font-family: var(--font);
}
.campo-form textarea, textarea.control { min-height: 84px; resize: vertical; }

.campo-form input:focus,
.campo-form select:focus,
.campo-form textarea:focus,
.control:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--a-200);
}

.campo-form input[readonly], .control[readonly] { background: var(--n-100); color: var(--n-600); }
.campo-form input[disabled], .control[disabled] { opacity: .5; }
.campo-form .ayuda { margin-top: 1px; }

.campo-form select, select.control {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a0ae' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

/* Campo con botón pegado (token, copiar…) */
.campo-grupo { display: flex; gap: 0; }
.campo-grupo > input, .campo-grupo > .control {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-right: 0;
    min-width: 0;
}
.campo-grupo > .btn-mini,
.campo-grupo > .btn-sec {
    border-radius: 0;
    border-left-width: 1px;
    padding-left: 12px;
    padding-right: 12px;
}
.campo-grupo > :last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.campo-grupo.estrecho { max-width: 250px; }
.campo-grupo input.mono { font-family: var(--mono); font-size: 12px; }

/* Casilla */
.casilla {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    font-size: 13px;
    cursor: pointer;
}
.casilla input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-accent);
    margin-top: 1px;
    flex-shrink: 0;
}

/* Buscador */
.buscador { position: relative; display: flex; align-items: center; }
.buscador svg {
    position: absolute;
    left: 10px;
    color: var(--n-500);
    pointer-events: none;
}
.buscador input {
    background: var(--n-200);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 8px 12px 8px 32px;
    font-size: 13px;
    color: var(--color-text);
    width: 100%;
    font-family: var(--font);
}
.buscador input:focus {
    outline: none;
    background: var(--color-surface);
    border-color: var(--color-accent);
}

/* Rejilla de campos */
.rejilla-campos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    gap: var(--space-4);
}
.rejilla-campos.dos { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.campo-ancho { grid-column: 1 / -1; }

/* ------------------------------------------------------------
   8. PANELES
   ------------------------------------------------------------ */
.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-width: 0;
}
.panel.aviso-panel { border-left: 3px solid var(--color-accent); }
.panel.destacado { border-top: 3px solid var(--color-accent); }
.panel.plano { box-shadow: none; }

.panel-cab {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.panel-cab .icono-caja {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--a-100);
    color: var(--a-600);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.panel-cab .texto { flex: 1; min-width: 0; }
.panel-cab .texto h2 {
    font-size: 13.5px;
    font-weight: 800;
    letter-spacing: -.01em;
}
.panel-cab .texto p { font-size: 11.5px; color: var(--n-500); }
.panel-cab .acciones-fila { margin-left: auto; }

.rejilla {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: var(--space-4);
    align-items: start;
}
.rejilla.ancha { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
.rejilla-2-1 {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
    align-items: start;
}
@media (min-width: 1080px) {
    .rejilla-2-1 { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
    .rejilla-2-1.invertida { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
}

/* Apilado vertical con separación estándar */
.pila { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.pila.junta { gap: var(--space-2); }

/* Filas clave / valor */
.kv { display: flex; flex-direction: column; gap: var(--space-2); }
.kv > div {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    font-size: 12.5px;
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--color-divider);
}
.kv > div:last-child { border-bottom: 0; padding-bottom: 0; }
.kv dt, .kv .k { color: var(--n-600); font-weight: 600; }
.kv dd, .kv .v { margin: 0; font-weight: 600; text-align: right; word-break: break-word; }

/* ------------------------------------------------------------
   9. TABLAS
   ------------------------------------------------------------ */
.tabla-caja { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }

.tabla-barra {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.tabla-barra .buscador { flex: 1; min-width: 200px; max-width: 340px; }

.tabla-scroll { overflow-x: auto; border-radius: var(--radius-sm); }

.tabla {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 12.5px;
}
.tabla thead th {
    background: var(--n-100);
    color: var(--n-500);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    text-align: left;
    padding: 9px var(--space-3);
    border-bottom: 1px solid var(--color-divider);
    white-space: nowrap;
}
.tabla thead th.orden { cursor: pointer; user-select: none; }
.tabla thead th.orden:hover { color: var(--a-600); }
.tabla thead th .flecha { opacity: .35; margin-left: 3px; }
.tabla thead th.asc .flecha, .tabla thead th.desc .flecha { opacity: 1; color: var(--a-600); }
.tabla thead th.desc .flecha { transform: rotate(180deg); }

.tabla tbody td {
    padding: 9px var(--space-3);
    border-bottom: 1px solid var(--n-200);
    vertical-align: middle;
}
.tabla tbody tr:hover td { background: var(--n-100); }
.tabla tbody tr.apagada td { opacity: .55; }
.tabla tbody tr.alerta td { background: color-mix(in srgb, var(--rojo) 7%, transparent); }
.tabla .celda-fuerte { font-weight: 700; }
.tabla td.acciones { white-space: nowrap; }
.tabla td.acciones > * + * { margin-left: var(--space-1); }
.tabla .celda-mensaje { max-width: 320px; color: var(--n-600); }
.tabla.compacta { min-width: 0; }
.tabla.compacta thead th, .tabla.compacta tbody td { padding: 6px var(--space-2); font-size: 12px; }

/* Tabla clave/valor (detalles de modal) */
.tabla-kv { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tabla-kv th {
    width: 38%;
    text-align: left;
    font-weight: 600;
    color: var(--n-600);
    padding: 7px var(--space-3) 7px 0;
    border-bottom: 1px solid var(--n-200);
    vertical-align: top;
}
.tabla-kv td {
    padding: 7px 0;
    border-bottom: 1px solid var(--n-200);
    font-weight: 600;
    word-break: break-word;
}

/* Paginación */
.paginacion {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--n-500);
}
.paginacion:empty { display: none; }
.paginacion .rango b { color: var(--color-text); font-weight: 700; }

/* Selector de registros por página */
.paginacion .por-pagina {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--n-500);
}
.paginacion .por-pagina select {
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--n-300);
    border-radius: 8px;
    padding: 4px 6px;
    cursor: pointer;
}
.paginacion .por-pagina select:hover { border-color: var(--n-500); }

/* Botones numerados */
.paginacion .botones {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-left: auto;
}
.paginacion .pag-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 700;
    color: var(--n-700);
    background: var(--color-surface);
    border: 1px solid var(--n-300);
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.paginacion .pag-num:hover:not(:disabled):not(.activo) {
    border-color: var(--n-500);
    background: var(--n-100);
    color: var(--color-text);
}
.paginacion .pag-num.activo {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
    cursor: default;
}
.paginacion .pag-num.flecha { padding: 0; color: var(--n-600); }
.paginacion .pag-num:disabled { opacity: .4; cursor: not-allowed; }
.paginacion .pag-sep { padding: 0 2px; color: var(--n-400); user-select: none; }

@media (max-width: 640px) {
    .paginacion { justify-content: center; text-align: center; }
    .paginacion .botones { margin-left: 0; }
}

/* Paginación de Laravel */
.paginacion-laravel nav { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.paginacion-laravel svg { width: 14px; height: 14px; }
.paginacion-laravel p { font-size: 12px; color: var(--n-500); }
.paginacion-laravel span, .paginacion-laravel a {
    font-size: 12px;
    border-radius: 8px;
    padding: 5px 9px;
    border: 1px solid var(--n-300);
    color: var(--n-700);
}
.paginacion-laravel a:hover { border-color: var(--n-500); background: var(--n-100); text-decoration: none; }
.paginacion-laravel [aria-current="page"] span {
    background: var(--a-100);
    color: var(--a-600);
    border-color: var(--a-200);
    font-weight: 800;
}

/* ------------------------------------------------------------
   10. CHIPS, BADGES, ESTADOS
   ------------------------------------------------------------ */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--n-300);
    background: var(--color-surface);
    color: var(--n-700);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    cursor: pointer;
}
.chip:hover { background: var(--a-100); border-color: var(--a-200); text-decoration: none; }
.chip.activo { background: var(--n-900); border-color: var(--n-900); color: var(--color-bg); font-weight: 700; }

/* Chip con su propio badge dentro (p. ej. periodo + estado) */
.chip .badge { pointer-events: none; }
.chip.activo .badge { background: rgba(255, 255, 255, .18); color: var(--color-bg); }

/* Periodos de SIRE agrupados por ejercicio */
.periodos-anio { display: flex; flex-direction: column; gap: var(--space-2); }
.periodos-anio + .periodos-anio { margin-top: var(--space-3); }

.chip-estado {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 10px 3px 8px;
    background: var(--n-200);
    color: var(--n-700);
    white-space: nowrap;
}
.chip-estado::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.chip-estado.ok { background: var(--a-100); color: var(--a-600); }
.chip-estado.alerta { background: var(--amb-100); color: var(--amb-700); }
.chip-estado.error { background: color-mix(in srgb, var(--rojo) 12%, transparent); color: var(--rojo); }

.badge {
    display: inline-block;
    font-size: 9.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-radius: 6px;
    padding: 3px 7px;
    background: var(--n-200);
    color: var(--n-700);
    white-space: nowrap;
}
.badge.ok { background: var(--a-100); color: var(--a-600); }
.badge.alerta { background: var(--amb-100); color: var(--amb-700); }
.badge.error { background: color-mix(in srgb, var(--rojo) 12%, transparent); color: var(--rojo); }
.badge.metodo-post { background: var(--a-100); color: var(--a-600); }
.badge.metodo-get { background: var(--n-200); color: var(--n-700); }

.contador {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--a-100);
    color: var(--a-600);
    font-size: 11px;
    font-weight: 800;
}

/* ------------------------------------------------------------
   11. KPIs
   ------------------------------------------------------------ */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.stats > div {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    border-right: 1px solid var(--color-divider);
}
.stats > div:last-child { border-right: 0; }
.stats .icono-caja {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--a-100);
    color: var(--a-600);
    display: grid;
    place-items: center;
}
.stats .numero {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.1;
}
.stats .detalle { font-size: 11.5px; color: var(--n-500); }

/* Número grande en línea con su explicación */
.numero-linea { display: flex; align-items: baseline; gap: var(--space-2); }
.numero-linea .numero { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }

/* Mini stats dentro de una tarjeta */
.mini-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(110px, 100%), 1fr));
    gap: var(--space-2);
}
.mini-stats > div {
    background: var(--n-100);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
}
.mini-stats strong { display: block; font-size: 16px; font-weight: 800; letter-spacing: -.02em; }
.mini-stats span {
    font-size: 9.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--n-500);
}

/* Barra de progreso */
.progreso {
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--n-200);
    overflow: hidden;
}
/* El ancho llega como --pct desde la vista (dato, no diseño) */
.progreso > i { display: block; height: 100%; width: var(--pct, 0%); background: var(--color-accent); border-radius: inherit; }
.progreso > i.alerta { background: var(--amb-700); }
.progreso > i.error { background: var(--rojo); }

/* ------------------------------------------------------------
   12. AVATARES
   ------------------------------------------------------------ */
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
    flex-shrink: 0;
    letter-spacing: -.02em;
}
.avatar.entidad { border-radius: 10px; background: var(--n-900); color: var(--color-bg); }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }

/* ------------------------------------------------------------
   13. AVISOS, VACÍOS, CARGA
   ------------------------------------------------------------ */
.aviso {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--n-600);
}
.aviso svg { flex-shrink: 0; margin-top: 1px; }
.aviso.ok { color: var(--a-600); }
.aviso.error { color: var(--rojo); }
.aviso.alerta { color: var(--amb-700); }

.aviso-caja {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    background: var(--n-100);
    border-left: 3px solid var(--n-400);
    font-size: 12.5px;
    color: var(--n-700);
}
.aviso-caja svg { flex-shrink: 0; margin-top: 1px; }
.aviso-caja.ok { background: var(--a-100); border-color: var(--color-accent); color: var(--a-700); }
.aviso-caja.alerta { background: var(--amb-100); border-color: var(--amb-700); color: var(--amb-700); }
.aviso-caja.error { background: color-mix(in srgb, var(--rojo) 8%, transparent); border-color: var(--rojo); color: var(--rojo); }

.vacio {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    text-align: center;
    color: var(--n-500);
    font-size: 12.5px;
    padding: var(--space-8) var(--space-4);
}
.vacio svg { color: var(--n-400); }
.vacio strong { font-size: 13.5px; font-weight: 800; color: var(--n-600); }

.cargando {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    color: var(--n-500);
    font-size: 12.5px;
    padding: var(--space-6);
}

.girando { animation: girar .9s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* Skeleton */
.skeleton {
    background: var(--n-200);
    border-radius: 6px;
    animation: pulso 1.3s ease-in-out infinite;
}
@keyframes pulso { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }

/* ------------------------------------------------------------
   14. MODAL
   ------------------------------------------------------------ */
.modal-fondo {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-6);
    overflow-y: auto;
    z-index: 60;
}
.modal-fondo.abierto { display: flex; }

.modal-tarjeta {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 440px;
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin: auto;
}
.modal-tarjeta.ancho { max-width: 720px; }
.modal-tarjeta.xl { max-width: 1040px; }

.modal-cab {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
}
.modal-cab h2 { font-size: 15px; font-weight: 800; letter-spacing: -.015em; }
.modal-cab p { font-size: 11.5px; color: var(--n-500); }

.modal-cuerpo {
    font-size: 13.5px;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    max-height: 70dvh;
    overflow-y: auto;
}

.modal-pie {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* ------------------------------------------------------------
   15. TOAST
   ------------------------------------------------------------ */
.toast {
    position: fixed;
    right: var(--space-6);
    bottom: var(--space-6);
    z-index: 90;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--n-900);
    color: var(--color-bg);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 11px 15px;
    font-size: 12.5px;
    font-weight: 600;
    max-width: min(380px, calc(100vw - 48px));
    animation: entra-toast .18s ease-out;
}
.toast svg { flex-shrink: 0; }
.toast.ok svg { color: var(--a-300); }
.toast.error svg { color: var(--rojo-contraste); }
@keyframes entra-toast { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------
   16. PESTAÑAS / SECCIONES PLEGABLES / PASOS
   ------------------------------------------------------------ */
.tabs {
    display: flex;
    gap: var(--space-1);
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-pill);
    padding: 4px;
    overflow-x: auto;
    align-self: flex-start;
    max-width: 100%;
}
.tabs button {
    border: 0;
    background: transparent;
    border-radius: var(--radius-pill);
    padding: 7px 14px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--n-600);
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font);
}
.tabs button:hover { color: var(--color-text); }
.tabs button.activo { background: var(--a-100); color: var(--a-600); font-weight: 800; }

/* Plegable */
.plegable { border: 1px solid var(--color-divider); border-radius: var(--radius-sm); overflow: hidden; }
.plegable + .plegable { margin-top: var(--space-2); }
.plegable > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 11px var(--space-3);
    background: var(--color-surface);
    font-size: 13px;
    font-weight: 700;
}
.plegable > summary::-webkit-details-marker { display: none; }
.plegable > summary:hover { background: var(--n-100); }
.plegable > summary .chevron { margin-left: auto; color: var(--n-500); transition: transform .15s; }
.plegable[open] > summary { border-bottom: 1px solid var(--color-divider); }
.plegable[open] > summary .chevron { transform: rotate(180deg); }
.plegable-cuerpo { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }

/* Barra de guardado fija al pie de un formulario largo */
.barra-guardar {
    position: sticky;
    bottom: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: var(--space-3) var(--space-4);
}
.barra-guardar .acciones-fila { margin-left: auto; }

/* Vista previa de una imagen cargada por el usuario */
.vista-logo {
    max-width: 160px;
    max-height: 72px;
    object-fit: contain;
    align-self: flex-start;
    background: var(--n-100);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
}

/* ------------------------------------------------------------
   Documentación de la API
   ------------------------------------------------------------ */
.ruta-api {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 12px;
    background: var(--n-200);
    color: var(--a-700);
    padding: 2px 7px;
    border-radius: 6px;
    word-break: break-all;
}

/* Barra con el endpoint sobre un bloque de ejemplo */
.pre-barra {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    background: var(--n-100);
    border: 1px solid var(--color-divider);
    border-bottom: 0;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: var(--space-2) var(--space-3);
    font-size: 12.5px;
    margin-top: var(--space-3);
}
.pre-barra .btn-mini { margin-left: auto; }
.pre-barra + .pre-caja > pre,
pre.con-barra { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

/* Separador de una parte grande del documento (VENTAS / COMPRAS) */
.separador-parte {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background: var(--a-100);
    color: var(--a-700);
    border-left: 3px solid var(--color-accent);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -.01em;
    margin-top: var(--space-6);
}
.separador-parte.compras {
    background: var(--amb-100);
    color: var(--amb-700);
    border-left-color: var(--amb-700);
}
.separador-parte code { background: transparent; color: inherit; padding: 0; }

/* Paso a paso del ciclo de vida */
.flujo {
    background: var(--n-100);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    font-size: 12.5px;
    color: var(--n-700);
}
.flujo b { color: var(--a-600); }

/* Cabecera de tabla escrita como <tr><th> sin <thead> */
.tabla > tbody > tr > th, .tabla > tr > th {
    background: var(--n-100);
    color: var(--n-500);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    text-align: left;
    padding: 9px var(--space-3);
    border-bottom: 1px solid var(--color-divider);
    white-space: nowrap;
}

/* Bloque de ejemplo con su botón de copiar en la esquina */
.pre-caja { position: relative; }
.pre-caja > .btn-mini {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    background: var(--n-800);
    border-color: var(--n-700);
    color: var(--n-200);
}
.pre-caja > .btn-mini:hover { background: var(--n-700); color: #fff; }

/* ------------------------------------------------------------
   Flujo guiado: pasos numerados que se habilitan en orden
   ------------------------------------------------------------ */
.flujo {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.flujo-paso {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--color-divider);
    position: relative;
}
.flujo-paso:last-child { border-bottom: 0; padding-bottom: 0; }
.flujo-paso:first-child { padding-top: 0; }

/* Línea que une los números */
.flujo-paso::before {
    content: "";
    position: absolute;
    left: 13px;
    top: var(--space-6);
    bottom: 0;
    width: 1px;
    background: var(--color-divider);
}
.flujo-paso:first-child::before { top: var(--space-4); }
.flujo-paso:last-child::before { display: none; }

.flujo-paso > .num {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: var(--a-100);
    color: var(--a-600);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    border: 2px solid var(--color-surface);
    box-sizing: content-box;
    margin-left: -2px;
}

.flujo-paso > .cuerpo {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.flujo-paso h3 {
    font-size: 13.5px;
    font-weight: 800;
    letter-spacing: -.01em;
    text-transform: none;
    color: var(--color-text);
    margin: 0;
}
.flujo-paso h3 + .ayuda { margin-top: -8px; }

/* Paso ya resuelto */
.flujo-paso.hecho > .num { background: var(--color-accent); color: #fff; }

/* Paso cuyo requisito todavía no se cumple */
.flujo-paso.bloqueado > .num { background: var(--n-200); color: var(--n-500); }
.flujo-paso.bloqueado > .cuerpo { opacity: .55; }
.flujo-paso.bloqueado button,
.flujo-paso.bloqueado input,
.flujo-paso.bloqueado select { pointer-events: none; }

.estado-paso {
    font-size: 11.5px;
    color: var(--n-500);
    display: flex;
    align-items: center;
    gap: 6px;
}
.estado-paso.ok { color: var(--a-600); font-weight: 600; }
.estado-paso.alerta { color: var(--amb-700); font-weight: 600; }

.paso { display: flex; align-items: flex-start; gap: var(--space-3); font-size: 12.5px; }
.paso .num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--a-100);
    color: var(--a-600);
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
}
.pasos { display: flex; flex-direction: column; gap: var(--space-3); }

/* ------------------------------------------------------------
   17. LOGIN
   ------------------------------------------------------------ */
.auth {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: var(--space-6);
    background: var(--color-bg);
}
.auth-tarjeta {
    width: 100%;
    max-width: 380px;
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: var(--space-8);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}
.auth-marca { display: flex; flex-direction: column; gap: var(--space-3); }
.auth-marca .emblema {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--color-accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -.02em;
}
.auth-marca h1 { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.auth-marca p { font-size: 12.5px; color: var(--n-500); }
.auth-pie { text-align: center; font-size: 12px; color: var(--n-500); }

/* ------------------------------------------------------------
   18. RESPONSIVE
   ------------------------------------------------------------ */
@media (max-width: 1080px) {
    .contenido { padding: var(--space-4); }
    .topbar { padding: 0 var(--space-4); }
}

@media (max-width: 860px) {
    :root { --lateral: var(--lateral-min); }
    .shell { grid-template-columns: var(--lateral-min) 1fr; }
    html[data-lateral="min"] .shell { grid-template-columns: var(--lateral-min) 1fr; }

    .lateral-marca { justify-content: center; padding: 0; }
    .lateral-marca .nombre,
    .nav-kicker,
    .nav-item span,
    .lateral-pie .datos { display: none; }
    .nav-item { justify-content: center; padding: 9px 0; }
    .lateral-pie { flex-direction: column; gap: var(--space-2); }

    .topbar .lema { display: none; }
    .topbar .acciones .solo-ancho { display: none; }

    .rejilla-campos, .rejilla-campos.dos { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .stats > div:nth-child(2n) { border-right: 0; }
    .stats > div { border-bottom: 1px solid var(--color-divider); }

    .modal-fondo { padding: var(--space-3); }
    .toast { left: var(--space-3); right: var(--space-3); bottom: var(--space-3); max-width: none; }
    .tabs { align-self: stretch; }
}

@media print {
    .lateral, .topbar, .acciones-fila, .tabla-barra { display: none !important; }
    .contenido { padding: 0; }
    .panel { box-shadow: none; border: 0; }
}
