:root {
  --ink: #26332d;
  --muted: #69746e;
  --paper: #f6f3ea;
  --surface: #fffdf8;
  --green: #315c47;
  --green-dark: #234535;
  --gold: #bd8a39;
  --border: #ded8ca;
  --danger: #a23b35;
  --success: #2f6d4e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top right, #eef1e8 0, var(--paper) 36%); }
a { color: var(--green); }
h1, h2 { line-height: 1.15; margin-top: 0; }
h1 { font-size: clamp(1.8rem, 3vw, 2.5rem); }
h2 { font-size: 1.25rem; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .9rem max(1rem, calc((100vw - 1120px) / 2)); background: var(--green-dark); color: white;
}
.brand { color: white; font-weight: 800; text-decoration: none; font-size: 1.15rem; }
.topbar nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar nav a, .link-button { color: white; text-decoration: none; font: inherit; }
.inline { display: inline; }
.link-button { border: 0; background: transparent; padding: 0; cursor: pointer; }

.container { width: min(1120px, calc(100% - 2rem)); margin: 2rem auto 4rem; }
.auth-container { min-height: 80vh; display: grid; place-items: center; }
.auth-card, .card, .stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 14px 40px rgba(38, 51, 45, .07);
}
.auth-card { width: min(460px, 100%); padding: 2rem; }
.card, .panel { padding: 1.5rem; margin-bottom: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 14px 40px rgba(38, 51, 45, .07); }
.narrow { max-width: 680px; }
.page-heading, .page-header { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.eyebrow { color: var(--gold); text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 800; margin-bottom: .4rem; }
.muted { color: var(--muted); }

form { display: grid; gap: 1rem; }
.search-form { grid-template-columns: minmax(220px, 1fr) auto auto; align-items: center; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: .45rem; font-weight: 700; font-size: .9rem; }
label small, small { color: var(--muted); font-weight: 400; }
.checkbox { display: flex; flex-direction: row; align-items: center; gap: .6rem; }
.checkbox input { width: auto; }
input, select, textarea {
  width: 100%; border: 1px solid var(--border); background: white; color: var(--ink);
  border-radius: 10px; padding: .78rem .85rem; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(189, 138, 57, .2); border-color: var(--gold); }
button, .button {
  display: inline-flex; justify-content: center; align-items: center; width: fit-content;
  border: 0; border-radius: 10px; padding: .78rem 1rem; background: var(--green); color: white;
  font: inherit; font-weight: 800; text-decoration: none; cursor: pointer;
}
button:hover, .button:hover { background: var(--green-dark); }
.button-secondary { background: transparent; color: var(--danger); border: 1px solid #e2aaa6; padding: .5rem .7rem; }
.button-secondary:hover { background: #fff0ef; }
.button.secondary { background: #eef1ed; color: var(--green-dark); }
.button.secondary:hover { background: #dfe7df; }
.button-neutral { background: #eef1ed; color: var(--green-dark); }
.button-neutral:hover { background: #dfe7df; }
.actions { display: flex; gap: .7rem; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { padding: 1.2rem; }
.stat span { color: var(--muted); display: block; font-size: .85rem; }
.stat strong { display: block; font-size: 2rem; margin-top: .3rem; color: var(--green-dark); }
.stat-card { padding: 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 14px 40px rgba(38, 51, 45, .07); }
.stat-card span { color: var(--muted); display: block; font-size: .85rem; }
.stat-card strong { display: block; font-size: 1.35rem; margin-top: .3rem; color: var(--green-dark); }
.alert { padding: .85rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; }
.alert-success { color: var(--success); background: #edf8f1; border-color: #aed1ba; }
.alert-error { color: var(--danger); background: #fff0ef; border-color: #e2aaa6; }
.badge { display: inline-block; border-radius: 999px; background: #edf2ed; color: var(--green-dark); padding: .25rem .55rem; font-size: .75rem; font-weight: 800; }
.badge.success { background: #edf8f1; color: var(--success); }
.badge.danger { background: #fff0ef; color: var(--danger); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .85rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.details div { display: grid; grid-template-columns: 120px 1fr; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 700; }
.check-list { line-height: 1.8; padding-left: 1.2rem; }
.profile-grid { display: grid; grid-template-columns: minmax(210px, 280px) 1fr; gap: 1.25rem; }
.portrait-card { text-align: center; }
.student-photo { width: 180px; height: 180px; object-fit: cover; border-radius: 22px; border: 5px solid white; box-shadow: 0 8px 30px rgba(38,51,45,.15); }
.photo-placeholder { width: 180px; height: 180px; border-radius: 22px; margin: 0 auto; display: grid; place-items: center; background: #e3eadf; color: var(--green-dark); font-size: 3rem; font-weight: 900; }
.relation-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--border); }
.relation-row form { flex: 0 0 auto; }
.pill { display: inline-block; padding: .16rem .45rem; border-radius: 999px; background: #edf2ed; font-size: .72rem; font-weight: 800; margin-left: .35rem; }
.pill.accent { background: #f6ead2; color: #73531d; }
details { border-top: 1px solid var(--border); padding-top: 1rem; }
summary { cursor: pointer; font-weight: 800; color: var(--green); }
.details-form { margin-top: 1rem; }
.enrollment-table select, .enrollment-table input:not([type="checkbox"]) { min-width: 210px; margin-top: .5rem; }
.student-selector { width: 1.25rem; height: 1.25rem; }
.enrollment-total { margin-top: 1rem; padding: 1rem; text-align: right; background: #edf2ed; border-radius: 12px; font-size: 1.15rem; }
.declaration-box { padding: 1rem; border: 1px solid var(--border); border-radius: 12px; background: #fffaf0; }
.receipt-actions { max-width: 850px; margin: 0 auto 1rem; display: flex; justify-content: space-between; align-items: center; }
.receipt-sheet { max-width: 850px; margin: 0 auto; background: white; border: 1px solid var(--border); padding: 2.5rem; box-shadow: 0 14px 40px rgba(38,51,45,.08); }
.receipt-header { display: flex; justify-content: space-between; gap: 2rem; border-bottom: 3px solid var(--green); padding-bottom: 1.25rem; }
.receipt-number { text-align: right; display: grid; gap: .3rem; }
.receipt-number strong { font-size: 1.3rem; color: var(--green-dark); }
.receipt-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; margin: 1.5rem 0; }
.receipt-note { margin-top: 2rem; color: var(--muted); font-size: .85rem; }
.signature-line { width: 220px; margin: 5rem auto 0; padding-top: .5rem; border-top: 1px solid var(--ink); text-align: center; }
.financial-stats .stat strong { font-size: 1.55rem; }
.payment-selection-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem; background: #edf2ed; border-radius: 12px; }
.payment-charge { width: 1.2rem; height: 1.2rem; }
.decision-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.status-overdue, .status-rejected { background: #fff0ef; color: var(--danger); }
.status-paid, .status-approved { background: #edf8f1; color: var(--success); }
.status-reported, .status-registered, .status-pending_verification { background: #fff6df; color: #73531d; }
.transfer-form { min-width: 260px; gap: .5rem; }
.transfer-form select, .transfer-form input { padding: .55rem .65rem; }
.stat .stat-text { font-size: 1.1rem; margin-top: .8rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.grade-input { min-width: 90px; }
.portal-student-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.portal-student-card { display: flex; gap: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
.portal-student-card h3 { margin: 0 0 .35rem; }
.portal-student-card p { margin: .3rem 0; }
.student-avatar { width: 82px; height: 82px; object-fit: cover; border-radius: 14px; flex: 0 0 auto; }
.student-photo-large { width: min(240px, 100%); max-height: 300px; object-fit: cover; border-radius: 18px; margin-top: 1rem; }
.status-present { background: #edf8f1; color: var(--success); }
.status-absent { background: #fff0ef; color: var(--danger); }
.status-excused { background: #fff6df; color: #73531d; }
.status-submitted { background: #fff6df; color: #73531d; }
.status-reviewed { background: #edf8f1; color: var(--success); }
.status-rejected { background: #fff0ef; color: var(--danger); }
.pre-line { white-space: pre-line; }
.report-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.report-card { display: flex; flex-direction: column; align-items: flex-start; }
.report-card .button { margin-top: auto; }
.report-filters { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)) auto; align-items: end; }
.report-summary .stat strong { font-size: 1.55rem; }
.report-table { font-size: .88rem; }
.report-sheet h2 { margin-bottom: 1rem; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1.25rem 0; }
td code { overflow-wrap: anywhere; }
button:disabled { opacity: .55; cursor: not-allowed; }
footer { text-align: center; color: var(--muted); padding: 1.5rem; font-size: .8rem; }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .stats-grid, .form-grid, .profile-grid, .search-form, .decision-grid, .portal-student-grid, .report-card-grid, .report-filters { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .receipt-header, .receipt-meta { grid-template-columns: 1fr; display: grid; }
  .receipt-number { text-align: left; }
  .payment-selection-bar { align-items: flex-start; flex-direction: column; }
}

@media print {
  :root, body { background: white; }
  .topbar, footer, .no-print, .alert { display: none !important; }
  .container { width: 100%; margin: 0; }
  .receipt-sheet { max-width: none; border: 0; box-shadow: none; padding: 0; }
  .report-sheet, .stat { box-shadow: none; break-inside: avoid; }
  .report-table { font-size: 9pt; }
  .report-table th, .report-table td { padding: .35rem; }
}
