/* SchoolBejoz — light theme, navy + gold, matching the brand logo */
:root {
  --bg: #f6f9ff; --surface: #fff; --ink: #0f2f73; --text: #1c2b4d; --muted: #5b6b8c;
  --line: #dfe7f5; --line-2: #eef2fa;
  --blue: #0d3b8e; --blue-700: #0a2f72; --blue-50: #eaf1ff; --blue-100: #d6e4ff;
  --gold: #b98a1e; --gold-50: #fbf3df;
  --ok: #17784a; --ok-bg: #e4f5ec; --bad: #bf3326; --bad-bg: #fdebe8; --warn: #a36a0a; --warn-bg: #fdf1d3;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,47,115,.06), 0 4px 16px rgba(15,47,115,.05);
  --side: 254px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--sans); color: var(--text); background: var(--bg); }
body.modal-open { overflow: hidden; }
h1, h2, h3 { margin: 0; color: var(--ink); font-weight: 600; }
h1 { font: 600 30px/1.15 var(--serif); letter-spacing: .1px; }
h2 { font-size: 16px; } h3 { font-size: 14px; }
p { margin: 0 0 .6em; }
a { color: var(--blue); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; } .center { text-align: center; }
.nowrap { white-space: nowrap; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; } .gap-s { gap: 6px; } .mt { margin-top: 16px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 16px; }
.hidden { display: none !important; }
.icon { display: inline-flex; width: 18px; height: 18px; flex: none; } .icon svg { width: 100%; height: 100%; }

/* boot + spinner */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--blue-100); border-top-color: var(--blue); animation: spin .8s linear infinite; }
.loading { display: grid; place-items: center; padding: 60px 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* shell */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; }
.brand img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }
.brand b { display: block; font: 700 22px/1 var(--serif); color: var(--blue); } .brand b span { color: var(--gold); }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { padding: 6px 10px 14px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 2px 0; border-radius: 9px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--blue-50); text-decoration: none; }
.nav a.active { background: var(--blue); color: #fff; } .nav a.active .icon { color: #fff; } .nav a .icon { color: var(--muted); }
.nav .pill { margin-left: auto; background: var(--gold); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 7px; }
.side-foot { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; }
.side-foot .who { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .title { font: 700 20px/1 var(--serif); color: var(--blue); flex: 1; }
.content { padding: 26px 30px 60px; width: 100%; max-width: 1240px; margin: 0 auto; }
.scrim { display: none; }
.banner { display: flex; gap: 10px; align-items: center; background: var(--gold-50); border: 1px solid #ecd9a5; color: #6f5310; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.banner.bad { background: var(--bad-bg); border-color: #f2c2bb; color: var(--bad); } .banner.info { background: var(--blue-50); border-color: var(--blue-100); color: var(--blue-700); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card.flush .card-head { padding: 16px 18px 0; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font: 600 30px/1.1 var(--serif); color: var(--ink); margin: 4px 0 2px; }
.stat .sub { font-size: 13px; color: var(--muted); }
.stat.warn .value { color: var(--bad); } .stat.gold { border-top: 3px solid var(--gold); } .stat.blue { border-top: 3px solid var(--blue); }
.meter { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; min-width: 70px; }
.meter i { display: block; height: 100%; background: var(--ok); border-radius: 99px; } .meter i.mid { background: #d59a1c; } .meter i.low { background: var(--bad); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--blue-50); text-decoration: none; } .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; } .btn.primary:hover { background: var(--blue-700); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; } .btn.gold:hover { background: #9d7415; }
.btn.danger { color: var(--bad); border-color: #f0c3bd; } .btn.danger:hover { background: var(--bad-bg); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; } .btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; } .btn.block { width: 100%; }
.btn .icon { width: 16px; height: 16px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; } .field > label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=month], input[type=time], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cfd9ee; border-radius: 9px; background: #fff; outline: none; min-height: 40px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(13,59,142,.14); }
input:disabled, select:disabled, textarea:disabled { background: #f3f6fc; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; } .form-grid .span2 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 9px; font-weight: 500; cursor: pointer; } .check input { width: 18px; height: 18px; accent-color: var(--blue); }
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; } .toolbar .field { min-width: 150px; } .toolbar .field.wide { min-width: 220px; flex: 1; }
.form-error { color: var(--bad); background: var(--bad-bg); border-radius: 8px; padding: 9px 12px; font-size: 14px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 14px; background: #f9fbff; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; } tbody tr:hover td { background: #fafcff; } tr.click { cursor: pointer; }
th.num, td.num { text-align: right; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 34px 16px; }

/* badges + tabs */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.info { background: var(--blue-50); color: var(--blue); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.active { color: var(--blue); border-bottom-color: var(--gold); }

/* attendance */
.att-list { display: flex; flex-direction: column; }
.att-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); }
.att-row .roll { width: 32px; color: var(--muted); font-variant-numeric: tabular-nums; }
.att-row .nm { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.seg { display: inline-flex; border-radius: 10px; overflow: hidden; border: 1px solid #cfd9ee; }
.seg button { border: 0; background: #fff; padding: 8px 16px; min-width: 52px; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid #cfd9ee; }
.seg button.on-P { background: var(--ok); color: #fff; } .seg button.on-A { background: var(--bad); color: #fff; } .seg button.on-L { background: var(--warn); color: #fff; }
.seg button:disabled { cursor: not-allowed; opacity: .7; }
.att-row.is-A { background: #fff6f5; }
.sticky-bar { position: sticky; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: 12px 14px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: space-between; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; } .chip { padding: 3px 11px; border-radius: 99px; background: var(--blue-50); color: var(--blue); font-weight: 600; font-size: 13px; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.cal .day { aspect-ratio: 1.15; border-radius: 9px; border: 1px solid var(--line-2); padding: 5px 7px; font-size: 13px; background: #fff; display: flex; flex-direction: column; justify-content: space-between; }
.cal .day.P { background: var(--ok-bg); border-color: #bfe5cf; } .cal .day.A { background: var(--bad-bg); border-color: #f2c2bb; } .cal .day.L { background: var(--warn-bg); border-color: #efd9a0; } .cal .day.off { background: transparent; border-color: transparent; }
.cal .day b { font-size: 12px; } .cal .day.P b { color: var(--ok); } .cal .day.A b { color: var(--bad); } .cal .day.L b { color: var(--warn); }
.cal .day.today { outline: 2px solid var(--gold); }

/* timetable */
.tt th, .tt td { text-align: center; border: 1px solid var(--line-2); padding: 8px 6px; min-width: 104px; }
.tt th.side { text-align: left; min-width: 110px; background: #f9fbff; }
.tt td.cell { cursor: default; height: 62px; } .tt.edit td.cell { cursor: pointer; } .tt.edit td.cell:hover { background: var(--blue-50); }
.tt .subj { font-weight: 600; color: var(--ink); font-size: 13px; } .tt .tch { font-size: 12px; color: var(--muted); }
.tt td.now { background: var(--gold-50); }

/* misc */
.list { display: flex; flex-direction: column; } .list > * + * { border-top: 1px solid var(--line-2); }
.item { padding: 12px 0; } .item h3 { margin-bottom: 2px; }
.notice { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; } .notice.unread { background: var(--blue-50); border-color: var(--blue-100); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 14px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.chart { width: 100%; height: auto; display: block; } .chart text { font: 11px var(--sans); fill: var(--muted); }
.cred { background: var(--blue-50); border: 1px dashed var(--blue-100); border-radius: 10px; padding: 12px 14px; }
.cred .mono { font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: .03em; }
.bell { position: relative; } .bell .pill { position: absolute; top: -2px; right: -2px; background: var(--bad); color: #fff; border-radius: 99px; font-size: 10px; font-weight: 700; padding: 0 5px; min-width: 16px; text-align: center; }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(12,28,66,.45); display: grid; place-items: center; padding: 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(8,20,55,.35); }
.modal.wide { width: min(900px, 100%); } .modal.xwide { width: min(1100px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font: 600 22px/1.1 var(--serif); }
.modal-body { padding: 18px 20px; overflow-y: auto; } .modal-foot { padding: 12px 20px 16px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line-2); }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; width: min(420px, calc(100% - 24px)); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(8,20,55,.3); font-weight: 500; animation: rise .2s ease; }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* receipt */
.receipt { font-size: 14px; } .receipt .head { text-align: center; border-bottom: 2px solid var(--gold); padding-bottom: 10px; margin-bottom: 12px; }
.receipt .head b { font: 700 24px var(--serif); color: var(--blue); display: block; } .receipt table td, .receipt table th { padding: 7px 8px; }
.receipt .void { color: var(--bad); font-weight: 700; text-align: center; border: 2px solid var(--bad); padding: 6px; border-radius: 8px; margin-bottom: 10px; }

/* login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-art { background: linear-gradient(160deg, #eef4ff 0%, #f8fbff 55%, #fbf3df 130%); display: grid; place-items: center; padding: 40px; border-right: 1px solid var(--line); }
.login-art > div { width: 100%; max-width: 420px; text-align: center; }
.login-art img { display: block; width: min(380px, 78%); height: auto; margin: 0 auto; }
.login-art p { text-align: center; color: var(--muted); max-width: 360px; margin: 18px auto 0; }
.login-form { display: grid; place-items: center; padding: 30px 22px; }
.login-form form { width: min(390px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-form .logo-sm { display: none; }
.login-form h1 { font-size: 36px; }

/* responsive */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  .app.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(8,20,55,.3); }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(12,28,66,.4); z-index: 25; }
  .topbar { display: flex; } .content { padding: 18px 14px 60px; } h1 { font-size: 26px; }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login { grid-template-columns: 1fr; } .login-art { display: none; } .login-form .logo-sm { display: block; width: 150px; margin: 0 auto; }
}
@media (max-width: 600px) {
  .g2, .g3, .form-grid { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 26px; } .kv { grid-template-columns: 110px 1fr; }
  .att-row { padding: 10px 10px; gap: 8px; } .seg button { padding: 9px 14px; }
  .modal { max-height: calc(100vh - 16px); } .overlay { padding: 8px; align-items: end; }
  .toolbar .field { min-width: 45%; flex: 1; } th, td { padding: 9px 10px; }
}
@media print {
  body * { visibility: hidden; }
  .receipt, .receipt * { visibility: visible; }
  .receipt { position: absolute; left: 0; top: 0; width: 100%; }
  .overlay { background: none; }
}
