/* School marks system — look and feel from stitch-design/DESIGN.md (navy + academic gold, Merriweather/Inter, Tajawal for Arabic). */
:root {
  --primary: #002046;
  --primary-2: #1b365d;
  --gold: #775a19;
  --gold-soft: #fed488;
  --gold-pale: #ffdea5;
  --gold-line: #e9c176;
  --surface: #f9f9ff;
  --surface-low: #f0f3ff;
  --surface-mid: #eaeefb;
  --surface-high: #e4e8f5;
  --surface-top: #dee2f0;
  --card: #ffffff;
  --text: #171c25;
  --muted: #44474e;
  --outline: #74777f;
  --line: #c4c6cf;
  --hair: #e2e8f0;
  --danger: #ba1a1a;
  --danger-bg: #ffdad6;
  --ok: #137333;
  --ok-bg: #e6f4ea;
  --warn: #b7791f;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow: 0 1px 3px rgba(15, 37, 55, .06), 0 4px 12px rgba(15, 37, 55, .04);
  --font: 'Inter', 'Tajawal', Tahoma, sans-serif;
  --font-head: 'Merriweather', 'Amiri', 'Tajawal', serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.6; background: var(--surface); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--primary-2); }
h1, h2, h3 { font-family: var(--font-head); color: var(--primary); margin: 0; line-height: 1.35; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
.en { font-family: 'Merriweather', serif; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.icon { font-family: 'Material Symbols Outlined'; font-weight: normal; font-style: normal; font-size: 20px; line-height: 1; display: inline-block; vertical-align: middle; -webkit-font-smoothing: antialiased; }
.icon.sm { font-size: 16px; }

/* ---------- top bars ---------- */
.topbar { background: var(--primary); color: #dee2f0; font-size: 12px; padding: 6px 40px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar .term { background: var(--primary-2); color: var(--gold-pale); padding: 1px 10px; border-radius: var(--radius); font-weight: 600; }
.topbar .accent { color: var(--gold-pale); font-weight: 600; }
.brandbar { background: var(--card); box-shadow: 0 1px 8px rgba(0, 0, 0, .04); }
.brandbar .inner { max-width: 1280px; margin: 0 auto; padding: 14px 40px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand .mark { width: 44px; height: 44px; border-radius: var(--radius); background: var(--primary-2); color: var(--gold-pale); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.brand .mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand .name { font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.brand .sub { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.usercard { display: flex; align-items: center; gap: 10px; background: var(--surface-low); padding: 6px 12px; border-radius: var(--radius); }
.usercard .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-2); color: var(--gold-pale); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.usercard .who { font-weight: 600; color: var(--primary); font-size: 13px; }
.role { background: var(--gold-soft); color: #785a1a; padding: 0 6px; border-radius: var(--radius); font-size: 11px; font-weight: 600; }
.iconbtn { background: none; border: 0; padding: 8px; border-radius: var(--radius); color: var(--muted); cursor: pointer; display: inline-flex; }
.iconbtn:hover { background: var(--surface-high); color: var(--text); }
.tabsbar { background: var(--surface-low); }
.tabsbar nav { max-width: 1280px; margin: 0 auto; padding: 0 40px; display: flex; gap: 2px; overflow-x: auto; }
.tabsbar a { padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap; border-radius: var(--radius) var(--radius) 0 0; }
.tabsbar a:hover { background: var(--surface-high); color: var(--text); }
.tabsbar a.active { background: var(--primary); color: #fff; }

main.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 40px 48px; flex: 1; }
main.page.narrow { max-width: 900px; }
footer.site { background: var(--primary); color: #dee2f0; font-size: 12px; padding: 18px 40px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
footer.site strong { color: #fff; font-family: var(--font-head); }

/* ---------- building blocks ---------- */
.card { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px 24px; margin-bottom: 20px; }
.card.trim { padding-top: 0; overflow: hidden; }
.trimline { height: 6px; margin: 0 -24px 18px; background: linear-gradient(to left, var(--gold) 0 33%, var(--primary) 33%); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.ribbon { display: flex; align-items: center; gap: 8px; color: var(--gold); font-weight: 600; font-size: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 20px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 24px; }
.grid.two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 960px) { .grid.two { grid-template-columns: 1fr; } }
.stat { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat .top { display: flex; justify-content: space-between; align-items: center; }
.stat .top .icon { background: var(--surface-mid); color: var(--primary); width: 32px; height: 32px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.stat .value { font-family: var(--font-head); font-size: 36px; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat .value small { font-family: var(--font); font-size: 13px; font-weight: 400; color: var(--muted); }
.stat .foot { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); border: 1px solid transparent; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; background: var(--primary); color: #fff; white-space: nowrap; }
.btn:hover { background: #0c2334; }
.btn:focus-visible, .input:focus-visible, select:focus-visible { outline: 2px solid rgba(197, 160, 89, .5); outline-offset: 1px; }
.btn.light { background: var(--surface-high); color: var(--primary); }
.btn.light:hover { background: var(--surface-top); }
.btn.outline { background: transparent; color: var(--primary); border-color: var(--gold-line); }
.btn.outline:hover { background: rgba(197, 160, 89, .08); }
.btn.green { background: #1d6b3f; }
.btn.green:hover { background: #155230; }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.btn.sm { padding: 5px 12px; font-size: 12px; }
.btn.block { width: 100%; padding: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--radius); font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--gold-soft); color: #785a1a; }
.badge.lock { background: var(--surface-low); color: var(--primary); }
.badge.danger { background: var(--danger-bg); color: #93000a; }
.badge.plain { background: var(--surface-high); color: var(--text); }
.chip { display: inline-block; padding: 1px 8px; border-radius: var(--radius); background: var(--surface-mid); color: var(--primary); font-size: 11px; font-weight: 700; margin: 1px; }

.bar { height: 8px; background: var(--surface-top); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.bar.navy > span { background: var(--primary); }
.bar.red > span { background: var(--danger); }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.input, select.input, .field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid #d3d9e2; border-radius: var(--radius); background: #fff; font: inherit; color: var(--text); }
.input:focus, .field input:focus { border-color: var(--primary-2); outline: 2px solid rgba(197, 160, 89, .25); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.filters select, .filters input { padding: 7px 10px; border: 1px solid #d3d9e2; border-radius: var(--radius); font: inherit; background: #fff; min-width: 140px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { background: #0f2537; color: #fff; font-weight: 700; font-size: 12px; text-align: start; padding: 10px 12px; white-space: nowrap; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
table.data tbody tr:nth-child(even) td { background: #f8fafc; }
table.data tbody tr:hover td { background: var(--surface-low); }
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: var(--radius); background: var(--ok-bg); color: var(--ok); margin-bottom: 8px; font-weight: 600; }
.notice { padding: 10px 14px; border-radius: var(--radius); background: var(--surface-low); color: var(--primary); margin: 0 0 14px; display: flex; gap: 8px; align-items: center; }
.notice.danger { background: var(--danger-bg); color: #93000a; }
.notice.warn { background: #fff4dc; color: #785a1a; }
.errorlist, .error { color: var(--danger); padding: 0; list-style: none; margin: 4px 0; }
.helptext, .helptext ul { color: var(--muted); font-size: 12px; }

/* ---------- dialog ---------- */
dialog.modal { border: 0; padding: 0; border-radius: var(--radius-lg); width: min(760px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(15, 37, 55, .35); color: var(--text); }
dialog.modal::backdrop { background: rgba(15, 37, 55, .4); }
dialog.modal .mhead { background: var(--primary); color: #fff; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 2px solid var(--gold-line); }
dialog.modal .mhead h2 { color: #fff; font-size: 18px; }
dialog.modal .mhead .iconbtn { color: #fff; }
dialog.modal .mbody { padding: 18px 20px; max-height: 70vh; overflow: auto; }
dialog.modal .mfoot { padding: 12px 20px; background: var(--surface-low); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.steplabel { font-size: 11px; font-weight: 700; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px; margin-bottom: 16px; }
.segmented label { border: 1px solid var(--hair); border-radius: var(--radius); padding: 10px; text-align: center; cursor: pointer; font-weight: 600; font-size: 13px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--primary); color: #fff; border-color: var(--primary); }
.segmented small { display: block; font-weight: 400; font-size: 11px; opacity: .8; }
.mapping { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.mapping span { background: var(--surface-low); border-radius: var(--radius); padding: 6px 10px; font-size: 12px; }
.mapping b { color: var(--ok); }
kbd { background: var(--card); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 0 6px; font-family: var(--font); font-size: 12px; }

/* ---------- simple pages (forms, help, lists) ---------- */
.card > h1:first-child { margin-bottom: 12px; }
.card form label:not(.field):not(.filters label) { display: block; margin: 12px 0 4px; font-weight: 600; }
.card form input[type=text], .card form input[type=password] { width: 100%; padding: 10px 12px; border: 1px solid #d3d9e2; border-radius: var(--radius); font: inherit; }
.card table:not(.data):not(.marks) { width: 100%; border-collapse: collapse; }
.card table:not(.data):not(.marks) th, .card table:not(.data):not(.marks) td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--hair); }
.btn-sm { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; background: var(--primary); color: #fff; border: 1px solid var(--primary); border-radius: var(--radius); text-decoration: none; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-sm.secondary { background: #fff; color: var(--primary); border-color: var(--gold-line); }
.badge.locked { background: var(--danger-bg); color: #93000a; }
.badge.open { background: var(--ok-bg); color: var(--ok); }
main.page.wide { max-width: 1280px; }

@media (max-width: 720px) {
  .topbar, .brandbar .inner, .tabsbar nav, main.page, footer.site { padding-left: 16px; padding-right: 16px; }
  h1 { font-size: 22px; }
}
@media print { .topbar, .brandbar, .tabsbar, footer.site, .no-print { display: none !important; } }
