/* =========================================================================
   ROBLEDO — Sistema de diseño (única fuente de verdad)
   Acento: azul · Tema oscuro por defecto · Iconos Lucide
   Reemplaza por completo la plantilla (style.css / components.css).
   ========================================================================= */

/* =========================================================================
   1. PALETA Y TOKENS
   ========================================================================= */
:root {
    /* --- Acento del proyecto --- */
    --color-accent: #2563eb;
    --a-100: #eef4ff;
    --a-200: #dbe6fe;
    --a-300: #93c5fd;
    --a-500: #3b82f6;
    --a-600: #1d4ed8;
    --a-700: #1e40af;

    /* --- Base --- */
    --color-bg: #f3f6fb;
    --color-surface: #ffffff;
    --color-text: #111827;
    --color-divider: #e5e9ef;
    --rojo: #dc2626;
    --rojo-suave: #fee2e2;

    /* --- 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;

    /* --- Semánticos suaves --- */
    --menta-100: #dcfce7;
    --menta-700: #15803d;
    --amb-100: #fef3c7;
    --amb-700: #92400e;

    /* --- Tipografía y métricas --- */
    --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
    --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.1);

    /* --- Portada de acceso ---
       Fijos a propósito: el panel de marca lleva texto claro encima, así que
       no puede invertirse con el tema oscuro como el resto de la rampa. */
    --marca-fondo-a: #16255c;
    --marca-fondo-b: #2563eb;
    --marca-texto: #eef4ff;
    --marca-texto-tenue: #a9c2f5;

    /* --- Shell --- */
    --ancho-sidebar: 236px;
    --ancho-sidebar-mini: 68px;
    --alto-topbar: 57px;
}

html[data-tema="oscuro"] {
    --color-accent: #2563eb;
    --a-100: #16233f;
    --a-200: #1d3159;
    --a-300: #7fa9fb;
    --a-500: #3b82f6;
    --a-600: #9dbcfd;
    --a-700: #c3d6fe;

    --color-bg: #0b1220;
    --color-surface: #111a2b;
    --color-text: #e7edf8;
    --color-divider: #1e2a41;
    --rojo: #f87171;
    --rojo-suave: #3b1418;

    --n-100: #151f33;
    --n-200: #1c2740;
    --n-300: #27354f;
    --n-400: #3d4f70;
    --n-500: #7d8fb3;
    --n-600: #9aabc9;
    --n-700: #b6c4dd;
    --n-800: #d2dcee;
    --n-900: #e9eff9;

    --menta-100: #0f2f22;
    --menta-700: #6ee7b7;
    --amb-100: #3a2c0c;
    --amb-700: #fcd34d;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
}

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

html,
body {
    background: var(--color-bg);
    color: var(--color-text);
}

body,
body * {
    font-family: var(--font);
}

code,
pre,
kbd,
samp,
.font-mono {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

body {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

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

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

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

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--n-300);
    border-radius: var(--radius-pill);
    border: 3px solid var(--color-bg);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--n-400);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--color-text);
    font-weight: 800;
    letter-spacing: -0.015em;
    margin: 0;
}

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

/* =========================================================================
   3. SHELL — sidebar + topbar + contenido
   ========================================================================= */
.rb-shell {
    display: grid;
    grid-template-columns: var(--ancho-sidebar) 1fr;
    min-height: 100dvh;
    transition: grid-template-columns 0.18s ease;
}

body.sidebar-mini .rb-shell {
    grid-template-columns: var(--ancho-sidebar-mini) 1fr;
}

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

.rb-marca {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: var(--alto-topbar);
    padding: 0 var(--space-4);
    border-bottom: 1px solid var(--color-divider);
    flex: 0 0 auto;
}

.rb-marca-caja {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: var(--radius-sm);
    background: var(--color-accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: -0.02em;
}

.rb-marca-txt {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

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

.rb-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;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    border: 0;
    background: none;
    width: 100%;
    text-align: left;
}

.rb-nav-item svg {
    flex: 0 0 17px;
    color: var(--n-500);
}

.rb-nav-item:hover {
    background: var(--n-100);
    color: var(--color-text);
}

.rb-nav-item:hover svg {
    color: var(--n-700);
}

.rb-nav-item.activo,
.rb-grupo.abierto > .rb-nav-item.tiene-hijos.rama-activa {
    background: var(--a-100);
    color: var(--a-600);
    font-weight: 800;
}

.rb-nav-item.activo svg,
.rb-grupo.abierto > .rb-nav-item.tiene-hijos.rama-activa svg {
    color: var(--a-600);
}

.rb-nav-item .rb-nav-txt {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-nav-item .rb-nav-caret {
    flex: 0 0 14px;
    transition: transform 0.16s ease;
}

.rb-grupo.abierto > .rb-nav-item .rb-nav-caret {
    transform: rotate(180deg);
}

.rb-submenu {
    display: none;
    flex-direction: column;
    gap: 1px;
    margin: 2px 0 var(--space-2);
    padding-left: 30px;
    position: relative;
}

.rb-submenu::before {
    content: "";
    position: absolute;
    left: 21px;
    top: 4px;
    bottom: 4px;
    width: 1px;
    background: var(--color-divider);
}

.rb-grupo.abierto > .rb-submenu {
    display: flex;
}

.rb-sub-item {
    display: block;
    padding: 7px var(--space-3);
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--n-600);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-sub-item:hover {
    background: var(--n-100);
    color: var(--color-text);
}

.rb-sub-item.activo {
    color: var(--a-600);
    font-weight: 800;
    background: var(--a-100);
}

/* Pie del sidebar: usuario */
.rb-sidebar-pie {
    flex: 0 0 auto;
    border-top: 1px solid var(--color-divider);
    padding: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.rb-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 50%;
    background: var(--n-900);
    color: var(--color-bg);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: -0.01em;
    overflow: hidden;
}

.rb-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rb-usuario-txt {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.rb-usuario-nombre {
    font-size: 12.5px;
    font-weight: 800;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-usuario-rol {
    font-size: 9.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--n-500);
    white-space: nowrap;
}

.rb-salir {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    color: var(--n-500);
    border: 1px solid transparent;
}

.rb-salir:hover {
    color: var(--rojo);
    background: var(--rojo-suave);
    border-color: transparent;
}

/* --- Sidebar comprimido --- */
body.sidebar-mini .rb-marca-txt,
body.sidebar-mini .rb-nav-txt,
body.sidebar-mini .rb-nav-caret,
body.sidebar-mini .rb-nav-kicker,
body.sidebar-mini .rb-usuario-txt {
    display: none;
}

body.sidebar-mini .rb-marca {
    justify-content: center;
    padding: 0;
}

body.sidebar-mini .rb-nav-item {
    justify-content: center;
    padding: 10px 0;
}

body.sidebar-mini .rb-submenu {
    padding-left: 0;
    margin: 2px 0;
}

body.sidebar-mini .rb-submenu::before {
    display: none;
}

body.sidebar-mini .rb-sub-item {
    text-align: center;
    font-size: 10.5px;
    padding: 6px 2px;
    white-space: normal;
    line-height: 1.15;
}

/* En comprimido el pie NO se oculta: se apila */
body.sidebar-mini .rb-sidebar-pie {
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3) 0;
}

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

.rb-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--alto-topbar);
    flex: 0 0 var(--alto-topbar);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-6);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-divider);
}

.rb-titulo-vista {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.015em;
    color: var(--color-text);
    white-space: nowrap;
}

.rb-lema {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 12px;
    color: var(--n-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-lema::before {
    content: "";
    width: 1px;
    height: 16px;
    background: var(--color-divider);
    flex: 0 0 1px;
}

.rb-topbar-der {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-icono {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-divider);
    background: var(--color-surface);
    color: var(--n-600);
    cursor: pointer;
    padding: 0;
}

.btn-icono:hover {
    border-color: var(--n-400);
    background: var(--n-100);
    color: var(--color-text);
}

/* --- Contenido --- */
.rb-main {
    flex: 1 1 auto;
    padding: var(--space-6);
    max-width: 1600px;
    width: 100%;
    min-width: 0;
    margin-inline: auto;
}

/* El velo solo existe en móvil; en escritorio no debe ocupar celda de la rejilla */
.rb-velo {
    display: none;
}

/* =========================================================================
   4. BOTONES (remapeo de Bootstrap a tokens)
   ========================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-2);
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.35;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: none;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
    text-align: left;
}

.btn:focus,
.btn.focus {
    box-shadow: none;
}

.btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.btn i,
.btn svg {
    font-size: 12.5px;
    line-height: 1;
}

.btn:disabled,
.btn.disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* Primario — uno por zona */
.btn-primary,
.btn-outline-primary:hover,
.btn-info,
.btn-info:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
    font-weight: 800;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-info:focus,
.btn-info:active {
    background: var(--a-600);
    border-color: var(--a-600);
    color: #fff;
}

/* Secundario / fantasma acentuado */
.btn-outline-primary,
.btn-outline-info,
.btn-secondary,
.btn-outline-secondary,
.btn-light,
.btn-outline-dark,
.btn-dark {
    background: var(--color-surface);
    border-color: var(--color-divider);
    color: var(--n-700);
}

.btn-outline-primary,
.btn-outline-info {
    color: var(--a-600);
    border-color: var(--a-200);
}

.btn-outline-info:hover,
.btn-outline-info:focus,
.btn-outline-info:active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.btn-secondary:hover,
.btn-outline-secondary:hover,
.btn-light:hover,
.btn-dark:hover,
.btn-outline-dark:hover {
    background: var(--n-100);
    border-color: var(--n-400);
    color: var(--color-text);
}

/* Destructivo — SIEMPRE fantasma, nunca relleno */
.btn-danger,
.btn-outline-danger {
    background: transparent;
    border-color: var(--rojo);
    color: var(--rojo);
}

.btn-danger:hover,
.btn-danger:focus,
.btn-danger:active,
.btn-outline-danger:hover,
.btn-outline-danger:focus,
.btn-outline-danger:active {
    background: var(--rojo-suave);
    border-color: var(--rojo);
    color: var(--rojo);
}

/* Positivo */
.btn-success,
.btn-outline-success {
    background: transparent;
    border-color: var(--menta-700);
    color: var(--menta-700);
}

.btn-success:hover,
.btn-success:focus,
.btn-success:active,
.btn-outline-success:hover,
.btn-outline-success:focus,
.btn-outline-success:active {
    background: var(--menta-100);
    border-color: var(--menta-700);
    color: var(--menta-700);
}

/* Alerta */
.btn-warning,
.btn-outline-warning {
    background: transparent;
    border-color: var(--amb-700);
    color: var(--amb-700);
}

.btn-warning:hover,
.btn-warning:focus,
.btn-warning:active,
.btn-outline-warning:hover,
.btn-outline-warning:focus,
.btn-outline-warning:active {
    background: var(--amb-100);
    border-color: var(--amb-700);
    color: var(--amb-700);
}

/* Estado seleccionado — anula el texto blanco que Bootstrap fuerza en .active */
.btn-secondary.active,
.btn-outline-secondary.active,
.btn-light.active,
.btn-dark.active,
.btn-outline-dark.active,
.btn-outline-primary.active,
.btn-outline-info.active {
    background: var(--a-100);
    border-color: var(--a-200);
    color: var(--a-600);
    font-weight: 800;
}

.btn-sm,
.btn-mini {
    padding: 5px 10px;
    font-size: 11.5px;
    border-radius: 8px;
    gap: 6px;
}

.btn-lg {
    padding: 11px 20px;
    font-size: 13.5px;
}

.btn-block,
.btn.w-100 {
    justify-content: center;
    text-align: center;
}

/* Botón de tabla solo-icono */
.btn.btn-sm > i:only-child,
.btn.btn-mini > i:only-child {
    margin: 0;
}

/* =========================================================================
   5. FORMULARIOS
   ========================================================================= */
label,
.form-label,
.col-form-label {
    display: block;
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--n-600);
    margin-bottom: var(--space-1);
}

.form-group {
    margin-bottom: var(--space-4);
}

.form-control,
.form-select,
select.form-control,
textarea.form-control,
input.form-control {
    width: 100%;
    background: var(--color-surface);
    border: 1px solid var(--n-300);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 13px;
    padding: 9px 12px;
    line-height: 1.4;
    box-shadow: none;
    transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.form-control::placeholder {
    color: var(--n-500);
}

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

.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
    background: var(--n-100);
    color: var(--n-600);
    opacity: 1;
}

.form-select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--n-500) 50%),
        linear-gradient(135deg, var(--n-500) 50%, transparent 50%);
    background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 32px;
}

textarea.form-control {
    min-height: 84px;
    resize: vertical;
}

.form-text,
.text-muted,
small.form-text {
    font-size: 11.5px;
    color: var(--n-500) !important;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.error,
.invalid-feedback,
span.text-danger.error {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--rojo) !important;
    margin-top: var(--space-1);
    text-transform: none;
    letter-spacing: 0;
}

/* Grupos de entrada */
.input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.input-group > .form-control,
.input-group > .form-select {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.input-group .input-group-text {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--n-100);
    border: 1px solid var(--n-300);
    color: var(--n-600);
    font-size: 12.5px;
}

.input-group > :not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    margin-left: -1px;
}

.input-group > :not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .input-group-prepend,
.input-group .input-group-append {
    display: flex;
}

.input-group .input-group-prepend .input-group-text {
    border-radius: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.input-group .input-group-prepend > .input-group-text > .btn,
.input-group .input-group-append > .input-group-text > .btn {
    height: 100%;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-color: var(--n-300);
}

/* -------------------------------------------------------------------------
   Campo con icono dentro del borde.
   Sustituye al patrón input-group-prepend de Bootstrap 4, que en BS5 ya no
   existe y dejaba el icono flotando fuera del campo.
   ------------------------------------------------------------------------- */
.campo-icono {
    position: relative;
    display: block;
    width: 100%;
}

.campo-icono > .form-control,
.campo-icono > .form-select {
    padding-left: 38px;
}

.campo-icono > .icono {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 16px;
    height: 16px;
    color: var(--n-500);
    font-size: 13px;
    pointer-events: none;
    transition: color 0.14s ease;
}

/* El icono se acentúa cuando el campo tiene el foco */
.campo-icono:focus-within > .icono {
    color: var(--color-accent);
}

.campo-icono > .form-control:disabled ~ .icono,
.campo-icono > .form-control[readonly] ~ .icono {
    color: var(--n-400);
}

/* Variante buscador: fondo suave, se aclara al enfocar */
.campo-icono.buscador > .form-control {
    background: var(--n-200);
    border-color: transparent;
}

.campo-icono.buscador > .form-control:focus {
    background: var(--color-surface);
    border-color: var(--color-accent);
}

/* Campo con un botón de acción al lado (consultar RENIEC/SUNAT, buscar…) */
.campo-accion {
    display: flex;
    align-items: stretch;
    gap: var(--space-2);
    width: 100%;
}

.campo-accion > .campo-icono,
.campo-accion > .form-control {
    flex: 1 1 auto;
    min-width: 0;
}

.campo-accion > .btn {
    flex: 0 0 auto;
    justify-content: center;
    padding-left: 12px;
    padding-right: 12px;
}

/* Prefijo de texto (S/, %) en vez de icono */
.campo-icono.con-prefijo > .form-control {
    padding-left: 42px;
}

.campo-icono.con-prefijo > .icono {
    width: auto;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--n-600);
}

/* Interruptor limpio (sustituye el checkbox gigante de la plantilla) */
input[type="checkbox"].rb-switch {
    appearance: none;
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: var(--radius-pill);
    background: var(--n-300);
    border: 0;
    cursor: pointer;
    transition: background 0.16s ease;
    flex: 0 0 38px;
}

input[type="checkbox"].rb-switch::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    transition: transform 0.16s ease;
}

input[type="checkbox"].rb-switch:checked {
    background: var(--color-accent);
}

input[type="checkbox"].rb-switch:checked::before {
    transform: translateX(16px);
}

.form-check-input {
    width: 15px;
    height: 15px;
    border: 1px solid var(--n-400);
    background: var(--color-surface);
    border-radius: 4px;
}

.form-check-input:checked {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
}

.form-check-label {
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
    font-weight: 400;
    color: var(--color-text);
}

/* =========================================================================
   6. PANELES / TARJETAS
   ========================================================================= */
.card,
.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-4);
    overflow: hidden;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--color-divider);
    padding: var(--space-3) var(--space-4);
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--n-500);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.card-header h4,
.card-header h5,
.card-header h6 {
    font-size: 13.5px;
    font-weight: 800;
    text-transform: none;
    letter-spacing: -0.01em;
    color: var(--color-text);
    margin: 0;
}

.card-body {
    padding: var(--space-4);
}

.card-footer {
    background: transparent;
    border-top: 1px solid var(--color-divider);
    padding: var(--space-3) var(--space-4);
}

.card-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--color-text);
}

/* Encabezado rico opcional */
.panel-cab {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.panel-cab-icono {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: var(--radius-sm);
    background: var(--a-100);
    color: var(--a-600);
    display: grid;
    place-items: center;
}

.panel-cab-txt {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

/* =========================================================================
   PUNTO DE VENTA — panel de cobro y resumen
   ========================================================================= */
.rb-cobro {
    position: sticky;
    top: calc(var(--alto-topbar) + var(--space-4));
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--n-100);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius);
}

.rb-cobro-acciones {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-divider);
}

/* El total es lo que mira el cajero: tiene que gritar */
.rb-resumen {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-sm);
}

.rb-resumen-items {
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--n-500);
    padding-bottom: var(--space-2);
}

.rb-resumen-fila {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    font-size: 12.5px;
    color: var(--n-600);
    padding: 3px 0;
}

.rb-resumen-fila span:last-child {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--color-text);
}

.rb-resumen-total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-divider);
}

.rb-resumen-total span:first-child {
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--n-500);
}

.rb-resumen-total span:last-child {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

/* La lista de items usa todo el ancho disponible */
#div_carrito table {
    width: 100%;
    table-layout: auto;
}

#div_carrito td,
#div_carrito th {
    vertical-align: middle;
}

/* La descripción manda: es la columna que puede crecer */
#div_carrito td:nth-child(4) {
    min-width: 220px;
    white-space: normal;
}

#div_carrito input[type="number"] {
    width: 100%;
    min-width: 76px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

#div_carrito td:last-child,
#div_carrito th:last-child {
    width: 48px;
    text-align: center;
}

@media (max-width: 991px) {
    .rb-cobro {
        position: static;
    }
}

/* Pestañas de configuración: para secciones largas que no caben en una pantalla */
.tabs-config {
    display: flex;
    gap: var(--space-1);
    flex-wrap: wrap;
    padding: 4px;
    margin-bottom: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius);
}

.tabs-config button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 8px 14px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--n-600);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.tabs-config button:hover {
    background: var(--n-100);
    color: var(--color-text);
}

.tabs-config button.activo {
    background: var(--a-100);
    color: var(--a-600);
    font-weight: 800;
}

.tabs-config button svg {
    color: currentColor;
}

/* Marca de "esta pestaña tiene un error" */
.tabs-config button.con-error::after {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--rojo);
}

.tab-panel[hidden] {
    display: none;
}

/* Barra de guardar fija al pie, solo en pantallas con formulario */
.rb-barra-guardar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-top: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.rb-barra-guardar .rb-barra-guardar-info {
    margin-right: auto;
    font-size: 11.5px;
    color: var(--n-500);
}

/* Barra de acciones de la vista (encima del panel) */
.rb-acciones {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.rb-acciones .rb-espacio {
    margin-left: auto;
}

/* Kicker suelto */
.kicker {
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--n-500);
}

/* =========================================================================
   7. KPIs — banda de celdas iguales
   ========================================================================= */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: var(--space-4);
}

.stat {
    padding: var(--space-4);
    border-right: 1px solid var(--color-divider);
    border-bottom: 1px solid var(--color-divider);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
}

.stat-cab {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.stat-icono {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: var(--radius-sm);
    background: var(--a-100);
    color: var(--a-600);
    display: grid;
    place-items: center;
}

.stat-kicker {
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--n-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-num {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--color-text);
    line-height: 1.1;
}

.stat-detalle {
    font-size: 11.5px;
    color: var(--n-500);
}

.stat-detalle a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    color: var(--a-600);
}

.stat-detalle a:hover {
    color: var(--color-accent);
}

/* =========================================================================
   8. TABLAS
   ========================================================================= */
.table,
table.dataTable {
    width: 100% !important;
    border-collapse: collapse;
    color: var(--color-text);
    margin: 0;
    font-size: 12.5px;
    background: transparent;
    --bs-table-bg: transparent;
    --bs-table-color: var(--color-text);
    --bs-table-striped-bg: var(--n-100);
    --bs-table-striped-color: var(--color-text);
    --bs-table-hover-bg: var(--n-100);
    --bs-table-hover-color: var(--color-text);
    --bs-table-accent-bg: transparent;
}

.table > :not(caption) > * > *,
table.dataTable > :not(caption) > * > * {
    background-color: transparent;
    box-shadow: none;
    color: var(--color-text);
}

.table thead th,
table.dataTable thead th {
    background: var(--n-100);
    color: var(--n-500);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--color-divider);
    white-space: nowrap;
    vertical-align: middle;
}

.table tbody td,
table.dataTable tbody td {
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--n-200);
    vertical-align: middle;
}

.table tbody tr:hover td,
table.dataTable tbody tr:hover td {
    background: var(--n-100);
}

.table tfoot th,
.table tfoot td {
    border-top: 1px solid var(--color-divider);
    background: var(--n-100);
    font-weight: 800;
    font-size: 12px;
    padding: 10px 12px;
}

.table-bordered > :not(caption) > * > * {
    border-width: 0 0 1px 0;
}

.table-sm tbody td,
.table-sm thead th {
    padding: 7px 10px;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

/* Acciones dentro de fila */
.table td .btn {
    margin: 0 2px;
}

/* =========================================================================
   9. DATATABLES
   ========================================================================= */
.dataTables_wrapper {
    font-size: 12.5px;
    color: var(--n-600);
}

.dataTables_wrapper .row {
    align-items: center;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--n-500);
    font-size: 11.5px;
    padding: var(--space-2) 0;
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--n-500);
    margin: 0;
}

.dataTables_wrapper .dataTables_filter {
    text-align: right;
}

.dataTables_wrapper .dataTables_filter label {
    justify-content: flex-end;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background: var(--n-200);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 12.5px;
    font-weight: 400;
    padding: 7px 11px;
    text-transform: none;
    letter-spacing: 0;
}

.dataTables_wrapper .dataTables_filter input {
    min-width: 200px;
}

.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
    background: var(--color-surface);
    border-color: var(--color-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--a-200);
}

.dataTables_wrapper .dataTables_paginate {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-1);
    flex-wrap: wrap;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 9px;
    margin: 0;
    border-radius: 8px;
    border: 1px solid var(--color-divider) !important;
    background: var(--color-surface) !important;
    color: var(--n-600) !important;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--n-100) !important;
    border-color: var(--n-400) !important;
    color: var(--color-text) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--color-accent) !important;
    border-color: var(--color-accent) !important;
    color: #fff !important;
    font-weight: 800;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    opacity: 0.45;
    background: var(--color-surface) !important;
    border-color: var(--color-divider) !important;
    color: var(--n-500) !important;
    cursor: default;
}

.dataTables_wrapper .dt-buttons {
    display: inline-flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.dataTables_wrapper .dt-buttons .dt-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-surface) !important;
    border: 1px solid var(--color-divider) !important;
    border-radius: 8px !important;
    padding: 6px 11px !important;
    margin: 0 !important;
    box-shadow: none !important;
    color: var(--n-700) !important;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.35;
}

.dataTables_wrapper .dt-buttons .dt-button i {
    font-size: 12px;
    color: var(--n-500);
}

.dataTables_wrapper .dt-buttons .dt-button:hover,
.dataTables_wrapper .dt-buttons .dt-button.active {
    border-color: var(--n-400) !important;
    background: var(--n-100) !important;
    color: var(--color-text) !important;
}

.dataTables_wrapper .dt-buttons .dt-button:hover i {
    color: var(--n-700);
}

/* --- Desplegable de columnas (colvis) --- */
div.dt-button-collection {
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: var(--space-1);
    z-index: 2001;
}

div.dt-button-collection > div.dropdown-menu {
    display: block;
    position: static;
    margin: 0;
    padding: 0;
    min-width: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

div.dt-button-collection .dt-button {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    min-width: 190px;
    justify-content: flex-start;
    text-align: left;
    margin: 0 !important;
    padding: 8px 11px !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: var(--n-700) !important;
    font-size: 12.5px;
    font-weight: 600;
    box-shadow: none !important;
}

div.dt-button-collection .dt-button:hover {
    background: var(--n-100) !important;
    color: var(--color-text) !important;
}

/* Columna visible: casilla marcada, nunca texto blanco sobre blanco */
div.dt-button-collection .dt-button.active {
    background: var(--a-100) !important;
    color: var(--a-600) !important;
    font-weight: 800;
}

div.dt-button-collection .dt-button.buttons-columnVisibility::before {
    content: "";
    flex: 0 0 15px;
    width: 15px;
    height: 15px;
    border: 1px solid var(--n-400);
    border-radius: 4px;
    background: var(--color-surface) no-repeat center;
    background-size: 10px 10px;
}

div.dt-button-collection .dt-button.buttons-columnVisibility.active::before {
    border-color: var(--color-accent);
    background-color: var(--color-accent);
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

div.dt-button-collection span.dt-button-spacer {
    display: block;
    height: 1px;
    margin: var(--space-1) 0;
    padding: 0;
    background: var(--color-divider);
    font-size: 0;
}

div.dt-button-collection .dt-button.buttons-colvisRestore {
    color: var(--a-600) !important;
    font-weight: 700;
}

table.dataTable thead .sorting,
table.dataTable thead .sorting_asc,
table.dataTable thead .sorting_desc {
    cursor: pointer;
}

table.dataTable thead th.sorting::after,
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::after,
table.dataTable thead th.sorting::before,
table.dataTable thead th.sorting_asc::before,
table.dataTable thead th.sorting_desc::before {
    color: var(--n-400) !important;
    opacity: 0.7;
}

.dataTables_empty {
    padding: var(--space-8) var(--space-4) !important;
    text-align: center;
    color: var(--n-500);
    font-size: 12.5px;
}

table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before {
    background: var(--color-accent) !important;
    border-color: var(--color-accent) !important;
    box-shadow: none !important;
}

/* =========================================================================
   10. CHIPS, BADGES, AVISOS
   ========================================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 9.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--n-200);
    color: var(--n-700);
    line-height: 1.3;
}

.badge.bg-primary,
.badge.bg-info {
    background: var(--a-100) !important;
    color: var(--a-600) !important;
}

.badge.bg-success {
    background: var(--menta-100) !important;
    color: var(--menta-700) !important;
}

.badge.bg-danger {
    background: var(--rojo-suave) !important;
    color: var(--rojo) !important;
}

.badge.bg-warning {
    background: var(--amb-100) !important;
    color: var(--amb-700) !important;
}

.badge.bg-secondary,
.badge.bg-dark,
.badge.bg-light {
    background: var(--n-200) !important;
    color: var(--n-700) !important;
}

.chip-estado {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    background: var(--n-200);
    color: var(--n-700);
}

.chip-estado::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 7px;
}

.chip-estado.ok {
    background: var(--menta-100);
    color: var(--menta-700);
}

.chip-estado.alerta {
    background: var(--amb-100);
    color: var(--amb-700);
}

.chip-estado.error {
    background: var(--rojo-suave);
    color: var(--rojo);
}

.alert {
    border: 1px solid var(--color-divider);
    border-left-width: 3px;
    border-radius: var(--radius-sm);
    background: var(--n-100);
    color: var(--color-text);
    font-size: 12.5px;
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
}

.alert-info,
.alert-primary {
    background: var(--a-100);
    border-color: var(--color-divider);
    border-left-color: var(--color-accent);
    color: var(--color-text);
}

.alert-success {
    background: var(--menta-100);
    border-left-color: var(--menta-700);
    color: var(--color-text);
}

.alert-danger {
    background: var(--rojo-suave);
    border-left-color: var(--rojo);
    color: var(--color-text);
}

.alert-warning {
    background: var(--amb-100);
    border-left-color: var(--amb-700);
    color: var(--color-text);
}

.vacio {
    text-align: center;
    color: var(--n-500);
    font-size: 12.5px;
    padding: var(--space-8) var(--space-4);
}

/* =========================================================================
   11. MODALES Y DROPDOWNS
   ========================================================================= */
.modal-backdrop {
    background: rgba(9, 14, 25, 0.55);
}

.modal-backdrop.show {
    opacity: 1;
}

.modal-content {
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    color: var(--color-text);
}

.modal-header {
    border-bottom: 1px solid var(--color-divider);
    padding: var(--space-4);
    align-items: center;
}

.modal-title {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.015em;
    color: var(--color-text);
}

.modal-body {
    padding: var(--space-4);
    font-size: 13.5px;
}

.modal-footer {
    border-top: 1px solid var(--color-divider);
    padding: var(--space-3) var(--space-4);
    gap: var(--space-2);
    justify-content: flex-end;
}

.modal-footer > * {
    margin: 0;
}

.btn-close {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-divider);
    background: none;
    opacity: 1;
    position: relative;
}

.btn-close::before,
.btn-close::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 12px;
    height: 1.6px;
    background: var(--n-600);
    border-radius: 2px;
}

.btn-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.btn-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.btn-close:hover {
    background: var(--n-100);
    border-color: var(--n-400);
}

.dropdown-menu {
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: var(--space-1);
    font-size: 13px;
    color: var(--color-text);
    min-width: 190px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 8px 11px;
    border-radius: 8px;
    color: var(--n-700);
    font-size: 12.5px;
    font-weight: 600;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--n-100);
    color: var(--color-text);
}

.dropdown-item.text-danger {
    color: var(--rojo) !important;
}

.dropdown-item.text-danger:hover {
    background: var(--rojo-suave);
}

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

.dropdown-title,
.dropdown-header {
    padding: var(--space-2) 11px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--n-500);
}

/* Pestañas */
.nav-tabs {
    border-bottom: 1px solid var(--color-divider);
    gap: var(--space-1);
}

.nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--n-600);
    font-size: 12.5px;
    font-weight: 700;
    padding: 9px 14px;
}

.nav-tabs .nav-link:hover {
    color: var(--color-text);
    border-bottom-color: var(--n-300);
}

.nav-tabs .nav-link.active {
    background: transparent;
    color: var(--a-600);
    border-bottom-color: var(--color-accent);
    font-weight: 800;
}

/* Paginación Bootstrap */
.page-link {
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    color: var(--n-600);
    font-size: 12px;
    font-weight: 600;
}

.page-link:hover {
    background: var(--n-100);
    border-color: var(--n-400);
    color: var(--color-text);
}

.page-item.active .page-link {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

/* Tooltips */
.tooltip-inner {
    background: var(--n-900);
    color: var(--color-bg);
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 8px;
    padding: 6px 10px;
}

.tooltip .tooltip-arrow::before {
    border-top-color: var(--n-900);
    border-bottom-color: var(--n-900);
    border-left-color: var(--n-900);
    border-right-color: var(--n-900);
}

/* =========================================================================
   12. LIBRERÍAS EXTERNAS (jQuery UI, SweetAlert2)
   ========================================================================= */
.ui-autocomplete {
    z-index: 5000;
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: var(--space-1);
    max-height: 320px;
    overflow-y: auto;
    font-family: var(--font);
    font-size: 12.5px;
}

.ui-autocomplete .ui-menu-item-wrapper,
.ui-autocomplete .ui-menu-item a {
    display: block;
    padding: 8px 11px;
    border-radius: 8px;
    color: var(--n-700);
    border: 0;
    background: transparent;
    font-weight: 600;
}

.ui-autocomplete .ui-menu-item-wrapper.ui-state-active,
.ui-autocomplete .ui-menu-item-wrapper:hover,
.ui-autocomplete .ui-menu-item a.ui-state-active {
    background: var(--a-100);
    color: var(--a-600);
    border: 0;
    margin: 0;
}

.ui-widget-content {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-divider);
}

.swal2-popup {
    background: var(--color-surface) !important;
    border: 1px solid var(--color-divider);
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-md);
    font-family: var(--font) !important;
    font-size: 13.5px !important;
}

.swal2-title {
    color: var(--color-text) !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    letter-spacing: -0.015em;
}

.swal2-html-container,
.swal2-content {
    color: var(--n-600) !important;
    font-size: 13px !important;
}

.swal2-actions {
    gap: var(--space-2);
}

.swal2-styled.swal2-confirm {
    background: var(--color-accent) !important;
    color: #fff !important;
    border-radius: var(--radius-sm) !important;
    font-size: 12.5px !important;
    font-weight: 800 !important;
    padding: 9px 18px !important;
    box-shadow: none !important;
}

.swal2-styled.swal2-cancel {
    background: transparent !important;
    border: 1px solid var(--rojo) !important;
    color: var(--rojo) !important;
    border-radius: var(--radius-sm) !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
    padding: 9px 18px !important;
}

.swal2-input,
.swal2-select,
.swal2-textarea {
    background: var(--color-surface) !important;
    border: 1px solid var(--n-300) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--color-text) !important;
    box-shadow: none !important;
    font-size: 13px !important;
}

.swal2-icon {
    border-color: var(--color-divider);
}

/* =========================================================================
   13. UTILIDADES DE COLOR (remapeo de las de Bootstrap)
   ========================================================================= */
.text-primary,
.text-info {
    color: var(--a-600) !important;
}

.text-danger {
    color: var(--rojo) !important;
}

.text-success {
    color: var(--menta-700) !important;
}

.text-warning {
    color: var(--amb-700) !important;
}

.text-secondary,
.text-muted {
    color: var(--n-500) !important;
}

.text-dark,
.text-body {
    color: var(--color-text) !important;
}

.bg-light {
    background: var(--n-100) !important;
}

.bg-white {
    background: var(--color-surface) !important;
}

.bg-dark {
    background: var(--n-900) !important;
    color: var(--color-bg) !important;
}

.border,
.border-top,
.border-bottom,
.border-start,
.border-end {
    border-color: var(--color-divider) !important;
}

.border-info,
.border-primary {
    border-color: var(--color-divider) !important;
}

.card-header.border-info,
.card-header.border-primary {
    border-bottom-color: var(--color-divider) !important;
}

.shadow,
.shadow-sm {
    box-shadow: var(--shadow-sm) !important;
}

.shadow-lg {
    box-shadow: var(--shadow-md) !important;
}

.rounded {
    border-radius: var(--radius-sm) !important;
}

/* =========================================================================
   14. PORTADA DE ACCESO (login)
   ========================================================================= */
body.rb-login {
    min-height: 100dvh;
    background: var(--color-bg);
}

.rb-portada {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    min-height: 100dvh;
}

/* ---- Panel de marca ---- */
.rb-portada-marca {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--space-8);
    padding: var(--space-8) clamp(32px, 6vw, 80px);
    background: linear-gradient(145deg, var(--marca-fondo-a) 0%, var(--marca-fondo-b) 100%);
    color: var(--marca-texto);
    overflow: hidden;
}

/* Trama sutil para que el degradado no se vea plano */
.rb-portada-marca::after {
    content: "";
    position: absolute;
    right: -18%;
    bottom: -28%;
    width: 65%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.13), transparent 68%);
    pointer-events: none;
}

.rb-portada-marca > * {
    position: relative;
    z-index: 1;
}

/* El logo va sobre una teja clara: no sabemos si el PNG del cliente
   tiene fondo transparente, blanco o de color. */
.rb-logo-teja {
    display: inline-grid;
    place-items: center;
    width: 132px;
    height: 132px;
    padding: var(--space-4);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 10px 30px rgba(8, 18, 48, 0.28);
}

.rb-logo-teja img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.rb-portada-nombre {
    font-size: clamp(26px, 3.2vw, 38px);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-top: var(--space-6);
    color: var(--marca-texto);
}

.rb-portada-razon {
    margin-top: var(--space-2);
    font-size: 13px;
    color: var(--marca-texto-tenue);
}

.rb-portada-puntos {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin-top: var(--space-8);
    padding: 0;
    list-style: none;
}

.rb-portada-puntos li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--marca-texto);
}

.rb-portada-puntos .punto-icono {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.14);
    color: var(--marca-texto);
}

.rb-portada-puntos b {
    display: block;
    font-weight: 700;
}

.rb-portada-puntos span.detalle {
    color: var(--marca-texto-tenue);
    font-size: 12.5px;
}

.rb-portada-pie {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-6);
    font-size: 11.5px;
    color: var(--marca-texto-tenue);
}

.rb-portada-pie span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ---- Panel de acceso ---- */
.rb-portada-acceso {
    display: grid;
    place-items: center;
    padding: var(--space-6);
    background: var(--color-bg);
}

.rb-login-card {
    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-6);
}

/* En pantallas cortas o móviles la portada se apila y la marca se comprime */
@media (max-width: 900px) {
    .rb-portada {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .rb-portada-marca {
        padding: var(--space-6);
        gap: var(--space-6);
    }

    .rb-portada-marca::after {
        display: none;
    }

    .rb-portada-puntos,
    .rb-portada-pie {
        display: none;
    }

    .rb-logo-teja {
        width: 92px;
        height: 92px;
        padding: var(--space-3);
    }

    .rb-portada-nombre {
        margin-top: var(--space-4);
        font-size: 22px;
    }

    .rb-portada-acceso {
        padding: var(--space-6) var(--space-4) var(--space-8);
    }
}

.rb-login-marca {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.rb-login-marca .rb-marca-caja {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    font-size: 15px;
    border-radius: var(--radius-sm);
}

.rb-login-titulo {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

.rb-login-micro {
    font-size: 11.5px;
    color: var(--n-500);
}

.rb-login-pie {
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    font-size: 11px;
    color: var(--n-500);
}

/* =========================================================================
   14.b MOTOR CRUD ASÍNCRONO (toasts, modal Alpine, paginación)
   ========================================================================= */
[x-cloak] {
    display: none !important;
}

.rb-toasts {
    position: fixed;
    right: var(--space-6);
    bottom: var(--space-6);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}

.rb-toast {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    max-width: 360px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: var(--n-900);
    color: var(--color-bg);
    box-shadow: var(--shadow-md);
    font-size: 12.5px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.rb-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.rb-toast-icono {
    display: grid;
    place-items: center;
    flex: 0 0 15px;
}

.rb-toast.ok .rb-toast-icono {
    color: var(--menta-700);
}

.rb-toast.error .rb-toast-icono {
    color: var(--rojo);
}

/* Modal propio del motor async (no depende del JS de Bootstrap) */
.rb-modal-velo {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: grid;
    place-items: center;
    padding: var(--space-4);
    background: rgba(9, 14, 25, 0.55);
    overflow-y: auto;
}

.rb-modal {
    width: 100%;
    max-width: 480px;
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.rb-modal-ancho {
    max-width: 760px;
}

.rb-modal-cab {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-divider);
}

.rb-modal-titulo {
    flex: 1 1 auto;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.015em;
}

.rb-modal-cuerpo {
    padding: var(--space-4);
}

.rb-modal-pie {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--color-divider);
}

/* Rejilla de campos dentro del modal */
.rb-campos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: var(--space-3);
}

.rb-campos .rb-ancho-total {
    grid-column: 1 / -1;
}

/* Barra de listado: buscador + acciones */
.rb-barra {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}

.rb-buscador {
    position: relative;
    flex: 1 1 260px;
    max-width: 360px;
}

.rb-buscador input {
    width: 100%;
    padding-left: 34px;
    background: var(--n-200);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 13px;
    padding-top: 9px;
    padding-bottom: 9px;
    padding-right: 12px;
}

.rb-buscador input:focus {
    background: var(--color-surface);
    border-color: var(--color-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--a-200);
}

.rb-buscador .rb-buscador-icono {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--n-500);
    display: grid;
    place-items: center;
    pointer-events: none;
}

/* Pie de tabla: conteo + paginación */
.rb-paginacion {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding-top: var(--space-3);
    margin-top: var(--space-3);
    border-top: 1px solid var(--color-divider);
    font-size: 11.5px;
    color: var(--n-500);
}

.rb-paginacion-botones {
    display: flex;
    gap: var(--space-2);
}

/* =========================================================================
   15. CARGA
   ========================================================================= */
.rb-cargando {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    background: var(--color-bg);
    transition: opacity 0.25s ease;
}

.rb-cargando.oculto {
    opacity: 0;
    pointer-events: none;
}

.rb-spinner {
    width: 26px;
    height: 26px;
    border: 2.5px solid var(--n-300);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: rb-giro 0.7s linear infinite;
}

@keyframes rb-giro {
    to {
        transform: rotate(360deg);
    }
}

.skeleton {
    background: var(--n-200);
    border-radius: var(--radius-sm);
    animation: rb-pulso 1.4s ease-in-out infinite;
}

@keyframes rb-pulso {
    0%,
    100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* =========================================================================
   16. RESPONSIVE
   ========================================================================= */
@media (max-width: 1279px) {
    .rb-main {
        padding: var(--space-4);
    }
}

@media (max-width: 860px) {
    .rb-shell,
    body.sidebar-mini .rb-shell {
        grid-template-columns: 1fr;
    }

    .rb-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--ancho-sidebar);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow-md);
    }

    body.sidebar-abierto .rb-sidebar {
        transform: translateX(0);
    }

    /* En móvil el sidebar se despliega completo, nunca en rail */
    body.sidebar-mini .rb-marca-txt,
    body.sidebar-mini .rb-nav-txt,
    body.sidebar-mini .rb-nav-caret,
    body.sidebar-mini .rb-nav-kicker,
    body.sidebar-mini .rb-usuario-txt {
        display: initial;
    }

    body.sidebar-mini .rb-nav-item {
        justify-content: flex-start;
        padding: 9px var(--space-3);
    }

    body.sidebar-mini .rb-marca {
        justify-content: flex-start;
        padding: 0 var(--space-4);
    }

    body.sidebar-mini .rb-sidebar-pie {
        flex-direction: row;
        padding: var(--space-3);
    }

    body.sidebar-mini .rb-submenu {
        padding-left: 30px;
    }

    body.sidebar-mini .rb-submenu::before {
        display: block;
    }

    body.sidebar-mini .rb-sub-item {
        text-align: left;
        font-size: 12.5px;
        padding: 7px var(--space-3);
    }

    .rb-velo {
        position: fixed;
        inset: 0;
        background: rgba(9, 14, 25, 0.5);
        z-index: 35;
        display: none;
    }

    body.sidebar-abierto .rb-velo {
        display: block;
    }

    .rb-topbar {
        padding: 0 var(--space-4);
    }

    .rb-lema {
        display: none;
    }

    .rb-main {
        padding: var(--space-3);
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat {
        padding: var(--space-3);
    }

    .stat-num {
        font-size: 20px;
    }

    .card-body {
        padding: var(--space-3);
    }

    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive > table {
        min-width: 560px;
    }

    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_filter label {
        text-align: left;
        justify-content: flex-start;
    }

    .dataTables_wrapper .dataTables_paginate {
        justify-content: center;
    }

    .modal-dialog {
        margin: var(--space-3);
    }
}
