/* Liraty — design tokens, then layout, then components. RTL-first; logical properties throughout. */
:root {
    --bg: #f4f7f5;
    --surface: #ffffff;
    --surface-2: #eef3f0;
    --ink: #0d1b16;
    --muted: #5a6b63;
    --line: #e1e8e4;
    --brand: #0f8a5f;
    --brand-deep: #0a5c40;
    --brand-soft: #e3f4ec;
    --gold: #9a7613;
    --gold-soft: #fbf3d9;
    --up: #14803c;
    --up-soft: #e2f5e8;
    --down: #cf2a2a;
    --down-soft: #fde8e8;
    --shadow: 0 1px 2px rgba(13, 27, 22, .04), 0 8px 24px rgba(13, 27, 22, .06);
    --radius: 18px;
    --font: "IBM Plex Sans Arabic", system-ui, "Segoe UI", Tahoma, sans-serif;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b1210; --surface: #121c18; --surface-2: #18251f; --ink: #e8f0ec; --muted: #8fa39a; --line: #22312a;
        --brand: #2fb886; --brand-deep: #0a5c40; --brand-soft: #14302a; --gold: #dcb84a; --gold-soft: #2c2714;
        --up: #3ddc97; --up-soft: #12302a; --down: #ff8080; --down-soft: #3a1c1c;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0b1210; --surface: #121c18; --surface-2: #18251f; --ink: #e8f0ec; --muted: #8fa39a; --line: #22312a;
    --brand: #2fb886; --brand-deep: #0a5c40; --brand-soft: #14302a; --gold: #dcb84a; --gold-soft: #2c2714;
    --up: #3ddc97; --up-soft: #12302a; --down: #ff8080; --down-soft: #3a1c1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0; background: var(--bg); color: var(--ink);
    font: 400 16px/1.7 var(--font); font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
h1, h2, h3 { line-height: 1.35; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(1.45rem, 1.1rem + 1.6vw, 2.1rem); font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; }
p { margin: 0 0 .8em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 10px; z-index: 50; }
.skip:focus { top: 8px; }
.muted { color: var(--muted); }
.wrap { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 16px; }
.narrow { max-width: 420px; margin-inline: auto; }

/* Header */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.logo:hover { text-decoration: none; }
.logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-text b { font-size: 1.15rem; font-weight: 700; }
.logo-text small { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.controls { display: flex; align-items: center; gap: 8px; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
.nav::-webkit-scrollbar { display: none; }
.nav a { flex: none; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-size: .92rem; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a[aria-current] { background: var(--brand-soft); color: var(--brand); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 14px; border-radius: 999px; font-size: .88rem; font-weight: 500; color: var(--muted); cursor: pointer; min-height: 32px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg.small button { padding: 3px 10px; font-size: .8rem; min-height: 28px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--ink); }
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .i-sun { display: block; }
    :root:not([data-theme="light"]) .i-moon { display: none; }
}

.demo-note { background: var(--gold-soft); color: var(--ink); font-size: .85rem; padding-block: 6px; border-bottom: 1px solid var(--line); }

main { padding-block: 20px 48px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: .82rem; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.block { margin-top: 32px; }
.block > h2, .block-head { margin-bottom: 12px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.block-head .muted, .more { font-size: .86rem; }
.page-head h1 { margin-bottom: 6px; }
.page-head .tabs { margin-top: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Hero */
.hero { display: grid; gap: 16px; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: stretch; }
@media (max-width: 860px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.hero-card {
    position: relative; overflow: hidden; color: #fff; border-radius: 24px; padding: 24px;
    background: radial-gradient(120% 90% at 100% 0%, rgba(230, 196, 83, .22), transparent 55%), linear-gradient(150deg, #11966a 0%, #0a5c40 60%, #073f2d 100%);
    box-shadow: 0 16px 40px rgba(10, 92, 64, .28);
    display: flex; flex-direction: column; gap: 18px;
}
.hero-card h1 { font-size: clamp(1.25rem, 1rem + 1.1vw, 1.6rem); }
.hero-date { margin: 4px 0 0; font-size: .88rem; opacity: .82; }
.hero-flag { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: .85rem; letter-spacing: .06em; opacity: .9; }
.hero-flag img { border-radius: 5px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); }
.hero-price { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hero-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hero-label { font-size: .9rem; opacity: .82; }
.hero-num { font-size: clamp(2.8rem, 2rem + 5vw, 4.4rem); font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.hero-unit { font-size: .95rem; opacity: .85; }
.hero-sub { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.hero-sub > div { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .12); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; }
.hero-sub > div > span { font-size: .78rem; opacity: .8; }
.hero-sub b { font-size: 1.15rem; font-weight: 600; }
.hero-empty { opacity: .85; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { padding: 6px 14px; border-radius: 999px; font-size: .9rem; font-weight: 500; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.tabs a:hover { text-decoration: none; border-color: var(--brand); }
.tabs a[aria-current] { background: var(--brand); border-color: var(--brand); color: #fff; }
.tabs.on-dark { margin-top: auto; }
.tabs.on-dark a { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .16); color: #fff; }
.tabs.on-dark a[aria-current] { background: #fff; border-color: #fff; color: #0a5c40; }

/* Change chip: colour + arrow + sign, never colour alone */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.chip-arrow { font-size: .62em; }
.chip.up { color: var(--up); background: var(--up-soft); }
.chip.down { color: var(--down); background: var(--down-soft); }
.chip.flat { color: var(--muted); background: var(--surface-2); }
.chip.on-dark { background: rgba(255, 255, 255, .14); color: #fff; font-size: .95rem; padding: 4px 12px; }
.chip.on-dark.up { color: #b9f6d5; }
.chip.on-dark.down { color: #ffc9c9; }

.spark { display: block; }
.spark { color: var(--muted); }

/* Grids of small cards */
.grid { display: grid; gap: 12px; }
.grid.cities { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.gold { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.mini { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; color: var(--ink); transition: transform .15s, border-color .15s; }
a.mini:hover { text-decoration: none; border-color: var(--brand); transform: translateY(-2px); }
.mini-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .9rem; font-weight: 500; }
.mini-num { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.mini-foot { font-size: .82rem; }
.badge { font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); }
.gold-card { border-top: 3px solid var(--gold); }
.gold-dot { width: 22px; height: 22px; border-radius: 50%; flex: none; background: radial-gradient(circle at 35% 30%, #f6e08f, #c9a227 60%, #8d6f12); }
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat > span { font-size: .84rem; color: var(--muted); }
.stat b { font-size: 1.35rem; font-weight: 700; }
.stat.note b { font-size: 1.05rem; font-weight: 600; }
.stat small { font-size: .8rem; font-weight: 400; color: var(--muted); }

/* Tables */
.table-card { overflow-x: auto; }
table.rates { width: 100%; border-collapse: collapse; }
.rates th, .rates td { padding: 12px 16px; text-align: start; border-top: 1px solid var(--line); white-space: nowrap; }
.rates thead th { border-top: 0; font-size: .8rem; font-weight: 500; color: var(--muted); background: var(--surface-2); }
.rates tbody th { font-weight: 500; }
.rates .num { text-align: end; }
.rates .strong { font-weight: 700; font-size: 1.05rem; }
.rates tbody tr:hover { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.rates a { color: var(--ink); }
.col-spark { width: 110px; }
.col-spark .spark { margin-inline-start: auto; }
.cur { display: flex; align-items: center; gap: 12px; }
.cur img { border-radius: 4px; box-shadow: 0 0 0 1px var(--line); flex: none; object-fit: cover; }
.cur-name { display: flex; flex-direction: column; line-height: 1.3; }
.cur-name small { font-size: .74rem; color: var(--muted); letter-spacing: .05em; }
@media (max-width: 620px) {
    .col-spark { display: none; }
    .rates th, .rates td { padding: 10px 10px; }
}
.small-note { font-size: .84rem; margin-top: 8px; }
.px.flash { animation: flash 1.2s ease-out; border-radius: 6px; }
@keyframes flash { from { background: color-mix(in srgb, var(--gold) 35%, transparent); } to { background: transparent; } }

/* Chart */
.chart-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.chart-head h2 { font-size: 1.05rem; }
.chart-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: .84rem; color: var(--muted); min-height: 1.6em; }
.chart-stats b { color: var(--ink); font-weight: 600; }
.chart-plot { position: relative; flex: 1; min-height: 240px; direction: ltr; }
.chart-plot svg { display: block; width: 100%; height: 100%; position: absolute; inset: 0; overflow: visible; touch-action: pan-y; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .9rem; direction: rtl; }
.chart-note { font-size: .78rem; margin: 0; }
.c-grid { stroke: var(--line); stroke-width: 1; }
.c-axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.c-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.c-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.c-dot { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }
.c-tip { position: absolute; top: 4px; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 10px; padding: 6px 10px; font-size: .78rem; line-height: 1.5; white-space: nowrap; direction: rtl; box-shadow: var(--shadow); z-index: 2; }
.c-tip b { font-weight: 600; }

/* Forms / converter */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: .8rem; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea, .admin-grid input {
    width: 100%; background: var(--surface-2); border: 1px solid transparent; border-radius: 12px; padding: 10px 12px; min-height: 46px;
}
.field input:focus, .field select:focus, .field textarea:focus, .admin-grid input:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.field input[dir="ltr"] { text-align: start; font-size: 1.15rem; font-weight: 600; }
.field textarea { font: .82rem/1.5 ui-monospace, Consolas, monospace; resize: vertical; }
.conv { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.conv-row { display: grid; grid-template-columns: 1.1fr 1.4fr auto 1.4fr; gap: 10px; align-items: end; }
.swap { margin-bottom: 4px; }
@media (max-width: 720px) {
    .conv-row { grid-template-columns: 1fr; }
    .swap { justify-self: center; margin: 0; }
}
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 12px; font-size: .84rem; cursor: pointer; min-height: 30px; }
.quick button:hover { border-color: var(--brand); color: var(--brand); }
.conv-out { background: var(--brand-soft); border-radius: 14px; padding: 14px 16px; }
.conv-main { font-size: clamp(1.5rem, 1.1rem + 2vw, 2.1rem); font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.conv-main small, .answer small { font-size: .5em; font-weight: 500; color: var(--muted); }
.conv-hint { font-size: .8rem; margin: 0; }

.answer { padding: 22px; }
.answer-from { color: var(--muted); }
.answer-num { font-size: clamp(2rem, 1.4rem + 3.4vw, 3.2rem); font-weight: 700; line-height: 1.25; color: var(--brand); overflow-wrap: anywhere; }
.answer-alt { font-size: 1.15rem; font-weight: 600; margin-bottom: 12px; }

.redenom { padding: 22px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: end; }
.redenom-eq { font-size: 1.8rem; font-weight: 700; color: var(--gold); padding-bottom: 6px; }
.redenom-usd { grid-column: 1 / -1; margin: 0; }
.field.big input { font-size: 1.6rem; min-height: 60px; }
@media (max-width: 560px) { .redenom { grid-template-columns: 1fr; } .redenom-eq { justify-self: center; padding: 0; } }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 20px 22px; color: var(--ink); border-inline-start: 4px solid var(--gold); }
.banner:hover { text-decoration: none; border-color: var(--gold); }
.banner p { margin: 4px 0 0; color: var(--muted); max-width: 60ch; }
.banner-cta { font-weight: 600; color: var(--brand); white-space: nowrap; }

.links-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.link-card { padding: 12px 16px; color: var(--ink); font-weight: 500; }
.link-card:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }

.prose { max-width: 72ch; }
.prose h2 { margin: 1.4em 0 .5em; }
.prose h2:first-child { margin-top: 0; }
.prose p { color: color-mix(in srgb, var(--ink) 86%, var(--muted)); }
.docs pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; overflow-x: auto; font-size: .86rem; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }

.faq { display: grid; gap: 8px; max-width: 80ch; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 16px; }
.faq summary { cursor: pointer; font-weight: 600; padding: 13px 0; list-style-position: inside; }
.faq p { color: var(--muted); padding-bottom: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 12px; padding: 10px 20px; min-height: 44px; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; }
:root[data-theme="dark"] .btn:not(.ghost):not(.danger) { color: #06231a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn:not(.ghost):not(.danger) { color: #06231a; } }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { background: var(--down-soft); color: var(--down); }
.form { padding: 20px; display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.form .btn { align-self: flex-start; }
.alert { padding: 10px 14px; border-radius: 12px; margin: 12px 0 0; }
.alert.ok { background: var(--up-soft); color: var(--up); }
.alert.error { background: var(--down-soft); color: var(--down); }
.admin-grid { display: grid; grid-template-columns: minmax(120px, 1.4fr) 1fr 1fr auto; gap: 10px 12px; align-items: center; }
@media (max-width: 620px) { .admin-grid { grid-template-columns: 1fr 1fr; } .admin-grid > b { grid-column: 1 / -1; margin-top: 8px; } .admin-grid > .muted { display: none; } }

.builder { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); align-items: start; }
@media (max-width: 820px) { .builder { grid-template-columns: minmax(0, 1fr); } }
.builder-form { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.builder-form .btn { align-self: flex-start; }
.builder-preview { padding: 18px; display: grid; place-items: center; }
.builder-preview iframe { border: 0; width: 100%; max-width: 340px; }
.checks { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks legend { font-size: .8rem; color: var(--muted); font-weight: 500; padding: 0; margin-bottom: 4px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; }
.store-row { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }

/* Footer */
.foot { border-top: 1px solid var(--line); background: var(--surface); padding-block: 32px 18px; font-size: .9rem; }
.foot-grid { display: grid; gap: 24px; grid-template-columns: 1.6fr repeat(3, 1fr); }
@media (max-width: 760px) { .foot-grid { grid-template-columns: 1fr 1fr; } .foot-grid > div { grid-column: 1 / -1; } }
.foot-brand { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.foot p { color: var(--muted); max-width: 46ch; }
.foot nav { display: flex; flex-direction: column; gap: 6px; }
.foot nav h3 { margin-bottom: 4px; }
.foot nav a { color: var(--muted); }
.foot nav a:hover { color: var(--brand); }
.foot-end { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Admin: dealers */
.dealer-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto auto; gap: 8px; align-items: center; padding-block: 8px; border-top: 1px solid var(--line); }
.dealer-row:first-child { border-top: 0; }
.dealer-row input, .dealer-row select { background: var(--surface-2); border: 1px solid transparent; border-radius: 10px; padding: 8px 10px; min-height: 42px; width: 100%; }
@media (max-width: 720px) { .dealer-row { grid-template-columns: 1fr 1fr; } }
