:root {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #172033;
    background: #f4f7fb;
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #f4f7fb; }
body { margin: 0; min-height: 100vh; background: #f4f7fb; }
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    min-height: 68px; display: flex; align-items: center; justify-content: space-between;
    gap: 20px; padding: 12px clamp(18px, 4vw, 52px);
    background: rgba(255,255,255,.96); border-bottom: 1px solid #dfe6ef;
    backdrop-filter: blur(12px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark, .login-logo {
    width: 42px; height: 42px; display: grid; place-items: center;
    border-radius: 12px; background: #12615c; color: white; font-size: 1.3rem; font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: #687386; font-size: .78rem; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-email { color: #5f697b; font-size: .88rem; }
.page-container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 60px; }

.page-heading, .attendance-heading {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 26px; margin-bottom: 26px;
}
.page-heading h1, .attendance-heading h1 { margin: 4px 0 4px; font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.05; }
.page-heading p, .attendance-heading p { margin: 0; color: #687386; }
.eyebrow { color: #12615c; text-transform: uppercase; letter-spacing: .09em; font-size: .76rem; font-weight: 800; }

.date-picker-card {
    min-width: 210px; padding: 12px 14px; background: white; border: 1px solid #dce3ec; border-radius: 14px;
    box-shadow: 0 8px 24px rgba(31, 48, 76, .06);
}
.date-picker-card span, .search-box span, .student-detail label span {
    display: block; margin-bottom: 6px; color: #687386; font-size: .75rem; font-weight: 700;
}
.date-picker-card input, .search-box input, .student-detail input, .student-detail select {
    width: 100%; min-height: 42px; border: 1px solid #cdd6e2; border-radius: 10px; padding: 8px 11px; background: white; color: #172033;
}

.course-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); gap: 18px; }
.course-card {
    min-height: 225px; display: flex; flex-direction: column; padding: 20px;
    border: 1px solid #dde5ee; border-radius: 18px; background: white;
    box-shadow: 0 10px 30px rgba(31, 48, 76, .07);
}
.course-card-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 28px; }
.course-tag { padding: 5px 9px; border-radius: 999px; background: #e9f4f2; color: #12615c; font-size: .76rem; font-weight: 800; }
.course-period { color: #7d8797; font-size: .78rem; }
.course-card h2 { margin: 0; font-size: 1.28rem; line-height: 1.2; }
.course-subject { color: #687386; margin: 8px 0 24px; }
.course-card .btn { margin-top: auto; }

.btn {
    min-height: 42px; border: 0; border-radius: 11px; padding: 9px 15px; cursor: pointer; font-weight: 750;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: #12615c; color: white; }
.btn-primary:hover:not(:disabled) { background: #0e504c; }
.btn-secondary { background: #eaf0f6; color: #27364a; }
.btn-ghost { background: transparent; color: #42516a; border: 1px solid #d6dee9; }
.btn-block { width: 100%; }

.alert { padding: 13px 15px; border-radius: 12px; margin: 0 0 20px; }
.alert-error { background: #fff0f1; border: 1px solid #f2c6cb; color: #962b38; }
.loading-state, .empty-state { padding: 40px; text-align: center; background: white; border: 1px solid #dde5ee; border-radius: 18px; color: #687386; }
.empty-state h1, .empty-state h2 { color: #172033; }

.summary-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 20px; }
.summary-card { min-height: 92px; padding: 14px; background: white; border: 1px solid #dde5ee; border-radius: 14px; }
.summary-card strong { display: block; font-size: 1.75rem; line-height: 1; }
.summary-card span { display: block; margin-top: 8px; color: #687386; font-size: .78rem; }

.attendance-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 24px 0 12px; }
.search-box { width: min(420px, 100%); }
.student-count { color: #687386; font-size: .85rem; white-space: nowrap; }
.attendance-list { display: grid; gap: 10px; }
.student-row {
    position: relative; padding: 15px 16px 12px; background: white; border: 1px solid #dde5ee; border-radius: 14px;
    transition: opacity .15s ease, box-shadow .15s ease;
}
.student-row.is-saving { opacity: .72; }
.student-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.student-name strong { display: block; font-size: .98rem; }
.student-name span { display: block; margin-top: 4px; color: #7a8595; font-size: .76rem; }
.status-buttons { display: grid; grid-template-columns: repeat(4, 44px); gap: 7px; }
.status-btn {
    width: 44px; height: 42px; border-radius: 10px; background: #f6f8fb; border: 1px solid #d8e0e9;
    color: #556174; cursor: pointer; font-weight: 850;
}
.status-btn.presente.active { background: #def5e8; border-color: #74c797; color: #17663b; }
.status-btn.retardo.active { background: #fff2cf; border-color: #e7bb51; color: #765614; }
.status-btn.falta.active { background: #ffe3e6; border-color: #e78892; color: #8e2834; }
.status-btn.justificada.active { background: #e7ebff; border-color: #919ee1; color: #384c9d; }
.student-detail { display: grid; grid-template-columns: 180px minmax(180px, 1fr) auto; gap: 10px; align-items: end; margin-top: 13px; padding-top: 13px; border-top: 1px dashed #d6dee9; }
.detail-toggle { margin-top: 10px; border: 0; background: transparent; padding: 0; color: #60728f; font-size: .76rem; cursor: pointer; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #e7f3f1 0, #f4f7fb 45%); }
.login-card { width: min(440px, 100%); background: white; border: 1px solid #dce4ed; border-radius: 20px; padding: 28px; box-shadow: 0 24px 65px rgba(31, 48, 76, .13); }
.login-heading { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.login-heading h1 { margin: 0; font-size: 1.5rem; }
.login-heading p { margin: 4px 0 0; color: #687386; }
.login-form { display: grid; gap: 16px; }
.login-form label > span { display: block; margin-bottom: 6px; color: #4c5a6f; font-size: .82rem; font-weight: 700; }
.login-form input[type="email"], .login-form input[type="password"] { width: 100%; min-height: 46px; border: 1px solid #cdd6e2; border-radius: 10px; padding: 9px 12px; }
.checkbox-row { display: flex; gap: 8px; align-items: center; color: #5d697b; font-size: .84rem; }
.checkbox-row span { margin: 0 !important; }
.login-note { margin: 20px 0 0; text-align: center; color: #7c8797; font-size: .78rem; }

@media (max-width: 900px) {
    .summary-grid { grid-template-columns: repeat(3, 1fr); }
    .student-detail { grid-template-columns: 1fr 1fr; }
    .student-detail .btn { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
    .page-container { width: min(100% - 20px, 1180px); padding-top: 20px; }
    .topbar { padding: 10px 12px; }
    .brand small, .user-email { display: none; }
    .page-heading { align-items: stretch; flex-direction: column; }
    .date-picker-card { width: 100%; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .attendance-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
    .attendance-toolbar { align-items: stretch; flex-direction: column; }
    .student-main { grid-template-columns: 1fr; }
    .status-buttons { grid-template-columns: repeat(4, 1fr); }
    .status-btn { width: 100%; height: 46px; }
    .student-detail { grid-template-columns: 1fr; }
    .course-grid { grid-template-columns: 1fr; }
}


.course-actions {
    margin-top: auto;
    display: grid;
    gap: 9px;
}
.course-card .course-actions .btn { margin-top: 0; }

.history-list { display: grid; gap: 12px; }
.history-session {
    overflow: hidden;
    background: white;
    border: 1px solid #dde5ee;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(31, 48, 76, .05);
}
.history-header {
    width: 100%;
    border: 0;
    background: transparent;
    padding: 16px 18px;
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    text-align: left;
    cursor: pointer;
    color: inherit;
}
.history-header:hover { background: #f8fafc; }
.history-date strong { display: block; font-size: 1rem; }
.history-date span { display: block; margin-top: 4px; color: #7a8595; font-size: .76rem; }
.history-metrics { display: flex; flex-wrap: wrap; gap: 7px; }
.history-pill {
    min-width: 72px;
    padding: 7px 9px;
    border-radius: 10px;
    background: #f5f7fa;
    border: 1px solid #e0e6ed;
    text-align: center;
}
.history-pill strong { display: block; font-size: .95rem; }
.history-pill span { display: block; margin-top: 2px; color: #778296; font-size: .68rem; }
.history-expand { color: #60728f; font-size: .82rem; font-weight: 750; white-space: nowrap; }
.history-detail { padding: 0 18px 18px; border-top: 1px solid #edf1f5; }
.history-detail-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0 10px;
}
.history-detail-toolbar span { color: #687386; font-size: .82rem; }
.history-students { display: grid; gap: 7px; }
.history-student {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px 48px;
    gap: 12px;
    align-items: center;
    min-height: 46px;
    padding: 9px 11px;
    border: 1px solid #e2e7ed;
    border-radius: 10px;
    background: #fbfcfd;
}
.history-student-name strong { display: block; font-size: .9rem; }
.history-student-name span { display: block; margin-top: 2px; color: #7a8595; font-size: .72rem; }
.history-justification { color: #687386; font-size: .78rem; }
.history-status {
    width: 38px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    font-size: .78rem;
    font-weight: 850;
    border: 1px solid #d8e0e9;
    background: #f6f8fb;
}
.history-status.status-p { background: #def5e8; border-color: #74c797; color: #17663b; }
.history-status.status-r { background: #fff2cf; border-color: #e7bb51; color: #765614; }
.history-status.status-f { background: #ffe3e6; border-color: #e78892; color: #8e2834; }
.history-status.status-j { background: #e7ebff; border-color: #919ee1; color: #384c9d; }

@media (max-width: 760px) {
    .history-header { grid-template-columns: 1fr; gap: 10px; }
    .history-expand { justify-self: start; }
    .history-detail-toolbar { align-items: stretch; flex-direction: column; }
    .history-student { grid-template-columns: minmax(0, 1fr) 44px; }
    .history-justification { grid-column: 1 / -1; grid-row: 2; }
}

/* Reporte de asistencia por rango de fechas */
.report-heading { align-items: center; }
.report-filter-card {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: 14px;
    align-items: end;
    margin-bottom: 20px;
    padding: 16px;
    background: white;
    border: 1px solid #dde5ee;
    border-radius: 16px;
}
.report-filter-card label > span {
    display: block;
    margin-bottom: 6px;
    color: #687386;
    font-size: .75rem;
    font-weight: 700;
}
.report-filter-card input {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cdd6e2;
    border-radius: 10px;
    padding: 8px 11px;
    background: white;
    color: #172033;
}
.report-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}
.report-note {
    margin-bottom: 24px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f7f9fc;
    border: 1px solid #dfe6ee;
    color: #5e6b7d;
    font-size: .82rem;
}
.report-section { margin-top: 28px; }
.section-heading-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 12px;
}
.section-heading-row h2 { margin: 0; font-size: 1.2rem; }
.section-heading-row p { margin: 5px 0 0; color: #748094; font-size: .82rem; }
.report-days {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}
.report-day-card {
    padding: 14px;
    background: white;
    border: 1px solid #dde5ee;
    border-radius: 14px;
}
.report-day-card > strong { display: block; }
.report-day-card > span { display: block; margin-top: 3px; color: #7a8595; font-size: .75rem; }
.report-day-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 12px; }
.report-day-metrics span { padding: 6px 4px; border-radius: 8px; background: #f5f7fa; text-align: center; font-size: .72rem; }
.report-search { width: min(340px, 100%); }
.report-table-wrap {
    width: 100%;
    overflow-x: auto;
    background: white;
    border: 1px solid #dde5ee;
    border-radius: 16px;
}
.report-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    font-size: .82rem;
}
.report-table th,
.report-table td {
    padding: 11px 10px;
    border-bottom: 1px solid #edf1f5;
    text-align: center;
    vertical-align: middle;
}
.report-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f7f9fc;
    color: #687386;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .025em;
}
.report-table th:first-child,
.report-table td:first-child { text-align: left; min-width: 240px; }
.report-table td strong { display: block; font-size: .86rem; }
.report-table td small { display: block; margin-top: 3px; color: #7a8595; }
.report-table tr.is-open > td { background: #fbfcfd; }
.report-detail-button { min-height: 34px; padding: 6px 10px; font-size: .75rem; }
.report-percent {
    display: inline-flex;
    min-width: 62px;
    justify-content: center;
    padding: 6px 8px;
    border-radius: 999px;
    font-weight: 800;
}
.report-percent.percent-high { background: #def5e8; color: #17663b; }
.report-percent.percent-mid { background: #fff2cf; color: #765614; }
.report-percent.percent-low { background: #ffe3e6; color: #8e2834; }
.report-detail-row td { padding: 0 !important; background: #f9fbfd; }
.report-student-detail { display: grid; gap: 6px; padding: 12px 18px 16px; }
.report-detail-item {
    display: grid;
    grid-template-columns: 100px 42px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 38px;
    padding: 6px 8px;
    border: 1px solid #e3e8ef;
    border-radius: 9px;
    background: white;
    text-align: left;
}
.report-detail-item > span:last-child { color: #687386; font-size: .78rem; }

@media (max-width: 800px) {
    .report-filter-card { grid-template-columns: 1fr 1fr; }
    .report-filter-card .btn { grid-column: 1 / -1; }
    .report-summary-grid { grid-template-columns: repeat(2, 1fr); }
    .report-table-heading { align-items: stretch; flex-direction: column; }
    .report-search { width: 100%; }
}

@media (max-width: 520px) {
    .report-filter-card { grid-template-columns: 1fr; }
    .report-filter-card .btn { grid-column: auto; }
    .report-summary-grid { grid-template-columns: 1fr 1fr; }
    .report-detail-item { grid-template-columns: 86px 42px minmax(0, 1fr); }
}

/* Selección de fecha según horario */
.schedule-heading { align-items: center; }
.schedule-summary-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
    padding: 16px 18px;
    background: white;
    border: 1px solid #dde5ee;
    border-radius: 16px;
}
.schedule-label,
.schedule-period span {
    display: block;
    margin-bottom: 7px;
    color: #687386;
    font-size: .75rem;
    font-weight: 750;
}
.schedule-days { display: flex; flex-wrap: wrap; gap: 7px; }
.schedule-day-pill {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid #cbd8e8;
    border-radius: 999px;
    background: #f5f8fc;
    color: #33445f;
    font-size: .78rem;
    font-weight: 800;
}
.schedule-period { text-align: right; }
.schedule-period strong { display: block; font-size: .88rem; }
.schedule-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.schedule-option-card {
    min-width: 0;
    padding: 20px;
    background: white;
    border: 1px solid #dde5ee;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(31, 48, 76, .04);
}
.schedule-option-card h2 { margin: 6px 0 8px; font-size: 1.2rem; }
.schedule-option-card > p { margin: 0 0 18px; color: #6e7b8e; font-size: .86rem; line-height: 1.5; }
.schedule-extra-card { border-style: dashed; }
.schedule-field { display: block; margin-bottom: 14px; }
.schedule-field > span {
    display: block;
    margin-bottom: 6px;
    color: #687386;
    font-size: .76rem;
    font-weight: 750;
}
.schedule-field small { font-weight: 500; }
.schedule-field select,
.schedule-field input {
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid #cdd6e2;
    border-radius: 10px;
    background: white;
    color: #172033;
    font-size: .9rem;
}
.schedule-selected-note {
    margin: 2px 0 14px;
    padding: 10px 12px;
    border: 1px solid #dfe6ee;
    border-radius: 10px;
    background: #f7f9fc;
    color: #5d6a7c;
    font-size: .78rem;
    line-height: 1.45;
}
.schedule-selected-note.is-captured {
    border-color: #9fd7b5;
    background: #eef9f2;
    color: #246543;
}
.schedule-selected-note.is-extra-day {
    border-color: #e4c36b;
    background: #fff9e8;
    color: #73591d;
}
.schedule-selected-note.is-normal-day {
    border-color: #b7c9e8;
    background: #f1f6fd;
    color: #3f5f8c;
}
.schedule-extra-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 4px;
}


.off-schedule-sessions {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid #d9e2ec;
}
.off-schedule-title {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 10px;
}
.off-schedule-title strong { font-size: .9rem; }
.off-schedule-title span { color: #6e7b8e; font-size: .78rem; line-height: 1.4; }
.off-schedule-session {
    width: 100%;
    border: 1px solid #d9e2ec;
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: left;
    cursor: pointer;
    color: #12233f;
    margin-top: 7px;
}
.off-schedule-session:hover { background: #f7fafc; }
.off-schedule-session small { color: #607086; white-space: nowrap; }

@media (max-width: 760px) {
    .schedule-summary-card { align-items: flex-start; flex-direction: column; }
    .schedule-period { text-align: left; }
    .schedule-choice-grid { grid-template-columns: 1fr; }
    .schedule-extra-actions { align-items: stretch; flex-direction: column-reverse; }
    .schedule-extra-actions .btn { width: 100%; }
    .off-schedule-session { align-items: flex-start; flex-direction: column; gap: 3px; }
}
