
/* ================================================================
   RESET & BASE
   ================================================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
}

h1:focus {
    outline: none;
}

/* ================================================================
   THEME VARIABLES
   Clases aplicadas en .app-shell por ThemeService
   ================================================================ */

/* -- Azul (default) -- */
.theme-blue {
    --c-primary: #1565C0;
    --c-primary-dark: #0D47A1;
    --c-primary-text: #ffffff;
    --c-topbar-bg: #1565C0;
    --c-topbar-text: #ffffff;
    --c-sidebar-bg: #E3F2FD;      /* Blue 50 � m�s claro que el contenido */
    --c-sidebar-text: #0D47A1;   /* Blue 900 */
    --c-sidebar-hover: #90CAF9;  /* Blue 200 */
    --c-sidebar-active: #1565C0;
    --c-bg: #BBDEFB;             /* Blue 100 � contenido, un tono m�s fuerte */
    --c-surface: #E3F2FD;        /* Blue 50 � cards/panels */
    --c-border: #90CAF9;         /* Blue 200 */
    --c-text: #0D47A1;           /* Blue 900 � igual que sidebar text */
    --c-text-muted: #1565C0;     /* Blue 800 */
}

/* -- Rojo -- */
.theme-red {
    --c-primary: #C62828;
    --c-primary-dark: #B71C1C;
    --c-primary-text: #ffffff;
    --c-topbar-bg: #C62828;
    --c-topbar-text: #ffffff;
    --c-sidebar-bg: #FFEBEE;     /* Red 50 � m�s claro */
    --c-sidebar-text: #B71C1C;   /* Red 900 */
    --c-sidebar-hover: #EF9A9A;  /* Red 200 */
    --c-sidebar-active: #C62828;
    --c-bg: #FFCDD2;             /* Red 100 � contenido, un tono m�s fuerte */
    --c-surface: #FFEBEE;        /* Red 50 � cards/panels */
    --c-border: #EF9A9A;         /* Red 200 */
    --c-text: #B71C1C;           /* Red 900 � igual que sidebar text */
    --c-text-muted: #C62828;     /* Red 800 */
}

/* -- Oscuro -- */
.theme-dark {
    --c-primary: #455A64;
    --c-primary-dark: #263238;
    --c-primary-text: #ECEFF1;
    --c-topbar-bg: #263238;
    --c-topbar-text: #ECEFF1;
    --c-sidebar-bg: #37474F;
    --c-sidebar-text: #ECEFF1;    /* blanco */
    --c-sidebar-hover: #455A64;
    --c-sidebar-active: #546E7A;
    --c-bg: #1C2327;
    --c-surface: #263238;
    --c-border: #37474F;
    --c-text: #ECEFF1;
    --c-text-muted: #90A4AE;
}

/* ================================================================
   SHELL PRINCIPAL
   ================================================================ */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background-color: var(--c-bg, #F5F7FA);
    color: var(--c-text, #212121);
}

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative; /* necesario para sidebar overlay en mobile */
}

.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background-color: var(--c-bg, #F5F7FA);
}

/* ================================================================
   TOPBAR
   ================================================================ */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 16px;
    background-color: var(--c-topbar-bg, #1565C0);
    color: var(--c-topbar-text, #fff);
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
    z-index: 100;
    flex-shrink: 0;
}

.topbar__brand {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: .04em;
    margin-right: 24px;
    white-space: nowrap;
}

.topbar__left {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    overflow: visible;
    min-width: 0;
}

.topbar__menus {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.topbar__right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Grupos de men� superior */
.topbar__group {
    position: relative;
}

.topbar__group-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: var(--c-topbar-text, #fff);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: background .15s;
}

    /* Los spans dentro del bot�n del topbar heredan el color blanco */
    .topbar__group-btn span,
    .topbar__brand,
    .topbar__user { color: var(--c-topbar-text, #fff) !important; }

    .topbar__group-btn:hover,
    .topbar__group--open .topbar__group-btn {
        background: rgba(255,255,255,.18);
    }

.topbar__caret {
    font-size: 10px;
    opacity: .8;
}

/* Backdrop para cerrar dropdown al click fuera (z-index entre contenido y dropdown) */
.topbar__backdrop {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 150;
    cursor: default;
    background: transparent;
}

.topbar__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    background: var(--c-surface, #fff);
    border: 1px solid var(--c-border, #CFD8DC);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0,0,0,.15);
    z-index: 200;
    overflow: hidden;
}

.topbar__dropdown-item {
    display: block;
    padding: 8px 16px;
    color: var(--c-text, #212121) !important;
    text-decoration: none !important;
    font-size: 13px;
    transition: background .12s;
}

    .topbar__dropdown-item:hover,
    .topbar__dropdown-item.active {
        background: var(--c-sidebar-hover, #BBDEFB);
        color: var(--c-primary, #1565C0) !important;
    }

/* Derecha del topbar */
.topbar__theme-select {
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.35);
    color: var(--c-topbar-text, #fff);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 12px;
    cursor: pointer;
}

    .topbar__theme-select option {
        color: #212121;
        background: #fff;
    }

.topbar__user {
    font-size: 13px;
    opacity: .9;
    white-space: nowrap;
}

.topbar__logout {
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.4);
    color: var(--c-topbar-text, #fff);
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}

    .topbar__logout:hover {
        background: rgba(255,255,255,.3);
    }

/* ================================================================
   SIDEBAR
   ================================================================ */

/* Rail = contenedor flex que agrupa aside + toggle-tab */
.sidebar-rail {
    display: flex;
    align-items: flex-start;
    flex-shrink: 0;
    position: relative;
    height: 100%;
}

.sidebar {
    width: 220px;
    min-width: 220px;
    background-color: var(--c-sidebar-bg, #E3F2FD);
    border-right: 1px solid var(--c-border, #CFD8DC);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width .2s, min-width .2s, border .2s;
    flex-shrink: 0;
    height: 100%;
}

/* Al colapsar: ancho 0, contenido oculto, sin borde */
.sidebar--collapsed {
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden !important;
    border: none !important;
}

/* Toggle-tab: hermano del aside, pegado a su borde derecho */
.sidebar__toggle {
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 12px;
    background: var(--c-sidebar-bg, #E3F2FD);
    border: 1px solid var(--c-border, #CFD8DC);
    border-left: none;
    border-radius: 0 6px 6px 0;
    color: var(--c-sidebar-text, #0D47A1);
    cursor: pointer;
    width: 18px;
    height: 40px;
    font-size: 11px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    z-index: 1;
}

    .sidebar__toggle:hover {
        background: var(--c-sidebar-hover, #BBDEFB);
    }

.sidebar__nav {
    padding: 4px 0 12px;
}

.sidebar__group {
    margin-bottom: 4px;
}

.sidebar__group-label {
    display: block;
    padding: 6px 14px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--c-text-muted, #607D8B);
}

.sidebar__link {
    display: block;
    padding: 7px 14px 7px 20px;
    color: var(--c-sidebar-text, #0D47A1);
    text-decoration: none;
    border-left: 3px solid transparent;
    font-size: 13px;
    transition: background .12s, border-color .12s;
}

    .sidebar__link:hover {
        background: var(--c-sidebar-hover, #BBDEFB);
        color: var(--c-primary, #1565C0);
    }

    .sidebar__link.active {
        background: var(--c-sidebar-hover, #BBDEFB);
        border-left-color: var(--c-sidebar-active, #1565C0);
        font-weight: 600;
        color: var(--c-primary, #1565C0);
    }

/* ================================================================
   CONTENEDOR DE P�GINAS
   ================================================================ */
.page-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--c-surface, #fff);
    border-bottom: 1px solid var(--c-border, #CFD8DC);
    flex-shrink: 0;
}

.page-toolbar__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--c-text, #212121);
}

.page-toolbar__actions {
    display: flex;
    gap: 8px;
}

/* ================================================================
   P�GINA DE LOGIN  �  r�plica fiel del Acceso.xaml WPF
   ================================================================ */

/* Contenedor ra�z de la p�gina login: full-screen y posici�n relativa */
.login-page {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    display: flex;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 24px 0;
}

/* ?? Fondo con slideshow de 3 im�genes (igual al Storyboard WPF) ?? */
.login-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
}

.login-bg__img {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0;
}

.login-bg__img--1 {
    background-image: url('../images/IMG_0016.JPG');
    animation: slide1 15s infinite;
}

.login-bg__img--2 {
    background-image: url('../images/IMG_0017.JPG');
    animation: slide2 15s infinite;
}

.login-bg__img--3 {
    background-image: url('../images/IMG_0019.JPG');
    animation: slide3 15s infinite;
}

/* Timings que replican el Storyboard WPF (15s total):
   Img1: 0-4s visible, 4-5s fade out, 14-15s fade in
   Img2: 4-5s fade in, 5-9s visible, 9-10s fade out
   Img3: 9-10s fade in, 10-14s visible, 14-15s fade out          */
@keyframes slide1 {
    0%, 26.7% {
        opacity: 1;
    }

    33.3%, 93.3% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

@keyframes slide2 {
    0%, 26.7% {
        opacity: 0;
    }

    33.3%, 60% {
        opacity: 1;
    }

    66.7%, 100% {
        opacity: 0;
    }
}

@keyframes slide3 {
    0%, 60% {
        opacity: 0;
    }

    66.7%, 93.3% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Overlay oscuro semi-transparente (igual a #66000000 del WPF) */
.login-bg__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.40);
}

/* ?? Card del login � izquierda, igual al WPF ?? */
.login-card {
    position: relative;
    z-index: 10;
    width: 323px;
    margin-left: 32px;
    background: rgba(245, 255, 255, 0.97);
    border-radius: 20px;
    padding: 30px 35px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.30);
    display: flex;
    flex-direction: column;
}

@media (max-width: 576px) {
    .login-card {
        width: calc(100% - 32px);
        max-width: 380px;
        margin-left: auto;
        margin-right: auto;
        padding: 24px 20px;
    }
}

.login-card__header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.login-card__logo {
    width: 208px;
    height: 109px;
    object-fit: contain;
    margin-bottom: 5px;
}

.login-card__title {
    font-size: 26px;
    font-weight: 700;
    color: #212529;
    margin: 0 0 3px;
    text-align: center;
}

.login-card__subtitle {
    font-size: 13px;
    color: #6c757d;
    margin: 0;
    text-align: center;
}

/* ?? Campos del formulario ?? */
.login-field {
    margin-bottom: 12px;
}

.login-field__label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #212529;
    margin-bottom: 4px;
}

.login-field__icon {
    font-size: 14px;
}

/* Input base */
.login-input {
    display: block;
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    border: 2px solid #ced4da;
    border-radius: 8px;
    background: #ffffff;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}

    .login-input:focus {
        border-color: #86b7fe;
        box-shadow: 0 0 0 3px rgba(13, 110, 253, .15);
    }

/* Validaci�n en tiempo real (id�ntica al color del WPF) */
.login-input--valid {
    border-color: #198754 !important;
}

.login-input--invalid {
    border-color: #dc3545 !important;
}

/* Mensaje de error por campo */
.login-field__error {
    display: block;
    margin-top: 3px;
    margin-left: 5px;
    font-size: 11px;
    color: #dc3545;
}

/* ?? Wrap del campo contrase�a (input + bot�n toggle) ?? */
.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

    .login-input-wrap .login-input {
        padding-right: 40px;
    }

.login-input-wrap__toggle {
    position: absolute;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    color: #0c0c0c;
}

    .login-input-wrap__toggle:hover {
        opacity: .7;
    }

/* ?? Bot�n principal de login ?? */
.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 42px;
    margin-top: 10px;
    background: #0d6efd;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}

    .login-btn:hover:not(:disabled) {
        background: #0b5ed7;
    }

    .login-btn:disabled {
        background: #6c757d;
        opacity: .6;
        cursor: not-allowed;
    }

/* ?? Caja de error general ?? */
.login-error-box {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 12px;
    padding: 10px 12px;
    background: #f8d7da;
    border: 1px solid #f5c2c7;
    border-radius: 6px;
    font-size: 13px;
    color: #842029;
    line-height: 1.4;
}


/* ================================================================
   MODAL DE B�SQUEDA
   ================================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn .15s ease;
}

/* .modal-dialog eliminado � cada tipo de modal usa su propia clase Bootstrap (modal-sm, modal-lg) + estilos inline */

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--c-primary, #1565C0);
    color: var(--c-primary-text, #fff);
    border-radius: 8px 8px 0 0;
}

    .modal-header .modal-title {
        margin: 0;
        font-size: 1rem;
        font-weight: 600;
        color: aliceblue;
    }

    .modal-header .btn-close {
        filter: invert(1);
    }

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--c-border, #CFD8DC);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ================================================================
   FORMULARIO � CARD OVERRIDE PARA TEMAS
   ================================================================ */
/* ?? Contenido principal: garantiza fondo de tema pese a scoped CSS ?? */
.theme-dark .app-content,
.theme-dark main {
    background-color: var(--c-bg) !important;
}

/* ?? Texto gen�rico ?? */
.theme-dark h1, .theme-dark h2, .theme-dark h3,
.theme-dark h4, .theme-dark h5, .theme-dark h6 { color: var(--c-text); }
.theme-dark label, .theme-dark .form-label,
.theme-dark .col-form-label { color: var(--c-text); }
.theme-dark .text-muted { color: var(--c-text-muted) !important; }

/* ?? Cards ?? */
.theme-dark .card {
    background-color: var(--c-surface);
    border-color: var(--c-border);
    color: var(--c-text);
}
.theme-dark .card-header {
    background-color: var(--c-sidebar-bg);
    border-bottom-color: var(--c-border);
    color: var(--c-text);
}
.theme-dark .card-body { background-color: var(--c-surface); color: var(--c-text); }
.theme-dark .card-footer {
    background-color: var(--c-sidebar-bg);
    border-top-color: var(--c-border);
    color: var(--c-text);
}

/* ?? Formularios ?? */
.theme-dark .form-control,
.theme-dark .form-select {
    background-color: var(--c-bg) !important;
    border-color: var(--c-border) !important;
    color: var(--c-text) !important;
}
.theme-dark .form-control:focus,
.theme-dark .form-select:focus {
    background-color: var(--c-bg) !important;
    border-color: var(--c-primary) !important;
    color: var(--c-text) !important;
    box-shadow: 0 0 0 .25rem rgba(69,90,100,.4);
}
.theme-dark .form-control:disabled,
.theme-dark .form-control[readonly],
.theme-dark .form-select:disabled {
    background-color: var(--c-sidebar-bg) !important;
    color: var(--c-text-muted) !important;
}
.theme-dark .form-control::placeholder { color: var(--c-text-muted) !important; opacity: .8; }
.theme-dark .input-group-text {
    background-color: var(--c-sidebar-bg);
    border-color: var(--c-border);
    color: var(--c-text);
}
.theme-dark .form-check-input {
    background-color: var(--c-bg);
    border-color: var(--c-border);
}

/* ?? Tablas ?? */
.theme-dark .table {
    color: var(--c-text);
    border-color: var(--c-border);
    --bs-table-color: var(--c-text);
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255,255,255,.03);
    --bs-table-hover-bg: var(--c-sidebar-hover);
    --bs-table-hover-color: var(--c-text);
    --bs-table-border-color: var(--c-border);
}
.theme-dark .table > :not(caption) > * { border-color: var(--c-border); }
.theme-dark .table > :not(caption) > * > * { background-color: transparent; color: var(--c-text); }
.theme-dark .table-light,
.theme-dark .table thead th {
    background-color: var(--c-sidebar-bg) !important;
    color: var(--c-text) !important;
    --bs-table-bg: var(--c-sidebar-bg);
    --bs-table-color: var(--c-text);
}
.theme-dark .table-hover > tbody > tr:hover > * {
    background-color: var(--c-sidebar-hover);
    color: var(--c-text);
}

/* ?? Page toolbar ?? */
.theme-dark .page-toolbar__title { color: var(--c-text); }

/* Modificaciones de orden � refuerzo tema oscuro (scoped + variables) */
.theme-dark .mo-panel__badge {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.14) !important;
    border-color: rgba(255, 255, 255, 0.38) !important;
}

/* ?? Sidebar: hover/active en dark � --c-primary == --c-sidebar-hover ? texto invisible ?? */
.theme-dark .sidebar__link:hover,
.theme-dark .sidebar__link.active {
    color: var(--c-sidebar-text) !important;   /* #ECEFF1 � blanco sobre fondo oscuro */
}

/* ?? Topbar dropdown: mismo problema en dark ?? */
.theme-dark .topbar__dropdown-item:hover,
.theme-dark .topbar__dropdown-item.active {
    background: var(--c-sidebar-hover);
    color: var(--c-sidebar-text) !important;   /* #ECEFF1 � legible sobre #455A64 */
}

/* ?? Card headers con bg-light: fondo claro ? texto oscuro para que sea legible ?? */
.theme-dark .card-header.bg-light {
    color: #1C2327 !important;
}
.theme-dark .card-header.bg-light h1,
.theme-dark .card-header.bg-light h2,
.theme-dark .card-header.bg-light h3,
.theme-dark .card-header.bg-light h4,
.theme-dark .card-header.bg-light h5,
.theme-dark .card-header.bg-light h6 {
    color: #1C2327 !important;
}

/* ?? Modal ?? */
.theme-dark .modal-content {
    background-color: var(--c-surface);
    border-color: var(--c-border);
    color: var(--c-text);
}
.theme-dark .modal-header { border-bottom-color: var(--c-border); }
.theme-dark .modal-body { background-color: var(--c-surface); }
.theme-dark .modal-footer { background-color: var(--c-surface); border-top-color: var(--c-border); }

/* ?? Miscel�nea ?? */
.theme-dark hr { border-color: var(--c-border); }
.theme-dark .list-group-item {
    background-color: var(--c-surface);
    border-color: var(--c-border);
    color: var(--c-text);
}

/* ================================================================
   OVERRIDES BOOTSTRAP � TEMAS AZUL Y ROJO
   ================================================================ */
.theme-blue label, .theme-blue .form-label,
.theme-red  label, .theme-red  .form-label { color: var(--c-text); }

.theme-blue h1,.theme-blue h2,.theme-blue h3,.theme-blue h4,.theme-blue h5,.theme-blue h6,
.theme-red  h1,.theme-red  h2,.theme-red  h3,.theme-red  h4,.theme-red  h5,.theme-red  h6 { color: var(--c-text); }

.theme-blue p, .theme-blue .app-content span, .theme-blue .sidebar-rail span,
.theme-red  p, .theme-red  .app-content span, .theme-red  .sidebar-rail span { color: var(--c-text); }

.theme-blue .form-control, .theme-blue .form-select,
.theme-red  .form-control, .theme-red  .form-select {
    background-color: #ffffff !important;      /* blanco: contrasta con el surface del card */
    border-color: var(--c-border) !important;
    color: var(--c-text) !important;
}
.theme-blue .form-control:focus, .theme-blue .form-select:focus,
.theme-red  .form-control:focus, .theme-red  .form-select:focus {
    background-color: #ffffff !important;
    border-color: var(--c-primary) !important;
    color: var(--c-text) !important;
    box-shadow: 0 0 0 .2rem rgba(0,0,0,.08);
}
.theme-blue .form-control:disabled,
.theme-blue .form-control[readonly],
.theme-red  .form-control:disabled,
.theme-red  .form-control[readonly] {
    background-color: var(--c-bg) !important;  /* tono del tema � distingue campo readonly */
    color: var(--c-text) !important;
    opacity: .85;
}
.theme-blue .form-control::placeholder, .theme-red .form-control::placeholder {
    color: var(--c-text-muted) !important;
    opacity: .65;
}
.theme-blue .input-group-text, .theme-red .input-group-text {
    background-color: var(--c-bg);
    border-color: var(--c-border);
    color: var(--c-text);
}
.theme-blue .form-check-input, .theme-red .form-check-input {
    background-color: #ffffff;
    border-color: var(--c-primary);
}

.theme-blue .card, .theme-red .card {
    background-color: var(--c-surface);
    border-color: var(--c-border);
    color: var(--c-text);
}
.theme-blue .card-header, .theme-red .card-header {
    background-color: var(--c-sidebar-bg);
    border-bottom-color: var(--c-border);
    color: var(--c-text);
}

.theme-blue .table, .theme-red .table {
    color: var(--c-text);
    --bs-table-color: var(--c-text);
    --bs-table-border-color: var(--c-border);
}

.theme-blue .modal-content, .theme-red .modal-content {
    background-color: var(--c-surface);
    border-color: var(--c-border);
    color: var(--c-text);
}
.theme-blue .modal-header, .theme-red .modal-header { border-bottom-color: var(--c-border); }
.theme-blue .modal-footer, .theme-red .modal-footer { border-top-color: var(--c-border); }

.theme-blue .list-group-item, .theme-red .list-group-item {
    background-color: var(--c-surface);
    border-color: var(--c-border);
    color: var(--c-text);
}

.theme-blue .page-toolbar, .theme-red .page-toolbar {
    background: var(--c-surface);
    border-bottom-color: var(--c-border);
}
.theme-blue .page-toolbar__title, .theme-red .page-toolbar__title { color: var(--c-text); }

/* ================================================================
   RESPONSIVE � MOBILE ( ? 767 px )
   ================================================================ */
@media (max-width: 767px) {
    /* Ocultar men�s din�micos del topbar; s�lo queda brand + derecha */
    .topbar__menus { display: none !important; }

    .topbar {
        flex-wrap: nowrap;
        align-items: center;
        height: 56px;
        min-height: 56px;
        padding: 0 8px;
        gap: 6px;
    }

    .topbar__left {
        flex: 0 1 auto;
        min-width: 0;
        overflow: hidden;
    }

    .topbar__brand {
        margin-right: 0;
        font-size: 0.9rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar__right {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-end;
        gap: 4px;
    }

    .topbar__theme-select {
        flex: 0 1 auto;
        min-width: 0;
        max-width: 7.5rem;
        font-size: 10px;
        padding: 3px 4px;
    }

    .topbar__user {
        flex: 0 1 auto;
        min-width: 0;
        max-width: 5.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 11px;
        white-space: nowrap;
    }

    .topbar__logout {
        flex: 0 0 auto;
        margin-left: 0;
        padding: 3px 8px;
        font-size: 11px;
    }

    .sidebar-rail {
        position: absolute;
        z-index: 500;
        height: 100%;
        top: 0;
        left: 0;
    }

    .sidebar--collapsed {
        pointer-events: none;
    }

    .sidebar__toggle {
        margin-top: 8px;
    }

    .cot-toolbar {
        display: grid;
        grid-template-columns: 1fr;
        gap: 6px;
        justify-content: start;
        align-content: start;
        align-items: start;
    }

    .cot-toolbar__head {
        flex: none;
        width: 100%;
    }

    .cot-toolbar__panel {
        display: contents;
    }

    .cot-toolbar__status {
        display: flex;
        justify-content: center;
        width: 100%;
    }

    .cot-toolbar__actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
        width: 100%;
    }
}

/* ================================================================
   ANIMACIONES
   ================================================================ */
@keyframes fadeIn {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0
    }

    to {
        transform: translateY(0);
        opacity: 1
    }
}

/* ================================================================
   VALIDACI�N BLAZOR
   ================================================================ */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e53935;
}

/* ================================================================
   SCROLLBAR PERSONALIZADO
   ================================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--c-border, #CFD8DC);
    border-radius: 3px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--c-text-muted, #607D8B);
    }

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

/* ===== APP LOADER (initial - before Blazor renders) ===== */
.app-loader {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #f2f2f2;
    color: #333;
    font-family: 'Inter', system-ui, sans-serif;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
}

    .app-loader.hidden {
        opacity: 0;
        pointer-events: none;
        transition: opacity 220ms ease-out;
    }

/* ===== SPINNER/LOADER ===== */
.spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(0, 0, 0, 0.08);
    border-top-color: #57b846;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.loader-text {
    margin-top: 1rem;
    font-size: 0.95rem;
    opacity: 0.85;
    letter-spacing: 0.03em;
    color: #333;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ================================================================
   HOME PAGE
   ================================================================ */
.home-bg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 56px);
    padding: 2rem;
    background-color: var(--c-bg, #F5F7FA);
}

.home-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
    max-width: 480px;
    width: 100%;
}

.home-logo {
    width: clamp(100px, 25vw, 200px);
    height: auto;
    object-fit: contain;
}

.home-title {
    font-size: clamp(1.2rem, 3vw, 1.75rem);
    font-weight: 700;
    color: var(--c-text, #1f2937);
    margin: 0;
}

.home-subtitle {
    font-size: clamp(0.82rem, 2vw, 0.95rem);
    color: var(--c-text-muted, #607D8B);
    margin: 0;
}
.topbar {
    z-index: 9999;
}

/* -- QUILL EDITOR � imagen resizable -------------------- */
.quill-wrapper {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
}

.quill-wrapper .ql-toolbar {
    border: none;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.quill-wrapper .ql-container {
    border: none;
    font-family: inherit;
    font-size: 13px;
}

.quill-wrapper .ql-editor img {
    cursor: pointer;
    max-width: 100%;
}

.quill-wrapper .ql-editor img:hover {
    outline: 2px solid #1565C0;
    outline-offset: 2px;
}

.ql-img-handle {
    box-shadow: 0 1px 4px rgba(0,0,0,.35);
    transition: transform .1s;
}

.ql-img-handle:hover {
    transform: scale(1.3);
}

/* ── TOOLBAR (global — cotizaciones, inventario, normas) ── */
.cot-header__icon {
    font-size: 2rem;
    line-height: 1;
}

.cot-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    background: var(--c-surface, #fff);
    border: 1px solid var(--c-border, #CFD8DC);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    overflow: hidden;
    max-width: 100%;
}

.cot-toolbar__head {
    flex: 1 1 200px;
    min-width: 0;
}

.cot-toolbar__title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.cot-toolbar__title-text {
    min-width: 0;
}

.cot-toolbar__title-text h4 {
    font-size: clamp(0.95rem, 3.2vw, 1.25rem);
    line-height: 1.2;
    word-break: break-word;
}

.cot-toolbar__panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 1 1 260px;
    min-width: 0;
    max-width: 100%;
}

.cot-toolbar__status {
    flex: 0 0 auto;
}

.cot-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
}

.cot-toolbar__btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 64px;
    padding: 6px 10px;
    border: 1px solid var(--c-border, #CFD8DC);
    border-radius: 6px;
    background: var(--c-bg, #E3F2FD);
    color: var(--c-text, #0D47A1);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}

.cot-toolbar__btn:hover:not(:disabled) {
    background: var(--c-primary, #1565C0);
    color: #fff;
    border-color: var(--c-primary, #1565C0);
}

.cot-toolbar__btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cot-toolbar__btn--primary {
    background: var(--c-primary, #1565C0);
    color: #fff;
    border-color: var(--c-primary, #1565C0);
}

.cot-toolbar__btn--primary:hover:not(:disabled) {
    background: #0d47a1;
    border-color: #0d47a1;
    color: #fff;
}

.cot-toolbar__btn--primary:disabled {
    opacity: 0.55;
}

.cot-toolbar__icon {
    font-size: 1.4rem;
    line-height: 1;
}

.cot-toolbar__btn--primary .cot-toolbar__icon,
.cot-toolbar__btn--primary .spinner-border {
    color: #fff;
}

.theme-dark .cot-toolbar {
    background: var(--c-surface, #37474F);
    border-color: #546E7A;
}

.theme-dark .cot-toolbar__btn {
    background: #455A64;
    border-color: #546E7A;
    color: #ECEFF1;
}

.theme-dark .cot-toolbar__btn:hover:not(:disabled) {
    background: var(--c-primary, #546E7A);
    color: #fff;
}

.theme-dark .cot-toolbar__btn--primary {
    background: var(--c-primary, #546E7A);
    color: #fff;
    border-color: #546E7A;
}

@media (max-width: 576px) {
    .cot-toolbar__btn {
        min-width: 52px;
        padding: 5px 6px;
        font-size: 10px;
    }

    .cot-toolbar__icon {
        font-size: 1.15rem;
    }

    .cot-toolbar__status .badge {
        font-size: 0.8rem !important;
        padding: 0.35rem 0.65rem !important;
    }

    .topbar__brand {
        font-size: 0.8rem;
    }

    .topbar__theme-select {
        max-width: 6.5rem;
    }

    .topbar__user {
        max-width: 4.5rem;
    }
}