/* StudentIndex — app styles (LTR + RTL via logical properties) */
:root {
  --navy: #243C8F; --navy-d: #1B2D6B; --navy-ink: #0F172A;
  --teal: #14A394; --teal-l: #CCF2EC; --teal-d: #0F6B62; --teal-bg: #EAF7F5;
  --orange: #EA580C; --orange-d: #C2410C; --orange-l: #FFEDD5; --orange-ink: #9A3412;
  --green: #15803D; --green-l: #DCFCE7; --green-ink: #166534;
  --amber: #A16207; --amber-l: #FEF3C7; --amber-ink: #92400E;
  --bg: #F4F6FA; --card: #fff; --line: #E2E8F0; --line-2: #F1F5F9; --field: #CBD5E1;
  --ink: #0F172A; --ink-2: #334155; --muted: #475569; --soft: #F8FAFC;
  --side: #0F172A; --side-2: #1E293B; --side-ink: #CBD5E1;
  --r: 14px; --r-s: 10px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
html[lang="ar"] { --font: Cairo, Inter, system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; }
body { -webkit-font-smoothing: antialiased; }
a { color: var(--navy); } a:hover { color: var(--navy-d); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
.boot { display: grid; place-items: center; height: 100vh; font-weight: 700; color: var(--navy); font-size: 20px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.side { width: 248px; flex-shrink: 0; background: var(--side); color: #fff; padding: 18px 12px; display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; border-bottom: 1px solid var(--side-2); }
.brand .logo { width: 40px; height: 40px; border-radius: 10px; background: var(--side-2); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.brand .bname { font-weight: 600; font-size: 15px; line-height: 1.2; }
.brand .bsub { color: #94A3B8; font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--side-ink); text-decoration: none; font-size: 14px; }
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.on { background: var(--navy); color: #fff; font-weight: 600; }
.nav .sep { height: 1px; background: var(--side-2); margin: 8px 4px; }
.side-foot { margin-top: auto; font-size: 11px; color: #64748B; padding: 0 6px; }
.main { flex: 1; min-width: 0; padding: 22px 28px 40px; display: flex; flex-direction: column; gap: 18px; }
#page { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.sv #page, #app > #page { gap: 0; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.topbar .crumb { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mobile-bar { display: none; }
.imp-bar { background: var(--orange-l); color: var(--orange-ink); padding: 8px 14px; border-radius: var(--r-s); display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 600; }

/* ---------- Components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card.p0 { padding: 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card.p0 .card-h { padding: 16px 18px 0; }
.grid { display: grid; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row > .grow { flex: 2 1 420px; min-width: 0; }
.row > .side-col { flex: 1 1 300px; min-width: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.field label, .lbl { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.in, select.in, textarea.in { width: 100%; height: 42px; border: 1px solid var(--field); border-radius: var(--r-s); padding: 0 12px; background: #fff; }
textarea.in { height: auto; min-height: 110px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.in:focus, .btn:focus-visible, .chip:focus-visible, .seg button:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.in.sm { height: 36px; } .w-auto, select.in.w-auto, .in.w-auto { width: auto; max-width: 100%; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: var(--r-s); border: 1px solid var(--field);
  background: #fff; color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--soft); color: var(--ink); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; } .btn.primary:hover { background: var(--navy-d); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { border-color: #FDBA74; color: var(--orange-ink); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.xs { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.ic { width: 18px; height: 18px; flex-shrink: 0; }
.btn .ic { width: 16px; height: 16px; }
.photo-btn .ic { width: 32px; height: 32px; color: var(--navy); }
.drop .ic { width: 24px; height: 24px; color: var(--navy); }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--field); background: #fff; display: inline-grid; place-items: center; cursor: pointer; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--ink-2); border-radius: 8px; padding: 7px 13px; font-weight: 600; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--navy-ink); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--field); background: #fff; border-radius: 999px; padding: 6px 13px; font-size: 13px; cursor: pointer; }
.chip.on { border-color: var(--navy); background: var(--teal-bg); color: var(--navy); font-weight: 600; }
.pill { display: inline-block; border-radius: 999px; padding: 3px 10px; font-weight: 600; font-size: 12px; white-space: nowrap; }
.pill.P, .pill.green { background: var(--green-l); color: var(--green-ink); }
.pill.A, .pill.orange { background: var(--orange-l); color: var(--orange-ink); }
.pill.L, .pill.PARTIAL, .pill.amber { background: var(--amber-l); color: var(--amber-ink); }
.pill.E, .pill.teal { background: var(--teal-l); color: var(--teal-d); }
.pill.gray { background: var(--line-2); color: var(--muted); }
.cell { display: inline-flex; width: 30px; height: 30px; border-radius: 8px; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; border: 0; cursor: default; }
button.cell { cursor: pointer; }
.cell.P { background: var(--green-l); color: var(--green-ink); } .cell.A { background: var(--orange-l); color: var(--orange-ink); }
.cell.L { background: var(--amber-l); color: var(--amber-ink); } .cell.E { background: var(--teal-l); color: var(--teal-d); }
.cell.N { background: var(--line-2); color: #64748B; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--line); color: var(--ink-2); display: inline-grid; place-items: center; font-weight: 600; font-size: 13px; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who .nm { font-weight: 600; } .who .sb { font-size: 12px; color: var(--muted); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.note { background: var(--soft); border-radius: var(--r-s); padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
.note.warn { background: var(--orange-l); color: var(--orange-ink); }
.note.ok { background: var(--green-l); color: var(--green-ink); }
.bar { height: 12px; background: #EEF2F7; border-radius: 6px; overflow: hidden; flex: 1; }
.bar > i { display: block; height: 100%; border-radius: 6px; background: var(--teal); }
.bar > i.low { background: var(--orange); }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bars .b { display: flex; align-items: center; gap: 12px; }
.bars .b .l { width: 120px; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .b .v { width: 54px; text-align: end; font-weight: 600; font-variant-numeric: tabular-nums; }
.cols { display: flex; align-items: flex-end; gap: 14px; height: 190px; border-bottom: 1px solid var(--line); padding: 0 6px; }
.cols .c { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.cols .c i { display: block; width: 100%; max-width: 70px; border-radius: 8px 8px 0 0; background: var(--teal); min-height: 2px; }
.cols .c i.low { background: var(--orange); }
.cols-l { display: flex; gap: 14px; padding: 8px 6px 0; } .cols-l span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { padding: 10px 14px; font-size: 14px; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; cursor: pointer; }
.tabs a.on { color: var(--navy); border-color: var(--navy); font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 38px; height: 38px; border: 1px solid var(--field); background: #fff; border-radius: 9px; font-size: 18px; font-weight: 600; cursor: pointer; }
.stepper .val { min-width: 60px; text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { font-size: 12px; color: var(--muted); text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; white-space: nowrap; background: #fff; }
.tbl td { font-size: 14px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--soft); }
.tbl .gi { width: 70px; height: 36px; border: 1px solid var(--field); border-radius: 8px; text-align: center; }
.tbl .gi.err { border-color: var(--orange); background: var(--orange-l); }
.tbl .gi.abs { background: var(--line-2); color: var(--muted); }
.tbl-foot { padding: 12px 16px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 4px; vertical-align: -1px; }

/* ---------- Modal & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { max-width: 820px; }
.modal-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-b { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-f { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--soft); flex-wrap: wrap; }
.x { border: 0; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--ink-2); padding: 4px 8px; }
#toasts { position: fixed; inset-block-end: 18px; inset-inline-start: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; }
html[dir="rtl"] #toasts { transform: translateX(50%); }
.toast { background: var(--navy-ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 6px 20px rgba(15,23,42,.25); }
.toast.err { background: var(--orange-d); }
.drop { border: 2px dashed var(--field); border-radius: 12px; padding: 14px; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.drop:hover { background: var(--soft); }

/* ---------- Camera / photo ---------- */
.photo-btn { width: 160px; height: 160px; border-radius: 50%; border: 2px dashed #94A3B8; background: var(--soft); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--ink-2); font-weight: 600; font-size: 13px; overflow: hidden; padding: 0; }
.photo-btn img { width: 100%; height: 100%; object-fit: cover; }
.cam { position: relative; background: #1E293B; height: 320px; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 12px; }
.cam video { width: 100%; height: 100%; object-fit: cover; }
.cam .ring { position: absolute; width: 220px; height: 220px; border-radius: 50%; border: 3px solid rgba(255,255,255,.85); box-shadow: 0 0 0 999px rgba(15,23,42,.35); pointer-events: none; }
.shutter { width: 64px; height: 64px; border-radius: 50%; border: 4px solid var(--navy); background: #fff; cursor: pointer; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(180deg, #EEF2FA, var(--bg)); }
.login .box { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login .mark { display: flex; align-items: center; gap: 12px; }
.login .mark img { width: 48px; height: 48px; border-radius: 12px; }
.login .mark b { font-size: 22px; color: var(--navy); } .login .mark b span { color: var(--teal); }

/* ---------- Supervisor (mobile) ---------- */
.sv { max-width: 560px; width: 100%; min-width: 0; margin: 0 auto; min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }
.sv-h { background: var(--navy-ink); color: #fff; padding: 18px 16px 16px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; z-index: 5; }
.sv-h .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sv-h .title { font-size: 20px; font-weight: 700; }
.sv-h .sub { font-size: 12px; color: #94A3B8; }
.sv-h .ghost { border: 1px solid #334155; background: transparent; color: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 12px; cursor: pointer; }
.sv-stats { display: flex; gap: 8px; }
.sv-stats div { flex: 1; background: var(--side-2); border-radius: 10px; padding: 7px 10px; }
.sv-stats .k { font-size: 11px; color: #94A3B8; } .sv-stats .v { font-size: 18px; font-weight: 700; }
.periods { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 12px; min-width: 0; }
.sv > * { min-width: 0; }
.periods .list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.periods button { flex-shrink: 0; min-width: 54px; height: 40px; border-radius: 10px; font-weight: 600; font-size: 13px; cursor: pointer; border: 1px solid var(--field); background: #fff; color: var(--muted); }
.periods button.done { background: var(--green-l); color: var(--green-ink); border-color: #86EFAC; }
.periods button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.sv-list { flex: 1; padding: 8px 12px 100px; display: flex; flex-direction: column; gap: 8px; }
.st-row { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; }
.st-row .avatar { width: 46px; height: 46px; cursor: pointer; }
.st-row .info { flex: 1; min-width: 0; } .st-row .info .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marks { display: flex; gap: 4px; }
.marks button { width: 40px; height: 40px; border-radius: 9px; border: 1px solid var(--field); background: #fff; color: var(--muted); font-weight: 700; cursor: pointer; }
.marks button.P.on { background: var(--green); border-color: var(--green); color: #fff; }
.marks button.A.on { background: var(--orange-d); border-color: var(--orange-d); color: #fff; }
.marks button.L.on { background: var(--amber); border-color: var(--amber); color: #fff; }
.sv-foot { position: fixed; inset-block-end: 0; inset-inline: 0; background: #fff; border-top: 1px solid var(--line); padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); }
.sv-foot .in-w { max-width: 532px; margin: 0 auto; }
.sv-foot .btn { width: 100%; height: 50px; font-size: 15px; }
.class-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.class-card:hover { border-color: var(--navy); color: var(--ink); }

/* ---------- Print (PDF) ---------- */
.print-head { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .side, .mobile-bar, .no-print, .top-actions, .imp-bar, #toasts, .sv-foot { display: none !important; }
  .main { padding: 0; }
  .card { border: 0; padding: 0; break-inside: avoid; }
  .print-head { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--navy); padding-bottom: 10px; margin-bottom: 8px; }
  .print-head img { width: 44px; height: 44px; object-fit: contain; }
  .tbl th, .tbl td { padding: 6px 8px; font-size: 11px; }
  .tbl-wrap { overflow: visible; }
  a { color: inherit; text-decoration: none; }
  .bar, .bar > i, .cell, .pill, .cols .c i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; height: 100%; }
  html[dir="rtl"] .side { transform: translateX(100%); }
  .layout.menu-open .side { transform: none; }
  .layout.menu-open::after { content: ""; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 30; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--side); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 20; }
  .mobile-bar button { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; }
  .main { padding: 16px 14px 40px; }
  .kpi .v { font-size: 24px; }
}
