/* Rafeq — styles */
:root {
  --brand: #116a5f; --brand-2: #168072; --brand-soft: #e2f1ee;
  --gold: #cb9836; --gold-soft: #f8eedb;
  --bg: #f8f6f0; --surface: #ffffff; --surface-2: #f1efe7;
  --text: #1b211e; --muted: #5d6b66; --border: #e2ded2;
  --ok: #1f7a4d; --ok-bg: #e2f4ea; --no: #b23b3b; --no-bg: #fbe7e7;
  --cond: #9a6b00; --cond-bg: #fdf2d6; --diff: #3d5aa8; --diff-bg: #e6ecfa;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(15,92,74,.06);
  --on-brand: #ffffff; --hero-1: #116a5f; --hero-2: #0b453e;
  --font: 'Readex Pro', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #3fb393; --brand-2: #55c6a6; --brand-soft: #16302a;
    --gold: #d9a648; --gold-soft: #2f2716;
    --bg: #0f1513; --surface: #161e1b; --surface-2: #1c2622;
    --text: #e6ece9; --muted: #9aa8a3; --border: #2a3632;
    --ok: #5fd39a; --ok-bg: #173225; --no: #f08a8a; --no-bg: #3a1c1c;
    --cond: #f2c35b; --cond-bg: #372c10; --diff: #9bb3ff; --diff-bg: #1d2640;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    --on-brand: #06231b; --hero-1: #0f4a3c; --hero-2: #0a2c25;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --brand: #3fb393; --brand-2: #55c6a6; --brand-soft: #16302a;
    --gold: #d9a648; --gold-soft: #2f2716;
    --bg: #0f1513; --surface: #161e1b; --surface-2: #1c2622;
    --text: #e6ece9; --muted: #9aa8a3; --border: #2a3632;
    --ok: #5fd39a; --ok-bg: #173225; --no: #f08a8a; --no-bg: #3a1c1c;
    --cond: #f2c35b; --cond-bg: #372c10; --diff: #9bb3ff; --diff-bg: #1d2640;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    --on-brand: #06231b; --hero-1: #0f4a3c; --hero-2: #0a2c25;
    color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.65; font-size: 16px; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
main.wrap { padding-block: 28px 48px; min-height: 60vh; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); margin-inline-end: auto; }
.logo-img { height: 40px; width: auto; display: block; }
.logo-dark { display: none; }
.logo small { display: block; font-size: .74rem; color: var(--muted); max-width: 170px; line-height: 1.35; border-inline-start: 1px solid var(--border); padding-inline-start: 10px; }
@media (max-width: 420px) { .logo small { display: none; } }
nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--text); padding: 8px 12px; border-radius: 10px; font-size: .95rem; }
nav a:hover { background: var(--surface-2); }
nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.lang-btn { margin-inline-start: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 7px 12px; font: inherit; cursor: pointer; }
.lang-btn:hover { border-color: var(--brand); }
.menu-btn { display: none; background: none; border: 1px solid var(--border); border-radius: 10px; font-size: 1.2rem; padding: 4px 10px; color: var(--text); cursor: pointer; }
@media (max-width: 760px) {
  .menu-btn { display: block; }
  nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 12px; }
  .site-header.open nav { display: flex; }
  .lang-btn { margin: 6px 0 0; }
}

/* footer */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0; background: var(--surface); font-size: .9rem; }
.disclaimer { background: var(--gold-soft); border-inline-start: 4px solid var(--gold); padding: 10px 14px; border-radius: 8px; margin: 0 0 10px; }

/* hero */
.hero { background: linear-gradient(135deg, var(--hero-1) 0%, var(--hero-2) 100%); color: #fff; border-radius: 22px; padding: clamp(28px, 6vw, 56px); position: relative; overflow: hidden; }
.hero > * { position: relative; z-index: 1; }
.hero .hero-mark { position: absolute; z-index: 0; inset-inline-end: clamp(24px, 6vw, 80px); top: 50%; transform: translateY(-50%); width: clamp(150px, 19vw, 210px); height: auto; aspect-ratio: 1; object-fit: contain; padding: 26px; border-radius: 50%; background: #fbfaf6; box-shadow: 0 12px 40px rgba(0,0,0,.18); box-sizing: border-box; }
@media (max-width: 860px) { .hero .hero-mark { display: none; } }
.hero h1, .hero p { max-width: 640px; }
.hero p { opacity: .92; font-size: 1.08rem; }
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; position: relative; z-index: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 11px 20px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-gold { background: var(--gold); color: #1d1a0c; }
.btn-ghost { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-2); }
.btn-light { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }


.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 24px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
a.card { text-decoration: none; color: inherit; transition: transform .15s, border-color .15s; display: block; }
a.card:hover { transform: translateY(-2px); border-color: var(--brand); }
.card .icon { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.card .more { color: var(--brand); font-weight: 600; font-size: .92rem; }
.verse { text-align: center; padding: 28px 20px; }
.verse blockquote { margin: 0 auto; max-width: 760px; font-size: 1.15rem; }
[lang=ar] .verse blockquote { font-family: 'Amiri', serif; font-size: 1.55rem; line-height: 2.1; }
.verse cite { display: block; margin-top: 8px; color: var(--muted); font-style: normal; font-size: .9rem; }

/* page head */
.page-head { margin-bottom: 20px; }
.page-head p { margin: 0; color: var(--muted); }

/* tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 16px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.panel[hidden] { display: none; }

/* forms */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px 18px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; color: var(--brand); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: .9rem; color: var(--muted); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; }
input[type=number], input[type=text], select { font: inherit; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); width: 100%; min-width: 0; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; margin: 6px 0; cursor: pointer; }
.check input { margin-top: 5px; accent-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg label { padding: 8px 14px; cursor: pointer; font-size: .92rem; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: var(--brand); font-weight: 600; }
.seg label:has(input:checked) { background: var(--brand-soft); }
.gold-row { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
@media (max-width: 480px) { .gold-row { grid-template-columns: 1fr 1fr; } }
.link-btn { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 4px 0; }
.link-btn.danger { color: var(--no); }

/* results */
.result { position: sticky; top: 84px; }
.result-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.big { font-size: 2rem; font-weight: 700; color: var(--brand); line-height: 1.2; margin: 4px 0 8px; word-break: break-word; }
.big.zero { color: var(--muted); font-size: 1.4rem; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: .94rem; }
.kv:last-child { border-bottom: 0; }
.kv span:last-child { font-weight: 600; text-align: end; }
.alert { padding: 10px 14px; border-radius: 10px; font-size: .92rem; margin: 10px 0; }
.alert.info { background: var(--brand-soft); }
.alert.warn { background: var(--cond-bg); color: var(--cond); }
.alert.err { background: var(--no-bg); color: var(--no); }

/* advisor */
.verdict { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; padding: 3px 10px; border-radius: 999px; font-size: .85rem; white-space: nowrap; }
.v-yes { background: var(--ok-bg); color: var(--ok); }
.v-no { background: var(--no-bg); color: var(--no); }
.v-cond { background: var(--cond-bg); color: var(--cond); }
.v-differs { background: var(--diff-bg); color: var(--diff); }
.checker { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .checker { grid-template-columns: 1fr; } }
.answer { margin-top: 14px; padding: 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.answer .verdict { font-size: 1rem; padding: 6px 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: start; vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.cat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.cat .n { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--gold-soft); color: var(--gold); font-weight: 700; margin-inline-end: 6px; }
.cat h3 { display: flex; align-items: center; margin-bottom: 4px; }
.cat p { margin: 0; font-size: .9rem; color: var(--muted); }
details.guide { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; }
details.guide summary { padding: 14px 16px; cursor: pointer; list-style: none; display: flex; gap: 12px; align-items: center; }
details.guide summary::-webkit-details-marker { display: none; }
details.guide summary .ico { font-size: 1.5rem; }
details.guide summary .s { display: block; font-size: .88rem; color: var(--muted); font-weight: 400; }
details.guide[open] summary { border-bottom: 1px solid var(--border); }
details.guide .body { padding: 6px 16px 14px; }
details.guide dl { margin: 0; }
details.guide dt { font-weight: 600; margin-top: 10px; color: var(--brand); }
details.guide dd { margin: 2px 0 0; }
section { margin-bottom: 36px; }

/* inheritance */
.counter { display: flex; align-items: center; justify-content: flex-start; gap: 12px; padding: 6px 8px; margin: 0 -8px; border-radius: 10px; }
.counter .stepper { order: -1; }
.counter:hover { background: var(--surface-2); }
.counter label { font-size: .93rem; cursor: pointer; flex: 1; min-width: 0; }
.counter.on { background: var(--brand-soft); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex-shrink: 0; }
.stepper button { background: var(--surface-2); border: 0; width: 34px; height: 34px; font-size: 1.1rem; cursor: pointer; color: var(--text); }
.stepper button:hover { background: var(--brand-soft); }
.stepper input { width: 46px; text-align: center; border: 0; border-radius: 0; padding: 6px 2px; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.counter.on label { color: var(--brand); font-weight: 600; }
.heir-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 16px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; display: flex; gap: 10px; padding: 6px 0; font-size: .93rem; }
.steps li::before { content: counter(s); flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; margin: 12px 0; background: var(--surface-2); }
.bar span { display: block; height: 100%; }
.tag { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); margin: 2px; white-space: nowrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: middle; }
.notes li { margin-bottom: 8px; font-size: .92rem; }
.frac { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
#inh-result { margin-top: 20px; }
.field > .seg, .field > .link-btn { align-self: flex-start; }
.kv span:last-child { unicode-bidi: plaintext; }

/* wealth asset groups */
details.asset-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 12px; }
details.asset-group > summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
details.asset-group > summary::-webkit-details-marker { display: none; }
details.asset-group > summary::before { content: '▸'; color: var(--brand); transition: transform .15s; }
[dir=rtl] details.asset-group > summary::before { content: '◂'; }
details.asset-group[open] > summary::before { transform: rotate(90deg); }
[dir=rtl] details.asset-group[open] > summary::before { transform: rotate(-90deg); }
details.asset-group > summary > span:first-of-type { flex: 1; }
details.asset-group > summary strong { color: var(--brand); display: block; }
details.asset-group[open] > summary { border-bottom: 1px solid var(--border); }
details.asset-group > .row { padding: 14px 18px 4px; }
details.asset-group[data-sec=liabilities] > summary strong { color: var(--no); }
.subtotal { font-weight: 600; font-size: .92rem; white-space: nowrap; unicode-bidi: plaintext; }
.hint { display: block; color: var(--muted); font-size: .8rem; line-height: 1.45; font-weight: 400; }
.field .hint:empty, .check .hint:empty { display: none; }
.full { grid-column: 1 / -1; }
.input-wrap { position: relative; }
.input-wrap.has-suffix input { padding-inline-end: 34px; }
.input-wrap .suffix { position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; pointer-events: none; }
.kv.sub { font-size: .86rem; color: var(--muted); padding: 4px 0; }
.kv.sub span:last-child { font-weight: 500; }
.not-zakatable { margin-bottom: 16px; background: var(--brand-soft); border-color: transparent; box-shadow: none; }
.not-zakatable ul { margin: 0; padding-inline-start: 20px; font-size: .9rem; }
.not-zakatable li { margin-bottom: 4px; }
/* Western digits everywhere for numbers typed by the user */
input[type=number] { direction: ltr; text-align: start; }
[dir=rtl] input[type=number] { text-align: right; }
[dir=rtl] .input-wrap { direction: ltr; }

/* logo variant per theme */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-light { display: none; } :root:not([data-theme="light"]) .logo-dark { display: block; } }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
