/* =====================================================================
   Portal design system — Zayed Educational Complex – Suhaila
   Colour scheme taken from the MOE "End of Term 1 Exam Schedules" deck
   (الجداول الزمنية لاختبارات نهاية الفصل الدراسي الأول.pdf, PowerPoint export):
     #89191E  maroon       (main brand: title blocks, tabs, buttons, headings)
     #A35D25  bronze       (secondary accent, table headers)   #E08A4F orange (highlights)
     #F6DCCA  peach        (title bars, panels)                #EADFD3 beige (borders, banding)
     #FCF3ED  cream / #FBF8F5 warm white (backgrounds)         #D1C9C1 warm grey (frames)
     #383B3D  charcoal (text)   #455961 slate (secondary text)   #2E1A0E dark brown   #2E7D5E green (pass)
   (Variable names are historical: --navy = darkest brand tone, --blue = action tone,
    --olive / --lime = secondary accents.)
   ===================================================================== */
:root {
  --navy: #89191E; --navy-2: #731519; --navy-3: #5C1014;
  --blue: #89191E; --blue-2: #6E1418; --sky: #F6DCCA; --sky-2: #FCF3ED;
  --olive: #89191E; --olive-2: #A35D25; --lime: #A35D25; --lime-2: #EBC3A6; --olive-pale: #F6DCCA; --olive-50: #FCF3ED; --band: #F5EBE3;
  --frame: #D1C9C1; --gold: #A35D25; --gold-pale: #F5F0EA; --orange: #E08A4F;
  --ink: #383B3D; --muted: #455961; --line: #EADFD3; --line-2: #F5F0EA;
  --bg: #FBF8F5; --surface: #ffffff;
  --ok: #2E7D5E; --ok-bg: #E2F1EA; --bad: #C0392B; --bad-bg: #FBE4E1; --warn: #8a5a00; --warn-bg: #fff3d6;
  --radius: 12px; --radius-s: 8px;
  --shadow: 0 1px 2px rgba(46, 26, 14, .06), 0 4px 16px rgba(46, 26, 14, .07);
  --shadow-l: 0 10px 40px rgba(46, 26, 14, .22);
  --font: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.55; font-variant-numeric: lining-nums tabular-nums; }
img { max-width: 100%; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--navy); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* ---------- header ---------- */
.app-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.app-header .bar { max-width: 1320px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 16px; }
.app-header .brand { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; }
.app-header .brand img.strip { height: 40px; width: auto; display: block; }
.app-header .brand img.mark { height: 44px; display: none; }
.app-header .spacer { flex: 1; }
.app-header .tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.term-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--olive-50); color: var(--olive); border: 1px solid var(--olive-pale); padding: 5px 12px; border-radius: 999px; font-weight: 800; font-size: 13px; white-space: nowrap; }
.term-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--lime); }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--sky-2); }
.lang-switch button { border: 0; background: none; padding: 6px 12px; font-weight: 700; font-size: 13px; cursor: pointer; color: var(--muted); }
.lang-switch button.on { background: var(--navy); color: #fff; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--navy); background: #fff; }
[dir=rtl] .user-chip { padding: 4px 12px 4px 6px; }
.user-chip .role { background: var(--sky); color: var(--navy); border-radius: 999px; padding: 2px 8px; font-size: 11px; }
.icon-btn { border: 0; background: none; cursor: pointer; width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--navy); }
.icon-btn:hover { background: var(--sky); }
.icon-btn svg { width: 19px; height: 19px; fill: currentColor; }
[dir=rtl] .icon-btn svg.flip { transform: scaleX(-1); }

/* Hero = the slides' pale-lime title bar: dark-olive square tab at the start, olive title, soft corner circles */
.hero-band { background: var(--olive-pale); color: var(--olive); position: relative; overflow: hidden; border-bottom: 1px solid var(--olive-2); }
.hero-band::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 14px; background: var(--olive); }
.hero-band::after { content: ""; position: absolute; width: 150px; height: 150px; border-radius: 50%; background: #fff; inset-inline-end: -60px; top: -70px; opacity: .9; }
.hero-band .in { max-width: 1320px; margin: 0 auto; padding: 20px 34px 22px; display: flex; align-items: center; gap: 20px; position: relative; z-index: 1; }
.hero-band h1 { color: var(--olive); font-size: 26px; font-weight: 800; }
.hero-band p { margin: 4px 0 0; color: var(--olive-2); font-size: 14px; font-weight: 700; }
.hero-band .motto { margin-inline-start: auto; height: 58px; border-radius: 8px; box-shadow: 0 2px 10px rgba(46,26,14,.18); background: #fff; }
.hero-band .deco { position: absolute; inset-inline-end: 340px; top: -6px; width: 110px; opacity: .35; }

/* ---------- layout ---------- */
.page { max-width: 1320px; margin: 0 auto; padding: 20px; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: thin; }
.tabs button { border: 0; background: none; padding: 11px 16px; font-weight: 800; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.tabs button img { width: 22px; height: 22px; }
.tabs button.on { color: var(--navy); border-bottom-color: var(--blue); }
.tabs button:hover { color: var(--navy); }
.tab-panel { display: none; } .tab-panel.on { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
/* Card header = slide section bar: pale lime strip with a dark-olive square tab at the start */
.card-h { padding: 12px 18px; background: var(--olive-50); border-bottom: 1px solid var(--line); border-inline-start: 12px solid var(--olive); border-start-start-radius: var(--radius); border-start-end-radius: var(--radius); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-h h2 { color: var(--olive); }
.card-h h2 { font-size: 17px; font-weight: 800; }
.card-h .sub { color: var(--muted); font-size: 13px; }
.card-h .ill { width: 40px; height: 40px; flex: none; }
.card-b { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.sep { height: 1px; background: var(--line-2); margin: 14px 0; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--blue); }
.kpi.olive::before { background: var(--orange); } .kpi.gold::before { background: var(--gold); } .kpi.navy::before { background: var(--navy); }
.kpi .v { font-size: 26px; font-weight: 800; color: var(--navy); direction: ltr; unicode-bidi: isolate; display: inline-block; }
.kpi .l { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.kpi .bar { height: 6px; background: var(--line-2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.kpi .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--lime)); border-radius: 3px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 800; color: var(--navy); }
.input, select.input, textarea.input { width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-s); padding: 9px 12px; background: #fff; outline: 0; transition: border-color .15s, box-shadow .15s; min-height: 40px; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(137,25,30, .22); }
.input.big { font-size: 20px; letter-spacing: 2px; text-align: center; font-weight: 800; }
.pin-input { letter-spacing: 14px; font-size: 26px; text-align: center; font-weight: 800; direction: ltr; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; margin-bottom: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--blue); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid transparent; border-radius: var(--radius-s); padding: 9px 16px; font-weight: 800; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, transform .05s, box-shadow .15s; min-height: 40px; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; fill: currentColor; }
.btn-primary { background: var(--blue); color: #fff; } .btn-primary:hover { background: var(--blue-2); }
.btn-navy { background: var(--navy); color: #fff; } .btn-navy:hover { background: var(--navy-3); }
.btn-olive { background: var(--olive); color: #fff; } .btn-olive:hover { background: #5C1014; }
.btn-lime { background: var(--lime); color: #ffffff; } .btn-lime:hover { background: #8A4E1F; }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line); } .btn-ghost:hover { background: var(--sky-2); border-color: var(--lime-2); }
.btn-danger { background: #fff; color: var(--bad); border-color: #F2C9C3; } .btn-danger:hover { background: var(--bad-bg); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; min-height: 32px; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; max-height: 70vh; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.data th { position: sticky; top: 0; z-index: 1; background: var(--lime); color: #fff; text-shadow: 0 1px 1px rgba(46,26,14,.35); border-inline-end: 1px solid rgba(255,255,255,.55); text-align: start; padding: 10px 12px; font-weight: 800; white-space: nowrap; font-size: 12.5px; }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tbody tr:nth-child(odd) td { background: var(--band); } table.data tbody tr:nth-child(even) td { background: var(--olive-50); }
table.data td { border-inline-end: 1px solid #fff; }
table.data tbody tr:hover td { background: var(--olive-pale); }
table.data tbody tr.sub td { background: #fff; font-size: 12.5px; }
table.data tr.sub td:first-child { border-inline-start: 3px solid var(--lime); }
table.data tbody tr.group td { background: var(--olive-50); font-weight: 800; color: var(--olive); }
table.data td.c, table.data th.c { text-align: center; }
table.data td[dir=auto] { min-width: 170px; }
table.data .clickable { cursor: pointer; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty img { width: 90px; opacity: .85; display: block; margin: 0 auto 8px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); } .b-bad { background: var(--bad-bg); color: var(--bad); } .b-warn { background: var(--warn-bg); color: var(--warn); }
.b-blue { background: var(--sky); color: var(--navy); } .b-olive { background: var(--olive-50); color: var(--olive); border: 1px solid var(--olive-pale); } .b-gray { background: #F5F0EA; color: #455961; }
.b-gold { background: var(--gold-pale); color: var(--gold); }

/* ---------- pills ---------- */
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pill { border: 1.5px solid var(--line); background: #fff; color: var(--navy); border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: 13px; cursor: pointer; }
.pill.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.pill .n { opacity: .7; margin-inline-start: 4px; }

/* ---------- toasts & modal ---------- */
#toasts { position: fixed; top: 16px; inset-inline-end: 16px; z-index: 9000; display: flex; flex-direction: column; gap: 8px; }
.toast { min-width: 260px; max-width: 380px; background: #fff; border: 1px solid var(--line); border-inline-start: 5px solid var(--blue); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow-l); font-weight: 700; font-size: 14px; animation: tin .25s ease; }
.toast.ok { border-inline-start-color: var(--lime); } .toast.err { border-inline-start-color: var(--bad); } .toast.warn { border-inline-start-color: #f59e0b; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }
.modal-back { position: fixed; inset: 0; background: rgba(46,26,14, .5); z-index: 8000; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-l); width: 100%; max-width: 520px; max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { max-width: 900px; } .modal.xl { max-width: 1100px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; }
.modal-h h3 { font-size: 18px; flex: 1; }
.modal-b { padding: 18px 20px; overflow: auto; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- misc ---------- */
.notice { border-radius: 10px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.notice.info { background: var(--olive-50); border: 1px solid var(--olive-pale); color: var(--olive); }
.notice.warn { background: var(--warn-bg); border: 1px solid #f3dfae; color: #6b4500; }
.notice.err { background: var(--bad-bg); border: 1px solid #F2C9C3; color: var(--bad); }
.notice.ok { background: var(--ok-bg); border: 1px solid #B9DCCB; color: var(--ok); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.demo-ribbon { background: repeating-linear-gradient(135deg, #fff7e0 0 12px, #fff1cc 12px 24px); color: #6b4500; text-align: center; font-size: 12px; font-weight: 800; padding: 4px 10px; border-bottom: 1px solid #f3dfae; }
.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 26px 16px 34px; }
.footer img { height: 34px; opacity: .8; display: block; margin: 0 auto 6px; }
code, .mono { font-family: Consolas, 'Courier New', monospace; font-size: 12.5px; }
.prompt-box { white-space: pre-wrap; background: #2E1A0E; color: #FCF3ED; border-radius: 10px; padding: 14px 16px; font-family: Consolas, 'Courier New', monospace; font-size: 12.5px; line-height: 1.6; max-height: 52vh; overflow: auto; }
.prompt-box.ar { direction: rtl; font-family: 'Tajawal', Tahoma, sans-serif; font-size: 14px; }

@media (max-width: 980px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hero-band .deco { display: none; } }
@media (max-width: 720px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .app-header .bar { padding: 8px 14px; gap: 8px; flex-wrap: wrap; }
  .app-header .brand img.strip { display: none; } .app-header .brand img.mark { display: block; height: 40px; }
  .hero-band .in { flex-direction: column; align-items: flex-start; padding: 18px 16px; }
  .hero-band .motto { margin-inline-start: 0; height: 46px; max-width: 100%; }
  .page { padding: 14px 16px; }
  .user-chip .nm { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media print { .app-header, .tabs, .filters, .btn, .demo-ribbon { display: none !important; } body { background: #fff; } }

/* KaTeX math must always read left-to-right, even inside Arabic (RTL) text */
.katex { direction: ltr; unicode-bidi: isolate; }
