:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --text: #17201d;
  --muted: #5d6b66;
  --line: #e2e7e4;
  --accent: #0f766e;
  --accent-soft: #e6f3f1;
  --minus: #b42318;
  --plus: #067647;
  --wa: #1f9d55;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --card: #171e1b;
    --text: #e8efec;
    --muted: #9aa8a2;
    --line: #26302c;
    --accent: #2dd4bf;
    --accent-soft: #11302b;
    --minus: #f97066;
    --plus: #47cd89;
    --wa: #25b863;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", "Geeza Pro", sans-serif;
}
[dir="rtl"] body, body[dir="rtl"] { font-family: "Noto Sans Arabic", "Geeza Pro", system-ui, sans-serif; }
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top {
  max-width: 720px; margin: 0 auto; padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: -0.01em; }
.lang {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 32px; }
h1 { font-size: clamp(1.45rem, 4.5vw, 2rem); line-height: 1.2; margin: 8px 0 6px; letter-spacing: -0.02em; }
.lead { color: var(--muted); margin: 0 0 18px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--bg); padding: 4px; border-radius: 11px; margin-bottom: 14px; }
.mode {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  padding: 10px; border-radius: 8px; cursor: pointer;
}
.mode.active { background: var(--card); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.money { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); }
.money:focus-within { border-color: var(--accent); }
.money input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 1.35rem; font-weight: 600; padding: 12px 14px; outline: none;
}
.cur { padding: 0 14px; color: var(--muted); font-weight: 600; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button {
  width: 48px; height: 46px; border: 0; background: var(--bg); color: var(--text);
  font-size: 1.4rem; cursor: pointer;
}
.stepper output { min-width: 56px; text-align: center; font-size: 1.2rem; font-weight: 700; }

.more { margin: 4px 0 14px; }
.more summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 15px; padding: 6px 0; }
.more[open] summary { margin-bottom: 10px; }
.more .money input { font-size: 1.05rem; padding: 10px 12px; }

.result { border-top: 1px solid var(--line); padding-top: 14px; }
.big { background: var(--accent-soft); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.big span { display: block; font-size: 14px; color: var(--muted); }
.big strong { display: block; font-size: clamp(1.9rem, 8vw, 2.5rem); color: var(--accent); line-height: 1.15; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.big small { color: var(--muted); }

.breakdown { width: 100%; border-collapse: collapse; font-size: 15px; }
.breakdown th { text-align: start; font-weight: 500; padding: 8px 0; color: var(--text); }
.breakdown td { text-align: end; padding: 8px 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.breakdown tr + tr { border-top: 1px dashed var(--line); }
.breakdown .info th, .breakdown .info td { color: var(--muted); font-size: 14px; }
.breakdown .minus { color: var(--minus); }
.breakdown .plus { color: var(--plus); }
.breakdown .total th, .breakdown .total td { font-weight: 700; font-size: 16px; border-top: 1.5px solid var(--text); }
.breakdown .opt.hide { display: none; }
#o-fprate, #o-mrate { color: var(--muted); font-size: 13px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.btn {
  flex: 1 1 160px; border: 1.5px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; padding: 11px 14px; border-radius: 10px; cursor: pointer;
}
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }

.ad:empty { display: none; }
.ad { margin: 18px 0; min-height: 100px; }

.content { margin-top: 28px; }
.content h2 { font-size: 1.25rem; margin: 28px 0 8px; letter-spacing: -0.01em; }
.content h3 { font-size: 1.02rem; margin: 18px 0 4px; }
.content p, .content li { color: var(--text); }
.content ol, .content ul { padding-inline-start: 1.3rem; }
.content li { margin: 6px 0; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scale { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 14px; background: var(--card); border-radius: 10px; overflow: hidden; }
.scale th, .scale td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: start; }
.scale th { background: var(--accent-soft); }
.note { color: var(--muted); font-size: 14px; margin-top: 24px; }

.foot { max-width: 720px; margin: 0 auto; padding: 18px 16px 40px; color: var(--muted); font-size: 14px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px;
}
