:root {
    --sidebar: #17233b;
    --sidebar-soft: #223251;
    --primary: #3157d5;
    --primary-dark: #2544ad;
    --surface: #ffffff;
    --canvas: #f4f7fb;
    --text: #1d2942;
    --muted: #6c7890;
    --border: #e3e9f2;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text);
    background:
        radial-gradient(circle at 88% 4%, rgba(49, 87, 213, 0.1), transparent 28rem), var(--canvas);
}

:where(a, button, [tabindex]:not(input):not(select):not(textarea)):focus-visible {
    outline: 3px solid var(--brand-gold, #d19a2b) !important;
    outline-offset: 2px;
}

main {
    scroll-margin-top: 1rem;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    width: 265px;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1030;
    overflow-x: hidden;
    overflow-y: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
    color: #fff;
    background: linear-gradient(180deg, var(--sidebar), #10192c);
    box-shadow: 12px 0 35px rgba(21, 33, 57, 0.13);
}

.sidebar-navigation::-webkit-scrollbar {
    width: 7px;
}

.sidebar-navigation::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.28);
}

.sidebar-header {
    flex: 0 0 auto;
    padding: max(1.5rem, env(safe-area-inset-top)) 1.5rem 1.25rem;
    background: rgba(23, 35, 59, 0.96);
}

.sidebar-navigation {
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.5rem 1.5rem 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.sidebar-user {
    flex: 0 0 auto;
    padding: 1.15rem 1.5rem max(1.5rem, env(safe-area-inset-bottom));
    background: rgba(12, 20, 36, 0.72);
    box-shadow: 0 -10px 28px rgba(8, 14, 26, 0.16);
}

.sidebar-user-avatar {
    display: inline-grid;
    width: 2.35rem;
    height: 2.35rem;
    min-width: 2.35rem;
    place-items: center;
    flex: 0 0 2.35rem;
    border-radius: 50%;
    line-height: 1;
}

.sidebar-user-avatar .bi {
    line-height: 1;
}

.sidebar-close {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    padding: 0;
    border-radius: 10px;
}

.sidebar-backdrop {
    display: none;
}

.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, #5578ef, #7f58dc);
    box-shadow: 0 8px 20px rgba(64, 91, 205, 0.35);
}

.sidebar-brand-mark {
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    padding: 0.3rem;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 8px 20px rgba(5, 12, 25, 0.3);
}

.sidebar-brand-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar .nav-link {
    color: #bdc8dc;
    border-radius: 12px;
    padding: 0.8rem 1rem;
    transition: 0.2s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #fff;
    background: var(--sidebar-soft);
}

.sidebar .nav-link.active {
    box-shadow: inset 3px 0 0 #7891f1;
}

main {
    margin-left: 265px;
    width: calc(100% - 265px);
    min-width: 0;
}

.page-container {
    max-width: 1500px;
    margin-inline: auto;
    padding: 2rem;
}

.hero {
    position: relative;
    overflow: hidden;
    padding: 1.7rem;
    color: #fff;
    border-radius: 24px;
    background: linear-gradient(125deg, #2748b7, #4268df 55%, #704dcc);
    box-shadow: 0 18px 45px rgba(49, 87, 213, 0.22);
}

.hero::after {
    content: "";
    position: absolute;
    width: 240px;
    height: 240px;
    right: -55px;
    top: -120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.11);
}

.card-soft {
    border: 1px solid rgba(227, 233, 242, 0.9);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 12px 35px rgba(30, 47, 82, 0.07);
}

.section-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--primary);
    border-radius: 12px;
    background: #eef2ff;
}

.required-mark {
    color: var(--bs-danger, #dc3545) !important;
    font-weight: 700;
}

.title-with-icon {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.section-title-icon {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 34px;
    color: var(--primary);
    border-radius: 10px;
    background: #eef2ff;
    font-size: 1rem;
}

.form-control,
.input-group-text {
    border-color: #dfe5ef;
}

.form-control:focus {
    border-color: #7891f1;
    box-shadow: 0 0 0 0.22rem rgba(49, 87, 213, 0.12);
}

.btn-primary {
    border-color: var(--primary);
    background: var(--primary);
}

.btn-primary:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
}

.modal-content {
    border: 0;
    border-radius: 20px;
    box-shadow: 0 22px 65px rgba(20, 31, 54, 0.24);
}

.mobile-header {
    display: none;
}

.mobile-menu-button {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    padding: 0;
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f5f7ff;
}

.mobile-menu-button:hover,
.mobile-menu-button:focus-visible {
    color: var(--primary-dark);
    border-color: #aebbf0;
    background: #eef2ff;
}

.mobile-page-title {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.min-width-0 {
    min-width: 0;
}

/* Distribución compartida de las pantallas CRUD de Administración. */
.admin-crud-layout > .admin-form-column {
    order: 1;
}

.admin-crud-layout > .admin-search-column {
    order: 2;
}

.admin-crud-layout > .admin-table-column {
    order: 3;
}

.admin-form-column > .card-soft {
    width: min(100%, 920px);
}

.admin-search-column > .card-soft {
    margin-bottom: 0 !important;
}

.admin-table-column > .card-soft {
    width: 100%;
}

@media (max-width: 991.98px) {
    .sidebar {
        width: min(310px, 88vw);
        z-index: 1055;
        visibility: hidden;
        transform: translateX(-102%);
        transition:
            transform 0.25s ease,
            visibility 0.25s ease;
        box-shadow: 18px 0 45px rgba(10, 18, 34, 0.28);
    }

    .sidebar-open .sidebar {
        visibility: visible;
        transform: translateX(0);
    }

    .sidebar-header {
        padding: max(1rem, env(safe-area-inset-top)) 1rem 0.9rem;
    }

    .sidebar-brand-mark {
        width: 50px;
        height: 50px;
        flex-basis: 50px;
    }

    .sidebar-navigation {
        padding: 0.5rem 1rem 1rem;
    }

    .sidebar-user {
        padding: 0.9rem 1rem max(1rem, env(safe-area-inset-bottom));
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1050;
        padding: 0;
        visibility: hidden;
        opacity: 0;
        border: 0;
        background: rgba(10, 18, 34, 0.56);
        transition:
            opacity 0.25s ease,
            visibility 0.25s ease;
    }

    .sidebar-open .sidebar-backdrop {
        visibility: visible;
        opacity: 1;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    main {
        width: 100%;
        margin-left: 0;
    }

    .mobile-header {
        display: flex;
        position: sticky;
        top: 0;
        z-index: 1040;
        min-height: 67px;
        box-shadow: 0 4px 18px rgba(30, 47, 82, 0.07);
    }

    .page-container {
        padding: 1rem;
    }
}

@media (max-width: 575.98px) {
    .mobile-header {
        padding-inline: 0.75rem !important;
    }

    .mobile-page-title {
        max-width: 56vw;
    }

    .page-container {
        padding: 0.75rem;
    }

    .hero {
        padding: 1.25rem;
        border-radius: 18px;
    }

    .card-soft {
        border-radius: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto !important;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (forced-colors: active) {
    :where(a, button, input, select, textarea, [tabindex]):focus-visible {
        outline: 3px solid CanvasText !important;
    }

    .required-mark,
    .text-danger {
        color: Mark !important;
    }
}

/* Selectores personalizados y buscables del sistema. */
.searchable-select-group {
    display: flex;
    width: 100%;
    align-items: stretch;
    gap: 0.5rem;
}

.searchable-select-group-auto {
    width: auto;
    min-width: 5.5rem;
    flex: 0 0 auto;
}

.searchable-select-group-auto .searchable-select {
    width: 5.5rem;
    flex-basis: 5.5rem;
}

.searchable-select {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

.searchable-select-add {
    display: inline-grid;
    width: 42px;
    min-width: 42px;
    padding: 0;
    place-items: center;
    border-radius: 0.6rem;
}

.searchable-select-native {
    position: absolute !important;
    left: 0;
    bottom: 0;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: 0 !important;
    opacity: 0;
    pointer-events: none;
}

.searchable-select-input {
    padding-right: 2.7rem;
    cursor: text;
    background-color: var(--bs-body-bg, #fff);
}

.searchable-select-group-sm .searchable-select-input {
    padding-right: 2.35rem;
}

.catalog-page-size,
.catalog-page-size-toggle {
    width: 5.5rem;
}

.catalog-page-size-toggle {
    cursor: pointer;
    background-color: var(--surface, #fff);
}

.catalog-page-size-menu {
    min-width: 5.5rem;
    padding: 0.4rem;
    border: 1px solid rgba(102, 55, 15, 0.18);
    border-radius: 0.85rem;
    background: var(--surface, #fff);
    box-shadow: 0 14px 35px rgba(77, 47, 28, 0.17);
}

.catalog-page-size-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.62rem 0.75rem;
    border-radius: 0.6rem;
}

.catalog-page-size-option:hover,
.catalog-page-size-option:focus {
    color: var(--primary);
    background: #f7e8d1;
}

.catalog-page-size-option.is-selected {
    color: var(--primary);
    font-weight: 600;
    background: #f3dfc0;
}

.searchable-select-group-sm .searchable-select-toggle {
    width: 1.75rem;
    height: 1.75rem;
}

.searchable-select-toggle {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    display: grid;
    width: 2rem;
    height: 2rem;
    padding: 0;
    place-items: center;
    color: #6c757d;
    border: 0;
    border-radius: 0.4rem;
    background: transparent;
    transform: translateY(-50%);
}

.searchable-select-toggle:hover,
.searchable-select-toggle:focus-visible {
    color: var(--primary);
    background: #f7e8d1;
}

.searchable-select.is-open .searchable-select-toggle i {
    transform: rotate(180deg);
}

.searchable-select-toggle i {
    transition: transform 0.18s ease;
}

.searchable-select-menu {
    position: fixed;
    z-index: 1090;
    overflow-y: auto;
    padding: 0.4rem;
    border: 1px solid rgba(102, 55, 15, 0.18);
    border-radius: 0.85rem;
    background: var(--surface, #fff);
    box-shadow: 0 14px 35px rgba(77, 47, 28, 0.17);
}

.searchable-select-option {
    display: block;
    width: 100%;
    padding: 0.62rem 0.75rem;
    color: var(--bs-body-color, #212529);
    text-align: left;
    border: 0;
    border-radius: 0.6rem;
    background: transparent;
    transition:
        color 0.15s ease,
        background-color 0.15s ease;
}

.searchable-select-option:hover,
.searchable-select-option:focus {
    color: var(--primary);
    outline: none;
    background: #f7e8d1;
}

.searchable-select-option.is-selected {
    color: var(--primary);
    font-weight: 600;
    background: #f3dfc0;
}

.searchable-select-option.is-selected::after {
    float: right;
    margin-left: 0.75rem;
    content: "\2713";
    font-weight: 700;
}

.searchable-select-empty {
    padding: 0.8rem;
    color: #6c757d;
    text-align: center;
    font-size: 0.875rem;
}

.searchable-select.is-disabled .searchable-select-input {
    cursor: not-allowed;
    background-color: var(--bs-secondary-bg, #e9ecef);
}

.searchable-select.is-open .searchable-select-input {
    border-color: #bf8640;
    box-shadow: 0 0 0 0.22rem rgba(139, 78, 22, 0.14);
}

.was-validated
    .searchable-select-native:invalid
    + .searchable-select-group
    .searchable-select-input,
.searchable-select.is-invalid .searchable-select-input {
    border-color: var(--bs-form-invalid-border-color, #dc3545);
}

.was-validated .searchable-select-native:valid + .searchable-select-group .searchable-select-input {
    border-color: var(--bs-form-valid-border-color, #198754);
}

@media (prefers-reduced-motion: reduce) {
    .searchable-select-toggle i {
        transition: none;
    }
}

.disabled-action-message {
    display: inline-block;
    cursor: help;
    line-height: 1;
}

.disabled-action-message > .action-button:disabled {
    pointer-events: none;
}

.disabled-action-message:focus-visible {
    border-radius: 0.375rem;
    outline: 3px solid rgba(13, 110, 253, 0.25);
    outline-offset: 2px;
}

/* Lectura de listados extensos en teléfonos y tabletas. */
.mobile-table-value {
    min-width: 0;
}

.icono-expiracion-sesion {
    width: 4.5rem;
    height: 4.5rem;
    flex: 0 0 4.5rem;
    border-radius: 1rem;
}

@media (max-width: 991.98px) {
    .mobile-table-wrapper {
        overflow: visible;
        padding: 0.75rem;
        background: var(--canvas);
    }

    .mobile-card-table {
        display: block;
        width: 100%;
        min-width: 0 !important;
        border: 0;
    }

    .mobile-card-table > thead {
        position: absolute !important;
        overflow: hidden;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .mobile-card-table > tbody {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
        width: 100%;
    }

    .mobile-card-table > tbody > tr {
        display: flex;
        min-width: 0;
        overflow: hidden;
        flex-direction: column;
        border: 1px solid var(--border);
        border-radius: 0.9rem;
        background: var(--surface);
        box-shadow: 0 4px 14px rgba(30, 40, 60, 0.06);
    }

    .mobile-card-table > tbody > tr > td {
        display: flex;
        width: 100%;
        min-width: 0;
        align-items: flex-start;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.7rem 0.8rem;
        text-align: right;
        white-space: normal !important;
        border-bottom: 1px solid var(--border);
        background: transparent;
    }

    .mobile-card-table > tbody > tr > td::before {
        min-width: 7rem;
        max-width: 42%;
        flex: 0 0 38%;
        color: var(--muted);
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 700;
        line-height: 1.35;
        text-align: left;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }

    .mobile-card-table > tbody > tr > td:last-child {
        border-bottom: 0;
    }

    .mobile-card-table .mobile-table-value {
        min-width: 0;
        flex: 1 1 auto;
        overflow-wrap: anywhere;
        text-align: right;
    }

    .mobile-card-table .mobile-table-actions {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .mobile-card-table > tbody > tr > td[colspan] {
        display: block;
        padding: 1rem;
        text-align: center;
        border-bottom: 0;
    }

    .mobile-card-table > tbody > tr > td[colspan]::before {
        display: none;
    }

    .mobile-card-table > tbody > tr > td[colspan] .mobile-table-value {
        text-align: center;
    }
}

@media (max-width: 767.98px) {
    .mobile-card-table > tbody {
        grid-template-columns: minmax(0, 1fr);
    }

    .mobile-card-table > tbody > tr > td::before {
        min-width: 6.5rem;
    }
}
