:root {
  --bg-page: #F5F0F8;
  --bg-header: #4C126B;
  --header-nav-active: #350B4C;
  --color-primary-orange: #FF6A00;
  --color-secondary-gold: #FFA800;
  --text-dark: #28083B;
  --text-light: #FFFFFF;
  --border-light: #E2D8E8;
  --brand: var(--color-primary-orange);
  --brand-dark: var(--bg-header);
  --bg: var(--bg-page);
  --line: var(--border-light);
  --text: var(--text-dark);
  --muted: #6B5B75;
  --bad: #b3261e;
  --warn: #9a6700;
  /* Accessible action colours: white on #C2410C is 5.18:1 */
  --action: #C2410C;
  --action-hover: #9A3412;
  --focus-ring: #4C126B;
  --disabled-bg: #E9E1EE;
  --disabled-text: #6B5B75;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
h1, h2, h3 { margin: 0 0 .6rem; }
h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
button, input, select, textarea { font: inherit; }
input, select, textarea { padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; max-width: 100%; color: var(--text-dark); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus-ring); outline-offset: 1px; border-color: var(--focus-ring); }
textarea { width: 100%; min-height: 5rem; }
label { display: block; margin: 0 0 .25rem; }
label[data-required]::after { content: " *"; color: var(--bad); }
label.field-check, label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
input[type="checkbox"], input[type="radio"] { width: 1.1rem; height: 1.1rem; min-height: 0; margin: 0; padding: 0; border: 0; background: none; accent-color: var(--bg-header); flex: none; }
.check-list { border: 1px solid var(--line); border-radius: 6px; background: #fff; max-width: 460px; }
.check-list .check-all { padding: .45rem .55rem; border-bottom: 1px solid var(--line); font-weight: 600; }
.check-list .check-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .15rem .8rem; padding: .45rem .55rem; max-height: 11rem; overflow: auto; }
.check-list .check-row { display: flex; align-items: center; gap: .45rem; margin: 0; cursor: pointer; }
.check-list input:disabled { cursor: not-allowed; }
button { padding: .45rem .9rem; border: 0; border-radius: 6px; background: var(--action); color: var(--text-light); cursor: pointer; transition: background-color .15s ease, box-shadow .15s ease, transform .15s ease; }
button:hover { background: var(--action-hover); box-shadow: 0 2px 8px rgba(76, 18, 107, 0.12); transform: translateY(-1px); }
button.ghost { background: #fff; color: var(--action); border: 1px solid var(--action); }
button.ghost:hover { background: #FFF1E8; border-color: var(--action); color: var(--action-hover); }
button.danger { background: var(--bad); }
button.danger:hover { background: #8F1D17; }
button:disabled { background: var(--disabled-bg); color: var(--disabled-text); opacity: 1; cursor: not-allowed; box-shadow: none; transform: none; }
button.ghost:disabled { background: #F4F0F7; border-color: var(--line); color: var(--disabled-text); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.login { max-width: 380px; margin: 8vh auto; background: #fff; padding: 2rem; border: 1px solid var(--border-light); border-radius: 12px; box-shadow: 0 8px 28px rgba(76, 18, 107, 0.05); }
.login h1 { color: var(--bg-header); }
.brand-logo { display: block; width: 100%; max-width: 380px; height: auto; }
.document-logo { width: 280px; margin-bottom: 1rem; }
.print-brand { display: none; }
.login label { display: block; margin: .6rem 0 .2rem; font-size: .85rem; color: var(--text-dark); }
.login input { width: 100%; }
.login button { width: 100%; margin-top: 1rem; }
.platform-login-link { margin: 1.2rem 0 0; text-align: center; font-size: .85rem; }
.platform-login-link a { color: var(--bg-header); }
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.shell > nav { background: var(--bg-header); color: var(--text-light); padding: 1rem .6rem; display: flex; flex-direction: column; gap: .2rem; }
.shell > nav .logo { color: var(--text-light); font-size: 1rem; font-weight: 750; padding: .2rem .45rem .55rem; }
.shell > nav .logo .brand-logo { height: 34px; width: auto; max-width: 100%; background: #fff; border-radius: 6px; padding: .2rem .35rem; }
.nav-school { margin-top: .45rem; color: rgba(255, 255, 255, 0.72); font-size: .72rem; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.shell > nav a { color: rgba(255, 255, 255, 0.88); padding: .5rem .7rem; border-left: 3px solid transparent; border-radius: 0 6px 6px 0; cursor: pointer; text-decoration: none; line-height: 1.3; }
.shell > nav a.active, .shell > nav a:hover { background: var(--header-nav-active); border-left-color: var(--color-primary-orange); color: var(--text-light); }
.shell > nav .nav-group { margin-bottom: .35rem; }
.shell > nav .nav-group > summary { color: var(--text-light); padding: .5rem .7rem; font-size: .9rem; }
.shell > nav .nav-group > a { display: block; margin-left: .4rem; font-size: .85rem; }
.shell > nav .nav-subgroup { margin: .1rem 0 .1rem .55rem; border-left: 1px solid rgba(255, 255, 255, 0.18); padding-left: .15rem; }
.shell > nav .nav-subgroup > summary { color: rgba(255, 255, 255, 0.9); padding: .4rem .5rem; font-size: .82rem; }
.shell > nav .nav-subgroup > a { display: block; margin-left: 0; font-size: .8rem; padding: .4rem .5rem; }
.shell > nav .nav-subgroup .nav-subgroup { margin-left: .3rem; }
.shell > nav a:focus-visible, .shell > nav summary:focus-visible { outline: 2px solid var(--color-secondary-gold); outline-offset: -2px; }
.shell > nav { position: sticky; top: 0; height: 100vh; overflow: hidden; }
.shell > nav .nav-head { flex: none; }
.nav-toggle { display: none; }
.shell > nav .nav-menu { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: .2rem; padding-top: .4rem; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.35) transparent; }
.shell > nav .nav-menu::-webkit-scrollbar { width: 6px; }
.shell > nav .nav-menu::-webkit-scrollbar-track { background: transparent; }
.shell > nav .nav-menu::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.35); border-radius: 3px; }
.workspace { min-width: 0; }
.user-bar { position: sticky; top: 0; z-index: 30; display: flex; justify-content: flex-end; align-items: center; min-height: 60px; padding: .35rem 1.6rem; background: #fff; border-bottom: 1px solid var(--line); }
.top-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; min-width: 0; min-height: 44px; }
.page-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.05rem; font-weight: 750; color: var(--text); }
.user-bar .who { position: relative; width: auto; max-width: 100%; margin: 0; padding: 0; color: var(--text); background: transparent; border: 0; }
.who-trigger { display: inline-flex; align-items: center; gap: .5rem; min-height: 40px; max-width: 100%; padding: .2rem .55rem .2rem .25rem; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--text); }
.who-trigger:hover, .who-trigger[aria-expanded="true"] { background: var(--bg-page); border-color: var(--line); box-shadow: none; transform: none; }
.who-trigger:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.who-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--bg-header); color: #fff; font-weight: 750; font-size: .8rem; }
.who-avatar img { width: 100%; height: 100%; object-fit: cover; }
.who-name { min-width: 0; max-width: 15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; font-weight: 700; }
.who-caret { flex: none; color: var(--muted); font-size: .65rem; }
.who-menu { position: absolute; top: calc(100% + .35rem); right: 0; z-index: 60; width: 248px; max-width: calc(100vw - 1.4rem); padding: .35rem; background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 16px 34px rgba(23, 5, 34, .2); }
.who-menu[hidden] { display: none; }
.who-menu-head { padding: .5rem .6rem .6rem; margin-bottom: .25rem; border-bottom: 1px solid var(--line); }
.who-menu-name { font-size: .9rem; font-weight: 750; overflow-wrap: anywhere; }
.who-role { display: inline-block; margin-top: .15rem; color: var(--color-primary-orange); font-size: .68rem; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.who-school { margin-top: .2rem; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.who-item { display: block; width: 100%; min-height: 38px; padding: .45rem .6rem; border: 0; border-radius: 6px; background: transparent; color: var(--text); text-align: left; font-size: .88rem; }
.who-item:hover, .who-item:focus-visible { background: var(--bg-page); box-shadow: none; transform: none; }
.who-sep { height: 1px; margin: .25rem .3rem; background: var(--line); }
.profile-dialog { width: min(420px, calc(100% - 2rem)); padding: 1.2rem; border: 0; border-radius: 10px; box-shadow: 0 24px 60px rgba(23, 5, 34, .3); }
.profile-dialog::backdrop { background: rgba(23, 5, 34, .45); }
main { padding: 1.4rem 1.6rem; overflow-x: auto; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; margin-bottom: 1rem; box-shadow: 0 4px 18px rgba(76, 18, 107, 0.05); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; box-shadow: 0 4px 18px rgba(76, 18, 107, 0.05); color: inherit; text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
a.stat:hover { border-color: #D9C7E6; box-shadow: 0 6px 20px rgba(76, 18, 107, 0.1); transform: translateY(-1px); }
.stat b { display: block; font-size: 1.5rem; color: var(--bg-header); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.skeleton b, .stat.skeleton span { color: transparent; border-radius: 4px; background: linear-gradient(90deg, #EFE7F5 25%, #F7F2FA 50%, #EFE7F5 75%); background-size: 200% 100%; animation: stat-skeleton 1.2s ease-in-out infinite; }
.stat.skeleton b { max-width: 9rem; }
.stat.skeleton span { max-width: 70%; }
@keyframes stat-skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); font-size: .93rem; color: var(--text-dark); }
th { color: var(--bg-header); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--border-light); }
tbody tr:hover { background: var(--bg-page); }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin-bottom: .8rem; }
.row > div { display: flex; flex-direction: column; gap: .2rem; }
.row > div[hidden] { display: none; }
.row label { font-size: .8rem; color: var(--bg-header); }
.table-scroll { overflow-x: auto; }
.report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.report-head h3 { margin: 0 0 .2rem; }
.report-head p { margin: 0; }
.report-tools { display: flex; gap: .4rem; flex-wrap: wrap; }
.report-tools button { white-space: nowrap; }
#report-print { display: none; }
.accounting-page, .accounting-page .card, .accounting-page .row > div { min-width: 0; max-width: 100%; }
.accounting-page .row > div { flex: 1 1 180px; }
.accounting-page input, .accounting-page select { min-width: 0; max-width: 100%; }
.coa-category { margin: .5rem 0; border-left: 4px solid var(--bg-header); padding-left: .6rem; }
.coa-category > summary { font-weight: 700; color: var(--bg-header); cursor: pointer; padding: .25rem 0; }
.coa-table { width: 100%; }
.coa-table .coa-group th { text-align: left; background: #F1E8F6; color: var(--bg-header); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.coa-table .coa-code { font-variant-numeric: tabular-nums; white-space: nowrap; }
.coa-table .coa-name { display: inline-flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.coa-table .coa-depth-0 .coa-name { padding-left: .75rem; }
.coa-table .coa-depth-1 .coa-name { padding-left: 2rem; }
.coa-table .coa-depth-2 .coa-name { padding-left: 3.25rem; }
.coa-table .coa-depth-3 .coa-name, .coa-table .coa-depth-4 .coa-name { padding-left: 4.5rem; }
.coa-table .coa-depth-1 .coa-code, .coa-table .coa-depth-2 .coa-code, .coa-table .coa-depth-3 .coa-code, .coa-table .coa-depth-4 .coa-code { color: #555; }
.coa-table .coa-parent td { font-weight: 700; }
.coa-table .coa-branch { color: var(--bg-header); font-family: monospace; }
.coa-table .coa-inactive td { color: #888; }
.accounting-page .journal-line { align-items: flex-end; }
.accounts-interface-group { margin-top: 14px; }
.accounts-interface-group h4 { margin: 0 0 6px; }
.accounts-interface-group select { min-width: 220px; }
.gl-picker { display: flex; flex-direction: column; gap: 4px; min-width: 220px; }
.gl-picker .gl-search { font-size: .9em; padding: 6px 10px; }
.gl-picker .gl-count:empty { display: none; }
.gl-view { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.gl-detail { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
.gl-summary .cards { margin: .6rem 0 1rem; }
.gl-table td.num, .gl-table th:nth-child(n+5), .gl-lines td.num, .gl-lines th.num { text-align: right; white-space: nowrap; }
.gl-accounts .gl-account-search { min-width: 220px; }
.gl-accounts .row .gl-count { align-self: center; }
.gl-accounts-table td.num, .gl-accounts-table th:nth-child(n+4) { text-align: right; white-space: nowrap; }
.gl-accounts-table tr.gl-account-row { cursor: pointer; }
.gl-accounts-table tr.gl-account-row:hover td { background: #faf5ff; }
.gl-accounts-table tr.gl-account-row:focus { outline: 2px solid var(--color-primary-orange); outline-offset: -2px; }
.gl-accounts-table tr.gl-account-inactive td { color: #888; }
.gl-table tr.gl-row { cursor: pointer; }
.gl-table tr.gl-row:hover td { background: #faf5ff; }
.gl-table tr.gl-row:focus { outline: 2px solid var(--color-primary-orange); outline-offset: -2px; }
.gl-table tr.gl-selected td { background: #fff4e5; font-weight: 600; }
.gl-table tr.gl-selected td:first-child { box-shadow: inset 4px 0 0 var(--color-primary-orange); }
.gl-facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .75rem; margin: 0 0 .8rem; font-size: .9rem; }.gl-facts dt { color: var(--muted); }
.gl-facts dd { margin: 0; }
.gl-lines { width: 100%; font-size: .88rem; }
.gl-lines tr.gl-this td { background: #fff4e5; font-weight: 600; }
.gl-lines tfoot th { border-top: 2px solid var(--line); }
@media (max-width: 1100px) { .gl-view { grid-template-columns: 1fr; } .gl-detail { position: static; max-height: none; } }
.accounting-page .actions { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.fee-invoice, .fee-invoice .row > div { min-width: 0; max-width: 100%; }
.fee-structure-preview { margin-top: .8rem; }
.fee-structure-preview h4 { margin: 0 0 .5rem; color: var(--bg-header); }
.fee-structure-preview h5 { margin: .8rem 0 .35rem; }
.fee-payment-allocations { flex: 1 1 100%; min-width: 0; max-width: 100%; }
.fee-receipt-invoice { margin: .75rem 0; }
.fee-receipt-invoice h5 { margin: 0 0 .35rem; color: var(--bg-header); }
.fee-receipt-plan { flex: 1 1 100%; min-width: 0; max-width: 100%; margin-top: 1rem; }
.fee-receipt-plan h4 { margin: 0 0 .5rem; }
.fee-receipt-plan h5 { margin: .8rem 0 .35rem; }
.fee-receipt-form > .row { align-items: flex-start; }
.document-id { overflow-wrap: anywhere; }
.fee-credit-account .row > div { min-width: 0; max-width: 100%; }
.fee-credit-account input, .fee-credit-account select { max-width: 100%; }
.fee-credit-account table { overflow-wrap: anywhere; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 1rem 0 0; }
.pagination > span { color: var(--muted); font-size: .85rem; }
/* A pager with no enabled direction navigates nowhere: hide it. */
.pagination:not(:has(button:not(:disabled))) { display: none; }

/* Fixed-height data tables: the table scrolls, the page stays put. */
.data-table { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; overscroll-behavior: contain; }
.data-table table { width: 100%; }
.data-table thead th { position: sticky; top: 0; z-index: 2; background: #F7F2FA; box-shadow: inset 0 -2px 0 var(--border-light); }
.data-table tbody tr.row-clickable { cursor: pointer; }
.data-table tbody tr.row-clickable:hover td, .data-table tbody tr.row-clickable:focus td { background: #FAF5FF; }
.data-table tbody tr.row-selected td { background: #FFF4E5; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .sort-button { background: none; color: inherit; border: 0; border-radius: 0; padding: 0; font: inherit; font-size: inherit; letter-spacing: inherit; text-transform: inherit; text-align: inherit; white-space: nowrap; }
.data-table .sort-button:hover { background: none; color: var(--action); box-shadow: none; transform: none; }
.data-table th.num .sort-button { margin-left: auto; }
.data-table th.sorted { color: var(--action); }
.data-table tr.table-totals td { font-weight: 700; background: #FBF8FD; border-top: 2px solid var(--line); }
.data-table tr.empty-row td { padding: 1rem; color: var(--muted); text-align: center; }
.data-table.compact th, .data-table.compact td { padding: .24rem .5rem; font-size: .86rem; }
.data-table.compact .badge { font-size: .7rem; }
.data-table .select-col { width: 2.2rem; text-align: center; }
.data-table .money-cell { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; }

.table-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin-bottom: .7rem; }
.table-toolbar > div { display: flex; flex-direction: column; gap: .2rem; }
.table-toolbar label { font-size: .8rem; color: var(--bg-header); }
.table-toolbar .toolbar-spacer { flex: 1 1 40px; }
.table-toolbar .selection-count { color: var(--muted); font-size: .85rem; align-self: center; }
.table-toolbar .density-toggle { white-space: nowrap; }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .45rem .7rem; margin-bottom: .6rem; border: 1px solid #F4C89A; background: #FFF7ED; border-radius: 8px; }
.bulk-bar > span { font-weight: 650; color: #7A3A00; }

.table-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-top: .7rem; padding: .45rem .6rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.pager-summary { color: var(--muted); font-size: .82rem; }
.pager-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.pager-controls button { min-width: 34px; padding: .35rem .55rem; }
.pager-controls button.current { background: var(--bg-header); color: #fff; border-color: var(--bg-header); opacity: 1; }
.pager-controls .pager-gap { color: var(--muted); padding: 0 .2rem; }
.pager-size { display: inline-flex; align-items: center; gap: .4rem; margin: 0; font-size: .85rem; color: var(--muted); font-weight: 400; }
.pager-size select { padding: .3rem .4rem; }

.badge { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .74rem; font-weight: 750; line-height: 1.4; white-space: nowrap; }
.badge-ok { background: #E6F4EA; color: #1E6B34; }
.badge-warn { background: #FFF4D6; color: #7A5300; }
.badge-bad { background: #FBE7E6; color: #9B1C17; }
.badge-neutral { background: #EDE7F2; color: var(--bg-header); }

.export-menu { position: relative; display: inline-block; }
.export-menu > summary { list-style: none; cursor: pointer; border: 1px solid var(--action); color: var(--action); background: #fff; border-radius: 6px; padding: .45rem .9rem; font-size: .93rem; font-weight: 600; white-space: nowrap; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu[open] > summary { background: #FFF1E8; }
.export-options { position: absolute; right: 0; z-index: 20; display: grid; gap: .2rem; min-width: 195px; padding: .3rem; margin-top: .25rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(76, 18, 107, 0.14); }
.export-options button { width: 100%; text-align: left; white-space: nowrap; }
.profile-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.profile-heading h3 { margin: 0; }
.learner-profile h4 { color: var(--bg-header); margin-bottom: .6rem; }
.guardian-form { border-top: 1px solid var(--border-light); padding-top: 1rem; margin-top: 1rem; }
details > summary { cursor: pointer; font-weight: 650; color: var(--bg-header); }
details > form { margin-top: 1rem; }
@media print {
  .data-table { max-height: none; overflow: visible; border: 0; }
  .data-table thead th { position: static; box-shadow: none; }
  .table-pager, .table-toolbar, .bulk-bar { display: none !important; }
  body:has(.stock-document) #app *:not(.stock-document):not(.stock-document *):not(:has(.stock-document)) { display: none; }
  body:has(.stock-document) #app :has(.stock-document) { margin: 0; padding: 0; border: 0; box-shadow: none; }
  .stock-document { position: static; border: 0; box-shadow: none; margin: 0; }
  .stock-document table { width: 100%; font-size: 9pt; overflow-wrap: anywhere; }
  .stock-document thead { display: table-header-group; }
  .stock-document tr { break-inside: avoid; }
  .brand-logo { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  nav, .user-bar, .toast, .platform-subnav { display: none; }
  .shell { display: block; }
  .print-brand { display: block; }
  body:has(.exam-report, .fee-document) * { visibility: hidden; }
  body:has(.exam-report) .exam-report, body:has(.exam-report) .exam-report *,
  body:has(.fee-document) .fee-document, body:has(.fee-document) .fee-document * { visibility: visible; }
  body:has(.exam-report, .fee-document) .shell, body:has(.exam-report, .fee-document) main { display: block; overflow: visible; }
  .exam-report, .fee-document { position: absolute; inset: 0; border: 0; box-shadow: none; margin: 0; }
  .exam-report .table-scroll, .fee-document .table-scroll { overflow: visible; }
  body:has(.fee-document) #app *:not(.fee-document):not(.fee-document *):not(:has(.fee-document)) { display: none; }
  body:has(.fee-document) #app :has(.fee-document) { margin: 0; padding: 0; border: 0; box-shadow: none; }
  body:has(.fee-document) .fee-document { position: static; }
  .academic-marksheet table { table-layout: fixed; width: 100%; }
  .academic-marksheet th, .academic-marksheet td { font-size: 8pt; padding: .2rem; overflow-wrap: anywhere; }
  .academic-marksheet tr { break-inside: avoid; }
  .academic-marksheet thead { display: table-header-group; }
  body.report-printing > *:not(#report-print) { display: none !important; }
  body.report-printing #report-print { display: block; }
  #report-print { font-size: 9pt; color: #000; }
  #report-print .report-document-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10mm; border-bottom: 2px solid #6d1b7b; padding-bottom: 4mm; margin-bottom: 5mm; }
  #report-print .report-document-head p { margin: 0 0 1mm; font-size: 8.5pt; }
  #report-print .report-document-name { font-size: 13pt; font-weight: 700; }
  #report-print .report-document-title { text-align: right; }
  #report-print .report-document-title h1 { font-size: 14pt; margin: 0 0 1mm; color: #3b0a48; }
  #report-print .report-document-stamp { white-space: nowrap; color: #444; }
  #report-print .report-document-section { margin-bottom: 5mm; }
  #report-print .report-document-section h2 { font-size: 10.5pt; margin: 0 0 2mm; color: #3b0a48; }
  #report-print table { width: 100%; border-collapse: collapse; font-size: 8pt; }
  #report-print th, #report-print td { border-bottom: 1px solid #bbb; padding: 1.1mm 1.6mm; text-align: left; vertical-align: top; }
  #report-print th { background: #EDE3F5; font-weight: 700; }
  #report-print th.num, #report-print td.num { text-align: right; white-space: nowrap; }
  #report-print thead { display: table-header-group; }
  #report-print tr { break-inside: avoid; }
  #report-print .report-document-foot { margin-top: 6mm; border-top: 1px solid #bbb; padding-top: 2mm; font-size: 7.5pt; color: #444; }
}
.muted { color: var(--muted); }
.narrow { width: 6rem; } .wide { min-width: 22rem; }
.pill { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .78rem; background: #F1E8F6; color: var(--bg-header); }
.pill.bad { background: #f9dedc; color: var(--bad); } .pill.warn { background: #fff1cc; color: var(--warn); }
.toast { position: fixed; right: 1rem; bottom: 1rem; background: var(--brand-dark); color: #fff; padding: .7rem 1rem; border-radius: 8px; max-width: 340px; z-index: 9; }
.toast.bad { background: var(--bad); }
.error { color: var(--bad); margin: .5rem 0; }
.platform-header { min-height: 64px; padding: .8rem 1.5rem; background: var(--bg-header); display: flex; align-items: center; justify-content: space-between; }
.platform-brand { color: #fff; text-decoration: none; font-size: 1.2rem; font-weight: 750; letter-spacing: -.02em; display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.platform-brand .brand-logo { width: 230px; background: #fff; border-radius: 6px; padding: .3rem; }
.platform-brand span { margin-left: .4rem; color: rgba(255, 255, 255, 0.8); font-size: .9rem; font-weight: 500; }
.platform-school-link { color: rgba(255, 255, 255, 0.9); text-decoration: none; font-size: .9rem; }
.platform-main { max-width: 1180px; margin: 0 auto; padding: 2rem 1.4rem; }
.platform-login { margin-top: 8vh; }
.platform-title, .platform-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.platform-title { margin: .5rem 0 1rem; align-items: flex-start; flex-wrap: wrap; }
.platform-title > div:first-child { flex: 1 1 320px; min-width: 0; }
.platform-title h1 { font-size: 1.8rem; }
.platform-title-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.platform-title-actions button { flex-shrink: 0; white-space: nowrap; background: #fff; color: var(--action); border: 1px solid var(--action); }
.platform-title-actions button:hover { background: #FFF1E8; color: var(--action-hover); border-color: var(--action-hover); }
.platform-subnav { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 1rem; padding: .4rem; background: #fff; border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 4px 18px rgba(76, 18, 107, 0.05); }
.platform-subnav a { display: inline-flex; align-items: center; min-height: 36px; padding: .35rem .85rem; border-radius: 999px; color: var(--bg-header); text-decoration: none; font-size: .85rem; font-weight: 650; }
.platform-subnav a:hover, .platform-subnav a:focus-visible { background: #F3EAF9; }
#school-form-card, #institutions-card, #sms-accounts-card, #platform-admins-card { scroll-margin-top: 1rem; }
.platform-eyebrow { color: var(--brand); font-size: .75rem; font-weight: 700; letter-spacing: .14em; margin: 0 0 .3rem; }
.platform-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; margin-top: 1rem; }
.platform-form label { display: flex; flex-direction: column; gap: .25rem; color: var(--bg-header); font-size: .82rem; }
.platform-form input, .platform-form select { width: 100%; min-width: 0; min-height: 40px; color: var(--text); }
.platform-form-heading, .platform-form-note { grid-column: 1 / -1; margin: .35rem 0 0; }
.platform-form-heading { color: var(--bg-header); padding-top: .7rem; border-top: 1px solid var(--border-light); }
.platform-form-note { font-size: .82rem; }
.institution-contact span { display: block; }
dialog { max-width: 560px; width: calc(100% - 2rem); max-height: calc(100dvh - 2rem); overflow: auto; border: 1px solid var(--border-light); border-radius: 12px; padding: 1.5rem; color: var(--text-dark); }
#school-admin-dialog, #sms-dialog { max-width: 1000px; }
dialog::backdrop { background: rgba(40, 8, 59, .45); }
.platform-form-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.platform-form-actions p { margin: 0; font-size: .85rem; }
.platform-admin-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.platform-table-wrap { width: 100%; max-width: 100%; overflow: auto; max-height: 70vh; margin-top: 1rem; overscroll-behavior: contain; }
.platform-table-wrap thead th { position: sticky; top: 0; z-index: 2; background: #F7F2FA; box-shadow: inset 0 -2px 0 var(--border-light); }
.platform-table-wrap table { min-width: 760px; width: 100%; table-layout: fixed; }
.platform-table-wrap .platform-institutions-table { min-width: 1080px; }
.platform-institutions-table col:nth-child(1) { width: 12%; }
.platform-institutions-table col:nth-child(2) { width: 7%; }
.platform-institutions-table col:nth-child(3) { width: 9%; }
.platform-institutions-table col:nth-child(4) { width: 11%; }
.platform-institutions-table col:nth-child(5), .platform-institutions-table col:nth-child(6) { width: 15%; }
.platform-institutions-table col:nth-child(7) { width: 7%; }
.platform-institutions-table col:nth-child(8) { width: 8%; }
.platform-institutions-table col:nth-child(9) { width: 16%; }
.platform-table-wrap .platform-sms-table { min-width: 1040px; }
.platform-sms-table col:nth-child(1) { width: 17%; }
.platform-sms-table col:nth-child(2) { width: 9%; }
.platform-sms-table col:nth-child(3) { width: 9%; }
.platform-sms-table col:nth-child(4) { width: 9%; }
.platform-sms-table col:nth-child(5), .platform-sms-table col:nth-child(6) { width: 8%; }
.platform-sms-table col:nth-child(7) { width: 9%; }
.platform-sms-table col:nth-child(8) { width: 21%; }
.platform-sms-table col:nth-child(9) { width: 10%; }
.platform-table-wrap th, .platform-table-wrap td { padding: .7rem; vertical-align: top; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.platform-table-wrap th.num, .platform-table-wrap td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.platform-table-wrap .institution-name { font-weight: 650; }
.platform-table-wrap .mono { font-family: Consolas, "Courier New", monospace; font-size: .85rem; overflow-wrap: anywhere; }
.platform-table-wrap td.warn-text { color: var(--warn); font-weight: 700; }
.pill.ok { background: #E3F4E8; color: #1E6B34; }
.platform-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; align-items: stretch; }
.platform-actions button { width: 100%; min-width: 0; padding: .4rem .45rem; font-size: .8rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.platform-actions button.platform-action-wide { grid-column: 1 / -1; }
.platform-main .card, .platform-title > div, .platform-section-heading > div { min-width: 0; }
.platform-header, .platform-section-heading, .platform-form-actions { flex-wrap: wrap; }
.platform-main, #school-admin-dialog { overflow-wrap: anywhere; }
.platform-form-actions button { flex-shrink: 0; }
.platform-search, .platform-section-heading input[type="search"] { max-width: 240px; min-height: 38px; align-self: center; }
.platform-section-heading .report-tools { align-items: center; }
#confirm-dialog p { max-width: 52ch; }
.platform-scroll-hint { font-size: .82rem; margin-bottom: 0; }
.platform-message { min-height: 1.4rem; margin: 0 0 .8rem; color: var(--brand-dark); }
.platform-footer { color: var(--muted); font-size: .82rem; padding: 1rem 0 2rem; }
.platform-password-card summary { cursor: pointer; font-weight: 650; }
@media screen {
  body { font-size: 14px; line-height: 1.4; }
  h1, h2, h3 { margin-bottom: .45rem; }
  h4 { margin: .6rem 0 .4rem; }
  p { margin: .4rem 0; }
  main { padding: 1rem 1.2rem; }
  .card { padding: .75rem .9rem; margin-bottom: .7rem; box-shadow: none; }
  .cards { gap: .6rem; margin-bottom: .7rem; }
  .stat { padding: .6rem .8rem; box-shadow: none; }
  .stat b { font-size: 1.3rem; }
  .row { gap: .5rem; margin-bottom: .6rem; }
  .row > div { min-width: 0; max-width: 100%; }
  input, select, button { min-height: 36px; }
  th, td { padding: .35rem .5rem; font-size: .875rem; }
  th { font-size: .75rem; }
  td p { margin: .2rem 0; }
  .shell > nav { padding: .7rem .5rem; }
  .shell > nav a, .shell > nav .nav-group > summary { padding: .4rem .6rem; }
  details > form { margin-top: .6rem; }
  .platform-main { padding: 1.2rem 1rem; }
  .platform-title { gap: .7rem; margin-bottom: .8rem; }
  .platform-title h1 { font-size: 1.5rem; }
  .platform-form { gap: .6rem; margin-top: .6rem; }
  .platform-form-heading { padding-top: .5rem; }
  .platform-table-wrap { margin-top: .6rem; }
  .platform-table-wrap th, .platform-table-wrap td { padding: .5rem; }
  .platform-message:empty { display: none; }
}
@media (max-width: 760px) {
  .platform-form, .platform-admin-form { grid-template-columns: 1fr; }
  .platform-form-actions { align-items: stretch; flex-direction: column; }
  .platform-title { align-items: flex-start; }
  .platform-main { padding: 1.2rem .8rem; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: start; }
  /* The module list collapses into a sticky bar + dropdown, not a wall of links. */
  .shell > nav { position: sticky; top: 0; z-index: 40; height: auto; overflow: visible; flex-direction: row; align-items: center; padding: .4rem .7rem; }
  .shell > nav .nav-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; width: 100%; }
  .shell > nav .logo { padding: 0; line-height: 1; }
  .shell > nav .logo .brand-logo { height: 30px; width: auto; padding: .15rem .3rem; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: .35rem .9rem; border: 1px solid rgba(255, 255, 255, .55); border-radius: 6px; background: transparent; color: #fff; font-size: .9rem; font-weight: 650; }
  .nav-toggle:hover, .nav-toggle[aria-expanded="true"] { background: rgba(255, 255, 255, .14); box-shadow: none; transform: none; }
  .shell > nav .nav-menu { display: none; }
  .shell > nav.nav-open .nav-menu { display: flex; flex-direction: column; gap: .1rem; position: absolute; top: 100%; left: 0; right: 0; max-height: calc(100vh - 3.4rem); max-height: calc(100dvh - 3.4rem); overflow-y: auto; overscroll-behavior: contain; padding: .35rem .7rem .9rem; background: var(--bg-header); border-top: 1px solid rgba(255, 255, 255, .16); box-shadow: 0 18px 32px rgba(23, 5, 34, .45); }
  .shell > nav .nav-menu a, .shell > nav .nav-group > summary, .shell > nav .nav-subgroup > summary { display: flex; align-items: center; min-height: 40px; padding: .5rem .7rem; font-size: .92rem; }
  .shell > nav .nav-subgroup > summary, .shell > nav .nav-subgroup > a { min-height: 38px; font-size: .86rem; }
  .shell > nav a.active, .shell > nav a:hover { border-left-color: var(--color-primary-orange); border-bottom: 0; border-radius: 0 6px 6px 0; }

  /* Identity stays a compact row under the page title instead of covering content. */
  .user-bar { position: static; padding: .4rem .7rem; }
  .top-bar { gap: .5rem; min-height: 40px; }
  .page-title { font-size: .95rem; }
  .who-trigger { min-height: 36px; padding: .15rem .3rem; gap: .35rem; }
  .user-bar .who-avatar { width: 30px; height: 30px; font-size: .72rem; }
  .user-bar .who-name { max-width: 8.5rem; font-size: .8rem; }
  .who-menu { width: min(248px, calc(100vw - 1rem)); }
  .shell > nav .nav-school { margin-top: .15rem; max-width: 12rem; font-size: .66rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  main { padding: .8rem .7rem 2rem; }
  .card { padding: .75rem .7rem; }
  .report-head { gap: .4rem; margin-bottom: .5rem; }
  .fee-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .5rem; }
  .fee-tabs button { flex: none; }

  /* Search spans the row; filters pair up; actions get full-width targets. */
  .table-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; align-items: end; }
  .table-toolbar > :first-child { grid-column: 1 / -1; }
  .table-toolbar > div { min-width: 0; }
  .table-toolbar .toolbar-spacer { display: none; }
  .table-toolbar .selection-count { grid-column: 1 / -1; align-self: center; }
  .table-toolbar .selection-count:empty { display: none; }
  .table-toolbar input, .table-toolbar select { width: 100%; }
  .table-toolbar button, .table-toolbar .export-menu, .table-toolbar .export-menu > summary, .table-toolbar .report-tools { width: 100%; }
  .table-toolbar button, .table-toolbar .export-menu > summary { min-height: 40px; }
  .table-toolbar .export-menu > summary { text-align: center; }
  .table-toolbar form { display: flex; min-width: 0; }
  .table-toolbar form > button { width: 100%; }
  .table-toolbar label { font-size: .75rem; }

  .data-table { max-height: 62vh; -webkit-overflow-scrolling: touch; }
  .data-table th, .data-table td { padding: .45rem .5rem; font-size: .84rem; }
  .data-table.compact th, .data-table.compact td { padding: .3rem .45rem; font-size: .8rem; }
  .data-table .select-col { width: 2rem; }
  .data-table .money-cell { gap: .3rem; }

  /* Two rows: range + rows-per-page, then touch-sized page controls. */
  .table-pager { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .35rem .5rem; margin-top: .55rem; padding: .4rem .55rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
  .pager-summary { grid-column: 1; grid-row: 1; font-size: .78rem; }
  .pager-size { grid-column: 2; grid-row: 1; font-size: .78rem; }
  .pager-size select { min-height: 30px; padding: .15rem .3rem; }
  .pager-controls { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; }
  .pager-controls button { min-width: 38px; min-height: 38px; padding: .3rem .6rem; }
  .pager-gap { padding: 0; }

  .bulk-bar { padding: .4rem .55rem; }
  .bulk-bar button { flex: 1 1 auto; }
  .login { margin: 4vh auto; padding: 1.3rem; }
}

@media (max-width: 480px) {
  /* Small phones: the avatar alone keeps the page title readable. */
  .user-bar .who-name, .user-bar .who-caret { display: none; }
  .who-trigger { padding: .15rem; }
  .page-title { font-size: .9rem; }
}

/* Fees workspace */
.filter-bar { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; }
.fee-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 .9rem; padding-bottom: .6rem; border-bottom: 1px solid var(--line); }
.fee-tabs button { border-radius: 999px; }
.fee-tabs button[aria-pressed="true"] { background: var(--action); color: var(--text-light); }
.fee-tool-panel:empty { display: none; }
.fee-recon .row input:not([type=file]) { min-width: 12rem; }
.fee-recon input[type=file] { padding: .3rem .4rem; }
.fee-recon h4 { margin: 1rem 0 .4rem; }
.form-hint { margin-left: .7rem; font-size: .85rem; }
.fee-recon textarea { margin-bottom: .6rem; }
textarea.mono { font-family: Consolas, "Courier New", monospace; font-size: .9rem; min-height: 4.5rem; }

@media (prefers-reduced-motion: reduce) {
  button, .stat, .stat.skeleton b, .stat.skeleton span { transition: none; animation: none; }
  button:hover, a.stat:hover { transform: none; }
}
#footer { padding: 1.1rem 1.6rem; text-align: center; font-size: .85rem; color: var(--text-light); background: var(--bg-header); border-top: 3px solid var(--color-primary-orange); }
