/* Mobile first: base styles target phones; wider layouts are layered on with min-width queries.
   Modern light theme: Inter, soft borderless cards, filled inputs, floating tab bar, teal → sky accents. */
:root {
  --bg: #f3f7f6;
  --surface: #ffffff;
  --surface-2: #eaf3f1;
  --field: #f1f5f4;
  --text: #13201e;
  --muted: #55696a;
  --border: #e1ebe8;
  --primary: #0a7a70;
  --primary-ink: #ffffff;
  --primary-soft: #d8f5ef;
  --primary-ring: rgba(10, 122, 112, .18);
  --grad: linear-gradient(135deg, #0a7a70, #0369a1);
  --gold: #946210;
  --gold-soft: #fcf1d6;
  --star: #f5a524;
  --accent2: #0284c7;
  --hero-from: #d4f6ee;
  --hero-to: #dcefff;
  --hero-text: #13201e;
  --hero-muted: #4b6463;
  --hero-bar: rgba(10, 122, 112, .14);
  --hero-fill: linear-gradient(90deg, #14b8a6, #38bdf8);
  --ok: #15803d;
  --ok-soft: #e7f8ed;
  --warn: #b45309;
  --warn-soft: #fef5e7;
  --bad: #b91c1c;
  --bad-soft: #fde4e2;
  --info: #1d4ed8;
  --info-soft: #e2eafd;
  --shadow-sm: 0 1px 2px rgba(15, 40, 35, .05);
  --shadow: 0 1px 2px rgba(15, 40, 35, .04), 0 6px 20px rgba(15, 40, 35, .06);
  --shadow-lg: 0 10px 40px rgba(15, 40, 35, .14);
  --radius: 20px;
  --tabbar-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabbar-space: calc(var(--tabbar-h) + 12px + var(--safe-b));
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(900px 480px at 110% -12%, #dbeffd 0, transparent 60%),
    radial-gradient(760px 420px at -15% -8%, #d6f6ee 0, transparent 58%),
    var(--bg);
  background-attachment: fixed;
  font: 16px/1.5 "Inter", "Noto Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
.ar { font-family: "Amiri", "Noto Naskh Arabic", "Geeza Pro", "Traditional Arabic", serif; direction: rtl; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
[hidden] { display: none !important; }
h1, h2, h3 { letter-spacing: -.015em; }

/* ─── Top bar ─────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(var(--safe-t) + 10px) 12px 10px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
}
.topbar h1 { flex: 1; margin: 0 4px; font-size: 22px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: inline-grid; place-items: center;
  min-width: 44px; height: 44px; padding: 0 6px;
  border: 0; border-radius: 14px; background: transparent; cursor: pointer;
}
.icon-btn:hover, .icon-btn:active { background: var(--surface); box-shadow: var(--shadow-sm); }

main {
  padding: 12px 16px calc(var(--tabbar-space) + 24px);
  max-width: 1100px; margin: 0 auto;
}

/* ─── Floating bottom tab bar (phones) ───── */
.tabbar {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + var(--safe-b)); z-index: 30;
  display: flex; justify-content: space-around; padding: 0 2px;
  height: var(--tabbar-h);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-radius: 24px;
  box-shadow: 0 0 0 1px rgba(15, 40, 35, .05), var(--shadow-lg);
}
.tabbar a, .tabbar button {
  border: 0; background: transparent; font: inherit; cursor: pointer; padding: 0;
  flex: 1; position: relative; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 10.5px; font-weight: 600; letter-spacing: -.01em;
}
.tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar svg { width: 22px; height: 22px; padding: 4px 12px; box-sizing: content-box; border-radius: 14px; transition: background .15s; }
.tabbar .active { color: var(--primary); }
.tabbar .active svg { background: var(--primary-soft); }
.tabbar .dot {
  position: absolute; top: 4px; left: calc(50% + 8px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}

/* ─── Menu drawer (phones) / sidebar (wide screens) ── */
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
  width: 292px; max-width: 86vw;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 14px) 12px calc(var(--safe-b) + 14px);
  background: var(--surface);
  overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(-102%); transition: transform .24s cubic-bezier(.2, .8, .2, 1);
  box-shadow: var(--shadow-lg);
  border-radius: 0 24px 24px 0;
}
.drawer.open { transform: none; }
.drawer:empty { display: none; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 49; background: rgba(15, 30, 28, .38); backdrop-filter: blur(2px); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px; margin-bottom: 6px; }
.drawer-head img { border-radius: 12px; flex: none; box-shadow: var(--shadow); }
.drawer-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 14px;
  min-height: 48px; padding: 0 12px; border-radius: 14px; border: 0; background: transparent;
  color: var(--text); text-decoration: none; font-weight: 550; font-size: 15px; cursor: pointer; text-align: left; width: 100%;
}
.nav-item svg { width: 22px; height: 22px; color: var(--muted); flex: none; }
.nav-item:hover { background: var(--field); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.nav-item.active svg { color: var(--primary); }
.nav-item.danger, .nav-item.danger svg { color: var(--bad); }
.nav-item .dot { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 11px; line-height: 20px; text-align: center; }
.grow { flex: 1; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 8px; }
.nav-lang { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 0 12px; }
.seg-sm { padding: 3px; border-radius: 12px; }
.seg-sm button { min-height: 34px; min-width: 46px; padding: 0 10px; font-size: 14px; border-radius: 9px; }
.lang-switch { display: inline-flex; }
.login .lang-switch { align-self: flex-end; margin-bottom: 8px; }
.kv { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; border-bottom: 1px solid var(--border); }
.kv.last { border-bottom: 0; }

/* ─── Cards & lists ─────────────────────── */
.card {
  background: var(--surface); border: 0; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 12px;
}
.card h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 4px 12px; }
.section-title h2 { margin: 0; font-size: 18px; font-weight: 750; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.row-link {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius); border: 0;
  background: var(--surface); box-shadow: var(--shadow);
  color: inherit; text-decoration: none; min-height: 68px;
  transition: transform .12s, box-shadow .12s;
}
.row-link:hover { box-shadow: 0 1px 2px rgba(15, 40, 35, .05), 0 10px 28px rgba(15, 40, 35, .09); }
.row-link:active { transform: scale(.99); }
.row-main { flex: 1; min-width: 0; }
.row-main strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 650; }
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 15px;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  background: linear-gradient(135deg, #ccf5ec, #dbeefe); color: var(--primary);
}
.chev { color: #9fb2b0; flex: none; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--field); color: var(--muted);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }

/* ─── Stats ─────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: 13px; color: var(--muted); font-weight: 550; }
.stat .value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12.5px; color: var(--muted); }

.bar { height: 10px; border-radius: 5px; background: var(--field); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--hero-fill); border-radius: 5px; }

.hero {
  background:
    radial-gradient(420px 220px at 105% -20%, rgba(56, 189, 248, .28), transparent 60%),
    radial-gradient(360px 200px at -10% 120%, rgba(20, 184, 166, .22), transparent 60%),
    linear-gradient(135deg, var(--hero-from), var(--hero-to));
  color: var(--hero-text); border: 0; box-shadow: var(--shadow);
}
.hero .muted { color: var(--hero-muted); }
.hero .bar { background: var(--hero-bar); }
.hero .bar > span { background: var(--hero-fill); }
.hero h2 { margin: 0; font-size: 23px; font-weight: 750; }
.hero .star-txt { color: var(--gold); }
a.child-card { display: block; text-decoration: none; color: var(--hero-text); }
a.child-card:active { transform: scale(.99); }

/* ─── Buttons & forms ─────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 15px;
  border: 0; background: var(--field); font-weight: 650; cursor: pointer;
  text-decoration: none; color: var(--text); transition: transform .1s, filter .15s;
}
.btn:hover { filter: brightness(.98); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: var(--primary-ink); box-shadow: 0 6px 18px rgba(10, 122, 112, .25); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn:disabled { opacity: .6; }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--tabbar-space) + 14px); z-index: 25;
  height: 54px; padding: 0 22px; border-radius: 18px; border: 0;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 10px 28px rgba(3, 105, 161, .3); cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.fab:active { transform: scale(.97); }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 7px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 50px; padding: 11px 15px;
  border: 1.5px solid transparent; border-radius: 14px; background: var(--field);
  font-size: 16px; /* prevents iOS zoom */
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.input:hover { background: #ebf1f0; }
textarea.input { min-height: 92px; resize: vertical; }
.input:focus { outline: none; background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.input:disabled { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-ref { display: grid; grid-template-columns: 1fr 88px; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }

.seg { display: flex; gap: 4px; background: var(--field); padding: 4px; border-radius: 16px; }
.seg button {
  flex: 1; min-height: 44px; border: 0; border-radius: 12px; background: transparent;
  font-weight: 600; cursor: pointer; color: var(--muted); transition: background .15s, color .15s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 2px 8px rgba(15, 40, 35, .06); }

.stars { display: flex; gap: 6px; }
.stars button {
  flex: 1; height: 54px; border-radius: 14px; border: 0; background: var(--field);
  font-size: 26px; line-height: 1; color: #cfdcd9; cursor: pointer; transition: transform .1s;
}
.stars button:active { transform: scale(.94); }
.stars button.on { color: var(--star); background: var(--gold-soft); }
.star-txt { color: var(--star); letter-spacing: 1px; white-space: nowrap; }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 50px; height: 50px; border-radius: 14px; border: 0; background: var(--field); font-size: 22px; cursor: pointer; }
.stepper input { text-align: center; flex: 1; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 4px; margin: 0 -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px; padding: 0 15px; border-radius: 12px;
  border: 0; background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border) inset;
  font-weight: 600; font-size: 14px; cursor: pointer; color: var(--text);
}
.chip.on { background: var(--primary); color: var(--primary-ink); box-shadow: 0 4px 12px rgba(10, 122, 112, .22); }

.search { position: relative; margin-bottom: 12px; }
.search .input { padding-left: 44px; background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border) inset; }
.search .input:focus { box-shadow: 0 0 0 4px var(--primary-ring); }
.search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); }

/* ─── Roll call ─────────────────────────── */
.roll { display: flex; flex-direction: column; gap: 10px; }
.roll-item { background: var(--surface); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.roll-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.roll-head .avatar { width: 38px; height: 38px; font-size: 14px; border-radius: 13px; }
.roll-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.roll-actions button {
  min-height: 52px; border-radius: 14px; border: 0; background: var(--field);
  font-size: 12.5px; font-weight: 650; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; gap: 3px;
  transition: background .15s, color .15s, transform .1s;
}
.roll-actions button:active { transform: scale(.96); }
.roll-actions button .i { font-size: 17px; }
.roll-actions button.on { color: #fff; box-shadow: 0 4px 12px rgba(15, 40, 35, .16); }
.roll-actions button.on.on_time { background: var(--ok); }
.roll-actions button.on.late { background: var(--warn); }
.roll-actions button.on.absent { background: var(--bad); }
.roll-actions button.on.excused { background: var(--info); }

/* ─── Timeline / history ─────────────────── */
.timeline { display: flex; flex-direction: column; gap: 10px; }
.entry { background: var(--surface); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); }
.entry-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.entry .ref { font-weight: 650; margin-top: 6px; }
.entry .note { margin-top: 8px; color: var(--muted); font-size: 14px; white-space: pre-wrap; padding: 8px 12px; background: var(--field); border-radius: 12px; }
.tag-hifz { background: var(--primary-soft); color: var(--primary); }
.tag-muraja { background: #dff0fd; color: #075985; }

.chart-box { position: relative; height: 220px; }

.amount { flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 700; }
.amount.overdue, .stat-bad .value { color: var(--bad); }
.amount.paid { color: var(--muted); }
.stat-bad { background: linear-gradient(135deg, #fff, #fff5f4); box-shadow: var(--shadow), 0 0 0 1px #f8d3cf inset; }

.alert-card { display: flex; gap: 12px; align-items: flex-start; }
.alert-card .ic { flex: none; width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; }
.alert-card.unread { box-shadow: var(--shadow), 0 0 0 2px var(--primary-soft) inset; }
.flag-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.flag { padding: 14px 16px; border-radius: 18px; background: var(--warn-soft); color: var(--text); font-size: 14px; }
.flag strong { display: block; color: var(--warn); }

.tabs { display: flex; gap: 4px; background: var(--field); padding: 4px; border-radius: 16px; margin: 20px 0 12px; }
.tabs button { flex: 1; min-height: 42px; border: 0; background: transparent; font-weight: 600; color: var(--muted); border-radius: 12px; cursor: pointer; }
.tabs button.on { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm), 0 2px 8px rgba(15, 40, 35, .06); }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

.menu { background: var(--surface); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; box-shadow: var(--shadow); }
.menu a, .menu button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 0 18px;
  border: 0; border-bottom: 1px solid var(--border); background: transparent; text-decoration: none; color: inherit; text-align: left; cursor: pointer; font-weight: 550;
}
.menu a:hover, .menu button:hover { background: var(--field); }
.menu > :last-child { border-bottom: 0; }
.menu .grow { flex: 1; }

/* ─── Login ─────────────────────────────── */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; max-width: 420px; margin: 0 auto; }
.login .brand { text-align: center; margin-bottom: 26px; }
.login .brand img { width: 80px; height: 80px; border-radius: 24px; box-shadow: 0 12px 30px rgba(3, 105, 161, .22); }
.login .brand h1 { margin: 14px 0 2px; font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.login .card { padding: 22px; box-shadow: var(--shadow-lg); }

/* ─── Bottom sheet ───────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(15, 30, 28, .38); backdrop-filter: blur(2px); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 28px 28px 0 0;
  padding-bottom: var(--safe-b); box-shadow: var(--shadow-lg);
  animation: up .26s cubic-bezier(.2, .8, .2, 1);
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: #d5e1de; margin: 10px auto 0; }
.sheet-head { display: flex; align-items: center; padding: 8px 10px 0 20px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 19px; font-weight: 750; }
.sheet-body { overflow-y: auto; padding: 14px 20px 22px; overscroll-behavior: contain; }
.sheet-body .card { background: var(--field); box-shadow: none; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabbar-space) + 82px);
  background: #13201e; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg);
}
.toast.err { background: var(--bad); }

.spinner { display: grid; place-items: center; padding: 48px; color: var(--muted); }

/* ─── Larger screens ─────────────────────── */
@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .list.cols { display: grid; grid-template-columns: 1fr 1fr; }
  .roll { display: grid; grid-template-columns: 1fr 1fr; }
  .sheet { left: 50%; right: auto; width: 560px; transform: translateX(-50%); bottom: 24px; border-radius: 28px; animation: none; }
  .chart-box { height: 260px; }
  .tabbar { left: 50%; right: auto; width: 520px; transform: translateX(-50%); }
}
/* Wide screens: the menu becomes a permanent sidebar and replaces the bottom tab bar */
@media (min-width: 900px) {
  body.authed { padding-left: 272px; }
  body.authed .drawer { transform: none; width: 256px; top: 12px; bottom: 12px; left: 12px; border-radius: 24px; box-shadow: var(--shadow); transition: none; }
  body.authed .drawer-backdrop { display: none !important; }
  body.authed .tabbar { display: none !important; }
  body.authed #menu-btn { display: none; }
  body.authed main { padding-bottom: 96px; }
  body.authed .fab { bottom: 28px; right: 28px; }
  body.authed .toast { bottom: 28px; }
  body.authed .sheet { left: calc(50% + 136px); }
}
@media (min-width: 1000px) {
  main { padding-top: 20px; }
  .charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .charts .card.wide { grid-column: span 2; }
  .roll { grid-template-columns: 1fr 1fr 1fr; }
  .list.cols { grid-template-columns: 1fr 1fr 1fr; }
}

/* Login brand block */
.brand-ar { font-size: 36px; line-height: 1.4; color: var(--primary); margin-top: 4px; }
.login .tagline { margin: 14px 0 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; line-height: 1.4; }
.login .tagline .muted { font-size: 16px; font-weight: 500; }

/* ─── Character layer: pattern, colour and gradient accents ─────────────── */
:root {
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%230a7a70' stroke-opacity='.11' stroke-width='1.2'%3E%3Crect x='18' y='18' width='28' height='28'/%3E%3Crect x='18' y='18' width='28' height='28' transform='rotate(45 32 32)'/%3E%3Ccircle cx='32' cy='32' r='6'/%3E%3C/g%3E%3C/svg%3E");
  --violet: #6d28d9;
  --violet-soft: #ede7fe;
}

/* Eight-point star pattern on hero cards and the sign-in screen */
.hero {
  background:
    var(--pattern),
    radial-gradient(420px 220px at 105% -20%, rgba(56, 189, 248, .30), transparent 60%),
    radial-gradient(360px 200px at -10% 120%, rgba(20, 184, 166, .26), transparent 60%),
    linear-gradient(135deg, #c9f4ea 0%, #d3ebff 60%, #e6defe 100%);
  background-size: 64px 64px, auto, auto, auto;
}
body:not(.authed) {
  background:
    var(--pattern),
    radial-gradient(900px 480px at 110% -12%, #d3ebff 0, transparent 60%),
    radial-gradient(760px 420px at -15% -8%, #c9f4ea 0, transparent 58%),
    var(--bg);
  background-size: 64px 64px, auto, auto, auto;
  background-attachment: fixed;
}

/* Gradient accents for the main actions */
.btn.primary { background: var(--grad); box-shadow: 0 8px 20px rgba(3, 105, 161, .22); }
.chip.on { background: var(--grad); box-shadow: 0 6px 14px rgba(3, 105, 161, .22); }
.tabbar .active svg { background: var(--grad); color: #fff; box-shadow: 0 6px 14px rgba(3, 105, 161, .28); }
.nav-item.active { background: linear-gradient(135deg, #d8f5ef, #dcefff); }
.section-title h2 { display: flex; align-items: center; gap: 10px; }
.section-title h2::before { content: ''; width: 6px; height: 20px; border-radius: 3px; background: var(--grad); }

/* Colourful avatars, rotating through a pastel palette down each list */
.avatar { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .6); }
:is(.list, .roll) > :nth-child(6n+1) .avatar { background: linear-gradient(135deg, #c9f4ea, #a7ecdc); color: #0a6b62; }
:is(.list, .roll) > :nth-child(6n+2) .avatar { background: linear-gradient(135deg, #d3ebff, #b3dcfd); color: #075985; }
:is(.list, .roll) > :nth-child(6n+3) .avatar { background: linear-gradient(135deg, #fde9c8, #fbd89d); color: #92400e; }
:is(.list, .roll) > :nth-child(6n+4) .avatar { background: linear-gradient(135deg, #e6defe, #d4c6fd); color: #5b21b6; }
:is(.list, .roll) > :nth-child(6n+5) .avatar { background: linear-gradient(135deg, #fde0e6, #fbc4d0); color: #9f1239; }
:is(.list, .roll) > :nth-child(6n+6) .avatar { background: linear-gradient(135deg, #dcf5d9, #bfeab9); color: #166534; }

/* Stat tiles: each its own tint with a colour accent */
.stat { position: relative; overflow: hidden; }
.stat::before { content: ''; position: absolute; left: 16px; top: 0; width: 28px; height: 4px; border-radius: 0 0 4px 4px; background: var(--tone, var(--primary)); }
.stats .stat:nth-child(4n+1) { --tone: #14b8a6; background: linear-gradient(160deg, #fff 55%, #e3f8f3); }
.stats .stat:nth-child(4n+2) { --tone: #0ea5e9; background: linear-gradient(160deg, #fff 55%, #e2f2fe); }
.stats .stat:nth-child(4n+3) { --tone: #f59e0b; background: linear-gradient(160deg, #fff 55%, #fef3dc); }
.stats .stat:nth-child(4n+4) { --tone: #8b5cf6; background: linear-gradient(160deg, #fff 55%, #efe9fe); }
.stats .stat.stat-bad { --tone: var(--bad); background: linear-gradient(160deg, #fff 50%, #fde7e5); }

/* Mosque branding on sign-in / invitation pages */
.login .brand .brand-icon { display: block; margin: 0 auto; }
.login .brand .org-logo { display: block; width: 210px; max-width: 70%; height: auto; margin: 14px auto 0; }
.login .brand h1 .org-name { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login .brand img.org-logo { width: 200px; height: auto; border-radius: 0; box-shadow: none; }
.login .brand h1:has(.org-name) { font-size: clamp(20px, 6vw, 30px); text-wrap: balance; }
.drawer-head .row-main strong { white-space: normal; line-height: 1.25; }

/* Recorder */
.recorder { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 14px; border-radius: 20px; background: var(--field); }
.rec-btn { width: 84px; height: 84px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; background: var(--grad); box-shadow: 0 10px 26px rgba(3, 105, 161, .3); transition: transform .12s; }
.rec-btn:active { transform: scale(.95); }
.rec-btn .dot-rec { width: 30px; height: 30px; border-radius: 50%; background: #fff; transition: border-radius .2s, width .2s, height .2s; }
.rec-btn.recording { background: var(--bad); box-shadow: 0 0 0 0 rgba(185, 28, 28, .45); animation: rec-pulse 1.4s infinite; }
.rec-btn.recording .dot-rec { width: 26px; height: 26px; border-radius: 6px; }
@keyframes rec-pulse { 0% { box-shadow: 0 0 0 0 rgba(185, 28, 28, .45); } 70% { box-shadow: 0 0 0 18px rgba(185, 28, 28, 0); } 100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0); } }
.rec-time { font-size: 28px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.rec-feedback { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--ok-soft); }
.rec-card .stars button { height: 46px; font-size: 22px; }

/* ─── Right-to-left (Arabic) ─────────────────────────────────────────────── */
[dir="rtl"] body { font-family: "Noto Sans Arabic", "Inter", system-ui, sans-serif; }
[dir="rtl"] .drawer { left: auto; right: 0; transform: translateX(102%); border-radius: 24px 0 0 24px; }
[dir="rtl"] .drawer.open { transform: none; }
[dir="rtl"] .fab { right: auto; left: 16px; }
[dir="rtl"] .search .input { padding-left: 15px; padding-right: 44px; }
[dir="rtl"] .search svg { left: auto; right: 15px; }
[dir="rtl"] .chev, [dir="rtl"] #back-btn svg { transform: scaleX(-1); }
[dir="rtl"] .stat::before { left: auto; right: 16px; }
[dir="rtl"] .nav-item, [dir="rtl"] .menu a, [dir="rtl"] .menu button { text-align: right; }
[dir="rtl"] .row-link[style*="text-align:left"], [dir="rtl"] button.row-link { text-align: right !important; }
[dir="rtl"] .tabbar .dot { left: auto; right: calc(50% + 8px); }
[dir="rtl"] .badge, [dir="rtl"] .amount, [dir="rtl"] .rec-time, [dir="rtl"] .stat .value { unicode-bidi: plaintext; }
/* Dates, times, numbers and e-mail addresses stay left-to-right */
[dir="rtl"] input[type="date"], [dir="rtl"] input[type="time"], [dir="rtl"] input[type="number"], [dir="rtl"] input[type="email"], [dir="rtl"] input[name="login"], [dir="rtl"] input[name="username"] { direction: ltr; text-align: right; }
@media (min-width: 900px) {
  [dir="rtl"] body.authed { padding-left: 0; padding-right: 272px; }
  [dir="rtl"] body.authed .drawer { left: auto; right: 12px; transform: none; border-radius: 24px; }
  [dir="rtl"] body.authed .fab { left: 28px; right: auto; }
  [dir="rtl"] body.authed .sheet { left: calc(50% - 136px); }
}
.brand-link { display: inline-block; flex: none; border-radius: 24px; } .login .brand .brand-link { display: block; width: max-content; margin: 0 auto; }
