:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --fg: var(--tg-theme-text-color, #1b1f23);
  --muted: var(--tg-theme-hint-color, #6b7280);
  --card: var(--tg-theme-secondary-bg-color, #f3f4f6);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-fg: var(--tg-theme-button-text-color, #ffffff);
  --good: #2e9e5b;
  --bad: #d1495b;
  --warn: #d98e04;
  --line: rgba(127, 127, 127, .22);
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif; }
body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
#title { font-weight: 700; font-size: 17px; }
#refresh { border: 0; background: var(--card); color: var(--fg); width: 36px; height: 36px; border-radius: 50%; font-size: 18px; }
main { padding: 12px 16px 24px; max-width: 720px; margin: 0 auto; }
nav { position: fixed; inset: auto 0 0 0; display: flex; background: var(--bg); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
nav button { flex: 1; border: 0; background: none; color: var(--muted); padding: 8px 2px 6px; font-size: 20px; line-height: 1.1; }
nav button span { display: block; font-size: 11px; margin-top: 2px; }
nav button.on { color: var(--accent); font-weight: 700; }
.card { background: var(--card); border-radius: var(--r); padding: 14px; margin: 0 0 12px; }
.card h2 { margin: 0 0 8px; font-size: 15px; }
.card h2 small { color: var(--muted); font-weight: 400; margin-inline-start: 6px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 5px 0; }
.row + .row { border-top: 1px solid var(--line); }
.row .k { color: var(--muted); }
.muted { color: var(--muted); }
.center { text-align: center; }
.big { font-size: 28px; font-weight: 800; letter-spacing: .5px; direction: ltr; text-align: center; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; background: var(--line); }
.pill.good { background: rgba(46,158,91,.18); color: var(--good); }
.pill.bad { background: rgba(209,73,91,.18); color: var(--bad); }
.pill.warn { background: rgba(217,142,4,.2); color: var(--warn); }
.btns { display: flex; gap: 8px; margin-top: 10px; }
.btns button, button.wide { flex: 1; border: 0; border-radius: 12px; padding: 11px 8px; font-size: 15px; font-weight: 600;
  background: var(--accent); color: var(--accent-fg); }
.btns button.alt, button.wide.alt { background: var(--line); color: var(--fg); }
.btns button.danger { background: var(--bad); color: #fff; }
button:disabled { opacity: .5; }
.banner { border-radius: var(--r); padding: 12px 14px; margin: 0 0 12px; background: rgba(36,129,204,.14); border: 1px solid rgba(36,129,204,.35); }
.banner b { display: block; margin-bottom: 2px; }
.swap { padding: 8px 0; }
.swap + .swap { border-top: 1px solid var(--line); }
.swap .names { display: flex; align-items: center; gap: 8px; font-weight: 600; flex-wrap: wrap; }
.swap .arrow { color: var(--muted); }
.swap .meta { color: var(--muted); font-size: 13px; direction: ltr; text-align: right; }
.swap .warn { color: var(--warn); font-size: 13px; }
.p { display: inline-flex; align-items: baseline; gap: 5px; margin: 3px 0; }
.p .x { color: var(--muted); font-size: 12px; direction: ltr; }
.line { padding: 4px 0; }
.line .pos { display: inline-block; width: 1.6em; }
.cap { color: var(--accent); font-weight: 700; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 6px 4px; text-align: center; border-top: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; border-top: 0; font-size: 12px; }
td:first-child, th:first-child { text-align: start; }
td.best { background: rgba(46,158,91,.2); font-weight: 700; border-radius: 6px; }
td.me, tr.me td { font-weight: 700; color: var(--accent); }
.num { direction: ltr; unicode-bidi: embed; }
svg { width: 100%; height: auto; display: block; }
svg text { fill: var(--muted); font-size: 10px; }
#toast { position: fixed; inset: auto 16px calc(80px + env(safe-area-inset-bottom)) 16px; background: #222; color: #fff;
  padding: 10px 14px; border-radius: 12px; opacity: 0; transform: translateY(8px); transition: .25s; pointer-events: none; z-index: 9; text-align: center; }
#toast.on { opacity: .95; transform: none; }
