/* ============================================================
   Sistema de gestión educativa — tema claro
   ============================================================ */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef2ff;
    --primary-border: #c7d2fe;

    --success: #059669;
    --success-soft: #ecfdf5;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --info: #0284c7;
    --info-soft: #f0f9ff;

    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-alt: #fafbfc;

    --text: #111827;
    --text-soft: #4b5563;
    --text-muted: #9ca3af;

    --border: #e5e7eb;
    --border-strong: #d1d5db;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .1), 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-lg: 0 10px 25px rgba(16, 24, 40, .1), 0 4px 10px rgba(16, 24, 40, .04);
    --shadow-xl: 0 25px 50px rgba(16, 24, 40, .18);

    --sidebar-w: 254px;
    --header-h: 66px;
}

* { box-sizing: border-box; }

/* Varios contenedores fijan `display`, que le gana al atributo hidden. */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* ---------------------------------------------------- layout */

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    transition: transform .22s ease;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 18px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.brand-logo { display: block; width: 100%; line-height: 0; }
.brand-logo img {
    width: 100%;
    max-width: 178px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
    text-align: center;
}

/* El logo del encabezado solo aparece cuando la barra lateral se oculta. */
.topbar-logo { display: none; line-height: 0; flex-shrink: 0; }
.topbar-logo img { height: 30px; width: auto; display: block; }
.topbar-title { min-width: 0; }
.topbar-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }

.nav-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    padding: 14px 10px 6px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-weight: 550;
    transition: background .13s, color .13s;
    text-decoration: none;
}

.nav a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }

.nav a.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 650;
}

.nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav .count {
    margin-left: auto;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 20px;
}

.sidebar-foot {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--text-muted);
}
.sidebar-foot .dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: var(--success); margin-right: 6px;
}
.user-chip { display: flex; flex-direction: column; gap: 2px; }
.user-chip strong { color: var(--text); font-size: 13px; }
.user-chip span { font-size: 11px; color: var(--text-muted); }

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--header-h);
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 26px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar h1 { font-size: 18px; }
.topbar .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-actions { display: flex; gap: 9px; align-items: center; }
.topbar-user {
    position: relative;
    flex-shrink: 0;
    padding-left: 12px;
    margin-left: 2px;
    border-left: 1px solid var(--border);
}
.topbar-user > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius-sm);
    padding: 4px 6px 4px 4px;
}
.topbar-user > summary::-webkit-details-marker { display: none; }
.topbar-user > summary:hover { background: var(--surface-alt); }
.topbar-user[open] > summary { background: var(--surface-alt); }
.topbar-user > summary > svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform .15s;
}
.topbar-user[open] > summary > svg { transform: rotate(180deg); }
.topbar-user .avatar {
    width: 34px;
    height: 34px;
    font-size: 12px;
}
.topbar-user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}
.topbar-user-meta strong {
    font-size: 13px;
    font-weight: 650;
    color: var(--text);
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-user-meta span {
    font-size: 11px;
    color: var(--text-muted);
}
.topbar-user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 80;
    padding: 6px;
    animation: campana-entra .15s ease both;
}
.topbar-user-menu-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.topbar-user-menu-head strong { font-size: 13.5px; }
.topbar-user-menu-head span { font-size: 12px; color: var(--text-muted); }
.topbar-user-menu a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-weight: 550;
    text-decoration: none;
}
.topbar-user-menu a:hover {
    background: var(--danger-soft);
    color: var(--danger);
    text-decoration: none;
}
.topbar-user-menu a svg { width: 16px; height: 16px; }

/* ------------------------------------------- campana de avisos */

.campana { position: relative; flex-shrink: 0; }

.campana-btn {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 38px; height: 38px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-soft);
    transition: background .14s, border-color .14s, color .14s;
}
.campana-btn:hover {
    background: var(--surface-alt);
    border-color: var(--border-strong);
    color: var(--text);
}
.campana-btn:active { transform: translateY(1px); }
.campana-btn svg { width: 19px; height: 19px; }

/* Con avisos sin resolver la campana se tiñe, para que se note sin gritar. */
.campana-btn.hay { color: var(--danger); border-color: #fecaca; }
.campana-btn.hay:hover { background: var(--danger-soft); border-color: var(--danger); }
.campana-btn.hay svg { animation: campana-toca 2.4s ease 2; transform-origin: 50% 15%; }

/* Va despues de .hay: con el panel abierto manda el estado abierto,
   si no quedaria la campana roja sobre el fondo violeta. */
.campana-btn.abierta,
.campana-btn.hay.abierta {
    background: var(--primary-soft);
    border-color: var(--primary-border);
    color: var(--primary);
}
.campana-btn.abierta svg { animation: none; }

@keyframes campana-toca {
    0%, 62%, 100% { transform: rotate(0); }
    66% { transform: rotate(11deg); }
    70% { transform: rotate(-9deg); }
    74% { transform: rotate(6deg); }
    78% { transform: rotate(-4deg); }
    82% { transform: rotate(0); }
}

.campana-punto {
    position: absolute;
    top: -5px; right: -5px;
    box-sizing: border-box;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
    border: 1.5px solid var(--surface);
    box-shadow: 0 1px 3px rgba(220, 38, 38, .35);
}

@media (prefers-reduced-motion: reduce) {
    .campana-btn.hay svg { animation: none; }
}

.campana-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 380px;
    max-height: min(70vh, 560px);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 80;
    animation: campana-entra .15s ease both;
}

@keyframes campana-entra {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

.campana-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.campana-head h3 { margin: 0; font-size: 14px; }

.campana-vacio {
    padding: 34px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
.campana-vacio svg {
    width: 34px; height: 34px;
    color: var(--success);
    margin-bottom: 10px;
}

.campana-lista { display: flex; flex-direction: column; }

.campana-pie {
    padding: 11px 16px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 12.5px;
}

/* ------------------------------------------------ aviso suelto */

.aviso {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: opacity .15s, background .15s;
}
.aviso:last-child { border-bottom: 0; }
.aviso.listo { background: var(--success-soft); }
.aviso.descartado { opacity: .5; }

.aviso-top {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 8px;
}

.aviso-cuando {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
    padding: 3px 9px;
    border-radius: 999px;
}
.aviso-cuando svg { width: 12px; height: 12px; }
.aviso-cuando.u-hoy     { background: var(--danger-soft);  color: var(--danger); }
.aviso-cuando.u-manana  { background: var(--warning-soft); color: var(--warning); }
.aviso-cuando.u-pronto  { background: var(--primary-soft); color: var(--primary); }

.aviso-descartar {
    background: none; border: 0; cursor: pointer;
    color: var(--text-muted);
    padding: 3px; border-radius: 6px;
    display: inline-flex;
}
.aviso-descartar:hover { background: var(--surface-alt); color: var(--text); }
.aviso-descartar svg { width: 14px; height: 14px; }

.aviso-curso {
    display: flex; align-items: center; gap: 7px;
    flex-wrap: wrap;
    margin-bottom: 7px;
}
.aviso-curso strong { font-size: 13px; }

.aviso-datos {
    display: flex; flex-direction: column; gap: 3px;
    font-size: 12px; color: var(--text-muted);
    margin-bottom: 11px;
}
.aviso-datos span { display: flex; align-items: center; gap: 6px; }
.aviso-datos svg { width: 13px; height: 13px; flex-shrink: 0; }

.aviso-checks { display: flex; flex-direction: column; gap: 6px; }

.check {
    display: flex; align-items: center; gap: 9px;
    font-size: 12.5px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
    transition: background .12s, border-color .12s;
}
.check:hover { background: var(--surface-alt); }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }

.check-caja {
    width: 18px; height: 18px;
    border: 1.5px solid var(--border-strong);
    border-radius: 5px;
    display: grid; place-items: center;
    flex-shrink: 0;
    transition: background .12s, border-color .12s;
}
.check-caja svg { width: 12px; height: 12px; color: #fff; opacity: 0; }

.check-txt { display: flex; align-items: center; gap: 6px; }
.check-txt svg { width: 13px; height: 13px; color: var(--text-muted); }

.check.si { border-color: var(--success); background: var(--success-soft); }
.check.si .check-caja { background: var(--success); border-color: var(--success); }
.check.si .check-caja svg { opacity: 1; }
.check.si .check-txt svg { color: var(--success); }

.aviso-listo {
    display: flex; align-items: center; gap: 6px;
    margin-top: 9px;
    font-size: 11.5px; font-weight: 600;
    color: var(--success);
}
.aviso-listo svg { width: 13px; height: 13px; }

.burger {
    display: none;
    background: none; border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 38px; height: 38px;
    cursor: pointer;
    align-items: center; justify-content: center;
}

.content { padding: 24px 26px 60px; }

/* ------------------------------- navegación sin recarga */

/* Linea fina bajo el encabezado mientras se pide la sección nueva. */
.route-progress {
    position: sticky;
    top: var(--header-h);
    height: 2px;
    z-index: 39;
    overflow: hidden;
    pointer-events: none;
}

.route-progress span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary), #8b7cf6);
    opacity: 0;
}

.route-progress.on span {
    opacity: 1;
    /* Avanza hasta cerca del final y espera: no se sabe cuanto tarda. */
    animation: barra-carga 1.1s cubic-bezier(.2, .8, .3, 1) forwards;
}

@keyframes barra-carga {
    0%   { width: 0; }
    45%  { width: 62%; }
    100% { width: 88%; }
}

.content.saliendo { opacity: .45; transition: opacity .13s ease; }
.content.entrando { animation: entrada-vista .2s ease both; }

@keyframes entrada-vista {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .content.saliendo { opacity: 1; }
    .content.entrando { animation: none; }
    .route-progress.on span { animation: none; width: 88%; }
}

/* ---------------------------------------------------- cards */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-head {
    display: flex; align-items: center; gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14.5px; }
.card-head .sub { font-size: 12px; color: var(--text-muted); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px; }

.grid { display: grid; gap: 16px; align-items: start; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); align-items: stretch; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* ---------------------------------------------------- stat */

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 14px;
    align-items: flex-start;
    min-width: 0;
    transition: box-shadow .15s, transform .15s;
}
.stat > div:last-child {
    min-width: 0;
    flex: 1;
}
a.stat-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}
a.stat-link:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-border);
    text-decoration: none;
}
.stat:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat-icon {
    width: 42px; height: 42px; border-radius: 11px;
    display: grid; place-items: center; flex-shrink: 0;
}
.stat-icon svg { width: 21px; height: 21px; }
.stat-icon.i-primary { background: var(--primary-soft); color: var(--primary); }
.stat-icon.i-success { background: var(--success-soft); color: var(--success); }
.stat-icon.i-danger  { background: var(--danger-soft); color: var(--danger); }
.stat-icon.i-warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.i-info    { background: var(--info-soft); color: var(--info); }

.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 27px; font-weight: 700; line-height: 1.15; margin-top: 3px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value.is-pos { color: var(--success); }
.stat-value.is-neg { color: var(--danger); }
.stat-hint { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background .13s, border-color .13s, box-shadow .13s, opacity .13s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(79,70,229,.3); }
.btn-primary:hover { background: var(--primary-dark); }

.btn-ghost { border-color: var(--border-strong); color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-alt); border-color: var(--text-muted); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-soft-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.btn-soft-danger:hover { background: #fee2e2; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }

.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; }
.btn-icon svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-wa { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.btn-wa:hover { background: #d1fae5; }

/* ---------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.field .help { font-size: 11.5px; color: var(--text-muted); }

input[type=text], input[type=search], input[type=date], input[type=number],
input[type=email], input[type=tel], input[type=time], input[type=month],
input[type=password],
select, textarea {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--text);
    transition: border-color .13s, box-shadow .13s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .13);
}
textarea { resize: vertical; min-height: 72px; }
input::placeholder { color: var(--text-muted); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

input[readonly] { background: var(--surface-alt); color: var(--text-soft); cursor: default; }

.horario-editor { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; width: 100%; }
.horario-rows { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.horario-row {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) 118px 118px auto;
    gap: 10px;
    align-items: end;
    width: 100%;
}
.horario-row .horario-del { margin-bottom: 1px; }

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 15px;
    margin: 0 0 15px;
}
legend { font-size: 12px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .05em; padding: 0 6px; }

.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
    width: 40px; height: 22px; border-radius: 20px;
    background: var(--border-strong); position: relative; transition: background .16s;
    flex-shrink: 0;
}
.switch .track::after {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; transition: transform .16s;
    box-shadow: var(--shadow-sm);
}
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ---------------------------------------------------- search */

.searchbox { position: relative; flex: 1; max-width: 420px; }
.searchbox svg {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.searchbox input { padding-left: 34px; }

.toolbar {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap; margin-bottom: 16px;
}

/* ---------------------------------------------------- table */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; }

table.data th a.sort {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
table.data th a.sort:hover { color: var(--primary); text-decoration: none; }
table.data th a.sort.is-sorted { color: var(--primary-dark); }

table.data td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-alt); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tr.is-debtor { background: #fff7f7; }
table.data tr.is-debtor:hover { background: #fef0f0; }
table.data tr.is-inactive td { color: var(--text-muted); }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.actions-cell { display: flex; gap: 5px; justify-content: flex-end; align-items: center; white-space: nowrap; }

.table-cursos {
    width: 100%;
    min-width: 0;
    font-size: 12.5px;
}
.table-cursos th,
.table-cursos td {
    padding: 7px 8px;
}
.table-cursos .chip {
    max-width: 86px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    font-size: 10.5px;
    padding: 1px 6px;
}
.table-cursos .col-nombre {
    max-width: 160px;
}
.table-cursos .col-nombre a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.table-cursos .col-horario,
.table-cursos .col-prof {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.table-cursos .col-fecha {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
}
.table-cursos .col-cuota {
    font-size: 12.5px;
}
.table-cursos .badge {
    padding: 1px 7px;
    font-size: 10.5px;
}

table.data th.col-acciones,
table.data td.col-acciones {
    position: sticky;
    right: 0;
    min-width: 72px;
    background: var(--surface);
    z-index: 1;
    box-shadow: -8px 0 8px -8px rgba(15, 23, 42, .12);
}
table.data thead th.col-acciones { z-index: 2; background: var(--surface); }
table.data tbody tr:hover td.col-acciones { background: var(--surface-alt); }

.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary-dark);
    display: grid; place-items: center;
    font-size: 11.5px; font-weight: 700; flex-shrink: 0;
}
.person .who { min-width: 0; flex: 1; }
.person .name {
    display: block;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.person .meta {
    display: block;
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------------------------------------------------- badges */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 650;
    white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
button.badge-btn {
    cursor: pointer;
    border: 0;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 650;
}
button.badge-btn:hover { filter: brightness(0.93); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info    { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: #f3f4f6; color: var(--text-soft); }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }
.badge svg { width: 13px; height: 13px; }

.chip {
    display: inline-block;
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-soft);
}

/* ---------------------------------------------------- pagination */

.pagination {
    display: flex; align-items: center; gap: 8px;
    padding: 13px 18px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.pagination .info { font-size: 12.5px; color: var(--text-muted); margin-right: auto; }
.pagination a, .pagination span.cur {
    min-width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 9px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 13px; font-weight: 600;
    color: var(--text-soft);
    text-decoration: none;
}
.pagination a:hover { background: var(--surface-alt); text-decoration: none; }
.pagination span.cur { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .gap { border: none; color: var(--text-muted); }

/* ---------------------------------------------------- empty */

.empty { padding: 54px 20px; text-align: center; }
.empty svg { width: 42px; height: 42px; color: var(--border-strong); margin-bottom: 12px; }
.empty h4 { font-size: 15px; margin-bottom: 5px; }
.empty p { color: var(--text-muted); margin: 0 0 16px; font-size: 13px; }

/* ---------------------------------------------------- modal */

.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(17, 24, 39, .45);
    backdrop-filter: blur(2px);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
    z-index: 100;
    opacity: 0;
    animation: fade .16s ease forwards;
}
@keyframes fade { to { opacity: 1; } }

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 720px;
    animation: pop .18s cubic-bezier(.2, .9, .3, 1.2) forwards;
    margin: auto;
}
.modal.sm { max-width: 440px; }
.modal.lg { max-width: 820px; }

/* En los formularios dos columnas se leen mejor que un auto-fit irregular. */
.modal .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 620px) {
    .modal .form-grid { grid-template-columns: 1fr; }
    .horario-row { grid-template-columns: 1fr 1fr auto; }
    .horario-row .field:first-child { grid-column: 1 / -1; }
}
@keyframes pop { from { transform: scale(.96) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
    display: flex; align-items: center; gap: 12px;
    padding: 17px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; }
.modal-head .sub { font-size: 12.5px; color: var(--text-muted); }
.modal-close {
    margin-left: auto; background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 5px; border-radius: 6px; display: grid; place-items: center;
}
.modal-close:hover { background: var(--surface-alt); color: var(--text); }
.modal-close svg { width: 19px; height: 19px; }

.modal-body { padding: 20px; }
.modal-foot {
    display: flex; gap: 9px; justify-content: flex-end;
    padding: 15px 20px; border-top: 1px solid var(--border);
    background: var(--surface-alt);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---------------------------------------------------- toast */

.toasts {
    position: fixed; bottom: 22px; right: 22px;
    display: flex; flex-direction: column; gap: 9px;
    z-index: 200;
}
.toast {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 12px 16px;
    min-width: 260px; max-width: 400px;
    font-size: 13.5px; font-weight: 550;
    animation: slidein .2s ease;
}
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast.ok svg { color: var(--success); }
.toast.err svg { color: var(--danger); }

/* ---------------------------------------------------- misc */

.spinner {
    width: 15px; height: 15px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
.spinner.dark { border-color: var(--border-strong); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

.bar { height: 7px; background: var(--surface-alt); border-radius: 20px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 20px; background: var(--primary); }

.list-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .rank {
    width: 24px; height: 24px; border-radius: 7px;
    background: var(--surface-alt); color: var(--text-soft);
    display: grid; place-items: center; font-size: 11.5px; font-weight: 700; flex-shrink: 0;
}

.kv { display: flex; flex-direction: column; gap: 3px; }
.kv .k { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kv .v { font-size: 14px; font-weight: 550; }

.alert {
    display: flex; gap: 11px; align-items: flex-start;
    padding: 13px 15px; border-radius: var(--radius-sm);
    font-size: 13.5px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-danger { background: var(--danger-soft); color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: var(--info-soft); color: #075985; border: 1px solid #bae6fd; }
.alert-warning { background: var(--warning-soft); color: #92400e; border: 1px solid #fde68a; }

.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 650; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 14px; } .mt-4 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; } .mb-3 { margin-bottom: 14px; }
.flex { display: flex; align-items: center; gap: 9px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap-gap { flex-wrap: wrap; }

/* ---------------------------------------------------- responsive */

.sidebar-scrim {
    display: none;
    position: fixed; inset: 0;
    background: rgba(17, 24, 39, .4);
    z-index: 50;
}

/* Las tablas tienen mas columnas de las que entran en pantallas chicas.
   En vez de desbordar, las secundarias se van ocultando por prioridad. */
@media (max-width: 1400px) { .hide-xl { display: none !important; } }
@media (max-width: 1180px) { .hide-lg { display: none !important; } }

/* Inverso de hide-lg / hide-md: repone el dato dentro de la celda principal
   justo cuando su columna deja de mostrarse. Lleva !important porque conviven
   con selectores mas especificos como `.person .meta`. */
.only-lg, .only-md { display: none !important; }
@media (max-width: 1180px) { .only-lg { display: block !important; } }
@media (max-width: 1000px) { .only-md { display: block !important; } }
@media (max-width: 1000px) { .hide-md { display: none !important; } }
@media (max-width: 700px)  { .hide-sm { display: none !important; } }

@media (max-width: 1180px) {
    :root { --sidebar-w: 228px; }
    table.data th, table.data td { padding: 10px 10px; }
    .content { padding: 20px 18px 50px; }
    .topbar { padding: 0 18px; }
    /* Con cuatro tarjetas, dos columnas cierran mejor que un 3+1 desparejo. */
    .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
    .grid-stats { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
    .sidebar { transform: translateX(-100%); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .sidebar-scrim { display: block; }
    .main { margin-left: 0; }
    .burger { display: inline-flex; }
    .topbar-logo { display: block; }
    .content { padding: 18px 15px 50px; }
    .topbar { padding: 0 15px; gap: 11px; }
    .topbar-user-meta { display: none; }
    .topbar-user { padding-left: 8px; gap: 6px; }
}

@media (max-width: 640px) {
    .topbar h1 { font-size: 15px; }
    .topbar .sub { display: none; }
    .topbar-logo img { height: 26px; }
    .modal-foot { flex-direction: column-reverse; }
    .modal-foot .btn { width: 100%; }
    table.data th, table.data td { padding: 9px 8px; }
    .stat { padding: 14px; gap: 11px; }
    .stat-value { font-size: 22px; }
}

/* Sin limite, un nombre largo estira la tabla y empuja las columnas
   importantes fuera de la pantalla. */
@media (max-width: 760px) {
    .person { max-width: 210px; }
    .card-head { flex-wrap: wrap; }
    .toolbar .searchbox { max-width: none; }
}

@media (max-width: 540px) {
    .person { max-width: 150px; }
    .person .avatar { display: none; }
}

@media print {
    .sidebar, .topbar, .toolbar, .pagination, .no-print, .password-gate { display: none !important; }
    .main { margin-left: 0; }
    .content { padding: 0; }
    .card { border: none; box-shadow: none; }
    body { background: #fff; }
    a { color: #111 !important; text-decoration: none !important; }
    .print-only { display: flex !important; }
    .print-masthead { margin-bottom: 18px; padding-bottom: 12px; }
    .print-curso { break-inside: auto; page-break-inside: auto; }
    .print-curso > header { break-after: avoid; page-break-after: avoid; }
}

.print-only { display: none !important; }
.print-masthead {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border);
}
.print-masthead img { height: 52px; width: auto; }
.print-masthead h2 { font-size: 18px; margin: 0 0 2px; }
.print-masthead p { margin: 0; font-size: 13px; color: var(--text-muted); }
.print-curso {
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.print-curso:last-child { border-bottom: none; }
.print-curso > header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}
.print-curso h3 {
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 6px;
}
.print-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    font-size: 12.5px;
    color: var(--text-soft);
}
.print-count {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ---------------------------------------------------- login */

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 18px;
    position: relative;
    background: #eef2ff;
}
.login-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(900px 420px at 80% -10%, rgba(99, 102, 241, .28), transparent 55%),
        radial-gradient(700px 380px at 0% 100%, rgba(14, 165, 233, .16), transparent 50%),
        linear-gradient(180deg, #eef2ff 0%, #f8fafc 55%, #f1f5f9 100%);
}
.login-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .45;
    background-image: radial-gradient(#a5b4fc 0.7px, transparent 0.7px);
    background-size: 22px 22px;
    mask-image: linear-gradient(180deg, rgba(0,0,0,.55), transparent 80%);
}
.login-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
}
.login-card {
    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 24px;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, .04),
        0 18px 50px rgba(79, 70, 229, .12);
    padding: 36px 32px 32px;
    backdrop-filter: blur(16px);
}
.login-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 22px;
}
.login-logo {
    display: block;
    width: min(200px, 72%);
    height: auto;
}
.login-card h1 {
    font-size: 26px;
    letter-spacing: -.03em;
    text-align: center;
    color: #0f172a;
    margin: 0 0 6px;
}
.login-lead {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin: 0 0 26px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin: 0;
}
.login-field > span:first-child {
    font-size: 12px;
    font-weight: 650;
    color: #475569;
    letter-spacing: .02em;
}
.login-control {
    position: relative;
    display: block;
    height: 48px;
}
.login-control > svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #94a3b8;
    pointer-events: none;
    z-index: 1;
}
.login-card input[type="text"],
.login-card input[type="password"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 48px;
    min-height: 48px;
    margin: 0;
    padding: 0 44px 0 44px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #f8fafc;
    color: #0f172a;
    font-family: inherit;
    font-size: 15px;
    line-height: normal;
    box-shadow: none;
}
.login-card input[type="text"]::placeholder,
.login-card input[type="password"]::placeholder {
    color: #94a3b8;
    opacity: 1;
    font-size: 15px;
}
.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
    outline: none;
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .14);
}
.login-card input::-ms-reveal,
.login-card input::-ms-clear {
    display: none;
}
.login-eye {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: #94a3b8;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.login-eye:hover { color: #475569; background: #eef2ff; }
.login-eye svg { width: 18px; height: 18px; }
.login-submit {
    width: 100%;
    height: 48px;
    margin-top: 6px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 650;
    box-shadow: 0 10px 20px rgba(79, 70, 229, .25);
}
.login-submit:hover { box-shadow: 0 12px 24px rgba(79, 70, 229, .32); }
.login-card .alert { margin: 0 0 4px; }
.login-foot {
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
    margin: 16px 0 0;
    font-weight: 550;
}

@media (max-width: 480px) {
    .login-card { padding: 28px 20px 24px; border-radius: 20px; }
    .login-card h1 { font-size: 22px; }
}

/* Primer ingreso: no se cierra hasta elegir contraseña. */
.password-gate {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(17, 24, 39, .55);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 16px;
    overflow-y: auto;
}
