/* ==========================================================================
   VARIABLES GLOBALES Y BREAKPOINTS
   ========================================================================== */

:root {
    --primary: #4f8cff;
    --primary-hover: #3a7af4;
    --primary-soft: rgba(79, 140, 255, 0.14);
    --bg-main: #0b1220;
    --bg-surface: #0f172a;
    --bg-card: #111827;
    --bg-card-alt: #162233;
    --bg-header: rgba(15, 23, 42, 0.92);
    --bg-input: #111c2f;
    --bg-input-strong: #1a2334;
    --text-main: #f8fafc;
    --text-secondary: #dfe7f3;
    --text-muted: #9aa9bc;
    --border-color: rgba(148, 163, 184, 0.18);
    --border-strong: rgba(148, 163, 184, 0.28);
    --error-color: #fca5a5;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --success-text: #86efac;
    --warning: #f59e0b;
    --warning-text: #fcd34d;
    --info: #38bdf8;
    --info-text: #7dd3fc;
    --superadmin: #8b5cf6;
    --superadmin-soft: rgba(139, 92, 246, 0.16);
    --superadmin-text: #c4b5fd;
    --shadow-soft: 0 18px 40px rgba(2, 6, 23, 0.38);
    --shadow-elevated: 0 22px 55px rgba(15, 23, 42, 0.5);
    --border-radius: 14px;

    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html {
    scroll-behavior: smooth;
    background: var(--bg-main);
}

body {
    background:
        radial-gradient(circle at top left, rgba(79, 140, 255, 0.18), transparent 26%),
        linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
    color: var(--text-main);
    min-height: 100vh;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

button,
input,
select,
textarea {
    font: inherit;
}

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

*::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
}

*::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 999px;
}

/* ==========================================================================
   LAYOUT PRINCIPAL & HEADER - RESPONSIVE
   ========================================================================== */

#view-container {
    padding: var(--spacing-sm);
    max-width: 1280px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    #view-container {
        padding: var(--spacing-md) var(--spacing-lg);
    }
}

/* ==========================================================================
   LAYOUT TIPO TAILADMIN (SIDEBAR + HEADER + PROFILE MENU)
   ========================================================================== */

body {
    background: #0b1220;
    color: #e2e8f0;
}

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

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    background: #1c2434;
    color: #aab4c5;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 1.5rem 1rem;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1100;
}

.app-shell.sidebar-open .app-sidebar {
    transform: translateX(0);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    color: #f8fafc;
}

.sidebar-logo strong {
    display: block;
    font-size: 1rem;
    font-weight: 700;
}

.sidebar-logo small {
    color: #8b9bb3;
    font-size: 0.75rem;
}

.sidebar-logo-badge {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(87, 102, 241, 0.2);
    color: #9ea8ff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    color: #7d8ca4;
    margin: 1rem 0 0.35rem;
    padding: 0 0.75rem;
}

.sidebar-link {
    width: 100%;
    border: 0;
    background: transparent;
    color: #c4cedd;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    padding: 0.62rem 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.sidebar-link.active {
    background: rgba(87, 102, 241, 0.22);
    color: #d6dcff;
}

.sidebar-accordion .sidebar-submenu {
    display: none;
    padding-left: 0.5rem;
}

.sidebar-accordion.open .sidebar-submenu {
    display: block;
}

.sidebar-sublink {
    font-size: 0.84rem;
    color: #9fb0c8;
}

.accordion-arrow {
    transition: transform 0.2s ease;
}

.sidebar-accordion.open .accordion-arrow {
    transform: rotate(180deg);
}

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

.app-header {
    background: #111827;
    border-bottom: 1px solid #243244;
    min-height: 72px;
    padding: 0 1rem;
    display: none;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
}

.sidebar-toggle {
    width: 42px;
    height: 42px;
    border: 1px solid #334155;
    background: #1e293b;
    border-radius: 8px;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 0 10px;
    cursor: pointer;
}

.sidebar-toggle span {
    height: 2px;
    width: 100%;
    background: #e2e8f0;
    border-radius: 999px;
}

.app-header-right {
    position: relative;
}

.profile-toggle {
    border: 1px solid #334155;
    border-radius: 12px;
    background: #1e293b;
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.65rem;
    cursor: pointer;
}

.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    object-fit: cover;
    background: #e2e8f0;
}

.profile-meta {
    text-align: left;
}

.profile-meta strong {
    display: block;
    color: #f8fafc;
    font-size: 0.85rem;
    line-height: 1.2;
}

.profile-meta small {
    display: block;
    color: #94a3b8;
    font-size: 0.75rem;
    line-height: 1.2;
}

.profile-chevron {
    color: #94a3b8;
    font-size: 0.78rem;
}

.profile-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    min-width: 180px;
    border-radius: 12px;
    border: 1px solid #334155;
    background: #1e293b;
    box-shadow: 0 14px 28px rgba(2, 6, 23, 0.45);
    padding: 0.4rem;
    z-index: 1000;
}

.profile-dropdown.open {
    display: block;
}

.profile-dropdown button {
    width: 100%;
    border: 0;
    border-radius: 8px;
    background: transparent;
    text-align: left;
    padding: 0.55rem 0.65rem;
    color: #e2e8f0;
    cursor: pointer;
}

.profile-dropdown button:hover {
    background: #334155;
}

#view-container {
    max-width: 100%;
    margin: 0;
    padding: 1rem;
}

.app-shell:not(.is-authenticated) .app-sidebar,
.app-shell:not(.is-authenticated) #main-header {
    display: none !important;
}

.app-shell:not(.is-authenticated) #view-container {
    padding: 0;
}

@media (min-width: 1024px) {
    .app-sidebar {
        transform: translateX(0);
    }

    .app-content {
        margin-left: 280px;
    }

    .sidebar-toggle {
        display: none;
    }

    #view-container {
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .app-shell:not(.is-authenticated) .app-content {
        margin-left: 0;
    }
}

@media (min-width: 1024px) {
    #view-container {
        padding: var(--spacing-lg) var(--spacing-xl);
    }
}

/* --- HEADER EN MÓVIL (GRID RESPONSIVO EN 2 FILAS) --- */
#main-header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem var(--spacing-sm);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.nav-brand {
    grid-column: 1;
}

.nav-brand h1 {
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
}

.nav-user {
    grid-column: 2;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Ocultar nombre largo del usuario en móviles pequeños para evitar desbordamientos */
#user-display-name {
    display: none;
}

@media (min-width: 480px) {
    #user-display-name {
        display: inline-block;
        max-width: 120px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Menú de navegación inferior con scroll horizontal suave */
.nav-menu {
    grid-column: 1 / -1;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.nav-menu::-webkit-scrollbar {
    display: none; /* Chrome / Safari */
}

/* Contenedor dinámico generado por app.js */
#nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    padding-bottom: 0.2rem;
}

.nav-menu button,
#nav-links button,
#nav-links a {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.5rem 0.85rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
    flex: 0 0 auto;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.nav-menu button:hover,
.nav-menu button.active,
#nav-links button:hover,
#nav-links button.active,
#nav-links a:hover,
#nav-links a.active {
    background: var(--bg-card);
    color: var(--text-main);
    border-color: var(--border-color);
}

/* --- HEADER EN TABLET Y DESKTOP (1 FILA CONTINUA) --- */
@media (min-width: 768px) {
    #main-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--spacing-sm) var(--spacing-md);
        gap: var(--spacing-sm);
    }

    .nav-brand h1 {
        font-size: 1.5rem;
    }

    .nav-menu {
        width: auto;
        overflow: visible;
    }

    #nav-links {
        padding-bottom: 0;
    }

    .nav-menu button,
    #nav-links button,
    #nav-links a {
        font-size: 0.95rem;
        padding: 0.5rem 1rem;
    }

    .nav-user {
        font-size: 1rem;
        gap: var(--spacing-sm);
    }

    #user-display-name {
        max-width: none;
    }
}

.header-section,
.dashboard-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .header-section,
    .dashboard-card-header {
        gap: var(--spacing-sm);
    }
}

.header-section h2,
.dashboard-card-header h3 {
    margin: 0;
    flex: 1 1 auto;
    min-width: 150px;
}

.header-section button,
.dashboard-card-header button {
    flex: 0 1 auto;
    white-space: nowrap;
}

/* ==========================================================================
   CARDS Y GRIDS - RESPONSIVE
   ========================================================================== */

.dashboard-card,
.card,
.filter-card {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.94), rgba(15, 23, 42, 0.96));
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(8px);
}

.filter-card {
    border-radius: 18px;
    padding: 1.25rem 1rem;
    box-shadow: 0 12px 28px rgba(2, 6, 23, 0.25);
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(15, 23, 42, 0.98));
}

@media (min-width: 768px) {
    .filter-card {
        padding: 1.25rem 1.5rem;
    }
}

.margin-top {
    margin-top: var(--spacing-md);
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

@media (min-width: 480px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

.metrics-grid .card h3 {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

@media (min-width: 768px) {
    .metrics-grid .card h3 {
        font-size: 0.9rem;
    }
}

.metrics-grid .card p {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    margin-top: 0.5rem;
}

@media (min-width: 768px) {
    .metrics-grid .card p {
        font-size: 1.8rem;
    }
}

/* ==========================================================================
   FORMULARIOS E INPUTS - RESPONSIVE
   ========================================================================== */

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label,
.filter-group label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (min-width: 768px) {
    .form-group label,
    .filter-group label {
        font-size: 0.85rem;
    }
}

.form-group input,
.form-group select,
.filter-group input[type="date"],
.filter-group select,
.filter-group option {
    width: 100%;
    padding: 0.8rem 0.9rem;
    background: #ffffff;
    border: 1px solid #dbe1ea;
    border-radius: 12px;
    color: #111827;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

.form-group input:focus,
.form-group select:focus,
.filter-group input[type="date"]:focus,
.filter-group select:focus {
    border-color: rgba(79, 140, 255, 0.9);
    box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.14);
    transform: translateY(-1px);
}

.filter-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

@media (min-width: 480px) {
    .filter-grid {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
    }
}

@media (min-width: 768px) {
    .filter-grid {
        gap: var(--spacing-md);
    }
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1 1 100%;
}

@media (min-width: 480px) {
    .filter-group {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 150px;
    }
}

@media (min-width: 768px) {
    .filter-group {
        flex: 1 1 200px;
    }
}

.filter-group input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
    cursor: pointer;
}

.form-actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: var(--spacing-md);
}

@media (min-width: 480px) {
    .form-actions {
        flex-direction: row;
    }
}

.confirm-modal {
    max-width: 420px;
    padding: var(--spacing-md);
}

.confirm-header h3 {
    margin: 0 0 0.75rem;
    padding: 0;
    border: none;
    color: var(--text-main);
}

.confirm-message {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 0.96rem;
}

.confirm-actions {
    justify-content: flex-end;
    margin-top: 1.25rem;
}

.payment-company-name {
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: rgba(37, 99, 235, 0.08);
    color: var(--text-main);
    font-weight: 600;
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 75vh;
    padding: var(--spacing-sm);
}

.login-card {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(15, 23, 42, 0.96));
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: 0 18px 42px rgba(2, 6, 23, 0.4);
    width: 100%;
    max-width: 400px;
}

@media (min-width: 768px) {
    .login-card {
        padding: 2.5rem;
    }
}

.login-card h2 {
    color: var(--text-main);
    margin-bottom: 0.2rem;
    font-size: 1.5rem;
}

@media (min-width: 768px) {
    .login-card h2 {
        font-size: 1.75rem;
    }
}

.login-card h2 span {
    color: var(--primary);
}

.login-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* ==========================================================================
   BOTONES - RESPONSIVE
   ========================================================================== */

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-consultar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.68rem 1rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-height: 40px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
}

@media (min-width: 768px) {
    .btn-primary,
    .btn-secondary,
    .btn-danger,
    .btn-consultar {
        padding: 0.75rem 1.2rem;
        font-size: 0.93rem;
        min-height: 42px;
    }
}

.btn-primary,
.btn-consultar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(79, 140, 255, 0.22);
}

.btn-primary:hover,
.btn-consultar:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary) 100%);
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(79, 140, 255, 0.25);
}

.btn-primary:active,
.btn-consultar:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: linear-gradient(180deg, rgba(26, 35, 52, 1), rgba(17, 28, 47, 1));
    color: var(--text-main);
    border-color: var(--border-color);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.btn-secondary:hover {
    background: rgba(26, 35, 52, 1);
    border-color: var(--border-strong);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-hover) 100%);
    color: #ffffff;
}

.btn-danger:hover {
    filter: brightness(1.05);
}

.btn-consultar {
    height: 42px;
}

/* ==========================================================================
   TABLAS
   ========================================================================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(17, 28, 47, 0.5);
    font-size: 0.95rem;
}

@media (max-width: 480px) {
    table {
        font-size: 0.85rem;
    }
}

th {
    background: rgba(17, 28, 47, 0.9);
    padding: var(--spacing-md);
    color: var(--text-muted);
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

@media (max-width: 480px) {
    th {
        padding: var(--spacing-sm);
        font-size: 0.75rem;
    }
}

td {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

tr:hover {
    background: rgba(79, 140, 255, 0.05);
}

@media (max-width: 480px) {
    td {
        padding: var(--spacing-sm);
    }
}

tr:hover {
    background: rgba(37, 99, 235, 0.05);
}

.col-id {
    text-align: center;
    font-weight: 600;
    max-width: 50px;
}

@media (min-width: 480px) {
    .col-id {
        max-width: 60px;
    }
}

@media (min-width: 768px) {
    .col-id {
        max-width: none;
    }
}

.col-status {
    text-align: center;
}

.col-actions {
    max-width: 100px;
    text-align: center;
}

@media (min-width: 480px) {
    .col-actions {
        max-width: 110px;
    }
}

@media (min-width: 768px) {
    .col-actions {
        max-width: none;
        text-align: left;
    }
}

.col-name {
    max-width: 120px;
    word-break: break-word;
    font-weight: 500;
}

@media (min-width: 480px) {
    .col-name {
        max-width: 150px;
    }
}

@media (min-width: 768px) {
    .col-name {
        max-width: none;
        word-break: normal;
    }
}

.col-value {
    text-align: right;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    min-width: 120px;
}

th.col-value,
td.col-value {
    width: 1%;
    text-align: right;
}

.dashboard-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.pagination-btn {
    min-width: 2.2rem;
    height: 2.2rem;
    padding: 0 0.75rem;
    border: 1px solid #dbe1ea;
    border-radius: 10px;
    background: #ffffff;
    color: #111827;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: #eef2ff;
    border-color: rgba(79, 140, 255, 0.5);
}

.pagination-btn.is-active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.pagination-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ==========================================================================
   MODALES Y FORMULARIOS FLOTANTES - RESPONSIVE
   ========================================================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: var(--spacing-sm);
}

.modal-content {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(15, 23, 42, 0.98));
    border: 1px solid var(--border-color);
    border-radius: 18px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: 0 28px 70px rgba(2, 6, 23, 0.45);
    color: var(--text-main);
    position: relative;
    animation: modalPop 0.25s ease-out forwards;
}

@media (min-width: 480px) {
    .modal-content {
        padding: 2rem;
    }
}

.modal-content h3,
.modal-content h2 {
    margin-bottom: 1.25rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    font-size: 1.25rem;
}

@media (min-width: 768px) {
    .modal-content h3,
    .modal-content h2 {
        font-size: 1.5rem;
    }
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================================================
   LAYOUTS RESPONSIVE - GRID Y FLEX
   ========================================================================== */

.responsive-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

@media (min-width: 768px) {
    .responsive-grid-2 {
        grid-template-columns: 1fr 2fr;
    }
}

.responsive-grid-equal {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .responsive-grid-equal {
        grid-template-columns: 1fr 1fr;
    }
}

.flex-responsive {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
}

@media (min-width: 480px) {
    .flex-responsive {
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
    }
}

@media (min-width: 768px) {
    .flex-responsive {
        gap: 1rem;
    }
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.checkbox-wrapper input[type="checkbox"] {
    width: auto;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-wrapper label {
    margin: 0;
    cursor: pointer;
    font-weight: normal;
    text-transform: none;
    letter-spacing: 0;
    flex: 1;
}

.header-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

@media (min-width: 480px) {
    .header-actions {
        flex-direction: row;
        width: auto;
        gap: 0.5rem;
    }
}

@media (min-width: 768px) {
    .header-actions {
        gap: 1rem;
    }
}

.header-actions button {
    flex: 1;
    min-width: 120px;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .header-actions button {
        flex: 0 1 auto;
    }
}

/* ==========================================================================
   ALERTAS Y NOTIFICACIONES TOAST - RESPONSIVE
   ========================================================================== */

.toast-container {
    position: fixed;
    top: 1rem;
    left: var(--spacing-sm);
    right: var(--spacing-sm);
    z-index: 20000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
    max-width: 100%;
}

@media (min-width: 480px) {
    .toast-container {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
}

.toast {
    pointer-events: auto;
    width: 100%;
    max-width: 420px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #f8fafc;
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    border: 1px solid rgba(148, 163, 184, 0.2);
    animation: toastSlideDown 0.3s ease forwards;
}

@media (min-width: 768px) {
    .toast {
        font-size: 0.95rem;
    }
}

@keyframes toastSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert,
.error-message,
.error-box,
.alertbox {
    padding: 1rem;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 4px solid transparent;
    background: var(--bg-card);
}

@media (min-width: 768px) {
    .alert,
    .error-message,
    .error-box,
    .alertbox {
        padding: 1rem 1.25rem;
        font-size: 0.9rem;
    }
}

.alert-success, .alertbox-success {
    background-color: rgba(16, 185, 129, 0.12);
    border-left-color: var(--success);
    color: var(--success-text);
}

.alert-danger, .error-message, .error-box, .alertbox-danger {
    background-color: rgba(239, 68, 68, 0.12);
    border-left-color: var(--danger);
    color: var(--error-color);
}

.alert-warning, .alertbox-warning {
    background-color: rgba(245, 158, 11, 0.12);
    border-left-color: var(--warning);
    color: var(--warning-text);
}

.alert-info, .alertbox-info {
    background-color: rgba(59, 130, 246, 0.12);
    border-left-color: var(--info);
    color: var(--info-text);
}

.alert-superadmin, .alertbox-superadmin {
    background-color: var(--superadmin-soft);
    border-left-color: var(--superadmin);
    color: var(--superadmin-text);
}

.toast.alertbox-superadmin {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(15, 23, 42, 0.96));
    border: 1px solid rgba(139, 92, 246, 0.45);
    box-shadow: 0 12px 30px rgba(91, 33, 182, 0.35);
    color: var(--superadmin-text);
}
/* ==========================================================================
   HEADER - VISIBILIDAD Y ALINEACIÓN CORREGIDA
   ========================================================================== */

#main-header {
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
    padding: 0.85rem var(--spacing-sm);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-brand h1 {
    color: var(--text-main);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    margin: 0;
    white-space: nowrap;
    background: linear-gradient(135deg, #f8fafc 0%, #7dd3fc 52%, #bfdbfe 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.26rem;
    width: 2.8rem;
    height: 2.8rem;
    padding: 0.55rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(17, 28, 47, 0.8);
    cursor: pointer;
    margin-left: auto;
    transition: all 0.2s ease;
}

.nav-toggle:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-main);
    border-radius: 999px;
    transition: all 0.2s ease;
}

.nav-toggle.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Contenedor del menú principal */
.nav-menu {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: var(--spacing-sm);
    right: var(--spacing-sm);
    background: rgba(15, 23, 42, 0.97);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-elevated);
    z-index: 20;
    padding: 0.75rem;
}

.nav-menu.open {
    display: block;
}

#nav-links {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    width: 100%;
}

.nav-menu button,
.nav-menu a,
#nav-links button,
#nav-links a {
    background: rgba(26, 35, 52, 0.95);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.7rem 0.9rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.nav-menu button:hover,
.nav-menu button.active,
#nav-links button:hover,
#nav-links button.active,
#nav-links a:hover,
#nav-links a.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: #ffffff;
    border-color: rgba(79, 140, 255, 0.7);
    box-shadow: 0 8px 18px rgba(79, 140, 255, 0.25);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    order: 2;
}

#user-display-name {
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.85rem;
}

@media (min-width: 768px) {
    #main-header {
        flex-wrap: nowrap;
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .nav-toggle {
        display: none;
    }

    .nav-menu {
        position: static;
        display: flex !important;
        order: 2;
        width: auto;
        overflow: visible;
        padding: 0;
        background: transparent;
        border: none;
        box-shadow: none;
    }

    #nav-links {
        width: auto;
        flex-direction: row;
        align-items: center;
    }

    .nav-user {
        order: 3;
    }

    .nav-menu button,
    .nav-menu a,
    #nav-links button,
    #nav-links a {
        width: auto;
        background: transparent;
        color: var(--text-muted);
        border-color: transparent;
    }

    .nav-menu button:hover,
    #nav-links button:hover,
    #nav-links a:hover {
        background: rgba(17, 28, 47, 0.9);
        color: var(--text-main);
        border-color: var(--border-color);
        box-shadow: none;
    }

    .nav-menu button.active,
    #nav-links button.active,
    #nav-links a.active {
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
        color: #ffffff;
        border-color: rgba(79, 140, 255, 0.7);
    }
}

/* ==========================================================================
   OVERRIDES FINALES PARA LAYOUT TAILADMIN
   ========================================================================== */

#app-shell #main-header.app-header {
    background: #111827;
    border-bottom: 1px solid #243244;
    box-shadow: none;
    min-height: 72px;
    padding: 0 1rem;
    display: none;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
}

#app-shell .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    background: #1c2434;
    color: #aab4c5;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 1.5rem 1rem;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1100;
}

#app-shell.sidebar-open .app-sidebar {
    transform: translateX(0);
}

#app-shell .app-sidebar #nav-links.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    width: 100%;
}

#app-shell .app-sidebar .sidebar-link {
    width: 100%;
    justify-content: space-between;
    text-align: left;
    background: transparent;
    border: 0;
    color: #c4cedd;
}

#app-shell .app-sidebar .sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    box-shadow: none;
}

#app-shell .app-sidebar .sidebar-link.active {
    background: rgba(87, 102, 241, 0.22);
    color: #d6dcff;
}

#app-shell .app-content #view-container {
    max-width: 100%;
    margin: 0;
    padding: 1rem;
}

#app-shell #user-display-name {
    display: block;
    max-width: none;
    color: #f8fafc;
    font-weight: 700;
}

#app-shell:not(.is-authenticated) .app-sidebar,
#app-shell:not(.is-authenticated) #main-header {
    display: none !important;
}

#app-shell:not(.is-authenticated) .app-content {
    margin-left: 0;
}

#app-shell:not(.is-authenticated) #view-container {
    padding: 0;
}

@media (min-width: 1024px) {
    #app-shell .app-sidebar {
        transform: translateX(0);
    }

    #app-shell .app-content {
        margin-left: 280px;
    }

    #app-shell .sidebar-toggle {
        display: none;
    }

    #app-shell .app-content #view-container {
        padding: 1.5rem;
    }

    #app-shell:not(.is-authenticated) .app-content {
        margin-left: 0;
    }
}