:root {
  --sage: #8fae9c;
  --sage-dark: #509579;
  --sage-deep: #356f5a;
  --ivory: #faf7f0;
  --cream: #efe6d3;
  --mint: #aed1c3;
  --white: #ffffff;
  --ink: #2b2e28;
  --ink-soft: #5c5f57;
  --ink-faint: #676b63;
  --line: rgba(43, 46, 40, 0.13);
  --line-strong: rgba(43, 46, 40, 0.22);
  --control-border: #8a8f86;
  --focus: #1d63c4;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warning: #8a6720;
  --warning-soft: #fbf1d5;
  --neutral: #626860;
  --neutral-soft: #f0f1ef;
  --info: #35667a;
  --info-soft: #e6f1f4;
  --success: #356f5a;
  --success-soft: #e6f1eb;
  --shadow-sm: 0 4px 16px rgba(43, 46, 40, 0.07);
  --shadow-md: 0 14px 36px rgba(43, 46, 40, 0.11);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --max: 1180px;
  --sidebar: 256px;
  /* Identity colors are deliberately vivid and never use semantic red or gray. */
  --student-sage: #00a878;
  --student-coral: #f26a00;
  --student-blue: #2f7df6;
  --student-purple: #8b5cf6;
  --student-plum: #d946a6;
  --student-gold: #74b816;
  --student-teal: #00a7b5;
  --student-slate: #5f6dfb;
  --teacher-emerald: #00a85a;
  --teacher-cobalt: #1f75ff;
  --teacher-violet: #7c5cff;
  --teacher-amber: #f5a400;
  --teacher-turquoise: #00a8a8;
  --teacher-fuchsia: #d946a6;
  --teacher-indigo: #5968f2;
  --teacher-lime: #76b900;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: "Work Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body.sidebar-is-open {
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, .display {
  margin: 0;
  color: var(--sage-deep);
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
p { margin: 0 0 1rem; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[lang="ar"] { font-family: "Amiri", "Noto Naskh Arabic", Georgia, serif; line-height: 1.65; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 1000;
  padding: 10px 16px; background: var(--sage-deep); color: white; border-radius: 8px;
}
.skip-link:focus { top: 12px; }
.wrap { width: min(var(--max), calc(100% - 48px)); margin-inline: auto; }
.muted { color: var(--ink-soft); }
.subtle { color: var(--ink-faint); font-size: 0.875rem; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack { display: grid; gap: 18px; }
.stack-sm { display: grid; gap: 10px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.cluster-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 0; }
.eyebrow {
  color: var(--sage-deep); font-size: 0.78rem; font-weight: 750;
  letter-spacing: 0.15em; text-transform: uppercase;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  max-width: 100%;
  flex-shrink: 0;
  min-height: 44px; padding: 10px 20px; border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--ink); cursor: pointer; font-weight: 650;
  line-height: 1.1; text-decoration: none; white-space: nowrap; transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--sage-deep); color: var(--white); box-shadow: 0 6px 20px rgba(53, 111, 90, 0.22); }
.btn-primary:hover { box-shadow: 0 10px 26px rgba(53, 111, 90, 0.28); }
.btn-secondary { background: var(--white); border-color: var(--control-border); color: var(--sage-deep); }
.btn-ghost { border-color: var(--sage-dark); color: var(--sage-deep); }
.btn-success { background: var(--success); color: var(--white); box-shadow: 0 6px 18px rgba(53, 111, 90, .2); }
.btn-danger { background: var(--danger-soft); border-color: rgba(164, 73, 73, 0.25); color: var(--danger); }
.btn-small { min-height: 36px; padding: 8px 14px; font-size: 0.85rem; }
.btn-icon { width: 42px; height: 42px; padding: 0; border-radius: 12px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
.link { color: var(--sage-deep); font-weight: 650; text-underline-offset: 3px; }
.link-danger { color: var(--danger); }

/* Public header */
.public-header {
  position: sticky; top: 0; z-index: 60; border-bottom: 1px solid var(--line);
  background: rgba(250, 247, 240, 0.94); backdrop-filter: blur(12px);
}
.public-nav { min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 100px;
  height: auto;
  aspect-ratio: 457 / 546;
  object-fit: contain;
}
.public-header .brand { gap: 10px; }
.public-brand-mark {
  width: 58px;
  aspect-ratio: 502 / 497;
}
.public-brand-wordmark {
  width: 140px;
  height: auto;
  object-fit: contain;
  transform: translateY(6px);
}
.public-links { display: flex; align-items: center; gap: 24px; }
.public-links a { color: var(--ink-soft); font-size: 0.92rem; text-decoration: none; }
.public-links a:hover { color: var(--sage-deep); }
.public-links a.btn-primary,
.public-links a.btn-primary:hover {
  color: var(--white);
}
.mobile-toggle { display: none; }

/* Landing */
.public-main section { padding: 84px 0; }
.hero { position: relative; overflow: hidden; padding: 90px 0 76px !important; }
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none; filter: blur(2px);
}
.hero::before { width: 440px; height: 440px; right: -180px; top: -180px; background: rgba(174, 209, 195, 0.22); }
.hero::after { width: 300px; height: 300px; left: -190px; bottom: -190px; background: rgba(239, 230, 211, 0.7); }
.hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(220px, .75fr); gap: clamp(36px, 7vw, 88px); align-items: center; }
.hero-grid > div:first-child { max-width: 780px; }
.hero-logo-panel {
  display: grid; width: min(100%, 300px); justify-self: end; place-items: center;
  padding: clamp(22px, 4vw, 38px); border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.hero-logo { width: 100%; height: auto; object-fit: contain; }
.hero h1 { max-width: 760px; margin: 14px 0 22px; font-size: clamp(2.35rem, 5vw, 4.1rem); }
.hero h1 em { color: var(--sage-dark); font-weight: 500; }
.hero .lead { max-width: 60ch; color: var(--ink-soft); font-size: 1.08rem; }
.hero-ctas, .hero-tags { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-ctas { margin-top: 28px; }
.hero-tags { margin-top: 22px; }
.tag { padding: 6px 13px; border: 1px solid rgba(80, 149, 121, 0.28); border-radius: 999px; background: rgba(143, 174, 156, 0.12); color: var(--sage-deep); font-size: 0.8rem; }
.section-alt { background: var(--cream); }
.section-head { max-width: 690px; margin-bottom: 44px; }
.section-head h2 { margin-top: 10px; font-size: clamp(1.85rem, 3.4vw, 2.7rem); }
.section-head p { margin-top: 14px; color: var(--ink-soft); }
.card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.info-card { padding: 28px 24px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--white); box-shadow: var(--shadow-sm); }
.info-card h3 { margin: 12px 0 8px; font-size: 1.16rem; }
.info-card p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }
.course-kind { color: var(--ink-soft); font-size: .82em; white-space: nowrap; }
.icon-box { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--success-soft); color: var(--sage-deep); font-size: 1.25rem; }
.icon-box img { width: 28px; height: 28px; object-fit: contain; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.audience-card { padding: 34px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: linear-gradient(145deg, rgba(255,255,255,.75), rgba(174,209,195,.18)); }
.audience-card h3 { margin: 10px 0; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; counter-reset: step; }
.step-card { position: relative; padding: 30px 26px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--white); }
.step-card::before { counter-increment: step; content: counter(step); display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 18px; border-radius: 50%; background: var(--sage-deep); color: var(--white); font-weight: 700; }
.step-card h3 { margin-bottom: 10px; }
.step-card ul { margin: 12px 0 0; padding-left: 20px; color: var(--ink-soft); }
.faq-list { display: grid; gap: 12px; max-width: 840px; }
.faq-item { border: 1px solid var(--line); border-radius: 14px; background: var(--white); overflow: hidden; }
.faq-item summary { padding: 19px 22px; color: var(--sage-deep); cursor: pointer; font-weight: 650; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; float: right; color: var(--sage-dark); font-size: 1.25rem; }
.faq-item[open] summary::after { content: "−"; }
.faq-answer { padding: 0 22px 20px; color: var(--ink-soft); }
.cta-banner { padding: 52px; border-radius: 28px; background: var(--sage-deep); color: var(--white); text-align: center; }
.cta-banner h2 { color: var(--white); font-size: clamp(1.8rem, 3.5vw, 2.6rem); }
.cta-banner p { max-width: 56ch; margin: 14px auto 26px; color: rgba(255,255,255,.82); }
.contact-layout { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 52px; align-items: start; }
.contact-title { margin-bottom: 14px; font-size: clamp(2.1rem, 4vw, 3.25rem); }
.contact-channels { display: grid; gap: 12px; margin-top: 24px; }
.contact-channel { padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); overflow-wrap: anywhere; }

/* Forms */
.form-card { padding: 30px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); box-shadow: var(--shadow-sm); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { position: relative; display: grid; gap: 7px; }
.field label, .label { color: var(--ink-soft); font-size: 0.875rem; font-weight: 650; }
.field-help { color: var(--ink-faint); font-size: 0.8125rem; }
input, select, textarea {
  width: 100%; min-width: 0; min-height: 44px; padding: 10px 13px; border: 1px solid var(--control-border);
  border-radius: var(--radius-sm); background: var(--white); color: var(--ink);
}
textarea { min-height: 118px; resize: vertical; }
::placeholder { color: var(--ink-faint); opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--sage-deep); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input[readonly] { background: #f4f2ec; color: var(--ink-soft); }
.date-picker-popover {
  min-width: 0;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  width: min(100%, 320px);
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  box-shadow: var(--shadow-md);
}
.date-picker-popover[hidden] { display: none; }
.date-picker-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.date-picker-head strong {
  min-width: 0;
  overflow: hidden;
  color: var(--sage-deep);
  font-size: .95rem;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: capitalize;
  white-space: nowrap;
}
.date-picker-head button,
.date-picker-grid button {
  width: 100%;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.date-picker-head button:hover,
.date-picker-grid button:hover {
  border-color: var(--sage-deep);
  background: var(--success-soft);
}
.date-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}
.date-picker-weekday {
  display: grid;
  min-height: 24px;
  place-items: center;
  color: var(--ink-faint);
  font-size: .72rem;
  font-weight: 800;
}
.date-picker-grid button.is-today {
  border-color: var(--sage-deep);
}
.date-picker-grid button.is-selected {
  border-color: var(--sage-deep);
  background: var(--sage-deep);
  color: var(--white);
}
.honeypot { position: absolute !important; left: -9999px !important; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 6px; }
.danger-zone { padding: 22px; border: 1px solid rgba(164,73,73,.25); border-radius: var(--radius-md); background: var(--danger-soft); }

/* Footer */
.public-footer { padding: 48px 0 28px; background: var(--sage-deep); color: rgba(255,255,255,.84); }
.footer-grid { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 38px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 44px; }
.footer-col { display: grid; align-content: start; gap: 7px; }
.footer-col strong { color: rgba(255,255,255,.86); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; }
.footer-col a { color: rgba(255,255,255,.86); font-size: .88rem; text-decoration: none; overflow-wrap: anywhere; }
.footer-bottom { margin-top: 30px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.24); display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; font-size: .8125rem; color: rgba(255,255,255,.86); }

/* Auth */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, .8fr) minmax(420px, 1.2fr); }
.auth-aside { display: grid; place-items: center; padding: 48px; background: linear-gradient(145deg, var(--cream), #0d4c27); }
.auth-aside-inner { max-width: 420px; }
.auth-aside .brand-mark {
  width: 2600px;
  height: auto;
  aspect-ratio: 457 / 546;
  margin: 0 auto 26px;
  object-fit: contain;
}
.auth-aside h1 { font-size: 2.3rem; text-align: center; }
.auth-aside p { margin-top: 14px; color: var(--ink-soft); text-align: center; }
.auth-main { display: grid; place-items: center; padding: 36px; background: var(--ivory); }
.auth-card { width: min(100%, 470px); }
.auth-card h2 { margin: 10px 0 10px; font-size: 2rem; }
.auth-card .form-card { margin-top: 26px; }

/* App shell */
.app-body { background: var(--ivory); }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; min-height: 0; height: 100vh; display: flex; flex-direction: column; gap: 26px;
  padding: 24px 18px; border-right: 1px solid var(--line); background: var(--ivory); z-index: 70;
}
.sidebar .brand { padding: 0 8px;}
.sidebar .brand-mark { width: 110px; height: auto; object-fit: contain; }
.sidebar-nav { display: grid; min-height: 0; flex: 1; align-content: start; gap: 6px; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 9px 12px;
  border-radius: 12px; color: var(--ink-soft); text-decoration: none; font-size: .93rem;
}
.sidebar-nav a:hover, .sidebar-nav a[aria-current="page"] { background: var(--success-soft); color: var(--sage-deep); }
.nav-icon {
  width: 22px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 22px;
  text-align: center; font-size: 1.05rem; line-height: 1;
}
.nav-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; }
.nav-icon-chat svg path { fill: currentColor; fill-opacity: .1; }
.sidebar-bottom { display: grid; flex: 0 0 auto; gap: 12px; min-width: 0; }
.user-chip { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.user-chip strong { display: block; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; }
.user-chip span { color: var(--ink-faint); font-size: .76rem; }
.sidebar form .btn { width: 100%; }
.app-main { min-width: 0; }
.app-topbar {
  position: sticky; top: 0; z-index: 50; min-height: 68px; display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 12px 30px; border-bottom: 1px solid var(--line); background: rgba(250,247,240,.92); backdrop-filter: blur(12px);
}
.app-topbar-title { margin: 0; color: var(--ink); font-size: 1rem; font-weight: 700; letter-spacing: 0; }
.sidebar-toggle { display: none; }
.app-content { width: min(1380px, 100%); padding: 34px 36px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 20px; margin-bottom: 28px; }
.page-head h1 { font-size: clamp(1.75rem, 3vw, 2.35rem); }
.page-head p { max-width: 68ch; margin: 8px 0 0; color: var(--ink-soft); }
.greeting-ar {
  display: block;
  margin-top: 6px;
  color: var(--sage-deep);
  direction: rtl;
  font-family: "Amiri", "Noto Naskh Arabic", Georgia, serif;
  font-size: 1.15rem;
  text-align: left;
}

/* Dashboard focus card. The qualified selector prevents the generic panel
   background declared below from turning this card white. */
.next-course-card { margin-bottom: 24px; }
.next-course-card h2,
.next-course-card .eyebrow,
.next-course-card .lead-sm { color: var(--white); }
.next-course-card .eyebrow { opacity: .92; }
.next-course-card p { margin: 6px 0 0; color: rgba(255, 255, 255, .96); }
.next-course-card[class*="student-color-"] { box-shadow: inset 7px 0 0 var(--student-color), var(--shadow-sm); }
.student-accent-dot {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 10px;
  border: 2px solid rgba(255, 255, 255, .72);
  border-radius: 50%;
  background: var(--student-color);
  vertical-align: .08em;
}
.next-course-card .btn-primary { background: var(--white); color: var(--sage-deep); box-shadow: none; }
.next-course-card .btn-secondary { border-color: rgba(255, 255, 255, .7); background: transparent; color: var(--white); }
.next-course-card .course-homeworks {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .28);
}
.next-course-card .course-homeworks ul { margin: 7px 0 0; padding-left: 20px; }
.next-course-card .link { color: var(--white); }
.attendance-actions {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .28);
}
.attendance-actions input { min-width: 250px; flex: 1; }
.att-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 4px solid rgba(255,255,255,.55);
  border-radius: 14px;
  background: rgb(26, 82, 54);
  color: var(--white);
  cursor: pointer;
  font-weight: 700;
  font-size: .92rem;
}
.att-btn.present { border-color: #bfe3a8; }
.att-btn.present:active { background: #4a9a2a; border-color: #4a9a2a; }
.att-btn.absent { border-color: #f3b3ae; }
.att-btn.absent:active { background: #c23b34; border-color: #c23b34; }
.att-btn.excused { border-color: #e8c15a; }
.att-btn.excused:active { background: #e8c15a; border-color: #e8c15a; color: #4a3a05; }

/* App cards / data */
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--white); box-shadow: var(--shadow-sm); }
.panel.next-course-card {
  overflow: hidden;
  border-color: transparent;
  background: var(--sage-deep);
  color: var(--white);
}
.panel.next-course-card :focus-visible { outline-color: var(--white); box-shadow: 0 0 0 5px var(--focus); }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { font-family: inherit; color: var(--ink); font-size: 1rem; font-weight: 750; letter-spacing: 0; }
.panel-body { padding: 22px; }
.panel-empty { padding: 38px 22px; color: var(--ink-faint); text-align: center; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--white); box-shadow: var(--shadow-sm); }
.stat-label { color: var(--ink-faint); font-size: .8rem; font-weight: 650; }
.stat-value { display: block; margin-top: 4px; color: var(--sage-deep); font-family: "Fraunces", Georgia, serif; font-size: 2rem; line-height: 1.15; }
.stat-detail { margin-top: 7px; color: var(--ink-soft); font-size: .8125rem; }
.stats-grid-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(290px, .75fr); gap: 22px; align-items: start; }
.dashboard-stack { display: grid; gap: 22px; }
.list { display: grid; gap: 0; }
.list-item { display: flex; min-width: 0; justify-content: space-between; align-items: center; gap: 16px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.list-item > :first-child { min-width: 0; }
.list-item:first-child { padding-top: 0; }
.list-item:last-child { padding-bottom: 0; border-bottom: 0; }
.course-card-list { gap: 8px; }
.course-card-list .course-card-row {
  padding: 12px 14px;
  border: 1.5px solid var(--line-strong);
  border-left: 7px solid var(--student-color, var(--sage-deep));
  border-radius: 14px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}
.list-main { min-width: 0; }
.list-title { color: var(--ink); font-weight: 700; text-decoration: none; }
.list-title:hover { color: var(--sage-deep); }
.list-meta { margin-top: 3px; color: var(--ink-faint); font-size: .875rem; }
.avatar { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--success-soft); color: var(--sage-deep); font-weight: 800; }
.avatar[class*="student-color-"] { background: var(--student-color); color: var(--identity-text-color, var(--white)); }
.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 27px; padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 750; white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #ecebe7; color: var(--ink-soft); }
.badge-prominent { min-height: 34px; padding: 6px 12px; border: 1px solid currentColor; font-size: .82rem; font-weight: 850; text-transform: uppercase; }
.progress-group { display: grid; gap: 6px; }
.progress-label { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-soft); font-size: .79rem; }
progress { width: 100%; height: 9px; overflow: hidden; border: 0; border-radius: 99px; background: #e7e6e1; }
progress::-webkit-progress-bar { background: #e7e6e1; border-radius: 99px; }
progress::-webkit-progress-value { background: var(--sage-dark); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--sage-dark); border-radius: 99px; }
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); overflow-wrap: break-word; text-align: left; vertical-align: middle; }
th { color: var(--ink-faint); font-size: .75rem; font-weight: 750; letter-spacing: .055em; text-transform: uppercase; white-space: nowrap; }
tbody tr:hover { background: rgba(174,209,195,.08); }
tbody tr:last-child td { border-bottom: 0; }
.table-action-cell {
  width: 1%;
  min-width: 108px;
  white-space: nowrap;
  text-align: right;
}
.table-action-cell .btn {
  min-width: max-content;
}
.accounts-table {
  border-collapse: separate;
  border-spacing: 0 8px;
}
.accounts-table th {
  background: var(--white);
}
.accounts-table td {
  background: inherit;
  border-bottom-color: color-mix(in srgb, var(--identity-color, var(--sage-deep)) 10%, var(--line));
}
.accounts-table .account-row td:first-child {
  border-radius: 10px 0 0 10px;
}
.accounts-table .account-row td:last-child {
  border-radius: 0 10px 10px 0;
}
.accounts-table .account-name-cell {
  position: relative;
  min-width: 250px;
  padding-left: 17px;
  border-left: 7px solid var(--identity-color, var(--sage-deep));
  overflow: hidden;
}
.accounts-table .account-row { background: var(--account-row-background, var(--white)); }
.accounts-table .account-row:hover { background: var(--account-row-hover, rgba(174,209,195,.08)); }
.accounts-table .account-row[class*="student-color-"] .avatar {
  background: var(--student-color);
  color: var(--identity-text-color, var(--white));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--student-color) 70%, #1f2924),
    0 0 0 2px color-mix(in srgb, var(--student-color) 22%, white);
}
.account-name-layout {
  display: block;
}
.account-color-band {
  display: none;
}
.account-name-layout > .cluster {
  min-width: 0;
}
.accounts-table .account-row[class*="student-color-"] {
  --account-row-background: color-mix(in srgb, var(--student-color-soft) 55%, white);
  --account-row-hover: color-mix(in srgb, var(--student-color-soft) 72%, white);
}
.accounts-table .account-row.account-color-custom {
  --account-row-background: color-mix(in srgb, var(--student-color-soft, var(--teacher-color-soft)) 55%, white);
  --account-row-hover: color-mix(in srgb, var(--student-color-soft, var(--teacher-color-soft)) 72%, white);
}
.accounts-table .account-row[class*="teacher-color-"] {
  --account-row-background: color-mix(in srgb, var(--teacher-color-soft) 55%, white);
  --account-row-hover: color-mix(in srgb, var(--teacher-color-soft) 72%, white);
}
.account-color-admin {
  --identity-color: var(--sage-deep);
  --account-row-background: #f4f8f6;
  --account-row-hover: #e4efeb;
}
.table-actions { display: flex; justify-content: flex-end; gap: 7px; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; padding: 17px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--white); }
.filters .field { min-width: 170px; flex: 1; }
.filters .field.search { min-width: min(100%, 280px); flex: 2; }
.filters .field.searchable-select { min-width: min(100%, 230px); }
.searchable-select-control { position: relative; }
.select-search { padding-right: 42px; }
.searchable-select-toggle {
  position: absolute; right: 4px; top: 4px; display: grid; place-items: center;
  width: 36px; min-height: 36px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-soft); cursor: pointer; font-size: 1rem;
}
.searchable-select-toggle:hover { background: var(--success-soft); color: var(--sage-deep); }
.searchable-select-list {
  position: absolute; z-index: 45; left: 0; right: 0; top: calc(100% + 6px);
  display: grid; gap: 3px; max-height: 260px; overflow-y: auto; padding: 6px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--white);
  box-shadow: var(--shadow-md);
}
.searchable-select-list[hidden] { display: none; }
.searchable-select-option {
  width: 100%; min-height: 36px; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); text-align: left; cursor: pointer; font-size: .9rem;
}
.searchable-select-option:hover,
.searchable-select-option.is-active,
.searchable-select-option[aria-selected="true"] { background: var(--success-soft); color: var(--sage-deep); }
.searchable-select-empty { padding: 9px 10px; color: var(--ink-faint); font-size: .875rem; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 22px; padding: 5px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); width: fit-content; max-width: 100%; }
.tabs a { padding: 8px 15px; border-radius: 999px; color: var(--ink-soft); text-decoration: none; white-space: nowrap; font-size: .84rem; font-weight: 650; }
.tabs a.active { background: var(--sage-deep); color: var(--white); }

/* Progress: five compact cards per desktop row, as in the approved mock-up. */
.progress-summary {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 20px;
  padding: 24px 28px;
  border-radius: var(--radius-lg);
  background: var(--sage-deep);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}
.progress-summary h2,
.progress-summary .eyebrow { color: var(--white); }
.progress-summary .eyebrow { opacity: .82; }
.progress-summary p { margin: 6px 0 0; color: rgba(255, 255, 255, .94); }
.progress-summary-ring { position: relative; width: 92px; height: 92px; flex: 0 0 auto; }
.progress-summary-ring svg { width: 92px; height: 92px; transform: rotate(-90deg); }
.progress-summary-ring .ring-track { fill: none; stroke: rgba(255, 255, 255, .24); stroke-width: 10; }
.progress-summary-ring .ring-value { fill: none; stroke: var(--white); stroke-width: 10; stroke-linecap: round; }
.progress-summary-ring strong { position: absolute; inset: 0; display: grid; place-items: center; color: var(--white); font-size: .94rem; }
.surah-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.surah-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 15px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--white);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}
.surah-card:hover { transform: translateY(-2px); border-color: rgba(80,149,121,.42); box-shadow: var(--shadow-md); }
.surah-card:focus-visible { outline-offset: 4px; }
.surah-card-head { display: flex; width: 100%; min-width: 0; flex-direction: column; align-items: center; gap: 6px; }
.surah-number { color: var(--ink-faint); font-size: .75rem; font-weight: 800; }
.surah-names { display: grid; min-width: 0; gap: 2px; text-align: center; }
.surah-names strong { overflow: hidden; color: var(--ink); font-size: .875rem; line-height: 1.25; text-overflow: ellipsis; }
.surah-ar {
  color: var(--sage-deep);
  direction: rtl;
  font-family: "Amiri", "Noto Naskh Arabic", Georgia, serif;
  font-size: 1.08rem;
  line-height: 1.3;
}
.surah-ring { position: relative; width: 58px; height: 58px; flex: 0 0 auto; }
.surah-ring svg { width: 58px; height: 58px; transform: rotate(-90deg); }
.surah-ring .ring-track { fill: none; stroke: #e7e6e1; stroke-width: 8; }
.surah-ring .ring-value { fill: none; stroke: var(--sage-deep); stroke-width: 8; stroke-linecap: round; }
.surah-ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--sage-deep);
  font-size: .75rem;
  font-weight: 800;
}
.surah-card.status-complete .ring-value { stroke: #2f9e5f; }
.surah-card.status-review .ring-value { stroke: #d2695a; }
.surah-card.status-active .ring-value { stroke: #d99a2b; }
.surah-card.status-idle .ring-value { stroke: var(--line-strong); }
.surah-card.status-complete .badge { background: #dcf1e3; color: #1d7a45; }
.surah-card.status-active .badge { background: #fdecc4; color: #92650b; }
.surah-card.status-review .badge { background: #fbe0da; color: #a8432c; }
.surah-card.status-idle .badge { background: #ecebe7; color: var(--ink-soft); }
.surah-card-status { margin-top: auto; }
.surah-portions { display: grid; width: 100%; gap: 3px; color: var(--ink-soft); font-size: .75rem; line-height: 1.35; }
.surah-portions span { overflow-wrap: anywhere; }
.surah-overall { color: var(--sage-deep); font-family: "Fraunces", Georgia, serif; font-size: 1.45rem; }
.mini-progresses { display: grid; width: 100%; gap: 8px; }

/* Students */
.student-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.student-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--student-color, var(--student-sage));
  border-radius: var(--radius-md);
  background: var(--white);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
}
.student-card:hover { border-color: var(--student-color, var(--student-sage)); box-shadow: var(--shadow-md); }
.student-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 5px;
  place-items: center;
  border-radius: 50%;
  background: var(--student-color, var(--student-sage));
  color: var(--white);
  font-size: .82rem;
  font-weight: 800;
}
.student-card-meta { color: var(--ink-soft); font-size: .8rem; }
.student-card-next { margin-top: 5px; color: var(--sage-deep); font-size: .76rem; font-weight: 700; }
.student-color-sage { --student-color: var(--student-sage); --student-color-soft: #dffbf2; --identity-color: var(--student-sage); }
.student-color-blue { --student-color: var(--student-blue); --student-color-soft: #e3eeff; --identity-color: var(--student-blue); }
.student-color-purple { --student-color: var(--student-purple); --student-color-soft: #efe7ff; --identity-color: var(--student-purple); }
.student-color-terracotta { --student-color: var(--student-coral); --student-color-soft: #fff0df; --identity-color: var(--student-coral); }
.student-color-teal { --student-color: var(--student-teal); --student-color-soft: #ddf9fb; --identity-color: var(--student-teal); }
.student-color-plum { --student-color: var(--student-plum); --student-color-soft: #ffe5f5; --identity-color: var(--student-plum); }
.student-color-slate { --student-color: var(--student-slate); --student-color-soft: #e8eaff; --identity-color: var(--student-slate); }
.student-color-olive { --student-color: var(--student-gold); --student-color-soft: #effbdc; --identity-color: var(--student-gold); }

/* Teacher identity colors are separate from course state colors. */
.teacher-color-emerald { --teacher-color: var(--teacher-emerald); --teacher-color-soft: #ddfaea; --identity-color: var(--teacher-emerald); }
.teacher-color-cobalt { --teacher-color: var(--teacher-cobalt); --teacher-color-soft: #e2edff; --identity-color: var(--teacher-cobalt); }
.teacher-color-violet { --teacher-color: var(--teacher-violet); --teacher-color-soft: #ede8ff; --identity-color: var(--teacher-violet); }
.teacher-color-amber { --teacher-color: var(--teacher-amber); --teacher-color-soft: #fff3d6; --identity-color: var(--teacher-amber); }
.teacher-color-turquoise { --teacher-color: var(--teacher-turquoise); --teacher-color-soft: #ddf8f8; --identity-color: var(--teacher-turquoise); }
.teacher-color-fuchsia { --teacher-color: var(--teacher-fuchsia); --teacher-color-soft: #ffe5f5; --identity-color: var(--teacher-fuchsia); }
.teacher-color-indigo { --teacher-color: var(--teacher-indigo); --teacher-color-soft: #e8ebff; --identity-color: var(--teacher-indigo); }
.teacher-color-lime { --teacher-color: var(--teacher-lime); --teacher-color-soft: #effbdc; --identity-color: var(--teacher-lime); }
.teacher-identity,
.student-identity {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: inherit;
  vertical-align: middle;
}
.identity-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border: 2px solid var(--white);
  border-radius: 50%;
  background: var(--identity-color, var(--sage-deep));
  box-shadow: 0 0 0 1px var(--identity-color, var(--sage-deep));
}
.color-choice-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.color-choice { position: relative; min-width: 0; cursor: pointer; }
.color-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  opacity: 0;
}
.color-choice > span {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--control-border);
  border-radius: 12px;
  background: var(--white);
  color: var(--ink-soft);
  font-size: .8125rem;
  font-weight: 650;
}
.color-choice input:checked + span {
  border-color: var(--identity-color, var(--sage-deep));
  background: color-mix(in srgb, var(--identity-color, var(--sage-deep)) 9%, white);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--identity-color, var(--sage-deep));
}
.color-choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 3px; }
.color-choice-auto { --identity-color: var(--sage-deep); }
.identity-color-picker {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}
.identity-color-picker input[type="color"] {
  width: 70px;
  height: 44px;
  min-height: 44px;
  padding: 3px;
  cursor: pointer;
}
.identity-color-picker input[name="teacher_color_hex"],
.identity-color-picker input[name="color_hex"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  text-transform: uppercase;
}

/* Shared calendar */
.calendar-tools { margin-bottom: 14px; }
.calendar-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
}
.calendar-period-nav {
  display: grid;
  grid-template-columns: 44px 255px 44px;
  align-items: center;
  gap: 8px;
}
.calendar-nav .calendar-arrow {
  width: 44px;
  padding-inline: 0;
  touch-action: manipulation;
}
.calendar-nav .calendar-arrow:hover,
.calendar-nav .calendar-arrow:active { transform: none; }
.calendar-period-nav strong {
  min-width: 0;
  overflow: hidden;
  color: var(--sage-deep);
  font-family: "Fraunces", Georgia, serif;
  font-variant-numeric: tabular-nums;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-scroll {
  overflow-x: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  scrollbar-gutter: stable;
}
.calendar {
  display: grid;
  min-width: 875px;
  grid-template-columns: repeat(7, minmax(125px, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--white);
}
.calendar-day {
  min-height: 170px;
  padding: 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--white);
}
.calendar-week .calendar-day { min-height: 430px; }
.calendar-day.outside { background: #f5f3ed; color: var(--ink-faint); }
.calendar-day.today { background: rgba(174, 209, 195, .14); }
.calendar-day > header {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--ink-faint);
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
}
.calendar-day-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: var(--sage-deep);
  text-decoration: none;
}
.calendar-day.today .calendar-day-number { background: var(--sage-deep); color: var(--white); }
.calendar-events { display: grid; gap: 6px; }
.calendar-event,
.calendar-unavailable {
  display: grid;
  min-width: 0;
  gap: 1px;
  padding: 7px 8px;
  overflow: hidden;
  border-left: 4px solid var(--student-color, var(--sage-deep));
  border-radius: 8px;
  background: var(--course-background, #edf6f1);
  color: var(--ink);
  font-size: .75rem;
  line-height: 1.3;
  text-decoration: none;
}
.calendar-event time,
.calendar-event strong,
.calendar-event span,
.calendar-unavailable strong,
.calendar-unavailable span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event time,
.calendar-event span,
.calendar-unavailable span { color: var(--ink-soft); }
.calendar-event.type-tajwid_theory { --course-background: #f1ecf8; }
.calendar-event.type-literacy { --course-background: #fbf0df; }
.calendar-event.type-arabic { --course-background: #e9f3f7; }
.calendar-event.has-identity-color {
  background: var(--student-color-soft);
}
.calendar-event.status-cancelled,
.course-row.status-cancelled {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  opacity: 1;
}
.calendar-event.status-cancelled time,
.calendar-event.status-cancelled span { color: var(--danger); }
.calendar-cancelled-label { color: var(--danger) !important; font-size: .78rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.course-row.status-cancelled td:first-child { border-left: 4px solid var(--danger); }
.calendar-unavailable {
  --identity-color: var(--neutral);
  --teacher-color: var(--neutral);
  --teacher-color-soft: var(--neutral-soft);
  border-left-width: 5px;
  border-color: var(--neutral);
  background: var(--neutral-soft);
  color: var(--neutral);
}
.calendar-unavailable strong,
.calendar-unavailable span { color: var(--neutral); }
.calendar-unavailable-label {
  font-size: .82rem;
  font-weight: 850;
  letter-spacing: .035em;
  text-transform: uppercase;
}
.calendar-event .teacher-identity,
.calendar-event .student-identity,
.calendar-unavailable .teacher-identity { gap: 5px; }
.calendar-event .identity-dot,
.calendar-unavailable .identity-dot { width: 9px; height: 9px; border-width: 1px; }
.calendar-meet-link {
  width: fit-content;
  margin-top: 4px;
  color: var(--sage-deep);
  font-weight: 800;
  text-underline-offset: 2px;
}
.calendar-event.status-cancelled .calendar-meet-link { display: none; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink-soft);
  font-size: .76rem;
}
.calendar-legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--sage-deep); }
.calendar-legend i.type-tajwid_theory { background: var(--student-plum); }
.calendar-legend i.type-literacy { background: var(--student-gold); }
.calendar-legend i.type-arabic { background: var(--student-blue); }
.calendar-legend i.cancelled { background: var(--danger); }
.calendar-legend i.unavailable { background: var(--neutral); }
.course-history-panel { margin-top: 24px; }
.course-row.status-cancelled td { color: var(--danger); }

/* Student profile */
.profile-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; padding: 26px; margin-bottom: 22px; border-radius: var(--radius-lg); background: var(--sage-deep); color: var(--white); }
.profile-hero[class*="student-color-"] { box-shadow: inset 7px 0 0 var(--student-color), var(--shadow-sm); }
.profile-hero h1,
.profile-hero .eyebrow { color: var(--white); }
.profile-hero p { margin: 8px 0 0; color: rgba(255,255,255,.92); }
.profile-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.profile-meta .badge { background: rgba(255,255,255,.15); color: var(--white); }
.profile-hero .btn-primary { background: var(--white); color: var(--sage-deep); box-shadow: none; }
.profile-hero .btn-secondary { border-color: rgba(255,255,255,.7); background: transparent; color: var(--white); }
.credentials-box { padding: 20px; margin-bottom: 22px; border: 1px solid rgba(138,103,32,.28); border-radius: var(--radius-md); background: var(--warning-soft); }
.credentials-value { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin-top: 12px; }
.credentials-value code { overflow-wrap: anywhere; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr); gap: 22px; align-items: start; }
.kv-list { display: grid; gap: 0; }
.kv { display: grid; grid-template-columns: minmax(130px, .4fr) 1fr; gap: 18px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--ink-faint); font-size: .82rem; }
.kv dd { margin: 0; }
.note-card { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: #fbfaf6; }
.note-card p { white-space: pre-wrap; }
.notification.unread { border-left: 4px solid var(--sage-dark); padding-left: 14px; }
.notification.notification-cancelled {
  border-left-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}
.notification.notification-cancelled .list-meta,
.notification.notification-cancelled .subtle { color: var(--danger); }
.callout { padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--success-soft); color: var(--sage-deep); }
.callout-warning { background: var(--warning-soft); color: var(--warning); }
.callout-danger { background: var(--danger-soft); color: var(--danger); }

/* Flashes */
.flash-region { position: fixed; right: 24px; top: 84px; z-index: 200; width: min(420px, calc(100% - 48px)); display: grid; gap: 10px; }
.flash { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); box-shadow: var(--shadow-md); }
.flash-success { border-left: 4px solid var(--success); }
.flash-danger { border-left: 4px solid var(--danger); }
.flash-warning { border-left: 4px solid var(--warning); }
.flash-close { display: grid; width: 36px; height: 36px; flex: 0 0 auto; padding: 0; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--ink-faint); cursor: pointer; }

/* Details / dialogs */
details.action-details { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--white); }
details.action-details > summary { padding: 16px 18px; color: var(--sage-deep); cursor: pointer; font-weight: 700; }
details.action-details[open] > summary { border-bottom: 1px solid var(--line); }
details.action-details > .details-body { padding: 20px; }
.confirm-form { display: inline; }

/* Error */
.error-page { min-height: 70vh; display: grid; place-items: center; padding: 40px 20px; }
.error-card { max-width: 620px; padding: 42px; text-align: center; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); }
.error-code { color: var(--sage-deep); font-family: "Fraunces", Georgia, serif; font-size: 4rem; line-height: 1; }
.error-card h1 { margin: 14px 0 12px; }

@media (max-width: 1080px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .surah-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .student-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .detail-grid { grid-template-columns: 1fr; }
  .color-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .public-links { display: none; position: absolute; left: 24px; right: 24px; top: 86px; flex-direction: column; align-items: stretch; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--ivory); box-shadow: var(--shadow-md); }
  .public-links.open { display: flex; }
  .mobile-toggle { display: inline-flex; }
  .contact-layout { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  body.sidebar-is-open {
    position: fixed;
    inset-inline: 0;
    width: 100%;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(var(--sidebar), calc(100% - 54px));
    height: 100dvh;
    max-height: 100dvh;
    gap: 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
    transform: translateX(-110%);
    transition: transform 220ms ease;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-nav { flex: 0 0 auto; overflow: visible; }
  .sidebar-bottom { margin-top: auto; }
  .sidebar-toggle { display: inline-flex; }
  .app-topbar { padding-inline: 18px; }
  .app-content { padding: 26px 18px 54px; }
  .calendar-period-nav { grid-template-columns: 42px minmax(170px, 190px) 42px; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-logo-panel { width: min(100%, 210px); justify-self: center; order: -1; }
}

@media (max-width: 640px) {
  .wrap { width: min(var(--max), calc(100% - 32px)); }
  .brand-mark { width: 50px; }
  .public-brand-mark { width: 42px; }
  .public-brand-wordmark { width: 112px; transform: translateY(5px); }
  .public-main section { padding: 64px 0; }
  .hero { padding-top: 54px !important; }
  .hero h1 { font-size: 2.35rem; }
  .card-grid, .two-col, .stats-grid, .form-grid { grid-template-columns: 1fr; }
  .surah-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .student-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .cta-banner { padding: 38px 22px; }
  .footer-grid { display: grid; }
  .footer-links { gap: 28px; }
  .auth-main { padding: 24px 16px; }
  .form-card { padding: 22px; }
  .filters { align-items: stretch; padding: 14px; }
  .filters .field,
  .filters .field.search,
  .filters .field.searchable-select { min-width: 100%; flex-basis: 100%; }
  .filters .btn { width: 100%; }
  .panel-head, .panel-body { padding-inline: 17px; }
  .profile-hero { grid-template-columns: 1fr; }
  .profile-hero .cluster,
  .profile-hero .cluster .btn { width: 100%; }
  .kv { grid-template-columns: 1fr; gap: 3px; }
  .list-item { align-items: flex-start; }
  .table-actions { justify-content: flex-start; }
  .table-wrap > table:not(.accounts-table):not(.tracking-table) { min-width: 680px; }
  .admin-report-filters + .admin-report-stats + .panel .table-wrap > table,
  .admin-report-groups .table-wrap > table { min-width: 980px; }
  .calendar-nav { align-items: stretch; }
  .calendar-period-nav {
    width: 100%;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
  }
  .calendar-nav [data-calendar-today-link] { width: 100%; }
  .calendar {
    min-width: 735px;
    grid-template-columns: repeat(7, minmax(105px, 1fr));
  }
  .calendar-day { min-height: 150px; padding: 8px; }
  .calendar-week .calendar-day { min-height: 360px; }
  .flash-region { right: 16px; top: 76px; width: calc(100% - 32px); }
  .attendance-actions { align-items: stretch; }
  .attendance-actions input,
  .attendance-actions .btn,
  .attendance-actions .att-btn { width: 100%; justify-content: center; }
  .progress-summary { align-items: flex-start; padding: 20px; }
  .progress-summary-ring { width: 76px; height: 76px; }
  .progress-summary-ring svg { width: 76px; height: 76px; }
  .color-choice-grid { grid-template-columns: 1fr; }
  .page-head > .cluster { width: 100%; }
  .page-head > .cluster .btn { flex: 1 1 150px; }
}

@media (max-width: 390px) {
  .surah-grid { grid-template-columns: 1fr; }
  .app-content { padding-inline: 14px; }
  .calendar { min-width: 700px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
.spacer-md { height: 18px; }
.justify-center { justify-content: center; }
.pre-wrap { white-space: pre-wrap; }
.break-word { overflow-wrap: anywhere; }

/* Messaging — WhatsApp-inspired structure, Dar Al Huda design system */
.chat-app-content {
  width: 100%;
  min-height: calc(100dvh - 68px);
  padding: 18px 30px 26px;
}
.chat-action-menu { position: relative; }
.chat-action-menu summary {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--sage-deep);
  border-radius: 50%;
  background: var(--sage-deep);
  color: var(--white);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 1.45rem;
  font-weight: 650;
  line-height: 1;
  list-style: none;
}
.chat-action-menu summary::-webkit-details-marker { display: none; }
.chat-action-menu summary:hover {
  background: var(--sage-dark);
  border-color: var(--sage-dark);
}
.chat-action-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: grid;
  min-width: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  box-shadow: var(--shadow-md);
}
.chat-action-popover a {
  padding: 13px 15px;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}
.chat-action-popover a:hover {
  background: var(--success-soft);
  color: var(--sage-deep);
}
.chat-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  width: 100%;
  height: calc(100dvh - 112px);
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-sm);
}
.chat-sidebar {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
  background: var(--white);
}
.chat-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.chat-sidebar-head > div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 10px;
}
.chat-sidebar-head h2 {
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: 0;
}
.chat-conversation-list { min-height: 0; overflow-y: auto; }
.chat-conversation {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  min-height: 76px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  transition: background 160ms ease, box-shadow 160ms ease;
}
.chat-conversation:hover { background: rgba(174, 209, 195, .11); }
.chat-conversation.is-active {
  background: rgba(174, 209, 195, .2);
  box-shadow: inset 4px 0 var(--identity-color, var(--sage-deep));
}
.chat-avatar,
.chat-thread-avatar,
.chat-message-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--identity-color, var(--sage-deep));
  color: var(--identity-text-color, var(--white));
  font-size: .76rem;
  font-weight: 800;
}
.chat-avatar { width: 44px; height: 44px; }
.chat-conversation-copy { min-width: 0; }
.chat-conversation-line {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.chat-conversation-line strong {
  overflow: hidden;
  font-size: .9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-conversation-line time {
  flex: 0 0 auto;
  color: var(--ink-faint);
  font-size: .75rem;
  white-space: nowrap;
}
.chat-conversation-preview { margin-top: 4px; color: var(--ink-faint); font-size: .8125rem; }
.chat-conversation-preview > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-unread {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--sage-deep);
  color: var(--white);
  font-size: .72rem;
  font-weight: 800;
  white-space: nowrap;
}
.chat-empty { padding: 34px 20px; color: var(--ink-faint); text-align: center; }
.chat-start {
  display: grid;
  min-width: 0;
  place-items: center;
  padding: 34px;
  background: linear-gradient(145deg, var(--ivory), rgba(174, 209, 195, .16));
}
.chat-start-card {
  width: min(100%, 490px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-sm);
}
.chat-start-card h2 { margin: 12px 0 7px; }
.chat-start-card > p { color: var(--ink-soft); }
.chat-start-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 14px;
  background: var(--success-soft);
  color: var(--sage-deep);
  font-size: 1.2rem;
}
.chat-main {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--ivory);
}
.chat-thread-head {
  display: flex;
  min-height: 70px;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}
.chat-thread-avatar { width: 44px; height: 44px; }
.chat-thread-heading { min-width: 0; margin-right: auto; }
.chat-thread-heading h2 {
  overflow: hidden;
  color: var(--ink);
  font-family: inherit;
  font-size: .95rem;
  font-weight: 750;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-thread-heading p {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--ink-faint);
  font-size: .8125rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-mobile-back {
  display: none;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: var(--sage-deep);
  text-decoration: none;
}
.chat-notice {
  flex: 0 0 auto;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(138, 103, 32, .18);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: .76rem;
  text-align: center;
}
.chat-message-list {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  padding: 22px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.chat-history-action { display: flex; justify-content: center; margin-bottom: 6px; }
.chat-message-row {
  display: flex;
  max-width: min(78%, 720px);
  align-items: flex-end;
  align-self: flex-start;
  gap: 8px;
}
.chat-message-row.is-mine { align-self: flex-end; flex-direction: row-reverse; }
.chat-message-avatar { width: 30px; height: 30px; font-size: .62rem; }
.chat-message-content { position: relative; min-width: 0; max-width: 100%; }
.chat-bubble {
  min-width: 112px;
  padding: 10px 12px 7px;
  border: 1px solid var(--line);
  border-radius: 4px 15px 15px 15px;
  background: var(--white);
  box-shadow: 0 2px 8px rgba(43, 46, 40, .05);
}
.chat-message-row.is-other[class*="student-color-"] .chat-bubble,
.chat-message-row.is-other[class*="teacher-color-"] .chat-bubble {
  border-left: 3px solid var(--identity-color);
  background: var(--teacher-color-soft, var(--student-color-soft, var(--white)));
}
.chat-message-row.is-mine .chat-bubble {
  border-radius: 15px 4px 15px 15px;
  border-color: rgba(80, 149, 121, .18);
  background: var(--success-soft);
}
.chat-message-row.is-mine[class*="student-color-"] .chat-bubble,
.chat-message-row.is-mine[class*="teacher-color-"] .chat-bubble {
  border-right: 3px solid var(--identity-color);
  background: var(--teacher-color-soft, var(--student-color-soft, var(--success-soft)));
}
.chat-sender-name {
  display: block;
  margin-bottom: 3px;
  color: var(--identity-color, var(--sage-deep));
  font-size: .8125rem;
}
.chat-message-text {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: .9rem;
  line-height: 1.45;
}
.chat-message-time {
  color: var(--ink-faint);
  font-size: .75rem;
  line-height: 1.2;
}
.chat-bubble.is-hidden { border-style: dashed; background: #ecebe7; }
.chat-hidden-reason {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  color: var(--warning);
  font-size: .7rem;
}
.chat-message-meta {
  display: flex;
  min-height: 20px;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 5px;
}
.chat-read-receipt {
  color: var(--ink-faint);
  font-size: .75rem;
  font-weight: 650;
  white-space: nowrap;
}
.chat-read-receipt.is-read { color: var(--sage-deep); }

.chat-attachments { display: grid; gap: 8px; margin-top: 8px; }
.chat-attachment {
  overflow: hidden;
  border: 1px solid rgba(43, 46, 40, .18);
  border-radius: 12px;
  background: rgba(255, 255, 255, .78);
  color: var(--ink);
  text-decoration: none;
}
.chat-attachment:focus-visible { outline-offset: 2px; }
.chat-attachment-image { display: grid; max-width: 300px; }
.chat-attachment-image img {
  width: 100%;
  max-height: 230px;
  object-fit: cover;
  background: var(--cream);
}
.chat-attachment-image > span {
  overflow: hidden;
  padding: 8px 10px;
  color: var(--ink-soft);
  font-size: .75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-attachment-file {
  display: flex;
  min-width: min(280px, 100%);
  align-items: center;
  gap: 10px;
  padding: 10px;
}
.chat-attachment-file > span:last-child { min-width: 0; }
.chat-attachment-file strong {
  display: block;
  overflow: hidden;
  font-size: .8125rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-attachment-file small { display: block; margin-top: 2px; color: var(--ink-faint); font-size: .75rem; }
.chat-attachment-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: var(--success-soft);
  color: var(--sage-deep);
  font-size: .68rem;
  font-weight: 850;
}

.chat-message-menu { position: absolute; top: 0; z-index: 8; }
.chat-message-row.is-other .chat-message-menu { right: -44px; }
.chat-message-row.is-mine .chat-message-menu { left: -44px; }
.chat-message-menu > summary { list-style: none; }
.chat-message-menu > summary::-webkit-details-marker { display: none; }
.chat-message-menu-trigger {
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}
.chat-message-menu-trigger:hover,
.chat-message-menu[open] .chat-message-menu-trigger { border-color: var(--line-strong); background: var(--white); }
.chat-message-menu-popover {
  position: absolute;
  top: 44px;
  width: min(290px, calc(100vw - 42px));
  padding: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--white);
  box-shadow: var(--shadow-md);
}
.chat-message-row.is-other .chat-message-menu-popover { left: 0; }
.chat-message-row.is-mine .chat-message-menu-popover { right: 0; }
.chat-message-menu-title { display: block; margin-bottom: 10px; color: var(--ink); font-size: .875rem; }
.chat-message-menu-popover .field { gap: 5px; }
.chat-message-menu-popover .field label { font-size: .75rem; }
.chat-message-menu-popover input { min-height: 40px; }

.chat-composer {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--white);
}
.chat-composer > .chat-attach-button {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--control-border);
  border-radius: 14px;
  background: var(--white);
  color: var(--sage-deep);
  cursor: pointer;
  font-size: 1.05rem;
}
.chat-composer > .chat-attach-button:hover { background: var(--success-soft); }
.chat-attach-button.is-disabled,
.chat-composer > .chat-attach-button.is-disabled:hover {
  opacity: .55;
  cursor: not-allowed;
  background: var(--white);
}
.chat-composer textarea {
  min-width: 140px;
  flex: 1 1 220px;
  min-height: 44px;
  max-height: 120px;
  margin: 0;
  padding: 10px 14px;
  overflow-y: auto;
  resize: none;
  border-radius: 16px;
  background: var(--ivory);
}
.chat-attachment-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.chat-attachment-selection {
  display: flex;
  flex: 1 0 100%;
  flex-wrap: wrap;
  gap: 7px;
}
.chat-attachment-selection:empty { display: none; }
.chat-selected-file {
  display: inline-flex;
  max-width: 100%;
  min-height: 30px;
  align-items: center;
  padding: 5px 9px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--ivory);
  color: var(--ink-soft);
  font-size: .75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-send { flex: 0 0 auto; min-height: 44px; }
.chat-new-messages {
  position: absolute;
  right: 20px;
  bottom: 78px;
  z-index: 3;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--sage-deep);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: .75rem;
  font-weight: 750;
}
.chat-new-messages[hidden] { display: none; }

@media (max-width: 760px) {
  .chat-app-content { padding: 18px 14px 18px; }
  .chat-shell { grid-template-columns: 1fr; border-radius: var(--radius-md); }
  .chat-index-shell { height: auto; min-height: 0; overflow: visible; }
  .chat-index-shell .chat-sidebar { min-height: 430px; border-right: 0; }
  .chat-index-shell .chat-start { min-height: 430px; border-top: 1px solid var(--line); }
  .chat-thread-shell { height: calc(100dvh - 132px); min-height: 520px; }
  .chat-thread-shell .chat-sidebar { display: none; }
  .chat-thread-shell .chat-main { min-height: 0; }
  .chat-mobile-back { display: grid; }
  .chat-message-row { max-width: 90%; }
}

@media (max-width: 640px) {
  .chat-action-menu summary { width: 38px; height: 38px; font-size: 1.45rem; }
  .chat-action-popover { right: 0; min-width: 210px; }
  .chat-start { padding: 18px; }
  .chat-start-card { padding: 22px; }
  .chat-thread-head { padding-inline: 10px; }
  .chat-thread-head .btn-small { padding-inline: 10px; }
  .chat-message-list { padding: 16px 12px; }
  .chat-composer { padding: 10px; }
  .chat-send { padding-inline: 14px; }
  .chat-attachment-file { min-width: 0; }
  .chat-attachment-image { max-width: min(270px, 100%); }
  .chat-message-row.is-other .chat-message-menu { right: -38px; }
  .chat-message-row.is-mine .chat-message-menu { left: -38px; }
  .chat-message-menu-trigger { width: 36px; height: 36px; }
}
