:root {
  --bg: #ffffff;
  --ink: #0b0d12;
  --ink-2: #42495a;
  --ink-3: #7a8296;
  --line: #e6e8ee;
  --line-2: #f0f2f7;
  --brand: #0e7f4f;
  --brand-2: #066d3f;
  --accent: #c9a227;
  --gold: #f2c230;
  --silver: #c6cbd4;
  --bronze: #c88b4a;
  --top3-bg: #fbf7ea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 13, 18, 0.04), 0 4px 18px rgba(11, 13, 18, 0.06);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

[dir="rtl"] { font-family: 'Inter', 'Segoe UI', Tahoma, sans-serif; }

main { max-width: 960px; margin: 0 auto; padding: 24px 20px 64px; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 20px 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.topbar .brand { justify-self: start; }
.topbar-controls {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.topbar .lang-switch { justify-self: end; }

/* Custom date picker trigger */
.date-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--line-2);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.date-control:hover { background: #e4e7ef; border-color: var(--line); }
.date-control.is-open { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,127,79,0.12); }
.date-control input[type="date"] {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  min-width: 120px;
}
.date-control input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.6; }
.date-icon { font-size: 14px; }

/* ---------- Custom Date Picker Popover ---------- */
.datepicker-popover {
  position: absolute;
  z-index: 200;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(11,13,18,0.14), 0 2px 8px rgba(11,13,18,0.06);
  padding: 16px;
  min-width: 280px;
  animation: popover-in 0.18s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popover-in {
  from { opacity: 0; transform: translateX(-50%) scale(0.94) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) scale(1)   translateY(0); }
}
.datepicker-popover.closing {
  animation: popover-out 0.14s ease forwards;
}
@keyframes popover-out {
  from { opacity: 1; transform: translateX(-50%) scale(1) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) scale(0.95) translateY(-4px); }
}
.dp-anchor {
  position: relative;
  display: inline-flex;
}
.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}
.dp-nav-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-2);
  font-size: 14px;
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background 0.1s;
}
.dp-nav-btn:hover { background: var(--line-2); }
.dp-month-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  text-align: center;
  flex: 1;
}
.dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}
.dp-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 0;
}
.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.dp-day {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: var(--ink);
  transition: background 0.1s, color 0.1s;
  font-variant-numeric: tabular-nums;
}
.dp-day:hover:not(:disabled) { background: var(--line-2); }
.dp-day.dp-today { border: 2px solid var(--brand); color: var(--brand); font-weight: 700; }
.dp-day.dp-selected { background: var(--brand); color: #fff; font-weight: 700; }
.dp-day.dp-selected:hover { background: var(--brand-2); }
.dp-day:disabled { color: var(--silver); cursor: not-allowed; }
.dp-day.dp-other-month { color: var(--ink-3); opacity: 0.45; }
.dp-day.dp-other-month:disabled { opacity: 0.2; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(11, 13, 18, 0.08);
}
.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.brand-name { font-size: 16px; }

.lang-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--line-2);
}
.lang-switch a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}
.lang-flag {
  display: inline-block;
  width: 20px; height: 15px;
  border-radius: 3px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}
.ccy-flag {
  display: inline-block;
  width: 22px; height: 16px;
  border-radius: 3px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
  vertical-align: middle;
}
.ccy-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--line-2);
  border-radius: 999px;
  font-weight: 600;
}
.hero-pair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: 4px;
  padding: 2px 10px;
  background: #eaf5ee;
  border-radius: 999px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--brand-2);
  font-weight: 600;
}
.hero-arrow { color: var(--ink-3); margin: 0 4px; font-weight: 600; }
/* 2 rows × 3 columns: tips on row 1 (above each chip), chips + arrow on row 2 (vertically centered together). */
.hero-pair-block {
  display: grid;
  grid-template-columns: auto auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: start;
  column-gap: 10px;
  row-gap: 4px;
  width: max-content;
  max-width: 100%;
}
.ccy-tip {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ccy-tip-give    { grid-column: 1; grid-row: 1; }
.ccy-tip-receive { grid-column: 3; grid-row: 1; }
.ccy-row-give    { grid-column: 1; grid-row: 2; }
.ccy-row-receive { grid-column: 3; grid-row: 2; }
.hero-arrow {
  grid-column: 2;
  grid-row: 2;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-2);
  align-self: center;
  margin: 0;
}
.ccy-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: #eaf5ee;
  border-radius: 999px;
  font-weight: 600;
  color: var(--brand-2);
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1;
}
.hero-card[data-direction="fx-to-tnd"] .ccy-row { background: #faf0e1; color: #8a5a23; }
.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.select-flag {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
[dir="rtl"] .select-flag { left: auto; right: 12px; }
.select-wrap select { padding-inline-start: 42px; }
.lang-switch a:hover { background: #fff; text-decoration: none; }
.lang-switch a.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Page title (SEO h1, visually subtle) ---------- */
.page-title {
  margin: 24px 0 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ---------- Hero (two cards) ---------- */
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}
.hero-card {
  padding: 24px 22px;
  background: linear-gradient(180deg, #ffffff 0%, #f7faf8 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* The hero head groups the kicker + give/receive pair as one tight unit. */
.hero-head { display: flex; flex-direction: column; gap: 6px; }
.hero-head .hero-kicker { margin: 0; }
.hero-card[data-direction="fx-to-tnd"] {
  background: linear-gradient(180deg, #ffffff 0%, #fbf7f1 100%);
}
.hero-compute {
  margin: 6px 0 0;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--ink-2);
  font-weight: 500;
}
.hero {
  margin-top: 24px;
  padding: 28px 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f7faf8 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-kicker {
  margin: 0 0 14px;
  color: var(--ink-3);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.hero-direction { color: var(--brand-2); text-transform: none; letter-spacing: 0; font-weight: 600; }

.hero-bank {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.hero-logo {
  width: 72px; height: 72px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 22px;
  background: #e7f4ec;
  color: var(--brand-2);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.hero-meta { min-width: 0; }
.hero-bank-name {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* The compute line is now the prominent figure (more human-friendly than the rate). */
.hero-compute {
  margin: 8px 0 0;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1.2;
  overflow-wrap: anywhere;
}
/* The rate line is now secondary metadata. */
.hero-rate {
  margin: 6px 0 0;
  color: var(--ink-3);
  font-size: 13px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
}
.hero-rate-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.hero-rate-value {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.hero-rate-unit { color: var(--ink-3); font-size: 12px; }

/* ---------- Controls ---------- */
.controls {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}
.control { display: flex; flex-direction: column; gap: 6px; }
.control label, .control .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
}
.control select {
  appearance: none;
  -webkit-appearance: none;
  padding: 10px 34px 10px 12px;
  border: 1px solid var(--line);
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%237a8296' d='M6 8L0 0h12z'/></svg>") no-repeat right 12px center;
  border-radius: 10px;
  font: inherit;
  min-width: 220px;
}
[dir="rtl"] .control select {
  padding: 10px 12px 10px 34px;
  background-position: left 12px center;
}
.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.seg {
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.seg + .seg { border-inline-start: 1px solid var(--line); }
.seg:hover { background: var(--line-2); }
.seg-active { background: var(--ink); color: #fff; }
.seg-active:hover { background: var(--ink); }

/* ---------- Simulator (equation) ---------- */
.simulator {
  margin-top: 20px;
  padding: 22px 20px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}
/* Promoted variant: the simulator is the page hero. */
.simulator.hero-sim {
  margin-top: 0;
  padding: 28px 24px 22px;
  background: linear-gradient(180deg, #ffffff 0%, #f6faf8 100%);
}
.simulator h2 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 600;
}
.winner-line {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.winner-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
}
.winner-label {
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 700;
}
.winner-bank {
  font-weight: 700;
  color: var(--brand-2);
  font-size: 18px;
}
.winner-delta {
  color: var(--ink-3);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.eq {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.eq-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.eq-tip {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink-2);
  padding-inline-start: 12px;
}
.eq-bank {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  align-self: flex-end;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-2);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}
.eq-side {
  flex: 1 1 0;
  min-width: 0;
  min-height: 64px;
  display: flex;
  align-items: center;
  background: var(--line-2);
  border-radius: 12px;
  padding: 6px 10px 6px 6px;
  border: 1px solid transparent;
}
.eq-side:focus-within { border-color: var(--brand); background: #fff; }
.eq-amount {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  border: 0;
  background: transparent;
  padding: 10px 8px;
  font: inherit;
  font-weight: 700;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  outline: none;
}
.eq-ccy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #fff;
  border-radius: 8px;
  font-weight: 600;
  flex-shrink: 0;
  border: 1px solid var(--line);
  position: relative;
}
.eq-ccy-label { min-width: 30px; text-align: center; }
.eq-select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  padding: 0 14px 0 0;
  cursor: pointer;
  color: var(--ink);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%237a8296' d='M5 6L0 0h10z'/></svg>");
  background-repeat: no-repeat;
  background-position: right center;
  /* Match the 3-letter currency code's natural width so it doesn't push the amount input. */
  width: auto;
  min-width: 0;
  max-width: 56px;
}
[dir="rtl"] .eq-select { padding: 0 0 0 14px; background-position: left center; }
.swap-btn {
  flex-shrink: 0;
  width: 44px;
  height: 64px;
  align-self: flex-end;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink-2);
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.2s, background 0.15s;
}
.swap-btn:hover { background: var(--line-2); transform: rotate(180deg); }
.swap-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sim-at {
  margin: 12px 0 0;
  color: var(--ink-3);
  font-size: 14px;
}

/* ---------- Ranking / Table ---------- */
.ranking { margin-top: 28px; }
.ranking-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ranking-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.date-chip {
  display: inline-block;
  padding: 3px 10px;
  background: var(--line-2);
  color: var(--ink-2);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}
.history-btn {
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.history-btn:hover { background: var(--line-2); }
.history-panel {
  margin-top: 12px;
  padding: 12px;
  background: var(--line-2);
  border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
}
.history-panel input {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}

.table-wrap {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}
.rates-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.rates-table thead th {
  text-align: start;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 14px;
  background: #fafbfd;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.rates-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-2);
  font-size: 15px;
}
.rates-table tbody tr:last-child td { border-bottom: 0; }
.rates-table tbody tr.is-top3 { background: var(--top3-bg); }
.rates-table tbody tr.rank-1 { background: #fff6d7; }
.rates-table tbody tr.rank-2 { background: #f3f5f9; }
.rates-table tbody tr.rank-3 { background: #fbf1e3; }
.rates-table tbody tr:hover { background: #f3f8f5; }
.rates-table tbody tr.no-data { color: var(--ink-3); }
.rates-table tbody tr.no-data .bank-logo { opacity: 0.55; }
.rates-table tbody tr.no-data:hover { background: transparent; }
.rates-table .na { font-size: 13px; color: var(--ink-3); font-style: italic; }

.col-rank { width: 64px; font-weight: 700; font-size: 22px; text-align: center; }
.rates-table tbody tr.rank-1 .col-rank,
.rates-table tbody tr.rank-2 .col-rank,
.rates-table tbody tr.rank-3 .col-rank { font-size: 30px; line-height: 1; }
.col-bank { min-width: 180px; }
.col-receive { width: 200px; line-height: 1.25; white-space: nowrap; }
.col-receive strong { color: var(--brand-2); font-size: 16px; display: block; }
.rate-sub { color: var(--ink-3); font-size: 12px; font-weight: 400; display: block; margin-top: 2px; }
.col-delta { width: 130px; color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.rates-table tbody tr.rank-1 .col-delta { color: var(--ink-3); }
.cell-label { display: none; }

.bank-cell { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.bank-logo {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: inline-grid; place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.bank-logo[data-bank-slug] {
  background-size: cover;
  background-position: center;
}
.bank-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; color: var(--ink-3); padding: 24px; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 960px;
  margin: 32px auto 0;
  padding: 24px 20px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 13px;
  text-align: center;
}
.site-footer p { margin: 4px 0; }
.disclaimer { font-size: 12px; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .topbar {
    padding: 14px 16px 0;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    row-gap: 12px;
    column-gap: 10px;
  }
  .topbar .brand {
    justify-self: start;
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }
  .brand-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar .lang-switch {
    justify-self: end;
    grid-column: 2;
    grid-row: 1;
    margin-inline-start: 0;
  }
  .topbar-controls {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    width: 100%;
    justify-content: center;
  }
  .date-control {
    width: 100%;
    justify-content: center;
  }
  .date-control input[type="date"] {
    min-width: 0;
    width: auto;
    font-size: 13px;
  }
  .lang-switch a { padding: 6px 8px; }
  .lang-switch a span { display: none; }
  .datepicker-popover {
    left: 50%;
    transform: translateX(-50%);
    min-width: 260px;
  }

  main { padding: 12px 12px 48px; }
  .page-title {
    margin: 18px 0 12px;
    font-size: 13px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
  .hero { padding: 22px 18px; }
  .hero-bank-name { font-size: 22px; }
  .hero-rate-value { font-size: 18px; }
  .hero-logo { width: 56px; height: 56px; font-size: 16px; }

  .hero-grid { grid-template-columns: 1fr; gap: 12px; }
  .hero-card { padding: 20px 18px; }
  .hero-bank-name { font-size: 22px; }
  .hero-compute { font-size: 19px; }

  .simulator.hero-sim {
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
  }
  .eq {
    order: 2;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      "left"
      "swap"
      "right";
    align-items: stretch;
    gap: 10px;
  }
  .eq-bank { display: none; }
  .eq-col-left { grid-area: left; }
  .eq-col-right { grid-area: right; }
  .eq-side {
    flex: none;
    width: 100%;
    min-width: 0;
    min-height: 58px;
  }
  .swap-btn {
    grid-area: swap;
    justify-self: center;
    flex: none;
    width: 48px;
    height: 42px;
  }
  .eq-tip {
    padding-inline-start: 4px;
    font-size: 13px;
  }
  .eq-amount { font-size: 18px; }
  .eq-select { max-width: 52px; }
  .winner-line {
    order: 1;
    margin: 0 0 14px;
    align-items: center;
    gap: 8px;
  }
  .winner-logo {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }
  .winner-label { font-size: 13px; }
  .winner-bank { font-size: 16px; }
  .winner-delta {
    flex: 1 0 100%;
    padding-inline-start: 42px;
  }

  .rates-table thead { display: none; }
  .rates-table tbody td { display: block; padding: 4px 14px; border: 0; font-size: 14px; }
  .rates-table tbody tr {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-areas:
      "rank bank"
      "rank receive"
      "rank delta";
    padding: 12px 0;
    border-bottom: 1px solid var(--line-2);
    gap: 4px 8px;
    align-items: center;
  }
  .rates-table tbody tr.is-top3 { background: var(--top3-bg); }
  .col-rank {
    grid-area: rank;
    padding: 12px 0 0 12px !important;
    font-size: 20px;
    line-height: 1.2;
  }
  .rates-table tbody tr.rank-1 .col-rank,
  .rates-table tbody tr.rank-2 .col-rank,
  .rates-table tbody tr.rank-3 .col-rank {
    font-size: 20px;
    line-height: 1.2;
  }
  .col-bank {
    grid-area: bank;
    min-width: 0;
    padding-top: 10px !important;
    padding-inline-end: 12px !important;
  }
  .col-receive {
    grid-area: receive;
    width: auto;
    padding-top: 0 !important;
    padding-inline-end: 12px !important;
    text-align: start;
    white-space: normal;
  }
  .cell-label {
    display: inline;
    margin: 0;
    color: var(--ink-3);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
  }
  .cell-label::after { content: " : "; }
  .col-receive strong {
    display: inline;
    font-size: 14px;
    line-height: 1.35;
  }
  .rate-sub {
    display: block;
    margin-top: 2px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
  }
  .col-delta {
    grid-area: delta;
    width: auto;
    padding: 0 12px 0 14px !important;
    font-size: 14px;
    line-height: 1.35;
    white-space: normal;
  }
  .delta-value {
    display: inline;
    color: var(--ink-2);
    font-weight: 600;
  }
  .bank-cell { max-width: 100%; }
  .bank-name {
    min-width: 0;
    font-size: 14px;
    line-height: 1.35;
  }
  .bank-logo {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }
}

@media (max-width: 420px) {
  main { padding-inline: 10px; }
  .simulator.hero-sim { padding-inline: 12px; }
  .eq { gap: 8px; }
  .eq-bank {
    width: 52px;
    height: 52px;
  }
  .eq-side { min-height: 56px; padding-inline-end: 8px; }
  .eq-amount {
    font-size: 17px;
    padding-inline: 6px;
  }
  .eq-ccy { padding: 5px 8px; }
  .ccy-flag {
    width: 18px;
    height: 14px;
  }
  .eq-select { max-width: 48px; }
  .lang-switch {
    justify-content: space-between;
  }
  .lang-switch a { flex: 1 1 0; justify-content: center; }
  .datepicker-popover { min-width: 240px; padding: 12px; }
  .dp-day { font-size: 12px; }
}

/* ---------- Custom Currency Dropdown ---------- */
.ccy-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.ccy-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #fff;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  color: var(--ink);
  min-width: 0;
}
.ccy-dropdown-trigger:hover { border-color: #c0c5d0; }
.ccy-dropdown-trigger.is-open {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(14,127,79,0.12);
}
.ccy-dropdown-arrow {
  width: 10px; height: 6px;
  flex-shrink: 0;
  margin-inline-start: 2px;
  color: var(--ink-3);
  transition: transform 0.2s;
}
.ccy-dropdown-trigger.is-open .ccy-dropdown-arrow {
  transform: rotate(180deg);
}
.ccy-panel {
  position: absolute;
  z-index: 300;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(11,13,18,0.14), 0 2px 8px rgba(11,13,18,0.06);
  min-width: 220px;
  max-height: 320px;
  display: flex;
  flex-direction: column;
  animation: popover-in-right 0.18s cubic-bezier(0.34,1.56,0.64,1);
  overflow: hidden;
}
@keyframes popover-in-right {
  from { opacity: 0; transform: scale(0.94) translateY(-6px); transform-origin: top right; }
  to   { opacity: 1; transform: scale(1) translateY(0); transform-origin: top right; }
}
.ccy-panel.closing {
  animation: popover-out-right 0.13s ease forwards;
}
@keyframes popover-out-right {
  from { opacity: 1; transform: scale(1) translateY(0); transform-origin: top right; }
  to   { opacity: 0; transform: scale(0.94) translateY(-4px); transform-origin: top right; }
}
.ccy-search-wrap {
  padding: 10px 10px 6px;
  flex-shrink: 0;
}
.ccy-search {
  width: 100%;
  padding: 7px 10px 7px 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--line-2) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none' stroke='%237a8296' stroke-width='2'><circle cx='8' cy='8' r='5'/><line x1='13' y1='13' x2='18' y2='18'/></svg>") no-repeat 10px center;
  outline: none;
  transition: border-color 0.15s;
}
.ccy-search:focus { border-color: var(--brand); background-color: #fff; }
.ccy-list {
  overflow-y: auto;
  flex: 1;
  padding: 4px 6px 8px;
  /* scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.ccy-list::-webkit-scrollbar { width: 4px; }
.ccy-list::-webkit-scrollbar-track { background: transparent; }
.ccy-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.ccy-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  border: 0;
  background: transparent;
  width: 100%;
  text-align: start;
}
.ccy-option:hover { background: var(--line-2); color: var(--ink); }
.ccy-option.is-selected { background: #eaf5ee; color: var(--brand-2); font-weight: 600; }
.ccy-option-code {
  font-weight: 700;
  font-size: 13px;
  min-width: 36px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.ccy-option-name {
  flex: 1;
  font-size: 12px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: start;
}
.ccy-option.is-selected .ccy-option-name { color: var(--brand-2); opacity: 0.8; }
.ccy-option-check {
  flex-shrink: 0;
  width: 16px; height: 16px;
  color: var(--brand);
  opacity: 0;
  transition: opacity 0.1s;
}
.ccy-option.is-selected .ccy-option-check { opacity: 1; }
.ccy-no-results {
  text-align: center;
  padding: 16px;
  color: var(--ink-3);
  font-size: 13px;
}

/* ---------- Currency Internal Nav (SEO) ---------- */
.currency-nav {
  margin-top: 32px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafbfd;
}
.currency-nav h2 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-2);
}
.currency-nav-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px 12px;
}
.currency-nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.currency-nav-links a:hover {
  background: var(--line-2);
  color: var(--ink);
}
.currency-nav-links a.is-active {
  background: #eaf5ee;
  color: var(--brand-2);
  font-weight: 600;
}
@media (max-width: 720px) {
  .currency-nav { padding: 16px; margin-top: 24px; }
  .currency-nav-links { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 8px; }
  .currency-nav-links a { padding: 6px 8px; font-size: 12px; }
}
