:root {
    --bg-main: #060913;
    --bg-card: #0d1428;
    --bg-card-2: #121b34;
    --line: #27345f;
    --text-main: #ebefff;
    --text-soft: #9aa7cf;
    --accent: #3e7bff;
    --accent-2: #7a4dff;
    --ok: #3ce7bb;
    --err: #ff5f87;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background:
        radial-gradient(70rem 40rem at 100% -10%, rgba(122, 77, 255, 0.18), transparent 60%),
        radial-gradient(60rem 35rem at -10% 110%, rgba(62, 123, 255, 0.2), transparent 60%),
        var(--bg-main);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
}

a { color: inherit; text-decoration: none; }

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 280px;
    background: linear-gradient(180deg, #0a1023 0%, #080d1d 100%);
    border-right: 1px solid var(--line);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.brand-wrap h1 {
    margin: 0;
    font-size: 18px;
    font-family: 'Space Grotesk', sans-serif;
}

.brand-wrap small {
    color: var(--text-soft);
}

.menu-list {
    display: grid;
    gap: 8px;
}

.menu-link {
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: #cad5ff;
    transition: all .2s ease;
}

.menu-link:hover,
.menu-link.active {
    border-color: #3752a8;
    background: rgba(59, 103, 240, 0.2);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-chip {
    background: var(--bg-card);
    border: 1px solid var(--line);
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-soft);
}

.logout-link {
    background: rgba(255, 95, 135, 0.15);
    border: 1px solid rgba(255, 95, 135, 0.4);
    color: #ffc1d0;
    text-align: center;
    border-radius: 10px;
    padding: 10px;
}

.app-main {
    flex: 1;
    padding: 20px;
}

.mobile-head { margin-bottom: 12px; }
.btn-menu {
    border: 1px solid #3d59ad;
    color: #d4deff;
    background: rgba(31, 53, 117, 0.4);
}

.panel-card {
    background: linear-gradient(170deg, var(--bg-card) 0%, var(--bg-card-2) 100%);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.22);
}

.page-title {
    font-family: 'Space Grotesk', sans-serif;
    margin: 0 0 16px;
    font-size: 1.4rem;
}

.form-control,
.form-select,
.btn {
    border-radius: 10px;
}

.form-control,
.form-select {
    background-color: #080f22;
    border: 1px solid #2d3f79;
    color: #dfe6ff;
}

.form-control::placeholder {
    color: #5a6ea8;
    opacity: 1;
}

.form-control:-ms-input-placeholder { color: #5a6ea8; }
.form-control::-ms-input-placeholder { color: #5a6ea8; }

.form-control:focus,
.form-select:focus {
    border-color: #507ffd;
    box-shadow: 0 0 0 .2rem rgba(80, 127, 253, .2);
    background-color: #081028;
    color: #fff;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: 0;
}

.select2-container {
    width: 100% !important;
}

.select2-container--default .select2-selection--single {
    height: 46px;
    background: #080f22;
    border: 1px solid #2d3f79;
    border-radius: 10px;
    display: flex;
    align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #dfe6ff;
    line-height: 44px;
    padding-left: 14px;
    padding-right: 36px;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #5a6ea8;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px;
    right: 8px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #7f95d1 transparent transparent transparent;
}

.select2-dropdown {
    background: #0c1328;
    border: 1px solid #2d3f79;
    border-radius: 10px;
    overflow: hidden;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    background: #081028;
    border: 1px solid #314785;
    color: #e6edff;
    border-radius: 8px;
}

.select2-container--default .select2-results__option {
    color: #dfe6ff;
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background: rgba(62, 123, 255, 0.85);
    color: #fff;
}

.select2-container--default .select2-results__option--selected {
    background: rgba(122, 77, 255, 0.22);
    color: #fff;
}

/* Tabla dark — fuerza variables de Bootstrap 5 _tables.scss */
/* !important necesario porque Bootstrap inyecta las vars en el propio element style */
.table {
    --bs-table-bg: #0b1225 !important;
    --bs-table-color: #deebff !important;
    --bs-table-striped-bg: rgba(255,255,255,0.03) !important;
    --bs-table-striped-color: #deebff !important;
    --bs-table-hover-bg: rgba(59,103,240,0.14) !important;
    --bs-table-hover-color: #ffffff !important;
    --bs-table-border-color: #1e2f57 !important;
    --bs-table-accent-bg: transparent !important;
    color: #deebff;
    border-color: #1e2f57;
    background-color: #0b1225;
}

/* Algunos builds usan mayor especificidad; cubrimos ambos */
table.table,
.table-responsive > .table {
    --bs-table-bg: #0b1225 !important;
    --bs-table-color: #deebff !important;
    background-color: #0b1225;
    color: #deebff;
}

.table thead th {
    background: #080e20;
    border-color: #334476;
    color: #8aa3d9;
    font-weight: 500;
    letter-spacing: .03em;
    white-space: nowrap;
}

.table tbody td {
    border-color: #1e2f57;
    vertical-align: middle;
}

.table tbody tr:nth-child(odd) > td {
    background-color: rgba(255, 255, 255, 0.025);
}

.table tbody tr:hover > td {
    background-color: rgba(59, 103, 240, 0.1);
    color: #fff;
}

.badge-soft {
    background: rgba(62, 231, 187, 0.15);
    border: 1px solid rgba(62, 231, 187, 0.45);
    color: #93ffe1;
}

.alert-box {
    padding: 12px;
    border-radius: 10px;
    border: 1px solid;
}

.alert-ok {
    border-color: rgba(62, 231, 187, 0.45);
    color: #98ffe4;
    background: rgba(62, 231, 187, 0.08);
}

.alert-err {
    border-color: rgba(255, 95, 135, 0.5);
    color: #ffc2d1;
    background: rgba(255, 95, 135, 0.08);
}

.stat-card h3 {
    margin: 8px 0 0;
    font-size: 1.6rem;
}

@media (max-width: 992px) {
    .app-sidebar {
        position: fixed;
        left: -300px;
        z-index: 30;
        transition: left .25s ease;
    }

    .app-sidebar.open {
        left: 0;
    }

    .app-main { padding: 12px; }

    .table-mobile-cards thead { display: none; }
    .table-mobile-cards,
    .table-mobile-cards tbody,
    .table-mobile-cards tr,
    .table-mobile-cards td { display: block; width: 100%; }
    .table-mobile-cards tr {
        border: 1px solid #2c3d6f;
        border-radius: 12px;
        margin-bottom: 10px;
        padding: 8px;
        background: rgba(13, 20, 40, 0.8);
    }
    .table-mobile-cards td {
        border: 0;
        padding: 6px 8px;
    }
}
