/* تصميم عربي من اليمين لليسار، للموبايل أولًا. الألوان الأساسية تأتي من إعدادات المنصة */
:root {
  --primary: #0f6b4f;
  --accent: #d4a017;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #17211d;
  --muted: #5b6a64;
  --border: #dde4e1;
  --danger: #b42318;
  --success: #12795a;
  --warning: #9a6700;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 2px 8px rgba(16, 24, 20, .05);
  font-size: 17px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, 'Noto Sans Arabic', sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
.skip { position: absolute; right: -999px; top: 8px; background: #000; color: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { right: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.boot { padding: 4rem 1rem; text-align: center; color: var(--muted); }

/* الهيكل */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1rem; background: var(--primary); color: #fff;
}
.topbar .logo { width: 38px; height: 38px; border-radius: 10px; background: #fff; color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; overflow: hidden; flex: none; }
.topbar .logo img { width: 100%; height: 100%; object-fit: cover; }
.topbar .name { font-weight: 700; font-size: 1.05rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar a, .topbar button.link { color: #fff; }
.demo-banner { background: #fff4d6; color: #5c4300; font-size: .85rem; padding: .35rem 1rem; text-align: center; border-bottom: 1px solid #f1dfa6; }
main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 6.5rem; }
main.wide { max-width: 1180px; }

.bottomnav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem .25rem .45rem;
  text-decoration: none; color: var(--muted); font-size: .78rem; font-weight: 600; min-height: 60px; position: relative; }
.bottomnav a .ic { font-size: 1.35rem; line-height: 1; }
.bottomnav a[aria-current="page"] { color: var(--primary); }
.bottomnav a[aria-current="page"]::before { content: ''; position: absolute; top: 0; inset-inline: 25%; height: 3px; background: var(--primary); border-radius: 0 0 3px 3px; }
.badge-dot { position: absolute; top: 6px; inset-inline-start: calc(50% - 18px); background: var(--danger); color: #fff; border-radius: 99px; font-size: .7rem; min-width: 18px; padding: 0 5px; line-height: 18px; }

/* البطاقات */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card h2 a { font-size: .85rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hero { background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #000)); color: #fff; border: 0; }
.hero .muted { color: rgba(255,255,255,.85); }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.tile { display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; padding: 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); font-weight: 600; min-height: 92px; box-shadow: var(--shadow); }
.tile .ic { font-size: 1.6rem; }
.tile.off { opacity: .55; }
.tile small { font-weight: 400; color: var(--muted); font-size: .78rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .85rem; }

/* بطاقة العضوية */
.member-card { border-radius: 18px; padding: 1.1rem; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #000)); }
.member-card::after { content: ''; position: absolute; inset-inline-end: -40px; top: -40px; width: 150px; height: 150px; border-radius: 50%; border: 14px solid var(--accent); opacity: .18; }
.member-card .row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; position: relative; z-index: 1; }
.member-card .num { font-size: 1.35rem; font-weight: 700; letter-spacing: 1px; direction: ltr; text-align: right; }

/* القوائم */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list a.item, .list .item { display: flex; gap: .75rem; align-items: center; padding: .75rem 0; text-decoration: none; color: var(--text); }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; display: block; }
.unread .title::before { content: '●'; color: var(--primary); margin-inline-end: .35rem; font-size: .7rem; vertical-align: middle; }

/* الحالات */
.pill { display: inline-block; padding: .1rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #eef2f0; color: var(--muted); white-space: nowrap; }
.pill.green { background: #e3f4ec; color: var(--success); }
.pill.amber { background: #fff3d6; color: var(--warning); }
.pill.red { background: #fde8e6; color: var(--danger); }
.pill.blue { background: #e6f0fb; color: #1d5ca8; }

/* النماذج */
label { display: block; font-weight: 600; margin-bottom: .35rem; }
.field { margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
input[type=text], input[type=tel], input[type=email], input[type=date], input[type=search], input[type=color], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff; border: 1.5px solid var(--border); border-radius: 12px;
  padding: .75rem .9rem; min-height: 52px;
}
input[type=color] { padding: .25rem; width: 80px; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
input.big { font-size: 1.4rem; text-align: center; letter-spacing: 2px; direction: ltr; }
.check { display: flex; gap: .7rem; align-items: flex-start; font-weight: 400; padding: .55rem 0; cursor: pointer; }
.check input { width: 24px; height: 24px; margin-top: .2rem; flex: none; accent-color: var(--primary); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; border: 1.5px solid var(--border); border-radius: 99px; padding: .4rem .9rem; cursor: pointer; background: #fff; font-weight: 600; font-size: .9rem; min-height: 44px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip:has(input:focus-visible) { outline: 3px solid var(--accent); }
.error-box { background: #fde8e6; color: var(--danger); border-radius: 12px; padding: .75rem 1rem; margin-bottom: 1rem; font-weight: 600; }
.ok-box { background: #e3f4ec; color: var(--success); border-radius: 12px; padding: .75rem 1rem; margin-bottom: 1rem; font-weight: 600; }
.note-box { background: #fff8e5; color: #5c4300; border-radius: 12px; padding: .75rem 1rem; margin-bottom: 1rem; font-size: .9rem; }

/* الأزرار */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; font: inherit; font-weight: 700; cursor: pointer;
  border: 0; border-radius: 12px; padding: .75rem 1.25rem; min-height: 52px; background: var(--primary); color: #fff; text-decoration: none; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.block { width: 100%; }
.btn.secondary { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.danger { background: var(--danger); }
.btn.small { min-height: 40px; padding: .4rem .9rem; font-size: .9rem; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }
button.link { background: none; border: 0; font: inherit; color: var(--primary); cursor: pointer; padding: .25rem; text-decoration: underline; }
.spinner { width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 2rem; text-align: center; color: var(--muted); }

/* الأشرطة البيانية */
.bars { display: grid; gap: .55rem; }
.bar { display: grid; grid-template-columns: minmax(110px, 38%) 1fr 2.5rem; align-items: center; gap: .6rem; font-size: .9rem; }
.bar .track { background: #edf1ef; border-radius: 6px; height: 14px; overflow: hidden; }
.bar .fill { background: var(--primary); height: 100%; border-radius: 6px; }
.bar.warn .fill { background: #c2410c; }
.bar.wish .fill { background: var(--accent); }
.bar b { text-align: left; font-variant-numeric: tabular-nums; }

/* الجداول */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: start; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }

/* الإدارة */
.admin-layout { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.admin-nav { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; }
.admin-nav a { white-space: nowrap; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .5rem .8rem; font-weight: 600; font-size: .9rem; }
.admin-nav a[aria-current="page"] { background: var(--primary); color: #fff; border-color: var(--primary); }
@media (min-width: 900px) {
  .admin-layout { grid-template-columns: 230px 1fr; align-items: start; }
  .admin-nav { flex-direction: column; position: sticky; top: 80px; }
}

.timeline { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--border); }
.timeline li { padding: 0 1rem .9rem; position: relative; }
.timeline li::before { content: ''; position: absolute; inset-inline-start: -7px; top: .5rem; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); }
.timeline li.internal::before { background: var(--accent); }
.bubble { background: #f1f5f3; border-radius: 12px; padding: .6rem .8rem; margin-top: .25rem; white-space: pre-wrap; }

.photo { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: #dfe7e3; display: grid; place-items: center; font-size: 2.4rem; color: var(--primary); flex: none; border: 3px solid #fff; }
.prose { white-space: pre-wrap; }
.section-title { margin: 1.25rem 0 .6rem; font-size: 1.05rem; }

#toast { position: fixed; bottom: 80px; inset-inline: 1rem; max-width: 520px; margin: 0 auto; z-index: 50; pointer-events: none; }
#toast .t { background: #17211d; color: #fff; padding: .8rem 1rem; border-radius: 12px; box-shadow: var(--shadow); margin-top: .5rem; font-weight: 600; }
#toast .t.err { background: var(--danger); }

@media (min-width: 700px) { :root { font-size: 17.5px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* أقسام السيرة الذاتية */
.cv-list { list-style: none; margin: 0; padding: 0; }
.cv-list li { display: flex; gap: .75rem; align-items: baseline; padding: .55rem 0; border-bottom: 1px solid var(--border, #e6e8e7); }
.cv-list li:last-child { border-bottom: 0; }
.cv-date { flex: 0 0 auto; min-width: 6.5rem; font-size: .8rem; font-weight: 600; color: var(--primary, #0f6b4f); background: color-mix(in srgb, var(--primary, #0f6b4f) 10%, transparent); border-radius: 999px; padding: .1rem .6rem; text-align: center; direction: ltr; unicode-bidi: isolate; }
.cv-list li > span:last-child { flex: 1; }
main:focus, main:focus-visible { outline: none; }
