/* School Portal — original navy/white/gold design. No build step, no external assets. */
@font-face { font-family: "Kantumruy Pro"; font-weight: 400; font-display: swap; src: url("../fonts/kantumruy-pro-latin-400-normal.c64d8b1e2c70.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Kantumruy Pro"; font-weight: 600; font-display: swap; src: url("../fonts/kantumruy-pro-latin-600-normal.b25163bd94c5.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Kantumruy Pro"; font-weight: 700; font-display: swap; src: url("../fonts/kantumruy-pro-latin-700-normal.c26aa5263aff.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Kantumruy Pro"; font-weight: 400; font-display: swap; src: url("../fonts/kantumruy-pro-khmer-400-normal.af25bbe1db5a.woff2") format("woff2"); unicode-range: U+1780-17FF, U+19E0-19FF, U+200C-200D, U+25CC; }
@font-face { font-family: "Kantumruy Pro"; font-weight: 600; font-display: swap; src: url("../fonts/kantumruy-pro-khmer-600-normal.251af73aa011.woff2") format("woff2"); unicode-range: U+1780-17FF, U+19E0-19FF, U+200C-200D, U+25CC; }
@font-face { font-family: "Kantumruy Pro"; font-weight: 700; font-display: swap; src: url("../fonts/kantumruy-pro-khmer-700-normal.974cf1f44b73.woff2") format("woff2"); unicode-range: U+1780-17FF, U+19E0-19FF, U+200C-200D, U+25CC; }

:root {
  --navy-900: #0f1f4b; --navy-800: #16295f; --navy-700: #1e3a7b; --navy-100: #e6ebf7; --navy-50: #f3f5fb;
  --gold-500: #c9a227; --gold-100: #faf3dc; --gold-700: #7a5f0e;
  --ink: #17203a; --muted: #56607a; --line: #dfe3ee; --bg: #f5f6fa; --card: #ffffff;
  --ok: #17734a; --ok-bg: #e5f4ec; --warn: #8a5300; --warn-bg: #fdf0db; --bad: #b42318; --bad-bg: #fde8e6;
  --info: #1e3a7b; --info-bg: #e6ebf7;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,31,75,.06), 0 4px 14px rgba(15,31,75,.06);
  --focus: 0 0 0 3px #fff, 0 0 0 6px var(--gold-500);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Kantumruy Pro", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--bg); }
:lang(km) body, body:lang(km) { line-height: 1.75; }
a { color: var(--navy-700); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: .5rem 1rem; z-index: 50; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); } .small { font-size: .875rem; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* App bar */
.appbar { background: var(--navy-800); color: #fff; padding: calc(env(safe-area-inset-top) + .75rem) 1rem .75rem; position: sticky; top: 0; z-index: 10; }
.appbar .inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: .75rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 600; min-width: 0; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-weight: 400; opacity: .8; font-size: .75rem; }

/* Child switcher */
.switcher { background: var(--navy-700); color: #fff; padding: .6rem 1rem; }
.switcher .inner { max-width: 760px; margin: 0 auto; }
.switcher details { position: relative; }
.switcher summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .75rem; min-height: 48px; padding: .25rem .25rem; border-radius: 10px; }
.switcher summary::-webkit-details-marker { display: none; }
.switcher summary:hover { background: rgba(255,255,255,.08); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--gold-500); color: var(--navy-900); display: grid; place-items: center; font-weight: 700; flex: none; border: 2px solid rgba(255,255,255,.7); }
.avatar.sm { width: 36px; height: 36px; font-size: .85rem; border-color: var(--line); }
.child-name { font-weight: 600; display: block; }
.child-class { font-size: .85rem; opacity: .85; }
.chev { margin-left: auto; font-size: .85rem; opacity: .9; }
.switch-menu { position: absolute; left: 0; right: 0; top: calc(100% + .4rem); background: #fff; color: var(--ink); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(15,31,75,.25); padding: .4rem; z-index: 20; }
.switch-menu form { margin: 0; }
.switch-menu button { width: 100%; display: flex; gap: .75rem; align-items: center; background: none; border: 0; padding: .6rem; border-radius: 10px; text-align: left; font: inherit; color: inherit; cursor: pointer; min-height: 52px; }
.switch-menu button:hover, .switch-menu button[aria-current="true"] { background: var(--navy-50); }

/* Layout */
main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem calc(88px + env(safe-area-inset-bottom)); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; border: 1px solid var(--line); }
.card h2 { display: flex; align-items: center; gap: .5rem; }
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link:hover { border-color: var(--navy-700); }
.card.attention { border-left: 5px solid var(--gold-500); background: linear-gradient(0deg, #fff, #fff), var(--gold-100); }
.card .meta { font-size: .85rem; color: var(--muted); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .7rem 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.greeting { font-size: .95rem; color: var(--muted); }
.ico { width: 22px; height: 22px; flex: none; }

/* Badges with text + shape so status never depends on colour */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 600; padding: .15rem .6rem; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.badge::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.b-present, .b-ok { color: var(--ok); background: var(--ok-bg); border-color: #b9e0c9; }
.b-late, .b-warn { color: var(--warn); background: var(--warn-bg); border-color: #f2d29b; }
.b-absent, .b-bad { color: var(--bad); background: var(--bad-bg); border-color: #f5c2bd; }
.b-excused, .b-info { color: var(--info); background: var(--info-bg); border-color: #c7d2ee; }
.b-none { color: var(--muted); background: #eef0f5; border-color: var(--line); }
.b-none::before { background: none; border: 1.5px solid currentColor; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 46px; padding: .55rem 1.1rem; border-radius: 10px; border: 1px solid var(--navy-800); background: var(--navy-800); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--navy-900); }
.btn.secondary { background: #fff; color: var(--navy-800); }
.btn.gold { background: var(--gold-500); border-color: var(--gold-500); color: var(--navy-900); }
.btn.block { width: 100%; }
label { display: block; font-weight: 600; margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 46px; padding: .55rem .75rem; border: 1px solid #b8c0d4; border-radius: 10px; font: inherit; background: #fff; color: var(--ink); }
.field { margin-bottom: 1rem; }
.helptext, .field .help { font-size: .85rem; color: var(--muted); }
.errorlist { color: var(--bad); padding-left: 1.1rem; margin: .3rem 0; font-size: .9rem; }
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .75rem 1rem; border-radius: 10px; margin-bottom: .5rem; font-weight: 600; }
.messages .success { background: var(--ok-bg); color: var(--ok); }
.messages .error { background: var(--bad-bg); color: var(--bad); }
.messages .info, .messages .warning { background: var(--info-bg); color: var(--info); }

/* Bottom tab bar (guardian) */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabbar ul { list-style: none; margin: 0 auto; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); max-width: 760px; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .5rem .25rem .55rem; text-decoration: none; color: var(--muted); font-size: .75rem; min-height: 60px; }
.tabbar a[aria-current="page"] { color: var(--navy-800); font-weight: 700; }
.tabbar a[aria-current="page"] .ico { color: var(--navy-800); }
.tabbar a[aria-current="page"]::after { content: ""; width: 22px; height: 3px; border-radius: 3px; background: var(--gold-500); }

/* Staff desktop: sidebar */
.staff { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.sidebar { background: var(--navy-900); color: #dfe5f5; padding: 1rem; }
.sidebar nav ul { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.sidebar a { display: flex; align-items: center; gap: .6rem; color: #dfe5f5; text-decoration: none; padding: .6rem .75rem; border-radius: 10px; min-height: 44px; }
.sidebar a:hover { background: rgba(255,255,255,.08); }
.sidebar a[aria-current="page"] { background: var(--navy-700); color: #fff; box-shadow: inset 3px 0 0 var(--gold-500); }
.staff main { max-width: 1100px; width: 100%; padding: 1.5rem 1rem 3rem; }
@media (min-width: 900px) {
  .staff { grid-template-columns: 250px 1fr; }
  .sidebar { min-height: 100vh; position: sticky; top: 0; align-self: start; }
  .sidebar nav ul { display: block; }
  .staff main { padding: 2rem; }
}
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--navy-50); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
.seg { display: inline-flex; flex-wrap: wrap; gap: .35rem; border: 0; padding: 0; margin: 0; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label { margin: 0; font-weight: 600; font-size: .85rem; padding: .45rem .7rem; border: 1px solid #b8c0d4; border-radius: 999px; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; background: #fff; }
.seg input:checked + label { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
.seg input:focus-visible + label { box-shadow: var(--focus); }

/* Auth screens */
.auth { min-height: 100vh; display: grid; place-items: start center; padding: calc(env(safe-area-inset-top) + 56px) 1rem 2rem; background: linear-gradient(180deg, var(--navy-800) 0 240px, var(--bg) 240px); }
.auth .card { width: 100%; max-width: 420px; padding: 1.5rem; }
.auth-brand { text-align: center; color: #fff; margin-bottom: 1rem; }
.auth-brand .brand-mark { width: 64px; height: 64px; margin: 0 auto .5rem; display: block; }
.auth form p { margin-bottom: 1rem; }
.auth button[type=submit], .auth form button { min-height: 46px; padding: .55rem 1.1rem; border-radius: 10px; border: 0; background: var(--navy-800); color: #fff; font: inherit; font-weight: 600; cursor: pointer; width: 100%; }
.lang-switch { display: flex; gap: .5rem; }
.lang-switch button { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 999px; padding: .25rem .7rem; font: inherit; font-size: .8rem; cursor: pointer; min-height: 36px; }
.lang-switch button[aria-pressed="true"] { background: #fff; color: var(--navy-800); }
.empty { text-align: center; padding: 1.5rem 1rem; color: var(--muted); }
.pill-soon { font-size: .75rem; background: var(--navy-50); color: var(--navy-700); padding: .1rem .5rem; border-radius: 999px; font-weight: 600; }
.auth-wrap { width: 100%; max-width: 420px; } .center { text-align: center; margin-top: 1rem; }
.field.check { display: flex; align-items: center; gap: .6rem; }
.field.check label { margin: 0; font-weight: 600; }
.field.check input { width: 22px; height: 22px; flex: none; accent-color: var(--navy-800); }
textarea { min-height: 100px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
input[type=file] { width: 100%; padding: .5rem; border: 1px dashed #b8c0d4; border-radius: 10px; background: #fff; font: inherit; }
.tab-ico { position: relative; display: inline-flex; }
.dot { position: absolute; top: -2px; right: -4px; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); border: 2px solid #fff; }
.count { margin-left: auto; background: var(--gold-500); color: var(--navy-900); border-radius: 999px; padding: 0 .5rem; font-size: .75rem; font-weight: 700; }
.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.bubble { background: #fff; border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: .75rem 1rem; max-width: 88%; align-self: flex-start; box-shadow: var(--shadow); }
.bubble.mine { align-self: flex-end; background: var(--navy-50); border-color: #c7d2ee; border-radius: 14px 14px 4px 14px; }
.bubble .who { font-size: .8rem; font-weight: 600; margin-bottom: .25rem; color: var(--muted); }
.num { text-align: right; white-space: nowrap; }
tfoot th, tfoot td { border-bottom: 0; background: none; text-transform: none; letter-spacing: 0; font-size: .95rem; color: var(--ink); }
.big { font-size: 1.35rem; }
.facts { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: .4rem 1rem; margin: 0; }
.facts dt { color: var(--muted); font-size: .9rem; }
.facts dd { margin: 0; }
table.lines input, table.lines select { min-width: 90px; }
.receipt { max-width: 720px; margin: 2rem auto; background: #fff; padding: 2rem; border: 1px solid var(--line); border-radius: var(--radius); }
.receipt header { border-bottom: 2px solid var(--navy-800); padding-bottom: 1rem; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.receipt .brand-mark { width: 48px; height: 48px; margin-right: .5rem; }
.void-stamp { color: var(--bad); border: 3px solid var(--bad); font-weight: 700; padding: .5rem 1rem; display: inline-block; transform: rotate(-2deg); }
@media print { body { background: #fff; } .receipt { border: 0; margin: 0; } .no-print, .skip { display: none !important; } }
.show-sm { display: none; }
@media (max-width: 560px) {
  .hide-sm { display: none; }
  .show-sm { display: inline; }
}
.totals { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1.25rem; margin: .75rem 0 0 auto; max-width: 360px; text-align: right; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; white-space: nowrap; }
.totals .due { border-top: 1px solid var(--line); padding-top: .35rem; color: var(--ink); font-weight: 600; }
