:root {
  --bg: #f5f2e9;
  --surface: #fffefa;
  --surface-2: #f9f7f0;
  --ink: #172522;
  --muted: #66736f;
  --line: #dfded5;
  --brand: #0f5b4f;
  --brand-2: #e1efea;
  --brand-3: #073e36;
  --green: #247a55;
  --green-soft: #e5f3ea;
  --amber: #a86410;
  --amber-soft: #fff0d5;
  --red: #a53b32;
  --red-soft: #f9e6e2;
  --blue: #356987;
  --blue-soft: #e8f0f5;
  --shadow: 0 18px 50px rgba(24, 45, 39, .12);
  --radius: 16px;
  --focus: 0 0 0 3px rgba(42, 134, 112, .28);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
body.locked { overflow: hidden; }

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(1.65rem, 4vw, 2.2rem); line-height: 1.15; }
h2 { margin-bottom: 6px; font-size: clamp(1.35rem, 3vw, 1.75rem); line-height: 1.2; }
h3 { margin-bottom: 12px; font-size: 1.05rem; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  transform: translateY(-150%);
  border-radius: 8px;
  background: var(--ink);
  color: white;
}
.skip-link:focus { transform: none; }

#toast {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: 24px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  transform: translate(-50%, 30px);
  border-radius: 999px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast.bad { background: var(--red); }

.shell { min-height: 100vh; }
.container { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.container.narrow { width: min(760px, calc(100% - 32px)); }
.page { padding: 30px 0 64px; }

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  background: var(--brand);
  color: white;
}
.topbar-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  color: inherit;
  font-size: 1.05rem;
  font-weight: 760;
  letter-spacing: -.01em;
}
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-nav { display: flex; gap: 4px; }
.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.nav-btn,
.top-btn {
  min-height: 40px;
  padding: 0 13px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, .8);
  font-weight: 680;
}
.nav-btn:hover,
.top-btn:hover { background: rgba(255, 255, 255, .1); color: white; }
.nav-btn.active { background: white; color: var(--brand); }
.top-btn.icon-only { width: 42px; padding: 0; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px 16px;
  background:
    radial-gradient(circle at 10% 10%, rgba(27, 115, 97, .08), transparent 30%),
    radial-gradient(circle at 90% 90%, rgba(181, 126, 41, .08), transparent 28%),
    var(--bg);
}
.login-wrap { width: min(430px, 100%); }
.login-brand { margin-bottom: 22px; text-align: center; }
.bismillah { margin-bottom: 8px; color: var(--brand); font-family: Georgia, serif; font-size: 1.25rem; }
.login-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.role-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 22px;
  padding: 5px;
  border-radius: 12px;
  background: var(--surface-2);
}
.role-switch button {
  min-height: 42px;
  padding: 4px 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 680;
}
.role-switch button.active { background: white; color: var(--brand); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.login-note { min-height: 42px; color: var(--muted); font-size: .9rem; }
.login-card .field + .field { margin-top: 14px; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.card-pad { padding: 20px; }
.subtle { color: var(--muted); }
.small { font-size: .86rem; }
.eyebrow {
  margin-bottom: 6px;
  color: var(--brand);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 690;
}
.btn:hover { border-color: #c5cac5; background: #fff; }
.btn.primary { border-color: var(--brand); background: var(--brand); color: white; }
.btn.primary:hover { background: var(--brand-3); }
.btn.secondary { border-color: #a9cfc3; background: var(--brand-2); color: var(--brand-3); }
.btn.secondary:hover { border-color: var(--brand); background: #d4e8e1; }
.btn.danger { border-color: #e8c2bd; color: var(--red); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.sm { min-height: 36px; padding: 0 11px; border-radius: 9px; font-size: .87rem; }
.btn.wide { width: 100%; }
.icon { width: 18px; height: 18px; flex: none; }

.field { display: grid; gap: 7px; }
.field + .field { margin-top: 15px; }
.field label, .field-label { color: #42504c; font-size: .83rem; font-weight: 740; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
}
textarea { min-height: 86px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #9ca5a1; }
.search-hidden { display: none !important; }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-heading p { margin-bottom: 0; }
.heading-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.notice {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
  padding: 10px 13px;
  border: 1px solid #ead9b8;
  border-radius: 11px;
  background: #fff8e8;
  color: #76501c;
  font-size: .88rem;
}

.day-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}
.date-nav { display: flex; align-items: center; gap: 7px; }
.date-input { width: 148px; }
.summary-line { display: flex; justify-content: center; gap: 16px; color: var(--muted); font-size: .88rem; }
.summary-line b { color: var(--ink); }

.list-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.search { position: relative; min-width: 220px; flex: 1; }
.search input { padding-left: 38px; background: var(--surface); }
.search .icon { position: absolute; left: 12px; top: 13px; color: var(--muted); }
.filters { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.filter-btn {
  min-height: 38px;
  flex: none;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 680;
}
.filter-btn.active { border-color: #c9ddd7; background: var(--brand-2); color: var(--brand); }

.roster {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.roster-head,
.student-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.15fr) 174px minmax(220px, 1.7fr) 90px 58px;
  align-items: center;
  gap: 12px;
}
.roster-head {
  min-height: 42px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: .74rem;
  font-weight: 760;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.student-row {
  min-height: 66px;
  width: 100%;
  padding: 9px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
}
.student-row:last-child { border-bottom: 0; }
.student-row:hover { background: #fbfcf9; }
.student-name { min-width: 0; }
.student-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.student-name span { color: var(--muted); font-size: .82rem; }
.attendance { display: inline-flex; gap: 3px; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.att-btn {
  min-width: 50px;
  min-height: 34px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 760;
}
.att-btn.active.p { background: var(--green-soft); color: var(--green); }
.att-btn.active.l { background: var(--amber-soft); color: var(--amber); }
.att-btn.active.a { background: var(--red-soft); color: var(--red); }
.record-summary { min-width: 0; overflow: hidden; color: var(--muted); font-size: .87rem; text-overflow: ellipsis; white-space: nowrap; }
.grade-mark { font-weight: 760; text-align: center; }
.status-dot { width: 9px; height: 9px; margin: auto; border-radius: 50%; background: #d6d7d2; }
.status-dot.done { background: var(--green); }
.status-dot.waiting { background: var(--amber); }
.status-dot.absent { background: var(--red); }

.empty-state { padding: 42px 20px; color: var(--muted); text-align: center; }

.overlay {
  position: fixed;
  z-index: 60;
  inset: 0;
  background: rgba(11, 25, 22, .42);
  backdrop-filter: blur(2px);
}
.drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(520px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: -20px 0 60px rgba(8, 33, 28, .18);
}
.drawer-head {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
.drawer-title { min-width: 0; flex: 1; }
.drawer-title h2 { margin: 0; font-size: 1.18rem; }
.drawer-title p { margin: 2px 0 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.drawer-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 254, 250, .96);
}
.close-btn { width: 44px; padding: 0; }
.saved-state { min-width: 58px; color: var(--muted); font-size: .82rem; text-align: right; }
.saved-state.saving { color: var(--amber); }
.saved-state.error { color: var(--red); }

.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segment {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--muted);
  font-weight: 700;
}
.segment.active { border-color: var(--brand); background: var(--brand-2); color: var(--brand); }
.segment.good.active { border-color: #acd2bc; background: var(--green-soft); color: var(--green); }
.segment.warn.active { border-color: #e1c08d; background: var(--amber-soft); color: var(--amber); }
.segment.bad.active { border-color: #e2b3ad; background: var(--red-soft); color: var(--red); }

.entry-section {
  margin-top: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
}
.entry-section:first-child { margin-top: 0; }
.entry-section.memorization-section { border-left: 4px solid #7653a6; background: #fbf9fe; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h3 { margin: 0; }
.outcomes { display: flex; flex-wrap: wrap; gap: 5px; }
.page-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0; }
.page-chip { min-width: 43px; min-height: 36px; padding: 0 9px; }
.inline-grid { display: grid; grid-template-columns: 1fr 100px; gap: 10px; }
.mistakes {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.mistakes summary { color: var(--muted); cursor: pointer; font-size: .84rem; font-weight: 680; }
.stepper { display: inline-flex; align-items: center; gap: 10px; margin-top: 9px; }
.stepper button { width: 38px; min-height: 38px; padding: 0; }
.stepper strong { min-width: 24px; text-align: center; }
.grade-row { display: flex; gap: 6px; }
.grade-btn { width: 44px; min-height: 42px; padding: 0; }
.family-followup { margin-top: 14px; padding: 13px; border-radius: 12px; background: var(--brand-2); color: var(--brand-3); }
.family-followup p:last-child { margin-bottom: 0; }
.program-record-guide {
  display: grid;
  gap: 3px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  background: var(--brand-2);
  color: var(--brand-3);
}
.program-record-guide span { font-size: .82rem; }
.program-record-guide.naazirah { border-color: #3976a8; background: #edf6fd; color: #214e72; }
.program-record-guide.alimiyyah { border-color: #7653a6; background: #f4effb; color: #523978; }
.program-record-guide.summer { border-color: #c98227; background: #fff5e7; color: #794b12; }
.program-record-guide.generic { border-color: #6f7773; background: #f1f3f2; color: #414844; }

.admin-list { overflow: hidden; }
.management-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.management-help { margin: 12px 2px 0; }
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.bulk-select { min-height: 40px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.bulk-select input, .admin-select input { width: 19px; height: 19px; accent-color: var(--brand); }
.bulk-count { white-space: nowrap; }
.bulk-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex: 1; flex-wrap: wrap; }
.bulk-program { width: auto; min-width: 130px; }
.bulk-custom-program { width: min(180px, 100%); }
.admin-row {
  min-height: 66px;
  display: grid;
  grid-template-columns: 32px minmax(170px,1.3fr) 120px 100px minmax(160px,1fr) minmax(230px,auto);
  align-items: center;
  gap: 12px;
  padding: 10px 15px;
  border-bottom: 1px solid var(--line);
}
.admin-select { min-height: 44px; display: grid; place-items: center; cursor: pointer; }
.admin-row:last-child { border-bottom: 0; }
.admin-row:hover { background: #fbfcf9; }
.admin-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.student-pin { display: grid; gap: 3px; }
.student-pin strong { font-family: ui-monospace, monospace; font-size: 1.02rem; letter-spacing: .08em; }
.family-intro {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #c9ddd7;
  border-radius: 12px;
  background: var(--brand-2);
  color: var(--brand-3);
}
.family-intro p { margin: 0; }
.family-list { display: grid; gap: 10px; }
.family-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 112px minmax(260px, auto);
  align-items: center;
  gap: 18px;
  padding: 16px;
}
.family-copy { min-width: 0; }
.family-copy h2 { margin-bottom: 2px; font-size: 1.08rem; }
.family-copy p { margin: 0; overflow-wrap: anywhere; }
.family-copy p:last-child { margin-top: 5px; }
.family-pin { display: grid; gap: 3px; }
.family-pin strong { font-family: ui-monospace, monospace; font-size: 1.02rem; letter-spacing: .08em; }
.family-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.family-modal { width: min(700px, calc(100% - 28px)); }
.family-modal .modal-head > div { min-width: 0; flex: 1; }
.family-modal .modal-head p { margin: 3px 0 0; }
.family-members-editor { margin-top: 18px; }
.family-members-editor .search { margin-bottom: 10px; }
.family-warning {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #ead9b8;
  border-radius: 10px;
  background: #fff8e8;
  color: #76501c;
}
.member-checklist {
  max-height: min(330px, 42vh);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.member-option {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.member-option:last-child { border-bottom: 0; }
.member-option:hover { background: var(--surface-2); }
.member-option input { width: 19px; min-height: 19px; flex: none; accent-color: var(--brand); }
.member-option span { min-width: 0; }
.member-option strong, .member-option small { display: block; }
.member-option small { color: var(--muted); }
.family-link-section { background: var(--surface-2); }
.family-link-summary {
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  background: var(--brand-2);
  color: var(--brand-3);
}
.family-link-summary p { margin: 3px 0 0; font-size: .84rem; }
.family-link-summary .pending-change { margin-top: 8px; font-weight: 740; }
.progress-mini { min-width: 0; }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: #e8e6de; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--brand); }
.progress-label { margin-top: 5px; color: var(--muted); font-size: .78rem; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .74rem;
  font-weight: 720;
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }

.detail-header { margin-bottom: 16px; padding: 21px; }
.detail-top { display: flex; align-items: flex-start; gap: 14px; }
.detail-title { flex: 1; }
.detail-title h1 { margin-bottom: 4px; }
.big-progress { margin-top: 17px; }
.big-progress .progress-track { height: 10px; }
.progress-copy { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; color: var(--muted); font-size: .86rem; }
.tabs { display: flex; gap: 5px; margin-bottom: 14px; }
.tab-btn { min-width: 100px; }
.records { display: grid; gap: 8px; }
.record {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}
.record-top {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}
.record-top::-webkit-details-marker { display: none; }
.record-top:hover { background: var(--surface-2); }
.record-top strong { flex: 1; }
.record-chevron { width: 30px; height: 30px; display: grid; flex: none; place-items: center; color: var(--muted); transition: transform .16s ease; }
.record-chevron .icon { width: 16px; height: 16px; }
.record[open] .record-chevron { transform: rotate(90deg); }
.record[open] .record-top { border-bottom: 1px solid var(--line); }
.record-body { padding: 14px 16px 16px; }
.record-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.record-part { min-width: 0; }
.record-part span { display: block; color: var(--muted); font-size: .75rem; font-weight: 720; text-transform: uppercase; }
.record-part p { margin: 3px 0 0; overflow-wrap: anywhere; font-size: .88rem; }
.record-note { margin: 11px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: #3e4d48; }
.record-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

.progress-dashboard { margin-bottom: 26px; }
#growthTitle { scroll-margin-top: 88px; }
.section-intro { margin: 4px 2px 14px; }
.section-intro h2 { margin-bottom: 5px; }
.section-intro p { max-width: 680px; margin-bottom: 0; }
.month-snapshot { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 12px; }
.snapshot-card {
  min-width: 0;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}
.snapshot-card:hover { border-color: #b9d2ca; background: var(--brand-2); }
.snapshot-card span { color: var(--muted); font-size: .75rem; font-weight: 740; text-transform: uppercase; }
.snapshot-card strong { margin: 6px 0 4px; color: var(--brand); font-size: 1.18rem; }
.snapshot-card small { color: var(--muted); font-size: .72rem; line-height: 1.3; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.growth-chart { min-width: 0; padding: 16px; }
.growth-chart.wide { grid-column: 1 / -1; }
.chart-head { min-height: 68px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.chart-head h3 { margin-bottom: 3px; }
.chart-head p { margin: 0; color: var(--muted); font-size: .79rem; }
.chart-head > span { flex: none; padding: 3px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .68rem; font-weight: 720; text-transform: uppercase; }
.chart-scroll { overflow-x: auto; padding: 7px 1px 3px; scrollbar-width: thin; }
.chart-bars { min-width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(48px, 1fr); align-items: end; gap: 6px; }
.chart-item {
  min-width: 48px;
  min-height: 174px;
  display: grid;
  grid-template-rows: 22px 122px 28px;
  align-items: end;
  justify-items: center;
  padding: 0 2px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
}
button.chart-item:hover { background: var(--surface-2); }
.chart-value { color: var(--brand); font-size: .73rem; font-weight: 780; }
.chart-column { width: 100%; height: 120px; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--line); }
.chart-bar { width: min(30px, 68%); min-height: 3px; border-radius: 7px 7px 2px 2px; background: var(--brand); transition: filter .16s ease, transform .16s ease; transform-origin: bottom; }
.chart-bar.quality { background: var(--blue); }
.chart-bar.memorization { background: #7653a6; }
button.chart-item:hover .chart-bar { filter: brightness(1.13); transform: scaleX(1.08); }
.chart-label { align-self: start; color: var(--muted); font-size: .68rem; line-height: 1.15; text-align: center; }
.chart-empty { min-height: 110px; display: grid; place-items: center; color: var(--muted); font-size: .86rem; text-align: center; }
.month-history { scroll-margin-top: 88px; }
.month-history-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.month-history-head h2 { margin-bottom: 3px; }
.month-history-head p { margin-bottom: 0; }
.month-nav { display: grid; grid-template-columns: 40px minmax(160px, 1fr) 40px; align-items: center; gap: 6px; }
.month-nav select { min-height: 40px; padding-top: 6px; padding-bottom: 6px; }
.month-arrow { width: 40px; padding: 0; font-size: 1.25rem; }
.empty-state.compact { padding: 24px 18px; }

.juz-list { display: grid; gap: 8px; }
.juz-row { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 12px; padding: 13px 15px; }
.juz-number { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--brand-2); color: var(--brand); font-weight: 800; }
.juz-copy p { margin: 2px 0 0; color: var(--muted); font-size: .84rem; }

.parent-switch { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; }
.latest-card { padding: 21px; }
.latest-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.latest-head h2 { margin: 0; }
.latest-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.record-grid.has-extra, .latest-grid.has-extra { grid-template-columns: repeat(2,1fr); }
.latest-part { padding: 12px; border-radius: 11px; background: var(--surface-2); }
.latest-part span { display: block; color: var(--muted); font-size: .75rem; font-weight: 720; text-transform: uppercase; }
.latest-part strong { display: block; margin-top: 4px; font-size: .9rem; }
.teacher-note { margin-top: 14px; padding: 13px; border-left: 3px solid var(--brand); border-radius: 0 10px 10px 0; background: var(--brand-2); }
.teacher-note p { margin-bottom: 0; }
.home-record { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 13px; }
.home-record summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #b9d5cc;
  border-radius: 12px;
  background: var(--brand-2);
  color: var(--brand-3);
  cursor: pointer;
  font-weight: 760;
  list-style: none;
}
.home-record summary::-webkit-details-marker { display: none; }
.home-record summary::marker { content: ""; }
.home-record-cue { display: inline-flex; align-items: center; gap: 5px; color: var(--brand); font-size: .8rem; white-space: nowrap; }
.home-record-cue .icon { width: 15px; height: 15px; transition: transform .18s ease; }
.home-record[open] .home-record-cue .icon { transform: rotate(90deg); }
.home-record.needs-attention:not([open]) summary { animation: home-record-pulse 3.4s ease-in-out infinite; }
.home-record.needs-attention:not([open]) .home-record-cue .icon { animation: home-record-arrow 3.4s ease-in-out infinite; }
.home-body { padding-top: 14px; }
.home-minutes { display: flex; flex-wrap: wrap; gap: 5px; }
.salah-row { display: flex; flex-wrap: wrap; gap: 7px; }
.salah-btn { min-width: 58px; min-height: 48px; padding: 4px 7px; }
.salah-btn span { display: block; font-size: .72rem; }
.home-readonly { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.home-readonly-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.home-readonly-row span { color: var(--muted); font-size: .82rem; font-weight: 720; }
.home-readonly-row + .field { margin-top: 15px; }
.salah-readonly { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 7px; }
.salah-status { padding: 9px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: center; }
.salah-status.recorded { border-color: #b9d5cc; background: var(--brand-2); }
.salah-status span, .salah-status strong { display: block; }
.salah-status span { color: var(--muted); font-size: .7rem; }
.salah-status strong { margin-top: 2px; color: var(--brand-3); font-size: .76rem; }
.ack-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }

@keyframes home-record-pulse {
  0%, 62%, 100% { border-color: #b9d5cc; box-shadow: 0 0 0 0 rgba(15, 91, 79, 0); transform: translateY(0); }
  72% { border-color: var(--brand); box-shadow: 0 0 0 5px rgba(15, 91, 79, .12); transform: translateY(-1px); }
  84% { border-color: #8ebcaf; box-shadow: 0 0 0 0 rgba(15, 91, 79, 0); transform: translateY(0); }
}

@keyframes home-record-arrow {
  0%, 62%, 84%, 100% { transform: translateX(0); }
  72% { transform: translateX(4px); }
}

.progress-summary { margin-top: 14px; padding: 18px; }
.progress-summary-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.metric-line { display: flex; flex-wrap: wrap; gap: 9px 18px; margin-top: 11px; color: var(--muted); font-size: .84rem; }

.student-book-page { width: min(720px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 60px; }
.student-welcome { margin-bottom: 14px; padding: 22px; background: var(--brand); color: white; }
.student-welcome.program-naazirah { background: #2d6b9d; }
.student-welcome.program-alimiyyah { background: #63458d; }
.student-welcome.program-summer { background: #a96518; }
.student-welcome.program-generic { background: #505a55; }
.student-welcome p { margin-bottom: 0; color: rgba(255,255,255,.72); }
.book-entry-card { padding: 20px; }
.book-entry-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.book-entry-head h2 { margin-bottom: 0; }
.book-section { padding: 18px 0; border-top: 1px solid var(--line); }
.book-section.naazirah-memorization { padding-left: 13px; border-left: 4px solid #7653a6; }
.book-section:first-of-type { margin-top: 18px; }
.book-section:last-child { padding-bottom: 0; }
.student-home-card { margin-top: 14px; padding: 20px; }
.student-home-card > p { margin-bottom: 18px; }
.feedback-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.feedback-card { margin-top: 14px; padding: 20px; }
.student-section { margin-top: 24px; }
.page-heading.compact { margin-bottom: 12px; }

.modal {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(480px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 20px;
  transform: translate(-50%, -50%);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.modal-head h2 { flex: 1; margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pin-row { display: flex; align-items: center; gap: 8px; }
.pin-value { flex: 1; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-family: ui-monospace, monospace; font-size: 1.05rem; letter-spacing: .08em; }

@media (max-width: 820px) {
  .container { width: min(100% - 24px, 720px); }
  .topbar-inner { min-height: 58px; gap: 8px; }
  .brand { margin-right: auto; }
  .brand-name { max-width: 180px; }
  .top-btn .button-label { display: none; }
  .day-toolbar { grid-template-columns: 1fr auto; gap: 10px; }
  .summary-line { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .list-tools { align-items: stretch; flex-direction: column; }
  .search { min-width: 0; }
  .roster-head { display: none; }
  .student-row {
    grid-template-columns: minmax(145px,1fr) auto 28px;
    gap: 8px;
    padding: 12px;
  }
  .student-row .record-summary { grid-column: 1 / 3; grid-row: 2; }
  .student-row .attendance { grid-column: 2; grid-row: 1; }
  .student-row .grade-mark { grid-column: 2; grid-row: 3; text-align: right; }
  .student-row .status-dot { grid-column: 3; grid-row: 1 / 4; }
  .bulk-toolbar { align-items: flex-start; flex-wrap: wrap; }
  .bulk-actions { width: 100%; flex-basis: 100%; justify-content: flex-start; }
  .admin-row { grid-template-columns: 44px 1fr auto; gap: 8px; }
  .admin-select { grid-column: 1; grid-row: 1 / 5; }
  .admin-row .student-name, .admin-program, .admin-row .student-pin, .admin-row .progress-mini { grid-column: 2; }
  .admin-actions { grid-column: 3; grid-row: 1 / 5; flex-direction: column; }
  .family-row { grid-template-columns: 1fr auto; gap: 10px; }
  .family-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .record-grid, .record-grid.has-extra, .latest-grid, .latest-grid.has-extra { grid-template-columns: 1fr; }
  .latest-part { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .latest-part strong { margin-top: 0; text-align: right; }
  .month-snapshot { grid-template-columns: 1fr 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .growth-chart.wide { grid-column: auto; }
}

@media (max-width: 560px) {
  button { min-height: 44px; }
  .btn, .btn.sm, .filter-btn, .att-btn, .segment, .nav-btn, .top-btn, .close-btn { min-height: 44px; }
  .icon-only, .close-btn, .att-btn, .page-chip, .grade-btn { min-width: 44px; }
  .page { padding-top: 20px; }
  .brand-name { max-width: 126px; font-size: .94rem; }
  .main-nav .nav-btn { min-height: 44px; padding: 0 10px; font-size: .86rem; }
  .top-actions .top-btn { min-height: 44px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { width: 100%; }
  .heading-actions .btn { flex: 1; }
  .date-input { width: 142px; }
  .summary-line { gap: 10px; font-size: .8rem; }
  .filter-btn { padding: 0 10px; }
  .student-row { grid-template-columns: 1fr 28px; }
  .student-row .attendance { grid-column: 1; grid-row: 2; justify-self: start; }
  .student-row .record-summary { grid-column: 1; grid-row: 3; }
  .student-row .grade-mark { grid-column: 1; grid-row: 4; text-align: right; }
  .student-row .status-dot { grid-column: 2; grid-row: 1 / 5; }
  .drawer-head { min-height: 64px; padding: 10px 13px; }
  .drawer { width: 100%; }
  .drawer-body { padding: 13px; }
  .drawer-foot { padding-left: 13px; padding-right: 13px; }
  .drawer-foot .btn { flex: 1; padding-left: 9px; padding-right: 9px; }
  .entry-section { padding: 13px; }
  .inline-grid { grid-template-columns: 1fr; }
  .two-cols { grid-template-columns: 1fr; }
  .student-book-page { width: min(100% - 24px, 720px); padding-top: 18px; }
  .book-entry-card, .student-home-card, .feedback-card { padding: 16px; }
  .tabs { overflow-x: auto; }
  .tab-btn { flex: none; }
  .snapshot-card { min-height: 106px; padding: 11px; }
  .snapshot-card strong { font-size: 1.05rem; }
  .growth-chart { padding: 13px 11px; }
  .chart-head { min-height: 82px; }
  .chart-bars { grid-auto-columns: 52px; }
  .month-history-head { align-items: stretch; flex-direction: column; }
  .month-nav { width: 100%; grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .month-arrow { width: 44px; }
  .record-top { align-items: center; flex-wrap: wrap; gap: 7px; padding: 11px 12px; }
  .record-top strong { min-width: calc(100% - 40px); }
  .record-chevron { order: 5; margin-left: auto; }
  .record-body { padding: 13px; }
  .juz-row { grid-template-columns: 48px 1fr; }
  .juz-row .btn { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .home-record.needs-attention:not([open]) summary,
  .home-record.needs-attention:not([open]) .home-record-cue .icon { animation: none; }
}

@media print {
  .topbar, .btn, .filters, .search, .overlay, #toast { display: none !important; }
  body { background: white; }
  .page { padding: 0; }
  .card, .record, .roster { break-inside: avoid; border-color: #bbb; }
}
