:root {
  --bg: #f7f1e3;
  --card: #fffdf7;
  --ink: #1d2a22;
  --muted: #6b6a5e;
  --line: #e6dcc3;
  --brand: #0f5a3f;
  --brand-dark: #093d2b;
  --gold: #b8892d;
  --gold-light: #e2c47a;
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23b8892d' stroke-opacity='.16' stroke-width='1'%3E%3Crect x='18' y='18' width='36' height='36'/%3E%3Crect x='18' y='18' width='36' height='36' transform='rotate(45 36 36)'/%3E%3Ccircle cx='36' cy='36' r='7'/%3E%3Cpath d='M0 0L18 18M72 0L54 18M0 72L18 54M72 72L54 54'/%3E%3C/g%3E%3C/svg%3E");
  --pattern-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23e2c47a' stroke-opacity='.22' stroke-width='1'%3E%3Crect x='18' y='18' width='36' height='36'/%3E%3Crect x='18' y='18' width='36' height='36' transform='rotate(45 36 36)'/%3E%3Ccircle cx='36' cy='36' r='7'/%3E%3Cpath d='M0 0L18 18M72 0L54 18M0 72L18 54M72 72L54 54'/%3E%3C/g%3E%3C/svg%3E");
  --rosette: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cg fill='none' stroke='%23b8892d' stroke-width='1.3'%3E%3Crect x='7' y='7' width='14' height='14'/%3E%3Crect x='7' y='7' width='14' height='14' transform='rotate(45 14 14)'/%3E%3C/g%3E%3Ccircle cx='14' cy='14' r='2.5' fill='%23b8892d'/%3E%3C/svg%3E");
  --ok: #2e7d4f;
  --bad: #b23a3a;
  --warn: #c07a1a;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg) var(--pattern); color: var(--ink); font: 16px/1.6 "Tajawal", Tahoma, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
code { background: var(--line); padding: 0 .3em; border-radius: 4px; }

/* الرأس */
.top { background: var(--pattern-light), linear-gradient(180deg, var(--brand), var(--brand-dark)); color: #fff; position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,.2); border-bottom: 3px solid var(--gold); }
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 4px; background: repeating-linear-gradient(90deg, var(--gold-light) 0 10px, transparent 10px 16px); opacity: .7; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1rem .2rem; max-width: 1100px; margin: 0 auto; }
.brand { color: var(--gold-light); font-family: "Aref Ruqaa", "Amiri", serif; font-weight: 700; font-size: 1.7rem; line-height: 1.2; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.brand .star { font-size: 1.1rem; margin-left: .35rem; vertical-align: middle; }
.brand:hover { text-decoration: none; }
.who { color: #cfe5db; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top nav { display: flex; gap: .2rem; padding: .2rem .75rem .5rem; max-width: 1100px; margin: 0 auto; overflow-x: auto; scrollbar-width: none; }
.top nav::-webkit-scrollbar { display: none; }
.top nav a { color: #e6f1ec; padding: .35rem .75rem; border-radius: 99px; white-space: nowrap; font-size: .95rem; }
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.18); text-decoration: none; }
.top nav a.muted { color: #bcd6cb; }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem; }
footer { text-align: center; color: var(--muted); padding: 1.5rem 1rem 2rem; font-size: .85rem; }
footer p { margin: .3rem 0; }
.foot-verse { font-family: "Amiri", serif; font-size: 1.2rem; color: var(--brand); }

.card { display: block; background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: 12px; box-shadow: 0 1px 3px rgba(80,60,20,.06); padding: 1.1rem; margin-bottom: 1rem; color: inherit; }
.card.flush { padding: 0; overflow: hidden; }
.card .pad { padding: 1.1rem 1.1rem 0; }
a.card:hover { text-decoration: none; border-color: var(--brand); }
.narrow { max-width: 420px; margin: 1.5rem auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid2 > .card { margin: 0; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.title-row h1 { margin: 0; }

.hero { position: relative; text-align: center; padding: 2.5rem 1rem 2.25rem; margin-bottom: 1.25rem; border-radius: 14px; background: var(--pattern-light), radial-gradient(ellipse at center, #136b4b, var(--brand-dark)); color: #fff; border: 2px solid var(--gold); box-shadow: inset 0 0 0 6px var(--brand-dark), inset 0 0 0 7px var(--gold-light), 0 4px 14px rgba(9,61,43,.25); }
.basmala { font-family: "Amiri", serif; color: var(--gold-light); font-size: 1.35rem; margin: 0 0 .5rem; }
.hero .title-ar { font-family: "Aref Ruqaa", "Amiri", serif; font-size: clamp(3rem, 12vw, 5.5rem); line-height: 1.15; margin: 0; color: var(--gold-light); text-shadow: 0 2px 0 #6d4f12, 0 4px 12px rgba(0,0,0,.35); font-weight: 700; }
.hero-sub { font-family: "Amiri", serif; font-size: 1.25rem; color: #f3e7c7; margin: 0 0 1.25rem; }

.flash { background: #e7f3ec; border: 1px solid #b9dcc8; padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.flash.err { background: #f8e8e8; border-color: #e5bcbc; }

/* الأزرار */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 9px; padding: .45rem 1.1rem; font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.light { background: #fff; color: var(--brand); border-color: #fff; }
.btn.sm { min-height: 34px; padding: .2rem .8rem; font-size: .9rem; }
.btn.block { width: 100%; }
.btn.danger, .link.danger { color: var(--bad); border-color: var(--bad); }
.link { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 1rem 0 0; }
.actions.inline { margin: 0; }
.actions form, .row-actions form { margin: 0; display: inline; }
.row-actions { display: flex; flex-wrap: wrap; gap: .4rem .9rem; }

/* النماذج */
.form { display: grid; gap: .85rem; }
.form.cols { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.form .wide, .form.cols .wide { grid-column: 1 / -1; }
label { display: grid; gap: .25rem; font-weight: 500; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; margin: 0; }
legend { font-weight: 700; padding: 0 .4rem; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
input, select, textarea { font: inherit; font-size: 16px; min-height: 42px; padding: .45rem .65rem; border: 1px solid #d6d1c3; border-radius: 9px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(30,107,79,.35); border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: 20px; min-height: 20px; height: 20px; }
textarea { min-height: 80px; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; flex: 1 1 200px; }
.inline-edit { display: flex; gap: .5rem; align-items: center; }
.inline-edit input { min-height: 36px; max-width: 220px; }

.tabs { display: flex; gap: .3rem; overflow-x: auto; margin-bottom: 1rem; padding-bottom: .2rem; }
.tabs a { padding: .4rem .9rem; border-radius: 99px; border: 1px solid var(--line); background: var(--card); white-space: nowrap; color: var(--ink); }
.tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* الجداول */
table { width: 100%; border-collapse: collapse; }
td, th { padding: .6rem .7rem; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: .88rem; background: #faf8f2; }
tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; }
.list tbody tr:hover td { background: #faf8f2; }
tr.off td { opacity: .5; }

/* قوائم بسيطة */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .9rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows li > :first-child { flex: 1 1 auto; }
.rows .wide { flex-basis: 100%; }
.errors { color: var(--bad); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .8rem; text-align: center; }
.stat b { display: block; font-size: 1.7rem; line-height: 1.2; color: var(--brand); }
.stat.ok b { color: var(--ok); }
.stat.bad b { color: var(--bad); }
.stat span { color: var(--muted); font-size: .88rem; }
.stats.small { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
.stats.small .stat b { font-size: 1.3rem; }

.info { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin: 0; }
.info dt { color: var(--muted); font-size: .85rem; }
.info dd { margin: 0; font-weight: 500; }
.info dd[dir=ltr] { text-align: right; }

.tag { display: inline-block; font-size: .78rem; padding: .05rem .55rem; border-radius: 99px; background: #e7f3ec; color: var(--ok); white-space: nowrap; }
.tag.review { background: #f6eedc; color: var(--gold); }

.kid-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.kid-head h2 { margin: 0; }
.mini { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.mini span { padding: .15rem .65rem; border-radius: 99px; background: #f3f1ea; font-size: .88rem; }
.mini .ok { color: var(--ok); } .mini .bad { color: var(--bad); } .mini .warn { color: var(--warn); }

.news { border-bottom: 1px solid var(--line); padding: .75rem 0; }
.news:last-child { border-bottom: 0; }
.news h3 { margin: 0; }
.news time { color: var(--muted); font-size: .85rem; }
.news.hidden { opacity: .55; }

/* الحضور */
.att { list-style: none; margin: 1rem 0 0; padding: 0; }
.att li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.att .name { font-weight: 500; }
.radios { display: flex; flex-wrap: wrap; gap: .35rem; }
.r { display: inline; }
.r input { position: absolute; opacity: 0; pointer-events: none; }
.r span { display: inline-block; padding: .4rem .8rem; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; font-size: .92rem; background: #fff; user-select: none; }
.r.present input:checked + span { background: var(--ok); border-color: var(--ok); color: #fff; }
.r.absent input:checked + span { background: var(--bad); border-color: var(--bad); color: #fff; }
.r.late input:checked + span { background: var(--warn); border-color: var(--warn); color: #fff; }
.r.excused input:checked + span { background: var(--muted); border-color: var(--muted); color: #fff; }
.sticky-save { position: sticky; bottom: 0; background: var(--card); padding: .75rem 0 .25rem; }

/* الهاتف */
@media (max-width: 760px) {
  main { padding: 1rem .75rem; }
  .grid2 { grid-template-columns: 1fr; }
  h1 { font-size: 1.3rem; }
  .hero h1 { font-size: 1.6rem; }
  .filters input, .filters select { flex: 1 1 100%; }
  .filters .btn { flex: 1 1 auto; }

  /* كل سطر في الجدول يصبح بطاقة */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
  table.cards td { border: 0; padding: .15rem 0; display: flex; gap: .5rem; }
  table.cards td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .85rem; min-width: 6.5rem; }
  table.cards td.main { font-size: 1.05rem; font-weight: 700; }
  table.cards td.main::before { display: none; }
  table.cards td[dir=ltr] { direction: rtl; }
  .att li { flex-direction: column; align-items: stretch; }
  .radios { display: grid; grid-template-columns: repeat(4, 1fr); }
  .r span { display: block; text-align: center; padding: .5rem .2rem; font-size: .85rem; }
}

/* ---------- الزخرفة ---------- */
h1, h2 { color: var(--brand-dark); }
h2.ornate, .card > h2, .frame > h2 { font-family: "Amiri", serif; font-weight: 700; font-size: 1.45rem; text-align: center; color: var(--brand); }
h2.ornate::before, h2.ornate::after { content: "۞"; color: var(--gold); font-size: .9em; margin: 0 .5rem; }
.divider { display: flex; align-items: center; gap: .75rem; max-width: 320px; margin: .75rem auto; color: var(--gold); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.divider span { font-size: 1.3rem; }
.divider.light { color: var(--gold-light); }
.divider.light::before, .divider.light::after { background: linear-gradient(90deg, transparent, var(--gold-light), transparent); }

/* إطار مزخرف بزوايا */
.frame { position: relative; background: var(--card); border: 2px solid var(--gold); border-radius: 6px; padding: 2rem 1.5rem 1.5rem; margin-bottom: 1.5rem;
  box-shadow: inset 0 0 0 5px var(--card), inset 0 0 0 6px var(--gold-light), 0 2px 10px rgba(80,60,20,.08);
  background-image: var(--rosette), var(--rosette), var(--rosette), var(--rosette);
  background-position: 10px 10px, calc(100% - 10px) 10px, 10px calc(100% - 10px), calc(100% - 10px) calc(100% - 10px);
  background-repeat: no-repeat; }
.quotes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.quotes.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.quote { margin: 0; padding: 1.1rem 1rem; text-align: center; border-radius: 10px; background: linear-gradient(180deg, #fffaf0, #fbf3df); border: 1px solid var(--line); }
.quote blockquote { margin: 0; font-family: "Amiri", serif; font-size: 1.45rem; line-height: 2; color: var(--brand-dark); }
.quote.verse blockquote { font-size: 1.6rem; }
.quote.hadith blockquote { font-size: 1.3rem; color: #3b2f12; }
.quote .said { margin: 0 0 .2rem; font-family: "Amiri", serif; color: var(--brand); font-weight: 700; }
.quote figcaption { margin-top: .4rem; color: var(--gold); font-size: .9rem; font-weight: 500; }

.btn.gold { background: linear-gradient(180deg, var(--gold-light), var(--gold)); border-color: var(--gold); color: var(--brand-dark); font-weight: 700; padding: .5rem 1.6rem; }
.btn { border-radius: 10px; }
.stat { border-top: 3px solid var(--gold-light); background: var(--card); }
.top nav a.on { background: rgba(226,196,122,.22); color: #fff; box-shadow: inset 0 -2px 0 var(--gold-light); }
th { background: #f6eed8; }
.tag { background: #e3efe7; }
.narrow { border-top: 3px solid var(--gold); }

@media (max-width: 760px) {
  .brand { font-size: 1.45rem; }
  .quotes.two { grid-template-columns: 1fr; }
  .frame { padding: 1.75rem 1rem 1rem; }
  .quote blockquote { font-size: 1.3rem; }
  .quote.verse blockquote { font-size: 1.4rem; }
}
