:root {
  --bg: #0e0e10;
  --bg-2: #17171b;
  --bg-3: #1f1f25;
  --border: #2a2a33;
  --text: #ececec;
  --muted: #8b8b94;
  --accent: #ffb33a;
  --accent-2: #4aa3ff;
  --danger: #ff5b6e;
  --success: #4ad28e;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
/* Тянем body на полный Telegram-viewport, чтобы не было «висячего» контента
   и юзеру не нужно было растягивать окно вручную. */
body {
  min-height: var(--tg-svh, 100dvh);
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.topbar-left { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: none; border: none; color: var(--text); padding: 6px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font-family: inherit; font-size: 15px; }
.icon-btn:active { background: var(--bg-3); }
.icon-btn.star { color: var(--accent); }

.container { padding: 12px 14px; max-width: 720px; margin: 0 auto; }
.step { margin-bottom: 20px; }
.step:last-child { margin-bottom: 8px; }
.step h2 { font-size: 18px; margin: 0 0 10px; font-weight: 700; letter-spacing: -0.1px; }

.search-wrap { position: relative; background: var(--bg-3); border-radius: 14px; padding: 14px 44px 14px 16px; }
.search-wrap.grow { flex: 1; }
.search-wrap input { background: none; border: none; outline: none; color: var(--text); font-size: 16px; width: 100%; font-family: inherit; }
.search-wrap svg { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.row { display: flex; gap: 8px; margin-bottom: 12px; }
.sort-btn { background: var(--bg-3); border: none; color: var(--text); padding: 0 18px; border-radius: 14px; font-size: 15px; cursor: pointer; min-width: 92px; font-family: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.sort-arrow { display: inline-flex; align-items: center; color: var(--muted); }
.sort-arrow-svg { display: block; }
#topStatsBtn { min-width: 52px; padding: 0; font-size: 18px; }

.card-list { background: var(--bg-2); border: 1px solid var(--border); border-radius: 16px; margin-top: 12px; overflow: hidden; }
.card-list .item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .18s ease, transform .12s ease; }
.card-list .item:last-child { border-bottom: none; }
.card-list .item:hover { background: rgba(255,255,255,.02); }
.card-list .item:active { background: var(--bg-3); transform: scale(.99); }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.card-list.changing { animation: fadeInUp .22s ease both; }
.svc-ico-wrap, .svc-letter, .card-list .item .flag {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
  overflow: hidden;
}
.svc-ico-wrap { position: relative; padding: 0; }
.svc-letter-bg { position: absolute; inset: 0; display: inline-flex; align-items: center; justify-content: center; }
.svc-ico-wrap.has-img .svc-letter-bg { display: none; }
.svc-logo { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 50%; object-fit: contain; background: #fff; padding: 4px; box-sizing: border-box; opacity: 0; transition: opacity .15s; }
.svc-ico-wrap.has-img .svc-logo { opacity: 1; }
.svc-any { font-size: 22px; font-weight: 800; }
.card-list .item .flag { background: transparent; padding: 2px; }
.flag-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.flag-fallback { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.card-list .item .name { flex: 1; font-size: 16px; }
.card-list .item .right { text-align: right; }
.card-list .item .right .price { font-weight: 700; font-size: 15px; }
.card-list .item .right .count { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-list .empty-line { padding: 18px; text-align: center; color: var(--muted); }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 14px 4px; font-weight: 700; }
.pager .link { background: none; border: none; color: var(--muted); font-weight: 700; cursor: pointer; font-size: 15px; font-family: inherit; }
.pager .link:disabled { opacity: .35; cursor: default; }

.selected { display: flex; align-items: center; gap: 12px; background: var(--bg-3); border-radius: 14px; padding: 14px 16px; margin-top: 12px; position: relative; }
.selected .x { background: none; border: none; color: var(--muted); font-size: 22px; padding: 4px 8px; cursor: pointer; }
.selected #selSvcIco { display: inline-flex; }
.selected .name { flex: 1; font-weight: 600; }
.selected .badge { position: absolute; right: 12px; top: -10px; background: #b9c4d3; color: #1f2733; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }

.empty { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--bg-3); border-radius: 14px; padding: 20px; color: var(--muted); margin-top: 12px; }

.price-hint { color: var(--muted); opacity: .65; font-size: 12px; line-height: 1.45; margin: 2px 2px 12px; padding: 0; letter-spacing: .1px; }
.top-stats-cta { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 60px; margin: 8px 0 14px; padding: 22px 20px; border: none; border-radius: 16px; background: linear-gradient(135deg, #4ad28e 0%, #2eb574 100%); color: #0d1f15; font-family: inherit; font-size: 16px; font-weight: 700; line-height: 1; cursor: pointer; transition: transform .08s, box-shadow .15s, filter .15s; letter-spacing: .2px; box-shadow: 0 8px 22px -10px rgba(74,210,142,.55), inset 0 1px 0 rgba(255,255,255,.2); animation: topStatsBreathe 2.6s ease-in-out infinite; }
@keyframes topStatsBreathe {
  0%, 100% { box-shadow: 0 8px 22px -10px rgba(74,210,142,.55), inset 0 1px 0 rgba(255,255,255,.2), 0 0 0 0 rgba(74,210,142,0); filter: brightness(1); }
  50% { box-shadow: 0 8px 24px -8px rgba(74,210,142,.7), inset 0 1px 0 rgba(255,255,255,.25), 0 0 0 8px rgba(74,210,142,.14); filter: brightness(1.04); }
}
.top-stats-cta:hover { animation-play-state: paused; }
.top-stats-cta:active { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { .top-stats-cta { animation: none; } }
.top-stats-cta:hover { filter: brightness(1.05); }
.top-stats-cta:active { transform: scale(0.985); box-shadow: 0 4px 12px -8px rgba(74,210,142,.5), inset 0 1px 0 rgba(255,255,255,.15); }
.top-stats-cta-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; background: rgba(13,31,21,.18); flex-shrink: 0; }
.top-stats-cta-icon svg { width: 18px; height: 18px; }
.top-stats-cta-label { flex: 0 1 auto; }
.top-stats-cta-arrow { display: none; }

.hidden { display: none !important; }

.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 84%; max-width: 360px; background: var(--bg); border-right: 1px solid var(--border); transform: translateX(-100%); transition: transform .22s ease; z-index: 50; padding-top: 64px; }
.drawer.open { transform: translateX(0); box-shadow: 0 0 50px rgba(0,0,0,.5); }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer-inner { padding: 24px; height: 100%; display: flex; flex-direction: column; box-sizing: border-box; }
.drawer-tg { margin-top: auto; align-self: center; display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; background: var(--bg-3); color: #2aabee; text-decoration: none; transition: transform .15s, background .15s; }
.drawer-tg:active { transform: scale(.94); background: var(--bg-2); }
.drawer-inner h3 { font-size: 22px; text-align: center; margin: 0 0 18px; }
.drawer-card { background: var(--bg-3); border-radius: 14px; padding: 4px 0; }
.row-line { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.row-line:last-child { border-bottom: none; }
.ico-wrap { color: var(--muted); display: flex; }
.row-name { flex: 1; font-weight: 600; }
.row-val { color: var(--text); font-weight: 600; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 100; opacity: 1; transition: opacity .22s ease, backdrop-filter .22s ease; backdrop-filter: blur(2px); }
.modal.hidden { opacity: 0; pointer-events: none; display: flex !important; }
.modal-inner {
  background: var(--bg-2);
  width: 100%;
  max-width: 520px;
  max-height: calc(var(--tg-svh, 100dvh) - 32px);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  transform: translateY(0);
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
#orderModal .modal-inner {
  height: var(--tg-svh, 100dvh);
  max-height: var(--tg-svh, 100dvh);
  max-width: 100%;
  border-radius: 0;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Fullscreen purchase modal polish */
#orderModal .modal-head { padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 0; }
#orderModal .modal-head h3 { font-size: 22px; font-weight: 800; letter-spacing: -0.2px; margin: 0; }
#orderModal #modalSub { display: none; }
#orderModal #modalSub b { color: var(--text); font-weight: 700; }

#orderModal .buy-info { margin: 4px 0 0; gap: 14px; }
#orderModal .buy-info-stats {
  /* Flex чтобы при скрытом боксе остальные равномерно занимали ширину. */
  display: flex;
  gap: 6px;
  align-items: stretch;
}
#orderModal .buy-info-stat {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 12px 11px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 4px;
}
/* Страна — чуть шире остальных под флаг + название. */
#orderModal .buy-info-stat:first-child { flex: 1.3 1 0; }
#orderModal .buy-info-stat-label {
  font-size: 10px;
  letter-spacing: 0.4px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
  /* Длинные лейблы вроде «СРОК ДЕЙСТВИЯ» переносим на 2 строки, не клипуем. */
  white-space: normal;
  line-height: 1.15;
}
#orderModal .buy-info-stat-val {
  font-size: 13px;
  letter-spacing: 0;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  word-break: break-word;
}
/* Страна — флаг и название одной строкой, без переноса между ними. */
#orderModal #buyInfoCountry { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#orderModal .buy-info-perks { gap: 8px; margin-top: 4px; }
#orderModal .buy-info-perks li { font-size: 13px; line-height: 1.5; }

#orderModal .num-block { background: linear-gradient(180deg, var(--bg-3) 0%, rgba(31,31,37,.6) 100%); border: 1px solid var(--border); padding: 28px 16px 22px; border-radius: 18px; box-shadow: 0 10px 28px -14px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.03); }
#orderModal .num { font-size: 26px; font-weight: 800; letter-spacing: .3px; font-variant-numeric: tabular-nums; word-break: break-all; line-height: 1.15; }
#orderModal .copy { background: var(--bg); border: 1px solid var(--border); padding: 9px 20px; border-radius: 999px; font-weight: 600; font-size: 13px; margin-top: 14px; transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .12s ease; }
#orderModal .copy:active { transform: scale(.97); border-color: var(--accent); color: var(--accent); }
#orderModal .status { padding-top: 16px; font-size: 13.5px; }
#orderModal .status .expires-line { font-size: 14px; font-weight: 600; margin-top: 6px; color: var(--text); }
#orderModal .status .expires-line.expires-out { color: var(--danger); }

#orderModal .sms-row { border: 1px solid rgba(74,210,142,.22); background: linear-gradient(180deg, rgba(74,210,142,.08) 0%, rgba(74,210,142,.02) 100%); padding: 16px 50px; border-radius: 14px; margin-top: 14px; box-shadow: 0 6px 18px -10px rgba(74,210,142,.3); }
#orderModal .sms-row.is-previous { background: rgba(139,139,148,.06); border-color: rgba(139,139,148,.2); box-shadow: none; padding-top: 26px; }
#orderModal .sms-row .sms { font-size: 22px; letter-spacing: 1.2px; background: none; padding: 0; }

#orderModal .actions { margin-top: auto; padding-top: 14px; gap: 10px; }
#orderModal .actions .btn { padding: 26px 16px; font-size: 17px; font-weight: 800; letter-spacing: 0.2px; border-radius: 18px; }
#orderModal .actions .btn.primary {
  background: linear-gradient(180deg, var(--accent) 0%, #f0a325 100%);
  color: #1a1208;
  position: relative;
  animation: buyBtnGlow 2.4s ease-in-out infinite alternate;
}
#orderModal .actions .btn.primary:active { transform: scale(0.985); animation-play-state: paused; }
@keyframes buyBtnGlow {
  0% {
    box-shadow:
      0 10px 26px -10px rgba(255, 179, 58, 0.45),
      0 0 0 0 rgba(255, 179, 58, 0),
      inset 0 1px 0 rgba(255, 255, 255, 0.35);
    filter: brightness(1);
  }
  100% {
    box-shadow:
      0 18px 42px -8px rgba(255, 179, 58, 0.75),
      0 0 0 6px rgba(255, 179, 58, 0.18),
      inset 0 1px 0 rgba(255, 255, 255, 0.45);
    filter: brightness(1.05);
  }
}
@media (prefers-reduced-motion: reduce) {
  #orderModal .actions .btn.primary { animation: none; }
}
#orderModal .actions .btn.ghost { background: var(--bg-3); border: 1px solid var(--border); }
#orderModal .actions .btn.ghost:active:not(:disabled) { background: var(--bg); }
.modal.hidden .modal-inner { transform: translateY(100%); }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal .muted { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.num-block { background: var(--bg-3); border-radius: 14px; padding: 16px; text-align: center; margin-bottom: 14px; }
.num { font-size: 24px; font-weight: 700; letter-spacing: 0.5px; }
.copy { margin-top: 8px; background: none; border: 1px solid var(--border); color: var(--text); padding: 6px 14px; border-radius: 10px; font-size: 13px; cursor: pointer; }
.status { margin-top: 10px; color: var(--muted); font-size: 14px; transition: color .2s; }
.status .elapsed { color: var(--accent); font-variant-numeric: tabular-nums; transition: color .2s; }
.status .expires-line { margin-top: 4px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.status .expires-line.expires-out { color: var(--danger); }
.status .dots::after {
  content: '…';
  display: inline-block;
  animation: dotsPulse 1.4s infinite ease-in-out;
}
@keyframes dotsPulse {
  0%, 100% { opacity: 0.35; letter-spacing: 0; }
  50% { opacity: 1; letter-spacing: 1px; }
}
.sms-row { position: relative; margin-top: 10px; background: var(--bg); padding: 10px 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; transition: opacity .28s ease, padding .28s cubic-bezier(.2,.8,.2,1), background-color .22s ease; }
.sms-row .sms { transition: color .22s ease; }
.sms-row.is-previous { opacity: .55; padding-top: 22px; }
.sms-row.is-previous::before { content: attr(data-label); position: absolute; top: 4px; left: 12px; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .3px; text-transform: uppercase; }
.sms-row.is-previous .sms { color: var(--muted); }
.sms-row .sms { flex: 0 1 auto; padding: 0; background: none; margin: 0; text-align: center; }
.sms-row .copy-icon { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.sms { background: var(--bg); padding: 10px; border-radius: 10px; font-size: 18px; font-weight: 700; color: var(--success); letter-spacing: 1px; text-align: center; }
.actions { display: flex; flex-direction: column; gap: 8px; }
.btn { padding: 14px 16px; border-radius: 12px; border: none; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; transition: transform .12s ease, background-color .22s ease, opacity .22s ease, filter .22s ease, color .22s ease; will-change: transform; }
.btn.primary { background: var(--accent); color: #1a1a1a; }
.btn.ghost { background: var(--bg-3); color: var(--text); }
.btn:active:not(:disabled) { transform: scale(.985); filter: brightness(.95); }
.btn:disabled { opacity: .55; cursor: default; transform: none; filter: none; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--bg-3); color: var(--text); padding: 12px 18px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.4); z-index: 200; font-size: 14px; }

/* Clickable drawer row */
.row-line.clickable { cursor: pointer; transition: background .12s; }
.row-line.clickable:active { background: var(--bg); }

/* Language toggle */
.lang-toggle { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; }
.lang-btn { background: none; border: none; color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 700; font-size: 13px; cursor: pointer; font-family: inherit; }
.lang-btn.active { background: var(--accent); color: #1a1a1a; }

/* Modal head (shared) */
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 18px; flex: 1; }
.x-btn { background: none; border: none; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; padding: 4px 10px; border-radius: 8px; }
.x-btn:active { background: var(--bg-3); }

/* Activations modal */
.activations-modal { max-height: 88vh; overflow-y: auto; }
.activations-list { display: flex; flex-direction: column; gap: 12px; }
.act-card { background: var(--bg-3); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.act-head { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.act-main { display: flex; align-items: center; gap: 12px; }
.act-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.act-svc { font-size: 16px; font-weight: 700; color: var(--text); }
.act-country { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.act-country .flag { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.act-country .flag .flag-img { width: 20px; height: 20px; }
.act-actions { display: flex; gap: 8px; margin-top: 2px; }
.act-actions .btn { flex: 1; padding: 10px 8px; font-size: 13px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }

#detService, #detCountry { display: inline-flex; align-items: center; gap: 8px; }
#detService .svc-ico-wrap, #detService .svc-letter { width: 22px; height: 22px; font-size: 11px; }
#detService .svc-logo { width: 22px; height: 22px; }
#detCountry .flag { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
#detCountry .flag .flag-img { width: 20px; height: 20px; }

.badge-btn { padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; border: none; cursor: pointer; font-family: inherit; }
.badge-btn.status-ok { background: rgba(74,210,142,.15); color: var(--success); cursor: default; }
.badge-btn.status-cancel { background: rgba(255,91,110,.15); color: var(--danger); cursor: default; }
.badge-btn.status-wait { background: rgba(255,179,58,.18); color: var(--accent); cursor: default; }

/* Details modal */
.det-rows { background: var(--bg-3); border-radius: 14px; padding: 4px 16px; margin-bottom: 14px; }
.det-row { display: flex; align-items: center; gap: 6px; padding: 12px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.det-row:last-child { border-bottom: none; }
.det-row > span:first-child { color: var(--muted); }
.det-row > span:last-child { font-weight: 600; color: var(--text); text-align: right; }
.dots-fill { flex: 1; min-width: 12px; }

.det-section { margin-bottom: 14px; }
.det-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.copy-row { display: flex; align-items: center; gap: 10px; background: var(--bg-3); border-radius: 12px; padding: 12px 14px; }
.copy-row > span { flex: 1; font-weight: 700; font-size: 16px; letter-spacing: .3px; word-break: break-all; }
.copy-row .sms-meta { flex: 0 0 auto; font-weight: 500; font-size: 12px; color: var(--muted); letter-spacing: 0; white-space: nowrap; }
#detSmsList { display: flex; flex-direction: column; gap: 8px; }
.copy-icon { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.copy-icon:active { background: var(--bg-2); color: var(--accent); }

.det-status-banner { padding: 12px 14px; border-radius: 12px; text-align: center; font-weight: 700; font-size: 15px; }
.det-status-banner.status-ok { background: rgba(74,210,142,.15); color: var(--success); }
.det-status-banner.status-cancel { background: rgba(255,91,110,.15); color: var(--danger); }
.det-status-banner.status-wait { background: rgba(255,179,58,.18); color: var(--accent); }

.top-stats-modal { max-height: 88vh; overflow-y: auto; }
.top-stats-hint { color: var(--muted); opacity: .75; font-size: 12px; line-height: 1.45; margin: 0 2px 14px; }
.top-stats-list { display: flex; flex-direction: column; background: var(--bg-3); border-radius: 14px; overflow: hidden; }
.top-stats-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.top-stats-row:last-child { border-bottom: none; }
.top-stats-row:active { background: var(--bg-2); }
.top-stats-row .rank { width: 22px; text-align: center; color: var(--muted); font-weight: 700; font-size: 13px; flex-shrink: 0; }
.top-stats-row .flag { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.top-stats-row .flag .flag-img { width: 24px; height: 24px; }
.top-stats-row .name { flex: 1; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-stats-row .pct-block { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.top-stats-row .pct { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--success); flex-shrink: 0; line-height: 1.1; }
.top-stats-row .pct.mid { color: var(--accent); }
.top-stats-row .pct.low { color: var(--danger); }
.top-stats-row .price-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1; opacity: .85; }
.top-stats-row.disabled { cursor: default; opacity: .55; }
.top-stats-row.disabled:active { background: transparent; }

#insufficientModal .insufficient-modal-inner { background: var(--bg-2); width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 28px 22px; text-align: center; position: relative; }
#insufficientModal .insufficient-x { position: absolute; top: 10px; right: 12px; }
#insufficientModal .insufficient-icon { font-size: 44px; margin-bottom: 8px; }
#insufficientModal h3 { margin: 0 0 6px; font-size: 20px; }
#insufficientModal .muted { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
#insufficientModal .insufficient-detail { background: var(--bg-3); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--text); margin-bottom: 16px; }
#insufficientModal .actions { display: flex; flex-direction: column; gap: 8px; }

/* Pre-purchase info block (dial code, validity, perks) */
.buy-info { margin: 4px 0 16px; display: flex; flex-direction: column; gap: 10px; }
.buy-info-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.buy-info-stat { background: var(--bg-3); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.buy-info-stat-label { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; }
.buy-info-stat-val { font-size: 17px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.buy-info-perks { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.buy-info-perks li { position: relative; padding-left: 20px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.buy-info-perks li::before { content: ''; position: absolute; left: 4px; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--success); opacity: .75; }
.op-select { position: relative; background: var(--bg-3); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.op-select-label { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; }
.op-select-trigger { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; transition: border-color .18s ease, background-color .18s ease; }
.op-select-trigger:active { transform: scale(.99); }
.op-select-trigger.is-open { border-color: var(--accent); }
.op-select-trigger[disabled] { opacity: .7; cursor: default; }
.op-select-trigger.is-loading .op-select-chevron { opacity: 0; }
.op-select-trigger.is-empty { color: var(--muted); font-weight: 500; font-size: 13px; }
.op-select-trigger.is-empty .op-select-chevron { display: none; }
.op-select-current { flex: 1; text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-select-chevron { color: var(--muted); transition: transform .18s ease; flex-shrink: 0; }
.op-select-trigger.is-open .op-select-chevron { transform: rotate(180deg); }
.op-select-panel { position: absolute; left: 14px; right: 14px; top: calc(100% - 6px); background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; padding: 6px; max-height: min(55vh, 420px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; box-shadow: 0 18px 40px -10px rgba(0,0,0,.75); z-index: 30; }
.op-select-panel::-webkit-scrollbar { width: 6px; }
.op-select-panel::-webkit-scrollbar-track { background: transparent; }
.op-select-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.op-select-panel::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.op-select-option { width: 100%; background: none; border: none; color: var(--text); padding: 12px; border-radius: 10px; font-size: 14px; font-family: inherit; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; transition: background-color .15s ease; min-height: 44px; }
.op-select-option + .op-select-option { margin-top: 2px; }
.op-select-option:hover { background: var(--bg-3); }
.op-select-option:active { background: var(--bg); }
.op-select-option.is-active { background: var(--bg-3); color: var(--accent); }
.op-select-option .op-name { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.25; word-break: break-word; }
.op-select-option .op-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; flex-shrink: 0; white-space: nowrap; background: var(--bg); padding: 3px 8px; border-radius: 999px; }

/* App loader overlay (shown until services are loaded) */
.app-loader { position: fixed; inset: 0; background: var(--bg); z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 1; transition: opacity .35s ease, visibility 0s linear 0s; visibility: visible; }
.app-loader.fade-out { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .35s ease, visibility 0s linear .35s; }
.app-loader-spinner { width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255,255,255,.12); border-top-color: var(--accent); animation: appLoaderSpin .9s linear infinite; }
@keyframes appLoaderSpin { to { transform: rotate(360deg); } }

.mini-loader-wrap { display: flex; align-items: center; justify-content: center; padding: 28px 16px; }
.mini-loader { width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.1); border-top-color: var(--accent); animation: appLoaderSpin .9s linear infinite; }
.mini-loader-inline { display: inline-block; width: 16px; height: 16px; border-width: 2px; vertical-align: -3px; }

/* ── Smoothness pass ── */
.icon-btn, .x-btn, .copy, .copy-icon, .sort-btn, .lang-btn, .pager .link, .badge-btn, .drawer-tg, .row-line.clickable, .card-list .item, .top-stats-row {
  transition: background-color .18s ease, color .18s ease, transform .12s ease, opacity .18s ease;
}
.icon-btn:active, .x-btn:active, .copy:active, .copy-icon:active, .sort-btn:active, .lang-btn:active:not(.active), .pager .link:active:not(:disabled), .badge-btn:active:not([class*="status-"]) {
  transform: scale(.96);
}
.copy { transition: background-color .18s ease, border-color .18s ease, transform .12s ease, color .18s ease; }
.copy:active { border-color: var(--accent); color: var(--accent); }

.sms { transition: color .22s ease, background-color .22s ease; }
.num { transition: color .22s ease; }

.modal-inner, .drawer { will-change: transform; backface-visibility: hidden; }
.modal { will-change: opacity; }
.drawer-backdrop { transition: opacity .22s ease; }

/* Toast fade (overrides global .hidden display:none via higher specificity) */
#toast.toast { transition: opacity .24s ease, transform .24s cubic-bezier(.2,.8,.2,1), visibility 0s linear 0s; opacity: 1; transform: translateX(-50%) translateY(0); visibility: visible; }
#toast.toast.hidden { display: flex !important; opacity: 0; transform: translateX(-50%) translateY(10px); visibility: hidden; pointer-events: none; transition: opacity .24s ease, transform .24s cubic-bezier(.2,.8,.2,1), visibility 0s linear .24s; }

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* === eSIM-specific additions === */
.card-list .card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background .18s ease, transform .12s ease;
}
.card-list .card:hover { background: rgba(255,255,255,.02); }
.card-list .card:active { background: var(--bg-3); transform: scale(.99); }
.card-list .card.disabled { opacity: .45; cursor: not-allowed; }
.card-ico { flex: 0 0 32px; display: flex; align-items: center; justify-content: center; }
.card-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.card-title { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { font-size: 13px; color: var(--muted); }
.card-price { font-weight: 700; font-size: 15px; white-space: nowrap; margin-left: 8px; }

.kind-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background .18s ease;
}
.kind-card:hover { background: rgba(255,255,255,.02); }
.kind-ico {
  flex: 0 0 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--bg-3);
  color: var(--accent, #6c8cff);
}
.kind-text { display: flex; flex-direction: column; gap: 4px; }
.kind-title { font-size: 16px; font-weight: 700; }
.kind-sub { font-size: 13px; color: var(--muted); line-height: 1.4; }

.activation-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .18s ease;
}
.activation-row:last-child { border-bottom: none; }
.activation-row:hover { background: rgba(255,255,255,.02); }
.activation-row-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.activation-row-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.activation-row-head .badge {
  background: var(--bg-3);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* === eSIM QR styled card === */
.qr-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.qr-card {
  background: #ffffff;
  padding: 14px;
  border-radius: 18px;
  display: inline-flex;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45),
              0 0 0 1px rgba(255,179,58,0.18),
              inset 0 0 0 1px rgba(0,0,0,0.04);
}
.qr-card svg { display: block; border-radius: 8px; }
.qr-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  max-width: 240px;
  line-height: 1.4;
}

/* === Cards in buy modal: «Что важно знать» and «Что вы получите» ===
   Единый стиль карточек: subtle gradient bg, заметный заголовок с цветной точкой,
   опрятные буллеты с цветным маркером. */
/* Плоские «секции» вместо тяжёлых карточек: только маленький заголовок и
   список — без насыщенных фонов и сильных бордеров. */
.buy-warn,
.buy-get {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.buy-warn-title,
.buy-get-title {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}
.buy-warn-title { color: var(--accent); }
.buy-get-title { color: var(--accent-2); }
.buy-warn-text {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.45;
}

.buy-warn-list,
.buy-get-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.buy-warn-list li,
.buy-get-list li {
  position: relative;
  padding-left: 14px;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text);
}
.buy-warn-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  font-weight: 700;
}
.buy-get-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-2);
}

/* === Inline buy result === */
.order-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}
.order-result .result-status {
  font-size: 13px;
  color: var(--accent);
  text-align: center;
  font-weight: 600;
}
.order-result .det-section {
  margin: 0;
}

/* === Card list — каждая карточка самодостаточная, без обёртки.
   Все карточки имеют одинаковый базовый стиль; selected получает только
   оранжевый бордер + лёгкий фон-тинт. Без левых полосок, без переокраски
   текста, без двойных рамок — единый чистый вид. */
.card-list {
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
}
.card-list .card,
.kind-card {
  position: relative;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  width: 100%;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}
.card-list .card.selected,
.kind-card.selected {
  background: rgba(255, 179, 58, 0.08);
  border-color: rgba(255, 179, 58, 0.7);
}

/* Для kind при выборе оставляем «×» справа и резервируем под него padding,
   чтобы текст не наезжал. */
.kind-card.selected { padding-right: 48px; }
.kind-card.selected::after {
  content: '×';
  position: absolute;
  top: 50%;
  right: 18px;
  transform: translateY(-50%);
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  color: var(--muted);
  pointer-events: none;
}

/* Sticky topbar высотой ~56px — учитываем при scrollIntoView,
   чтобы заголовок шага не уезжал под него. */
.step { scroll-margin-top: 68px; }


/* === Smooth global animations === */
@keyframes esimFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Plавное появление шагов выбора и их содержимого */
.country-area:not(.hidden),
.plan-area:not(.hidden) {
  animation: esimFadeIn 0.32s cubic-bezier(.2,.8,.2,1) both;
}

/* Список тарифов и стран после загрузки */
#plansList .card,
#countriesList .card {
  animation: esimFadeIn 0.28s ease-out both;
}

/* Окно покупки — секции */
#orderModal .buy-info > * {
  animation: esimFadeIn 0.32s cubic-bezier(.2,.8,.2,1) both;
}
#orderModal .buy-info > *:nth-child(2) { animation-delay: 0.04s; }
#orderModal .buy-info > *:nth-child(3) { animation-delay: 0.08s; }
#orderModal .order-result {
  animation: esimFadeIn 0.36s cubic-bezier(.2,.8,.2,1) both;
}

/* Selected card — плавный переход обводки */
.card-list .card,
.kind-card {
  transition:
    border-color 0.22s ease,
    background-color 0.22s ease,
    box-shadow 0.22s ease,
    transform 0.12s ease;
}

/* Подсветка при тапе */
.card-list .card:active,
.kind-card:active { transform: scale(0.985); }

/* Modal backdrop с плавным fade */
.modal:not(.hidden) { animation: esimFadeIn 0.22s ease-out both; }

@media (prefers-reduced-motion: reduce) {
  .country-area:not(.hidden),
  .plan-area:not(.hidden),
  #plansList .card,
  #countriesList .card,
  #orderModal .buy-info > *,
  #orderModal .order-result,
  .modal:not(.hidden) {
    animation: none;
  }
}
