:root {
    --primary: #0f3b73;
    --primary-hover: #0a2d59;
    --primary-light: rgba(15,59,115,0.08);
    --accent: #3b82f6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --purple: #8b5cf6;
    --bg: #f1f5f9;
    --card: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.07), 0 4px 12px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
    --sidebar-w: 270px;
    --top-h: 68px;
    --transition: all 0.22s cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
    --bg: #0f172a;
    --card: #1e293b;
    --border: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --primary-light: rgba(59,130,246,0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    transition: background .3s, color .3s;
}

/* ─── LOGIN SCREEN ─────────────────────────── */
.login-screen {
    position: fixed;
    inset: 0;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1.5rem;
}

.login-card {
    background: var(--card);
    width: 100%;
    max-width: 420px;
    padding: 3rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: fadeUp .4s ease-out;
}

.login-header { margin-bottom: 2.5rem; }
.login-logo { width: 64px; height: 64px; margin-bottom: 1.25rem; object-fit: contain; }
.login-header h1 { font-size: 1.8rem; font-weight: 800; color: var(--primary); margin-bottom: .25rem; }
.login-header p { color: var(--text-muted); font-size: .95rem; }

.login-form { text-align: left; }
.login-form .form-group { margin-bottom: 1.5rem; }

.input-with-icon { position: relative; }
.input-with-icon i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
}
.input-with-icon .form-input { padding-left: 2.8rem; }

.btn-block { width: 100%; justify-content: center; padding: .85rem; margin-top: 1rem; font-size: 1rem; }

.login-error {
    margin-top: 1.5rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #ef4444;
    padding: .85rem;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    justify-content: center;
}

.outfit { font-family: 'Outfit', sans-serif; }
/* ─── LOADING ANIMATIONS ─────────────────────────── */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
    color: var(--text-muted);
}

.loader::after {
    content: "";
    width: 48px;
    height: 48px;
    border: 5px solid var(--border);
    border-bottom-color: var(--accent);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

.loader-sm {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: rotation 1s linear infinite;
    display: inline-block;
}

.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin-top: -9px;
    margin-left: -9px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: rotation 0.6s linear infinite;
}

.btn-secondary.loading::after {
    border-color: rgba(0,0,0,0.1);
    border-top-color: var(--primary);
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}


/* ─── LAYOUT ─────────────────────────────────── */
.app-layout { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

/* ─── SIDEBAR ─────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    transition: var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-brand-text { overflow: hidden; }
.sidebar-title {
    display: block;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: .9rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-subtitle {
    display: block;
    font-size: .7rem;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1rem 1.25rem;
    margin: .75rem .75rem 0;
    background: rgba(255,255,255,.05);
    border-radius: var(--radius-sm);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    color: white;
    flex-shrink: 0;
}

.user-name {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    display: block;
    font-size: .68rem;
    color: var(--sidebar-text);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .75rem .75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}

.nav-group-label {
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .1em;
    color: rgba(148,163,184,.55);
    padding: 1rem .5rem .35rem;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .65rem .85rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    position: relative;
}

.nav-item:hover {
    background: rgba(255,255,255,.07);
    color: #e2e8f0;
}

.nav-item.active {
    background: rgba(59,130,246,.18);
    color: #93c5fd;
    font-weight: 600;
}

.nav-item.active .nav-icon { color: var(--accent); }

.nav-icon { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
    background: var(--accent);
    color: white;
    font-size: .65rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-version { font-size: .65rem; color: rgba(148,163,184,.4); }

/* ─── MAIN ─────────────────────────────────── */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.top-bar {
    height: var(--top-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    flex-shrink: 0;
    transition: background .3s;
}

.view-title { font-size: 1.35rem; font-weight: 700; color: var(--text); }

.date-chip {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .4rem 1rem;
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.75rem 2rem;
}

/* ─── STAT CARDS ─────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.1rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: default;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: rgba(59,130,246,.12); color: #3b82f6; }
.stat-icon.green  { background: rgba(16,185,129,.12); color: #10b981; }
.stat-icon.orange { background: rgba(245,158,11,.12);  color: #f59e0b; }
.stat-icon.purple { background: rgba(139,92,246,.12);  color: #8b5cf6; }
.stat-icon.teal   { background: rgba(20,184,166,.12);  color: #14b8a6; }

.stat-info h3 { font-size: .78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .2rem; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text); font-family: 'Outfit', sans-serif; line-height: 1; }

/* ─── WELCOME BANNER ─────────────────────────────────── */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    border-radius: var(--radius);
    padding: 2rem 2.5rem;
    margin-bottom: 1.75rem;
    box-shadow: 0 8px 24px rgba(15,59,115,.25);
    position: relative;
    overflow: hidden;
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 200px; height: 200px;
    background: rgba(255,255,255,.05);
    border-radius: 50%;
}

.welcome-banner h2 {
    color: white;
    font-size: 1.5rem;
    margin-bottom: .35rem;
}

.welcome-banner p { color: rgba(255,255,255,.8); font-size: .92rem; }

/* ─── DATA TABLE ─────────────────────────────────── */
.data-table-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    overflow-x: auto;
}

.table-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.table-header h3 { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: .1rem; }
.table-header-sub { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }

table { width: 100%; border-collapse: collapse; }

th {
    text-align: left;
    padding: .85rem 1.25rem;
    background: rgba(0,0,0,.025);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
    color: var(--text);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--primary-light); }

.td-primary { font-weight: 600; }
.td-muted   { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

.enhanced-table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .9rem;
    padding: .85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--card);
}

.table-toolbar-main {
    display: flex;
    align-items: center;
    gap: .65rem;
    flex-wrap: wrap;
    min-width: 0;
}

.table-search-control,
.table-order-control {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.table-search-control i,
.table-order-control i {
    position: absolute;
    left: .75rem;
    color: var(--text-muted);
    font-size: .85rem;
    pointer-events: none;
}

.table-global-filter,
.table-default-order,
.table-column-filter {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: .8rem;
    outline: none;
    transition: var(--transition);
}

.table-global-filter {
    width: 230px;
    padding: .55rem .75rem .55rem 2rem;
}

.table-default-order {
    min-width: 180px;
    padding: .55rem .75rem .55rem 2rem;
}

.table-global-filter:focus,
.table-default-order:focus,
.table-column-filter:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.table-result-count {
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
}

.enhanced-table thead tr:first-child th.sortable-column {
    padding: 0;
}

.table-sort-btn {
    width: 100%;
    min-height: 44px;
    padding: .85rem 1.25rem;
    border: 0;
    background: transparent;
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    font: inherit;
    text-align: left;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
}

.table-sort-btn:hover {
    background: var(--primary-light);
    color: var(--accent);
}

.table-sort-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-sort-btn i {
    color: var(--text-muted);
    font-size: .8rem;
    flex-shrink: 0;
}

.sortable-column[aria-sort="ascending"] .table-sort-btn,
.sortable-column[aria-sort="descending"] .table-sort-btn {
    color: var(--primary);
}

.sortable-column[aria-sort="ascending"] .table-sort-btn i,
.sortable-column[aria-sort="descending"] .table-sort-btn i {
    color: var(--accent);
}

.column-filter-row th {
    padding: .45rem .75rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.table-column-filter {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: .45rem .6rem;
    box-sizing: border-box;
}

.table-empty-row td {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    background: var(--card) !important;
}

@media (max-width: 700px) {
    .enhanced-table-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .table-toolbar-main,
    .table-search-control,
    .table-order-control,
    .table-global-filter,
    .table-default-order {
        width: 100%;
    }
}

@media print {
    .enhanced-table-toolbar,
    .column-filter-row {
        display: none !important;
    }

    .enhanced-table thead tr:first-child th.sortable-column,
    .table-sort-btn {
        padding: .85rem 1.25rem;
    }

    .table-sort-btn {
        display: block;
        min-height: 0;
        background: transparent;
    }

    .table-sort-btn i {
        display: none;
    }
}

/* ─── SEARCH INPUT ─────────────────────────────────── */
.search-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.search-wrap i {
    position: absolute;
    left: .85rem;
    color: var(--text-muted);
    font-size: .9rem;
    pointer-events: none;
}

.search-input {
    padding: .55rem .85rem .55rem 2.2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: .85rem;
    font-family: inherit;
    width: 260px;
    transition: var(--transition);
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* ─── BUTTONS ─────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .875rem;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover   { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(15,59,115,.3); }

.btn-secondary { background: var(--card); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }

.btn-success   { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(1.1); }

.btn-info { background: var(--accent); color: white; }
.btn-info:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,.25); }

.btn-danger    { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }

.btn-sm { padding: .38rem .8rem; font-size: .78rem; border-radius: 6px; }

.btn-ghost {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

.btn-ghost:hover { background: rgba(255,255,255,.1); color: white; }

.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text-muted);
    cursor: pointer;
    font-size: .9rem;
    transition: var(--transition);
}

.btn-icon:hover { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.btn-icon.edit:hover { background: var(--primary-light); border-color: var(--accent); color: var(--accent); }

.action-btns { display: flex; gap: .4rem; }

/* ─── ACTION CHIPS (Docente → Generador) ─────────────────────────────────── */
.doc-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .65rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
}

.chip-isr   { background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.25); color: #059669; }
.chip-isr:hover   { background: #059669; color: white; }
.chip-acta  { background: rgba(59,130,246,.1); border-color: rgba(59,130,246,.25); color: var(--accent); }
.chip-acta:hover  { background: var(--accent); color: white; }
.chip-tdr   { background: rgba(139,92,246,.1); border-color: rgba(139,92,246,.25); color: #7c3aed; }
.chip-tdr:hover   { background: #7c3aed; color: white; }

/* ─── QUICK ACCESS CARD ─────────────────────────────────── */
.quick-access { display: flex; flex-direction: column; gap: .6rem; }

.quick-btn {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .9rem 1.1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text);
    font-size: .88rem;
    font-weight: 500;
    font-family: inherit;
    transition: var(--transition);
    text-align: left;
    width: 100%;
}

.quick-btn:hover { border-color: var(--accent); background: var(--primary-light); color: var(--primary); }

.quick-btn-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: .95rem;
    flex-shrink: 0;
}

/* ─── GENERATOR FRAME ─────────────────────────────────── */
.generator-wrapper { display: flex; flex-direction: column; height: calc(100vh - var(--top-h) - 3.5rem); }

.generator-toolbar {
    display: flex;
    gap: .75rem;
    align-items: center;
    padding: .85rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    flex-shrink: 0;
}

.generator-toolbar select {
    flex: 1;
    padding: .55rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: .875rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.generator-toolbar select:focus { border-color: var(--accent); }

.generator-frame {
    flex: 1;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: white;
}

.generator-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    font-size: .82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    flex-shrink: 0;
}

/* ─── MODAL ─────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.55);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    opacity: 0; visibility: hidden;
    transition: all .25s ease;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-box {
    background: var(--card);
    border-radius: var(--radius);
    width: 95%;
    max-width: 650px;
    padding: 2.2rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(16px) scale(.98);
    transition: all .25s cubic-bezier(.34,1.56,.64,1);
    max-height: 95vh;
    overflow-y: auto;
}

.modal-box.large { max-width: 950px; }
.modal-box.extra-large { max-width: 1300px; }

.modal-overlay.active .modal-box { transform: translateY(0) scale(1); }

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-head h3 { font-size: 1.1rem; font-weight: 700; }
.modal-body { font-size: .95rem; line-height: 1.6; }
.modal-footer { border-top: 1px solid var(--border); padding-top: 1.25rem; }


/* ─── FORM ─────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
@media (max-width: 600px) {
    .form-grid { grid-template-columns: 1fr; }
}
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

.form-input {
    padding: .65rem .9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }

/* ─── BADGES ─────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .25rem .65rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.badge-success  { background: rgba(16,185,129,.12); color: #059669; }
.badge-danger   { background: rgba(239,68,68,.12);  color: var(--danger); }
.badge-warning  { background: rgba(245,158,11,.12); color: #d97706; }
.badge-info     { background: rgba(59,130,246,.12); color: var(--accent); }

/* ─── TOASTS ─────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 1.75rem;
    right: 1.75rem;
    display: flex;
    flex-direction: column-reverse;
    gap: .6rem;
    z-index: 9999;
}

.toast {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .9rem 1.25rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    font-size: .875rem;
    font-weight: 500;
    transform: translateX(120%);
    transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .25s;
    opacity: 0;
}

.toast.show { transform: translateX(0); opacity: 1; }
.toast.success i { color: var(--success); }
.toast.danger  i { color: var(--danger); }
.toast.info    i { color: var(--accent); }

/* ─── ANIMATIONS ─────────────────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.view-content { animation: fadeUp .3s ease-out; }

/* ─── ACTIVITY TABLE ─────────────────────────────────── */
.activity-type {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
}

/* ─── EMPTY STATE ─────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state i { font-size: 2.5rem; opacity: .35; display: block; margin-bottom: .75rem; }
.empty-state p { font-size: .88rem; }

/* ─── SCROLLBARS ─────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ─── TWO-COL LAYOUT ─────────────────────────────────── */
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
@media (max-width: 1100px) { .grid-2-1 { grid-template-columns: 1fr; } }

/* ─── WEEKLY GRID ─────────────────────────────────── */
.horario-view-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.weekly-grid-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.schedule-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.jornada-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.jornada-header h4 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--text);
}

.jornada-header span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.jornada-count {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    white-space: nowrap;
}

.jornada-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.jornada-summary-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 0.75rem;
    align-items: center;
    box-shadow: var(--shadow);
}

.jornada-summary-card > div {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.jornada-summary-card span {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.jornada-summary-card strong {
    color: var(--text);
    font-size: 1.15rem;
}

.jornada-vespertino,
.jornada-summary-card.jornada-vespertino {
    border-left-color: #7c3aed;
}

.weekly-grid {
    display: grid;
    grid-template-columns: 80px repeat(6, minmax(140px, 1fr));
    grid-template-rows: auto repeat(var(--block-count, 14), minmax(45px, auto)); 
    min-width: 1000px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--border);
    gap: 1px;
}

.grid-day-header {
    background: #f8fafc;
    padding: 0.75rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.grid-time-label {
    background: #f8fafc;
    padding: 0.35rem;
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border);
}

.grid-time-label .block-number {
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 800;
    margin-bottom: 2px;
}

.grid-bg-cell {
    background: white;
    min-height: 45px;
}

.horario-card {
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.72rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    transition: var(--transition);
    margin: 1px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    z-index: 5;
    cursor: pointer;
}

.horario-card.is-class {
    background: #f0f7ff;
    border-left: 4px solid var(--primary);
}

.horario-card.is-reservation {
    background: #fffcf0;
    border-left: 4px solid var(--warning);
}

.horario-card:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    z-index: 50;
}

.horario-card .mod-name {
    font-weight: 700;
    color: var(--text);
    display: block;
    margin-bottom: 1px;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.horario-card .doc-name {
    color: var(--text-muted);
    font-size: 0.65rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.horario-card .time-range {
    margin-top: 2px;
    font-weight: 600;
    font-size: 0.65rem;
    color: var(--primary);
    opacity: 0.8;
}

.horario-card .sala-info {
    display: none; /* Already in header */
}

.view-tabs {
    display: inline-flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 1.5rem;
}

.view-tab {
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    transition: var(--transition);
}

.view-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
/* ─── CUSTOM CONFIRM MODALS ─────────────────────────── */
.confirm-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    z-index: 10000;
    opacity: 0; visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.confirm-overlay.active { opacity: 1; visibility: visible; }

.confirm-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
}

.confirm-overlay.active .confirm-box { transform: scale(1) translateY(0); }

.confirm-icon {
    width: 60px; height: 60px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 1.5rem;
}

.confirm-icon.warning { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.confirm-icon.question { background: rgba(59, 130, 246, 0.1); color: var(--accent); }

.confirm-title { font-family: 'Outfit', sans-serif; font-size: 1.25rem; font-weight: 700; margin-bottom: 0.75rem; color: var(--text); }
.confirm-message { color: var(--text-muted); font-size: 0.95rem; line-height: 1.5; margin-bottom: 2rem; }

.confirm-btns { display: flex; gap: 0.75rem; justify-content: center; }
.confirm-btns .btn { flex: 1; justify-content: center; padding: 0.75rem; }

/* --- CARRERA CARDS & DETAIL --------------------------- */
.carrera-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.carrera-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}

.carrera-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 40px; height: 40px;
    background: linear-gradient(135deg, transparent 50%, var(--primary-light) 50%);
    opacity: 0;
    transition: var(--transition);
}

.carrera-card:hover::after { opacity: 1; }

.carrera-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.carrera-icon {
    width: 42px; height: 42px;
    background: var(--primary-light);
    color: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.carrera-code {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg);
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
}

.carrera-card-body h3 {
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.carrera-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.carrera-progress {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

.carrera-progress .progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #6366f1);
    border-radius: 3px;
}

.carrera-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
    opacity: 0.8;
}

/* Carrera Detail View */
.carrera-detail-container {
    animation: fadeUp 0.4s ease-out;
}

.carrera-detail-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    background: var(--card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.btn-back {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

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

.header-info { flex: 1; }
.header-info h2 { font-size: 1.5rem; margin-bottom: 0.2rem; }

.header-badges {
    display: flex;
    gap: 0.5rem;
}

.semester-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.semester-column {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.semester-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-light);
}

.sem-number {
    width: 28px; height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.semester-header h4 { font-size: 1rem; color: var(--text); }

.module-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.module-item {
    padding: 0.85rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: var(--transition);
}

.module-item:hover {
    border-color: var(--accent);
    background: white;
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

.module-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.module-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.module-docente {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.module-action { color: var(--accent); opacity: 0.4; transition: var(--transition); }
.module-item:hover .module-action { opacity: 1; transform: translateX(2px); }

.empty-semester {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.6;
}

.empty-semester i { font-size: 1.5rem; }
.empty-semester span { font-size: 0.8rem; }

/* --- DOCUMENT MANAGEMENT --------------------------- */
.badge-pendiente { background: rgba(245,158,11,.12); color: #d97706; border: 1px solid rgba(245,158,11,0.3); }
.badge-aprobado  { background: rgba(16,185,129,.12); color: #059669; border: 1px solid rgba(16,185,129,0.3); }
.badge-rechazado  { background: rgba(239,68,68,.12);  color: #ef4444; border: 1px solid rgba(239,68,68,0.3); }

.comment-bubble {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    margin-top: 0.25rem;
    display: inline-block;
    max-width: 200px;
    white-space: normal;
    word-break: break-word;
    border-left: 3px solid var(--accent);
}

.file-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg);
}

.file-upload-zone:hover {
    border-color: var(--accent);
    background: var(--primary-light);
}

.file-upload-zone i {
    font-size: 2.5rem;
    color: var(--accent);
    display: block;
    margin-bottom: 1rem;
}

/* ─── SCHEDULE GRID ────────────────────────── */
.schedule-grid-container {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.schedule-grid {
    display: grid;
    grid-template-columns: 80px repeat(6, 1fr);
    background: var(--border);
    gap: 1px;
}

.schedule-header-cell {
    background: var(--bg);
    padding: 1rem .5rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.schedule-time-cell {
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.75rem .5rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.schedule-cell {
    background: var(--card);
    min-height: 60px;
    position: relative;
    transition: background .2s;
}

.schedule-block {
    position: absolute;
    inset: 4px;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.3;
    z-index: 10;
    cursor: default;
    transition: transform .2s, box-shadow .2s;
}

.schedule-block:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
    z-index: 20;
}

.schedule-block strong {
    font-size: 0.85rem;
    display: block;
    margin-bottom: 0.2rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.schedule-block .room {
    opacity: 0.9;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.schedule-block .time {
    margin-top: auto;
    font-size: 0.7rem;
    opacity: 0.8;
    font-weight: 700;
}

/* Dynamic colors for blocks */
.block-color-0 { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.block-color-1 { background: linear-gradient(135deg, #10b981, #059669); }
.block-color-2 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.block-color-3 { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.block-color-4 { background: linear-gradient(135deg, #ec4899, #db2777); }
.block-color-5 { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.block-color-6 { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.block-color-7 { background: linear-gradient(135deg, #6366f1, #4f46e5); }

@media (max-width: 1024px) {
    .schedule-grid {
        grid-template-columns: 60px repeat(6, 150px);
        overflow-x: auto;
    }
}

/* ─── MALLA CURRICULAR GRID ─────────────────── */
.malla-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.view-switcher {
    display: flex;
    background: var(--bg);
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    width: fit-content;
}

.view-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.view-btn.active {
    background: var(--card);
    color: var(--primary);
    box-shadow: var(--shadow);
}

.malla-grid {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    padding-bottom: 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.malla-semester-col {
    min-width: 280px;
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.malla-semester-header {
    background: var(--primary);
    color: white;
    padding: 0.85rem;
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: var(--shadow);
}

.malla-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: var(--transition);
    position: relative;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent);
}

.malla-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-left-color: var(--primary);
}

.malla-card-code {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.malla-card-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.malla-card-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.malla-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    margin-top: 0.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    opacity: 0.6;
    transition: opacity 0.2s;
}

.malla-card:hover .malla-card-actions {
    opacity: 1;
}
