:root {
  --bg: #f6f3ec;
  --card: #ffffff;
  --ink: #1d2a28;
  --muted: #6b7a77;
  --line: #e3ddd0;
  --brand: #0f5e57;
  --brand-ink: #ffffff;
  --gold: #f2b84b;
  --ok: #1f8a5b;
  --ok-bg: #e4f3ea;
  --bad: #c43a31;
  --bad-bg: #fbe7e5;
  --warn-bg: #fff3d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 40, 36, .06), 0 4px 14px rgba(20, 40, 36, .05);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Naskh Arabic", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--brand); color: var(--brand-ink);
}
.top .who { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .iconbtn { background: rgba(255,255,255,.14); border: 0; color: inherit; border-radius: 10px; padding: 7px 11px; }
.wrap { max-width: 720px; margin: 0 auto; padding: 14px 16px 120px; }
.wrap.wide { max-width: 980px; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.16); }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #7ee2a8; }
.chip.off::before { background: var(--gold); }
.chip.err::before { background: #ff8f86; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth form { width: 100%; max-width: 380px; background: var(--card); border-radius: 20px; padding: 28px 22px; box-shadow: var(--shadow); }
.auth img { width: 64px; height: 64px; display: block; margin: 0 auto 10px; border-radius: 16px; }
.auth h1 { margin: 0 0 4px; text-align: center; font-size: 22px; }
.auth p.sub { margin: 0 0 20px; text-align: center; color: var(--muted); font-size: 14px; }
label.f { display: block; margin: 12px 0 0; font-size: 14px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], select {
  width: 100%; margin-top: 5px; padding: 12px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px;
}
input:focus, select:focus { outline: 3px solid rgba(15, 94, 87, .25); border-color: var(--brand); }
input[dir=ltr] { text-align: left; }
.btn { width: 100%; margin-top: 18px; padding: 14px; border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 700; font-size: 17px; }
.btn.small { width: auto; margin: 0; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn.ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn.danger { background: var(--bad); }
.btn:disabled { opacity: .55; }
.msg { margin-top: 14px; padding: 10px 12px; border-radius: 10px; font-size: 14px; background: var(--bad-bg); color: var(--bad); }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.warn { background: var(--warn-bg); color: #8a5a00; }

/* ---------- teacher: attendance ---------- */
.bar { display: flex; gap: 10px; margin: 2px 0 10px; }
.bar > * { flex: 1; min-width: 0; }
.bar select, .bar input { margin-top: 0; }
.summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 6px 0 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
}
.summary b { font-size: 20px; }
.summary .st { font-size: 13px; padding: 3px 10px; border-radius: 99px; background: var(--warn-bg); color: #8a5a00; white-space: nowrap; }
.summary .st.done { background: var(--ok-bg); color: var(--ok); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: right;
  padding: 12px 14px; border: 1.5px solid transparent; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
}
.row .n { width: 26px; color: var(--muted); font-size: 13px; text-align: center; flex: none; }
.row .nm { flex: 1; font-size: 16px; line-height: 1.35; }
.row .lbl { font-size: 13px; color: var(--ok); min-width: 38px; text-align: center; font-weight: 700; }
.tg { position: relative; width: 48px; height: 28px; flex: none; border-radius: 99px; background: #cfe3d9; transition: background .15s; }
.tg::after { content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.row[aria-checked=true] { background: var(--bad-bg); border-color: #efb6b1; }
.row[aria-checked=true] .tg { background: var(--bad); }
.row[aria-checked=true] .tg::after { transform: translateX(-20px); }
.row[aria-checked=true] .lbl { color: var(--bad); }
.savebar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 6;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, rgba(246,243,236,0));
}
.savebar .btn { max-width: 720px; margin: 0 auto; display: block; box-shadow: 0 6px 18px rgba(15,94,87,.3); }
.empty { padding: 36px 12px; text-align: center; color: var(--muted); }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 6px; padding: 10px 16px 0; background: var(--brand); overflow-x: auto; }
.tabs button { flex: none; border: 0; background: transparent; color: rgba(255,255,255,.75); padding: 10px 14px; border-radius: 10px 10px 0 0; font-weight: 700; }
.tabs button[aria-selected=true] { background: var(--bg); color: var(--brand); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin: 0 0 12px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat { padding: 12px; border-radius: 12px; background: #fff; border: 1.5px solid var(--line); }
.stat .t { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 800; }
.stat.bad { border-color: #efb6b1; background: var(--bad-bg); }
.stat.ok { border-color: #b9dfc9; background: var(--ok-bg); }
.stat.none { background: var(--warn-bg); border-color: #f0dcae; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: right; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1.5px solid var(--line); }
.tbl td { padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl td.num, .tbl th.num { text-align: center; white-space: nowrap; }
.scroll { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; background: #eef2ef; color: var(--brand); margin: 2px 0 2px 4px; }
.pill.off { background: var(--bad-bg); color: var(--bad); }
.contact { display: inline-flex; gap: 6px; align-items: center; direction: ltr; }
.contact a { text-decoration: none; padding: 5px 10px; border-radius: 9px; font-size: 13px; font-weight: 700; border: 1.5px solid var(--brand); color: var(--brand); }
.contact a.wa { border-color: #1f9d55; color: #1f9d55; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.inline > label { flex: 1; min-width: 130px; margin: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.note { font-size: 13px; color: var(--muted); }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(15, 30, 28, .5); display: grid; place-items: end center; }
.modal > div { width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: var(--bg); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal { place-items: center; } .modal > div { border-radius: 20px; } }
.modal h2 { margin: 0 0 8px; font-size: 18px; }
.secret { margin: 12px 0; padding: 14px; border-radius: 12px; background: #fff; border: 2px dashed var(--brand); text-align: center; direction: ltr; font: 700 22px/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; user-select: all; }
#toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; z-index: 30; max-width: 90vw; padding: 10px 16px; border-radius: 12px; background: #1d2a28; color: #fff; font-size: 14px; transition: .2s; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
