/* Telegram Night theme defaults — overridden by actual tg-theme vars at runtime */
:root {
  --bg:       var(--tg-theme-bg-color,           #1a2535);
  --bg2:      var(--tg-theme-secondary-bg-color, #151e2d);
  --card:     #1f2e40;
  --text:     var(--tg-theme-text-color,         #f5f5f5);
  --hint:     var(--tg-theme-hint-color,         #6c849d);
  --link:     var(--tg-theme-link-color,         #5da0e0);
  --btn:      var(--tg-theme-button-color,       #5288c1);
  --btn-text: var(--tg-theme-button-text-color,  #ffffff);
  --sep:      rgba(255, 255, 255, 0.06);
  --green:    #4dca7a;
  --red:      #e05252;
  --radius:   14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg2);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  font-size: 15px;
}

/* ---- Screens ---- */
.screen {
  display: none;
  padding: 16px 14px 100px;
  max-width: 480px;
  margin: 0 auto;
  animation: fadeIn .18s ease;
}
.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Header ---- */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header .logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #5288c1, #3a6ea8);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(82, 136, 193, 0.35);
}

/* ---- Section title ---- */
.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin: 20px 0 8px 2px;
}

/* ---- Generic card ---- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ---- Info banner ---- */
.info-banner {
  background: rgba(82, 136, 193, 0.14);
  border: 1px solid rgba(82, 136, 193, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 4px;
}
.info-banner b { color: #7db8ea; }

.orders-closed-banner {
  background: rgba(224, 82, 82, 0.12);
  border: 1px solid rgba(224, 82, 82, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  color: #e05252;
  line-height: 1.5;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.orders-closed-refresh {
  background: none;
  border: none;
  color: #e05252;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
  opacity: 0.7;
}
.orders-closed-refresh:hover { opacity: 1; }

/* ---- Action cards (home screen) ---- */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.action-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 12px 18px;
  text-align: center;
  cursor: pointer;
  transition: transform .13s, background .13s;
  border: 1px solid var(--sep);
  width: 100%;
  color: var(--text);
}
.action-card:active { transform: scale(.96); background: #253344; }
.action-card .icon { font-size: 34px; margin-bottom: 10px; }
.action-card .label { font-size: 14.5px; font-weight: 600; }
.action-card .sub { font-size: 12px; color: var(--hint); margin-top: 4px; }
.action-card--wide { grid-column: 1 / -1; padding: 14px 20px; display: flex; align-items: center; gap: 14px; text-align: left; }
.action-card--wide .icon { font-size: 28px; margin-bottom: 0; }
.action-card--wide .label { font-size: 14.5px; font-weight: 600; }
.action-card--wide .sub { font-size: 12px; color: var(--hint); margin-top: 2px; }

/* ---- Orders screen ---- */
.order-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--sep);
  border-left-width: 3px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.order-card--card   { border-left-color: var(--btn); }
.order-card--topup  { border-left-color: #4bb543; }
.order-card-header  { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.order-card-title   { font-size: 14px; font-weight: 700; color: var(--text); }
.order-card-num     { font-size: 12px; color: var(--hint); font-weight: 400; margin-left: 4px; }
.order-card-footer  { display: flex; justify-content: space-between; align-items: flex-end; }
.order-card-meta    { }
.order-card-date    { font-size: 12px; color: var(--hint); }
.order-card-pay     { font-size: 12px; color: var(--hint); margin-top: 3px; }
.order-card-amount  { font-size: 16px; font-weight: 700; color: var(--text); text-align: right; }
.order-status { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.order-status--new        { background: rgba(255,255,255,.08); color: var(--hint); }
.order-status--paid       { background: rgba(82,136,193,.2);   color: #7db8ea; }
.order-status--processing { background: rgba(232,160,0,.15);   color: #e8a000; }
.order-status--done       { background: rgba(75,181,67,.15);   color: #4bb543; }
.order-status--cancelled  { background: rgba(224,82,82,.15);   color: #e05252; }
.order-card-status-row  { display: flex; align-items: center; gap: 6px; }
.order-refresh-btn { background: none; border: none; color: var(--hint); font-size: 15px; cursor: pointer; padding: 0; line-height: 1; transition: transform .3s; }
.order-refresh-btn:hover { color: var(--text); }
.order-refresh-btn--spin { animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Field list ---- */
.field-list {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--sep);
}
.field {
  display: flex;
  flex-direction: column;
  padding: 11px 14px;
  border-bottom: 1px solid var(--sep);
}
.field:last-child { border-bottom: none; }
.field label {
  font-size: 11.5px;
  color: var(--hint);
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.field input, .field select {
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.field input::placeholder { color: rgba(108, 132, 157, 0.6); }

/* ---- Payment method toggle ---- */
.method-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.method-btn {
  border: 1.5px solid var(--sep);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  background: var(--card);
  color: var(--hint);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: border-color .13s, background .13s, color .13s;
}
.method-btn .m-icon { font-size: 22px; display: block; margin-bottom: 3px; }
.method-btn.selected {
  border-color: var(--btn);
  background: rgba(82, 136, 193, 0.15);
  color: #7db8ea;
}

/* ---- Calc box ---- */
.calc-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 4px 14px;
  border: 1px solid var(--sep);
}
.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--sep);
}
.calc-row:last-child { border-bottom: none; }
.calc-row .label { color: var(--hint); }
.calc-row .value { font-weight: 600; }
.calc-total .value { font-size: 16px; color: #7db8ea; }

/* ---- Amount highlight ---- */
.amount-highlight {
  background: rgba(82, 136, 193, 0.13);
  border: 1px solid rgba(82, 136, 193, 0.25);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.amount-highlight .big {
  font-size: 30px;
  font-weight: 700;
  color: #7db8ea;
  line-height: 1;
}
.amount-highlight .sub {
  font-size: 13px;
  color: var(--hint);
  margin-top: 4px;
}

/* ---- Payment details ---- */
.pay-details {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--sep);
}
.pay-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--sep);
  gap: 10px;
}
.pay-row:last-child { border-bottom: none; }
.pay-row .key { font-size: 13px; color: var(--hint); flex-shrink: 0; }
.pay-row .val { font-size: 14px; font-weight: 600; text-align: right; word-break: break-all; }
.copy-btn {
  background: rgba(82, 136, 193, 0.18);
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  color: #7db8ea;
  cursor: pointer;
  flex-shrink: 0;
  font-weight: 600;
  font-family: inherit;
}
.copy-btn:active { opacity: .7; }
.pay-row--copy-only { justify-content: space-between; }
.pay-row--copy-only .val { flex: 1; text-align: left; word-break: break-all; }
.copy-btn--icon {
  background: none;
  font-size: 18px;
  padding: 2px 6px;
  color: var(--hint);
  border-radius: 4px;
}
.copy-btn--icon:active { opacity: .5; }

/* ---- Statement screen ---- */
.limit-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.limit-tab {
  flex: 1;
  padding: 8px 0;
  border: 1.5px solid var(--sep);
  border-radius: 8px;
  background: none;
  color: var(--hint);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
}
.limit-tab.active {
  background: var(--btn);
  border-color: var(--btn);
  color: #fff;
}
.statement-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0;
}
.statement-empty {
  text-align: center;
  padding: 40px 0;
  color: var(--hint);
  font-size: 14px;
}
.tx-list { display: flex; flex-direction: column; gap: 0; }
.tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--sep);
}
.tx-item:last-child { border-bottom: none; }
.tx-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-desc {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-date { font-size: 12px; color: var(--hint); margin-top: 2px; }
.tx-amount {
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
  text-align: right;
}
.tx-amount.credit { color: var(--green); }
.tx-amount.debit  { color: var(--red, #e05252); }
.tx-amount.neutral { color: var(--hint); }

/* ---- Primary button ---- */
.btn-primary {
  display: block;
  width: 100%;
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 15px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 14px;
  transition: opacity .13s, transform .1s;
  font-family: inherit;
  letter-spacing: .1px;
}
.btn-primary:active { opacity: .85; transform: scale(.99); }
.btn-primary:disabled { opacity: .4; cursor: default; }

/* ---- Back button ---- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--link);
  font-size: 16px;
  cursor: pointer;
  margin-bottom: 16px;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

/* ---- Conditions table (home) ---- */
.card .calc-row { padding: 10px 14px; }
.card .calc-row:last-child { border-bottom: none; }

/* ---- Success screen ---- */
.success-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 0 24px;
}
.success-icon { font-size: 68px; margin-bottom: 18px; }
.success-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.success-sub {
  font-size: 15px;
  color: var(--hint);
  line-height: 1.55;
  max-width: 290px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all .22s;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,.15);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Spinner ---- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .65s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- QR code block ---- */
.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #ffffff;
  border-radius: var(--radius);
  padding: 18px;
  gap: 12px;
}
.qr-wrap canvas, .qr-wrap img { display: block; border-radius: 4px; }
.qr-hint {
  font-size: 13px;
  color: #555;
  margin: 0;
  text-align: center;
}
.qr-loading {
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #999;
}

/* ---- Support button ---- */
.btn-support {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 10px;
  background: rgba(255,255,255,.08);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: opacity .13s, transform .1s;
}
.btn-support:active { opacity: .7; transform: scale(.99); }

/* ---- App version ---- */
.app-version {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 13px;
  color: var(--hint);
  opacity: 0.55;
  pointer-events: none;
  z-index: 999;
}

/* ---- Update banner ---- */
.update-banner {
  position: fixed;
  bottom: 24px;
  left: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1f2f45;
  border: 1px solid rgba(92,168,220,0.35);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
}
.update-banner__icon {
  font-size: 26px;
  flex-shrink: 0;
}
.update-banner__text {
  flex: 1;
  min-width: 0;
}
.update-banner__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.update-banner__sub {
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
}
.update-banner__btn {
  background: var(--btn);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 10px;
  flex-shrink: 0;
  white-space: nowrap;
}
.update-banner__close {
  background: none;
  border: none;
  color: var(--hint);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  line-height: 1;
}

/* ---- SBP link button ---- */
.btn-sbp-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px;
  margin-top: 10px;
  background: rgba(93, 160, 224, 0.12);
  border: 1px solid rgba(93, 160, 224, 0.25);
  border-radius: var(--radius);
  color: var(--link);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-sbp-link:active { opacity: 0.7; }

/* ---- Cancel button ---- */
.btn-cancel {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 10px;
  background: rgba(255,255,255,.08);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: opacity .13s, transform .1s;
}
.btn-cancel:active { opacity: .7; transform: scale(.99); }

/* ---- QR payment status ---- */
.usdt-qr-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 16px 0 4px;
}
.usdt-qr-label {
  font-size: 12px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.usdt-qr-block img {
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  display: block;
}

.qr-countdown {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--hint);
}
.qr-countdown span {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 36px;
}

.qr-poll-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}
.qr-poll-status.waiting {
  background: rgba(93, 160, 224, 0.12);
  color: var(--link);
}
.qr-poll-status.paid {
  background: rgba(77, 202, 122, 0.15);
  color: var(--green);
  font-size: 16px;
}
.qr-poll-status.rejected {
  background: rgba(224, 82, 82, 0.12);
  color: var(--red);
}
.spinner-tiny {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* ---- Balance modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadeIn .18s ease;
}
.modal-box {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 28px 24px 36px;
  width: 100%;
  max-width: 480px;
  text-align: center;
  border-top: 1px solid var(--sep);
}
.modal-state { display: flex; flex-direction: column; align-items: center; min-height: 80px; justify-content: center; }
.modal-close {
  margin-top: 20px;
  width: 100%;
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.modal-close:active { opacity: .7; }

/* ---- Note text ---- */
.note {
  font-size: 13px;
  color: var(--hint);
  line-height: 1.55;
  margin-top: 10px;
  padding: 0 2px;
}
