/* Ihsan Academy — single stylesheet, no build step. */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --border: #e4e0d6;
  --text: #1f2a24;
  --muted: #6b726d;
  --brand: #1f5d4a;
  --brand-ink: #ffffff;
  --brand-soft: #e3efe9;
  --accent: #b7862f;
  --danger: #b4382f;
  --danger-soft: #fbe9e7;
  --warn-soft: #fbf3e2;
  --ok-soft: #e6f3ec;
  --info-soft: #e8eef8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31, 42, 36, .06), 0 1px 1px rgba(31, 42, 36, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand); color: var(--brand-ink); padding: 1.25rem 1rem; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1.25rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; font-weight: 800; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: rgba(255,255,255,.85); padding: .5rem .7rem; border-radius: 8px; display: flex; gap: .6rem; align-items: center; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; }
.nav .section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.55); padding: .9rem .7rem .3rem; }
.sidebar-foot { margin-top: auto; font-size: .85rem; color: rgba(255,255,255,.75); }
.sidebar-foot a, .sidebar-foot button { color: #fff; }
.main { padding: 1.5rem 2rem 3rem; max-width: 1200px; width: 100%; }
.topbar { display: none; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head .sub { color: var(--muted); margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; align-items: start; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; }
.card + .card { margin-top: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.stat { padding: 1rem 1.1rem; }
.stat .num { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .85rem; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; }

/* ---------- lists & tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: .6rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .6rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .75rem; align-items: center; justify-content: space-between; }
.list li:last-child { border-bottom: 0; }

.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: inline-grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; }
.who { display: flex; align-items: center; gap: .65rem; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.present { background: var(--ok-soft); color: #1d6b45; border-color: #cfe7da; }
.badge.late { background: var(--warn-soft); color: #8a5f12; border-color: #f1e0bb; }
.badge.absent { background: var(--danger-soft); color: var(--danger); border-color: #f3cdc8; }
.badge.perf-1 { background: var(--danger-soft); color: var(--danger); }
.badge.perf-2 { background: var(--warn-soft); color: #8a5f12; }
.badge.perf-3, .badge.perf-4 { background: var(--brand-soft); color: var(--brand); }
.badge.perf-5 { background: var(--brand); color: #fff; border-color: var(--brand); }
.badge.inactive { background: #eee; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem .95rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; line-height: 1.2; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: #f0c7c2; }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: .3rem .6rem; font-size: .85rem; }
.btn.link { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 500; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(183, 134, 47, .45); outline-offset: 1px; }

/* ---------- forms ---------- */
.form { max-width: 720px; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }
.field .help { color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.field .errors, .errorlist { color: var(--danger); font-size: .85rem; margin: .3rem 0 0; padding: 0; list-style: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field.check { display: flex; align-items: center; gap: .5rem; }
.field.check label { margin: 0; font-weight: 500; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=search], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 2.6rem; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.filters input[type=search] { max-width: 280px; }
.filters select, .filters input[type=date] { width: auto; }

/* ---------- messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.messages li { padding: .7rem 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.messages .success { background: var(--ok-soft); border-color: #cfe7da; }
.messages .error { background: var(--danger-soft); border-color: #f3cdc8; }
.messages .info, .messages .warning { background: var(--warn-soft); border-color: #f1e0bb; }

/* ---------- profile ---------- */
.profile-head { display: flex; gap: 1rem; align-items: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; }
.snapshot { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.snapshot .card { margin: 0; border-top: 3px solid var(--brand); }
.snapshot .card:nth-child(2) { border-top-color: var(--accent); }
.snapshot .card:nth-child(3) { border-top-color: #6a8caf; }
.snapshot .card:nth-child(4) { border-top-color: #a35d6a; }
.snapshot h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { border-inline-start: 2px solid var(--border); padding-block: 0 1.25rem; padding-inline: 1.1rem 0; position: relative; }
.timeline > li::before { content: ""; position: absolute; inset-inline-start: -6px; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline > li.absent::before { background: var(--danger); }
.timeline .t-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.note-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 1.25rem; }
.note-fields .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.note-fields .full { grid-column: 1 / -1; }

/* ---------- session sheet ---------- */
.sheet-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: .75rem; }
.sheet-row.is-absent .note-inputs { opacity: .45; }
.sheet-top { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.att-group { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.att-group label { padding: .35rem .7rem; cursor: pointer; font-size: .85rem; font-weight: 600; border-inline-end: 1px solid var(--border); color: var(--muted); user-select: none; }
.att-group label:last-child { border-inline-end: 0; }
.att-group input { position: absolute; opacity: 0; pointer-events: none; }
.att-group input:checked + span { color: inherit; }
.att-group label:has(input:checked) { background: var(--brand); color: #fff; }
.att-group label.absent:has(input:checked) { background: var(--danger); }
.att-group label.late:has(input:checked) { background: var(--accent); }
.note-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.note-inputs .field { margin: 0; }
.note-inputs .wide { grid-column: span 2; }
.prev { font-size: .8rem; color: var(--muted); }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 1rem 0 .5rem; display: flex; gap: .5rem; justify-content: flex-end; }

/* ---------- pagination ---------- */
.pagination { display: flex; gap: .4rem; align-items: center; justify-content: center; margin-top: 1rem; font-size: .9rem; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at 20% 10%, #e3efe9, transparent 50%), var(--bg); }
.auth .card { width: 100%; max-width: 380px; padding: 2rem; }
.auth .brand { color: var(--text); margin-bottom: 1.25rem; justify-content: center; }

/* ---------- responsive ---------- */
@media screen and (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .grid-3 { grid-template-columns: 1fr; }
  .snapshot { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .note-inputs { grid-template-columns: 1fr 1fr; }
}
@media screen and (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 30; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem; background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; }
  .main { padding: 1rem 1rem 3rem; }
  .grid-2, .form-grid, .note-fields, .note-inputs, .snapshot { grid-template-columns: 1fr; }
  .note-inputs .wide { grid-column: auto; }
  .hide-sm { display: none; }
  .filters input[type=search] { max-width: none; flex: 1 1 100%; }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .no-print, .messages { display: none !important; }
  .app { display: block; }
  .main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .report-entry { break-inside: avoid; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.field > div[id] { display: flex; gap: .4rem 1.1rem; flex-wrap: wrap; }
.field > div[id] label { font-weight: 500; display: inline-flex; gap: .35rem; align-items: center; margin: 0; }
.grid > .card, .snapshot > .card { margin-top: 0; }
.badges { display: inline-flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
@media screen and (max-width: 760px) { .list li { flex-wrap: wrap; } }

/* ---------- charts ---------- */
:root { --chart-1: #1f5d4a; --chart-2: #2a78d6; --chart-grid: #e9e5dc; --chart-ink: #6b726d; }
.chart { margin: 0; }
.chart-title { font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.chart-scroll { overflow-x: auto; }
.chart svg { width: 100%; height: auto; display: block; font-family: var(--font); }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .grid.base { stroke: #cfc9bc; }
.chart .tick, .chart .xlab { font-size: 10px; fill: var(--chart-ink); }
.chart .val { font-size: 10px; font-weight: 700; fill: var(--text); }
.chart .hit { fill: transparent; }
.chart .bar:hover path { opacity: .8; }
.chart .bar:hover .hit { fill: rgba(31, 93, 74, .06); }
.chart .bar.muted path { opacity: .35; }
.chart-empty { color: var(--muted); font-size: .9rem; padding: 1.5rem 0; text-align: center; border: 1px dashed var(--border); border-radius: 8px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat-row .tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; }
.stat-row .tile .num { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.stat-row .tile .label { font-size: .78rem; color: var(--muted); }
.att-strip { display: flex; flex-wrap: wrap; gap: 3px; margin: .25rem 0 .4rem; }
.att-strip span { width: 14px; height: 14px; border-radius: 3px; background: #cfe7da; }
.att-strip span.late { background: #eda100; }
.att-strip span.absent { background: #e34948; }
.att-strip span.present { background: #1f5d4a; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .78rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: .3rem; vertical-align: -1px; }
.hbars { display: grid; gap: .35rem; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 3.2rem; gap: .6rem; align-items: center; font-size: .88rem; }
.hbar .track { display: block; height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; background: var(--chart-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .v { text-align: end; font-variant-numeric: tabular-nums; font-weight: 600; }
.spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 22px; }
.spark i { width: 5px; background: var(--chart-1); border-radius: 2px 2px 0 0; min-height: 1px; }
.spark i.zero { background: var(--border); }
.flag { color: #8a5f12; font-weight: 600; }
@media screen and (max-width: 960px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.handover { border-inline-start: 4px solid var(--accent); }
.handover .badge.ai { background: #efe9fb; color: #5a43b8; border-color: #ddd3f5; }
.handover .plan { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .75rem .9rem; }
.handover .plan-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin-bottom: .35rem; }
.handover .tips { margin: .5rem 0 0; padding-inline-start: 1.1rem; font-size: .9rem; }
.handover-foot { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; margin-top: .75rem; }
h3.mini { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: .25rem 0; }
ul.dots { margin: 0; padding-inline-start: 1.1rem; font-size: .92rem; }
ul.dots.warn li::marker { color: var(--accent); }
.plan-inline { font-size: .82rem; background: #fbf6ea; border: 1px solid #f1e0bb; border-radius: 6px; padding: .35rem .6rem; margin: -.25rem 0 .75rem; }
.plan-inline b { color: #8a5f12; }
.badge.ai { background: #efe9fb; color: #5a43b8; border-color: #ddd3f5; }

/* ---------- bilingual / right-to-left ---------- */
[dir="rtl"] body { font-family: "Noto Sans Arabic", "Geeza Pro", "Segoe UI", Tahoma, system-ui, sans-serif; }
[data-back]::before { content: "← "; }
[data-next]::after { content: " →"; }
[dir="rtl"] [data-back]::before { content: "→ "; }
[dir="rtl"] [data-next]::after { content: " ←"; }
.chart svg { direction: ltr; }  /* time runs left to right in charts, in both languages */
[dir="rtl"] .hbar .fill { border-radius: 4px 0 0 4px; }
.lang-switch { display: inline-flex; gap: 2px; margin-top: .75rem; background: rgba(255,255,255,.12); border-radius: 8px; padding: 2px; }
.lang-switch button { border: 0; background: none; color: inherit; font: inherit; font-size: .82rem; padding: .25rem .6rem; border-radius: 6px; cursor: pointer; }
.lang-switch button[aria-current] { background: rgba(255,255,255,.9); color: var(--brand); font-weight: 700; cursor: default; }
.lang-auth { display: flex; justify-content: center; margin-top: 1rem; }
.lang-auth .lang-switch { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); margin: 0; }
.lang-auth .lang-switch button[aria-current] { background: var(--brand); color: #fff; }
@media screen and (max-width: 760px) {
  [dir="rtl"] .sidebar { inset: 0 0 0 auto; transform: translateX(100%); }
  [dir="rtl"] body.nav-open .sidebar { transform: none; }
}

/* ---------- session sheet (v1.4) ---------- */
.sheet-help { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem; margin-bottom: .75rem; font-size: .9rem; }
.sheet-help ol { margin: 0; padding-inline-start: 1.2rem; display: flex; flex-wrap: wrap; gap: .25rem 2rem; }
.sheet-toolbar { position: sticky; top: 0; z-index: 15; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; background: var(--bg); padding: .5rem 0; margin-bottom: .5rem; }
.sheet-toolbar input[type=search] { max-width: 260px; }
.counter { color: var(--muted); font-size: .9rem; margin-inline-start: auto; white-space: nowrap; }
.counter strong { color: var(--brand); font-size: 1.05rem; }
.sheet-row { border-inline-start: 4px solid var(--border); padding: .8rem 1rem; }
.sheet-row.is-touched, .sheet-row.is-done { border-inline-start-color: var(--brand); }
.sheet-row.is-absent { border-inline-start-color: var(--danger); background: var(--surface-2); }
.sheet-row.is-absent .row-body { display: none; }
.sheet-row .sname { font-weight: 700; color: var(--text); }
.sheet-top { margin-bottom: .5rem; }
.att-group label { padding: .55rem .9rem; font-size: .9rem; min-width: 4.5rem; text-align: center; }
.plan-inline { display: flex; gap: .75rem; align-items: center; justify-content: space-between; margin: 0 0 .6rem; }
.plan-inline span { margin-inline-end: .9rem; }
.plan-inline .plan-src { font-size: .72rem; color: var(--muted); font-weight: 600; margin-inline-start: .3rem; }
.plan-inline .tip { display: block; font-style: italic; color: #6b5a2e; }
.note-inputs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.note-inputs textarea, .more textarea { min-height: 2.4rem; overflow: hidden; }
details.more { margin-top: .5rem; }
details.more > summary { cursor: pointer; color: var(--brand); font-size: .88rem; font-weight: 600; padding: .25rem 0; list-style: revert; }
.more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem 1rem; margin-top: .5rem; }
.more-grid .field { margin: 0; }
fieldset.next-plan { border: 1px dashed var(--border); border-radius: 8px; margin: .75rem 0 0; padding: .5rem .75rem .75rem; }
fieldset.next-plan legend { font-weight: 600; font-size: .88rem; padding: 0 .3rem; }
.sticky-save .counter { margin-inline-end: auto; margin-inline-start: 0; }
@media screen and (max-width: 760px) {
  .note-inputs, .more-grid { grid-template-columns: 1fr; }
  .att-group { width: 100%; }
  .att-group label { flex: 1; }
  .plan-inline { flex-direction: column; align-items: stretch; }
  .sheet-toolbar input[type=search] { max-width: none; flex: 1 1 100%; }
}

/* ---------- folded sections (v1.4) ---------- */
details.fold { margin-top: 1rem; }
details.fold > summary { display: flex; align-items: baseline; gap: .75rem; cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0; }
details.fold > summary::after { content: "+"; margin-inline-start: auto; font-weight: 700; color: var(--brand); font-size: 1.2rem; line-height: 1; }
details.fold[open] > summary::after { content: "−"; }
details.fold[open] > summary { margin-bottom: .9rem; }
details.why { margin-top: .75rem; border-top: 1px solid var(--border); padding-top: .5rem; }
details.why > summary, details.more-fields > summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: .9rem; }
details.more-fields { margin: .25rem 0 1rem; }
details.more-fields[open] > summary { margin-bottom: .75rem; }
.plan-kv { font-size: 1rem; gap: .45rem 1.2rem; }
.plan-kv dt { padding-top: .1rem; }
.field > div[id] { display: flex; gap: .4rem 1.1rem; flex-wrap: wrap; }
.my-classes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.my-class { display: flex; flex-direction: column; gap: .35rem; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .75rem .9rem; }

/* ---------- class cards (v1.5) ---------- */
.note-inputs.cards-1 { grid-template-columns: 1fr; }
.note-inputs.cards-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.note-inputs.cards-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.note-inputs.cards-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.session-summary { margin-top: 1rem; }
.session-summary textarea { margin-top: .4rem; }
@media screen and (max-width: 760px) { .note-inputs[class*="cards-"] { grid-template-columns: 1fr; } }
.facts { display: flex; flex-wrap: wrap; gap: .3rem .9rem; align-items: center; margin: .25rem 0 0; color: var(--muted); }
.facts .fact { white-space: nowrap; }
.last-session { margin-bottom: 1rem; }
.last-session h2 { font-size: 1rem; }
.last-cards { display: grid; gap: .75rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.last-cards.n1 { grid-template-columns: 1fr; }
.last-cards.n2, .last-cards.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.last-cards.n5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.last-cards .card { margin: 0; border-top: 3px solid var(--brand); padding: .8rem .9rem; }
.last-cards .card:nth-child(2) { border-top-color: var(--accent); }
.last-cards .card:nth-child(3) { border-top-color: #6a8caf; }
.last-cards .card:nth-child(4) { border-top-color: #a35d6a; }
.last-cards .card:nth-child(5) { border-top-color: #6250d6; }
.last-cards h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .35rem; }
@media screen and (max-width: 960px) { .last-cards.n5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media screen and (max-width: 760px) { .last-cards[class*="n"] { grid-template-columns: 1fr 1fr; } }
.brief-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.brief-grid .card { margin: 0; }
.brief.flagged { border-inline-start: 4px solid var(--accent); }
.brief-head { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; margin-bottom: .6rem; }
.brief .mini { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: .5rem 0 .25rem; }
.brief-plan { background: #fbf6ea; border: 1px solid #f1e0bb; border-radius: 8px; padding: .35rem .7rem .55rem; }
.brief-plan .mini { color: #8a5f12; margin-top: .2rem; }
.brief .kv { gap: .2rem .8rem; }
.brief-level { margin: .6rem 0 0; }
.workflow { display: flex; flex-wrap: wrap; gap: .4rem; }
@media print { .brief-grid { grid-template-columns: 1fr 1fr; } .brief { break-inside: avoid; border: 1px solid #ddd !important; padding: .6rem !important; } }

/* ---------- course */
.course-card { margin-bottom: 1rem; }
.lesson-banner { background: var(--info-soft); border: 1px solid #cdd8ea; border-radius: var(--radius); padding: .65rem .85rem; margin-bottom: 1rem; }
.lesson-banner .mini { margin-bottom: .25rem; }
.lesson-body { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; }
.lesson-body .tip { color: var(--muted); font-style: italic; }
.course-card .lesson-banner { margin: 0; }
.goal-bar { height: 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin-bottom: .5rem; }
.goal-bar > span { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.goal p { margin: 0 0 .4rem; }
table.lessons td { vertical-align: top; }
table.lessons tr.past td { color: var(--muted); }
table.lessons tr.current td { background: var(--ok-soft); }
table.lessons.edit input[type=text], table.lessons.edit input[type=date] { width: 100%; min-width: 7rem; }
.pct { display: inline-flex; align-items: center; gap: .4rem; }
.pct .goal-bar { width: 60px; height: 6px; margin: 0; }
.stat .hint { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
@media print { .lesson-banner { break-inside: avoid; } }
.lesson-banner .mini { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }

/* ---------- needs attention */
ul.attention { list-style: none; margin: 0; padding: 0; }
ul.attention > li { padding: .65rem 0; border-top: 1px solid var(--border); }
ul.attention > li:first-child { border-top: 0; padding-top: .2rem; }
ul.attention .who { margin-bottom: .35rem; }
.reason { border-inline-start: 3px solid var(--accent); background: var(--warn-soft); border-radius: 6px; padding: .35rem .6rem; margin: .35rem 0 0; font-size: .88rem; }
.reason.absent { border-color: var(--danger); background: var(--danger-soft); }
.reason.stalled { border-color: #2a78d6; background: var(--info-soft); }
.reason.no_notes { border-color: var(--border); background: var(--surface-2); }
.reason .r-title { font-weight: 700; }
.reason .r-detail { color: var(--text); }
.reason .r-action { color: var(--brand); font-weight: 600; }
.brief-options label.check { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; margin: 0; }
.brief-level { margin: 0; }

/* =====================================================================
   Phone version (v1.9): app bar, bottom tabs, cards instead of tables,
   one-student-at-a-time recording. Desktop is unchanged.
   ===================================================================== */
.tabbar, .nav-scrim { display: none; }
.topbar svg, .tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.stepper, .mode-switch { display: none; }

@media screen and (max-width: 760px) {
  body { font-size: 16px; padding-bottom: env(safe-area-inset-bottom); }
  input[type=text], input[type=password], input[type=email], input[type=date], input[type=search],
  input[type=number], input[type=tel], select, textarea { font-size: 16px; padding: .65rem .75rem; } /* no zoom on iPhone */
  .btn { min-height: 44px; padding: .6rem 1rem; }
  .btn.sm { min-height: 38px; }

  /* app bar */
  .topbar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: .25rem; padding: calc(.35rem + env(safe-area-inset-top)) .5rem .35rem; min-height: 54px; }
  .topbar .brand { justify-content: center; min-width: 0; font-size: 1.02rem; }
  .topbar .brand .brand-mark { width: 28px; height: 28px; font-size: .9rem; }
  .topbar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar.has-title .brand-mark { display: none; }
  .topbar.has-title .topbar-title { opacity: 0; transition: opacity .15s; }
  .topbar.has-title.scrolled .topbar-title { opacity: 1; }
  .topbar-back, .topbar-menu { display: grid; place-items: center; width: 44px; height: 44px; color: #fff; border-radius: 10px; }
  .topbar-back[hidden] { display: grid; visibility: hidden; }
  .topbar-menu { visibility: hidden; } /* "More" in the tab bar opens the menu */
  [dir="rtl"] .topbar-back svg { transform: scaleX(-1); }
  .main .breadcrumb:has([data-back]) { display: none; }

  /* bottom tabs */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 10px rgba(31, 42, 36, .05); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; color: var(--muted); font: inherit; font-size: .7rem; font-weight: 600; background: none; border: 0; padding: .35rem 0; text-decoration: none !important; }
  .tabbar .active { color: var(--brand); }
  .tabbar .active svg { stroke-width: 2.3; }
  .main { padding: .9rem 1rem calc(96px + env(safe-area-inset-bottom)); }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 29; }
  body.nav-open .sidebar { box-shadow: none; }
  .sidebar { padding-top: calc(1.25rem + env(safe-area-inset-top)); overflow-y: auto; }
  .nav a { padding: .7rem .8rem; font-size: 1rem; }

  /* page header: big title, actions full width */
  h1 { font-size: 1.45rem; }
  .page-head { align-items: stretch; margin-bottom: 1rem; }
  .page-head > div:first-child { width: 100%; }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; }
  /* the page's main "+ Add" action floats above the tabs */
  [data-fab] { position: fixed; z-index: 24; inset-inline-end: 1rem; bottom: calc(72px + env(safe-area-inset-bottom)); border-radius: 999px; padding: .8rem 1.2rem; box-shadow: 0 6px 18px rgba(31, 93, 74, .35); flex: none !important; }

  /* tables become a list of cards */
  .table-wrap { overflow: visible; }
  .card.table-wrap { padding: .25rem .9rem !important; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: .75rem 0; border-bottom: 1px solid var(--border); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack tbody tr:hover { background: none; }
  table.stack td { border: 0; padding: .15rem 0; display: flex; gap: .75rem; justify-content: space-between; align-items: baseline; text-align: end; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; text-align: start; flex: none; max-width: 45%; }
  table.stack td:first-child { display: block; text-align: start; font-size: 1.02rem; padding-bottom: .3rem; }
  table.stack td:first-child::before, table.stack td:not([data-label])::before, table.stack td[data-label=""]::before { content: none; }
  table.stack td:empty { display: none; }
  table.stack td.empty { display: block; text-align: center; }
  table.stack td .who { display: inline-flex; }
  table.lessons.edit td { display: block; text-align: start; }
  table.lessons.edit td::before { display: block; margin-bottom: .2rem; }

  /* filters */
  .filters select, .filters input[type=date] { flex: 1 1 40%; width: auto; }
  .filters .btn { flex: 1 1 auto; }

  /* home: my classes first, compact numbers */
  .is-home .main { display: flex; flex-direction: column; }
  .is-home .home-classes { order: -1; margin-top: 0; }
  .is-home .page-head { order: -2; }
  .is-home .home-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
  .is-home .home-stats .stat { padding: .55rem .5rem; text-align: center; }
  .is-home .home-stats .num { font-size: 1.3rem; }
  .is-home .home-stats .label { font-size: .68rem; line-height: 1.2; }
  .my-classes { grid-template-columns: 1fr; }
  .my-class .workflow { display: grid; gap: .5rem; width: 100%; }
  .my-class .workflow .btn { width: 100%; min-height: 48px; font-size: 1rem; }

  /* misc */
  .brief-grid { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: minmax(70px, 110px) 1fr 2.6rem; }
  .profile-head .avatar.lg { width: 52px; height: 52px; }
  .kv { grid-template-columns: minmax(80px, max-content) 1fr; }
  .card { padding: 1rem; }
  .list li > .btn { flex: none; }
  .messages li { font-size: .95rem; }

  /* ---------- session sheet: one student at a time ---------- */
  .focus-mode .tabbar { display: none; }
  .focus-mode .main { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
  .mode-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); width: 100%; }
  .mode-switch button { flex: 1; border: 0; background: none; font: inherit; font-weight: 600; padding: .6rem; color: var(--muted); min-height: 44px; }
  .mode-switch button[aria-pressed="true"] { background: var(--brand); color: #fff; }
  .sheet-help { display: none; }
  .sheet-toolbar { position: static; }
  .one-by-one .sheet-row:not(.current), .one-by-one .no-match, .one-by-one #find, .one-by-one #all-present { display: none !important; }
  .one-by-one .sheet-row.current { margin-bottom: 1rem; }
  .one-by-one .sheet-row .sname { font-size: 1.2rem; }
  .one-by-one .att-group label { min-height: 52px; display: flex; align-items: center; justify-content: center; font-size: 1rem; }
  .one-by-one .session-summary { display: none; }
  .one-by-one.at-end .session-summary { display: block; }
  .sticky-save { position: fixed; inset: auto 0 0 0; z-index: 26; background: var(--surface); border-top: 1px solid var(--border); padding: .5rem .75rem calc(.5rem + env(safe-area-inset-bottom)); }
  .sticky-save .btn[name="save_continue"] { display: none; }
  .sticky-save .btn.primary { flex: 1; }
  .one-by-one .stepper { display: grid; grid-template-columns: 52px 1fr 52px; gap: .5rem; align-items: center; position: fixed; inset: auto 0 calc(62px + env(safe-area-inset-bottom)) 0; z-index: 26; padding: .5rem .75rem; background: var(--surface-2); border-top: 1px solid var(--border); }
  .stepper button { min-height: 48px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 1.4rem; font-weight: 700; color: var(--brand); }
  .stepper button:disabled { opacity: .35; }
  .stepper select { min-height: 48px; font-weight: 600; text-align: center; }
}
@media screen and (max-width: 760px) {
  .brief-grid > *, .grid > *, .split > * { min-width: 0; }
  .brief-head { flex-wrap: wrap; }
  .brief-head .nowrap { white-space: normal; }
  .brief-options label.check { flex: 1 1 40%; }
  .lesson-banner .mini { white-space: normal; }
}

/* ---------- Ihsan Academy brand (v1.10) ---------- */
img.brand-mark { background: none; display: block; border-radius: 8px; object-fit: contain; }
.auth .brand { flex-direction: column; gap: .6rem; font-size: 1.25rem; }
.auth .brand img.brand-mark { width: 64px; height: 64px; border-radius: 14px; }

/* ---------- paper sheets (v1.12) ---------- */
.sheet-row.from-scan { border-inline-start-color: #5a43b8; }
.scan-banner { margin-bottom: .75rem; }
.cam-start { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin-bottom: 1rem; }
.cam-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.cam { margin-bottom: 1rem; scroll-margin-top: 70px; }
.cam-view { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; }
.cam-view video { display: block; width: 100%; max-height: 70vh; object-fit: contain; }
.cam-guide { position: absolute; inset: 7% 5%; border: 2px dashed rgba(255, 255, 255, .8); border-radius: 6px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .25); pointer-events: none; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.on { animation: cam-flash .35s ease-out; }
@keyframes cam-flash { from { opacity: .85; } to { opacity: 0; } }
.cam-tip { margin: .5rem 0; }
.cam-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .75rem; }
.cam-controls #cam-switch { justify-self: start; }
.cam-controls #cam-close { justify-self: end; }
.cam-shutter { width: 68px; height: 68px; border-radius: 50%; border: 4px solid var(--brand); background: #fff; box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 30px var(--brand); cursor: pointer; }
.cam-shutter:active { transform: scale(.94); }
.cam-shutter:disabled { opacity: .4; }
.cam-pages { margin-bottom: 1rem; }
.cam-pages .mini { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin-bottom: .35rem; }
.cam-thumbs { display: flex; flex-wrap: wrap; gap: .6rem; }
.cam-thumbs figure { position: relative; margin: 0; width: 120px; }
.cam-thumbs img { width: 120px; height: 85px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.cam-thumbs figcaption { font-size: .75rem; color: var(--muted); text-align: center; }
.cam-remove { position: absolute; top: -8px; inset-inline-end: -8px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-size: 1rem; line-height: 1; cursor: pointer; }
@media screen and (max-width: 760px) { .cam-btn { width: 100%; min-height: 52px; font-size: 1.05rem; } .cam-view video { max-height: 60vh; } }

/* ---------- one colour per field, everywhere (v1.14) ----------
   Review = blue, New memorization = green, Reading = purple, Focus = orange, custom fields = teal. */
:root {
  --f-review: #2a6fd6;        --f-review-bg: #e8f0fc;        --f-review-ink: #1b4a91;
  --f-memorized: #1f8a5b;     --f-memorized-bg: #e3f4ea;     --f-memorized-ink: #145c3c;
  --f-currently_reading: #7b57c9; --f-currently_reading-bg: #f0eafb; --f-currently_reading-ink: #4f3391;
  --f-focus_on: #d9782d;      --f-focus_on-bg: #fcefe3;      --f-focus_on-ink: #8a4410;
  --f-custom: #1b8a8f;        --f-custom-bg: #e2f4f4;        --f-custom-ink: #11585b;
}
.fk-review { --f: var(--f-review); --f-bg: var(--f-review-bg); --f-ink: var(--f-review-ink); }
.fk-memorized { --f: var(--f-memorized); --f-bg: var(--f-memorized-bg); --f-ink: var(--f-memorized-ink); }
.fk-currently_reading { --f: var(--f-currently_reading); --f-bg: var(--f-currently_reading-bg); --f-ink: var(--f-currently_reading-ink); }
.fk-focus_on { --f: var(--f-focus_on); --f-bg: var(--f-focus_on-bg); --f-ink: var(--f-focus_on-ink); }
[class*="fk-custom"] { --f: var(--f-custom); --f-bg: var(--f-custom-bg); --f-ink: var(--f-custom-ink); }

/* label in the field's colour, value highlighted like a marker */
dt[class*="fk-"], .label[class*="fk-"], h3[class*="fk-"], label[class*="fk-"] { color: var(--f-ink); font-weight: 700; }
.fv[class*="fk-"] { background: var(--f-bg); color: var(--f-ink); border-inline-start: 3px solid var(--f); border-radius: 4px; padding: .1rem .45rem; }
dd.fv { margin-bottom: .15rem; }
span.fv { display: inline-block; }
.brief .kv { align-items: start; }
.brief .kv dt { padding-top: .12rem; }
/* student page "last session" cards */
.last-cards .card[class*="fk-"] { border-top-color: var(--f); background: linear-gradient(var(--f-bg), var(--f-bg)) top / 100% 2.4rem no-repeat, var(--surface); }
/* session sheet: coloured edge on each field, and plan chips */
.note-inputs .field[class*="fk-"] textarea, .note-inputs .field[class*="fk-"] input { border-inline-start: 4px solid var(--f); }
.plan-inline .chip { background: var(--f-bg); color: var(--f-ink); border-radius: 999px; padding: .05rem .55rem; }
.plan-inline .chip strong { color: inherit; }
/* timeline notes */
.note-fields > [class*="fk-"] .pre { display: inline-block; }
/* printed paper sheet: tinted column headers */
table.paper-table th[class*="fk-"] { background: var(--f-bg) !important; color: var(--f-ink); border-top: 3px solid var(--f); }
th[class*="fk-"] { color: var(--f-ink); }
@media print { .fv[class*="fk-"], table.paper-table th[class*="fk-"] { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* ---------- shared class day (v1.15) ---------- */
.shared-note { display: flex; flex-wrap: wrap; gap: .3rem 1rem; align-items: center; font-size: .9rem; margin-bottom: .6rem; }
.shared-note select { width: auto; margin-inline-start: .4rem; }
.sheet-filter { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); margin-bottom: .5rem; }
.sheet-filter button { border: 0; background: none; font: inherit; font-weight: 600; padding: .45rem .8rem; color: var(--muted); cursor: pointer; }
.sheet-filter button span { font-weight: 700; color: var(--text); margin-inline-start: .2rem; }
.sheet-filter button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.sheet-filter button[aria-pressed="true"] span { color: #fff; }
.sheet-row.filtered-out { display: none !important; }
.badge.with-teacher { background: var(--info-soft); color: #2d4a7a; border-color: #cdd8ea; }
.att-summary { margin-bottom: 1rem; }
.att-summary .stat.warn .num { color: var(--accent); }
@media screen and (max-width: 760px) { .sheet-filter { display: flex; width: 100%; } .sheet-filter button { flex: 1; min-height: 44px; } }

/* ---------- print: never print the app's own controls (tab bar, menus, floating buttons) ---------- */
@media print {
  .tabbar, .topbar, .sidebar, .nav-scrim, .sticky-save, .stepper, [data-fab], .no-print, .messages { display: none !important; }
  body { padding: 0 !important; }
  .main { padding: 0 !important; }
}

/* ---------- students: totals and last note (v1.16) ---------- */
.student-totals { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.student-totals a.tile { color: inherit; text-decoration: none; }
.student-totals a.tile:hover { border-color: var(--brand); }
.last-note { display: inline-flex; flex-direction: column; gap: .15rem; color: inherit; text-decoration: none !important; }
.last-note .nowrap { font-weight: 600; }
.last-note .ln-what .fv { font-size: .82rem; }
.last-note .badge { align-self: flex-start; }
@media screen and (max-width: 760px) { .student-totals { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; } .student-totals .tile { padding: .45rem .4rem; text-align: center; } .student-totals .tile .num { font-size: 1.15rem; } }
.backup-reminder { margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: .3rem .8rem; align-items: center; }
.backup-status { margin: 0 0 .8rem; }
.backup-status.overdue { color: #8a5f12; font-weight: 600; }
.backup-now, .backup-confirm { margin-bottom: 1rem; }

/* ---------- activity log (v1.17) ---------- */
.activity { padding: .25rem 1rem; }
.act { display: grid; grid-template-columns: 7.5rem 1fr; gap: .25rem 1rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.act:first-child { border-top: 0; }
.act.danger { box-shadow: inset 3px 0 0 var(--danger); padding-inline-start: .6rem; }
[dir="rtl"] .act.danger { box-shadow: inset -3px 0 0 var(--danger); }
.act-when { font-size: .88rem; }
.act-head { line-height: 1.45; }
.act-head .badge { margin-inline-start: .25rem; }
.act details { margin-top: .3rem; }
.act summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.act-rows { list-style: none; margin: .4rem 0; padding: 0; }
.act-rows > li { padding: .35rem 0; border-top: 1px dashed var(--border); }
.act-rows > li:first-child { border-top: 0; }
.act-row-title { font-size: .88rem; font-weight: 600; margin-bottom: .2rem; }
table.act-changes { width: auto; font-size: .86rem; border-collapse: collapse; }
table.act-changes th { text-align: start; font-weight: 600; color: var(--muted); padding: .15rem 0; padding-inline-end: .8rem; vertical-align: top; white-space: nowrap; text-transform: none; letter-spacing: 0; background: none; border: 0; }
table.act-changes td { padding: .15rem 0; border: 0; white-space: pre-wrap; }
table.act-changes del { color: var(--danger); text-decoration-thickness: 1px; }
table.act-changes .new { color: #1d6b45; font-weight: 600; }
table.act-changes .arrow { color: var(--muted); }
.activity-filters label { display: inline-flex; align-items: center; gap: .3rem; }
@media screen and (max-width: 760px) {
  .act { grid-template-columns: 1fr; gap: .1rem; }
  .act-when { color: var(--muted); }
  table.act-changes th { white-space: normal; }
}

/* ---------- attendance days (v1.18) ---------- */
.day-note { background: var(--info-soft); border: 1px solid #cdd8ea; border-radius: 8px; padding: .45rem .7rem; margin: 0 0 .7rem; }
.day-counts { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 .5rem; }
.badge.muted-badge { color: var(--muted); }
@media print { .print-day { display: block !important; } }
.day-fields { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem .4rem; margin: 0 0 .6rem; }
.day-fields legend { font-weight: 600; padding: 0 .3rem; }
.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem .75rem; }
.day-cell { display: flex; flex-direction: column; gap: .2rem; font-weight: 600; font-size: .9rem; margin: 0; }
.day-cell select { font-weight: 400; }
.day-fields .help { color: var(--muted); font-size: .8rem; margin: .5rem 0 0; }
.schedule-totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.schedule-totals .tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .55rem .75rem; font-size: .9rem; }
.schedule-totals .label { font-weight: 700; margin-bottom: .2rem; }
.schedule-table td { vertical-align: middle; }
.schedule-table select.sched { min-width: 8.5rem; }
.schedule-table select.sched.on { background: var(--info-soft); border-color: #cdd8ea; }
.schedule-table select.sched.me { background: var(--ok-soft); border-color: #cfe7da; font-weight: 600; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding: .6rem 0; display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.badge.comes-to { background: var(--surface-2); color: var(--muted); }

/* ---------- moving between student profiles (v1.20) ---------- */
.profile-nav { display: flex; align-items: center; gap: .5rem; margin: 0 0 .9rem; flex-wrap: wrap; }
.profile-nav .profile-jump { display: flex; align-items: center; gap: .5rem; flex: 1 1 14rem; min-width: 0; margin: 0; }
.profile-nav select { flex: 1 1 auto; min-width: 0; max-width: 22rem; }
.profile-nav .btn.disabled { opacity: .4; pointer-events: none; }
[dir="rtl"] .profile-nav [aria-hidden="true"] { display: inline-block; transform: scaleX(-1); }
@media screen and (max-width: 760px) {
  .profile-nav { display: grid; grid-template-columns: auto 1fr auto; }
  .profile-nav .profile-jump { flex-direction: column; align-items: stretch; gap: .1rem; text-align: center; }
  .profile-nav select { max-width: none; }
}
[dir="rtl"] .flip-rtl { display: inline-block; transform: scaleX(-1); }

/* ---------- progress overview (v1.21): tiles, tabs, one section at a time ---------- */
.ov-head .actions { align-items: center; }
.ov-filters { display: flex; gap: .4rem; flex-wrap: wrap; }
.ov-filters select { width: auto; }
.ov-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-bottom: .9rem; }
.ov-tile { display: flex; flex-direction: column; gap: .15rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .85rem; color: inherit; text-decoration: none !important; transition: border-color .15s; }
.ov-tile:hover { border-color: var(--brand); }
.ov-tile .num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ov-tile .num small { font-size: .95rem; color: var(--muted); font-weight: 600; }
.ov-tile .label { color: var(--muted); font-size: .82rem; line-height: 1.3; }
.ov-tile.warn .num { color: #a65f00; }
.ov-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: .9rem; overflow-x: auto; scrollbar-width: none; }
.ov-tabs button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: .55rem .85rem; border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.ov-tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.ov-tabs .count { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .78rem; text-align: center; }
.ov-tabs .count.warn { background: var(--warn-soft); color: #8a5f12; }
body:not(.ov-js) .ov-tabs { display: none; }
body:not(.ov-js) .ov-panel { margin-bottom: 1rem; }
.ov-panel.card { padding: .8rem .9rem; }
.ov-tools { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin-bottom: .6rem; }
.ov-tools input[type=search] { max-width: 260px; }
.ov-tools .check { display: inline-flex; gap: .35rem; align-items: center; margin: 0; font-weight: 500; }
.ov-hint { margin-inline-start: auto; }
.ov-foot { margin: .6rem 0 0; }
table.ov-table { width: 100%; }
table.ov-table th button { border: 0; background: none; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; padding: 0; cursor: pointer; }
table.ov-table th button::after { content: " ↕"; opacity: .35; }
table.ov-table th button.asc::after { content: " ↑"; opacity: 1; }
table.ov-table th button.desc::after { content: " ↓"; opacity: 1; }
table.ov-table td { vertical-align: top; }
table.ov-table .c-name strong { font-weight: 600; }
.flag { display: inline-block; font-size: .7rem; font-weight: 700; padding: .05rem .4rem; border-radius: 999px; margin-inline-start: .3rem; vertical-align: 1px; cursor: help; }
.flag.absent { background: var(--danger-soft); color: var(--danger); }
.flag.practice { background: var(--warn-soft); color: #8a5f12; }
.flag.stalled { background: var(--info-soft); color: #2d4a7a; }
.flag.no_notes { background: var(--surface-2); color: var(--muted); }
table.ov-table .spark { margin-inline-start: .35rem; vertical-align: -4px; }
/* Needs attention: grouped, one line per student */
.need-group { display: block; border: 1px solid var(--border); border-radius: 10px; margin-bottom: .6rem; overflow: hidden; }
.need-group > summary { cursor: pointer; padding: .55rem .8rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; background: var(--surface-2); list-style: none; }
.need-group > summary::-webkit-details-marker { display: none; }
.need-group > summary::after { content: "▾"; margin-inline-start: auto; color: var(--muted); }
.need-group:not([open]) > summary::after { content: "▸"; }
.need-group .count { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 .5em; font-size: .78rem; }
.need-dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--accent); flex: none; }
.need-group.absent .need-dot { background: var(--danger); }
.need-group.stalled .need-dot { background: #2a78d6; }
.need-group.no_notes .need-dot { background: var(--border); }
.need-rows { list-style: none; margin: 0; padding: 0; }
.need-rows li { padding: .5rem .8rem; border-top: 1px solid var(--border); display: grid; grid-template-columns: minmax(9rem, 14rem) 1fr; gap: .1rem 1rem; align-items: baseline; }
.need-rows .need-who { grid-row: span 2; }
.need-rows .need-name { font-weight: 600; }
.need-rows .need-who .muted { display: block; }
.need-detail { font-size: .88rem; }
.need-action { font-size: .85rem; color: var(--brand); font-weight: 600; }
.hbars-cols { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); column-gap: 2rem; }
@media screen and (max-width: 960px) { .ov-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media screen and (max-width: 760px) {
  .ov-head .actions { width: 100%; }
  .ov-filters { flex: 1 1 100%; }
  .ov-filters select { flex: 1 1 0; min-width: 0; }
  .ov-tiles { gap: .4rem; }
  .ov-tile { padding: .5rem .6rem; }
  .ov-tile .num { font-size: 1.3rem; }
  .ov-tile .label { font-size: .74rem; }
  .ov-hint { display: none; }
  .ov-tools input[type=search] { max-width: none; flex: 1 1 100%; }
  .ov-panel.card { padding: .5rem .6rem; }
  /* Students as compact cards: name, then three numbers, then where they are and what is next. */
  table.ov-table thead { display: none; }
  table.ov-table, table.ov-table tbody { display: block; }
  table.ov-table tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .25rem .6rem; padding: .65rem .1rem; border-top: 1px solid var(--border); }
  table.ov-table tr:first-child { border-top: 0; }
  table.ov-table tr[hidden] { display: none; }
  table.ov-table td { display: block; border: 0; padding: 0; font-size: .9rem; }
  table.ov-table td::before { content: attr(data-label); display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
  table.ov-table td.c-name, table.ov-table td.c-now, table.ov-table td.c-next { grid-column: 1 / -1; }
  table.ov-table td.c-came { order: 1; } table.ov-table td.c-new { order: 2; } table.ov-table td.c-known { order: 3; }
  table.ov-table td.c-now { order: 4; } table.ov-table td.c-next { order: 5; }
  table.ov-table td.c-name::before { display: none; }
  table.ov-table td.c-name .muted { display: inline; margin-inline-start: .3rem; }
  table.ov-table td.c-now, table.ov-table td.c-next { display: flex; gap: .4rem; align-items: baseline; }
  table.ov-table td.c-now::before, table.ov-table td.c-next::before { flex: none; min-width: 7.5rem; }
  table.ov-table td.c-came .muted, table.ov-table td.c-known .muted { display: inline; margin-inline-start: .25rem; }
  table.ov-table .spark { display: none; }
  .need-rows li { grid-template-columns: 1fr; }
  .need-rows .need-who { grid-row: auto; }
  .need-rows .need-who .muted { display: inline; }
  table.ov-table td.hide-sm { display: none; }
  .hbars-cols { grid-template-columns: 1fr; }
}
@media print { .ov-tabs, .ov-tools, .ov-filters { display: none !important; } .ov-panel[hidden] { display: block !important; } }
table.ov-table th { white-space: nowrap; }
.main { min-width: 0; }  /* a wide child (e.g. a scrolling tab bar) must not widen the page */
.ov-tabs { max-width: 100%; }

/* ---------- class page (v1.22): the day's steps, a Manage menu, tabs with sessions ---------- */
.class-head { align-items: flex-start; }
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-items { position: absolute; inset-inline-end: 0; top: calc(100% + .3rem); z-index: 30; min-width: 14rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(31, 42, 36, .12); padding: .3rem; display: flex; flex-direction: column; }
.menu-items a { padding: .55rem .7rem; border-radius: 6px; color: var(--text); text-decoration: none !important; font-weight: 500; }
.menu-items a:hover { background: var(--surface-2); }
.menu-items a.danger { color: var(--danger); }
.menu-items hr { border: 0; border-top: 1px solid var(--border); margin: .25rem 0; }
.day-steps { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 1rem; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; display: flex; flex-direction: column; gap: .7rem; justify-content: space-between; }
.step.main-step { border-color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }
.step-head { display: flex; gap: .7rem; align-items: flex-start; }
.step-head h2 { margin: 0; font-size: 1.05rem; }
.step-head p { margin: .15rem 0 0; }
.step-n { flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.main-step .step-n { background: var(--brand); color: #fff; }
.step-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.panel-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.panel-head .day-counts { margin: 0; }
.panel-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
details.month { border-top: 1px solid var(--border); }
details.month:first-child { border-top: 0; }
details.month > summary { cursor: pointer; padding: .6rem .2rem; display: flex; gap: .5rem; align-items: center; list-style: none; }
details.month > summary::-webkit-details-marker { display: none; }
details.month > summary::after { content: "▾"; margin-inline-start: auto; color: var(--muted); }
details.month:not([open]) > summary::after { content: "▸"; }
details.month .count { background: var(--surface-2); border-radius: 999px; padding: 0 .5em; font-size: .78rem; color: var(--muted); }
.session-rows { list-style: none; margin: 0 0 .5rem; padding: 0; }
.session-rows li { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr) 11rem auto; gap: .3rem 1rem; align-items: center; padding: .5rem .2rem; border-top: 1px dashed var(--border); }
.session-rows li.today { background: var(--ok-soft); border-radius: 8px; }
.session-rows .s-date { color: inherit; text-decoration: none; }
.s-att { display: flex; align-items: center; gap: .5rem; }
.meter { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; min-width: 3rem; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.s-actions { display: flex; gap: .3rem; justify-content: flex-end; }
@media screen and (max-width: 760px) {
  .day-steps { grid-template-columns: 1fr; gap: .6rem; }
  .step { padding: .7rem .8rem; gap: .55rem; }
  .step-actions .btn { flex: 1 1 auto; }
  .session-rows li { grid-template-columns: 1fr auto; }
  .session-rows .s-teachers { grid-column: 1 / -1; grid-row: 2; }
  .session-rows .s-att { grid-column: 1 / -1; }
  .session-rows .s-actions { grid-column: 2; grid-row: 1; }
  .menu-items { min-width: 12rem; }
}

/* ---------- one header for a class's teaching-day pages (v1.23) ---------- */
.class-crumb { display: flex; align-items: center; gap: .35rem; }
.class-crumb .sep { color: var(--muted); }
.class-steps { display: flex; flex-wrap: wrap; gap: .5rem; margin: .1rem 0 1rem; }
.cs-group { display: inline-flex; align-items: center; gap: .2rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .2rem; }
.cs-label { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 0 .55rem 0 .25rem; }
.cs-n { width: 1.35rem; height: 1.35rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: .75rem; color: var(--text); }
.cs-link { padding: .35rem .8rem; border-radius: 999px; font-weight: 600; font-size: .9rem; color: var(--text); text-decoration: none !important; white-space: nowrap; }
.cs-link:hover { background: var(--surface-2); }
.cs-link.current { background: var(--brand); color: #fff; }
.toolbar-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; margin-bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.toolbar-row .tb-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); min-width: 3.5rem; }
.toolbar-row label { display: inline-flex; align-items: center; gap: .35rem; margin: 0; font-weight: 500; font-size: .9rem; }
.toolbar-row select, .toolbar-row input[type=date], .toolbar-row input[type=number] { width: auto; }
.toolbar-note { font-size: .85rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: .45rem; }
@media screen and (max-width: 760px) {
  .class-steps { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -1rem; padding-inline: 1rem; }
  .cs-group { flex: none; }
  .toolbar-row .tb-title { min-width: 100%; }
}
.page-head .actions details.menu { display: inline-block; }
.class-crumb [data-back]::before { content: none; }
.howto { font-size: .85rem; }
.howto > summary { cursor: pointer; color: var(--brand); font-weight: 600; width: max-content; }
.howto ol { margin: .4rem 0 0; padding-inline-start: 1.2rem; color: var(--muted); }

/* ---------- paper sheet in its own window (v1.23.1) ---------- */
body.popup-page { background: var(--bg); }
.popup-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; background: var(--surface); border-bottom: 1px solid var(--border); padding: .6rem 1.2rem; }
.popup-title { display: flex; align-items: center; gap: .6rem; }
.popup-title img { width: 32px; height: 32px; }
.popup-title strong { display: block; font-size: 1.05rem; }
.popup-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.popup-main { max-width: 1180px; margin: 0 auto; padding: 1rem 1.2rem 2rem; }
.cs-link .ext { font-size: .8em; opacity: .7; margin-inline-start: .15rem; }
@media screen and (max-width: 760px) { .popup-bar { padding: .5rem .8rem; } .popup-main { padding: .8rem .8rem 2rem; } }
.popup-actions [hidden] { display: none !important; }

/* ---------- class dashboard (v1.24): one top and one row of tabs on every page of a class ---------- */
.class-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.class-title h1 { margin: 0; }
.class-title .sub { margin: .2rem 0 0; }
.today-strip { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; align-items: center; margin: .8rem 0 .3rem; font-size: .9rem; }
.today-strip .ts-day { background: var(--brand); color: #fff; border-radius: 999px; padding: .15rem .7rem; }
.today-strip .ts-day strong { color: #fff; }
.class-tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin: .5rem 0 1rem; overflow-x: auto; scrollbar-width: none; }
.class-tabs a { padding: .6rem .9rem; font-weight: 600; color: var(--muted); text-decoration: none !important; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.class-tabs a:hover { color: var(--text); }
.class-tabs a.current { color: var(--brand); border-bottom-color: var(--brand); }
.class-tabs .count { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--ok-soft); color: #1d6b45; font-size: .75rem; text-align: center; }
.tab-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.tab-head h2 { margin: 0; font-size: 1.15rem; }
.tab-head .sub { margin: .1rem 0 0; color: var(--muted); font-size: .9rem; }
.tab-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
@media screen and (max-width: 760px) {
  .class-tabs { margin-inline: -1rem; padding-inline: .5rem; }
  .class-tabs a { padding: .55rem .7rem; }
}
.start-today { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.5rem; padding: 1.4rem; }
.start-today h2 { margin: 0 0 .3rem; }
.start-today h3 { font-size: .95rem; margin: 0 0 .4rem; }
.start-other { display: flex; flex-direction: column; gap: 1rem; border-inline-start: 1px solid var(--border); padding-inline-start: 1.5rem; }
.btn.lg { padding: .8rem 1.4rem; font-size: 1.05rem; }
.inline-form { display: flex; gap: .4rem; }
.inline-form input { width: auto; }
@media screen and (max-width: 760px) { .start-today { grid-template-columns: 1fr; } .start-other { border: 0; padding: 0; } .start-today .btn.lg { width: 100%; } }
.brief-head { display: block; }
.brief-head .who { align-items: flex-start; }
.bh-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.bh-text strong { font-size: 1rem; }
.bh-name .flag { margin-inline-start: .35rem; vertical-align: 2px; }
.bh-meta { color: var(--muted); font-size: .85rem; line-height: 1.35; }
.print-only { display: none; }
@media print { .print-only { display: inline; } .tab-head { margin-bottom: .5rem; } }
.add-session { display: flex; gap: .4rem; align-items: center; }
.add-session input { width: auto; }
.sessions-card { padding: .4rem 1rem; }
/* Tabs as clear buttons (v1.25) */
.class-tabs { display: inline-flex; gap: .3rem; border: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: .3rem; margin: .7rem 0 1.1rem; max-width: 100%; }
.class-tabs a { border: 0; margin: 0; border-radius: 9px; padding: .55rem 1.3rem; font-size: 1rem; color: var(--text); }
.class-tabs a:hover { background: var(--surface); }
.class-tabs a.current { background: var(--brand); color: #fff; border: 0; box-shadow: 0 2px 6px rgba(31, 93, 74, .25); }
@media screen and (max-width: 760px) { .class-tabs { display: flex; margin-inline: 0; padding: .25rem; } .class-tabs a { flex: 1; text-align: center; padding: .55rem .4rem; } }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg label { padding: .3rem .75rem; cursor: pointer; margin: 0; font-weight: 600 !important; }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg label.on { background: var(--brand); color: #fff; }
.students-list { padding: .3rem 1rem; }
/* Teachers and today's summary on one line (v1.25.1) */
.class-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .85rem; margin-top: .3rem; color: var(--muted); font-size: .92rem; }
.class-meta strong { color: var(--text); }
.class-meta .ts-day { background: none; padding: 0; border-radius: 0; color: var(--brand); font-weight: 600; }
.class-meta .ts-day strong { color: var(--brand); }
.class-meta > span:nth-child(3) { color: var(--text); }
.class-title { flex: 1; min-width: 0; }
/* Class info row (v1.25.2): icon + text items with thin dividers, and a status badge */
.class-meta { gap: .35rem 0; font-size: .92rem; color: var(--text); align-items: center; }
.class-meta .cm-item { display: inline-flex; align-items: center; gap: .4rem; padding: 0 .85rem; border-inline-start: 1px solid var(--border); line-height: 1.3; }
.class-meta .cm-item:first-child { padding-inline-start: 0; border-inline-start: 0; }
.class-meta .cm-item svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.class-meta .cm-today { color: var(--brand); font-weight: 600; }
.class-meta .cm-today svg { stroke: var(--brand); }
.class-meta .cm-status { margin-inline-start: .3rem; font-size: .8rem; font-weight: 600; padding: .15rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.class-meta .cm-status.started { background: var(--ok-soft); color: #1d6b45; border-color: #cfe7da; text-decoration: none; }
.class-meta .cm-status.started:hover { border-color: #1d6b45; }
@media screen and (max-width: 760px) {
  .class-meta { flex-direction: column; align-items: flex-start; gap: .3rem; }
  .class-meta .cm-item { padding: 0; border: 0; }
  .class-meta .cm-status { margin: .15rem 0 0; }
}
/* Students tab options in one row (v1.25.3) */
.toolbar-row.one-row { gap: .45rem .6rem; }
.toolbar-row.one-row label { font-size: .88rem; gap: .3rem; }
.toolbar-row.one-row select, .toolbar-row.one-row input[type=date] { padding: .35rem .5rem; font-size: .88rem; min-height: 0; }
.toolbar-row.one-row .seg label { padding: .3rem .7rem; }
.tb-sep { width: 1px; align-self: stretch; background: var(--border); margin: .15rem .1rem; }
@media screen and (max-width: 760px) { .tb-sep { display: none; } }
.toolbar-row.one-row select { max-width: 9.5rem; }
.toolbar-row.one-row select[name=teacher] { max-width: 10rem; }
.toolbar-row.one-row input[type=date] { width: 8.6rem; }

/* ---------- phone-friendly pass (v1.26) ---------- */
.show-phone { display: none; }
.tb-fold > summary { display: none; }
.tb-fold { display: contents; }
@media screen and (max-width: 760px) {
  .hide-phone { display: none !important; }
  .show-phone { display: inline; }
  /* class pages: a compact top so the content starts higher */
  .class-top { gap: .6rem; }
  .class-title h1 { font-size: 1.35rem; line-height: 1.2; }
  .class-top details.menu > summary.btn { padding: .4rem .7rem; font-size: .88rem; }
  .class-meta { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .2rem .7rem; font-size: .84rem; margin-top: .25rem; }
  .class-meta .cm-item:first-child { flex-basis: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
  .class-meta .cm-item:first-child svg { display: inline-block; vertical-align: -3px; margin-inline-end: .35rem; }
  .class-meta .cm-item svg { width: 14px; height: 14px; }
  .class-meta .cm-status { font-size: .74rem; padding: .1rem .5rem; margin: 0; }
  .class-tabs { margin: .55rem 0 .8rem; }
  .class-tabs a { padding: .5rem .3rem; font-size: .95rem; }
  .tab-head { margin-bottom: .6rem; gap: .4rem .6rem; }
  .tab-head h2 { font-size: 1.02rem; }
  .tab-actions { width: 100%; flex-wrap: nowrap; }
  .tab-actions .btn { flex: 1 1 0; padding: .55rem .5rem; font-size: .88rem; white-space: nowrap; }
  /* options folded into one line */
  .tb-fold { display: block; }
  .tb-fold > summary { display: flex; align-items: center; gap: .5rem; cursor: pointer; list-style: none; padding: .15rem 0; min-height: 36px; }
  .tb-fold > summary::-webkit-details-marker { display: none; }
  .tb-fold > summary::after { content: "▾"; margin-inline-start: auto; color: var(--muted); }
  .tb-fold[open] > summary::after { content: "▴"; }
  .tb-fold[open] > summary { margin-bottom: .5rem; }
  .tb-summary-label { font-weight: 700; font-size: .85rem; }
  .tb-summary-value { color: var(--muted); font-size: .85rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .toolbar-card { padding: .5rem .7rem; gap: .35rem; }
  .toolbar-row.one-row select, .toolbar-row.one-row input[type=date] { max-width: none; min-height: 40px; }
  .toolbar-row.one-row label { min-height: 40px; }
  .toolbar-note { font-size: .8rem; }
  /* the class's course lesson: compact */
  .lesson-banner { padding: .5rem .7rem; font-size: .9rem; }
  .lesson-banner > p.muted { display: none; }
  /* buttons stuck to the bottom stay above the tab bar */
  .sticky-actions { bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 5; }
  /* comfortable tap targets for small choices */
  .inline-checks label, .field > div[id] label { min-height: 40px; padding: .2rem .3rem; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .export-btn { padding: .4rem .7rem; font-size: .85rem; }
}
@media screen and (max-width: 760px) {
  /* title and Manage on one row; the info line uses the full width below them */
  .class-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: .6rem; }
  .class-title { display: contents; }
  .class-title h1 { grid-column: 1; grid-row: 1; }
  .class-top > details.menu { grid-column: 2; grid-row: 1; }
  .class-meta { grid-column: 1 / -1; grid-row: 2; }
  .sheet-context .toolbar-row label { flex-wrap: wrap; }
}

/* v1.27: the class's pages live in the sidebar (class picker + Students · Sessions · Course) */
.nav-class { display: flex; flex-direction: column; gap: 2px; margin: .15rem 0 .35rem; padding-inline-start: .7rem; border-inline-start: 2px solid rgba(255,255,255,.14); margin-inline-start: .7rem; }
.nav-class-pick select { width: 100%; font: inherit; font-size: .9rem; font-weight: 600; color: #fff; background-color: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22); border-radius: 8px; padding: .42rem 1.9rem .42rem .6rem; margin: .1rem 0 .25rem; cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: 14px; background-position: right .55rem center; }
[dir="rtl"] .nav-class-pick select { padding: .42rem .6rem .42rem 1.9rem; background-position: left .55rem center; }
.nav-class-pick select:hover { background-color: rgba(255,255,255,.16); }
.nav-class-pick select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav-class-pick option { color: var(--text); background: #fff; }
.nav-class-name { color: #fff; font-weight: 700; font-size: .9rem; padding: .3rem .6rem .25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a.sub { padding: .4rem .6rem; font-size: .92rem; }
.nav a.sub svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.nav a.sub.active { background: rgba(255,255,255,.17); box-shadow: inset 3px 0 0 var(--accent); }
[dir="rtl"] .nav a.sub.active { box-shadow: inset -3px 0 0 var(--accent); }
/* the sidebar now carries the class's pages: no in-page tabs on wide screens (phones keep them; the sidebar is a drawer there) */
@media screen and (min-width: 761px) { .class-tabs { display: none; } }
@media screen and (max-width: 760px) { .nav a.sub { padding: .6rem .7rem; font-size: 1rem; } .nav-class-pick select { font-size: 1rem; padding-block: .55rem; } }
.tab-head .all-students { display: inline-block; margin-top: .15rem; color: var(--muted); }
.tab-head .all-students:hover { color: var(--brand); }

/* v1.28: the sidebar is the chosen class's menu: picker on top, then its pages */
.nav-class { margin: 0 0 .45rem; padding: 0; border: 0; }
.nav-class-label { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.55); padding: 0 .15rem .3rem; }
.nav-class-pick { display: block; }
.nav-class-pick select { margin: 0; font-size: .95rem; padding-block: .5rem; }
.nav-class-name { padding: .1rem .15rem; font-size: 1rem; }
.nav a.sub { padding: .5rem .7rem; font-size: inherit; }
.nav a.sub svg { width: 18px; height: 18px; }
.home-class-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.home-today { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
@media screen and (max-width: 760px) { .nav a.sub { padding: .7rem .8rem; font-size: 1rem; } }

/* v1.28.1 phones: the app bar is the class picker; the bottom bar has the class's pages */
.topbar-switch { display: none; }

@media screen and (max-width: 760px) {
  .topbar-switch { display: flex; justify-content: center; min-width: 0; }
  .topbar-switch select, .topbar-class { max-width: 100%; min-width: 0; font: inherit; font-size: 1.05rem; font-weight: 700; color: #fff; background-color: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); border-radius: 999px; padding: .45rem 2.1rem .45rem 1rem; min-height: 40px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; appearance: none; -webkit-appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: 14px; background-position: right .8rem center; }
  [dir="rtl"] .topbar-switch select { padding: .45rem 1rem .45rem 2.1rem; background-position: left .8rem center; }
  .topbar-class { background-image: none; padding: .45rem 1rem; border-color: transparent; background-color: transparent; cursor: default; }
  .topbar-switch select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .topbar-switch option { color: var(--text); background: #fff; font-weight: 400; }
  /* the class name is in the app bar: the page heading can be smaller */
  .class-top .class-title h1 { font-size: 1.2rem; }
  /* dashboard tiles: two per row so the labels stay on one or two lines */
  .is-home .home-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: .5rem !important; }
  .is-home .home-stats .stat { display: flex; align-items: center; gap: .6rem; padding: .65rem .8rem; text-align: start; }
  .is-home .home-stats .stat .num { font-size: 1.45rem; min-width: 1.6em; }
  .is-home .home-stats .stat .label { font-size: .8rem; line-height: 1.25; }
  .home-today .home-class-actions { width: 100%; }
  .home-today .home-class-actions .btn { flex: 1 1 0; }
}
@media screen and (max-width: 760px) {
  /* the app bar already names the class: keep the info line and Manage on one compact row */
  .class-top .class-title h1 { display: none; }
  .class-top .class-meta { grid-column: 1; grid-row: 1; }
  .class-top > details.menu { align-self: start; }
  /* session sheet filter: short one-line choices */
  .sheet-filter button { white-space: nowrap; font-size: .85rem; padding-inline: .5rem; line-height: 1.2; }
}
.sheet-filter button span.hide-phone, .sheet-filter button span.show-phone { font-weight: inherit; color: inherit; margin: 0; }

/* v1.29: the day badges of the students list filter it */
a.day-chip { text-decoration: none !important; color: var(--text); cursor: pointer; transition: background .12s, border-color .12s; min-height: 30px; display: inline-flex; align-items: center; }
a.day-chip:hover { border-color: var(--brand); color: var(--brand); }
a.day-chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
a.day-chip.muted-badge.on { color: #fff; }
.day-counts { align-items: center; }
.day-clear { margin-inline-start: .3rem; color: var(--muted); }
.day-note { margin: -.1rem 0 .5rem; }
@media screen and (max-width: 760px) { a.day-chip { min-height: 36px; padding-inline: .7rem; } }

/* v1.31: deleting a class is a deliberate, guarded step */
.danger-page { max-width: 760px; }
.danger-head { display: flex; gap: .9rem; align-items: flex-start; margin-bottom: 1rem; }
.danger-head h1 { margin: 0 0 .2rem; }
.danger-icon { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--danger); color: #fff; font-weight: 800; font-size: 1.4rem; }
.danger-card { border-color: #f0c7c2; border-inline-start: 4px solid var(--danger); }
.danger-card h2, .safer-card h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.safer-card { border-inline-start: 4px solid var(--brand); background: var(--ok-soft); }
.safer-card p { margin: 0 0 .7rem; }
.impact { margin: 0 0 .5rem; padding-inline-start: 1.2rem; }
.impact li { margin: .2rem 0; }
.kept { margin: .5rem 0 0; padding: .5rem .7rem; background: var(--warn-soft); border-radius: 8px; font-size: .92rem; }
.danger-steps { margin: 0; padding-inline-start: 1.3rem; display: grid; gap: 1rem; }
.danger-steps > li > strong { display: block; margin-bottom: .3rem; }
.danger-steps .ok-line { color: #1d6b45; font-weight: 600; margin: .2rem 0 .4rem; }
.danger-steps .bad-line { color: var(--danger); font-weight: 600; margin: .2rem 0 .4rem; }
.danger-steps .field { margin: .5rem 0; }
.danger-steps code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 .3rem; font-weight: 700; }
.btn.danger.solid[disabled] { opacity: .45; cursor: not-allowed; }

/* v1.33: "Keep me signed in on this device" on the sign-in page */
.auth .field.remember { flex-wrap: wrap; margin: .2rem 0 1rem; }
.auth .field.remember input { width: 20px; height: 20px; margin: 0; }
.auth .field.remember .help { flex-basis: 100%; margin: 0 0 0 calc(20px + .5rem); color: var(--muted); font-size: .8rem; }
[dir="rtl"] .auth .field.remember .help { margin: 0 calc(20px + .5rem) 0 0; }

/* v1.34: a new account's first sign-in */
.first-password-note { margin: 0 0 1rem; padding: .7rem .9rem; background: var(--ok-soft); border-inline-start: 4px solid var(--brand); border-radius: 8px; }
.first-password-out { margin-top: .6rem; }
/* nothing else to open until the password is chosen */
.first-pw .sidebar, .first-pw .tabbar { display: none !important; }
.first-pw .app { grid-template-columns: 1fr; }
.first-pw .main { max-width: 560px; margin-inline: auto; width: 100%; }

/* v1.35: deleting a student */
.danger-link { margin: 1rem 0 0; padding-top: .8rem; border-top: 1px solid var(--border); text-align: end; font-size: .9rem; }
.danger-link a { color: var(--danger); font-weight: 600; }

/* v1.37: errors inside the days-and-teachers grid */
.day-cell .day-error { display: block; color: var(--danger); font-size: .78rem; font-weight: 600; margin-top: .2rem; }
.day-cell.has-error select { border-color: var(--danger); }
.day-cell[hidden] { display: none !important; }
.first-password-lang { margin-top: 1rem; }
.first-password-lang .lang-switch { background: var(--surface-2); border: 1px solid var(--border); }
.first-password-lang .lang-switch button { color: var(--text); }
.first-password-lang .lang-switch button[aria-current] { background: var(--brand); color: #fff; }
.nav-class .nav-class-all { display: inline-block; padding: .1rem .15rem; font-size: .8rem; color: rgba(255,255,255,.7); }
.nav-class .nav-class-all:hover { color: #fff; }
/* "My account" and "Sign out" on one line (phones too) */
.sidebar-foot form { margin: 0; display: inline-flex; }
.sidebar-foot .btn.link { padding: 0; min-height: 0; margin: 0; line-height: inherit; font-size: inherit; }
.sidebar-foot > div[style*="flex"] { align-items: center; }

/* v1.37.1: "Show all students" next to "+ Add session" */
.add-session { flex-wrap: wrap; }
.add-session-all { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; color: var(--muted); white-space: nowrap; cursor: pointer; }
.add-session-all input { width: 18px; height: 18px; margin: 0; }
@media screen and (max-width: 760px) { .add-session-all { flex-basis: 100%; min-height: 40px; } }

/* v1.37.2: "Show all students" toggle on the session sheet (always visible) */
.sheet-all { display: inline-flex; align-items: center; gap: .35rem; margin-inline-start: auto; font-weight: 600; white-space: nowrap; cursor: pointer; }
.sheet-all input { width: 18px; height: 18px; }
@media screen and (max-width: 760px) { .sheet-all { margin-inline-start: 0; min-height: 40px; } }
