:root {
  --bg: #f5f8fc; --card: #fff; --text: #34465a; --muted: #627188; --edge: #e3eaf2;
  --sky: #6ec1e4; --mint: #7bd389; --sun: #ffc857; --coral: #f28b82; --lav: #b39ddb; --pink: #f7a1c4; --peach: #ffb385;
  --sky-t: #e3f4fb; --mint-t: #e3f6e9; --sun-t: #fff4d6; --coral-t: #fde4e1; --lav-t: #efe9fa; --pink-t: #fde9f2; --peach-t: #ffeedf;
  --sky-d: #1b6a9a; --mint-d: #1f7a45; --sun-d: #8a6100; --coral-d: #b23b3b; --lav-d: #5e4a9e; --pink-d: #b0306a; --peach-d: #a0522d;
  --l0: #f28b82; --l1: #ffc857; --l2: #6ec1e4; --l3: #7bd389;
  --l0-t: #fde2e1; --l1-t: #fff1c9; --l2-t: #ddf0fb; --l3-t: #ddf5e6;
  --l0-d: #b23b3b; --l1-d: #8a6100; --l2-d: #1b6a9a; --l3-d: #1f7a45;
  --radius: 18px; --shadow: 0 2px 10px rgba(52, 70, 90, .06);
  --font: 'Tajawal', 'Segoe UI', Tahoma, sans-serif; --head: 'Baloo Bhaijaan 2', 'Tajawal', sans-serif;
  --nav-w: 230px; --tab-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--head); margin: 0; font-weight: 700; }
a { color: var(--sky-d); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(135deg, #ffe3ee 0%, #e0f2ff 55%, #e8f8ec 100%); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 26px; padding: 28px 24px; box-shadow: 0 12px 40px rgba(80, 100, 140, .15); }
.login-card .logo { font-size: 46px; text-align: center; }
.login-card h1 { text-align: center; font-size: 24px; color: #4a5a8c; margin-top: 4px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 6px 0 20px; }
.startup-card { text-align: center; line-height: 1.7; }
.startup-card .muted { font-size: 14px; margin-bottom: 16px; }
.startup-card [hidden] { display: none; }
.rainbow { height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--coral), var(--peach), var(--sun), var(--mint), var(--sky), var(--lav)); margin: 14px 0 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: 13.5px; }
.input, select.input, textarea.input { width: 100%; border: 1.5px solid var(--edge); border-radius: 12px; padding: 11px 12px; background: #fff; outline: none; transition: border .15s; }
.input:focus { border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-t); }
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 700; cursor: pointer; background: var(--sky-t); color: var(--sky-d); display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.btn.primary { background: linear-gradient(90deg, #79c7ea, #8fd8a0); color: #183e4c; text-shadow: none; }
.btn.danger { background: var(--coral-t); color: var(--coral-d); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.whatsapp { background: #dcf5e5; color: #176b3d; text-decoration: none; min-height: 44px; }
.error { background: var(--coral-t); color: var(--coral-d); padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; font-size: 13.5px; }
.demo-box { margin-top: 18px; padding: 12px; border-radius: 14px; background: var(--sun-t); font-size: 13px; }
.demo-box .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.demo-box .btn { padding: 7px 10px; font-size: 12.5px; background: #fff; }

/* ---------- shell ---------- */
.shell { min-height: 100dvh; }
.topbar { position: sticky; top: 0; z-index: 20; background: linear-gradient(90deg, #ffe3ee, #e0f2ff); padding: 10px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #fff; }
.topbar .brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.topbar .brand .emoji { font-size: 26px; }
.topbar .brand h1 { font-size: 17px; color: #4a5a8c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand .sub { font-size: 11.5px; color: #6b7a90; }
.chip { background: #fff; border-radius: 999px; padding: 6px 10px; font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.role-admin { color: var(--lav-d); } .role-teacher { color: var(--mint-d); } .role-viewer { color: var(--sky-d); }
.demo-flag { background: var(--sun); color: #5a4300; border-radius: 999px; padding: 3px 9px; font-size: 11px; font-weight: 700; }
.net { font-size: 11.5px; padding: 3px 8px; border-radius: 999px; background: var(--coral-t); color: var(--coral-d); }

.sidenav { display: none; }
.tabbar { position: fixed; bottom: 0; inset-inline: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--edge); display: flex; z-index: 30; }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--muted); font-size: 11px; gap: 2px; }
.tabbar a .i { font-size: 22px; filter: grayscale(.6); opacity: .8; }
.tabbar a.active { color: var(--sky-d); font-weight: 700; }
.tabbar a.active .i { filter: none; opacity: 1; transform: translateY(-1px); }
main.view { padding: 14px 14px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); max-width: 1320px; margin: 0 auto; }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .sidenav { display: flex; flex-direction: column; gap: 4px; position: fixed; top: 0; bottom: 0; right: 0; width: var(--nav-w); background: #eaf4fc; padding: 18px 14px; z-index: 25; }
  .sidenav .brand { text-align: center; margin-bottom: 14px; }
  .sidenav .brand .emoji { font-size: 40px; }
  .sidenav .brand h2 { font-size: 16px; color: #4a5a8c; margin-top: 2px; }
  .sidenav a { text-decoration: none; color: var(--text); padding: 11px 12px; border-radius: 12px; display: flex; gap: 10px; align-items: center; font-weight: 700; }
  .sidenav a:hover { background: #fff8; }
  .sidenav a.active { background: #fff; color: var(--sky-d); box-shadow: var(--shadow); }
  .sidenav .foot { margin-top: auto; font-size: 12px; color: var(--muted); }
  .shell { padding-right: var(--nav-w); }
  .topbar .brand { visibility: hidden; }
  main.view { padding: 20px 24px 40px; }
}

/* ---------- page header & filters ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.page-head h2 { font-size: 22px; color: #4a5a8c; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: #fff; border-radius: 12px; padding: 4px; box-shadow: var(--shadow); }
.seg button { border: 0; background: transparent; padding: 8px 12px; border-radius: 9px; cursor: pointer; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--sky-t); color: var(--sky-d); }
.sel { border: 0; background: #fff; border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); font-weight: 700; color: var(--lav-d); }

/* ---------- cards / grid ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(12, 1fr); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; grid-column: span 12; display: flex; flex-direction: column; }
.card > .hd { padding: 11px 14px; font-weight: 800; font-family: var(--head); font-size: 15px; display: flex; align-items: center; gap: 8px; border-top: 4px solid var(--accent, var(--sky)); background: var(--tint, var(--sky-t)); }
.card > .bd { padding: 12px 14px; flex: 1; position: relative; }
.card > .ft { padding: 8px 14px 12px; color: var(--muted); font-size: 12px; text-align: center; }
.t-sky { --accent: var(--sky); --tint: var(--sky-t); } .t-mint { --accent: var(--mint); --tint: var(--mint-t); }
.t-sun { --accent: var(--sun); --tint: var(--sun-t); } .t-coral { --accent: var(--coral); --tint: var(--coral-t); }
.t-lav { --accent: var(--lav); --tint: var(--lav-t); } .t-pink { --accent: var(--pink); --tint: var(--pink-t); }
.t-peach { --accent: var(--peach); --tint: var(--peach-t); }

.kpis { grid-column: span 12; display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; border-top: 4px solid var(--accent); text-align: center; }
.kpi .lb { font-size: 12.5px; font-weight: 700; color: var(--dk); display: flex; gap: 5px; justify-content: center; align-items: center; }
.kpi .v { font-family: var(--head); font-size: 30px; font-weight: 800; color: var(--dk); line-height: 1.2; margin: 4px 0 2px; }
.kpi .s { font-size: 11.5px; color: var(--muted); min-height: 16px; }
.kpi .s.up { color: #2e9e5b; font-weight: 700; } .kpi .s.down { color: #d9534f; font-weight: 700; }
.k-sky { --accent: var(--sky); --dk: var(--sky-d); } .k-mint { --accent: var(--mint); --dk: var(--mint-d); }
.k-lav { --accent: var(--lav); --dk: var(--lav-d); } .k-sun { --accent: var(--sun); --dk: var(--sun-d); }
.k-coral { --accent: var(--coral); --dk: var(--coral-d); }

.gauges { grid-column: span 12; display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.gauge { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 10px 12px; text-align: center; }
.gauge .t { font-weight: 800; font-size: 13.5px; margin-bottom: 4px; }
.gauge .ring { position: relative; width: 100%; max-width: 150px; aspect-ratio: 1; margin: 0 auto; }
.gauge .ring canvas { position: absolute; inset: 0; }
.gauge .center { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--head); font-size: 26px; font-weight: 800; }
.gauge .lv { margin-top: 6px; font-weight: 800; font-size: 13px; border-radius: 999px; display: inline-block; padding: 3px 12px; }
.lv0, .tag.lv0, .avg.lv0 { background: var(--l0-t); color: var(--l0-d); } .lv1, .tag.lv1, .avg.lv1 { background: var(--l1-t); color: var(--l1-d); }
.lv2, .tag.lv2, .avg.lv2 { background: var(--l2-t); color: var(--l2-d); } .lv3, .tag.lv3, .avg.lv3 { background: var(--l3-t); color: var(--l3-d); }
.avg { font-family: var(--head); font-weight: 800; border-radius: 10px; padding: 2px 10px; display: inline-block; }
.tag.lv0, .tag.lv1, .tag.lv2, .tag.lv3 { font-weight: 700; }
.lvn { background: #eef1f5; color: var(--muted); }

.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 280px; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; text-align: center; }
.donut-center b { font-family: var(--head); font-size: 26px; display: block; line-height: 1.1; }

.gender { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.4fr) minmax(0,1fr); align-items: center; gap: 6px; text-align: center; }
.gender > * { min-width: 0; }
.gender .face { font-size: 44px; line-height: 1; }
.gender .num { font-family: var(--head); font-size: 26px; font-weight: 800; }
.gender .boy .num { color: var(--sky-d); } .gender .girl .num { color: var(--pink-d); }

table.heat { width: 100%; border-collapse: separate; border-spacing: 4px; font-size: 13px; }
table.heat th { color: var(--muted); font-weight: 700; font-size: 12px; }
table.heat td { text-align: center; border-radius: 8px; padding: 8px 4px; font-weight: 700; }
table.heat td.cls { text-align: right; background: transparent; font-weight: 700; }
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { display: flex; gap: 10px; align-items: center; padding: 9px 2px; border-bottom: 1px dashed var(--edge); }
.alerts li:last-child { border-bottom: 0; }
.alerts .ic { font-size: 20px; }
.alerts .ok { color: #2e9e5b; font-weight: 700; } .alerts .warn { color: #d9534f; font-weight: 700; }
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--edge); }
.rank li:last-child { border: 0; }
.rank .nm { font-weight: 700; } .rank .cl { font-size: 11.5px; color: var(--muted); }
.bar { height: 22px; min-width: 64px; border-radius: 8px; position: relative; background: #f1f4f8; overflow: hidden; }
.bar i { position: absolute; inset-block: 0; right: 0; border-radius: 8px; }
.bar b { position: relative; z-index: 1; font-size: 12.5px; padding: 0 8px; line-height: 22px; display: block; }

@media (min-width: 640px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .c6 { grid-column: span 6; }
}
@media (min-width: 1100px) {
  .kpis { grid-template-columns: repeat(6, 1fr); }
  .c4 { grid-column: span 4; } .c6 { grid-column: span 6; } .c8 { grid-column: span 8; }
}

/* ---------- grades entry ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1; min-width: 160px; }
.save-state { font-size: 12px; color: var(--muted); }
.save-state.ok { color: #2e9e5b; } .save-state.err { color: #d9534f; }
.cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, 1fr); } }
.scard { background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 12px; border-right: 5px solid var(--edge); }
.scard.g-ولد { border-right-color: var(--sky); } .scard.g-بنت { border-right-color: var(--pink); }
.scard .top { display: flex; align-items: center; gap: 8px; }
.scard .top .no { color: var(--muted); font-size: 12px; min-width: 20px; }
.scard .top .nm { font-weight: 800; flex: 1; }
.scard .top .avg { font-family: var(--head); font-weight: 800; border-radius: 10px; padding: 2px 10px; }
.scard .tags { display: flex; gap: 6px; margin: 6px 0 8px; flex-wrap: wrap; }
.tag { font-size: 11.5px; border-radius: 999px; padding: 2px 9px; background: #f1f4f8; color: var(--muted); }
.tag.boy { background: var(--sky-t); color: var(--sky-d); } .tag.girl { background: var(--pink-t); color: var(--pink-d); }
.tag.hem { background: var(--lav-t); color: var(--lav-d); }
.subj-inputs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.subj-inputs label { font-size: 11.5px; color: var(--muted); text-align: center; display: block; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-in { width: 100%; text-align: center; border: 1.5px solid var(--edge); border-radius: 12px; padding: 10px 2px; font-size: 18px; font-weight: 800; background: #fff; outline: none; }
.g-in:focus { border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-t); }
.g-in.lv0 { border-color: var(--l0); } .g-in.lv1 { border-color: var(--l1); } .g-in.lv2 { border-color: var(--l2); } .g-in.lv3 { border-color: var(--l3); }
.g-in.bad { background: var(--coral); color: #fff; }
.g-in:disabled { background: #f7f9fb; color: var(--muted); }
.scard .more { margin-top: 8px; display: flex; gap: 8px; }
.scard .more .btn { padding: 7px 10px; font-size: 12.5px; }

.table-wrap { overflow: auto; background: #fff; border-radius: 16px; box-shadow: var(--shadow); max-height: calc(100dvh - 220px); }
table.grades { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
table.grades th, table.grades td { padding: 6px; border-bottom: 1px solid var(--edge); text-align: center; white-space: nowrap; }
table.grades thead th { position: sticky; top: 0; background: #eef6fc; z-index: 2; font-size: 12.5px; }
table.grades td.nm, table.grades th.nm { text-align: right; position: sticky; right: 0; background: #fff; z-index: 1; min-width: 210px; font-weight: 700; }
table.grades thead th.nm { z-index: 3; background: #eef6fc; }
table.grades .g-in { width: 70px; padding: 7px 2px; font-size: 15px; }
table.grades tr:hover td { background: #fafcff; }

/* ---------- forms / modal ---------- */
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.panel h3 { font-size: 16px; margin-bottom: 12px; color: #4a5a8c; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .form-grid.two { grid-template-columns: 1fr 1fr; } .form-grid.four { grid-template-columns: repeat(4, 1fr); } }
.list { width: 100%; border-collapse: collapse; font-size: 14px; }
.list th, .list td { padding: 9px 6px; border-bottom: 1px solid var(--edge); text-align: right; }
.list th { color: var(--muted); font-size: 12.5px; }
.modal-bg { position: fixed; inset: 0; background: rgba(40, 55, 75, .35); z-index: 100; display: grid; place-items: end center; }
@media (min-width: 640px) { .modal-bg { place-items: center; } }
.modal { background: #fff; width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 18px; max-height: 92dvh; overflow: auto; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal { border-radius: 22px; } }
.modal h3 { margin-bottom: 14px; color: #4a5a8c; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 8px; flex-wrap: wrap; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { background: #f3f6fa; border-radius: 10px; padding: 7px 10px; display: flex; gap: 6px; align-items: center; font-size: 13.5px; }
.toast { position: fixed; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: #34465a; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 200; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
@media (min-width: 900px) { .toast { bottom: 24px; } }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty .big { font-size: 46px; }

/* ---------- report ---------- */
.report-page-head { max-width: 860px; margin: 4px auto 12px; display: block; }
.report-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.report-page-head .filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: 8px; }
.report-page-head .sel { width: 100%; }
.report-phone { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; color: #176b3d; text-underline-offset: 3px; font-weight: 700; }
.report-contact { max-width: 860px; margin: 0 auto 14px; padding: 12px 14px; border: 1px solid var(--edge); border-radius: 12px; background: #fff; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.report-contact .contact-meta { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.report-contact .contact-meta > b { display: block; margin-bottom: 4px; }
.report-contact .sel { width: 100%; max-width: 100%; }
.report-contact > p { flex-basis: 100%; margin: 0; }
.report-contact .whatsapp { gap: 12px; }
.report-contact .whatsapp bdi { font-size: 17px; }
.report-contact .whatsapp span { font-size: 13px; }
.message-tokens { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.message-tokens .btn { min-height: 44px; padding: 9px 12px; font-size: 13px; }
#s_whatsapp_help { margin-top: 10px; line-height: 1.7; }
.message-preview { margin-top: 12px; padding: 12px; background: #f4faf6; border: 1px solid #dcebe1; border-radius: 12px; }
#s_whatsapp_preview { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; margin-top: 8px; }
.report .chart-box canvas { max-width: 100%; }
.uae-phone { display: flex; align-items: center; border: 1px solid var(--edge); border-radius: 10px; overflow: hidden; background: #fff; }
.uae-phone > span { padding: 10px 12px; font-weight: 700; background: #edf4fa; align-self: stretch; display: flex; align-items: center; }
.uae-phone > .input { border: 0; border-radius: 0; min-width: 0; flex: 1; text-align: left; }
.uae-phone:focus-within { outline: 2px solid #6ec1e4; }
.report { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; max-width: 860px; margin: 0 auto; }
.report .r-head { text-align: center; border-radius: 16px; padding: 14px; background: linear-gradient(90deg, #ffe3ee, #e0f2ff); }
.report .r-head h2 { color: #4a5a8c; font-size: 22px; }
.report .who { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 14px 0; font-size: 14px; }
.report .who div { background: #f6f9fc; border-radius: 10px; padding: 8px 10px; }
.report table.rt { width: 100%; border-collapse: separate; border-spacing: 0 4px; font-size: 13.5px; }
.report table.rt th { color: var(--muted); font-size: 12px; padding: 4px; }
.report table.rt td { padding: 8px 6px; text-align: center; background: #f8fafc; }
.report table.rt td:first-child { text-align: right; min-width: 150px; border-radius: 0 10px 10px 0; font-weight: 700; }
.report table.rt td:last-child { border-radius: 10px 0 0 10px; }
.report .sum { display: grid; gap: 8px; margin-top: 12px; }
.report .sum div { border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.report .sig { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 22px; text-align: center; font-size: 13px; color: var(--muted); }
.report .sig div { border-top: 1.5px dashed #cfd8e3; padding-top: 30px; }
.up { color: #2e9e5b; font-weight: 700; } .down { color: #d9534f; font-weight: 700; }

/* A4 and print preview rules are in print.css. */
#printHost { display: none; }

/* ---------- logo / footer / flexible assignments ---------- */
.login-logo { display: block; width: 100%; max-width: 300px; height: auto; margin: 4px auto 6px; }
.side-logo { display: block; width: 100%; max-width: 196px; height: auto; margin: 4px auto 8px; }
.sidenav .brand { background: #fff; border-radius: 16px; padding: 12px 8px 10px; box-shadow: var(--shadow); }
.top-logo { height: 38px; width: auto; flex: none; }
.topbar .brand .sub { line-height: 1.25; }
.rep-logo { height: 64px; width: auto; }
.report .r-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; text-align: right; background: #fff; border: 1.5px solid #e3efe8; border-bottom: 4px solid #02a055; }
.report .r-head .r-title { text-align: left; }
.report .r-head h2 { color: #1f6f45; }
@media (max-width: 560px) { .report .r-head { flex-direction: column; text-align: center; } .report .r-head .r-title { text-align: center; } .rep-logo { height: 54px; } }
.supervisor { text-align: center; font-size: 11.5px; color: var(--muted); padding: 18px 8px 6px; letter-spacing: .2px; }
.login-card .supervisor { padding: 16px 0 0; border-top: 1px dashed var(--edge); margin-top: 18px; }
.report .supervisor { padding-top: 14px; }
.subj-row { display: grid; grid-template-columns: 2fr 1fr 70px auto; gap: 8px; align-items: end; margin-bottom: 6px; }
.subj-row .field { margin-bottom: 6px; }
.subj-row .btn { margin-bottom: 6px; padding: 10px 12px; }
@media (max-width: 640px) { .subj-row { grid-template-columns: 1fr 1fr; } .subj-row .field:first-child { grid-column: span 2; } }
.assign { display: grid; gap: 8px; }
.assign-row { background: #f6f9fc; border-radius: 12px; padding: 10px; }
.assign-row b { display: block; margin-bottom: 6px; }
.assign-row .hr { display: inline-flex; gap: 6px; align-items: center; font-size: 13.5px; margin-bottom: 6px; color: var(--mint-d); font-weight: 700; }
.assign-row .checks label { background: #fff; }
@media (min-width: 640px) { .gauges { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
.scard.inactive, tr.inactive td { opacity: .55; }
.state-box { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; background: var(--mint-t); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.state-box.off { background: #eef1f5; }
.state-box .btn { margin-inline-start: auto; padding: 8px 12px; }
.checks.col { flex-direction: column; align-items: stretch; }

/* phones: no auto-zoom on iOS (inputs >= 16px), compact charts */
@media (max-width: 900px) {
  .input, select.input, textarea.input, .sel, .search { font-size: 16px; }
  .chart-box { height: 210px; }
  .gauge .ring { max-width: 120px; }
  .gauge .center { font-size: 22px; }
}

/* ---------- interactive dashboard ---------- */
.dd { cursor: pointer; transition: transform .12s, box-shadow .12s, filter .12s; }
.kpi.dd:hover, .gauge.dd:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(60, 80, 110, .14); }
.kpi.dd:active, .gauge.dd:active, .rank li.dd:active { transform: scale(.98); }
.rank li.dd:hover, .spr.dd:hover { background: #f7fafd; }
table.heat td.dd:hover { filter: brightness(.95); outline: 2px solid #fff; }
.dd-hint { grid-column: span 12; text-align: center; font-size: 12px; color: var(--muted); margin: -4px 0 -2px; }
.card .hd .btn.sm { padding: 2px 8px; min-height: 0; font-size: 13px; }
.big { font-family: var(--head); font-size: 34px; font-weight: 800; line-height: 1.15; }
.why { color: var(--coral-d); font-weight: 600; }
.warnl li { grid-template-columns: 28px 1fr auto; }
/* drill-down list */
.modal:has(.dd-table) { max-width: 760px; }
.dd-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dd-table th { position: sticky; top: 0; background: #f3f6fa; font-size: 12px; padding: 6px 4px; white-space: nowrap; }
.dd-table td { padding: 6px 4px; border-bottom: 1px dashed var(--edge); text-align: center; }
.dd-table td:first-child { text-align: start; min-width: 140px; }
.dd-table td.hl { background: #fff7e0; }
.dd-table .nm { font-weight: 700; color: #3c5a99; text-decoration: none; }
.dd-table .cl { font-size: 11px; color: var(--muted); }
/* target */
.tbar { position: relative; height: 12px; background: #eef1f5; border-radius: 99px; overflow: visible; flex: 1; }
.tbar i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; }
.tbar u { position: absolute; top: -4px; bottom: -4px; width: 3px; background: #4a5a8c; border-radius: 2px; transform: translateX(-1px); }
.tbar { direction: ltr; }
.trow { display: grid; grid-template-columns: minmax(0, 1.2fr) 2fr 44px; gap: 8px; align-items: center; font-size: 12.5px; margin-top: 7px; }
/* spread */
.spr-scale { display: flex; justify-content: space-between; direction: ltr; font-size: 10.5px; color: var(--muted); margin: 0 calc(84px) 2px 0; padding-left: calc(38% + 8px); }
.spr { display: grid; grid-template-columns: minmax(0, 38%) 1fr 76px; gap: 8px; align-items: center; padding: 7px 4px; border-bottom: 1px dashed var(--edge); border-radius: 8px; }
.spr .nm { font-weight: 700; font-size: 13px; }
.spr .track { position: relative; height: 12px; background: #eef1f5; border-radius: 99px; direction: ltr; }
.spr .track i { position: absolute; top: 0; bottom: 0; background: #bfe3f4; border-radius: 99px; }
.spr .track b { position: absolute; top: -3px; width: 10px; height: 18px; margin-left: -5px; background: var(--sky-d); border-radius: 5px; }
.spr .tag { text-align: center; font-size: 11px; }
/* hemam */
.hem { display: flex; justify-content: space-around; align-items: center; text-align: center; padding: 6px 0 10px; border-radius: 12px; }
.hem .vs { color: var(--muted); font-size: 12px; }
@media print { .dd-hint, #tgEdit { display: none !important; } }
@media (max-width: 560px) {
  .dd-table { font-size: 11.5px; }
  .dd-table th { font-size: 10.5px; padding: 5px 2px; }
  .dd-table td { padding: 5px 2px; }
  .dd-table td:first-child { min-width: 0; max-width: 118px; }
  .dd-table .nm { display: block; line-height: 1.25; }
  .dd-table .tag { padding: 1px 4px; font-size: 11px; min-width: 0; }
  .dd-table .cl { line-height: 1.25; }
}
.h-with-ic { display: flex; align-items: center; gap: 10px; }
.h-with-ic .h-ic { flex: none; filter: drop-shadow(0 2px 4px rgba(90, 120, 170, .15)); }
@media (max-width: 560px) { .h-with-ic .h-ic { width: 32px; height: 32px; } }
/* admin tabs: never wider than the screen */
#aseg { max-width: 100%; flex-wrap: wrap; justify-content: center; }
@media (max-width: 560px) { #aseg button { padding: 7px 9px; font-size: 13px; } }
/* drill-down filters */
.dd-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dd-filters .input { width: auto; flex: 1 1 140px; min-width: 0; padding: 8px 10px; font-size: 14px; }
.dd-filters #ddq { flex: 2 1 200px; }
.dd-filters .chk { display: inline-flex; gap: 5px; align-items: center; font-size: 13px; font-weight: 700; color: var(--lav-d); background: #f4effc; padding: 7px 10px; border-radius: 10px; }
.dd-table tr.grp td { background: #eef6fc; text-align: start; font-weight: 800; color: var(--sky-d); padding: 7px 8px; }
.dd-table .no { display: inline-block; min-width: 20px; color: var(--muted); font-size: 11px; }
@media (max-width: 560px) { .dd-filters .input { flex: 1 1 45%; font-size: 16px; } .dd-filters #ddq { flex-basis: 100%; } }
#wcmp { max-width: 100%; }
#wcmp button { white-space: nowrap; }
@media (max-width: 560px) { #wcmp button { font-size: 12.5px; padding: 7px 7px; } }
/* academic years */
.year-btn { border: 0; background: transparent; font: inherit; color: inherit; cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.year-btn:not(:disabled):hover { background: #eef4fb; }
.year-btn:disabled { cursor: default; }
.year-btn.arch { background: #fff1c9; color: #8a6100; font-weight: 800; }
.arch-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; background: #fff7dd; border: 1px solid #ffe2a0; color: #7a5600; border-radius: 14px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.year-list { display: flex; flex-direction: column; gap: 8px; }
.year-list .btn { justify-content: flex-start; }
.fx-sel { display: flex; flex-direction: column; gap: 6px; }
/* gender donut: a square box the canvas can never outgrow (iOS Safari sized it wider than its column) */
.gender .g-ring { position: relative; width: 100%; max-width: 170px; aspect-ratio: 1; margin: 0 auto; overflow: hidden; }
.gender .g-ring canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
@media print { .print-dash .gender .g-ring { aspect-ratio: auto; height: auto; overflow: visible; } .print-dash .gender .g-ring img { position: static; width: 100%; } }


/* Mobile controls stay within the viewport, with readable text and touch targets. */
.grid > *, .filters, .form-grid > *, .subj-row > *, .scard, .report { min-width: 0; }
.filters, .sel, .seg { max-width: 100%; }
.input, .sel { min-width: 0; }
.btn, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--sky-d); outline-offset: 3px; }
body.modal-open { overflow: hidden; }
.modal { overscroll-behavior: contain; }
.modal-close { position: sticky; top: 0; float: left; z-index: 3; min-width: 44px; min-height: 44px; margin: -6px 0 8px 8px; font-size: 24px; background: #edf4fa; }
.modal h3 { min-height: 38px; padding-top: 4px; }
.report-table { overflow-x: auto; }
@media screen and (max-width: 899px) {
  .topbar { flex-wrap: wrap; padding-inline: max(12px, env(safe-area-inset-right)); }
  .topbar .brand { flex: 1 0 100%; justify-content: space-between; }
  .topbar .chip { min-height: 40px; max-width: 100%; font-size: 13px; white-space: normal; overflow-wrap: anywhere; }
  .topbar .year-btn { flex: none; min-height: 40px; font-size: 13px; }
  .topbar .top-logo { max-width: calc(100% - 100px); object-fit: contain; }
  .btn, .seg button, .sel, #aseg button { min-height: 44px; }
  .btn { white-space: normal; }
  .card .hd .btn.sm { min-width: 44px; min-height: 44px; }
  .scard .more .btn { min-height: 44px; font-size: 14px; }
  .subj-inputs { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .subj-inputs label { font-size: 13px; white-space: normal; overflow: visible; }
  .scard .more { flex-wrap: wrap; }
  .scard .top .nm { overflow-wrap: anywhere; }
  .tabbar a { min-width: 0; }
  .toast { width: max-content; max-width: calc(100vw - 24px); text-align: center; }
  #wcmp { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  #wcmp button { white-space: normal; line-height: 1.45; padding: 8px 6px; }
}
@media screen and (max-width: 560px) {
  .subj-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Keep one semantic table and the existing A4 print layout. On small screens,
   each subject gets full-width labels and predictable, evenly sized cells. */
@media screen and (max-width: 760px) {
  .report-heading h2 { font-size: 20px; }
  .report-heading .btn { padding: 10px; font-size: 13px; flex: none; }
  .report-page-head .filters { grid-template-columns: minmax(0, 1fr); }
  .report-page-head #rseg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .report-page-head .sel { font-size: 16px; }
  .report-contact { padding: 12px; gap: 8px; }
  .report-contact .contact-meta { flex-basis: 100%; }
  .report-contact .whatsapp, .report-contact > .btn { width: 100%; }
  .report-contact .contact-meta > b { margin-bottom: 3px; }
  #view .report { padding: 12px; }
  #view .report .who { grid-template-columns: minmax(0, 1fr); }
  #view .report .who div { overflow-wrap: anywhere; line-height: 1.65; }
  #view .report .r-head { padding: 12px; gap: 8px; }
  #view .report .r-head h2 { font-size: 20px; }
  #view .report .r-head .muted { font-size: 13px; line-height: 1.6; }
  #view .report .rep-logo { max-width: 100%; object-fit: contain; }
  #view .report-table { overflow: visible; }
  #view .report table.rt { display: block; border-spacing: 0; }
  #view .report table.rt thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #view .report table.rt tbody { display: grid; gap: 10px; }
  #view .report table.rt tr { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border: 1px solid #dce6ee; border-radius: 12px; overflow: hidden; background: #fff; }
  #view .report table.rt td { display: block; min-width: 0; border-radius: 0; border: 0; padding: 9px 6px; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; background: #fff; }
  #view .report table.rt td:first-child { grid-column: 1 / -1; grid-row: 1; min-width: 0; background: #edf6fb; padding: 10px 12px; font-size: 14px; }
  #view .report table.rt td:nth-child(2), #view .report table.rt td:nth-child(3), #view .report table.rt td:nth-child(4) { grid-column: span 2; grid-row: 2; border-bottom: 1px solid #e7edf3; }
  #view .report table.rt td:nth-child(5) { grid-column: 1 / 4; grid-row: 3; }
  #view .report table.rt td:nth-child(8) { grid-column: 4 / 7; grid-row: 3; }
  #view .report table.rt td:nth-child(6), #view .report table.rt td:nth-child(7) { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; text-align: end; border-top: 1px solid #e7edf3; }
  #view .report table.rt td:nth-child(6) { grid-row: 4; }
  #view .report table.rt td:nth-child(7) { grid-row: 5; }
  #view .report table.rt td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: #52637a; font-weight: 700; margin-bottom: 4px; }
  #view .report table.rt td:nth-child(6)::before, #view .report table.rt td:nth-child(7)::before { margin: 0; flex: 0 0 auto; }
  #view .report table.rt .tag { white-space: normal; max-width: 100%; line-height: 1.45; }
  #view .report table.rt .report-total td:first-child { background: var(--mint-t); }
  #view .report .sum div { overflow-wrap: anywhere; line-height: 1.65; padding: 10px; }
  #view .report .sig { gap: 6px; font-size: 11px; }
  #view .report .sig div { overflow-wrap: anywhere; padding-top: 22px; }
  #view .report .supervisor { overflow-wrap: anywhere; line-height: 1.6; }
}

/* Hidden notices must not inherit the visible button layout. */
.btn[hidden] { display: none !important; }


/* ---------- developmental domains ---------- */
.lens-seg button { white-space: nowrap; }
.rt-key { display: inline-block; padding: 1px 7px; border-radius: 8px; margin: 2px 1px; font-weight: 700; font-size: 11.5px; }
.r1 { --rc: #fad4d0; --rd: #b23b3b; } .r2 { --rc: #fff1c9; --rd: #8a6100; } .r3 { --rc: #d8eefb; --rd: #1b6a9a; } .r4 { --rc: #cdefd9; --rd: #1f7a45; }
.rt-key { background: var(--rc); color: var(--rd); }
table.ob-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ob-grid th { font-size: 11.5px; color: var(--muted); padding: 6px 3px; white-space: nowrap; line-height: 1.25; }
table.ob-grid td { padding: 7px 3px; border-bottom: 1px dashed var(--edge); text-align: center; }
table.ob-grid td:first-child { text-align: start; min-width: 150px; }
table.ob-grid tr[data-ob] { cursor: pointer; } table.ob-grid tr[data-ob]:hover { background: #f7fafd; }
table.ob-grid .no { display: inline-block; min-width: 20px; color: var(--muted); font-size: 11px; }
table.ob-grid .tag { font-size: 11px; padding: 2px 6px; }
.ob-prog { width: 64px; height: 7px; background: #eef1f5; border-radius: 99px; overflow: hidden; margin: 0 auto 2px; direction: ltr; }
.ob-prog i { display: block; height: 100%; background: var(--mint); }
.ob-nav { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.ob-nav .sel { flex: 1; min-width: 160px; }
.ob-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 2px 10px; font-size: 16px; }
.ob-dom { margin-bottom: 12px; }
.ob-dom .hd .ob-lv { margin-inline-start: auto; }
.ob-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--edge); }
.ob-row:last-child { border: 0; }
.ob-name { font-weight: 600; font-size: 14px; line-height: 1.4; }
.ob-prev { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.ob-choices { display: flex; gap: 4px; }
.ob-c { border: 1.5px solid var(--rc); background: #fff; color: var(--rd); border-radius: 10px; padding: 8px 7px; min-width: 54px; font-weight: 700; font-size: 12.5px; cursor: pointer; }
.ob-c.on { background: var(--rc); border-color: var(--rd); box-shadow: inset 0 0 0 1px var(--rd); }
.ob-c:disabled { cursor: default; opacity: .75; }
.ob-c:disabled.on { opacity: 1; }
@media (max-width: 560px) {
  .ob-row { grid-template-columns: 1fr; gap: 6px; }
  .ob-choices { display: grid; grid-template-columns: repeat(4, 1fr); }
  .ob-c { min-width: 0; padding: 10px 2px; }
}
.ob-nav { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; }
.ob-nav .sel { min-width: 0; width: 100%; }
.ob-nav .btn { padding: 9px 11px; }
.lvdot { display: inline-block; width: 18px; height: 18px; border-radius: 50%; vertical-align: middle; }
.lvdot.lv0 { background: var(--l0); } .lvdot.lv1 { background: var(--l1); } .lvdot.lv2 { background: var(--l2); } .lvdot.lv3 { background: var(--l3); } .lvdot.lvn { background: #e3e8ef; }
.lv-legend { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; justify-content: center; margin-bottom: 4px; }
.lv-legend span { display: inline-flex; align-items: center; gap: 4px; }
.lv-legend .lvdot { width: 11px; height: 11px; }
@media (max-width: 560px) { table.ob-grid td:first-child { min-width: 120px; } .ob-prog { width: 44px; } table.ob-grid th { font-size: 10px; } .lvdot { width: 16px; height: 16px; } }
.ob-th { display: block; }
@media (max-width: 560px) { .ob-th { display: none; } table.ob-grid th { font-size: 16px; padding: 4px 1px; } table.ob-grid td { padding: 7px 1px; } }
/* child report: developmental domains */
.r-domains { margin-top: 14px; }
.r-sub { font-size: 16px; margin: 0 0 8px; color: #3c6b4a; }
.r-dom-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; align-items: start; }
.r-radar { height: 260px !important; }
@media (max-width: 760px) { .r-dom-grid { grid-template-columns: 1fr; } }
.dom-card { border: 1px solid var(--edge); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; background: #fbfdfb; }
.dom-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dom-top .dom-act { margin-inline-start: auto; display: inline-flex; gap: 2px; }
.dom-card ol { margin: 6px 0 0; padding-inline-start: 22px; color: #4a5568; line-height: 1.7; }
.dom-checks { border-top: 1px dashed var(--edge); padding-top: 6px; margin-top: 6px; }
/* backup reminder */
.backup-due { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; background: #fff7dd; border: 1px solid #ffe2a0; color: #7a5600; border-radius: 14px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
