/* فيلا الرضوان — نظام التصميم
   رمل دافئ للخلفية، أخضر نخيل للهوية، ونحاس لتفاصيل صغيرة.
   العنصر المميّز: القوس (من شعار الفيلا) في رأس الصفحة وشاشة الدخول. */

:root {
  --sand: #F5F1E8;
  --surface: #FFFDF8;
  --surface-2: #FAF6EE;
  --palm: #1F4A3A;
  --palm-deep: #163628;
  --palm-soft: #E3ECE6;
  --brass: #B4884B;
  --brass-soft: #F3E9D8;
  --ink: #1D2622;
  --muted: #66716B;
  --line: #E5DFD2;

  --st-done: #2E8B57;      --st-done-bg: #E4F2EA;
  --st-progress: #D9822B;  --st-progress-bg: #FBEEDF;
  --st-future: #2F6FB3;    --st-future-bg: #E3EDF8;
  --st-voting: #7A4FB5;    --st-voting-bg: #EFE8F8;
  --st-alert: #C2413B;     --st-alert-bg: #F9E5E3;
  --st-paused: #7D837F;    --st-paused-bg: #ECEDEA;

  --r-panel: 22px;
  --r-tile: 16px;
  --r-field: 12px;
  --shadow: 0 1px 2px rgba(31, 74, 58, .06), 0 6px 18px rgba(31, 74, 58, .06);

  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-brand: "Reem Kufi", "IBM Plex Sans Arabic", Tahoma, sans-serif;

  --nav-h: 68px;
  --tap: 48px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--sand);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--palm); }
img, svg { display: block; }
h1, h2, h3 { line-height: 1.35; margin: 0; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ───────── الرأس المقوّس ───────── */
.top {
  position: relative;
  background: var(--palm);
  color: #fff;
  padding: 14px 16px 44px;
  border-radius: 0 0 50% 50% / 0 0 28px 28px;
}
.top-bar { display: flex; align-items: center; gap: 12px; max-width: 1080px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; margin-inline-end: auto; }
.brand img { width: 38px; height: 38px; }
.brand b { font-family: var(--font-brand); font-weight: 600; font-size: 21px; letter-spacing: 0; }
.brand small { display: block; font-size: 11px; opacity: .7; line-height: 1.2; font-family: var(--font); }
.icon-btn {
  position: relative; display: grid; place-items: center;
  width: var(--tap); height: var(--tap); border-radius: 50%;
  color: #fff; background: rgba(255,255,255,.08); border: 0; cursor: pointer;
}
.icon-btn .count {
  position: absolute; top: 2px; inset-inline-start: 0;
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--brass); color: #fff; font-size: 11px; font-weight: 700; line-height: 19px; text-align: center;
}
.hero { max-width: 1080px; margin: 18px auto 0; }
.hero h1 { font-family: var(--font-brand); font-weight: 600; font-size: 26px; }
.hero p { opacity: .82; font-size: 15px; margin-top: 2px; }

/* ───────── المحتوى ───────── */
.page { max-width: 1080px; margin: -26px auto 0; padding: 0 16px calc(var(--nav-h) + 28px); position: relative; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 2px 12px; }
.page-title h2 { font-size: 18px; font-weight: 700; }
.stack > * + * { margin-top: 14px; }

.panel {
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  padding: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.panel-head h3 { font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* البطاقة الرئيسية في الرأس */
.focus {
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  padding: 18px;
  border-top: 4px solid var(--brass);
}
.focus .label { font-size: 14px; color: var(--muted); }
.focus .figure { font-size: 32px; font-weight: 700; color: var(--palm-deep); line-height: 1.25; margin: 2px 0 10px; }
.focus .figure small { font-size: 16px; font-weight: 500; color: var(--muted); }
.focus-row { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.focus-row span b { color: var(--ink); }

/* شريط التقدم */
.bar { height: 10px; background: var(--palm-soft); border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--palm); border-radius: 6px; }
.bar.brass > i { background: var(--brass); }

/* شبكة الإحصاءات */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile {
  background: var(--surface); border-radius: var(--r-tile); padding: 14px;
  border: 1px solid var(--line); text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 2px; min-height: 92px;
}
.tile .t-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.tile .t-value { font-size: 24px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.tile .t-value small { font-size: 13px; font-weight: 500; color: var(--muted); }
.tile.wide { grid-column: 1 / -1; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* شارات الحالة */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.st-done     { color: var(--st-done);     background: var(--st-done-bg); }
.st-progress { color: var(--st-progress); background: var(--st-progress-bg); }
.st-future   { color: var(--st-future);   background: var(--st-future-bg); }
.st-voting   { color: var(--st-voting);   background: var(--st-voting-bg); }
.st-alert    { color: var(--st-alert);    background: var(--st-alert-bg); }
.st-paused   { color: var(--st-paused);   background: var(--st-paused-bg); }
.bg-done { background: var(--st-done); } .bg-progress { background: var(--st-progress); }
.bg-future { background: var(--st-future); } .bg-voting { background: var(--st-voting); }
.bg-alert { background: var(--st-alert); } .bg-paused { background: var(--st-paused); }
.bg-brass { background: var(--brass); } .bg-palm { background: var(--palm); }

/* قوائم الروابط (المزيد، الإشعارات) */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.list-item {
  display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 10px 4px;
  color: inherit; text-decoration: none; width: 100%; background: none; border: 0; font: inherit; text-align: start; cursor: pointer;
}
.list-item .lead { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--palm-soft); color: var(--palm); flex: none; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .body b { display: block; font-weight: 600; }
.list-item .body span { display: block; font-size: 13px; color: var(--muted); }
.list-item .chev { color: var(--muted); }
.list-item.unread .body b::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brass); margin-inline-start: 8px; vertical-align: middle; }
.group-label { font-size: 13px; color: var(--muted); margin: 22px 6px 6px; font-weight: 600; }

/* حالة فارغة */
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .ic { width: 40px; height: 40px; margin: 0 auto 10px; color: var(--brass); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ───────── النماذج والأزرار ───────── */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field > span em { font-style: normal; font-weight: 400; color: var(--muted); }
.input {
  width: 100%; min-height: var(--tap); padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: var(--r-field);
  background: #fff; color: var(--ink); font: inherit; font-size: 16px;
}
.input:focus { outline: none; border-color: var(--palm); box-shadow: 0 0 0 3px var(--palm-soft); }
.input[dir="ltr"] { text-align: right; }
.field.has-error .input { border-color: var(--st-alert); }
.field .err { display: block; color: var(--st-alert); font-size: 13px; margin-top: 5px; }
.field .hint { display: block; color: var(--muted); font-size: 13px; margin-top: 5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 20px; border-radius: 14px; border: 0;
  font: inherit; font-weight: 600; font-size: 16px; cursor: pointer; text-decoration: none;
  background: var(--palm); color: #fff;
}
.btn:hover { background: var(--palm-deep); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--palm); border: 1.5px solid var(--line); }
.btn.ghost:hover { background: var(--palm-soft); }
.btn.danger { background: var(--st-alert); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: 14px; border-radius: 11px; }
.link-btn { background: none; border: 0; color: var(--palm); font: inherit; font-weight: 600; cursor: pointer; padding: 8px; min-height: 40px; }

.alert { border-radius: 14px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert.error { background: var(--st-alert-bg); color: #8E2C27; }
.alert.success { background: var(--st-done-bg); color: #1F6340; }
.alert.info { background: var(--brass-soft); color: #6F5226; }

/* ───────── التنقل السفلي ───────── */
.bottom-nav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 20;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
}
.bottom-nav a .ic { width: 24px; height: 24px; }
.bottom-nav a[aria-current="page"] { color: var(--palm); font-weight: 700; }
.bottom-nav a[aria-current="page"] .ic { stroke-width: 2.2; }
.bottom-nav a[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--brass);
}
.bottom-nav a { position: relative; }

/* ───────── شاشات الدخول ───────── */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.auth-top {
  background: var(--palm); color: #fff; text-align: center;
  padding: 44px 20px 70px; border-radius: 0 0 50% 50% / 0 0 46px 46px;
}
.auth-top img { width: 84px; height: 84px; margin: 0 auto 12px; }
.auth-top h1 { font-family: var(--font-brand); font-size: 34px; font-weight: 600; }
.auth-top p { opacity: .8; font-size: 15px; }
.auth-top .en { font-size: 12px; opacity: .55; margin-top: 2px; }
.auth-body { width: 100%; max-width: 440px; margin: -44px auto 0; padding: 0 16px 32px; }
.auth-body .panel { padding: 22px; }
.auth-body h2 { font-size: 19px; margin-bottom: 4px; }
.auth-body .sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 15px; }

/* ───────── الحاسوب واللوحي ───────── */
.side-nav { display: none; }
@media (min-width: 900px) {
  .top { border-radius: 0 0 50% 50% / 0 0 40px 40px; padding-bottom: 60px; }
  .shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); max-width: 1180px; margin: 0 auto; gap: 24px; padding: 0 20px; }
  .page { margin-top: -40px; padding: 0 0 40px; max-width: none; }
  .bottom-nav { display: none; }
  .side-nav {
    display: block; position: sticky; top: 16px; align-self: start; margin-top: -40px;
    background: var(--surface); border-radius: var(--r-panel); box-shadow: var(--shadow); padding: 10px;
  }
  .side-nav a {
    display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; border-radius: 12px;
    color: var(--ink); text-decoration: none; font-weight: 500;
  }
  .side-nav a:hover { background: var(--surface-2); }
  .side-nav a[aria-current="page"] { background: var(--palm-soft); color: var(--palm); font-weight: 700; }
  .side-nav hr { border: 0; border-top: 1px solid var(--line); margin: 8px 6px; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tile.wide { grid-column: span 2; }
  .hero h1 { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ───────── حالات التحميل والتنبيهات ───────── */
[hidden] { display: none !important; }
.loading { display: grid; place-items: center; min-height: 160px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--palm-soft); border-top-color: var(--palm); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; background: var(--palm); }
.boot img { width: 72px; height: 72px; }
.toast {
  position: fixed; inset-inline: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 50;
  max-width: 440px; margin: 0 auto; padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: #fff; font-size: 15px; box-shadow: var(--shadow);
}
.toast.error { background: #8E2C27; }
.toast.success { background: var(--palm-deep); }
@media (min-width: 900px) { .toast { bottom: 24px; } }
.btn[disabled] { opacity: .6; cursor: progress; }
.code { direction: ltr; text-align: left; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-x: auto; white-space: pre; }
.announce { border-inline-start: 4px solid var(--brass); }
.announce.important { border-inline-start-color: var(--st-alert); }
.announce h3 { font-size: 16px; margin-bottom: 4px; }
.pending-vote { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.pending-vote .lead { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--st-voting-bg); color: var(--st-voting); flex: none; }
