/* =====================================================================
   Rased · راصد — identity (docs/BRAND.md, from Rased_Design_Guide.docx)
   Concept: a clear, ordered school register. Petrol for the brand, turquoise
   only for rules and small details (about 10% of the screen), light paper
   surfaces, dark ink. IBM Plex Sans / Plex Sans Arabic for the interface.
   ===================================================================== */
:root {
  --bg: #F5F8FA;            /* page */
  --panel: #FFFFFF;
  --ink: #172B36;
  --ink-2: #526673;         /* muted */
  --ink-3: #5D717E;
  --line: #E2EAEF;
  --line-2: #CCD9E0;        /* border */
  --brand: #164E63;         /* petrol */
  --brand-2: #1D6680;
  --brand-soft: #E8F1F5;
  --brand-deep: #083344;    /* top bar */
  --accent: #0F766E;        /* turquoise: rules, details — not body text on light */
  --accent-soft: #E6F4F1;
  --accent-line: #99D5CC;
  --warn: #8A5800;          /* pending / warning text */
  --max-bg: #F7FAFB;
  --calc-bg: #F9FBFC;
  --grade-bg: #EFF4F0;
  --input-bg: #FFFFFF;
  --focus: #164E63;
  --ok: #2E6B4F;
  --err: #B3261E;
  --err-bg: #FBEBE9;
  --warn-bg: #FBF4E3;
  --lock-bg: #EDF2F5;
  --A: #2E6B4F; --B: #2B5C84; --C: #8A5800; --D: #B8561B; --E: #B3261E;
  --logo: #07425A;          /* logo petrol, from the artwork */
  --logo-accent: #046F69;
  --radius: 8px;            /* cards */
  --radius-c: 6px;          /* fields and buttons */
  --shadow: none;
  --font: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --f-display: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --f-editorial: 'Spectral', Georgia, 'Times New Roman', serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1820; --panel: #10252F; --ink: #EAF3F7; --ink-2: #B4C8D3; --ink-3: #8FA6B2; --line: #1F3A46; --line-2: #48616E;
    --brand: #67E8F9; --brand-2: #A5F3FC; --brand-soft: #0E3340; --brand-deep: #06232D; --accent: #5EEAD4; --accent-soft: #0E2E2C; --accent-line: #285E5B;
    --logo: #EAF3F7; --logo-accent: #5EEAD4; --warn: #E0B34A; --max-bg: #0E1F28; --calc-bg: #0D1D25; --grade-bg: #10261E; --input-bg: #0A1A22; --focus: #5EEAD4;
    --ok: #6FC596; --err: #FFB4AB; --err-bg: #3A1D1A; --warn-bg: #2E2814; --lock-bg: #132A35;
    --A: #6FC596; --B: #7FB3DE; --C: #E0B34A; --D: #EE9150; --E: #FFB4AB; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1820; --panel: #10252F; --ink: #EAF3F7; --ink-2: #B4C8D3; --ink-3: #8FA6B2; --line: #1F3A46; --line-2: #48616E;
  --brand: #67E8F9; --brand-2: #A5F3FC; --brand-soft: #0E3340; --brand-deep: #06232D; --accent: #5EEAD4; --accent-soft: #0E2E2C; --accent-line: #285E5B;
  --logo: #EAF3F7; --logo-accent: #5EEAD4; --warn: #E0B34A; --max-bg: #0E1F28; --calc-bg: #0D1D25; --grade-bg: #10261E; --input-bg: #0A1A22; --focus: #5EEAD4;
  --ok: #6FC596; --err: #FFB4AB; --err-bg: #3A1D1A; --warn-bg: #2E2814; --lock-bg: #132A35;
  --A: #6FC596; --B: #7FB3DE; --C: #E0B34A; --D: #EE9150; --E: #FFB4AB; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.45; }
body { min-height: 100vh; }
a { color: var(--brand-2); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--ink-3); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }
.boot { padding: 40px; color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- layout */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 56px; background: var(--brand); color: #fff; }
:root[data-theme="dark"] .topbar, :root:not([data-theme="light"]) .topbar { color: #fff; }
.topbar .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; text-decoration: none; white-space: nowrap; }
.topbar .logo span.mark { width: 28px; height: 28px; border-radius: 7px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-size: 15px; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a { color: rgba(255,255,255,.85); text-decoration: none; padding: 7px 12px; border-radius: 8px; white-space: nowrap; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.topbar .right { display: flex; align-items: center; gap: 8px; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.3); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topbar { background: #12333d; } }
:root[data-theme="dark"] .topbar { background: #12333d; }
.user-chip { font-size: 12px; opacity: .9; text-align: end; line-height: 1.2; }
.page { padding: 22px 24px 60px; max-width: 1500px; margin: 0 auto; }
.page.wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--ink-3); margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel.pad { padding: 16px 18px; }
.panel h2 + *, .panel h3 + * { margin-top: 10px; }
.stack > * + * { margin-top: 14px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--brand-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #0f1719; } }
:root[data-theme="dark"] .btn.primary { color: #0f1719; }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn-ghost { background: transparent; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 6px; color: var(--ink-3); }
.icon-btn:hover { background: var(--brand-soft); color: var(--ink); }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=tel], input[type=date], input:not([type]), select, textarea {
  border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; background: var(--input-bg); min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
label.field > span { font-weight: 600; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button.on { background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button.on { color: #0f1719; } }
:root[data-theme="dark"] .seg button.on { color: #0f1719; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.tabs .sep { width: 1px; background: var(--line); margin: 8px 6px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-weight: 600; white-space: nowrap; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.lock { background: var(--lock-bg); color: var(--ink-2); }
.letter { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 5px; border-radius: 6px; font-weight: 700; font-size: 12px; color: #fff; }
.letter.A { background: var(--A); } .letter.B { background: var(--B); } .letter.C { background: var(--C); } .letter.D { background: var(--D); } .letter.E { background: var(--E); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .letter { color: #0f1719; } }
:root[data-theme="dark"] .letter { color: #0f1719; }
.progress { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand-2); border-radius: 99px; }
.notice { padding: 10px 14px; border-radius: 9px; background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.notice.err { background: var(--err-bg); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.notice.info { background: var(--brand-soft); border-color: transparent; }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi b { font-size: 22px; font-weight: 700; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }

/* ---------------------------------------------------------------- course cards */
.course-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; transition: border-color .15s; }
.course-card:hover { border-color: var(--brand-2); }
.course-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.course-card .subject { font-size: 16px; font-weight: 650; }
.course-card .meta { color: var(--ink-3); font-size: 12px; }
.course-card .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.course-card .stats div span { display: block; font-size: 11px; color: var(--ink-3); }
.course-card .stats div b { font-size: 17px; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); max-width: 100%; }
table.t { border-collapse: separate; border-spacing: 0; width: 100%; }
table.t th, table.t td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: start; }
table.t th { background: var(--max-bg); font-size: 12px; color: var(--ink-2); font-weight: 600; position: sticky; top: 0; z-index: 2; }
table.t tbody tr:hover td { background: color-mix(in srgb, var(--brand-soft) 50%, transparent); }
table.t td.c, table.t th.c { text-align: center; }
table.t tfoot td { background: var(--max-bg); font-weight: 600; }

/* ---------------------------------------------------------------- marks grid */
.grid-wrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.g { border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.g th, table.g td { border-inline-end: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; text-align: center; white-space: nowrap; }
table.g thead th { position: sticky; z-index: 3; background: var(--max-bg); font-weight: 600; color: var(--ink-2); padding: 5px 6px; font-size: 11.5px; }
table.g thead tr:nth-child(1) th { top: 0; height: 28px; }
table.g thead tr:nth-child(2) th { top: 28px; height: 28px; }
table.g thead tr:nth-child(3) th { top: 56px; height: 44px; white-space: normal; min-width: 54px; max-width: 120px; line-height: 1.2; }
table.g thead tr:nth-child(4) th { top: 100px; height: 26px; background: var(--brand-soft); color: var(--brand); }
table.g th.term { background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) table.g th.term { color: #0f1719; } }
:root[data-theme="dark"] table.g th.term { color: #0f1719; }
table.g th.win { background: var(--brand-soft); color: var(--brand); }
table.g th.calc, table.g td.calc { background: var(--calc-bg); }
table.g th.tot { background: color-mix(in srgb, var(--warn) 16%, var(--panel)); color: var(--ink); }
table.g td.calc { padding: 0 8px; color: var(--ink-2); min-width: 56px; font-variant-numeric: tabular-nums; }
table.g td.calc.pct { font-weight: 600; color: var(--ink); }
table.g .sticky { position: sticky; inset-inline-start: 0; z-index: 2; background: var(--panel); text-align: start; }
table.g thead .sticky { z-index: 4; background: var(--max-bg); }
table.g .sticky.no { inset-inline-start: 0; width: 36px; min-width: 36px; text-align: center; color: var(--ink-3); }
table.g .sticky.name { inset-inline-start: 36px; min-width: 210px; max-width: 260px; padding: 0 10px; overflow: hidden; text-overflow: ellipsis; box-shadow: inset -1px 0 0 var(--line-2); }
[dir=rtl] table.g .sticky.name { box-shadow: inset 1px 0 0 var(--line-2); }
table.g td.cell { width: 54px; min-width: 54px; height: 32px; }
table.g td.cell input { width: 100%; height: 32px; border: 0; border-radius: 0; text-align: center; background: transparent; padding: 0 2px; font-variant-numeric: tabular-nums; }
table.g td.cell input:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--input-bg); }
table.g td.cell.pending input { background: color-mix(in srgb, var(--warn) 12%, transparent); }
table.g td.cell.error input { background: var(--err-bg); color: var(--err); font-weight: 700; }
table.g td.cell.ab input { color: var(--D); font-weight: 600; }
table.g td.cell.ex input { color: var(--ink-3); font-style: italic; }
table.g td.cell.locked input { background: var(--lock-bg); color: var(--ink-3); cursor: not-allowed; }
table.g tfoot td { background: var(--max-bg); font-weight: 600; padding: 5px 6px; font-size: 12px; position: sticky; bottom: 0; z-index: 1; }
table.g tfoot tr:first-child td { bottom: 28px; }
table.g tfoot td.sticky { z-index: 3; }
table.g tbody tr:hover td { background-color: color-mix(in srgb, var(--brand-soft) 45%, var(--panel)); }
table.g tbody tr:hover td.sticky { background: color-mix(in srgb, var(--brand-soft) 45%, var(--panel)); }
.col-menu { font-size: 11px; color: var(--ink-3); cursor: pointer; border: 0; background: none; padding: 0 2px; }
.grid-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.save-state { font-size: 12px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.save-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.save-state.busy i { background: var(--warn); }
.save-state.bad i { background: var(--err); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); }
.legend kbd { font-family: inherit; font-size: 11px; border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; background: var(--panel); color: var(--ink-2); }

/* ---------------------------------------------------------------- report tables */
table.r { border-collapse: separate; border-spacing: 0; font-size: 13px; width: max-content; min-width: 100%; }
table.r th, table.r td { border-bottom: 1px solid var(--line); border-inline-end: 1px solid var(--line); padding: 6px 9px; text-align: center; white-space: nowrap; }
table.r thead th { background: var(--max-bg); font-size: 11.5px; color: var(--ink-2); position: sticky; top: 0; z-index: 2; }
table.r thead tr:nth-child(2) th { top: 31px; }
table.r thead th.grp { background: var(--brand-soft); color: var(--brand); }
table.r thead th.fin { background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) table.r thead th.fin { color: #0f1719; } }
:root[data-theme="dark"] table.r thead th.fin { color: #0f1719; }
table.r td.name, table.r th.name { text-align: start; position: sticky; inset-inline-start: 0; background: var(--panel); z-index: 1; min-width: 200px; }
table.r thead th.name { z-index: 3; background: var(--max-bg); }
table.r td.fin { background: var(--grade-bg); font-weight: 700; }
table.r td.w { color: var(--ink-3); }
table.r tfoot td { background: var(--max-bg); font-weight: 600; }
table.r tfoot td.name { background: var(--max-bg); }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 34px 1fr 64px; gap: 8px; align-items: center; font-size: 12px; }
.bar { height: 14px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; }
.stackbar { display: flex; height: 16px; border-radius: 5px; overflow: hidden; background: var(--line); }
.stackbar i { display: block; height: 100%; }
.cmp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.cmp-card { padding: 14px; cursor: pointer; text-align: start; }
.cmp-card.on { outline: 2px solid var(--brand-2); }
.cmp-card .nums { display: flex; gap: 14px; font-size: 12px; margin: 8px 0; }
.up { color: var(--A); } .down { color: var(--E); } .same { color: var(--ink-3); }

/* ---------------------------------------------------------------- setup */
.setup-cat { padding: 0; overflow: hidden; }
.setup-cat > header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--max-bg); }
.setup-cat .items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.setup-cat .term-col { padding: 10px 16px 14px; }
.setup-cat .term-col + .term-col { border-inline-start: 1px solid var(--line); }
.item-row { display: grid; grid-template-columns: 1fr 64px 26px; gap: 6px; align-items: center; padding: 3px 0; }
.item-row input { padding: 4px 8px; font-size: 13px; }
.item-row .grp { grid-column: 1 / -1; font-size: 11px; color: var(--ink-3); margin-top: 6px; }
.half-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--brand); margin: 8px 0 4px; }
table.weights input { width: 70px; text-align: center; padding: 4px 6px; }
@media (max-width: 800px) { .setup-cat .items { grid-template-columns: 1fr; } .setup-cat .term-col + .term-col { border-inline-start: 0; border-top: 1px solid var(--line); } }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 100%); }
.login .panel { width: min(400px, 100%); padding: 28px; }
.login h1 { margin-bottom: 4px; }
.login form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }

/* ---------------------------------------------------------------- modal & toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 25, 30, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.wide { width: min(900px, 100%); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
#toasts { position: fixed; bottom: 18px; inset-inline-end: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow); max-width: 420px; font-size: 13px; }
.toast.err { background: var(--err); color: #fff; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.secret { font-family: ui-monospace, Menlo, monospace; background: var(--max-bg); padding: 2px 6px; border-radius: 5px; user-select: all; }

/* ---------------------------------------------------------------- print */
.print-head { display: none; }
@media print {
  .topbar, .tabs, .grid-tools, .no-print, #toasts { display: none !important; }
  .page { padding: 0; max-width: none; }
  .print-head { display: block; margin-bottom: 10px; }
  .table-wrap, .grid-wrap { overflow: visible; max-height: none; border: 0; }
  table.r thead th, table.r td.name { position: static; }
  body { background: #fff; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .page { padding: 16px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .user-chip { display: none; }
}

/* ---------------------------------------------------------------- year selector & banners */
.year-select { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; padding: 5px 8px; font-size: 13px; }
.year-select option { color: #17282e; }
.banners { display: flex; flex-direction: column; }
.banner { padding: 8px max(16px, env(safe-area-inset-left, 0px)); background: var(--brand-soft); color: var(--brand); font-size: 13px; text-align: center; }
.banner.warn { background: var(--warn-bg); color: var(--ink); }
.banner.err { background: var(--err-bg); color: var(--err); font-weight: 600; }
.banner .btn { margin-inline-start: 8px; }

/* ---------------------------------------------------------------- platform landing */
.landing { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 480px); gap: 40px; align-items: start; padding-block: 24px; }
@media (max-width: 900px) { .landing { grid-template-columns: 1fr; gap: 24px; } }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-2); }
h1.hero { font-size: clamp(28px, 4vw, 42px); line-height: 1.12; letter-spacing: -0.02em; text-wrap: balance; }
.lede { font-size: 17px; color: var(--ink-2); max-width: 60ch; }
.feature-list { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.feature-list li { padding-inline-start: 26px; position: relative; color: var(--ink-2); max-width: 60ch; }
.feature-list li::before { content: '✓'; position: absolute; inset-inline-start: 0; color: var(--A); font-weight: 700; }

/* =====================================================================
   Rased identity — component layer (overrides the base rules above)
   ===================================================================== */
body { font-feature-settings: 'tnum' 0; -webkit-font-smoothing: antialiased; }
.num, table.g td, table.r td, table.t td.num, .kpi b { font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; letter-spacing: -0.005em; text-wrap: balance; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.icon { flex: none; vertical-align: -0.2em; }
.boot { font-size: 18px; font-weight: 600; color: var(--brand); }

/* top bar: deep petrol, closed by a turquoise hairline */
.topbar { background: var(--brand-deep); border-bottom: 2px solid var(--accent-line); height: 58px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topbar { background: var(--brand-deep); border-bottom-color: var(--accent-line); } }
:root[data-theme="dark"] .topbar { background: var(--brand-deep); }
.topbar nav a { border-radius: var(--radius-c); font-size: 13.5px; }
.topbar nav a.active { background: transparent; color: #fff; box-shadow: inset 0 -2px 0 #5EEAD4; border-radius: 0; }
.topbar nav a:hover { background: rgba(255, 255, 255, .08); }
.topbar .btn-ghost { border-color: rgba(153, 213, 204, .45); }
.year-select { border-color: rgba(153, 213, 204, .45); background: rgba(0, 0, 0, .15); }

/* the logo (inline SVG from public/js/logo.js): petrol with a turquoise entry; white on the top bar and in dark mode */
.lockup { display: inline-flex; align-items: center; color: inherit; text-decoration: none; line-height: 0; }
.lockup svg { display: block; height: 48px; width: auto; }
.lockup.compact svg { height: 40px; }
.lockup .lp { fill: var(--logo); }
.lockup .lt { fill: var(--logo-accent); }
.topbar .logo { gap: 0; }
.topbar .lockup { --logo: #FFFFFF; --logo-accent: #5EEAD4; }

/* page headings sit on a hairline */
.page-head { padding-bottom: 14px; border-bottom: 1px solid var(--line-2); margin-bottom: 20px; }
.page-head .sub { font-size: 13px; }

/* surfaces: flat, thin borders; shadows only for floating layers */
.panel { border-radius: var(--radius); box-shadow: none; }
.table-wrap, .grid-wrap { border-radius: var(--radius); }
.btn { border-radius: var(--radius-c); font-weight: 500; }
.btn.primary { background: var(--brand); border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #06232D; } }
:root[data-theme="dark"] .btn.primary { color: #06232D; }
.btn:hover { border-color: var(--brand); }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.seg { border-radius: var(--radius-c); }
.seg button.on { background: var(--brand); }
.tabs a.on { color: var(--brand); border-color: var(--accent); }
.badge { border-radius: 4px; font-weight: 600; letter-spacing: .01em; }
.letter { border-radius: 4px; font-weight: 600; font-size: 13px; }
.kpi b { font-weight: 600; font-size: 26px; }
.course-card .subject { font-size: 17px; font-weight: 600; }
.progress > i { background: var(--brand); }

/* tables read like a register: small headers over a turquoise hairline */
table.t th, table.r thead th, table.g thead th { text-transform: uppercase; letter-spacing: .05em; font-size: 10.5px; }
[dir="rtl"] table.t th, [dir="rtl"] table.r thead th, [dir="rtl"] table.g thead th { text-transform: none; letter-spacing: 0; font-size: 12px; }
table.t thead th { border-bottom: 1px solid var(--accent-line); }
table.g th.term { background: var(--brand); }
table.g th.win, table.r thead th.grp { background: var(--brand-soft); color: var(--brand); }
table.g th.tot { background: var(--accent-soft); }
table.r thead th.fin { background: var(--brand); }
table.g td.cell input:focus { outline-color: var(--focus); }

/* sign-in: a plain card with a petrol top edge */
.login { background: var(--bg); }
.login .panel { border: 1px solid var(--line-2); border-top: 3px solid var(--brand); padding: 34px 34px 30px; }
.login .panel .lockup svg { height: 60px; }
.login-school { font-size: 17px; font-weight: 500; color: var(--ink-2); margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

/* banners */
.banner { background: var(--accent-soft); color: var(--ink); border-bottom: 1px solid var(--accent-line); }

/* platform landing */
.eyebrow { color: var(--accent); }
h1.hero { font-weight: 600; font-size: clamp(30px, 4.2vw, 44px); }
[lang="en"] h1.hero, [dir="ltr"] h1.hero { font-family: var(--f-editorial); }
.report { border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel); }
.report header { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 16px; border-bottom: 1px solid var(--accent-line); }
.report header b { font-size: 16px; font-weight: 600; }
.report header span { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.report dl { margin: 0; display: grid; grid-template-columns: 150px minmax(0, 1fr); }
.report dt, .report dd { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.report dt { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--brand); padding-top: 14px; }
.report dd { color: var(--ink-2); }
.report dl > :nth-last-child(-n + 2) { border-bottom: 0; }
[dir="rtl"] .report dt { text-transform: none; letter-spacing: 0; font-size: 13px; }
@media (max-width: 560px) { .report dl { grid-template-columns: 1fr; } .report dt { border-bottom: 0; padding-bottom: 0; } }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=tel], input[type=date], input:not([type]), select, textarea { border-radius: var(--radius-c); }
.login .panel h1 { font-size: 22px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* =====================================================================
   Rased design guide — sizes, states and new components (docs/BRAND.md)
   Type: interface 16px, dense tables 14px, secondary 14px, page title 28px.
   Controls 44px tall; 4px spacing unit; radius 6 (controls) / 8 (cards).
   ===================================================================== */
html, body { font-size: 16px; line-height: 1.5; }
h1 { font-size: 28px; } h2 { font-size: 22px; } h3 { font-size: 17px; }
.small { font-size: 14px; }
.page { padding: 28px 32px 64px; }
.stack-tight > * + * { margin-top: 8px; }
.err-text { color: var(--err); }

.btn { min-height: 44px; padding: 0 16px; gap: 8px; font-size: 15px; transition: background-color .15s, border-color .15s; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.topbar .btn.small, .banner .btn.small { min-height: 34px; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=tel], input[type=date], input:not([type]), select, textarea { min-height: 44px; padding: 8px 12px; font-size: 15px; }
textarea { min-height: 88px; resize: vertical; width: 100%; }
table.g td.cell input, .item-row input, table.weights input, .year-select { min-height: 0; }
.item-row input { min-height: 36px; }
label.field { font-size: 14px; gap: 6px; }
.seg button { min-height: 40px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px; }
.icon-btn { min-width: 32px; min-height: 32px; display: inline-grid; place-items: center; }
.tabs a { padding: 12px 16px; }
.badge { font-size: 12px; padding: 3px 9px; }
table.t, table.r { font-size: 14px; }
table.t th { font-size: 12px; }
table.t th, table.t td { padding: 10px 12px; }
table.g { font-size: 14px; }
table.g td.cell { width: 58px; min-width: 58px; height: 36px; }
table.g td.cell input { height: 36px; font-size: 14px; }
.legend { font-size: 13px; }
.save-state { font-size: 14px; }
.course-card .meta, .course-card .stats div span { font-size: 13px; }
.notice { border-radius: 8px; display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.notice > .icon { margin-top: 3px; }
.notice > span { flex: 1; min-width: 220px; }
.modal { border-radius: 8px; box-shadow: 0 12px 32px rgba(8, 51, 68, .22); }
.modal header h2 { font-size: 20px; }
@media (max-width: 767px) { .page { padding: 16px 16px 48px; } h1 { font-size: 24px; } }

/* top bar context: school and term stay visible (with the year selector) */
.topbar .context { display: flex; flex-direction: column; line-height: 1.2; font-size: 12.5px; color: rgba(255, 255, 255, .85); text-align: end; max-width: 220px; }
.topbar .context .ctx-school { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1200px) { .topbar .context .ctx-school { display: none; } }

/* toasts: confirmations fade, errors stay with a close button */
.toast { display: flex; align-items: center; gap: 10px; font-size: 14px; border-radius: 8px; padding: 10px 12px 10px 14px; box-shadow: 0 8px 24px rgba(8, 51, 68, .2); }
.toast .icon-btn { color: inherit; min-width: 28px; min-height: 28px; }
.toast .icon-btn:hover { background: rgba(255, 255, 255, .15); color: inherit; }

/* review workflow chips */
.wf { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 4px; white-space: nowrap; border: 1px solid transparent; }
.wf-draft { background: var(--brand-soft); color: var(--brand); }
.wf-returned { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.wf-review { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.wf-approved { color: var(--ok); border-color: currentColor; background: var(--panel); }
.wf-locked { color: var(--ink-2); border-color: var(--line-2); background: var(--lock-bg); }
.wf-strip { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.wf-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--panel); border-radius: 6px; padding: 4px 6px 4px 9px; cursor: pointer; color: var(--ink-2); font-size: 13px; min-height: 36px; }
.wf-chip:hover { border-color: var(--brand); }
.wf-chip .k { font-weight: 600; font-variant-numeric: tabular-nums; }
.wf-row { display: flex; gap: 10px; flex-wrap: wrap; }
.wf-item { display: inline-flex; align-items: center; gap: 6px; }

/* dashboard */
.kpi-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 28px; }
.kpi-card { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; text-align: start; cursor: pointer; color: var(--ink); font: inherit; }
.kpi-card .label { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.kpi-card b { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-card:hover { border-color: var(--brand); }
.kpi-card.on { border-color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }
.section-head { margin-bottom: 12px; }
.panel.empty { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* mark entry: counts, read-only reasons, messages beside a cell, conflicts */
.grid-tools .count { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.notice.ro { background: var(--lock-bg); border-color: var(--line-2); }
table.g td.cell, .sv-cell { position: relative; }
table.g td.cell.na input, .sv-cell.na input { color: var(--ink-3); }
table.g td.cell.conflict input, .sv-cell.conflict input { background: var(--warn-bg); color: var(--warn); font-weight: 700; box-shadow: inset 0 0 0 2px var(--warn); }
table.g td.cell.error input { box-shadow: inset 0 0 0 2px var(--err); }
.cell-msg { position: absolute; top: calc(100% + 2px); inset-inline-start: -1px; z-index: 6; width: max-content; max-width: 280px; white-space: normal; text-align: start;
  background: var(--panel); color: var(--ink); border: 1px solid var(--err); border-radius: 6px; padding: 8px 10px; font-size: 13px; line-height: 1.4; box-shadow: 0 8px 20px rgba(8, 51, 68, .18); display: grid; gap: 8px; }
.conflict .cell-msg { border-color: var(--warn); }
.cell-msg .cell-actions { display: flex; gap: 6px; flex-wrap: wrap; }
table.g tbody tr:last-child .cell-msg, table.g tbody tr:nth-last-child(2) .cell-msg { top: auto; bottom: calc(100% + 2px); }

/* phones: one student at a time */
.sv-wrap { max-height: none; border: 0; background: transparent; overflow: visible; }
.sv { padding: 16px; display: grid; gap: 16px; max-width: 640px; }
.sv-nav { display: flex; gap: 8px; align-items: flex-end; }
.sv-nav select { width: 100%; }
.sv-totals { display: flex; gap: 20px; flex-wrap: wrap; padding: 12px 14px; background: var(--max-bg); border-radius: 6px; }
.sv-totals > div { display: flex; flex-direction: column; }
.sv-totals b { font-size: 20px; font-weight: 600; }
.sv-list { display: grid; }
.sv-head { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); padding: 12px 0 4px; border-bottom: 1px solid var(--accent-line); }
[dir="rtl"] .sv-head { text-transform: none; letter-spacing: 0; font-size: 13px; }
.sv-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); min-height: 60px; }
.sv-cell { width: 96px; flex: none; }
.sv-cell input { width: 100%; text-align: center; font-size: 17px; font-variant-numeric: tabular-nums; }
.sv-cell.locked input { background: var(--lock-bg); color: var(--ink-3); }
.sv-cell.error input { border-color: var(--err); color: var(--err); }
.sv-cell.pending input { background: color-mix(in srgb, var(--warn) 10%, var(--input-bg)); }
.sv-cell .cell-msg { inset-inline-start: auto; inset-inline-end: 0; }

/* settings */
.logo-preview { height: 56px; width: auto; max-width: 200px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; padding: 6px; background: #fff; }
#school-logo { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
label.btn:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }

/* printed reports: A4 portrait, wide grids landscape; header with the school's identity, page numbers, rules in the footer */
.print-foot { display: none; }
@page { size: A4 portrait; margin: 14mm 12mm 16mm; @bottom-right { content: counter(page) " / " counter(pages); font-size: 9pt; color: #526673; } }
@page wide { size: A4 landscape; margin: 12mm 10mm 14mm; @bottom-right { content: counter(page) " / " counter(pages); font-size: 9pt; color: #526673; } }
@media print {
  html, body { font-size: 11pt; background: #fff; color: #000; }
  main.page.wide { page: wide; }
  .print-head { display: flex !important; align-items: center; gap: 14px; padding-bottom: 8px; margin-bottom: 12px; border-bottom: 1.5pt solid #164E63; }
  .print-head .school-logo { height: 48px; width: auto; }
  .print-head .ph-school { font-size: 14pt; font-weight: 600; }
  .print-head .ph-title { font-size: 12pt; }
  .print-head .ph-meta, .print-head .ph-issued { font-size: 9.5pt; color: #333; }
  .print-foot { display: flex !important; justify-content: space-between; gap: 16px; margin-top: 14px; padding-top: 6px; border-top: 0.75pt solid #99D5CC; font-size: 8.5pt; color: #333; }
  .print-foot .ph-brand { color: #526673; white-space: nowrap; }
  .page-head, .wf-strip, .notice.ro { display: none !important; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  table.g thead th, table.g .sticky, table.g tfoot td, table.t th { position: static !important; }
  table.g td.cell input { color: #000; }
  .cell-msg { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* top bar: navigation and account controls become a drawer below 1200px (the guide's desktop breakpoint) */
.topbar .menu { display: contents; }
.menu-btn { display: none; color: #fff; }
.menu-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.row.nowrap { flex-wrap: nowrap; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.kpi b { font-size: 22px; line-height: 1.25; }
@media (max-width: 1199px) {
  .topbar { gap: 8px; }
  .menu-btn { display: inline-grid; }
  .topbar .menu { display: none; position: absolute; top: 100%; inset-inline: 0; flex-direction: column; gap: 12px; padding: 10px max(16px, env(safe-area-inset-left, 0px)) 16px;
    background: var(--brand-deep); border-bottom: 2px solid var(--accent-line); box-shadow: 0 10px 24px rgba(8, 51, 68, .25); max-height: calc(100vh - 60px); overflow: auto; }
  .topbar.nav-open .menu { display: flex; }
  .topbar nav { flex-direction: column; gap: 2px; overflow: visible; }
  .topbar nav a { padding: 12px 14px; border-radius: 6px; }
  .topbar nav a.active { box-shadow: inset 3px 0 0 #5EEAD4; background: rgba(255, 255, 255, .06); }
  [dir="rtl"] .topbar nav a.active { box-shadow: inset -3px 0 0 #5EEAD4; }
  .topbar .right { flex-wrap: wrap; justify-content: flex-start; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .15); }
  .topbar .context { text-align: start; max-width: none; }
  .topbar .context .ctx-school { display: inline; }
  .user-chip { display: block; text-align: start; }
  .topbar .btn.small { min-height: 40px; }
}
@media (max-width: 767px) {
  .topbar .lockup.compact svg { height: 34px; }
  .legend > span:first-child { display: none; }
}
