:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #17202a;
    --muted: #667085;
    --line: #d7dde5;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #315f9f;
    --green: #168a4a;
    --yellow: #b7791f;
    --red: #c53030;
    --shadow: 0 18px 45px rgba(22, 32, 42, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    height: 100dvh;
    background: linear-gradient(180deg, #102525 0%, #17202a 100%);
    color: white;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 26px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
    width: 62px;
    height: 62px;
    flex: 0 0 62px;
    object-fit: contain;
}
.brand strong { display: block; line-height: 1.15; }
.brand small { display: block; color: #b7c9c3; margin-top: 2px; }

nav {
    display: grid;
    gap: 6px;
    padding-bottom: 22px;
}
nav a {
    color: #dce8e4;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 650;
}
nav a.active, nav a:hover {
    background: rgba(15, 118, 110, .95);
    color: #fff;
    text-decoration: none;
}

.shell {
    margin-left: 250px;
    padding: 30px;
    min-height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: .76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(1.55rem, 3vw, 2.35rem); }
h2 { font-size: 1.1rem; }

.button, button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 750;
    cursor: pointer;
    min-height: 42px;
}
.button.small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: .82rem;
}
.button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.button.danger {
    background: #fff2f2;
    border-color: #e6a7a7;
    color: #a61b1b;
}
.button.danger:hover {
    background: #fee2e2;
}
.button:hover, button:hover { filter: brightness(.98); text-decoration: none; }

.flash {
    margin: 0 0 16px;
    border-radius: 8px;
    padding: 12px 14px;
    background: #e8f5ee;
    color: #14532d;
    border: 1px solid #b7dfc7;
}
.flash.error {
    background: #fff0f0;
    color: #9b1c1c;
    border-color: #f0b8b8;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
    margin: 0 0 18px;
    padding: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(22, 32, 42, .04);
}
.filters.compact { margin-top: 8px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: .88rem; font-weight: 700; }
.optional {
    color: #8a94a2;
    font-size: .76rem;
    font-weight: 600;
}
.support-copy {
    color: var(--muted);
    line-height: 1.6;
    margin: 0 0 18px;
}
.field-note {
    display: grid;
    gap: 4px;
    align-content: center;
    min-height: 68px;
    border: 1px solid #bcded8;
    border-radius: 8px;
    background: #edf8f6;
    color: var(--primary-dark);
    padding: 10px 12px;
}
.field-note span {
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.4;
}
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
    font: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: 3px solid rgba(15, 118, 110, .16);
    border-color: var(--primary);
}
textarea { resize: vertical; }

.hint {
    background: #edf7f6;
    border: 1px solid #c9e5e5;
    color: #275b5b;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-weight: 650;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.metric-link {
    color: inherit;
    text-decoration: none;
    display: block;
}
.metric-link article {
    height: 100%;
    transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.metric-link:hover article,
.metric-link:focus-visible article {
    border-color: var(--primary);
    box-shadow: 0 10px 24px rgba(24, 73, 75, .13);
    transform: translateY(-2px);
}
.print-school-header,
.print-only {
    display: none;
}
.permission-grid {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.permission-grid legend {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 750;
    padding: 0 6px;
}
.settings-users {
    align-items: start;
}
.certificate-footer {
    margin-top: 32px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 8px;
}
.certificate-footer p,
.certificate-footer span {
    margin: 0;
}
.certificate-signature {
    width: min(320px, 100%);
    margin: 62px auto 0;
    padding-top: 8px;
    border-top: 1px solid currentColor;
    text-align: center;
    font-weight: 700;
}
.formal-certificate {
    padding: 22px 8%;
}
.formal-certificate h3 {
    margin: 12px 0 28px;
    text-align: center;
    text-transform: uppercase;
    text-decoration: underline;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.45rem;
}
.formal-certificate p {
    margin: 18px 0;
    font-size: 1.02rem;
    line-height: 1.85;
    text-align: justify;
}
.metrics article, .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.metrics article {
    padding: 18px;
    display: grid;
    gap: 8px;
    border-top: 4px solid var(--primary);
}
.metrics span, .panel-head span { color: var(--muted); font-size: .86rem; font-weight: 650; }
.metrics strong { font-size: 2rem; }
.metrics small {
    color: var(--muted);
    font-size: .76rem;
    font-weight: 650;
}
.range-references {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.range-reference {
    padding: 18px;
    display: grid;
    gap: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 4px solid var(--primary);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.range-reference > span {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 650;
}
.range-line {
    display: grid;
    grid-template-columns: 104px 1fr;
    align-items: center;
    gap: 8px;
    border-left: 5px solid var(--line);
    border-radius: 7px;
    background: #f8fafc;
    padding: 7px 9px;
    color: var(--ink);
    line-height: 1.25;
}
.range-line.green { border-left-color: var(--green); }
.range-line.yellow { border-left-color: var(--yellow); }
.range-line.red { border-left-color: var(--red); }
.range-line.neutral { border-left-color: #7b8794; }
.range-line b {
    color: var(--muted);
    font-size: .72rem;
}
.range-line em {
    color: var(--ink);
    font-style: normal;
    font-weight: 800;
    text-align: right;
}

.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.panel { padding: 18px; margin-bottom: 18px; }
.panel::before {
    content: "";
    display: block;
    height: 3px;
    margin: -18px -18px 15px;
    border-radius: 8px 8px 0 0;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}
.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    margin-bottom: 14px;
}

.chart {
    width: 100%;
    height: 280px;
    display: block;
}

.report-explanation {
    display: grid;
    gap: 5px;
    border-left: 5px solid var(--accent);
    border-radius: 0 8px 8px 0;
    background: #edf3fb;
    color: #29496f;
    padding: 13px 16px;
    margin-bottom: 18px;
}
.report-explanation span {
    color: #53677e;
    font-size: .88rem;
}
.report-charts .panel { min-width: 0; }
.chart-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .86rem;
}
.chart-summary span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.risk-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.risk-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-left-width: 5px;
    border-radius: 8px;
    padding: 10px;
    background: #fff;
    color: var(--ink);
    display: grid;
    gap: 5px;
}
.risk-card:hover {
    text-decoration: none;
    background: #f8fafc;
}
.risk-card.green { border-left-color: var(--green); }
.risk-card.yellow { border-left-color: var(--yellow); }
.risk-card.red { border-left-color: var(--red); }
.risk-card.neutral { border-left-color: #7b8794; }
.risk-card span {
    min-height: 0;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 750;
}
.risk-card strong {
    font-size: 1.75rem;
    line-height: 1;
}
.risk-card em {
    color: var(--muted);
    font-size: .72rem;
    font-style: normal;
    font-weight: 750;
}
.risk-card small {
    color: var(--muted);
    font-size: .74rem;
}
.risk-chart { height: 160px; margin-top: 8px; }
.legacy-monthly-dashboard,
.risk-list-panel { display: none !important; }
.risk-list-panel.is-visible { display: block !important; }
.risk-overview .panel,
.grade-overview .panel {
    display: grid;
    align-content: start;
    gap: 8px;
}
.risk-overview .risk-cards,
.grade-overview .risk-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.risk-overview .risk-chart,
.grade-overview .risk-chart {
    display: block;
    height: 170px;
    margin-top: 0;
}
.grade-overview .risk-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grade-overview .risk-card {
    padding: 10px;
    gap: 4px;
}
.grade-overview .risk-card span {
    min-height: 0;
}
.grade-overview .risk-chart {
    height: 180px;
}
.status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 999px;
    margin-right: 8px;
    vertical-align: middle;
    background: #7b8794;
}
.status-dot.green { background: var(--green); }
.status-dot.yellow { background: var(--yellow); }
.status-dot.red { background: var(--red); }
.status-dot.neutral { background: #7b8794; }
.risk-list-panel .panel-head > div { display: grid; gap: 5px; }
.risk-filters { box-shadow: none; background: #f8fafc; }
.risk-list-total {
    margin: 12px 0 0;
    color: var(--muted);
    text-align: right;
}
.grade-student-list {
    display: grid;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 6px;
}
.grade-table-wrap {
    max-height: 72vh;
}
.grade-lines {
    display: grid;
    gap: 10px;
}
.subject-key {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
    margin: 8px 0 12px;
}
.subject-key span,
.grade-calculated {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 850;
    padding: 7px 9px;
}
section.panel:has(.grade-lines) .panel-head span + span {
    display: none;
}
.grade-line {
    display: flex;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    padding: 10px;
}
.grade-line-student {
    flex: 0 0 130px;
    display: grid;
    align-content: start;
    gap: 6px;
    padding: 8px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
}
.grade-line-student strong {
    line-height: 1.22;
}
.grade-line-student small {
    color: var(--muted);
    font-weight: 800;
}
.grade-line-notes {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 2px;
}
.grade-strip {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 8px;
}
.grade-strip-final {
    align-self: stretch;
}
.grade-strip-title {
    align-self: center;
    color: var(--accent);
    font-size: .78rem;
    font-weight: 900;
    white-space: nowrap;
}
.grade-subject-averages {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
}
.grade-subject-chip {
    display: grid;
    grid-template-columns: auto minmax(90px, auto) auto;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 8px 9px;
    white-space: nowrap;
    font-weight: 850;
}
.grade-subject-chip b {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
}
.grade-subject-chip strong {
    color: var(--ink);
    font-size: 1rem;
}
.student-form:has(input[name="student_id"][value]:not([value="0"])) .panel-head h2 {
    font-size: 0;
}
.student-form:has(input[name="student_id"][value]:not([value="0"])) .panel-head h2::after {
    content: "Editar ficha de alumno";
    font-size: 1.2rem;
}
.grade-table {
    min-width: 1450px;
}
.grade-table th,
.grade-table td {
    padding: 8px;
}
.grade-table th:first-child,
.grade-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 4;
    width: 180px;
    min-width: 180px;
}
.grade-table td:first-child {
    background: #fff;
}
.grade-table th:first-child {
    background: #1f2933;
}
.grade-table th.semester-heading {
    text-align: center;
    background: #334155;
}
.grade-student-cell {
    display: grid;
    gap: 6px;
}
.grade-student-cell strong {
    display: block;
    line-height: 1.25;
}
.grade-student-cell small {
    color: var(--muted);
    font-weight: 750;
}
.grade-save-form .button {
    width: 100%;
    min-height: 32px;
}
.grade-average {
    white-space: nowrap;
    font-weight: 800;
    text-align: center;
}
.grade-student-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    padding: 13px 15px;
    min-width: 980px;
}
.grade-student-head,
.grade-student-footer,
.semester-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.grade-student-head > div {
    display: grid;
    gap: 4px;
}
.grade-student-head > div span,
.semester-title span {
    color: var(--muted);
    font-size: .82rem;
}
.semester-block {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.grade-semesters {
    display: grid;
    grid-template-columns: repeat(2, minmax(420px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.grade-fields {
    display: grid;
    grid-template-columns: repeat(8, minmax(58px, 1fr));
    gap: 5px;
    margin-top: 8px;
}
.grade-fields label {
    text-align: center;
    font-size: .74rem;
}
.grade-input {
    width: 42px;
    min-width: 42px;
    text-align: center;
    font-weight: 800;
    font-size: .9rem;
    padding: 7px 2px;
    min-height: 36px;
}
.grade-student-footer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}
.grade-student-footer > span {
    font-size: 1rem;
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}
.delete-student-form {
    display: flex;
    justify-content: flex-end;
    padding-top: 16px;
    margin-top: 16px;
    border-top: 1px solid var(--line);
}
.swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}
.swatch.present { background: var(--green); }
.swatch.absent { background: var(--red); }

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.table-wrap.wide { max-height: 68vh; }
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px;
    background: #fff;
}
th, td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}
tr.new-record td {
    background: #e7f6ef;
    animation: record-highlight 2.8s ease-out;
}
@keyframes record-highlight {
    from { background: #b9ead2; }
    to { background: #e7f6ef; }
}
th {
    background: #1f2933;
    color: #fff;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: 0;
}
td small { display: block; color: var(--muted); margin-top: 2px; }

.attendance-table th:first-child,
.attendance-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
    min-width: 210px;
}
.attendance-table th:first-child { background: #f0f3ef; z-index: 2; }
.attendance-table th:first-child { background: #1f2933; }
.attendance-table select {
    min-width: 54px;
    padding: 7px;
}

.dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: .78rem;
    font-style: normal;
    font-weight: 800;
}
.dot.green { background: #dcfce7; color: var(--green); }
.dot.yellow { background: #fef3c7; color: var(--yellow); }
.dot.red { background: #fee2e2; color: var(--red); }
.dot.neutral { background: #eef2f7; color: #526070; }

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    border-radius: 999px;
    padding: 4px 8px;
    background: #eef2f7;
    color: #526070;
    font-weight: 800;
    font-size: .78rem;
}
.pill.yes { background: #dcfce7; color: var(--green); }

.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 230px;
}

.month-tabs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 2px 0 14px;
    margin-bottom: 4px;
}
.month-tabs a {
    flex: 0 0 auto;
    border-radius: 8px;
    background: #2f3a45;
    color: #fff;
    padding: 11px 18px;
    font-weight: 850;
    text-decoration: none;
    box-shadow: 0 8px 18px rgba(22, 32, 42, .12);
}
.month-tabs a.active {
    background: var(--primary);
}
.report-mode-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 12px;
}
.report-mode-tabs a {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 10px 14px;
    font-weight: 850;
}
.report-mode-tabs a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.course-tabs {
    padding-bottom: 8px;
}
.course-tabs a {
    background: #eef4f8;
    color: var(--ink);
    border: 1px solid var(--line);
    box-shadow: none;
}
.course-tabs a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.rules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.rules article {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #f9fafb;
}
.rules strong {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 4px;
}
.rules span { color: var(--muted); font-weight: 650; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-shell {
    max-width: 1040px;
    margin: 0 auto;
}
.record-search { margin-bottom: 20px; }
.search-grow { flex: 1 1 360px; }
.search-summary {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 700;
    margin: 0 0 10px;
}
.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 28px;
}
.student-form { padding: 24px; }
.check {
    display: flex;
    align-items: center;
    flex-direction: row;
    gap: 9px;
    color: var(--ink);
}
.check input { width: auto; }
.ticket input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

.ticket-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.ticket {
    width: fit-content;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafb;
    padding: 9px 12px;
}
.ticket:has(input:checked) {
    border-color: var(--primary);
    background: #e8f5f3;
    color: var(--primary-dark);
}
.ticket:has(input:checked)::after {
    content: "Marcado";
    color: var(--primary-dark);
    font-size: .75rem;
    font-weight: 800;
}

.situation-picker {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}
.situation-picker summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    cursor: pointer;
    background: #f4f7f8;
    color: var(--ink);
    font-weight: 800;
}
.situation-picker summary span {
    color: var(--muted);
    font-size: .82rem;
}
.situation-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
    max-height: 340px;
    overflow-y: auto;
}
.situation-options label {
    min-height: 44px;
    background: #fff;
    padding: 10px 12px;
    font-size: .82rem;
}
.situation-options label:has(input:checked) {
    background: #e7f3df;
    color: #254a2b;
}
.situation-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.situation-tags span {
    border: 1px solid #b9d6ac;
    border-radius: 999px;
    background: #e7f3df;
    color: #254a2b;
    padding: 7px 10px;
    font-size: .8rem;
    font-weight: 800;
}

.inline {
    display: flex;
    gap: 8px;
    align-items: center;
}
.inline input { max-width: 150px; padding: 7px; }
.link-button {
    border: 0;
    background: transparent;
    color: var(--accent);
    min-height: auto;
    padding: 0;
}

.profile {
    display: flex;
    justify-content: space-between;
    gap: 18px;
}
.profile h2 { font-size: 1.6rem; margin-bottom: 8px; }
.profile p { margin: 4px 0; color: var(--muted); }
.history-only-profile p:nth-of-type(n+3),
.history-only-profile .profile-stats {
    display: none;
}
.student-record-actions {
    display: flex;
    gap: 10px;
    margin: -6px 0 18px;
    padding: 0;
}
.student-record-actions .button {
    min-width: 180px;
    justify-content: center;
}
.profile-stats {
    display: flex;
    gap: 10px;
    align-items: center;
}
.profile-stats span {
    display: grid;
    gap: 4px;
    min-width: 110px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.profile-stats strong { font-size: 1.4rem; }
.academic-history .panel-head {
    align-items: end;
}
.history-year-filter {
    display: flex;
    align-items: end;
    gap: 8px;
}
.history-year-filter label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 750;
}
.history-year-filter select {
    min-width: 110px;
}
.history-attendance {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.history-stat {
    display: grid;
    gap: 5px;
    padding: 13px;
    border: 1px solid var(--line);
    border-left: 5px solid #7b8794;
    border-radius: 8px;
    background: #f8fafc;
}
.history-stat.green { border-left-color: var(--green); }
.history-stat.yellow { border-left-color: var(--yellow); }
.history-stat.red { border-left-color: var(--red); }
.history-stat span,
.history-stat small { color: var(--muted); }
.history-stat strong { font-size: 1.45rem; }
.history-general-average td {
    border-top: 2px solid var(--ink);
    background: #f8fafc;
}
.history-records-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}
.history-record-group {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}
.history-record-group h3 {
    margin: 0 0 12px;
    font-size: 1rem;
}

.note {
    border-left: 4px solid var(--primary);
    background: #f8fbfb;
    padding: 12px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 10px;
}
.note p { margin: 6px 0 0; color: #3d4852; }
.note-actions {
    display: flex;
    justify-content: flex-end;
    margin: 6px 0;
}

.specific-report-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}
.specific-reports-layout {
    display: flex;
    flex-direction: column;
}
.specific-general-builder { order: 10; }
.specific-general-message { order: 11; }
.specific-general-output { order: 12; }
.specific-search-panel { order: 20; }
.specific-individual-builder { order: 30; }
.specific-individual-message { order: 31; }
.specific-individual-output { order: 32; }
.specific-report-options .ticket {
    width: auto;
    justify-content: flex-start;
}
.report-option-periods {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 10px;
}
.report-option-period {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(120px, .8fr);
    gap: 8px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    background: #f8fafc;
}
.report-option-period.certificate-option-wide {
    grid-column: 1 / -1;
    grid-template-columns: minmax(180px, 1fr) minmax(170px, .8fr) minmax(190px, .9fr);
}
.report-option-period .ticket {
    width: auto;
    border: 0;
    background: transparent;
    padding: 6px;
}
.report-option-period select {
    min-width: 0;
}
.report-option {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    padding: 12px;
    font-weight: 750;
}
.specific-report-header {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbfb;
    margin-bottom: 14px;
}
.specific-report-header strong {
    width: 100%;
    font-size: 1.2rem;
}
.certificate-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 2px solid #f2c500;
}
.certificate-brand img {
    width: 76px;
    height: 76px;
    flex: 0 0 76px;
    object-fit: contain;
}
.certificate-brand strong {
    display: block;
    font-size: 1.25rem;
    color: #34373b;
}
.certificate-brand span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}
.report-block {
    display: grid;
    gap: 10px;
    padding-top: 14px;
    margin-top: 14px;
    border-top: 1px solid var(--line);
}
.report-block h3,
.report-block h4 {
    margin: 0;
}

@media (max-width: 980px) {
    .sidebar {
        position: static;
        width: auto;
        height: auto;
        padding: 14px;
        border-bottom: 4px solid var(--primary);
        overflow: visible;
        scrollbar-gutter: auto;
    }
    .sidebar nav {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        grid-auto-flow: row;
        padding-bottom: 0;
        overflow: visible;
    }
    .shell {
        margin-left: 0;
        padding: 18px;
    }
    .grid.two { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
    .topbar, .profile { align-items: stretch; flex-direction: column; }
    .grid.two, .form-grid { grid-template-columns: 1fr; }
    .panel { padding: 14px; }
    .filters { display: grid; grid-template-columns: 1fr; }
    .button, button { width: 100%; }
    .inline { align-items: stretch; flex-direction: column; }
    .inline input { max-width: none; }
    .profile-stats { align-items: stretch; }
    .student-record-actions { flex-direction: column; }
    .student-record-actions .button { width: 100%; }
    .academic-history .panel-head,
    .history-year-filter { align-items: stretch; flex-direction: column; }
    .history-attendance { grid-template-columns: 1fr; }
    .history-records-grid { grid-template-columns: 1fr; }
    .report-option-period,
    .report-option-period.certificate-option-wide { grid-template-columns: 1fr; }
    .situation-options { grid-template-columns: 1fr; }
    .risk-cards { grid-template-columns: 1fr; }
    .range-references { grid-template-columns: 1fr; }
    .risk-overview .risk-cards,
    .grade-overview .risk-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .risk-overview .risk-chart,
    .grade-overview .risk-chart {
        display: block;
        height: 145px;
    }
    .risk-overview .panel,
    .grade-overview .panel {
        padding: 10px;
    }
    .risk-overview .panel::before,
    .grade-overview .panel::before {
        margin: -10px -10px 10px;
    }
    .risk-overview .panel-head,
    .grade-overview .panel-head {
        margin-bottom: 8px;
    }
    .risk-overview .panel-head h2,
    .grade-overview .panel-head h2 {
        font-size: .95rem;
    }
    .risk-overview .panel-head span,
    .grade-overview .panel-head span {
        font-size: .72rem;
    }
    .risk-card {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }
    .risk-card span { min-height: 0; }
    .risk-card small { grid-column: 1 / -1; }
    .grade-table { min-width: 1320px; }
    .grade-table th:first-child,
    .grade-table td:first-child {
        width: 128px;
        min-width: 128px;
    }
    .grade-line {
        display: flex;
        gap: 8px;
        padding: 8px;
    }
    .grade-line-student {
        flex-basis: 92px;
        min-width: 92px;
    }
    .grade-line-student {
        padding: 7px;
    }
    .grade-line-student strong {
        font-size: .76rem;
    }
    .grade-input {
        width: 38px;
        min-width: 38px;
    }
    .grade-strip-title {
        font-size: .7rem;
    }
}

@media print {
    .sidebar, .topbar, .filters, .button, button { display: none !important; }
    .shell { margin: 0; padding: 0; }
    body { background: #fff; }
    @page { size: A4; margin: 18mm 20mm; }
    .panel, .metrics article { box-shadow: none; break-inside: avoid; }
    body.print-general-report .shell > *,
    body.print-individual-report .shell > * { display: none !important; }
    body.print-general-report .shell > .specific-reports-layout,
    body.print-individual-report .shell > .specific-reports-layout {
        display: block !important;
    }
    body.print-general-report .specific-reports-layout > *,
    body.print-individual-report .specific-reports-layout > * {
        display: none !important;
    }
    body.print-general-report .specific-general-output,
    body.print-individual-report .specific-individual-output {
        display: block !important;
        border: 0;
        padding: 0;
        margin: 0;
    }
    body.print-general-report .specific-general-output .panel-head,
    body.print-general-report .specific-general-output .table-wrap,
    body.print-individual-report .specific-individual-output .panel-head,
    body.print-individual-report .specific-individual-output .table-wrap {
        display: block !important;
    }
    body.print-general-report .specific-general-output .table-wrap,
    body.print-individual-report .specific-individual-output .table-wrap {
        overflow: visible;
        border: 1px solid #999;
    }
    body.print-general-report .specific-general-output table,
    body.print-individual-report .specific-individual-output table { min-width: 0; }
    body.print-risk-list .shell > * { display: none !important; }
    body.print-risk-list .shell > #risk-list {
        display: block !important;
        border: 0;
        padding: 0;
        margin: 0;
    }
    body.print-risk-list #risk-list .panel-head { display: flex !important; }
    body.print-risk-list #risk-list .table-wrap {
        overflow: visible;
        border: 1px solid #999;
    }
    body.print-risk-list #risk-list table { min-width: 0; }
    body.print-risk-list #risk-list a { color: #000; text-decoration: none; }
    body.print-dashboard-students .shell > * { display: none !important; }
    body.print-dashboard-students .shell > #student-status-list {
        display: block !important;
        border: 0;
        padding: 0;
        margin: 0;
    }
    body.print-dashboard-students #student-status-list .panel-head,
    body.print-dashboard-students #student-status-list .table-wrap,
    body.print-dashboard-students #student-status-list .print-school-header {
        display: flex !important;
    }
    body.print-dashboard-students #student-status-list .table-wrap {
        display: block !important;
        overflow: visible;
        border: 1px solid #999;
    }
    body.print-dashboard-students #student-status-list table { min-width: 0; }
    body.print-action-history .shell > * { display: none !important; }
    body.print-action-history .shell > #action-history-print {
        display: block !important;
        border: 0;
        padding: 0;
        margin: 0;
    }
    body.print-action-history #action-history-print .panel-head,
    body.print-action-history #action-history-print .table-wrap,
    body.print-action-history #action-history-print .print-school-header,
    body.print-action-history #action-history-print .print-only {
        display: flex !important;
    }
    body.print-action-history #action-history-print .table-wrap {
        display: block !important;
        overflow: visible;
        border: 1px solid #999;
    }
    body.print-action-history #action-history-print table { min-width: 0; }
    body.print-action-history #action-history-print th:last-child,
    body.print-action-history #action-history-print td:last-child { display: none; }
    .print-school-header {
        align-items: center;
        gap: 12px;
        margin-bottom: 18px;
        border-bottom: 2px solid #333;
        padding-bottom: 10px;
    }
    .print-school-header img { width: 58px; height: 58px; object-fit: contain; }
    .print-school-header div { display: grid; gap: 3px; }
    .print-school-header strong { font-size: 1.15rem; }
    .print-only { margin: 0 0 16px; }
    .formal-certificate {
        min-height: 620px;
        padding: 28px 7%;
        break-inside: avoid;
    }
    .formal-certificate h3 { font-size: 18pt; margin-top: 24px; }
    .formal-certificate p { font-size: 12pt; line-height: 1.85; }
    body.print-pie-dashboard .shell > * { display: none !important; }
    body.print-pie-dashboard .shell > #pie-monthly-dashboard {
        display: block !important;
        border: 0;
        padding: 0;
        margin: 0;
    }
    body.print-pie-dashboard #pie-monthly-dashboard .panel-head,
    body.print-pie-dashboard #pie-monthly-dashboard .month-tabs,
    body.print-pie-dashboard #pie-monthly-dashboard .table-wrap {
        display: block !important;
    }
    body.print-pie-dashboard #pie-monthly-dashboard .month-tabs {
        display: none !important;
    }
    body.print-pie-dashboard #pie-monthly-dashboard .table-wrap {
        overflow: visible;
        border: 1px solid #999;
    }
    body.print-pie-dashboard #pie-monthly-dashboard table { min-width: 0; }
    body.print-pie-dashboard #pie-monthly-dashboard a { color: #000; text-decoration: none; }
    body.print-general-dashboard .shell > * { display: none !important; }
    body.print-general-dashboard .shell > #general-monthly-dashboard {
        display: block !important;
        border: 0;
        padding: 0;
        margin: 0;
    }
    body.print-general-dashboard #general-monthly-dashboard .panel-head,
    body.print-general-dashboard #general-monthly-dashboard .month-tabs,
    body.print-general-dashboard #general-monthly-dashboard .table-wrap {
        display: block !important;
    }
    body.print-general-dashboard #general-monthly-dashboard .month-tabs {
        display: none !important;
    }
    body.print-general-dashboard #general-monthly-dashboard .table-wrap {
        overflow: visible;
        border: 1px solid #999;
    }
    body.print-general-dashboard #general-monthly-dashboard table { min-width: 0; }
    body.print-general-dashboard #general-monthly-dashboard a { color: #000; text-decoration: none; }
    body.print-monthly-dashboard .shell > * { display: none !important; }
    body.print-monthly-dashboard .shell > #monthly-dashboard {
        display: block !important;
        border: 0;
        padding: 0;
        margin: 0;
    }
    body.print-monthly-dashboard #monthly-dashboard .panel-head,
    body.print-monthly-dashboard #monthly-dashboard .month-tabs,
    body.print-monthly-dashboard #monthly-dashboard .report-mode-tabs,
    body.print-monthly-dashboard #monthly-dashboard .monthly-filters,
    body.print-monthly-dashboard #monthly-dashboard .table-wrap {
        display: block !important;
    }
    body.print-monthly-dashboard #monthly-dashboard .month-tabs,
    body.print-monthly-dashboard #monthly-dashboard .report-mode-tabs,
    body.print-monthly-dashboard #monthly-dashboard .monthly-filters {
        display: none !important;
    }
    body.print-monthly-dashboard #monthly-dashboard .table-wrap {
        overflow: visible;
        border: 1px solid #999;
    }
    body.print-monthly-dashboard #monthly-dashboard table { min-width: 0; }
    body.print-monthly-dashboard #monthly-dashboard a { color: #000; text-decoration: none; }
}

.year-intro {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(260px, .8fr);
    gap: 24px;
    align-items: center;
    padding: 24px;
    margin-bottom: 18px;
    color: #fff;
    background: #263238;
    border-left: 6px solid #f0c419;
}
.year-intro h2 { margin: 4px 0 8px; font-size: clamp(1.35rem, 2vw, 2rem); }
.year-intro p { margin: 0; max-width: 780px; color: #d9e1e3; }
.year-intro .eyebrow { color: #f0c419; }
.year-flow { display: grid; gap: 8px; }
.year-flow span {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid #536267;
    background: #344247;
}
.year-flow b {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    color: #263238;
    background: #f0c419;
}
.annual-enrollment { margin-top: 18px; }
.enrollment-table { min-width: 980px; }
.enrollment-table td { vertical-align: middle; }
.enrollment-table td:nth-child(2) small { display: block; color: #69777b; margin-top: 3px; }
.compact-ticket { min-height: 36px; padding: 7px 9px; white-space: nowrap; }
.student-match-list { display: grid; gap: 10px; margin-top: 16px; }
.student-match {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px;
    border: 1px solid #d8dfe1;
    background: #f8faf9;
}
.student-match > div { display: grid; gap: 3px; }
.student-match span { color: #667579; font-size: .86rem; }
.inline-enrollment-form { display: flex; align-items: center; gap: 8px; }
.new-student-callout { display: flex; justify-content: space-between; align-items: center; gap: 16px; }

@media (max-width: 760px) {
    .year-intro { grid-template-columns: 1fr; padding: 18px; }
    .student-match, .new-student-callout { align-items: stretch; flex-direction: column; }
    .inline-enrollment-form { align-items: stretch; flex-direction: column; width: 100%; }
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}
.topbar-actions form { margin: 0; }
.signed-user {
    display: grid;
    gap: 2px;
    padding-right: 8px;
    color: #667579;
    font-size: .72rem;
    text-align: right;
}
.signed-user strong { color: #1f2b2f; font-size: .9rem; }

.login-page {
    min-height: 100dvh;
    margin: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #e8eeec;
}
.login-shell {
    width: min(920px, 100%);
    min-height: 540px;
    display: grid;
    grid-template-columns: minmax(300px, .9fr) minmax(360px, 1.1fr);
    overflow: hidden;
    border: 1px solid #c8d2cf;
    background: #fff;
    box-shadow: 0 24px 60px rgba(18, 40, 43, .18);
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 44px;
    color: #fff;
    background: #10282b;
    border-bottom: 6px solid #f0c419;
}
.login-brand img {
    width: 96px;
    height: 96px;
    object-fit: contain;
}
.login-brand h1 {
    margin: 5px 0;
    font-size: 2rem;
    line-height: 1.08;
}
.login-brand p { margin: 0; color: #c7d5d1; }
.login-brand .eyebrow { color: #f0c419; }
.login-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 22px;
    padding: 54px;
}
.login-panel h2 { margin: 4px 0 8px; font-size: 1.75rem; }
.login-support { margin: 0; color: #667579; line-height: 1.55; }
.login-form { display: grid; gap: 17px; }
.login-form label { display: grid; gap: 7px; font-weight: 700; color: #26363a; }
.login-form input { min-height: 48px; font-size: 1rem; }
.login-form .button { min-height: 48px; margin-top: 4px; }

@media (max-width: 760px) {
    .topbar-actions { align-items: stretch; flex-wrap: wrap; justify-content: flex-start; }
    .signed-user { width: 100%; text-align: left; }
    .login-page { padding: 0; place-items: stretch; }
    .login-shell { min-height: 100dvh; grid-template-columns: 1fr; border: 0; }
    .login-brand { padding: 28px 24px; }
    .login-brand img { width: 72px; height: 72px; }
    .login-brand h1 { font-size: 1.55rem; }
    .login-panel { justify-content: flex-start; padding: 38px 24px; }
}
