:root {
  --bg: #f5f6fb; --surface: #ffffff; --surface-2: #f1f3f9; --line: #e4e7f0; --text: #111827; --muted: #6b7280; --faint: #9ca3af;
  --brand: #4f46e5; --brand-2: #7c3aed; --brand-soft: #eef0ff; --brand-text: #4338ca;
  --ok: #059669; --ok-soft: #d9f7ea; --late: #d97706; --late-soft: #fdf0d5; --bad: #dc2626; --bad-soft: #fde4e4; --exc: #0284c7; --exc-soft: #dff1fb;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.05); --shadow-lg: 0 20px 50px rgba(16,24,40,.22);
  --r: 16px; --r-sm: 10px; --side: 248px;
  font-family: Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans Arabic", sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0c0e16; --surface: #151824; --surface-2: #1c2030; --line: #272c3f; --text: #eceef6; --muted: #9aa1b5; --faint: #6b7288;
  --brand: #818cf8; --brand-2: #a78bfa; --brand-soft: #23264a; --brand-text: #b4bcff;
  --ok: #34d399; --ok-soft: #0f3a2c; --late: #fbbf24; --late-soft: #40300d; --bad: #f87171; --bad-soft: #431a1a; --exc: #38bdf8; --exc-soft: #0d3348;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.3); --shadow-lg: 0 24px 60px rgba(0,0,0,.6);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
h1 { font-size: 24px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
a { color: var(--brand-text); text-decoration: none; cursor: pointer; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12.5px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; } .grow { flex: 1; min-width: 0; } .hide { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; } .wrap { flex-wrap: wrap; } .col { display: flex; flex-direction: column; gap: 10px; } .between { justify-content: space-between; }
.boot { height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* layout */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 16px; }
.brand .logo { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.35); }
.brand .logo svg { width: 21px; height: 21px; stroke-width: 2.6; }
.brand b { display: block; font-size: 15px; line-height: 1.15; } .brand span { font-size: 11.5px; color: var(--muted); }
.nav-label { font-size: 11px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 11px; color: var(--muted); font-weight: 550; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--brand-soft); color: var(--brand-text); }
.nav .badge { margin-left: auto; }
.me { margin-top: auto; padding: 10px; border-radius: 14px; background: var(--surface-2); display: flex; align-items: center; gap: 10px; }
.main { min-width: 0; padding: 22px clamp(14px, 3vw, 34px) 90px; max-width: 1380px; width: 100%; margin: 0 auto; animation: fade .2s; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.top h1 { flex: 1; min-width: 180px; } .top .sub { color: var(--muted); font-size: 13.5px; font-weight: 400; margin-top: 2px; letter-spacing: 0; }
.bottom-nav { display: none; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; white-space: nowrap; transition: transform .06s, background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: var(--faint); } .btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.28); }
.btn.primary:hover { box-shadow: 0 8px 22px rgba(79,70,229,.4); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); } .btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--bad); } .btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 9px; } .btn.icon { padding: 8px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=email], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; min-height: 42px; }
textarea { min-height: 78px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.invalid input, .invalid select, input.invalid { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 0; }
.f .hint { font-weight: 400; color: var(--faint); }
.grid { display: grid; gap: 14px; } .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)); }
.span2 { grid-column: span 2; } .span3 { grid-column: 1 / -1; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 6px; background: var(--line); outline: none; padding: 0; min-height: 0; border: 0; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); border: 3px solid var(--surface); box-shadow: 0 1px 6px rgba(0,0,0,.3); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--brand); border: 3px solid var(--surface); cursor: pointer; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); overflow: hidden; }
.stepper button { width: 36px; height: 38px; border: 0; background: transparent; font-size: 18px; font-weight: 600; cursor: pointer; color: var(--muted); }
.stepper button:hover { background: var(--surface-2); color: var(--text); }
.stepper output { min-width: 50px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 13px; cursor: pointer; color: var(--muted); user-select: none; transition: all .12s; }
.chip:hover { border-color: var(--faint); } .chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .chip.on { color: #0c0e16; }
.seg { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 11px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.search { position: relative; flex: 1; min-width: 200px; max-width: 420px; } .search svg { position: absolute; left: 12px; top: 12px; color: var(--faint); } .search input { padding-left: 38px; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 550; color: var(--text); font-size: 14px; }
.switch input { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; min-height: 0; border-radius: 99px; background: var(--line); border: 0; position: relative; padding: 0; flex: none; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked { background: var(--brand); } .switch input:checked::after { transform: translateX(18px); }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card > h2 { margin-bottom: 14px; display: flex; align-items: center; gap: 8px; } .card > h2 .btn { margin-left: auto; }
.card.flush { padding: 0; overflow: hidden; } .card.flush > h2 { padding: 16px 18px 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; cursor: default; }
a.kpi { color: inherit; cursor: pointer; transition: transform .12s, box-shadow .12s; } a.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(16,24,40,.1); }
.kpi .lbl { color: var(--muted); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.kpi .val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .val small { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 3px; }
.kpi .foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .dot { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); }
.kpi.bad .dot { background: var(--bad-soft); color: var(--bad); } .kpi.ok .dot { background: var(--ok-soft); color: var(--ok); } .kpi.late .dot { background: var(--late-soft); color: var(--late); }
.kpi.bad .val { color: var(--bad); }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; } .cols.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.late { background: var(--late-soft); color: var(--late); }
.badge.exc { background: var(--exc-soft); color: var(--exc); } .badge.brand { background: var(--brand-soft); color: var(--brand-text); }
.avatar { width: 40px; height: 40px; border-radius: 13px; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; object-fit: cover; background: var(--brand); }
.avatar.lg { width: 96px; height: 96px; border-radius: 26px; font-size: 32px; } .avatar.sm { width: 30px; height: 30px; border-radius: 10px; font-size: 11.5px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); } .empty svg { width: 34px; height: 34px; color: var(--faint); margin-bottom: 8px; } .empty b { display: block; color: var(--text); margin-bottom: 4px; }
table { width: 100%; border-collapse: collapse; } .tablewrap { overflow-x: auto; }
th { text-align: left; font-size: 11.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; } tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
.list > * { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); } .list > *:last-child { border-bottom: 0; }
.list a.item { color: inherit; border-radius: 10px; } .list a.item:hover { background: var(--surface-2); }
.progress { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; } .progress i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.progress.bad i { background: var(--bad); } .progress.late i { background: var(--late); } .progress.ok i { background: var(--ok); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--brand-text); border-bottom-color: var(--brand); }
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 18px; } .dl div span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; } .dl div b { font-weight: 550; overflow-wrap: anywhere; }

/* attendance sheet */
.daybar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.daybar input[type=date] { width: auto; }
.tally { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tally .badge { padding: 6px 12px; font-size: 12.5px; }
.att { display: grid; grid-template-columns: minmax(200px, 1.4fr) auto auto; gap: 14px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); transition: background .2s; }
.att:last-child { border-bottom: 0; }
.att.s-present { background: color-mix(in srgb, var(--ok-soft) 45%, transparent); } .att.s-late { background: color-mix(in srgb, var(--late-soft) 45%, transparent); }
.att.s-absent { background: color-mix(in srgb, var(--bad-soft) 45%, transparent); } .att.s-excused { background: color-mix(in srgb, var(--exc-soft) 45%, transparent); }
.att .who { display: flex; align-items: center; gap: 12px; min-width: 0; } .att .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.cdot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.marks { display: flex; gap: 6px; }
.mark { border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 9px 13px; font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); transition: all .12s; min-height: 42px; }
.mark:active { transform: scale(.95); }
.mark.present:hover, .mark.present.on { border-color: var(--ok); color: var(--ok); } .mark.present.on { background: var(--ok); color: #fff; }
.mark.late:hover, .mark.late.on { border-color: var(--late); color: var(--late); } .mark.late.on { background: var(--late); color: #fff; }
.mark.absent:hover, .mark.absent.on { border-color: var(--bad); color: var(--bad); } .mark.absent.on { background: var(--bad); color: #fff; }
.mark.excused:hover, .mark.excused.on { border-color: var(--exc); color: var(--exc); } .mark.excused.on { background: var(--exc); color: #fff; }
.mark.cancelled:hover, .mark.cancelled.on { border-color: var(--muted); color: var(--text); } .mark.cancelled.on { background: var(--muted); color: #fff; }
.att.s-noshow { background: color-mix(in srgb, var(--bad-soft) 60%, transparent); } .heat i.noshow { background: #9f1239; } .tstat.noshow { background: #9f1239; }
.att.s-cancelled { background: var(--surface-2); } .att.s-cancelled .who { opacity: .6; }
:root[data-theme="dark"] .mark.on { color: #0c0e16; }
.hoursbox { display: flex; flex-direction: column; align-items: center; gap: 4px; } .hoursbox .small { color: var(--faint); }

/* timetable */
.tt { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.tt .day { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px; min-height: 140px; }
.tt .day.today { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }
.tt .day h3 { font-size: 13px; margin-bottom: 8px; display: flex; justify-content: space-between; color: var(--muted); }
.slot { border-radius: 10px; padding: 8px 9px; margin-bottom: 6px; font-size: 12.5px; border-left: 4px solid var(--brand); background: var(--surface-2); cursor: pointer; }
.slot:hover { filter: brightness(.97); } .slot b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .slot.off { opacity: .45; }

/* charts */
.chart { width: 100%; display: block; overflow: visible; } .chart text { fill: var(--muted); font-size: 11px; font-family: inherit; } .chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .bar { transition: opacity .15s; } .chart .bar:hover { opacity: .75; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 8px; } .legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); gap: 3px; overflow-x: auto; padding-bottom: 4px; } .heat i { width: 13px; height: 13px; border-radius: 3px; background: var(--surface-2); }
.heat i.cancelled { background: var(--faint); } .heat i.present { background: var(--ok); } .heat i.late { background: var(--late); } .heat i.absent { background: var(--bad); } .heat i.excused { background: var(--exc); }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; } .donut-wrap svg { width: 132px; height: 132px; flex: none; } .donut-wrap text.big { font-size: 22px; font-weight: 700; fill: var(--text); }

/* profile */
.hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.hero .photo { position: relative; } .hero .photo .btn { position: absolute; right: -8px; bottom: -8px; border-radius: 50%; padding: 7px; box-shadow: var(--shadow); }
.hero h1 { font-size: 26px; }
.doc { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 13px; }
.doc .thumb { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); flex: none; cursor: pointer; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: all .15s; } .drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); }
.inst { display: grid; grid-template-columns: 28px 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 6px; } .inst span { color: var(--faint); font-weight: 650; font-size: 12.5px; }
.summary { background: var(--surface-2); border-radius: 14px; padding: 14px; display: grid; gap: 6px; } .summary div { display: flex; justify-content: space-between; gap: 10px; } .summary .total { font-size: 18px; font-weight: 700; border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 4px; }
.issue { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; } .issue:hover { background: var(--surface-2); } .issue:last-child { border-bottom: 0; }
.issue .sev { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.issue.error .sev { background: var(--bad-soft); color: var(--bad); } .issue.warn .sev { background: var(--late-soft); color: var(--late); } .issue.info .sev { background: var(--exc-soft); color: var(--exc); }
.qr { background: #fff; border-radius: 14px; padding: 8px; width: 176px; flex: none; } .qr svg { width: 100%; height: auto; display: block; }
.report { display: flex; flex-direction: column; gap: 10px; } .report p { margin: 0; color: var(--muted); font-size: 13px; flex: 1; }

/* modal, toast, auth */
.overlay { position: fixed; inset: 0; background: rgba(10,12,24,.55); backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 14px; overflow-y: auto; z-index: 50; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 22px; width: 100%; max-width: 620px; box-shadow: var(--shadow-lg); animation: pop .18s; } .modal.wide { max-width: 860px; } .modal.narrow { max-width: 440px; }
.modal header { display: flex; align-items: center; padding: 18px 20px 0; gap: 10px; } .modal header h2 { flex: 1; font-size: 19px; }
.modal .body { padding: 16px 20px; } .modal footer { padding: 14px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); }
.formerr { background: var(--bad-soft); color: var(--bad); border-radius: 11px; padding: 10px 12px; font-weight: 550; margin-bottom: 12px; display: flex; gap: 8px; }
.warnbox { background: var(--late-soft); color: var(--late); border-radius: 11px; padding: 10px 12px; font-weight: 550; display: flex; gap: 8px; margin-bottom: 8px; }
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: #111827; color: #fff; padding: 11px 16px; border-radius: 13px; box-shadow: var(--shadow-lg); font-weight: 550; animation: pop .18s; display: flex; gap: 8px; align-items: center; }
.toast.err { background: #b91c1c; } .toast.warn { background: #b45309; } .toast.ok svg { color: #6ee7b7; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent), radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--brand-2) 22%, transparent), transparent), var(--bg); }
.auth .card { width: 100%; max-width: 430px; padding: 28px; border-radius: 24px; } .auth .brand { padding: 0 0 18px; } .auth h1 { margin-bottom: 4px; } .auth p { color: var(--muted); margin: 0 0 18px; }
.crop { width: 300px; height: 300px; max-width: 100%; border-radius: 22px; background: #000; touch-action: none; cursor: grab; display: block; margin: 0 auto 14px; }
.results { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-lg); margin-top: 6px; z-index: 20; max-height: 340px; overflow-y: auto; padding: 6px; }
.results a { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 9px; color: inherit; } .results a:hover { background: var(--surface-2); }

/* phone number with country code, logo, family contract rows */
.phone { display: flex; gap: 6px; align-items: center; } .phone select { width: 118px; flex: none; padding-left: 8px; padding-right: 4px; } .phone input[type=tel] { flex: 1; min-width: 0; } .phone [data-wa]:not([href]) { opacity: .3; pointer-events: none; }
.logo-img { width: 40px; height: 40px; border-radius: 12px; object-fit: contain; background: #fff; flex: none; border: 1px solid var(--line); } .auth .logo-img { width: 56px; height: 56px; }
.memrow { display: grid; grid-template-columns: 1.3fr auto 1fr 1.3fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
/* instructor timetable */
.tgrid-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.tgrid { display: grid; min-width: max-content; background: var(--surface); }
.thead { height: 46px; padding: 6px 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; position: sticky; top: 0; background: var(--surface); z-index: 3; }
.thead b { font-size: 13px; } .thead span { font-size: 11px; color: var(--muted); }
.ttimes span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; } .ttimes span:first-child { transform: none; }
.tcol { border-left: 1px solid var(--line); min-width: 150px; } .tcol.today .thead { background: var(--brand-soft); } .tcol.today .thead b { color: var(--brand-text); } .tcol.over .tbody { background-color: var(--brand-soft); }
.tbody { position: relative; background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px); }
.tbox { position: absolute; left: 4px; right: 4px; border-radius: 9px; padding: 5px 8px 5px 10px; font-size: 11.5px; line-height: 1.32; overflow: hidden; cursor: grab; user-select: none; -webkit-user-select: none;
  background: color-mix(in srgb, var(--c) 17%, var(--surface)); border-left: 4px solid var(--c); display: flex; flex-direction: column; transition: box-shadow .15s; z-index: 1; }
.tbox:hover { box-shadow: 0 4px 14px rgba(16,24,40,.16); z-index: 2; }
.tbox > b { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; padding-right: 16px; } .tbox > b svg { width: 13px; height: 13px; }
.tbox > span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbox .grip { position: absolute; top: 3px; right: 2px; color: var(--faint); touch-action: none; cursor: grab; padding: 2px; } .tbox .grip svg { width: 14px; height: 14px; stroke-width: 3; }
.tbox.dragging { opacity: .35; } .tdetails { display: none; }
.tbox.open { height: auto !important; min-height: 60px; z-index: 6; overflow: visible; box-shadow: var(--shadow-lg); background: var(--surface); outline: 2px solid var(--c); cursor: default; min-width: 250px; }
.tbox.open > span, .tbox.open > b { white-space: normal; } .tbox.open .tdetails { display: grid; gap: 9px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 12.5px; }
.tmarks { display: flex; gap: 4px; flex-wrap: wrap; } .tmarks .mark { min-height: 34px; padding: 5px 10px; font-size: 12px; border-radius: 9px; } .tmarks .mark[disabled] { opacity: .45; pointer-events: none; }
.tmember { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 5px 0; border-top: 1px solid var(--line); }
.tghost { position: absolute; left: 4px; right: 4px; border: 2px dashed var(--brand); border-radius: 9px; background: color-mix(in srgb, var(--brand) 14%, transparent); z-index: 5; font-size: 12px; font-weight: 700; color: var(--brand-text); padding: 4px 8px; pointer-events: none; }
.tstat { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--faint); } .tstat.present, .tstat.late { background: var(--ok); } .tstat.absent { background: var(--bad); } .tstat.excused { background: var(--exc); }
.planrow { display: grid; grid-template-columns: 1.3fr 1fr 1.4fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mbar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--surface-2); margin: 6px 0; min-width: 120px; } .mbar i { display: block; height: 100%; }
@media (max-width: 1000px) { .cols, .cols.even { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; } .side { display: none; }
  .side.open { display: flex; position: fixed; inset: 0; z-index: 40; width: 100%; height: 100%; padding-bottom: 90px; }
  .main { padding: 16px 14px 104px; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line); z-index: 45; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; font-size: 10.5px; font-weight: 600; color: var(--muted); border-radius: 12px; }
  .bottom-nav a.on { color: var(--brand-text); background: var(--brand-soft); } .bottom-nav svg { width: 21px; height: 21px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .att { grid-template-columns: 1fr; gap: 10px; } .marks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; } .mark { justify-content: center; padding: 10px 2px; font-size: 11.5px; }
  .planrow, .memrow { grid-template-columns: 1fr 1fr !important; } .phone select { width: 96px; } .mark svg { display: none; }
  .hoursbox { flex-direction: row; justify-content: space-between; }
  h1 { font-size: 21px; } .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .kpi .val { font-size: 21px; }
  .overlay { padding: 0; align-items: flex-end; } .modal { border-radius: 22px 22px 0 0; max-height: 94vh; overflow-y: auto; max-width: none !important; }
  td, th { padding: 10px; } .hide-m { display: none !important; } #toasts { bottom: 86px; }
}
@media print { .side, .bottom-nav, .btn, #toasts { display: none !important; } .shell { display: block; } body { background: #fff; } }

/* contract form: hours stepper, child cards, finishing-soon box, frozen lessons */
.hstep { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--surface); max-width: 220px; }
.hstep button { width: 44px; border: 0; background: var(--surface-2); font-size: 20px; font-weight: 600; cursor: pointer; color: var(--text); flex: none; }
.hstep button:active { background: var(--line); } .hstep input { border: 0 !important; border-radius: 0; text-align: center; font-weight: 700; box-shadow: none !important; min-width: 0; }
.memcard { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; display: grid; gap: 10px; background: var(--surface); }
.memgrid { display: grid; grid-template-columns: 220px 1fr 1fr; gap: 10px; align-items: end; }
.finishbox { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--late-soft); } .finishbox .list > * { border-color: color-mix(in srgb, var(--late) 25%, transparent); }
.tbox.frozen { background-image: repeating-linear-gradient(135deg, transparent 0 7px, color-mix(in srgb, var(--exc) 22%, transparent) 7px 14px); opacity: .8; }
.summary > div { flex-wrap: wrap; }
html, body { overflow-x: hidden; }

/* phones: keep everything inside the visible screen and give each control room */
@media (max-width: 820px) {
  .main { padding: calc(14px + env(safe-area-inset-top)) 12px calc(96px + env(safe-area-inset-bottom)); }
  .auth { padding-top: calc(20px + env(safe-area-inset-top)); align-items: start; }
  .side.open { padding-top: calc(18px + env(safe-area-inset-top)); }
  .overlay { padding: 0; align-items: flex-end; height: 100dvh; }
  .modal { max-height: calc(100dvh - env(safe-area-inset-top) - 10px); display: flex; flex-direction: column; overflow: hidden; }
  .modal > form { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow: hidden; }
  .modal header { flex: none; padding: 14px 16px 8px; position: relative; z-index: 2; background: var(--surface); border-radius: 22px 22px 0 0; }
  .modal .body { overflow-y: auto; flex: 1; min-height: 0; padding: 10px 16px 14px; -webkit-overflow-scrolling: touch; }
  .modal footer { flex: none; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); }
  .modal footer .btn { flex: 1 1 auto; }
  .top { gap: 8px; margin-bottom: 14px; } .top h1 { flex: 1 1 100%; min-width: 0; } .top > .btn, .top > a.btn, .top > .row { flex: 1 1 auto; } .top .search { flex: 1 1 100%; max-width: none !important; }
  .card { padding: 14px; border-radius: 14px; } .card > h2 { flex-wrap: wrap; row-gap: 8px; font-size: 16px; } .card > h2 .btn, .card > h2 > .row, .card > h2 > .seg { margin-left: 0 !important; }
  .card.flush > h2 { padding: 14px 14px 0; }
  .hero { gap: 12px; } .hero > .grow { flex: 1 1 60%; min-width: 0; } .hero h1 { font-size: 20px; overflow-wrap: anywhere; } .avatar.lg { width: 72px; height: 72px; border-radius: 20px; font-size: 26px; }
  .hero > .row.wrap { flex: 1 1 100%; } .hero > .row.wrap > .btn { flex: 1 1 calc(50% - 6px); } .hero > .row.wrap > .btn.icon { flex: 0 0 auto; }
  .tabs { margin: 0 -12px 14px; padding: 0 12px; scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; } .tabs button { padding: 10px 11px; font-size: 13.5px; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; } .seg button { flex: none; }
  .dl { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
  .daybar > .btn.primary { flex: 1 1 100%; } .daybar .grow { display: none; }
  .memgrid { grid-template-columns: 1fr; } .hstep { max-width: none; }
  .inst { grid-template-columns: 22px 1fr 1fr; } .inst > span:last-child { display: none; }
  .docs { grid-template-columns: 1fr; } .doc .row { flex-wrap: wrap; }
  .list > * { flex-wrap: wrap; } .issue { padding: 12px; }
  .kpi { padding: 12px; } .kpi .lbl { font-size: 11.5px; } .kpi .dot { width: 26px; height: 26px; }
  .report .row { flex-wrap: wrap; } .report .btn { flex: 1; }
  .btn { min-height: 40px; } .btn.sm { min-height: 34px; }
  .phone select { width: 92px; font-size: 13px; }
  .qr { width: 150px; }
  .tgrid-wrap { margin: 0 -4px; }
  .bottom-nav { padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=email], input[type=tel], input[type=search], input[type=month], select, textarea { font-size: 16px; }
}

/* grouped subject chips, flags, cover */
.chips.grouped .chipgroup { flex: 0 0 100%; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin-top: 6px; }
.chips.grouped { max-height: 260px; overflow-y: auto; padding: 2px; }
.card.flags { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: color-mix(in srgb, var(--bad-soft) 35%, var(--surface)); }
a.flagcard { color: inherit; box-shadow: none; padding: 12px; } a.flagcard:hover { border-color: var(--bad); }
.badge svg.ic { width: 12px; height: 12px; }
.tbox.covered { opacity: .5; filter: grayscale(.6); } .tbody { cursor: copy; } .tbox { cursor: grab; }

/* iPhone home-screen app: the page must reach the real bottom of the screen (no dead strip under the bottom bar) */
html { min-height: calc(100% + env(safe-area-inset-top)); }
@media (max-width: 820px) {
  .side.open { height: 100dvh; padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
  .bottom-nav { bottom: 0; }
}

/* delete confirmation, calendar, filters */
ul.purge { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 6px; } ul.purge li { line-height: 1.4; }
.calgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calhead { text-align: center; font-size: 11px; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding-bottom: 2px; }
.calcell { min-height: 64px; border: 1px solid var(--line); border-radius: 10px; padding: 4px; display: flex; flex-direction: column; gap: 3px; background: var(--surface); min-width: 0; }
.calcell.out { border: 0; background: transparent; } .calcell.shut { background: var(--surface-2); } .calcell.today { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 18%, transparent); }
.caln { font-size: 11.5px; font-weight: 650; color: var(--muted); }
.calpill { font-size: 10.5px; font-weight: 650; border-radius: 6px; padding: 2px 4px; color: #fff; background: var(--faint); text-align: center; overflow: hidden; white-space: nowrap; }
.calpill.present { background: var(--ok); } .calpill.late { background: var(--late); } .calpill.absent { background: var(--bad); } .calpill.noshow { background: #9f1239; } .calpill.excused { background: var(--exc); }
.calpill.booked { background: transparent; color: var(--brand-text); border: 1.5px dashed var(--brand); padding: 1px 3px; } .calpill.unmarked { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; } .filters select { width: auto; flex: 0 1 190px; min-height: 38px; padding: 7px 10px; }

/* instructor timetable, fit-to-screen view: the whole week without scrolling sideways */
.tgrid-wrap.fit { overflow: visible; } .tgrid.fit { min-width: 0; }
.tgrid.fit .tcol { min-width: 0; } .tgrid.fit .thead { height: 38px; padding: 3px 2px; align-items: center; text-align: center; } .tgrid.fit .thead b { font-size: 11.5px; } .tgrid.fit .thead span { font-size: 9.5px; white-space: nowrap; }
.tgrid.fit .ttimes span { font-size: 9.5px; right: 3px; }
.tgrid.fit .tbox { left: 1px; right: 1px; padding: 2px 3px 2px 4px; font-size: 9.5px; line-height: 1.25; border-left-width: 3px; border-radius: 6px; }
.tgrid.fit .tbox > b { font-size: 10.5px; padding-right: 0; gap: 3px; } .tgrid.fit .tbox .grip { display: none; }
.tgrid.fit .tbox.open { width: 264px; right: auto; left: 1px; font-size: 12px; padding: 8px 10px; } .tgrid.fit .tcol.r .tbox.open { left: auto; right: 1px; } .tgrid.fit .tbox.open > b { font-size: 13.5px; }
@media (max-width: 820px) {
  .calcell { min-height: 50px; padding: 2px; border-radius: 7px; } .calpill { font-size: 9px; padding: 1px 2px; } .caln { font-size: 10.5px; }
  .filters select { flex: 1 1 44%; }
  .tgrid.fit .tbox > span { display: none; } .tgrid.fit .tbox.open > span { display: block; }
}
@media (max-width: 820px) {
  /* on a phone an opened timetable box becomes a card in the middle of the screen, so nothing is cut off */
  .tgrid.fit .tbox.open, .tgrid.fit .tcol.r .tbox.open { position: fixed; left: 12px; right: 12px; width: auto; top: 14vh !important; max-height: 70vh; overflow-y: auto; z-index: 44; }
}

/* ---- app-like shell: the page itself never moves; only the content area scrolls ---- */
html { height: calc(100% + env(safe-area-inset-top)); min-height: 0; overflow: hidden; overscroll-behavior: none; }
body { height: 100%; overflow: hidden; overscroll-behavior: none; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
#app { height: 100%; }
.shell { height: 100%; min-height: 0; grid-template-rows: minmax(0, 1fr); overflow: hidden; position: relative; }
.side { position: static; height: 100%; }
.main { height: 100%; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; max-width: none; margin: 0;
  padding-left: max(clamp(14px, 3vw, 34px), calc((100% - 1380px) / 2)); padding-right: max(clamp(14px, 3vw, 34px), calc((100% - 1380px) / 2)); }
.auth { height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.btn, .nav a, .bottom-nav a, .chip, .mark, .tabs button, .seg button, .tbox { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (max-width: 820px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .bottom-nav { position: absolute; bottom: 0; }
  .side.open { position: absolute; height: 100%; }
}
@media print { html, body, #app, .shell, .main { height: auto !important; overflow: visible !important; } }

/* ---- motion: plays once when a page opens ---- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes growY { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes drawLine { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes donutIn { from { opacity: 0; transform: rotate(-70deg) scale(.86); } to { opacity: 1; transform: none; } }
.nav-anim > * { animation: rise .38s cubic-bezier(.2, .8, .2, 1) both; }
.nav-anim > *:nth-child(2) { animation-delay: .04s; } .nav-anim > *:nth-child(3) { animation-delay: .08s; } .nav-anim > *:nth-child(4) { animation-delay: .12s; } .nav-anim > *:nth-child(n+5) { animation-delay: .16s; }
.nav-anim .chart rect.grow { transform-box: fill-box; transform-origin: 50% 100%; animation: growY .7s cubic-bezier(.2, .8, .2, 1) both; }
.nav-anim .chart polyline.draw { stroke-dasharray: 1; animation: drawLine 1.1s cubic-bezier(.4, 0, .2, 1) both; }
.nav-anim .chart .fadein { animation: fade .9s .25s both; }
.nav-anim .donut-wrap svg { transform-origin: 50% 50%; animation: donutIn .8s cubic-bezier(.2, .8, .2, 1) both; }
.nav-anim .progress i { transform-origin: 0 50%; animation: growX .8s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes growX { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.btn, .mark, .chip, .kpi, .card { transition: transform .12s cubic-bezier(.2, .8, .2, 1), box-shadow .15s, background .15s, border-color .15s, color .15s; }
.mark:active, .chip:active, .bottom-nav a:active { transform: scale(.94); }
.tbox.lift { transform: scale(1.07); box-shadow: 0 14px 34px rgba(16, 24, 40, .35); z-index: 9; opacity: .92 !important; transition: transform .16s cubic-bezier(.2, .8, .2, 1), box-shadow .16s; }
.tghost { transition: top .08s linear; }
@media (prefers-reduced-motion: reduce) { .nav-anim > *, .nav-anim .chart rect.grow, .nav-anim .chart polyline.draw, .nav-anim .donut-wrap svg, .nav-anim .progress i { animation: none !important; } }

/* import page */
.mapgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 14px; }
label.drop { display: block; }
