/* ===== Payment Mini App — Shared Styles ===== */

/* ===== 1. DESIGN TOKENS ===== */

:root {
  /* --- Telegram SDK color passthrough (SDK fills these; fallbacks for browser) --- */
  --tg-bg:           var(--tg-theme-bg-color, #ffffff);
  --tg-text:         var(--tg-theme-text-color, #000000);
  --tg-hint:         var(--tg-theme-hint-color, #8e8e93);
  --tg-link:         var(--tg-theme-link-color, #007aff);
  --tg-btn:          var(--tg-theme-button-color, #007aff);
  --tg-btn-text:     var(--tg-theme-button-text-color, #ffffff);
  --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #f7f8f9);

  /* --- Safe areas (set dynamically by tg-init.js, fallback to env) --- */
  --tg-safe-top:    env(safe-area-inset-top, 0px);
  --tg-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tg-safe-left:   env(safe-area-inset-left, 0px);
  --tg-safe-right:  env(safe-area-inset-right, 0px);

  /* --- Semantic surfaces --- */
  --surface-primary:   var(--tg-bg);
  --surface-secondary: var(--tg-secondary-bg);
  --surface-overlay:   rgba(0, 0, 0, 0.4);

  /* --- Semantic text --- */
  --text-primary:   var(--tg-text);
  --text-secondary: var(--tg-hint);
  --text-tertiary:  #aeaeb2;
  --text-accent:    var(--tg-link);

  /* --- Borders (static fallbacks for older browsers) --- */
  --border-default: rgba(142, 142, 147, 0.15);
  --border-subtle:  rgba(142, 142, 147, 0.08);

  /* --- Status colors --- */
  --status-success-bg:   #dcfce7;
  --status-success-text: #15803d;
  --status-warning-bg:   #fef3c7;
  --status-warning-text: #a16207;
  --status-error-bg:     #fef2f2;
  --status-error-text:   #b91c1c;

  /* --- Shadows --- */
  --shadow-xs:    0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:    0 4px 12px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg:    0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);

  /* --- Glass --- */
  --glass-bg:     rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.2);

  /* --- Border radius scale --- */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  18px;
  --radius-2xl: 22px;

  /* --- Legacy compatibility aliases --- */
  --bg-primary:   var(--surface-primary);
  --bg-secondary: var(--surface-secondary);
  --accent:       var(--tg-link);
  --accent-hover: #0071e3;
  --accent-active:#0062cc;
  --separator:    var(--border-default);
  --card-bg:      var(--surface-primary);
  --card-shadow:  var(--shadow-md);
  --error:        var(--status-error-text);
  --success:      var(--status-success-text);
}

/* --- color-mix() enhanced tokens for modern browsers --- */
@supports (color: color-mix(in srgb, red 50%, blue)) {
  :root {
    --text-tertiary:  color-mix(in srgb, var(--tg-hint) 60%, transparent);
    --border-default: color-mix(in srgb, var(--tg-hint) 15%, transparent);
    --border-subtle:  color-mix(in srgb, var(--tg-hint) 8%, transparent);
    --accent-hover:   color-mix(in srgb, var(--tg-link) 85%, white);
    --accent-active:  color-mix(in srgb, var(--tg-link) 80%, black);
  }
}

/* --- Dark mode: Telegram SDK priority > system preference --- */
[data-theme="dark"] {
  color-scheme: dark;

  /* Override --tg-* for non-Telegram pages where SDK doesn't inject them */
  --tg-bg:           var(--tg-theme-bg-color, #1c1c1e);
  --tg-text:         var(--tg-theme-text-color, #ffffff);
  --tg-hint:         var(--tg-theme-hint-color, #8e8e93);
  --tg-link:         var(--tg-theme-link-color, #0a84ff);
  --tg-btn:          var(--tg-theme-button-color, #0a84ff);
  --tg-btn-text:     var(--tg-theme-button-text-color, #ffffff);
  --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #2c2c2e);

  /* Status colors */
  --status-success-bg:   rgba(22, 163, 74, 0.15);
  --status-success-text: #4ade80;
  --status-warning-bg:   rgba(234, 179, 8, 0.15);
  --status-warning-text: #facc15;
  --status-error-bg:     rgba(239, 68, 68, 0.15);
  --status-error-text:   #f87171;

  /* Shadows */
  --shadow-xs:    0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-md:    0 4px 12px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.15);
  --shadow-lg:    0 8px 24px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);

  /* Glass */
  --glass-bg:     rgba(30, 30, 30, 0.78);
  --glass-border: rgba(255, 255, 255, 0.08);

  /* Borders (static fallback) */
  --border-default: rgba(255, 255, 255, 0.12);
  --border-subtle:  rgba(255, 255, 255, 0.06);

  /* Surface overlay */
  --surface-overlay: rgba(0, 0, 0, 0.6);

  /* Text tertiary (static fallback) */
  --text-tertiary: #636366;

  /* Legacy aliases */
  --bg-primary:    #1c1c1e;
  --bg-secondary:  #2c2c2e;
  --accent:        #0a84ff;
  --accent-hover:  #409cff;
  --accent-active: #0070e0;
  --separator:     rgba(255, 255, 255, 0.12);
  --card-bg:       #2c2c2e;
  --card-shadow:   0 2px 8px rgba(0, 0, 0, 0.3);
  --error:         #ff453a;
  --success:       #30d158;
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
  [data-theme="dark"] {
    --text-tertiary:  color-mix(in srgb, var(--tg-hint) 60%, transparent);
    --border-default: rgba(255, 255, 255, 0.12);
    --border-subtle:  rgba(255, 255, 255, 0.06);
  }
}

/* System preference fallback (ONLY when data-theme not set) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;

    --tg-bg:           #1c1c1e;
    --tg-text:         #ffffff;
    --tg-hint:         #8e8e93;
    --tg-link:         #0a84ff;
    --tg-btn:          #0a84ff;
    --tg-btn-text:     #ffffff;
    --tg-secondary-bg: #2c2c2e;

    --status-success-bg:   rgba(22, 163, 74, 0.15);
    --status-success-text: #4ade80;
    --status-warning-bg:   rgba(234, 179, 8, 0.15);
    --status-warning-text: #facc15;
    --status-error-bg:     rgba(239, 68, 68, 0.15);
    --status-error-text:   #f87171;

    --shadow-xs:    0 1px 2px rgba(0, 0, 0, 0.15);
    --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.15);
    --shadow-md:    0 4px 12px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.15);
    --shadow-lg:    0 8px 24px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);

    --glass-bg:     rgba(30, 30, 30, 0.78);
    --glass-border: rgba(255, 255, 255, 0.08);

    --border-default: rgba(255, 255, 255, 0.12);
    --border-subtle:  rgba(255, 255, 255, 0.06);
    --surface-overlay: rgba(0, 0, 0, 0.6);
    --text-tertiary: #636366;

    --bg-primary:    #1c1c1e;
    --bg-secondary:  #2c2c2e;
    --accent:        #0a84ff;
    --accent-hover:  #409cff;
    --accent-active: #0070e0;
    --separator:     rgba(255, 255, 255, 0.12);
    --card-bg:       #2c2c2e;
    --card-shadow:   0 2px 8px rgba(0, 0, 0, 0.3);
    --error:         #ff453a;
    --success:       #30d158;
  }
}

/* ===== 2. RESET & BASE ===== */

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

html {
  -webkit-text-size-adjust: 100%;
}

* {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--surface-secondary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--tg-safe-top, env(safe-area-inset-top, 0px));
  padding-left: var(--tg-safe-left, env(safe-area-inset-left, 0px));
  padding-right: var(--tg-safe-right, env(safe-area-inset-right, 0px));
}

/* ===== 3. CSS ANIMATIONS ===== */

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes check-draw {
  from { stroke-dashoffset: 48; }
  to   { stroke-dashoffset: 0; }
}

@keyframes circle-draw {
  from { stroke-dashoffset: 150; }
  to   { stroke-dashoffset: 0; }
}

@keyframes circle-scale {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.3); }
  50%      { box-shadow: 0 0 0 12px rgba(52, 199, 89, 0); }
}

@keyframes indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

@keyframes pop-in {
  0%   { opacity: 0; transform: scale(0.8) translateY(8px); }
  60%  { transform: scale(1.02) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Utility animation classes */
.animate-fade-in {
  animation: fade-in 0.3s ease-out both;
}

.animate-slide-up {
  animation: slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-scale-in {
  animation: scale-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Stagger delays */
.stagger-1 { animation-delay: 0.04s; }
.stagger-2 { animation-delay: 0.08s; }
.stagger-3 { animation-delay: 0.12s; }
.stagger-4 { animation-delay: 0.16s; }
.stagger-5 { animation-delay: 0.20s; }
.stagger-6 { animation-delay: 0.24s; }

/* Shimmer skeleton */
.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    var(--surface-secondary) 25%,
    var(--surface-primary) 50%,
    var(--surface-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: var(--radius-md);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .animate-fade-in,
  .animate-slide-up,
  .animate-scale-in,
  .skeleton-shimmer {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== 4. LAYOUT ===== */

.pay-container {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 16px;
}

.pay-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 32px 24px;
}

/* ===== BRANDING HEADER ===== */

.brand-header {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--tg-btn), color-mix(in srgb, var(--tg-btn) 70%, #000));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--tg-btn-text);
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.brand-tagline {
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.2px;
}

/* ===== LEGAL FOOTER ===== */

.legal-footer {
  width: 100%;
  max-width: 420px;
  text-align: center;
  padding: 16px 24px 8px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-tertiary);
}

.legal-footer p {
  margin: 0;
}

/* ===== 5. PAY PAGE ===== */

.pay-amount {
  font-size: 36px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.pay-currency {
  font-weight: 400;
  color: var(--text-secondary);
}

.pay-description {
  text-align: center;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.4;
  margin-bottom: 24px;
}

.pay-comment {
  background: var(--surface-secondary);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 24px;
  display: none;
}

.pay-comment-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.pay-divider {
  height: 1px;
  background: var(--border-default);
  margin: 0 0 20px;
}

.pay-offer-link {
  display: block;
  text-align: center;
  color: var(--text-accent);
  font-size: 14px;
  text-decoration: none;
  margin-bottom: 8px;
}

.pay-offer-link:hover {
  text-decoration: underline;
}

.pay-terms {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 12px;
  margin-bottom: 0;
}

.pay-terms a {
  color: var(--text-tertiary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ===== CONFETTI CANVAS ===== */

.confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ===== 6. BUTTONS ===== */

@keyframes btn-glow {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tg-btn) 40%, transparent); }
  50%      { box-shadow: 0 0 0 8px color-mix(in srgb, var(--tg-btn) 0%, transparent); }
}

.pay-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  border: none;
  border-radius: var(--radius-xl);
  background: var(--tg-btn);
  color: var(--tg-btn-text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.15s ease, box-shadow 0.3s ease;
  user-select: none;
}

.pay-button:not(:disabled):active {
  transform: scale(0.97);
}

.pay-button:not(:disabled) {
  animation: btn-glow 2s ease-in-out 0.5s 2;
}

.pay-button:active {
  transform: scale(0.98);
}

.pay-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== 7. SPINNER ===== */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
}

/* ===== 8. ERROR MESSAGE ===== */

.pay-error {
  text-align: center;
  color: var(--status-error-text);
  font-size: 14px;
  margin-top: 12px;
  display: none;
}

/* ===== 9. LOADING SKELETON ===== */

.pay-loading {
  text-align: center;
  padding: 40px 0;
}

.pay-loading .skeleton {
  display: inline-block;
  height: 14px;
  border-radius: 7px;
}

.pay-loading .skeleton-amount {
  width: 160px;
  height: 36px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.pay-loading .skeleton-text {
  width: 240px;
  margin-bottom: 8px;
}

/* ===== 10. STATUS / SUCCESS PAGE ===== */

.status-container {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.status-card {
  text-align: center;
  max-width: 360px;
}

.status-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.status-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
}

.status-text {
  color: var(--text-secondary);
  font-size: 15px;
}

/* Animated success checkmark */
.success-check {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--status-success-bg);
  color: var(--status-success-text);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  animation: circle-scale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both,
             glow-pulse 2s ease-in-out 0.6s 3;
}

.success-check-pending {
  background: var(--surface-secondary);
  animation: none;
}

.check-svg .check-circle {
  stroke-dasharray: 150;
  stroke-dashoffset: 150;
  animation: circle-draw 0.6s ease-out 0.2s forwards;
}

.check-svg .check-path {
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: check-draw 0.4s ease-out 0.5s forwards;
}

.spinner-dark {
  border-color: rgba(0, 0, 0, 0.15);
  border-top-color: var(--text-secondary);
  width: 28px;
  height: 28px;
}

/* ===== 11. UPLOAD SECTION ===== */

.upload-section {
  margin-top: 24px;
}

.upload-hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 16px;
}

.upload-drop {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, transform 0.1s;
}

.upload-drop:active {
  transform: scale(0.99);
}

.upload-drop.dragover {
  border-color: var(--tg-btn);
  background: rgba(0, 122, 255, 0.05);
}

[data-theme="dark"] .upload-drop.dragover {
  background: rgba(10, 132, 255, 0.08);
}

.upload-drop-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.upload-drop-text {
  font-size: 15px;
  color: var(--text-primary);
  font-weight: 500;
}

.upload-drop-or {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 8px 0;
}

.upload-browse-btn {
  display: inline-block;
  color: var(--text-accent);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.upload-formats {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
}

.upload-file-info {
  text-align: center;
  padding: 12px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-secondary);
  border-radius: var(--radius-md);
  margin-top: 12px;
}

.upload-file-info #file-size {
  color: var(--text-secondary);
  margin-left: 8px;
}

/* Upload progress */
.upload-progress {
  height: 4px;
  background: var(--surface-secondary);
  border-radius: 2px;
  margin: 12px 0;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: var(--tg-btn);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s;
}

.upload-progress-bar.indeterminate {
  width: 30%;
  animation: indeterminate 1.5s ease-in-out infinite;
}

.upload-button {
  margin-top: 16px;
}

.upload-success {
  text-align: center;
  color: var(--status-success-text);
  font-size: 15px;
  font-weight: 500;
  margin-top: 16px;
  padding: 16px;
  background: var(--status-success-bg);
  border-radius: var(--radius-lg);
}

.upload-another-btn {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: none;
  color: var(--text-accent);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease;
}

.upload-another-btn:hover {
  background: rgba(0, 122, 255, 0.08);
}

/* ===== 12. OFFER PAGE ===== */

.offer-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.offer-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
}

.offer-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 32px;
}

.offer-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
}

.offer-section {
  margin-bottom: 28px;
}

.offer-section-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-left: 12px;
  border-left: 3px solid var(--tg-btn);
}

.offer-item {
  margin-bottom: 8px;
}

.offer-list {
  margin: 8px 0 8px 24px;
  list-style: disc;
}

.offer-list li {
  margin-bottom: 4px;
}

.offer-footer {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-default);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* ===== 13. DASHBOARD ===== */

.dash-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-top: calc(16px + var(--tg-safe-top, env(safe-area-inset-top, 0px)));
  padding-bottom: calc(16px + var(--tg-safe-bottom, env(safe-area-inset-bottom, 0px)));
}

.dash-header {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* Dashboard skeleton */
.dash-skeleton-header {
  height: 28px;
  width: 120px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.dash-skeleton-card {
  height: 80px;
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
}

/* Stats block */
.dash-stats {
  background: var(--surface-primary);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
}

.dash-stats-amount {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.dash-stats-count {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 12px;
}

.dash-stats-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dash-pill {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.dash-pill-succeeded {
  color: var(--status-success-text);
  background: var(--status-success-bg);
}

.dash-pill-pending {
  color: var(--status-warning-text);
  background: var(--status-warning-bg);
}

.dash-pill-canceled {
  color: var(--text-secondary);
  background: var(--surface-secondary);
}

/* Filters */
.dash-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

/* Glass sticky filters */
@supports (backdrop-filter: blur(20px)) {
  .dash-filters-sticky {
    position: sticky;
    top: var(--tg-safe-top, 0px);
    z-index: 10;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    margin: 0 -16px 16px;
    padding: 12px 16px;
  }
}

.dash-select {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 15px;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='%238e8e93'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  transition: border-color 0.15s ease;
}

.dash-select:focus {
  border-color: var(--tg-btn);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

/* Payment cards */
.dash-card {
  background: var(--surface-primary);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  transition: transform 0.1s ease;
}

.dash-card:active {
  transform: scale(0.99);
}

.dash-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dash-amount {
  font-size: 18px;
  font-weight: 600;
}

.dash-badge {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  font-weight: 500;
}

.dash-badge-succeeded {
  background: var(--status-success-bg);
  color: var(--status-success-text);
}

.dash-badge-pending {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
}

.dash-badge-canceled {
  background: var(--surface-secondary);
  color: var(--text-secondary);
}

.dash-card-comment {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.4;
}

.dash-card-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 8px;
}

.dash-receipt-link {
  cursor: pointer;
}

/* Load more */
.dash-load-more {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--surface-primary);
  color: var(--text-accent);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.dash-load-more:active {
  transform: scale(0.98);
}

.dash-load-more:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

/* Empty state */
.dash-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 48px 16px;
  font-size: 15px;
}

.dash-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  background: var(--surface-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
}

/* ===== 14. FORM INPUTS & CREATE PAYMENT ===== */

.dash-form-group {
  margin-bottom: 12px;
}

.dash-form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.dash-input {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 16px; /* prevent iOS zoom */
  color: var(--text-primary);
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.15s ease;
}

.dash-input::placeholder {
  color: var(--text-tertiary);
}

.dash-input:focus {
  border-color: var(--tg-btn);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.dash-input[inputmode="numeric"] {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}

/* Create payment section */
.create-section {
  background: var(--surface-primary);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
}

.create-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  border: none;
  border-radius: var(--radius-xl);
  background: var(--tg-btn);
  color: var(--tg-btn-text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
  user-select: none;
  font-family: inherit;
  margin-top: 4px;
}

.create-btn:active {
  transform: scale(0.98);
}

.create-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Result card */
.create-result {
  background: var(--status-success-bg);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
}

.create-result-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--status-success-text);
  margin-bottom: 10px;
}

.create-result-url {
  font-size: 14px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  word-break: break-all;
  color: var(--text-primary);
  background: var(--surface-primary);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  user-select: all;
}

.create-result-actions {
  display: flex;
  gap: 8px;
}

.copy-btn {
  flex: 1;
  height: 40px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--tg-btn);
  color: var(--tg-btn-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.copy-btn:active {
  transform: scale(0.97);
}

.new-btn {
  flex: 1;
  height: 40px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-primary);
  color: var(--text-accent);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s ease;
}

.new-btn:active {
  transform: scale(0.97);
}

.create-error {
  text-align: center;
  color: var(--status-error-text);
  font-size: 14px;
  margin-top: 8px;
  display: none;
}

.bot-sent-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding: 8px;
}

/* ===== 15. DESKTOP PHONE FRAME ===== */

.desktop-frame {
  min-height: 100vh;
  min-height: 100dvh;
}

.desktop-frame-inner {
  min-height: 100vh;
  min-height: 100dvh;
}

@media (min-width: 500px) {
  body {
    background: #f0f0f5;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
  }

  [data-theme="dark"] body {
    background: #0f0f14;
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme]) body {
      background: #0f0f14;
    }
  }

  .desktop-frame {
    width: 100%;
    max-width: 430px;
    min-height: calc(100dvh - 32px);
    max-height: 932px;
    margin: 0 auto;
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.06),
      0 8px 40px rgba(0, 0, 0, 0.12),
      0 20px 80px rgba(0, 0, 0, 0.08);
    background: var(--surface-secondary);
    position: relative;
  }

  [data-theme="dark"] .desktop-frame {
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.06),
      0 8px 40px rgba(0, 0, 0, 0.4),
      0 20px 80px rgba(0, 0, 0, 0.3);
  }

  .desktop-frame-inner {
    height: 100%;
    min-height: calc(100dvh - 32px);
    max-height: 932px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* Override child containers */
  .desktop-frame .pay-container,
  .desktop-frame .status-container {
    min-height: auto;
    padding-top: 40px;
  }

  .desktop-frame .dash-container {
    max-width: none;
  }

  .desktop-frame .offer-container {
    max-width: none;
  }
}

/* ===== 15. PRINT STYLES ===== */

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
  }

  .desktop-frame {
    max-width: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .desktop-frame-inner {
    max-height: none !important;
    overflow: visible !important;
  }

  .offer-section {
    break-inside: avoid;
  }

  .offer-section-title {
    border-left-color: #000000 !important;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 12px;
    color: #666;
  }
}
