@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

/* ═══════════════════════════
   ПЕРЕМЕННЫЕ
═══════════════════════════ */
:root {
  --bg:       #070b12;
  --sur:      #0d1420;
  --sur2:     #111c2b;
  --sur3:     #162234;
  --bor:      #1a2840;
  --bor2:     #213250;
  --gold:     #f59e0b;
  --gold2:    #fbbf24;
  --gold-dim: rgba(245,158,11,.12);
  --green:    #10b981;
  --red:      #ef4444;
  --blue:     #3b82f6;
  --text:     #e2e8f0;
  --muted:    #4d6a87;
  --muted2:   #7a9ab8;
  --r:        10px;
  --r2:       16px;
  --r3:       22px;
}

/* ═══════════════════════════
   ОБЁРТКА ВИДЖЕТА
═══════════════════════════ */
.cex, .cex * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

.cex {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 300px;
}

/* ═══════════════════════════
   ЭКРАНЫ
═══════════════════════════ */
.cex-screen { width: 100%; }

/* ═══════════════════════════
   ЗАГРУЗКА
═══════════════════════════ */
.cex-loader-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 60px 20px;
}
.cex-logo-icon {
  font-size: 52px;
  filter: drop-shadow(0 0 20px rgba(245,158,11,.5));
  animation: cex-float 2.5s ease-in-out infinite;
}
@keyframes cex-float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }

.cex-spinner-lg {
  width: 36px; height: 36px;
  border: 3px solid var(--bor2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: cex-spin .8s linear infinite;
}
.cex-spinner-sm {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--bor2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: cex-spin .7s linear infinite;
}
@keyframes cex-spin { to { transform:rotate(360deg) } }

/* ═══════════════════════════
   АВТОРИЗАЦИЯ
═══════════════════════════ */
.cex-auth-wrap {
  background: var(--sur);
  border: 1px solid var(--bor);
  border-radius: var(--r3);
  padding: 24px 18px 28px;
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
}
@media(min-width:420px){
  .cex-auth-wrap { padding: 32px 32px 36px; }
}

.cex-brand { text-align: center; margin-bottom: 24px; }
.cex-brand-icon {
  font-size: 48px;
  filter: drop-shadow(0 0 18px rgba(245,158,11,.45));
  margin-bottom: 4px;
}
.cex-brand-name {
  font-size: 22px; font-weight: 800;
  background: linear-gradient(135deg,var(--gold),var(--gold2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.cex-brand-sub { font-size: 13px; color: var(--muted2); margin-top: 2px; }

/* Табы гостя */
.cex-auth-tabs {
  display: flex;
  background: var(--sur2);
  border-radius: var(--r);
  padding: 4px;
  margin-bottom: 22px;
  gap: 2px;
}
.cex-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 9px 6px;
  border-radius: 8px;
  color: var(--muted2);
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
}
.cex-tab.active {
  background: var(--sur3);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.cex-tab-op { color: var(--muted); font-size: 12px; }
.cex-tab-op.active { color: var(--gold); }

.cex-op-login-badge {
  background: var(--gold-dim);
  border: 1px solid rgba(245,158,11,.25);
  border-radius: var(--r);
  padding: 9px 14px;
  font-size: 14px;
  color: var(--gold2);
  margin-bottom: 16px;
  text-align: center;
}

/* ═══════════════════════════
   ПОЛЯ
═══════════════════════════ */
.cex-field { margin-bottom: 14px; }
.cex-field label {
  display: block;
  font-size: 11px; font-weight: 600;
  color: var(--muted2);
  text-transform: uppercase; letter-spacing: .8px;
  margin-bottom: 6px;
}
.cex-field-hint-inline { color: var(--muted); font-size: 11px; text-transform: none; font-weight: 400; }
.cex-field-note { font-size: 12px; color: var(--muted2); margin: 5px 0 0; line-height: 1.4; }

.cex-field input {
  width: 100%;
  background: var(--sur2);
  border: 1.5px solid var(--bor2);
  border-radius: var(--r);
  padding: 13px 14px;
  color: var(--text);
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  -webkit-appearance: none;
}
.cex-field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245,158,11,.1);
}
.cex-field input::placeholder { color: var(--muted); }

/* Капча */
.cex-captcha-img-wrap { position: relative; margin-bottom: 8px; }
.cex-captcha-img-wrap img {
  width: 100%; max-height: 160px;
  object-fit: cover;
  border-radius: var(--r);
  border: 1px solid var(--bor2);
  display: block;
}
.cex-captcha-reload {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.65);
  border: none; color: #fff;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer; font-size: 16px; line-height: 1;
}

/* ═══════════════════════════
   КНОПКИ
═══════════════════════════ */
.cex-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 14px 20px;
  background: linear-gradient(135deg,#f59e0b,#d97706);
  color: #08111e;
  font-family: 'Syne', sans-serif;
  font-size: 15px; font-weight: 700;
  border: none; border-radius: var(--r);
  cursor: pointer;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  -webkit-appearance: none;
  margin-top: 6px;
}
.cex-btn:hover:not(:disabled) {
  opacity: .9; transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(245,158,11,.35);
}
.cex-btn:active:not(:disabled) { transform: translateY(0); }
.cex-btn:disabled { opacity: .35; cursor: not-allowed; }

.cex-btn-green { background: linear-gradient(135deg,#10b981,#059669); color: #fff; }
.cex-btn-green:hover:not(:disabled) { box-shadow: 0 6px 22px rgba(16,185,129,.3); }

.cex-btn-op { background: linear-gradient(135deg,#3b82f6,#2563eb); color: #fff; }
.cex-btn-op:hover:not(:disabled) { box-shadow: 0 6px 22px rgba(59,130,246,.3); }

.cex-logout-btn {
  background: transparent;
  border: 1.5px solid var(--bor2);
  border-radius: var(--r);
  color: var(--muted2);
  font-family: 'Syne', sans-serif;
  font-size: 13px; font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}
.cex-logout-btn:hover { border-color: var(--red); color: #f87171; }

.cex-back {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none;
  color: var(--muted2); font-family: 'Syne', sans-serif;
  font-size: 13px; cursor: pointer; padding: 0;
  margin-bottom: 16px;
  transition: color .15s;
}
.cex-back:hover { color: var(--text); }

/* ═══════════════════════════
   СООБЩЕНИЯ
═══════════════════════════ */
.cex-msg {
  padding: 10px 14px; border-radius: var(--r);
  margin-bottom: 12px; font-size: 14px; font-weight: 500;
  display: none;
}
.cex-msg-ok  { background:rgba(16,185,129,.1);  border:1px solid rgba(16,185,129,.3); color:#34d399; }
.cex-msg-err { background:rgba(239,68,68,.1);   border:1px solid rgba(239,68,68,.3);  color:#f87171; }

/* ═══════════════════════════
   КАБИНЕТ КЛИЕНТА
═══════════════════════════ */
.cex-cab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--sur);
  border: 1px solid var(--bor);
  border-radius: var(--r2);
  padding: 14px 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.cex-cab-user { display: flex; align-items: center; gap: 10px; }
.cex-cab-avatar { font-size: 28px; }
.cex-cab-login { font-size: 16px; font-weight: 700; }
.cex-cab-tg    { font-size: 12px; color: var(--muted2); }

/* Внутренние вкладки */
.cex-inner-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.cex-itab {
  flex: 1;
  background: var(--sur);
  border: 1.5px solid var(--bor);
  border-radius: var(--r);
  padding: 11px 8px;
  color: var(--muted2);
  font-family: 'Syne', sans-serif;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  -webkit-appearance: none;
}
.cex-itab.active {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-dim);
}

/* ── Шаги обмена ── */
.cex-step {
  background: var(--sur);
  border: 1px solid var(--bor);
  border-radius: var(--r2);
  padding: 18px 16px;
}
@media(min-width:420px){ .cex-step { padding: 22px 22px; } }

.cex-step-title {
  font-size: 17px; font-weight: 700;
  margin: 0 0 16px;
}

/* Статус WS */
.cex-status-bar {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 14px;
  font-size: 12px; color: var(--muted2);
}
.cex-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); flex-shrink: 0;
}
.cex-dot.on {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: cex-pulse 2s infinite;
}
@keyframes cex-pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* Монеты */
.cex-coin-btns { display: grid; grid-template-columns:1fr 1fr; gap: 8px; margin-bottom: 14px; }
.cex-coin {
  background: var(--sur2);
  border: 2px solid var(--bor2);
  border-radius: var(--r);
  padding: 12px 8px;
  color: var(--text);
  font-family: 'Syne', sans-serif;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: all .18s;
  -webkit-appearance: none;
}
.cex-coin span { font-size: 18px; }
.cex-coin.active, .cex-coin:hover {
  border-color: var(--gold);
  background: var(--gold-dim);
  color: var(--gold);
}

/* Курс */
.cex-rate-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--sur2);
  border: 1px solid var(--bor);
  border-radius: var(--r);
  padding: 11px 14px;
  margin-bottom: 12px;
}
.cex-rate-label { font-size: 13px; color: var(--muted2); }
.cex-rate-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px; font-weight: 600;
  color: var(--gold);
}

/* Ввод суммы */
.cex-amount-input {
  width: 100%;
  background: var(--sur2);
  border: 2px solid var(--bor2);
  border-radius: var(--r);
  padding: 14px 16px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px; font-weight: 600;
  outline: none;
  transition: border-color .18s;
  -webkit-appearance: none;
}
.cex-amount-input:focus { border-color: var(--gold); }
.cex-amount-input::placeholder { font-size: 16px; font-weight: 400; color: var(--muted); }

/* Калькулятор */
.cex-calc {
  background: var(--sur2);
  border: 1px solid var(--bor);
  border-radius: var(--r);
  overflow: hidden;
  margin: 10px 0 14px;
}
.cex-calc-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 14px;
  font-size: 14px; color: var(--muted2);
  border-bottom: 1px solid var(--bor);
}
.cex-calc-row:last-child { border-bottom: none; }
.cex-calc-total {
  color: var(--text);
  font-size: 16px; font-weight: 700;
  padding: 12px 14px;
}
.cex-calc-total span:last-child {
  color: var(--green);
  font-family: 'JetBrains Mono', monospace;
}

/* Пилюля итога */
.cex-summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--sur2);
  border: 1px solid var(--bor);
  border-radius: 30px;
  padding: 8px 16px;
  font-size: 14px; font-weight: 600;
  margin-bottom: 18px;
  color: var(--gold2);
}

/* Банки */
.cex-banks { display: flex; flex-direction: column; gap: 8px; }
.cex-bank-btn {
  background: var(--sur2);
  border: 2px solid var(--bor2);
  border-radius: var(--r);
  padding: 14px 16px;
  color: var(--text);
  font-family: 'Syne', sans-serif;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  text-align: left; width: 100%;
  transition: all .18s;
  -webkit-appearance: none;
}
.cex-bank-btn:hover:not(:disabled) {
  border-color: var(--blue);
  background: rgba(59,130,246,.08);
  color: #93c5fd;
}
.cex-bank-btn:disabled { opacity: .5; cursor: not-allowed; }
.cex-bank-logo { width: 28px; height: 28px; object-fit: contain; border-radius: 5px; }

/* Карта оплаты */
.cex-pay-card {
  background: linear-gradient(135deg,#12213a 0%,#091727 100%);
  border: 1px solid var(--gold);
  border-radius: var(--r2);
  padding: 18px 16px;
  margin-bottom: 16px;
  box-shadow: 0 0 32px rgba(245,158,11,.1), inset 0 1px 0 rgba(245,158,11,.08);
}
.cex-pay-bank { font-size: 16px; font-weight: 700; color: var(--gold2); margin-bottom: 14px; }
.cex-pay-section-label {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .9px; color: var(--muted2);
  margin-bottom: 6px;
}
.cex-pay-card-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.cex-pay-cardnum {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(16px,5vw,24px);
  font-weight: 600;
  color: #fff;
  letter-spacing: 1px;
  flex: 1;
  word-break: break-all;
}
.cex-copy-btn {
  background: rgba(255,255,255,.1);
  border: none; border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer; font-size: 14px;
  transition: background .15s;
}
.cex-copy-btn:hover { background: rgba(255,255,255,.2); }
.cex-pay-holder { font-size: 13px; color: var(--muted2); margin-bottom: 0; min-height: 16px; }
.cex-pay-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(24px,7vw,32px);
  font-weight: 700;
  color: var(--green);
}

/* Таймер */
.cex-timer-block { text-align: center; margin-bottom: 16px; }
.cex-timer-lbl { font-size: 12px; color: var(--muted2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
.cex-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(30px,9vw,42px);
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.cex-progress {
  height: 4px; background: var(--sur2);
  border-radius: 2px; overflow: hidden;
  max-width: 260px; margin: 0 auto;
}
.cex-progress-inner {
  height: 100%; width: 100%;
  background: linear-gradient(90deg,var(--green),var(--gold));
  border-radius: 2px;
  transition: width 1s linear;
}

.cex-warn {
  background: rgba(245,158,11,.07);
  border: 1px solid rgba(245,158,11,.22);
  border-radius: var(--r);
  padding: 10px 13px;
  font-size: 13px; color: #fcd34d;
  margin-bottom: 14px; line-height: 1.5;
}

/* Ожидание / результат */
.cex-result-icon { font-size: 54px; text-align: center; margin: 16px 0 12px; }
.cex-result-title { font-size: 20px; font-weight: 800; text-align: center; margin: 0 0 10px; }
.cex-result-text { text-align: center; color: var(--muted2); font-size: 14px; line-height: 1.6; }
.cex-checking {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted2); font-size: 14px;
  background: var(--sur2); border-radius: var(--r);
  padding: 12px 16px; margin-top: 18px;
}

/* ── История заявок ── */
.cex-hist-empty {
  text-align: center; padding: 36px 20px;
  color: var(--muted2); font-size: 14px;
  background: var(--sur);
  border: 1px solid var(--bor);
  border-radius: var(--r2);
}
.cex-hist-item {
  background: var(--sur);
  border: 1px solid var(--bor);
  border-radius: var(--r2);
  margin-bottom: 10px;
  overflow: hidden;
}
.cex-hist-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--bor);
  background: var(--sur2);
}
.cex-hist-id { font-size: 14px; font-weight: 700; }
.cex-hist-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  padding: 12px 14px;
}
@media(max-width:360px){ .cex-hist-body { grid-template-columns: 1fr; } }
.cex-hist-cell { display: flex; flex-direction: column; gap: 2px; }
.cex-hist-cell span { font-size: 11px; color: var(--muted2); text-transform: uppercase; letter-spacing: .4px; }
.cex-hist-cell b { font-size: 14px; font-weight: 600; }
.cex-hist-note {
  padding: 8px 14px;
  font-size: 13px;
  border-top: 1px solid var(--bor);
}
.cex-note-ok  { background:rgba(16,185,129,.09); color:#34d399; }
.cex-note-err { background:rgba(239,68,68,.09);  color:#f87171; }

/* Статус-бейджи */
.cex-badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap;
}
.badge-waiting  { background:rgba(245,158,11,.15); color:var(--gold);  }
.badge-paid     { background:rgba(59,130,246,.15);  color:#93c5fd; }
.badge-confirmed{ background:rgba(16,185,129,.15);  color:#34d399; }
.badge-cancelled,
.badge-expired  { background:rgba(239,68,68,.15);   color:#f87171; }

/* ═══════════════════════════
   ОПЕРАТОР
═══════════════════════════ */
.cex-op-header {
  background: var(--sur);
  border: 1px solid var(--bor);
  border-radius: var(--r2);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.cex-op-title { display: flex; align-items: center; gap: 10px; }
.cex-op-icon  { font-size: 26px; }
.cex-op-name  { font-size: 16px; font-weight: 700; }
.cex-op-role  { font-size: 12px; color: var(--muted2); }
.cex-op-meta  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cex-op-badge {
  background: var(--gold-dim);
  border: 1px solid rgba(245,158,11,.25);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px; font-weight: 700;
  color: var(--gold2);
}
.cex-op-live { font-size: 12px; font-weight: 600; color: var(--green); }

.cex-op-empty {
  background: var(--sur);
  border: 1px solid var(--bor);
  border-radius: var(--r2);
  text-align: center;
  padding: 48px 20px;
  color: var(--muted2);
}
.cex-op-empty-icon { font-size: 44px; margin-bottom: 10px; }

.cex-op-card {
  background: var(--sur);
  border: 1px solid var(--bor);
  border-left: 4px solid var(--gold);
  border-radius: var(--r2);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0,0,0,.3);
}
.cex-op-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--bor);
  background: var(--sur2);
}
.cex-op-card-id   { font-size: 15px; font-weight: 700; }
.cex-op-card-time { font-size: 12px; color: var(--muted2); }

.cex-op-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  padding: 14px 16px;
}
@media(max-width:440px){ .cex-op-card-body { grid-template-columns: 1fr; } }

.cex-op-row { display: flex; flex-direction: column; gap: 3px; padding: 3px 0; }
.cex-op-row > span:first-child {
  font-size: 11px; color: var(--muted2);
  text-transform: uppercase; letter-spacing: .4px;
}
.cex-op-row > span:last-child, .cex-op-row > b { font-size: 14px; font-weight: 500; }
.cex-op-amount { color: var(--green); font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 700; }
.cex-op-mono   { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--gold); word-break: break-all; }
.cex-op-wallet { font-size: 11px !important; color: var(--muted2) !important; word-break: break-all; }

.cex-op-card-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--bor);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cex-op-note-input {
  width: 100%;
  background: var(--sur2);
  border: 1.5px solid var(--bor2);
  border-radius: var(--r);
  padding: 10px 12px;
  color: var(--text);
  font-family: 'Syne', sans-serif;
  font-size: 14px; outline: none;
  box-sizing: border-box;
  transition: border-color .18s;
}
.cex-op-note-input::placeholder { color: var(--muted); }
.cex-op-note-input:focus { border-color: var(--gold); }

.cex-op-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media(max-width:360px){ .cex-op-actions { grid-template-columns: 1fr; } }
.cex-op-actions .cex-btn { margin-top: 0; padding: 12px 10px; font-size: 14px; }

/* ═══════════════════════════
   ЗАГРУЗКА КОНТЕНТА
═══════════════════════════ */
.cex-loading {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 28px 20px;
  color: var(--muted2); font-size: 14px;
}
.cex-err-box {
  text-align: center; padding: 20px;
  color: #f87171; font-size: 14px;
  background: rgba(239,68,68,.07);
  border-radius: var(--r);
  border: 1px solid rgba(239,68,68,.2);
}
