:root {
  color-scheme: light;
  --bg: #f4f7fa;
  --surface: #ffffff;
  --text: #182332;
  --muted: #68778a;
  --line: #dce4ec;
  --primary: #245b88;
  --primary-soft: #e8f1f8;
  --green: #24735c;
  --amber: #9a621b;
  --red: #b54242;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.public-page { min-height: 100vh; }
.public-shell { width: min(100% - 40px, 1120px); min-height: 100vh; margin: 0 auto; display: grid; grid-template-rows: auto 1fr auto auto; }
.public-header { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.public-brand { display: inline-flex; align-items: center; gap: 11px; color: var(--text); font-weight: 800; text-decoration: none; }
.public-brand img { border-radius: 8px; }
.header-login { min-height: 42px; display: inline-flex; align-items: center; padding: 0 18px; border: 1px solid #bfcbd7; border-radius: 6px; color: var(--text); font-weight: 700; text-decoration: none; }
.header-login:hover { border-color: var(--primary); color: var(--primary); }
.public-intro { max-width: 780px; align-self: center; padding: 80px 0 64px; }
.public-intro h1 { max-width: 760px; margin: 12px 0 22px; font-size: clamp(42px, 7vw, 76px); line-height: 1.02; letter-spacing: 0; }
.public-lead { max-width: 720px; margin: 0 0 32px; color: var(--muted); font-size: 20px; line-height: 1.55; }
.primary-link { min-height: 52px; display: inline-flex; align-items: center; justify-content: center; padding: 0 24px; border-radius: 6px; background: var(--primary); color: #fff; font-weight: 800; text-decoration: none; }
.primary-link:hover { background: #1d4b72; }
.public-capabilities { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.public-capabilities article { min-height: 132px; display: grid; align-content: center; gap: 8px; padding: 24px 28px; border-right: 1px solid var(--line); }
.public-capabilities article:last-child { border-right: 0; }
.public-capabilities strong { font-size: 17px; }
.public-capabilities span { color: var(--muted); line-height: 1.45; }
.public-footer { min-height: 72px; display: flex; align-items: center; color: var(--muted); font-size: 14px; }
.public-footer a:hover { color: var(--primary); }

.login-page { display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(100%, 520px); }
.back-home { display: inline-block; margin-bottom: 20px; color: var(--primary); font-weight: 700; text-decoration: none; }
.site-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.site-brand img, .portal-brand img { border-radius: 8px; }
.site-brand span { color: var(--muted); font-size: 14px; font-weight: 600; }
.site-brand h1 { margin: 2px 0 0; font-size: 28px; letter-spacing: 0; }
.login-panel { padding: 34px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 44px rgb(24 35 50 / 9%); }
.eyebrow { margin: 0; color: var(--primary); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.login-panel h2 { margin: 8px 0 24px; font-size: 24px; letter-spacing: 0; }
.login-description { margin: -14px 0 22px; color: var(--muted); line-height: 1.5; }
.login-panel form { display: grid; gap: 10px; }
.login-panel label { color: var(--muted); font-size: 14px; font-weight: 600; }
.login-panel input { width: 100%; min-height: 52px; padding: 0 14px; border: 1px solid #bfcbd7; border-radius: 6px; background: #fff; color: var(--text); }
.login-panel input:focus { outline: 3px solid rgb(36 91 136 / 15%); border-color: var(--primary); }
.login-panel button { min-height: 52px; margin-top: 4px; border: 0; border-radius: 6px; background: var(--primary); color: #fff; font-weight: 700; }
.login-panel button:disabled { opacity: .65; cursor: wait; }
.form-error, .portal-error { padding: 12px 14px; border: 1px solid #efcaca; border-radius: 6px; background: #fff2f2; color: var(--red); }
.legacy-login { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.legacy-login summary { color: var(--primary); font-weight: 700; cursor: pointer; }
.legacy-login form { margin-top: 16px; }
.login-footer { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 20px 2px; color: var(--muted); font-size: 13px; }

.portal-topbar { position: sticky; top: 0; z-index: 20; min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 12px max(22px, calc((100vw - 1320px) / 2)); background: rgb(255 255 255 / 94%); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.portal-brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; text-decoration: none; }
.portal-identity { display: grid; text-align: right; }
.portal-identity small { color: var(--muted); }
.portal-user-actions { display: flex; align-items: center; gap: 14px; }
.portal-logout { min-height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font-weight: 700; }
.portal-logout:hover { border-color: #b8c5d1; background: #f7f9fb; }
.portal-shell { width: min(100% - 36px, 1320px); margin: 0 auto; padding: 30px 0 60px; }
.portal-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.portal-heading p { margin: 0 0 5px; color: var(--muted); }
.portal-heading h1 { margin: 0; font-size: 30px; letter-spacing: 0; }
.portal-heading span { display: block; margin-top: 5px; color: var(--primary); font-weight: 700; }
.month-control { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.month-control input { min-height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); }
.portal-tabs { display: flex; gap: 4px; margin: 22px 0; padding: 4px; overflow-x: auto; background: #e8edf2; border-radius: 8px; }
.portal-tabs button { min-width: max-content; flex: 1; min-height: 42px; padding: 0 16px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 700; }
.portal-tabs button.active { background: var(--surface); color: var(--primary); box-shadow: 0 2px 8px rgb(24 35 50 / 8%); }
.portal-view { display: none; }
.portal-view.active { display: block; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.summary-grid article { min-height: 112px; display: grid; align-content: center; gap: 5px; padding: 20px 24px; border-right: 1px solid var(--line); }
.summary-grid article:last-child { border-right: 0; }
.summary-grid strong { font-size: 30px; line-height: 1; }
.summary-grid span { color: var(--muted); font-size: 14px; }
.content-section { margin-top: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.content-section > header { display: flex; justify-content: space-between; align-items: center; min-height: 76px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.content-section h2 { margin: 0; font-size: 19px; letter-spacing: 0; }
.content-section header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.table-scroll { overflow: auto; }
.portal-table { width: 100%; min-width: 680px; border-collapse: collapse; }
.portal-table th, .portal-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.portal-table th { color: var(--muted); background: #f8fafc; font-size: 12px; text-transform: uppercase; }
.portal-table td small { display: block; margin-top: 4px; color: var(--muted); }
.portal-table tbody tr:last-child td { border-bottom: 0; }
.grade-value { display: inline-grid; min-width: 34px; height: 34px; place-items: center; border-radius: 6px; background: var(--primary-soft); color: var(--primary); }
.grade-5 { background: #e5f4ed; color: #1d7657; }
.grade-4 { background: #e9f1fb; color: #285f96; }
.grade-3 { background: #fff2dc; color: #9a621b; }
.grade-2 { background: #fde9e9; color: #ad3f3f; }
.status { display: inline-flex; padding: 6px 9px; border-radius: 6px; background: #eef2f5; color: var(--muted); font-size: 13px; font-weight: 700; }
.status-present { background: #e5f4ed; color: var(--green); }
.status-absent { background: #fde9e9; color: var(--red); }
.status-late { background: #fff2dc; color: var(--amber); }
.status-sick, .status-excused { background: #e9f1fb; color: #285f96; }
.attendance-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); background: #f8fafc; }
.attendance-summary article { display: grid; gap: 3px; padding: 14px 18px; border-right: 1px solid var(--line); }
.attendance-summary article:last-child { border-right: 0; }
.attendance-summary strong { font-size: 20px; }
.attendance-summary span { color: var(--muted); font-size: 12px; }
.attendance-note { margin: 0; padding: 12px 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.45; }
.attendance-exceptions { padding: 14px 14px 0; background: #f8fafc; }
.exceptions-block { overflow: hidden; border: 1px solid #e9c8c8; border-radius: 8px; background: #fff; }
.exceptions-block > header { min-height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid #efdada; background: #fff4f4; }
.exceptions-block h3 { margin: 0; font-size: 15px; }
.exceptions-block > header span { min-width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; background: var(--red); color: #fff; font-size: 12px; font-weight: 800; }
.exceptions-block article { display: grid; grid-template-columns: 145px minmax(0, 1fr) max-content; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.exceptions-block article:last-child { border-bottom: 0; }
.exceptions-block time { color: var(--muted); font-size: 13px; }
.attendance-ok { display: grid; gap: 3px; padding: 16px 18px; border: 1px solid #bcded1; border-radius: 8px; background: #eff9f5; color: var(--green); }
.attendance-ok span { font-size: 13px; }
.attendance-list { display: grid; gap: 12px; padding: 14px; background: #f8fafc; }
.attendance-day { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.attendance-day > header { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #f4f7fa; }
.attendance-day > header div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 12px; }
.attendance-day > header div span { color: var(--muted); font-size: 13px; }
.all-present { color: var(--green); font-size: 12px; font-weight: 700; }
.attendance-item { display: grid; grid-template-columns: 90px minmax(0, 1fr) max-content; align-items: center; gap: 14px; min-height: 58px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.attendance-item:last-child { border-bottom: 0; }
.attendance-slot { color: var(--primary); }
.homework-list { display: grid; }
.homework-item { display: grid; grid-template-columns: minmax(180px, 260px) minmax(0, 1fr); gap: 20px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.homework-item:last-child { border-bottom: 0; }
.homework-item div { display: grid; gap: 4px; }
.homework-item span { color: var(--muted); }
.homework-item p { margin: 0; line-height: 1.5; }
.schedule-list { display: grid; gap: 12px; padding: 14px; background: #f8fafc; }
.schedule-day { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.schedule-day > header { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #f4f7fa; }
.schedule-day > header div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 12px; }
.schedule-day > header strong { font-size: 16px; }
.schedule-day > header span { color: var(--muted); font-size: 13px; }
.schedule-day.is-today { border-color: #9fbcd2; box-shadow: 0 0 0 1px rgb(36 91 136 / 8%); }
.schedule-day.is-today > header { background: var(--primary-soft); }
.schedule-day > header .today-badge { padding: 5px 8px; border-radius: 6px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.schedule-item { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 18px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.schedule-item:last-child { border-bottom: 0; }
.schedule-slot, .schedule-subject { display: grid; align-content: start; gap: 4px; }
.schedule-slot b { color: var(--primary); }
.schedule-slot time, .schedule-subject span, .schedule-subject small { color: var(--muted); font-size: 13px; }
.portal-empty { padding: 34px 20px; color: var(--muted); text-align: center; }

@media (max-width: 760px) {
  .public-shell { width: min(100% - 28px, 1120px); }
  .public-intro { padding: 58px 0 46px; }
  .public-intro h1 { font-size: 46px; }
  .public-lead { font-size: 18px; }
  .public-capabilities { grid-template-columns: 1fr; }
  .public-capabilities article { min-height: 104px; padding: 20px 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .public-capabilities article:last-child { border-bottom: 0; }
  .portal-topbar { padding-inline: 14px; }
  .portal-user-actions { gap: 8px; }
  .portal-identity strong { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .portal-shell { width: min(100% - 24px, 1320px); padding-top: 20px; }
  .portal-heading { align-items: stretch; flex-direction: column; gap: 16px; }
  .portal-heading h1 { font-size: 25px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-grid article:nth-child(2) { border-right: 0; }
  .summary-grid article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .homework-item { grid-template-columns: 1fr; gap: 10px; }
  .attendance-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .attendance-summary article:nth-child(2) { border-right: 0; }
  .attendance-summary article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .exceptions-block article { grid-template-columns: 1fr; gap: 5px; }
  .exceptions-block article .status { justify-self: start; }
  .attendance-list { gap: 10px; padding: 10px; }
  .attendance-day > header { align-items: flex-start; flex-direction: column; gap: 5px; }
  .attendance-item { grid-template-columns: 72px minmax(0, 1fr); gap: 8px 12px; padding: 12px 14px; }
  .attendance-item .status { grid-column: 2; justify-self: start; }
  .schedule-list { gap: 10px; padding: 10px; }
  .schedule-item { grid-template-columns: 86px minmax(0, 1fr); gap: 12px; padding: 13px 14px; }
  .portal-table { min-width: 620px; }
}

@media (max-width: 480px) {
  .public-header { min-height: 72px; }
  .public-brand span { max-width: 178px; font-size: 14px; }
  .header-login { min-height: 40px; padding-inline: 14px; }
  .public-intro { padding-top: 48px; }
  .public-intro h1 { font-size: 40px; }
  .login-page { padding: 18px; }
  .login-panel { padding: 26px 20px; }
  .portal-brand span { display: none; }
  .portal-identity strong { max-width: 105px; }
  .content-section > header { padding-inline: 15px; }
  .summary-grid article { min-height: 96px; padding: 16px; }
  .summary-grid strong { font-size: 26px; }
}
