/* Frontier Academy — portal styles */
:root {
  --green-950: #072B26;
  --green-900: #0B3B34;
  --green-700: #13594E;
  --green-500: #2E7D6B;
  --green-100: #E1EEE8;
  --green-50:  #F1F7F4;
  --chalk: #F2C230;
  --chalk-soft: #FBF0C8;
  --paper: #F7F8F4;
  --white: #FFFFFF;
  --ink: #1B2623;
  --muted: #5C6B66;
  --line: #D6DED9;
  --red: #B83A2B;
  --red-soft: #F8E3DF;
  --amber: #8A5A00;
  --amber-soft: #FBEFD3;
  --blue: #1F5F8B;
  --blue-soft: #E1EDF6;
  --radius-s: 6px;
  --radius-m: 10px;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --sidebar: 260px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--body); font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--paper); }
h1, h2, h3, h4 { font-family: var(--display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
a { color: var(--green-700); }
img, video { max-width: 100%; }
:focus-visible { outline: 3px solid var(--chalk); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--chalk); color: var(--ink); padding: .5rem 1rem; z-index: 99; }
.skip:focus { left: 0; }
.ok { color: var(--green-500); }

/* ---------- Shell ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--green-900); color: #D9E8E2; overflow-y: auto; z-index: 40; padding: 0 0 2rem; }
.brand { display: flex; align-items: center; gap: .65rem; padding: 1.1rem 1.25rem; color: #fff; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 1.1rem; border-bottom: 1px solid rgba(255,255,255,.08); position: sticky; top: 0; background: var(--green-900); z-index: 1; }
.brand img { width: 36px; height: 36px; object-fit: contain; }
.crest { width: 36px; height: 36px; border-radius: 50% 50% 50% 8px; background: var(--chalk); color: var(--green-900); display: grid; place-items: center; font-weight: 800; font-size: 1.15rem; }
.sidebar nav { padding: .5rem .75rem; }
.nav-group { margin: 1.1rem .6rem .35rem; font-size: .78rem; color: #8FB3A7; font-weight: 700; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a { display: flex; align-items: center; gap: .7rem; padding: .5rem .6rem; border-radius: var(--radius-s); color: #D9E8E2; text-decoration: none; font-size: .95rem; }
.sidebar li a i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .85; }
.sidebar li a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar li a.active { background: var(--chalk); color: var(--green-950); font-weight: 700; }
.sidebar li a.active i { opacity: 1; }
.shell { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.5rem; background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.top-session { flex: 1; font-size: .92rem; }
.top-session span:first-child { font-weight: 700; }
.menu-btn { display: none; }
.child-switch select { padding: .4rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-s); font: inherit; background: var(--green-50); }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: .6rem; cursor: pointer; padding: .25rem .4rem; border-radius: var(--radius-s); }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--green-50); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--green-100); color: var(--green-900); display: grid; place-items: center; font-weight: 700; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.who { display: flex; flex-direction: column; line-height: 1.2; }
.who small { color: var(--muted); }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + .4rem); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-m); min-width: 210px; padding: .4rem; box-shadow: 0 12px 30px -12px rgba(11,59,52,.35); }
.user-menu .menu a, .user-menu .menu button { display: flex; gap: .6rem; width: 100%; padding: .55rem .7rem; border: 0; background: none; font: inherit; color: var(--ink); text-decoration: none; border-radius: var(--radius-s); cursor: pointer; text-align: left; }
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--green-50); }
.content { padding: 1.75rem 1.5rem 3rem; flex: 1; width: 100%; max-width: 1280px; }
.portal-foot { padding: 1rem 1.5rem; font-size: .85rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head p { margin: 0; max-width: 70ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.scrim { display: none; }
.burger, .burger::before, .burger::after { display: block; width: 20px; height: 2px; background: var(--green-900); border-radius: 2px; position: relative; content: ""; }
.burger::before { position: absolute; top: -6px; }
.burger::after { position: absolute; top: 6px; }

/* ---------- Components ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .6rem 1.05rem; border-radius: var(--radius-s); border: 1px solid transparent; font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap; }
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-900); }
.btn-accent { background: var(--chalk); color: var(--green-950); }
.btn-accent:hover { background: #E3B21F; }
.btn-ghost { background: var(--white); color: var(--green-900); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--green-500); }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: .35rem .65rem; font-size: .85rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link { color: var(--green-700); font-weight: 700; text-decoration: none; }
.link:hover { text-decoration: underline; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-s); border: 1px solid transparent; background: none; color: var(--green-700); cursor: pointer; font-size: 1rem; text-decoration: none; }
.icon-btn:hover { background: var(--green-50); border-color: var(--line); }
.icon-btn.danger { color: var(--red); }
.icon-btn.danger:hover { background: var(--red-soft); }
form.inline { display: inline; }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.25rem; }
.panel + .panel, .panel + .grid, .grid + .panel { margin-top: 1.25rem; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.panel-head h2 { margin: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.alert { padding: .75rem 1rem; border-radius: var(--radius-s); margin-bottom: 1rem; border-left: 4px solid; }
.alert-success { background: var(--green-50); border-color: var(--green-500); color: var(--green-900); }
.alert-error { background: var(--red-soft); border-color: var(--red); color: #6E1F15; }
.alert-info { background: var(--blue-soft); border-color: var(--blue); color: #133B57; }
.alert-warn { background: var(--amber-soft); border-color: var(--amber); color: #5A3B00; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.badge-ok { background: var(--green-100); color: var(--green-900); }
.badge-warn { background: var(--amber-soft); color: var(--amber); }
.badge-bad { background: var(--red-soft); color: var(--red); }
.badge-info { background: var(--blue-soft); color: var(--blue); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1rem 1.1rem; display: flex; gap: .9rem; align-items: center; text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--green-500); }
.stat i { font-size: 1.35rem; width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-s); background: var(--green-50); color: var(--green-700); flex: none; }
.stat > span { min-width: 0; }
.stat .n { font-family: var(--display); font-size: clamp(1.15rem, 1.6vw, 1.5rem); font-weight: 700; line-height: 1.15; display: block; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .9rem; }
.stat.accent i { background: var(--chalk-soft); color: var(--amber); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; max-width: 900px; }
.span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field label { font-weight: 700; font-size: .92rem; }
.req { color: var(--red); }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=month], input[type=search], input[type=tel], input[type=url], select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid #BFCBC5; border-radius: var(--radius-s); font: inherit; color: var(--ink); background: var(--white); min-height: 42px;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(46,125,107,.2); }
input[type=file] { font: inherit; padding: .5rem 0; }
.check { display: inline-flex; align-items: center; gap: .5rem; font-weight: 400 !important; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--green-700); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }
.error-text { color: var(--red); margin: 0; font-size: .875rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; padding-top: .5rem; }
.input-prefix { display: flex; }
.input-prefix span { padding: .6rem .75rem; background: var(--green-50); border: 1px solid #BFCBC5; border-right: 0; border-radius: var(--radius-s) 0 0 var(--radius-s); }
.input-prefix input { border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.file-current { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .5rem; background: var(--green-50); border-radius: var(--radius-s); }
.file-current img, .file-current video { max-height: 110px; border-radius: var(--radius-s); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; margin-bottom: 1rem; padding: 1rem; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-m); }
.filters .field { min-width: 160px; flex: 1 1 160px; max-width: 260px; }
.field-btns { flex-direction: row !important; align-items: center; gap: .75rem !important; flex: 0 0 auto !important; min-width: 0 !important; }
.sum-line { margin: 0 0 .75rem; }

/* ---------- Tables ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-weight: 700; font-size: .85rem; color: var(--muted); padding: .75rem 1rem; border-bottom: 1px solid var(--line); background: var(--green-50); white-space: nowrap; }
.table td { padding: .7rem 1rem; border-bottom: 1px solid #E8EDEA; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFCFB; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.actions-col { white-space: nowrap; text-align: right; width: 1%; }
.thumb { width: 64px; height: 42px; object-fit: cover; border-radius: 4px; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty i { font-size: 2.2rem; color: var(--green-500); display: block; margin-bottom: .5rem; }
.pager { display: flex; gap: .35rem; margin-top: 1rem; flex-wrap: wrap; }
.pager a, .pager span { min-width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--white); text-decoration: none; }
.pager .cur { background: var(--green-700); color: #fff; border-color: var(--green-700); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: .65rem 0; border-bottom: 1px solid #E8EDEA; }
.list-plain li:last-child { border-bottom: 0; }

/* Attendance / marks inputs */
.att-options { display: flex; gap: .3rem; flex-wrap: wrap; }
.att-options label { position: relative; }
.att-options input { position: absolute; opacity: 0; }
.att-options span { display: inline-block; padding: .3rem .65rem; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; cursor: pointer; background: var(--white); }
.att-options input:checked + span.p { background: var(--green-700); color: #fff; border-color: var(--green-700); }
.att-options input:checked + span.a { background: var(--red); color: #fff; border-color: var(--red); }
.att-options input:checked + span.l { background: var(--amber); color: #fff; border-color: var(--amber); }
.att-options input:checked + span.e { background: var(--blue); color: #fff; border-color: var(--blue); }
.att-options input:focus-visible + span { outline: 3px solid var(--chalk); }
.score { width: 84px !important; min-height: 36px !important; padding: .35rem .5rem !important; text-align: right; }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.cal-head h2 { margin: 0; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--line); gap: 1px; }
.cal .dow { background: var(--green-50); padding: .5rem; font-size: .82rem; font-weight: 700; color: var(--muted); }
.cal .day { background: var(--white); min-height: 104px; padding: .4rem; display: flex; flex-direction: column; gap: .25rem; }
.cal .day.out { background: #FAFBF9; color: #A3B0AB; }
.cal .day .d { font-size: .85rem; font-weight: 700; }
.cal .day.today .d { background: var(--chalk); color: var(--green-950); border-radius: 999px; width: 26px; height: 26px; display: grid; place-items: center; }
.cal .ev { display: block; font-size: .78rem; padding: .15rem .35rem; border-radius: 4px; background: var(--green-100); color: var(--green-900); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; text-align: left; cursor: pointer; font-family: inherit; width: 100%; }
.cal .ev.c-Exam { background: var(--red-soft); color: var(--red); }
.cal .ev.c-Holiday { background: var(--chalk-soft); color: var(--amber); }
.cal .ev.c-Sports { background: var(--blue-soft); color: var(--blue); }
.cal .ev.c-Meeting { background: #ECE6F5; color: #4B3477; }
dialog { border: 0; border-radius: var(--radius-m); padding: 1.5rem; max-width: 520px; width: calc(100% - 2rem); box-shadow: 0 30px 60px -20px rgba(0,0,0,.45); }
dialog::backdrop { background: rgba(7,43,38,.55); }

/* Timetable */
.tt { width: 100%; border-collapse: collapse; min-width: 720px; }
.tt th, .tt td { border: 1px solid var(--line); padding: .5rem; vertical-align: top; }
.tt th { background: var(--green-50); font-size: .85rem; }
.tt .slot { background: var(--green-50); border-left: 3px solid var(--green-500); padding: .4rem .5rem; border-radius: 4px; margin-bottom: .35rem; font-size: .85rem; }
.tt .slot strong { display: block; }
.tt .slot small { color: var(--muted); display: block; }

/* Invoice print */
.invoice { max-width: 820px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 2.5rem; }
.invoice-head { display: flex; justify-content: space-between; gap: 2rem; border-bottom: 2px solid var(--green-900); padding-bottom: 1.25rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.invoice-head h2 { font-size: 1.6rem; margin: 0; }
.invoice-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 2rem; margin-bottom: 1.5rem; }
.invoice-meta dt { color: var(--muted); font-size: .85rem; }
.invoice-meta dd { margin: 0 0 .25rem; font-weight: 700; }
.stamp { display: inline-block; border: 3px solid var(--green-500); color: var(--green-500); font-family: var(--display); font-weight: 800; font-size: 1.4rem; padding: .25rem 1rem; transform: rotate(-6deg); border-radius: 6px; }
.stamp.unpaid { border-color: var(--red); color: var(--red); }
.stamp.partial { border-color: var(--amber); color: var(--amber); }

/* Report card */
.report-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.report-head dl { display: grid; grid-template-columns: auto auto; gap: .2rem 1rem; margin: 0; }
.report-head dt { color: var(--muted); }
.report-head dd { margin: 0; font-weight: 700; }

/* Bar chart */
.bars { display: flex; align-items: flex-end; gap: .6rem; height: 180px; padding-top: 1rem; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: .3rem; height: 100%; font-size: .78rem; color: var(--muted); }
.bars .bar span.b { width: 100%; max-width: 44px; background: var(--green-500); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar span.v { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Auth ---------- */
body.auth { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, 1fr); min-height: 100vh; background: var(--white); }
.auth-art { background-size: cover; background-position: center; position: relative; }
.auth-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(7,43,38,.9), rgba(7,43,38,.15) 60%); }
.auth-art-text { position: absolute; z-index: 1; left: 3rem; right: 3rem; bottom: 3rem; color: #fff; }
.auth-school { font-family: var(--display); font-weight: 800; font-size: clamp(2rem, 4vw, 3.4rem); margin: 0; line-height: 1; }
.auth-art-text p:last-child { font-size: 1.15rem; margin: .6rem 0 0; color: var(--chalk); }
.auth-panel { padding: 3rem clamp(1.5rem, 5vw, 4.5rem); display: flex; flex-direction: column; justify-content: center; gap: 1rem; max-width: 560px; }
.auth-panel h1 { font-size: 2rem; margin: 1rem 0 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(7,43,38,.5); z-index: 35; }
  .shell { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .who { display: none; }
  body.auth { grid-template-columns: 1fr; }
  .auth-art { min-height: 220px; }
  .auth-art-text { left: 1.5rem; bottom: 1.5rem; }
}
@media (max-width: 680px) {
  .content { padding: 1.25rem 1rem 2.5rem; }
  .topbar { padding: .6rem 1rem; }
  .top-session { font-size: .82rem; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .filters .field { max-width: none; }
  .panel { padding: 1rem; }
  .panel > table.table:not(.stack-sm) { display: block; overflow-x: auto; }
  .panel-head { flex-wrap: wrap; }
  .page-actions { width: 100%; }
  .table.stack-sm thead { display: none; }
  .table.stack-sm tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem 0; }
  .table.stack-sm td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .35rem 1rem; }
  .table.stack-sm td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; }
  .cal .day { min-height: 70px; }
  .cal .ev { font-size: 0; height: 8px; padding: 0; }
  .invoice { padding: 1.25rem; }
  .invoice-meta { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media print {
  .sidebar, .topbar, .page-head .page-actions, .portal-foot, .no-print, .filters, .pager { display: none !important; }
  .shell { margin: 0; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .invoice, .panel { border: 0; padding: 0; }
}
