/*
 * Public and member app styles.
 * Stage A public pages and the Stage B member dashboard. Other member pages
 * keep Tailwind until their redesign stage. Fonts are local; no third-party CDN.
 */

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url("/public/fonts/plus-jakarta-sans-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 500 900;
  font-display: swap;
  src: url("/public/fonts/fraunces-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Amiri";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/public/fonts/amiri-arabic-400.woff2") format("woff2");
}

:root {
  --ink: #102a43;
  --ink-soft: #334e68;
  --primary: #1f5c8b;
  --primary-dark: #17466b;
  --teal: #2c6e6a;
  --gold: #8a641f;
  --gold-soft: #ead8b4;
  --paper: #f7f1e5;
  --paper-deep: #efe6d5;
  --surface: #fffdf8;
  --line: #d9cdb8;
  --muted: #4f5f6c;
  --success: #246b4a;
  --danger: #a63d40;
  --shadow: 0 18px 40px -28px rgba(16, 42, 67, 0.45);
  --radius: 10px;
  --radius-lg: 18px;
  --shell: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    radial-gradient(circle at 12% 8%, rgba(184, 134, 47, 0.08), transparent 32%),
    radial-gradient(circle at 88% 12%, rgba(31, 92, 139, 0.07), transparent 30%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23102a43' stroke-opacity='.045' stroke-width='1'%3E%3Cpath d='M60 8l14 38 38 14-38 14-14 38-14-38-38-14 38-14z'/%3E%3Ccircle cx='60' cy='60' r='24'/%3E%3C/g%3E%3C/svg%3E");
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  width: min(100% - 40px, var(--shell));
  margin-inline: auto;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--gold);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.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: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--surface);
  border-radius: 6px;
}

.skip-link:focus {
  top: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-gold {
  background: var(--gold);
  color: #20180a;
}

.btn-gold:hover {
  background: #a27424;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}

.btn-ghost:hover {
  color: var(--primary);
}

.btn-sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 12px;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Marketing */
.marketing-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(217, 205, 184, 0.7);
  background: rgba(247, 241, 229, 0.88);
  backdrop-filter: blur(14px);
}

.marketing-header .container {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 72px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand img {
  width: 34px;
  height: 34px;
}

.brand span {
  font-size: 16px;
}

.marketing-nav {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.marketing-nav a:hover {
  color: var(--primary);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 78px 0 64px;
}

.hero .container {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 58px;
  align-items: center;
}

.hero h1 {
  max-width: 620px;
  font-size: clamp(44px, 6vw, 82px);
  line-height: 0.98;
}

.hero h1 em {
  color: var(--primary);
  font-style: normal;
}

.hero-lead {
  max-width: 520px;
  margin-top: 24px;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.hero-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.hero-note a {
  color: var(--primary);
  font-weight: 700;
}

.hero-art {
  position: relative;
  min-height: 480px;
}

.arch {
  position: absolute;
  inset: 12px 18px 12px 26px;
  overflow: hidden;
  border: 1px solid rgba(184, 134, 47, 0.55);
  border-radius: 220px 220px 14px 14px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.92), rgba(239, 230, 213, 0.95)),
    radial-gradient(circle at 50% 0%, rgba(184, 134, 47, 0.2), transparent 55%);
  box-shadow: var(--shadow);
}

.arch::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(184, 134, 47, 0.22);
  border-radius: 206px 206px 8px 8px;
}

.arch-content {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  padding: 80px 42px 40px;
  text-align: center;
}

.arabic {
  font-family: "Amiri", serif;
  direction: rtl;
  color: var(--ink);
}

.arch .arabic {
  font-size: clamp(30px, 3.7vw, 46px);
  line-height: 1.9;
}

.arch-translation {
  max-width: 330px;
  margin: 18px auto 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
}

.arch-ref {
  margin-top: 16px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.seal {
  position: absolute;
  right: 2px;
  bottom: 26px;
  display: grid;
  place-items: center;
  width: 118px;
  height: 118px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  text-align: center;
  box-shadow: var(--shadow);
  transform: rotate(7deg);
}

.seal::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px dashed rgba(184, 134, 47, 0.6);
  border-radius: 50%;
}

.seal strong {
  display: block;
  font-family: "Fraunces", serif;
  font-size: 30px;
  line-height: 1;
}

.seal span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stats-strip {
  border-block: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.62);
}

.stats-strip .container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.stat-strip-item {
  padding: 24px 26px;
  border-left: 1px solid var(--line);
}

.stat-strip-item:first-child {
  border-left: 0;
}

.stat-strip-item strong {
  display: block;
  font-family: "Fraunces", serif;
  font-size: 30px;
  line-height: 1;
}

.stat-strip-item span {
  color: var(--muted);
  font-size: 12px;
}

.section {
  padding: 84px 0;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 38px;
}

.section-head h2 {
  max-width: 620px;
  font-size: clamp(32px, 4vw, 48px);
}

.section-head p {
  max-width: 380px;
  color: var(--muted);
  font-size: 14px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.feature-card {
  position: relative;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.feature-card:hover {
  transform: translateY(-3px);
  border-color: rgba(31, 92, 139, 0.45);
  box-shadow: var(--shadow);
}

.feature-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 20px;
  border: 1px solid rgba(184, 134, 47, 0.4);
  border-radius: 50%;
  color: var(--gold);
  background: rgba(234, 216, 180, 0.25);
}

.feature-card h3 {
  margin-bottom: 8px;
  font-size: 21px;
}

.feature-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.step {
  padding: 30px 26px;
  border-left: 1px solid var(--line);
}

.step:first-child {
  border-left: 0;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-bottom: 18px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  font-family: "Fraunces", serif;
  font-size: 15px;
  font-weight: 700;
}

.step h3 {
  margin-bottom: 7px;
  font-size: 19px;
}

.step p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.quote-band {
  padding: 64px 0;
  background: var(--ink);
  color: var(--paper);
}

.quote-band .container {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
}

.quote-band .arabic {
  color: var(--paper);
  font-size: clamp(26px, 3.2vw, 42px);
  line-height: 1.9;
  text-align: right;
}

.quote-band blockquote {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(22px, 2.4vw, 32px);
  line-height: 1.35;
}

.quote-band cite {
  display: block;
  margin-top: 18px;
  color: var(--gold-soft);
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.cta-band {
  padding: 76px 0;
  background: var(--primary);
  color: #fff;
  text-align: center;
}

.cta-band h2 {
  max-width: 720px;
  margin: 0 auto;
  font-size: clamp(34px, 4.4vw, 56px);
}

.cta-band p {
  max-width: 520px;
  margin: 16px auto 28px;
  color: rgba(255, 255, 255, 0.78);
}

.cta-band .btn {
  background: var(--surface);
  color: var(--primary);
}

.site-footer {
  padding: 34px 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 12px;
}

.footer-links {
  display: flex;
  gap: 18px;
}

/* Login */
.auth-page {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  min-height: 100vh;
}

.auth-art {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
}

.auth-art::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.2;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg fill='none' stroke='%23ead8b4' stroke-width='1'%3E%3Cpath d='M90 10l18 62 62 18-62 18-18 62-18-62-62-18 62-18z'/%3E%3Ccircle cx='90' cy='90' r='42'/%3E%3C/g%3E%3C/svg%3E");
}

.auth-art > * {
  position: relative;
  z-index: 1;
}

.auth-art .brand span {
  color: var(--paper);
}

.auth-quote {
  max-width: 430px;
}

.auth-quote .arabic {
  color: var(--paper);
  font-size: 40px;
  line-height: 1.8;
}

.auth-quote p {
  margin-top: 18px;
  color: rgba(247, 241, 229, 0.76);
  font-family: "Fraunces", serif;
  font-size: 24px;
  line-height: 1.4;
}

.auth-quote cite {
  display: block;
  margin-top: 18px;
  color: var(--gold-soft);
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background: var(--paper);
}

.auth-card {
  width: min(100%, 430px);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-bottom: 8px;
  font-size: 36px;
}

.auth-card > p {
  color: var(--muted);
  font-size: 13px;
}

.auth-error {
  margin-top: 18px;
  padding: 11px 13px;
  border: 1px solid rgba(166, 61, 64, 0.35);
  border-radius: 7px;
  background: rgba(166, 61, 64, 0.07);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.6;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(184, 134, 47, 0.3);
  outline-offset: 1px;
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
}

.auth-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.auth-footer {
  margin-top: 24px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* Status pages */
.status-page {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 72px);
  padding: 44px 20px 64px;
}

.status-card {
  width: min(100%, 540px);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.status-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 20px;
  border: 1px solid rgba(184, 134, 47, 0.45);
  border-radius: 50%;
  background: rgba(234, 216, 180, 0.24);
  color: var(--gold);
}

.status-icon .icon {
  width: 24px;
  height: 24px;
}

.status-card h1 {
  font-size: clamp(30px, 4vw, 40px);
}

.status-card > p {
  max-width: 420px;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  padding: 5px 10px;
  border: 1px solid rgba(184, 134, 47, 0.4);
  border-radius: 999px;
  background: rgba(234, 216, 180, 0.25);
  color: #6f4d16;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-badge.danger {
  border-color: rgba(166, 61, 64, 0.35);
  background: rgba(166, 61, 64, 0.07);
  color: var(--danger);
}

.status-meta {
  display: grid;
  gap: 4px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.status-meta strong {
  color: var(--ink);
}

.status-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.status-actions .btn {
  min-width: 160px;
}

@media (max-width: 560px) {
  .status-card {
    padding: 28px 20px;
  }

  .status-actions .btn {
    width: 100%;
  }
}

/* App shell */
.app-body {
  min-height: 100vh;
  padding-bottom: 88px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(217, 205, 184, 0.8);
  background: rgba(247, 241, 229, 0.9);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 26px;
  min-height: 68px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.topnav a {
  padding: 9px 13px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.topnav a:hover {
  color: var(--primary);
  background: rgba(31, 92, 139, 0.06);
}

.topnav a[aria-current="page"] {
  color: var(--primary);
  background: rgba(31, 92, 139, 0.09);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper-deep);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
}

.avatar-img {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  object-fit: cover;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  display: none;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.96);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  backdrop-filter: blur(12px);
}

.bottom-nav a {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.bottom-nav a[aria-current="page"] {
  color: var(--primary);
  background: rgba(31, 92, 139, 0.08);
}

.bottom-nav .icon {
  width: 20px;
  height: 20px;
}

.page {
  padding: 34px 0 20px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.page-head h1 {
  font-size: clamp(34px, 4vw, 48px);
}

.page-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

/* Dashboard */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.dash-grid > *,
.stack,
.side-stack,
.log-layout > *,
.stats-grid > *,
.progress-grid > *,
.leader-layout > *,
.card,
.heatmap-card,
.admin-shell > *,
.admin-main,
.admin-sidebar {
  min-width: 0;
}

.stack {
  display: grid;
  gap: 18px;
}

.today-card {
  position: relative;
  overflow: hidden;
  padding: 28px;
  border: 1px solid rgba(31, 92, 139, 0.22);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.96), rgba(239, 230, 213, 0.88)),
    var(--surface);
  box-shadow: var(--shadow);
}

.today-card::before {
  content: "";
  position: absolute;
  top: -80px;
  right: -80px;
  width: 220px;
  height: 220px;
  border: 1px solid rgba(184, 134, 47, 0.22);
  border-radius: 50%;
}

.today-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
}

.today-head h2 {
  font-size: 26px;
}

.today-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.progress-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.progress-item {
  display: grid;
  gap: 9px;
}

.progress-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  font-weight: 700;
}

.progress-label span:last-child {
  color: var(--muted);
  font-weight: 600;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(16, 42, 67, 0.08);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 900ms cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-fill.teal {
  background: var(--teal);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.today-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.today-actions .btn-primary {
  flex: 1 1 220px;
}

.last-position {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.7);
}

.last-position .icon-wrap {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(184, 134, 47, 0.4);
  border-radius: 50%;
  color: var(--gold);
}

.last-position h3 {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.last-position p {
  color: var(--ink-soft);
  font-size: 13px;
}

.last-position .small {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-family: "Fraunces", serif;
  font-size: 28px;
  line-height: 1;
}

.stat-card small {
  color: var(--muted);
  font-size: 10px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.card-head h2,
.card-head h3 {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.card-head a {
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

.card-body {
  padding: 18px 20px;
}

.activity-list {
  display: grid;
}

.activity-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 20px;
  border-top: 1px solid rgba(217, 205, 184, 0.65);
}

.activity-row:first-child {
  border-top: 0;
}

.activity-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: rgba(31, 92, 139, 0.08);
  color: var(--primary);
}

.activity-mark.teal {
  background: rgba(44, 110, 106, 0.1);
  color: var(--teal);
}

.activity-main {
  min-width: 0;
  flex: 1;
}

.activity-main strong {
  display: block;
  font-size: 13px;
}

.activity-main span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-date {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.side-stack {
  display: grid;
  gap: 18px;
}

.streak-card {
  position: relative;
  padding: 22px;
  border: 1px solid rgba(184, 134, 47, 0.45);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(234, 216, 180, 0.4), rgba(255, 253, 248, 0.9));
}

.streak-top {
  display: flex;
  align-items: center;
  gap: 16px;
}

.streak-seal {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  flex: none;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: var(--surface);
  text-align: center;
}

.streak-seal strong {
  display: block;
  font-family: "Fraunces", serif;
  font-size: 24px;
  line-height: 1;
}

.streak-seal span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.streak-card h3 {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.streak-card p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.streak-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.freeze-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid rgba(44, 110, 106, 0.3);
  border-radius: 999px;
  background: rgba(44, 110, 106, 0.07);
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
}

.verse-mini {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
}

.verse-mini .arabic {
  color: var(--paper);
  font-size: 27px;
  line-height: 1.8;
  text-align: right;
}

.verse-mini p {
  margin-top: 12px;
  color: rgba(247, 241, 229, 0.74);
  font-size: 12px;
  line-height: 1.7;
}

.verse-mini span {
  display: block;
  margin-top: 10px;
  color: var(--gold-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.heatmap-card .card-body {
  overflow-x: auto;
}

.heatmap {
  display: grid;
  grid-template-rows: repeat(7, 13px);
  grid-auto-flow: column;
  grid-auto-columns: 13px;
  gap: 3px;
  width: max-content;
}

.heat-cell {
  width: 13px;
  height: 13px;
  border: 1px solid rgba(16, 42, 67, 0.07);
  border-radius: 2px;
  background: var(--paper-deep);
}

.heatmap-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 26px;
}

.heatmap-summary {
  display: grid;
  min-width: 160px;
  gap: 12px;
}

.heatmap-summary div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(217, 205, 184, 0.6);
}

.heatmap-summary div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.heatmap-summary span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.heatmap-summary strong {
  font-family: "Fraunces", serif;
  font-size: 17px;
  font-weight: 700;
}

.heat-cell[data-level="1"] {
  background: #c6d8e6;
}

.heat-cell[data-level="2"] {
  background: #8db3cf;
}

.heat-cell[data-level="3"] {
  background: #4f85ad;
}

.heat-cell[data-level="4"] {
  background: var(--primary);
}

.heat-cell[data-frozen="true"] {
  background: #d9eceb;
  border-color: #9ccbc8;
}

.heat-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 10px;
}

.heatmap-hint {
  display: none;
  margin-top: 8px;
}

@media (max-width: 820px) {
  .heatmap-hint {
    display: block;
  }
}

.juz-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.juz-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper-deep);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.juz-cell[data-level="1"] {
  background: #c6d8e6;
  color: var(--ink);
}

.juz-cell[data-level="2"] {
  background: #8db3cf;
  color: var(--ink);
}

.juz-cell[data-level="3"] {
  background: #3d6f92;
  color: #fff;
}

.juz-cell[data-level="4"] {
  background: var(--primary);
  color: #fff;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 180px;
  margin-top: 10px;
}

.bar-item {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  height: 100%;
  text-align: center;
}

.bar {
  width: 100%;
  min-height: 4px;
  border-radius: 4px 4px 0 0;
  background: var(--primary);
}

.bar-item:nth-child(even) .bar {
  background: var(--teal);
}

.bar-item span {
  color: var(--muted);
  font-size: 10px;
}

.bar-item strong {
  font-family: "Fraunces", serif;
  font-size: 11px;
  font-weight: 700;
}

.heat-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.heat-swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--paper-deep);
}

.heat-swatch[data-level="1"] { background: #c6d8e6; }
.heat-swatch[data-level="2"] { background: #8db3cf; }
.heat-swatch[data-level="3"] { background: #4f85ad; }
.heat-swatch[data-level="4"] { background: var(--primary); }
.heat-swatch[data-frozen="true"] { background: #d9eceb; border: 1px solid #9ccbc8; }

/* Log form */
.log-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.7fr);
  gap: 18px;
  align-items: start;
}

.log-form {
  padding: 26px;
}

.log-form h2 {
  font-size: 24px;
}

.log-form .form-intro {
  margin: 5px 0 22px;
  color: var(--muted);
  font-size: 12px;
}

.continue-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid rgba(31, 92, 139, 0.25);
  border-radius: var(--radius);
  background: rgba(31, 92, 139, 0.05);
}

.continue-box .icon-wrap {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid rgba(31, 92, 139, 0.25);
  border-radius: 50%;
  color: var(--primary);
}

.continue-box strong {
  display: block;
  font-size: 13px;
}

.continue-box span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
}

.segmented button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(16, 42, 67, 0.12);
}

.amount-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.amount-chip {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.amount-chip[aria-pressed="true"] {
  border-color: var(--primary);
  background: rgba(31, 92, 139, 0.08);
  color: var(--primary);
}

.amount-input {
  width: 88px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  text-align: center;
  font-weight: 700;
}

.summary-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.summary-box > div {
  display: grid;
  gap: 2px;
}

.summary-box span {
  color: var(--muted);
  font-size: 11px;
}

.summary-box strong {
  font-family: "Fraunces", serif;
  font-size: 20px;
  white-space: nowrap;
}

.field .segmented {
  justify-self: start;
}

details.detail-drawer {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

details.detail-drawer summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  list-style: none;
}

details.detail-drawer summary::-webkit-details-marker {
  display: none;
}

details.detail-drawer summary::before {
  content: "+";
  display: inline-block;
  width: 18px;
  color: var(--gold);
  font-weight: 800;
}

details.detail-drawer[open] summary::before {
  content: "−";
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.side-note {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.side-note h3 {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.side-note p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.mini-log {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.mini-log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(217, 205, 184, 0.6);
  font-size: 12px;
}

.mini-log-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.mini-log-row span {
  color: var(--muted);
  font-size: 11px;
}

/* Leaderboard */
.leader-layout {
  display: grid;
  gap: 18px;
}

.leader-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.month-tabs {
  display: flex;
  gap: 4px;
}

.month-tabs button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.month-tabs button[aria-pressed="true"] {
  border-color: var(--line);
  background: var(--surface);
  color: var(--primary);
}

.podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.podium-card {
  position: relative;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.podium-card.first {
  border-color: rgba(184, 134, 47, 0.65);
  background: linear-gradient(160deg, rgba(234, 216, 180, 0.45), var(--surface));
}

.podium-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-family: "Fraunces", serif;
  font-size: 14px;
  font-weight: 700;
}

.podium-card.first .podium-rank {
  border-color: var(--gold);
  color: var(--gold);
}

.podium-name {
  font-family: "Fraunces", serif;
  font-size: 20px;
  line-height: 1.1;
}

.podium-score {
  margin-top: 8px;
  color: var(--primary);
  font-family: "Fraunces", serif;
  font-size: 26px;
  font-weight: 700;
}

.podium-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.leader-table {
  width: 100%;
  border-collapse: collapse;
}

.leader-table th,
.leader-table td {
  padding: 12px 14px;
  text-align: left;
  border-top: 1px solid rgba(217, 205, 184, 0.65);
  font-size: 12px;
}

.leader-table th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.leader-table td:last-child,
.leader-table th:last-child {
  text-align: right;
}

.leader-table tr.is-me {
  background: rgba(31, 92, 139, 0.06);
}

.leader-person {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.leader-person .avatar {
  width: 30px;
  height: 30px;
  font-size: 10px;
}

.you-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.leader-cards {
  display: none;
  gap: 10px;
}

.leader-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.leader-card.is-me {
  border-color: rgba(31, 92, 139, 0.45);
  background: rgba(31, 92, 139, 0.05);
}

.leader-card .rank {
  width: 24px;
  color: var(--muted);
  font-family: "Fraunces", serif;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.leader-card .person {
  min-width: 0;
  flex: 1;
}

.leader-card .person strong {
  display: block;
  font-size: 13px;
}

.leader-card .person > span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.account-head {
  display: flex;
  align-items: center;
  gap: 18px;
}

.table-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-member-cards {
  display: none;
  padding: 12px;
}

.leader-card .score {
  color: var(--primary);
  font-family: "Fraunces", serif;
  font-size: 20px;
  font-weight: 700;
}

/* Admin */
.admin-body {
  min-height: 100vh;
}

.admin-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.7);
}

.admin-sidebar .brand {
  padding: 0 10px 20px;
}

.admin-sidebar .brand span {
  font-size: 14px;
}

.admin-nav {
  display: grid;
  gap: 3px;
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-nav a:hover {
  color: var(--primary);
  background: rgba(31, 92, 139, 0.06);
}

.admin-nav a[aria-current="page"] {
  color: var(--primary);
  background: rgba(31, 92, 139, 0.09);
}

.admin-main {
  padding: 26px 30px 60px;
}

.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

.admin-top h1 {
  font-size: 34px;
}

.admin-top p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.admin-stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.admin-stat span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-stat strong {
  display: block;
  margin-top: 5px;
  font-family: "Fraunces", serif;
  font-size: 28px;
  line-height: 1;
}

.pending-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid rgba(184, 134, 47, 0.45);
  border-radius: var(--radius);
  background: rgba(234, 216, 180, 0.22);
}

.pending-person {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.pending-person strong {
  display: block;
  font-size: 13px;
}

.pending-person span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.pending-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 12px 14px;
  text-align: left;
  border-top: 1px solid rgba(217, 205, 184, 0.65);
  font-size: 12px;
}

.admin-table th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-santri {
  background: rgba(46, 125, 91, 0.1);
  color: var(--success);
}

.badge-admin {
  background: rgba(31, 92, 139, 0.1);
  color: var(--primary);
}

.badge-pending {
  background: rgba(184, 134, 47, 0.14);
  color: #8a641f;
}

.admin-empty {
  padding: 30px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* Toast and modal */
.toast {
  position: fixed;
  right: 20px;
  bottom: 96px;
  z-index: 80;
  max-width: 340px;
  padding: 13px 16px;
  border: 1px solid rgba(46, 125, 91, 0.45);
  border-radius: 8px;
  background: #f0f8f4;
  color: #1d5a40;
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(16, 42, 67, 0.45);
}

.modal-backdrop.is-open {
  display: grid;
}

.modal {
  width: min(100%, 420px);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 30px 80px -30px rgba(16, 42, 67, 0.6);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-head h2 {
  font-size: 24px;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
}

/* Motion */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: rise 700ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.reveal-delay-1 { animation-delay: 90ms; }
.reveal-delay-2 { animation-delay: 180ms; }
.reveal-delay-3 { animation-delay: 270ms; }

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Responsive */
@media (max-width: 1040px) {
  .hero .container,
  .quote-band .container {
    grid-template-columns: 1fr;
  }

  .hero-art {
    min-height: 420px;
    max-width: 520px;
    margin: 0 auto;
  }

  .dash-grid,
  .log-layout {
    grid-template-columns: 1fr;
  }

  .side-stack {
    grid-template-columns: 1fr 1fr;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .admin-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .admin-nav a {
    white-space: nowrap;
  }
}

@media (max-width: 820px) {
  .topnav {
    display: none;
  }

  .bottom-nav {
    display: grid;
  }

  .topbar-actions .btn {
    display: inline-flex;
    width: 38px;
    min-height: 38px;
    padding: 0;
  }

  .topbar-actions .target-label {
    display: none;
  }

  .card-head {
    flex-wrap: wrap;
  }

  .table-tools {
    width: 100%;
  }

  .table-tools input,
  .table-tools select {
    flex: 1;
    min-width: 0;
  }

  .admin-table {
    display: none;
  }

  .admin-member-cards {
    display: grid;
  }

  .juz-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .podium {
    grid-template-columns: 1fr;
  }

  .podium-card.first {
    order: -1;
  }

  .leader-table {
    display: none;
  }

  .leader-cards {
    display: grid;
  }

  .card-grid,
  .steps {
    grid-template-columns: 1fr;
  }

  .step {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .step:first-child {
    border-top: 0;
  }

  .marketing-nav {
    display: none;
  }

  .marketing-header .container {
    justify-content: space-between;
  }

  .section {
    padding: 58px 0;
  }

  .section-head {
    display: block;
  }

  .section-head p {
    margin-top: 10px;
  }

  .auth-page {
    grid-template-columns: 1fr;
  }

  .auth-art {
    min-height: 280px;
    padding: 28px;
  }

  .auth-quote .arabic {
    font-size: 30px;
  }

  .auth-quote p {
    font-size: 19px;
  }

  .auth-panel {
    padding: 30px 18px;
  }

  .admin-main {
    padding: 22px 16px 50px;
  }

  .admin-stats {
    grid-template-columns: 1fr 1fr;
  }

  .pending-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .pending-actions {
    width: 100%;
  }

  .pending-actions .btn {
    flex: 1;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .container {
    width: min(100% - 28px, var(--shell));
  }

  .hero {
    padding-top: 48px;
  }

  .hero h1 {
    font-size: 45px;
  }

  .hero-lead {
    font-size: 15px;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .hero-art {
    min-height: 390px;
  }

  .arch {
    inset: 8px 4px;
  }

  .arch-content {
    padding: 64px 22px 30px;
  }

  .seal {
    right: -4px;
    bottom: 10px;
    width: 92px;
    height: 92px;
  }

  .seal strong {
    font-size: 24px;
  }

  .stats-strip .container {
    grid-template-columns: 1fr 1fr;
  }

  .stat-strip-item {
    border-top: 1px solid var(--line);
  }

  .stat-strip-item:nth-child(odd) {
    border-left: 0;
  }

  .stat-strip-item:nth-child(-n+2) {
    border-top: 0;
  }

  .page-head {
    display: block;
  }

  .page-head .date-chip {
    margin-top: 12px;
  }

  .today-card,
  .log-form {
    padding: 20px;
  }

  .progress-grid {
    grid-template-columns: 1fr;
  }

  .today-actions .btn {
    width: 100%;
    flex: none;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .side-stack {
    grid-template-columns: 1fr;
  }

  .activity-row {
    padding-inline: 15px;
  }

  .activity-date {
    display: none;
  }

  .site-footer .container {
    display: block;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
    margin-top: 10px;
  }

  .account-head {
    flex-wrap: wrap;
  }

  .account-head .btn {
    width: 100%;
  }

  .auth-card {
    padding: 26px 20px;
  }

  .auth-card h1 {
    font-size: 30px;
  }

  .admin-top h1 {
    font-size: 28px;
  }
}

/* Member app (Stage B) */
.app-body .brand {
  flex: none;
}

.lang-form,
.streak-actions form {
  display: flex;
  margin: 0;
}

.avatar-link {
  display: grid;
  place-items: center;
  border-radius: 50%;
  flex: none;
}

.avatar-link:hover {
  box-shadow: 0 0 0 3px rgba(31, 92, 139, 0.12);
}

.alert {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
}

.alert-success {
  border-color: rgba(36, 107, 74, 0.25);
  background: rgba(36, 107, 74, 0.08);
  color: var(--success);
}

.alert-error {
  border-color: rgba(166, 61, 64, 0.25);
  background: rgba(166, 61, 64, 0.08);
  color: var(--danger);
}

.today-empty {
  display: grid;
  justify-items: start;
  gap: 14px;
  padding: 20px;
  border: 1px dashed rgba(31, 92, 139, 0.3);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.65);
}

.today-empty p {
  color: var(--muted);
  font-size: 13px;
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.card-links a {
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

.activity-list,
.activity-row,
.activity-side {
  min-width: 0;
}

.activity-row {
  overflow: hidden;
}

.activity-main {
  min-width: 0;
  overflow: hidden;
}

.activity-side {
  display: grid;
  justify-items: end;
  gap: 2px;
  flex: none;
}

.activity-edit {
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
}

.activity-edit:hover {
  text-decoration: underline;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

a.stat-card {
  color: inherit;
}

a.stat-card:hover {
  border-color: rgba(31, 92, 139, 0.35);
}

.year-form {
  display: flex;
  align-items: center;
}

.year-form select {
  min-height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.heatmap button.heat-cell {
  padding: 0;
  cursor: pointer;
}

.heatmap button.heat-cell:hover {
  transform: scale(1.15);
}

.heatmap button.heat-cell.is-filler,
.heat-cell.is-filler {
  border-color: transparent;
  background: transparent;
  pointer-events: none;
}

.heatmap-card .card-body {
  overflow-x: visible;
}

.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.heatmap {
  grid-template-rows: repeat(7, 10px);
  grid-auto-columns: 10px;
  gap: 2px;
}

.heatmap .heat-cell {
  width: 10px;
  height: 10px;
}

.heatmap-body {
  display: block;
}

.heatmap-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
  margin-top: 18px;
  gap: 16px;
}

.heatmap-summary div {
  display: block;
  padding-bottom: 0;
  border-bottom: 0;
}

.heatmap-summary strong {
  display: block;
  margin-top: 2px;
}

.heatmap-detail {
  min-height: 18px;
  margin-top: 10px;
}

.heatmap-details {
  margin-top: 8px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

.heatmap-details summary {
  cursor: pointer;
}

.heatmap-day-list {
  display: grid;
  gap: 0;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-weight: 500;
}

.heatmap-day-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid rgba(217, 205, 184, 0.6);
}

.heatmap-day-list li:first-child {
  border-top: 0;
}

.target-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 10px;
}

.target-input-wrap input {
  width: 100%;
  min-height: 44px;
  padding: 0 118px 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.target-input-wrap span {
  position: absolute;
  right: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field .amount-input {
  width: 88px;
  min-height: 40px;
  padding: 0 10px;
}

[data-log-juz]:not([hidden]),
[data-log-pages]:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-log-row > div {
  display: grid;
  gap: 2px;
}

.segmented a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.segmented a[aria-current="page"] {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(16, 42, 67, 0.12);
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.check-inline input {
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--primary);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.pager a {
  color: var(--primary);
  font-weight: 700;
}

@media (max-width: 560px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.modal .field + .field {
  margin-top: 18px;
}

.modal .field-hint {
  margin-top: 8px;
}

.modal .form-actions {
  margin-top: 22px;
}

@media (min-width: 821px) {
  .app-body {
    padding-bottom: 0;
  }
}

@media (max-width: 820px) {
  .topbar-actions .btn {
    min-height: 38px;
  }

  .activity-side {
    justify-items: end;
  }

  .heatmap-body {
    display: block;
  }

  .heatmap-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 18px;
  }

  .heatmap-summary div {
    display: block;
    padding: 0;
    border-bottom: 0;
  }

  .heatmap-summary strong {
    display: block;
    margin-top: 2px;
  }
}

@media (max-width: 560px) {
  .page-head h1 {
    font-size: 36px;
  }

  .date-chip {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-inner {
    gap: 12px;
  }

  .brand span {
    max-width: 126px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions {
    gap: 6px;
  }

  .target-input-wrap input {
    padding-right: 106px;
  }
}
