:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #111827;
  --muted: #5b6574;
  --gold: #8a6a12;
  --gold-bright: #b8912a;
  --gold-soft: #f6f1e3;
  --navy: #0e1a2b;
  --line: #dfe3e8;
  --line-soft: #eceff3;
  --down: #b42318;
  --up: #067647;
  --blue: #1d4f9f;
  --blue-soft: #eef3fb;
  --red: #b42318;
  --red-soft: #fef3f2;
  --warn-bg: #fffaeb;
  --warn-ink: #7a4d00;
  --radius: 4px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: "IBM Plex Sans Arabic", "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
body.ltr { font-family: "IBM Plex Sans", "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--blue); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px 56px; }
.num, td, .price, .v { font-variant-numeric: tabular-nums lining-nums; }

/* ---------- header ---------- */
header.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 0 14px; margin: 0;
}
header.top .brandlink { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.35rem; color: var(--navy); letter-spacing: 0; }
.logo { width: 30px; height: 30px; }
.lang a {
  color: var(--muted); text-decoration: none; font-size: .84rem; font-weight: 500;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 12px; background: #fff;
}
.lang a:hover { color: var(--navy); border-color: var(--navy); }

.nav {
  display: flex; gap: 0; margin: 0 0 24px; border-top: 2px solid var(--navy);
  border-bottom: 1px solid var(--line); background: #fff; overflow-x: auto; white-space: nowrap;
}
.nav a {
  color: var(--muted); text-decoration: none; padding: 10px 18px; font-size: .94rem; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav a.cur { color: var(--navy); font-weight: 700; border-bottom-color: var(--gold-bright); }
.nav a:hover:not(.cur) { color: var(--navy); background: var(--bg); }

/* ---------- headline ---------- */
h1 { font-size: 1.55rem; font-weight: 700; margin: 0 0 4px; color: var(--navy); line-height: 1.35; }
.live { color: var(--muted); font-size: .85rem; margin-bottom: 18px; display: flex; align-items: center; }
.live .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--up); margin-inline-end: 7px; }
.stale-banner {
  display: none; background: var(--warn-bg); color: var(--warn-ink);
  border: 1px solid #f0d9a0; border-radius: var(--radius); padding: 9px 14px; margin-bottom: 16px; font-size: .88rem;
}

/* ---------- hero: flat price strip ---------- */
.hero {
  background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--gold-bright);
  border-radius: var(--radius); padding: 18px 22px; margin-bottom: 20px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; color: var(--ink);
}
.hero .label { color: var(--muted); font-size: .9rem; font-weight: 500; }
.hero .price { font-size: 2.5rem; font-weight: 700; color: var(--navy); line-height: 1.2; }
.hero .price small { font-size: .95rem; font-weight: 500; color: var(--muted); }
.hero .change { font-size: .92rem; font-weight: 600; padding: 2px 0; }
.change.down { color: var(--down); }
.change.up { color: var(--up); }
.hero-img { display: none; }

/* ---------- sections (flat) ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 20px;
}
.card h2 { font-size: 1.02rem; font-weight: 700; margin-bottom: 12px; color: var(--navy); }

/* stat strip */
.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-bottom: 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.tile { padding: 12px 18px; border-bottom: 1px solid var(--line-soft); border-inline-end: 1px solid var(--line-soft); }
.tile:nth-child(3n) { border-inline-end: none; }
.tile:nth-last-child(-n+3) { border-bottom: none; }
.tile .t { color: var(--muted); font-size: .8rem; font-weight: 500; }
.tile .v { font-size: 1.15rem; font-weight: 700; margin-top: 0; color: var(--navy); }

/* ---------- tables ---------- */
table {
  width: 100%; border-collapse: collapse; background: var(--card); margin-bottom: 20px;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
caption { text-align: start; font-weight: 700; padding: 0 0 8px; font-size: 1rem; color: var(--navy); caption-side: top; }
th, td { padding: 9px 16px; border-bottom: 1px solid var(--line-soft); text-align: start; font-size: .93rem; }
th { background: #f1f3f6; color: var(--muted); font-weight: 600; font-size: .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }
tr:last-child td { border-bottom: none; }
td:not(:first-child) { font-weight: 600; }

.note, .disclaimer { color: var(--muted); font-size: .86rem; margin-bottom: 14px; }
.note { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.note h2 { font-size: 1rem; color: var(--navy); margin-bottom: 6px; font-weight: 700; }
.prose a, .note a { color: var(--blue); font-weight: 500; }

/* ---------- chart ---------- */
.ranges { display: flex; gap: 0; margin-bottom: 10px; }
.ranges button {
  font: inherit; font-size: .82rem; font-weight: 600; border: 1px solid var(--line); background: #fff;
  padding: 4px 14px; cursor: pointer; color: var(--muted); margin-inline-end: -1px;
}
.ranges button:first-child { border-start-start-radius: var(--radius); border-end-start-radius: var(--radius); }
.ranges button:last-child { border-start-end-radius: var(--radius); border-end-end-radius: var(--radius); }
.ranges button.on { background: var(--navy); border-color: var(--navy); color: #fff; position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .empty { color: var(--muted); font-size: .9rem; padding: 26px 8px; text-align: center; background: var(--bg); border-radius: var(--radius); }
.chart-note { font-size: .86rem; color: var(--muted); margin-top: 6px; }
.chart-note .up { color: var(--up); } .chart-note .down { color: var(--down); }

/* ---------- forms ---------- */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 12px; }
.form label { font-size: .82rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.form input, .form select {
  font: inherit; font-size: .98rem; padding: 8px 10px; border: 1px solid #c8ced6; border-radius: var(--radius);
  background: #fff; color: var(--ink); width: 100%;
}
.form input:focus, .form select:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
.result {
  background: var(--bg); border: 1px solid var(--line); border-inline-start: 3px solid var(--gold-bright);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-size: 1rem; font-weight: 600;
}

/* ---------- footer ---------- */
footer {
  border-top: 1px solid var(--line); padding-top: 18px; margin-top: 24px;
  color: var(--muted); font-size: .8rem; line-height: 1.8;
}
footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
footer a:hover { color: var(--navy); }
.flinks { margin-bottom: 8px; font-size: .86rem; }
.flinks a { text-decoration: none; color: var(--navy); font-weight: 500; }
.attr { font-size: .78rem; }
.attr a { color: var(--muted); }

/* ---------- prose / articles ---------- */
.prose { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; margin-bottom: 20px; }
.prose h1 { font-size: 1.65rem; font-weight: 700; margin: 0 0 14px; line-height: 1.4; }
.prose h2 { font-size: 1.12rem; font-weight: 700; margin: 22px 0 8px; color: var(--navy); }
.prose p, .prose ul { margin-bottom: 12px; }
.prose ul { padding-inline-start: 22px; }
.artlist { list-style: none; padding: 0 !important; }
.artlist li { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.artlist li:last-child { border-bottom: none; }
.artlist a { font-weight: 700; color: var(--navy); text-decoration: none; }
.artlist a:hover { color: var(--gold); text-decoration: underline; }
.artlist p { color: var(--muted); font-size: .9rem; margin: 4px 0 0; }
.artlist li img { width: 96px; height: 60px; object-fit: cover; border-radius: var(--radius); flex: none; border: 1px solid var(--line); }
.banner { display: block; width: 100%; height: auto; max-height: 220px; object-fit: cover; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid var(--line); }
.banner.art { max-height: 240px; }

#weights-table, #fx-table { display: block; overflow-x: auto; white-space: nowrap; }
html, body { overflow-x: hidden; }

/* ---------- alerts ---------- */
#alerts h2 .bell { display: none; }
.alert-sub { color: var(--muted); font-size: .86rem; margin-bottom: 12px; }
.btn-blue {
  background: var(--navy); color: #fff; border: none; border-radius: var(--radius);
  padding: 9px 18px; font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer;
}
.btn-blue:hover { background: #1b2f4b; }
.alert-hit { background: var(--red-soft); border: 1px solid #f4b8b2; color: var(--red); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-weight: 600; }
.alert-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; background: #fff; }
.alert-row.hit { border-color: #f4b8b2; background: var(--red-soft); }
.alert-row .a-txt { flex: 1; }
.alert-badge { background: var(--red); color: #fff; font-size: .75rem; font-weight: 600; border-radius: 3px; padding: 1px 8px; }
.a-del { background: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 3px 12px; cursor: pointer; font: inherit; font-size: .8rem; color: var(--muted); }
.a-del:hover { border-color: var(--red); color: var(--red); }
.alert-empty { color: var(--muted); font-size: .88rem; }
.alert-note { color: var(--red); font-size: .86rem; min-height: 1.2em; margin-top: 6px; }

/* ---------- zakat ---------- */
.btn-link { display: inline-block; text-decoration: none; }
.z-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--line-soft); }
.z-row:last-of-type { border-bottom: none; }
.z-row span { color: var(--muted); font-size: .92rem; }
.z-row b { font-size: 1.05rem; }
.z-row.z-due b { color: var(--navy); font-size: 1.25rem; }
.z-verdict { margin-top: 10px; border-radius: var(--radius); padding: 10px 14px; font-weight: 600; font-size: .92rem; }
.z-verdict.up { background: var(--blue-soft); color: var(--blue); border: 1px solid #c9d9f2; }
.z-verdict.down { background: var(--gold-soft); color: var(--warn-ink); border: 1px solid #e8dcb5; }

.mail-slot { background: var(--gold-soft); border: 1px dashed var(--gold-bright); padding: 2px 10px; }

@media (max-width: 640px) {
  .wrap { padding: 0 14px 40px; }
  h1 { font-size: 1.3rem; }
  .hero { padding: 14px 16px; }
  .hero .price { font-size: 2.1rem; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .tile:nth-child(3n) { border-inline-end: 1px solid var(--line-soft); }
  .tile:nth-child(2n) { border-inline-end: none; }
  .tile:nth-last-child(-n+3) { border-bottom: 1px solid var(--line-soft); }
  .tile:nth-last-child(-n+2) { border-bottom: none; }
  th, td { padding: 8px 10px; font-size: .88rem; }
  .prose { padding: 18px 16px; }
  .nav a { padding: 10px 14px; }
}

/* country bar */
#country-card { padding: 10px 16px; margin-bottom: 14px; }
#country-card .form { margin: 0; display: flex; }
#country-card .form label { flex-direction: row; align-items: center; gap: 12px; width: 100%; white-space: nowrap; }
#country-card select { max-width: 280px; }
#country-card .chart-note { margin-top: 6px; }
#weights-table, #fx-table { border: none; border-top: 1px solid var(--line); } #weights-table caption, #fx-table caption { display: block; }

/* ===== color pass ===== */
:root { --bg: #f5f2ea; --navy: #0b2545; --navy-2: #13315c; --gold: #9a6f0b; --gold-bright: #d4a72c; --gold-soft: #fbf3d9; }
body { background: var(--bg); }
header.top {
  background: var(--navy); padding: 14px 20px; margin: 0 -20px; 
  box-shadow: 0 0 0 100vmax var(--navy); clip-path: inset(0 -100vmax);
}
.brand { color: var(--gold-bright); }
.lang a { background: transparent; color: #dbe4f3; border-color: rgba(255,255,255,.3); }
.lang a:hover { color: #fff; border-color: var(--gold-bright); }
.nav {
  background: var(--navy-2); border-top: none; border-bottom: 3px solid var(--gold-bright);
  margin: 0 -20px 24px; padding: 0 20px;
  box-shadow: 0 0 0 100vmax var(--navy-2); clip-path: inset(0 -100vmax -3px);
}
.nav a { color: #c9d6ec; border-bottom: 3px solid transparent; margin-bottom: 0; }
.nav a.cur { color: var(--navy); background: var(--gold-bright); font-weight: 700; border-bottom-color: var(--gold-bright); }
.nav a:hover:not(.cur) { background: rgba(255,255,255,.08); color: #fff; }
h1 { color: var(--navy); }

.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  border: none; border-radius: 6px; padding: 22px 26px; color: #fff;
}
.hero .label { color: #c9d6ec; }
.hero .price { color: var(--gold-bright); font-size: 2.8rem; }
.hero .price small { color: #c9d6ec; }
.hero .change { background: rgba(255,255,255,.1); border-radius: 4px; padding: 3px 12px; }
.change.up { color: #5fe0a0; } .change.down { color: #ff9b8f; }

.card { border-top: 3px solid var(--gold-bright); background: #fff; }
.card h2 { color: var(--navy); }
#country-card { background: var(--gold-soft); border: 1px solid #ecdca0; border-top: 3px solid var(--gold-bright); }
.grid { background: #fff; border-color: #e3dcc4; border-top: 3px solid var(--navy); }
.tile:nth-child(odd) { background: #fbfaf5; }
.tile .v { color: var(--navy); }
.tile .t { color: var(--gold); font-weight: 600; }

table { border-color: #e3dcc4; }
th { background: var(--navy); color: var(--gold-bright); border-bottom: none; font-size: .82rem; }
tbody tr:nth-child(even) { background: #faf7ec; }
tbody tr:hover { background: var(--gold-soft); }
td:not(:first-child) { color: var(--navy); }
caption { color: var(--navy); border-inline-start: 4px solid var(--gold-bright); padding: 0 10px 8px; margin-bottom: 4px; }
.note { border-inline-start: 4px solid var(--gold-bright); background: #fffdf5; }
.ranges button.on { background: var(--navy); color: var(--gold-bright); border-color: var(--navy); }
.btn-blue { background: var(--gold-bright); color: var(--navy); font-weight: 700; }
.btn-blue:hover { background: #e2b83c; }
.result { background: var(--gold-soft); border-color: #ecdca0; border-inline-start-color: var(--gold-bright); color: var(--navy); }
.chart svg path[stroke] { stroke: var(--gold); }
.z-row.z-due b { color: var(--gold); }
.z-verdict.up { background: #e8f6ee; color: var(--up); border-color: #b5e0c8; }
.z-verdict.down { background: var(--gold-soft); color: var(--warn-ink); }
.prose { border-top: 3px solid var(--gold-bright); }
.prose h2 { color: var(--navy); border-inline-start: 4px solid var(--gold-bright); padding-inline-start: 10px; }
footer { background: var(--navy); color: #b9c7de; margin: 28px -20px -56px; padding: 22px 20px 36px; border: none;
  box-shadow: 0 0 0 100vmax var(--navy); clip-path: inset(0 -100vmax); }
footer a { color: #dbe4f3; } .flinks a { color: var(--gold-bright); } .attr a { color: #dbe4f3; }
@media (max-width: 640px) {
  header.top, .nav { margin-inline: -14px; padding-inline: 14px; }
  footer { margin-inline: -14px; padding-inline: 14px; }
  .hero .price { font-size: 2.3rem; }
}
.nav { border-bottom: none; clip-path: inset(0 -100vmax); }
.nav a { border-bottom: none; }

/* English (ltr) pages */
body.ltr #fx-table { display: table; width: 100%; }
@media (max-width: 640px) {
  body.ltr #fx-table { display: block; }
  body.ltr .nav a { padding: 10px 9px; font-size: 14px; }
}
@media (max-width: 400px) {
  body.ltr .nav a { padding: 10px 7px; font-size: 13px; }
}

/* Visitor comments */
.c-list { margin-bottom: 14px; }
.c-item { border: 1px solid var(--line, #e8e2d4); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.c-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.c-name { font-weight: 700; color: var(--ink); }
.c-date { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.c-body { line-height: 1.7; overflow-wrap: break-word; }
.c-empty { color: var(--muted); padding: 8px 0; }
.c-form textarea { width: 100%; border: 1px solid #d7dde6; border-radius: 10px; padding: 9px 11px; font-family: inherit; font-size: .95rem; resize: vertical; box-sizing: border-box; }
.c-form textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
.c-body-label { grid-column: 1 / -1; }
.c-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.c-note { font-size: .82rem; color: var(--muted); margin-top: 6px; }

/* ===== UI Moments polish (v15): subtle micro-interactions ===== */
/* Buttons: lift on hover, springy press, visible focus */
.btn-blue { transition: background .18s ease, transform .12s ease, box-shadow .18s ease; }
.btn-blue:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(11,26,51,.18); }
.btn-blue:active { transform: translateY(0) scale(.97); box-shadow: none; }
.btn-blue:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.ranges button { transition: background .18s ease, color .18s ease, transform .12s ease; }
.ranges button:hover { transform: translateY(-1px); }
.ranges button:active { transform: scale(.96); }

/* Cards & tiles: gentle hover feedback on pointer devices only */
@media (hover:hover) {
  .card { transition: box-shadow .22s ease; }
  .card:hover { box-shadow: 0 6px 18px rgba(11,26,51,.08); }
  .tile { transition: background .18s ease, transform .18s ease; }
  .tile:hover { background: #fafbfc; transform: translateY(-2px); }
}

/* Nav & link transitions */
.nav a { transition: color .18s ease, background .18s ease, border-color .18s ease; }
.flinks a, footer a, .note a, .artlist a, .lang a { transition: color .15s ease, border-color .15s ease, background .15s ease; }

/* Live indicator pulse */
.live .dot { animation: pulse-dot 2.2s ease-in-out infinite; }
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(29,122,61,.35); }
  50% { box-shadow: 0 0 0 5px rgba(29,122,61,0); }
}

/* One-time gentle entrance for the page heading and hero */
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
h1 { animation: fade-up .3s ease-out both; }
.hero { animation: fade-up .38s ease-out .04s both; }

/* Loading shimmer on "…" placeholders (class managed by ui.js) */
.shimmer { position: relative; color: transparent !important; min-width: 3ch; }
.shimmer::after { content: ""; position: absolute; inset: 2px 0; border-radius: 6px;
  background: linear-gradient(90deg, #eae7dd 25%, #f7f5ee 50%, #eae7dd 75%);
  background-size: 200% 100%; animation: shimmer-slide 1.2s linear infinite; }
@keyframes shimmer-slide { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Flash when a price value changes (class toggled by ui.js) */
.flash-up { animation: flash-up 1.1s ease; }
.flash-down { animation: flash-down 1.1s ease; }
@keyframes flash-up { 0% { background: rgba(29,122,61,.22); border-radius: 6px; } 100% { background: transparent; } }
@keyframes flash-down { 0% { background: rgba(179,38,30,.18); border-radius: 6px; } 100% { background: transparent; } }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}
