/* ── Telegram theme tokens ─────────────────────────────────────── */
:root {
  --bg:          var(--tg-theme-bg-color,           #ffffff);
  --bg2:         var(--tg-theme-secondary-bg-color,  #f2f2f7);
  --text:        var(--tg-theme-text-color,          #000000);
  --hint:        var(--tg-theme-hint-color,          #8e8e93);
  --link:        var(--tg-theme-link-color,          #007aff);
  --btn:         var(--tg-theme-button-color,        #007aff);
  --btn-text:    var(--tg-theme-button-text-color,   #ffffff);
  --sep:         rgba(0,0,0,.08);
  --green:       #34c759;
  --red:         #ff3b30;
  --yellow:      #ff9500;
  --r:           14px;
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg2);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type=number] { -moz-appearance: textfield; }

/* ── App shell ─────────────────────────────────────────────────── */
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; }

/* ── Tab bar ───────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--sep);
  padding: 0 16px;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.tab {
  padding: 12px 14px 10px;
  border: none;
  background: none;
  color: var(--hint);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tab.active {
  color: var(--btn);
  border-bottom-color: var(--btn);
  font-weight: 600;
}

/* ── Screens ───────────────────────────────────────────────────── */
.screen { display: none; padding: 12px 16px 32px; }
.screen.active { display: block; }

/* ── Converter card ────────────────────────────────────────────── */
.converter-card {
  background: var(--bg);
  border-radius: var(--r);
  padding: 4px 0 0;
  margin-bottom: 8px;
  overflow: hidden;
}

.conv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 0;
}
.conv-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.conv-right {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--hint);
}
.conv-flag { font-size: 20px; }

.conv-amount-row { padding: 4px 16px 12px; }
.conv-input {
  width: 100%;
  border: none;
  outline: none;
  background: none;
  font-size: 34px;
  font-weight: 700;
  color: var(--text);
  caret-color: var(--btn);
}
.conv-input::placeholder { color: var(--hint); }

.conv-divider { padding: 0 16px; }
.conv-hr { border: none; border-top: 1px solid var(--sep); }

/* Выбор страны — отдельная кнопка над карточкой */
.conv-country-row { margin-bottom: 8px; }

.corridor-picker-top {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  background: var(--bg);
  border: none;
  border-radius: var(--r);
  padding: 13px 16px;
  cursor: pointer;
  color: var(--text);
  text-align: left;
}
.corridor-picker-top #cp-flag { font-size: 22px; line-height: 1; }
.corridor-picker-top #cp-name { flex: 1; font-size: 16px; font-weight: 600; }
.corridor-picker-top .cp-arrow { font-size: 18px; color: var(--hint); }

/* Таб-кнопки выбора валюты в строке «Получит» */
.recv-currency-tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.rct-btn {
  font-size: 13px; font-weight: 700; letter-spacing: .3px;
  padding: 5px 12px; border-radius: 10px; cursor: pointer;
  background: rgba(0,122,255,.08); color: var(--btn);
  border: 1.5px solid rgba(0,122,255,.25);
  transition: background .15s, color .15s, border-color .15s;
  font-family: inherit;
  display: flex; align-items: center; gap: 3px;
}
.rct-btn.rct-active { background: var(--btn); color: #fff; border-color: transparent; }
.rct-btn[disabled]:not(.rct-active) { opacity: 0.35; cursor: default; background: var(--bg2); border-color: transparent; color: var(--hint); }
.rct-btn.rct-active[disabled] { cursor: default; }
.rct-dot { font-size: 8px; opacity: .6; }

/* Дропдаун выбора валюты в разделе «Оплата» */
.pay-currency-select {
  -webkit-appearance: none;
  appearance: none;
  background: var(--btn);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 6px 28px 6px 12px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: .3px;
  cursor: pointer;
  min-width: 96px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23fff' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}

/* Баннер устаревших данных */
.stale-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 16px 8px;
  padding: 8px 12px;
  background: rgba(255,149,0,.12);
  border-radius: 10px;
  font-size: 13px; color: var(--yellow);
}
.stale-spinner {
  width: 14px; height: 14px; flex-shrink: 0;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* Presets */
.presets {
  display: flex;
  gap: 4px;
  padding: 4px 16px 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.presets::-webkit-scrollbar { display: none; }
.preset {
  flex-shrink: 0;
  padding: 4px 8px;
  border: 1.5px solid var(--sep);
  border-radius: 20px;
  background: none;
  color: var(--hint);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s;
}
.preset.active, .preset:active {
  background: var(--btn);
  border-color: var(--btn);
  color: var(--btn-text);
}

/* ── CBR row ───────────────────────────────────────────────────── */
.cbr-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  background: var(--bg);
  border-radius: var(--r);
  padding: 8px 14px;
  margin-bottom: 8px;
}
.cbr-text {
  font-size: 12px;
  font-weight: 400;
  color: var(--hint);
  flex: 1 1 auto;
}
.list-updated {
  font-size: 12px;
  color: var(--hint);
  opacity: .7;
  white-space: nowrap;
}

/* ── Provider list ─────────────────────────────────────────────── */
.provider-list { display: flex; flex-direction: column; gap: 1px; }

/* Loading */
.list-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 0;
  color: var(--hint);
  font-size: 14px;
}
.spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--bg2);
  border-top-color: var(--btn);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Provider row */
.prow {
  background: var(--bg);
  padding: 14px 86px 12px 16px;
  cursor: pointer;
  position: relative;
  transition: background .1s;
}
.prow-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.prow-share {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--bg2);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.prow-share:active { opacity: 0.55; }
.prow-fav {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--bg2);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.prow-fav svg { fill: none; stroke: currentColor; }
.prow-fav.active { color: #ff3b30; }
.prow-fav.active svg { fill: currentColor; stroke: #ff3b30; }
.prow-fav:active { opacity: 0.6; }
.prow:active { background: var(--bg2); }
.prow:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0; left: 16px; right: 0;
  background: var(--sep);
}
.prow:first-child { border-radius: var(--r) var(--r) 0 0; }
.prow:last-child  { border-radius: 0 0 var(--r) var(--r); }
.prow:only-child  { border-radius: var(--r); }

/* Best badge */
.best-badge {
  display: inline-block;
  background: #e8f9ee;
  color: #1a7a36;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 8px;
}

/* Row layout */
.prow-right { }
.prow-amount { font-size: 24px; font-weight: 700; white-space: nowrap; }

/* Sub-row: rate + margin chips */
.prow-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.prow-rate  { font-size: 12px; color: var(--hint); }
.prow-fee {
  display: inline-block;
  font-size: 11px;
  color: var(--red);
  background: rgba(255,59,48,.08);
  border-radius: 4px;
  padding: 1px 6px;
}
.rate-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--hint);
  background: var(--bg2);
  border-radius: 4px;
  padding: 1px 6px;
}

/* Provider identity — logo + name, sits at bottom of card */
.prow-left {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.prow-logo {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  background: var(--bg2);
  flex-shrink: 0;
}
.prow-logo-svg { background: none !important; padding: 0; border-radius: 0; }
.prow-logo-svg svg { display: block; border-radius: 10px; }
.prow-name-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
}
.prow-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prow-corridor { font-size: 12px; color: var(--hint); white-space: nowrap; letter-spacing: -.1px; flex-shrink: 0; }
.prow-delivery { font-size: 12px; color: var(--hint); margin-top: 1px; }

/* Margin chip */
.margin-chip {
  font-size: 11px;
  color: var(--yellow);
  background: rgba(255,149,0,.08);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
}
.margin-chip.ok   { color: var(--green);  background: rgba(52,199,89,.08); }
.margin-chip.warn { color: var(--yellow); background: rgba(255,149,0,.10); }
.margin-chip.bad  { color: var(--red);    background: rgba(255,59,48,.08); }


/* ── Payment rates screen ─────────────────────────────────────── */
.screen-title { font-size: 20px; font-weight: 700; padding: 4px 0; }

/* ── Overlays / bottom sheets ──────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.bottom-sheet {
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 8px 0 32px;
  animation: slideUp .25s cubic-bezier(.32,.72,0,1);
}
@keyframes slideUp { from { transform: translateY(100%) } to { transform: translateY(0) } }

.bs-handle {
  width: 36px; height: 4px;
  background: var(--sep);
  border-radius: 2px;
  margin: 6px auto 12px;
}
.bs-title { font-size: 17px; font-weight: 700; padding: 0 16px 12px; }

/* Country list */
.country-list { display: flex; flex-direction: column; }
.country-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--sep);
  transition: background .1s;
}
.country-item:last-child { border-bottom: none; }
.country-item:active { background: var(--bg2); }
.country-item.active { background: rgba(0,122,255,.05); }
.ci-flag { font-size: 24px; }
.ci-name { flex: 1; font-size: 16px; font-weight: 500; color: var(--text); }
.ci-codes { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.ci-curr { font-size: 11px; font-weight: 600; color: var(--btn-text); background: var(--btn); border-radius: 4px; padding: 2px 5px; opacity: 0.75; }
.ci-curr-soon { color: var(--hint); background: var(--bg2); }
.ci-check { color: var(--btn); font-size: 18px; font-weight: 700; }

/* Detail sheet */
.detail-header { padding: 0 16px 16px; }
.dh-name { font-size: 20px; font-weight: 700; }
.dh-delivery { font-size: 13px; color: var(--hint); margin-top: 3px; }

.detail-rows { padding: 0 16px; }
.dr { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--sep); font-size: 15px; }
.dr:last-of-type { border-bottom: none; }
.dr-label { color: var(--hint); }
.dr-val { font-weight: 600; }
.dr-val.warn { color: var(--yellow); }
.dr-val.good { color: var(--green); }

.detail-steps { padding: 0 16px 16px; }
.ds-title { font-size: 13px; color: var(--hint); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; margin-bottom: 10px; }
.ds-step { display: flex; gap: 10px; margin-bottom: 10px; align-items: flex-start; }
.ds-num { width: 22px; height: 22px; background: var(--btn); color: var(--btn-text); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.ds-text { font-size: 14px; line-height: 1.45; }

.detail-cta { padding: 8px 16px 0; }
.detail-note { font-size: 12px; color: var(--hint); text-align: center; margin-top: 8px; }

/* ── Payment rates screen: стили унаследованы от .prow-* ──── */
