:root {
  --bg: #f8f3ea;
  --surface: #ffffff;
  --surface-2: #f2ebdf;
  --ink: #1f1a14;
  --muted: #6d6256;
  --line: #e4d9c7;
  --primary: #14513d;
  --primary-ink: #ffffff;
  --primary-soft: #e3efe9;
  --gold: #b8862b;
  --gold-soft: #f6ead2;
  --danger: #b23b2e;
  --danger-soft: #f8e3df;
  --warn: #a86a00;
  --warn-soft: #fbeed4;
  --ok: #2f7d4f;
  --ok-soft: #e1f1e7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 26, 20, .06), 0 6px 20px rgba(31, 26, 20, .06);
  --font: 'Tajawal', 'Inter', system-ui, sans-serif;
}
html[lang="en"] { --font: 'Inter', 'Tajawal', system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.55; font-size: 15.5px; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 40; background: rgba(248, 243, 234, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.25rem; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: var(--gold-soft); display: grid; place-items: center; }
.brand-mark svg { width: 24px; height: 24px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.lang-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 600; }
.lang-btn:hover { border-color: var(--gold); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--gold-soft); color: var(--gold); display: grid; place-items: center; font-weight: 700; position: relative; }
.avatar .dot { position: absolute; inset-block-end: 0; inset-inline-end: 0; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--bg); }
.menu-btn { display: none; border: 0; background: none; font-size: 1.4rem; cursor: pointer; }
.demo-strip { background: var(--gold-soft); color: #6b4c12; font-size: .84rem; text-align: center; padding: 6px 16px; border-bottom: 1px solid #ecdcb9; }

@media (max-width: 1120px) {
  .menu-btn { display: block; }
  .nav { display: none; position: absolute; inset-inline: 0; top: 64px; flex-direction: column; background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 16px 16px; }
  .nav.open { display: flex; }
  .topbar-in { justify-content: space-between; }
}

main { padding-block: 28px 60px; min-height: 70vh; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 10px 18px; font-weight: 700; cursor: pointer; background: var(--surface); border-color: var(--line); color: var(--ink); transition: transform .06s, box-shadow .15s, background .15s; text-align: center; }
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { background: #0f4232; }
.btn.gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: #efc5be; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn.sm { padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Cards & layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card.pad-lg { padding: 28px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.cards { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.split { display: grid; gap: 24px; grid-template-columns: 1.4fr 1fr; align-items: start; }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, 1fr); } .split { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.section { margin-block: 44px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 1.55rem; }
.eyebrow { color: var(--gold); font-weight: 700; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }
.page-title { font-size: 1.9rem; margin-bottom: 4px; }
.crumbs { font-size: .88rem; color: var(--muted); margin-bottom: 14px; }

/* Hero */
.hero { border-radius: 22px; padding: 56px 44px; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(1200px 400px at 100% 0%, rgba(184, 134, 43, .45), transparent 60%), linear-gradient(135deg, #0f3e2f, #14513d 55%, #1e5d47); }
.hero h1 { font-size: clamp(2rem, 4vw, 3.1rem); font-weight: 800; margin-bottom: 10px; }
.hero p.lead { font-size: 1.15rem; max-width: 620px; opacity: .92; }
.hero .slogan { color: #f1d9a6; font-weight: 700; font-size: 1.1rem; margin-bottom: 14px; }
.hero .btn { margin-top: 10px; }
.hero .btn.outline { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .45); }
.hero-art { position: absolute; inset-inline-end: 24px; bottom: -10px; width: min(420px, 45%); opacity: .2; color: #f1d9a6; pointer-events: none; }
html[dir="rtl"] .hero-art { transform: scaleX(-1); }
@media (max-width: 700px) { .hero { padding: 36px 22px; } .hero-art { display: none; } }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 30px; }
.stat { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .15); border-radius: 14px; padding: 14px 16px; }
.stat b { display: block; font-size: 1.5rem; }
.stat span { font-size: .85rem; opacity: .85; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.feature { display: flex; flex-direction: column; gap: 8px; }
.feature .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 1.4rem; }
.feature ul { margin: 6px 0 0; padding-inline-start: 18px; color: var(--muted); font-size: .93rem; }
.steps { counter-reset: s; display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; position: relative; }
.step::before { counter-increment: s; content: counter(s); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: #fff; font-weight: 700; margin-bottom: 8px; }
.step h4 { margin-bottom: 4px; }
.step p { margin: 0; font-size: .9rem; color: var(--muted); }
@media (max-width: 900px) { .steps { grid-template-columns: 1fr 1fr; } }

/* Listing cards */
.lcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; color: var(--ink); transition: box-shadow .15s, transform .15s; }
.lcard:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.lcard .thumb { aspect-ratio: 4 / 3; display: grid; place-items: center; position: relative; }
.lcard .thumb svg { width: 72%; }
.lcard .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.lcard h3 { font-size: 1.05rem; margin: 0; }
.lcard .price { font-weight: 800; font-size: 1.15rem; color: var(--primary); margin-top: auto; }
.thumb .tags { position: absolute; top: 10px; inset-inline-start: 10px; display: flex; gap: 6px; }
.art { border-radius: var(--radius); display: grid; place-items: center; aspect-ratio: 16 / 10; }
.art svg { width: 60%; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.gold { background: var(--gold-soft); color: #87601a; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.primary { background: var(--primary-soft); color: var(--primary); }

/* Filters */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filters .search { flex: 1; min-width: 220px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .9rem; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 11px; padding: 10px 12px; outline: none; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { min-height: 90px; resize: vertical; }
.input.ltr { direction: ltr; text-align: start; }
html[dir="rtl"] .input.ltr { text-align: right; }
.hint { font-size: .82rem; color: var(--muted); }
.err { font-size: .82rem; color: var(--danger); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; margin-bottom: 8px; }
.check input { margin-top: 4px; accent-color: var(--primary); }

/* Money breakdown */
.ledger { width: 100%; border-collapse: collapse; }
.ledger td { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.ledger td:last-child { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ledger tr.total td { font-weight: 800; border-bottom: 0; padding-top: 10px; font-size: 1.05rem; }
.ledger tr.fee td { color: var(--gold); }
.pricebox { position: sticky; top: 84px; }
.bigprice { font-size: 1.9rem; font-weight: 800; color: var(--primary); }

.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kv div { background: var(--surface-2); border-radius: 11px; padding: 10px 12px; }
.kv span { display: block; font-size: .8rem; color: var(--muted); }
.kv b { font-size: .98rem; }

.notice { border-radius: 12px; padding: 12px 14px; background: var(--primary-soft); color: var(--primary); font-size: .92rem; display: flex; gap: 10px; align-items: flex-start; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.gold { background: var(--gold-soft); color: #7a5615; }

/* Timeline */
.timeline { display: flex; gap: 0; margin: 14px 0 6px; }
.tl { flex: 1; text-align: center; position: relative; font-size: .8rem; color: var(--muted); }
.tl::before { content: ''; position: absolute; top: 13px; inset-inline: 0; height: 3px; background: var(--line); z-index: 0; }
.tl:first-child::before { inset-inline-start: 50%; }
.tl:last-child::before { inset-inline-end: 50%; }
.tl .dotc { width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 3px solid var(--line); display: grid; place-items: center; margin: 0 auto 6px; position: relative; z-index: 1; font-size: .75rem; font-weight: 700; }
.tl.done .dotc { background: var(--ok); border-color: var(--ok); color: #fff; }
.tl.done::before { background: var(--ok); }
.tl.cur .dotc { border-color: var(--gold); color: var(--gold); }
.tl.cur { color: var(--ink); font-weight: 700; }
.tl.bad .dotc { background: var(--danger); border-color: var(--danger); color: #fff; }

.deal { display: grid; grid-template-columns: 90px 1fr auto; gap: 16px; align-items: center; }
.deal .mini { border-radius: 12px; aspect-ratio: 1; display: grid; place-items: center; }
.deal .mini svg { width: 80%; }
@media (max-width: 640px) { .deal { grid-template-columns: 64px 1fr; } .deal > :last-child { grid-column: 1 / -1; } }

.countdown { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.4rem; color: var(--warn); direction: ltr; display: inline-block; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }

/* Lineage tree */
.tree { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; align-items: center; }
.tree .col { display: flex; flex-direction: column; gap: 10px; justify-content: space-around; height: 100%; }
.tree .node { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; font-size: .88rem; text-align: center; border-inline-start: 3px solid var(--line); }
.tree .node.m { border-inline-start-color: #4a78a8; }
.tree .node.f { border-inline-start-color: #c06a8a; }
.tree .node.me { background: var(--primary); color: #fff; font-weight: 700; border: 0; }
.tree .node small { display: block; color: var(--muted); font-size: .72rem; }
.tree .node.me small { color: #cfe3da; }

/* Calendar */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: .72rem; text-align: center; color: var(--muted); padding: 4px 0; }
.cal button { aspect-ratio: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; cursor: pointer; font-size: .88rem; font-variant-numeric: tabular-nums; }
.cal button:hover:not([disabled]) { border-color: var(--primary); }
.cal button.booked { background: repeating-linear-gradient(45deg, var(--danger-soft), var(--danger-soft) 4px, #fff 4px, #fff 8px); color: var(--danger); cursor: not-allowed; border-color: #efc5be; }
.cal button.past { opacity: .35; cursor: not-allowed; }
.cal button.sel { background: var(--primary); color: #fff; border-color: var(--primary); }
.cal button.range { background: var(--primary-soft); border-color: #bcd9cb; }
.cal button.today { box-shadow: inset 0 0 0 2px var(--gold); }
.legend { display: flex; gap: 14px; font-size: .78rem; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-inline-end: 4px; }

/* Verification */
.vstep { display: grid; grid-template-columns: 44px 1fr; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.vstep:last-child { border-bottom: 0; }
.vstep .vic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 800; }
.vstep.ok .vic { background: var(--ok); color: #fff; }
.nafath-code { font-size: 2.4rem; font-weight: 800; letter-spacing: .1em; color: var(--primary); background: var(--primary-soft); border-radius: 14px; padding: 6px 20px; display: inline-block; direction: ltr; }

/* Arch diagram */
.arch { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 16px; align-items: stretch; }
.arch .lane { display: flex; flex-direction: column; gap: 10px; }
.arch .box { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px; }
.arch .box b { display: block; }
.arch .box span { font-size: .82rem; color: var(--muted); }
.arch .core { background: var(--primary); color: #fff; border-color: var(--primary); }
.arch .core span { color: #cfe3da; }
.arch .lane-title { font-size: .78rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: .05em; }
@media (max-width: 800px) { .arch { grid-template-columns: 1fr; } }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); }
table.tbl th { font-size: .82rem; color: var(--muted); font-weight: 600; background: var(--surface-2); }
table.tbl tr.hl td { background: var(--gold-soft); font-weight: 700; }
.range-row { display: grid; grid-template-columns: 1fr 140px; gap: 12px; align-items: center; }
input[type=range] { accent-color: var(--primary); width: 100%; }
.kpi { font-size: 1.7rem; font-weight: 800; color: var(--primary); }

/* Messages */
.thread { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; padding: 4px; }
.msg { max-width: 80%; padding: 9px 13px; border-radius: 14px; background: var(--surface-2); font-size: .92rem; }
.msg.me { align-self: flex-end; background: var(--primary-soft); }
.msg.sys { align-self: center; background: var(--gold-soft); color: #7a5615; font-size: .82rem; max-width: 95%; text-align: center; }
.msg small { display: block; color: var(--muted); font-size: .72rem; margin-top: 2px; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(20, 16, 10, .45); display: grid; place-items: center; z-index: 80; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 18px; width: min(560px, 100%); max-height: 92vh; overflow-y: auto; padding: 26px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal h3 { font-size: 1.3rem; }
@keyframes fade { from { opacity: 0; } }

.toasts { position: fixed; bottom: 18px; inset-inline-start: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); max-width: 360px; font-size: .9rem; animation: fade .2s; display: flex; gap: 10px; }
.toast b { color: #f1d9a6; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 2.4rem; }

.footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: .88rem; }
.footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
