.kdg-canvas-hub {
  --kdg-font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --kdg-brand: #0088cc;
  --kdg-brand-dark: #0077b3;
  --kdg-brand-rgb: 0, 136, 204;
  --kdg-brand-soft: #e0f2fe;
  --kdg-green: #16a34a;
  --kdg-green-bright: #22c55e;
  --kdg-green-soft: #f0fdf4;
  --kdg-green-border: #bbf7d0;
  --kdg-orange: #d97706;
  --kdg-orange-soft: #fffbeb;
  --kdg-orange-border: #fde68a;
  --kdg-red: #dc2626;
  --kdg-red-soft: #fef2f2;
  --kdg-red-border: #fecaca;
  --kdg-text-main: #0f172a;
  --kdg-text-muted: #64748b;
  --kdg-bg-soft: #f8fafc;
  --kdg-border-subtle: rgba(226, 232, 240, 0.8);
  --kdg-radius-pill: 9999px;

  direction: rtl !important;
  text-align: right !important;
  max-width: 580px;
  width: 100%;
  min-height: 520px;
  margin: 40px auto;
  background: #fff;
  border: 1px solid var(--kdg-border-subtle);
  border-radius: 28px;
  box-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.03);
  position: relative;
  overflow: hidden !important;
  padding: 44px 38px;
  color: var(--kdg-text-main);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.kdg-canvas-hub * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--kdg-font-family) !important;
}

.kdg-canvas-hub [hidden],
.kdg-modal-overlay[hidden] {
  display: none !important;
}

.kdg-canvas-hub::before {
  content: "";
  position: absolute;
  top: -120px;
  left: -120px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(var(--kdg-brand-rgb), 0.07) 0%, transparent 70%);
  pointer-events: none;
  border-radius: 50%;
}

.kdg-canvas-hub > * {
  position: relative;
  z-index: 1;
}

.kdg-deco {
  position: absolute;
  pointer-events: none;
  z-index: 0;
}
.kdg-deco-tl {
  top: -46px;
  left: -46px;
  color: rgba(var(--kdg-brand-rgb), 0.22);
}

@keyframes kdgFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.kdg-step { animation: kdgFadeUp 0.35s ease both; width: 100%; }

.kdg-head { text-align: center !important; margin-bottom: 24px; }
.kdg-center-text { text-align: center !important; }

.kdg-head-icon {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--kdg-brand-soft);
  color: var(--kdg-brand);
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
}
.kdg-head-icon svg { width: 28px; height: 28px; }
.kdg-head h1 { font-size: 22px; font-weight: 800; color: #0b1329; text-align: center !important; }
.kdg-head p { font-size: 13px; color: var(--kdg-text-muted); margin-top: 6px; }

/* فیلدهای فرم */
.kdg-field { margin-bottom: 16px; position: relative; }
.kdg-field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; text-align: right !important; }

.kdg-field input {
  width: 100%;
  height: 48px;
  padding: 10px 14px;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 11px;
  font-size: 14.5px;
  color: var(--kdg-text-main);
  outline: none;
  transition: all 0.2s ease;
  direction: ltr !important;
  text-align: left !important;
}
.kdg-field input:focus {
  border-color: var(--kdg-brand);
  box-shadow: 0 0 0 3px rgba(var(--kdg-brand-rgb), 0.12);
}
.kdg-field input.is-invalid {
  border-color: var(--kdg-red);
  background-color: var(--kdg-red-soft);
}
.kdg-field-msg {
  font-size: 12px;
  color: var(--kdg-red);
  margin-top: 5px;
  font-weight: 600;
  text-align: right !important;
}

.kdg-input-wrap {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}
.kdg-input-wrap input#kdg-sitecode {
  font-family: ui-monospace, Consolas, monospace !important;
  letter-spacing: 1.2px;
  font-weight: 700;
  text-transform: uppercase;
  padding-right: 76px !important;
  padding-left: 14px !important;
}

.kdg-action-btn-inline {
  position: absolute;
  right: 8px !important;
  left: auto !important;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--kdg-bg-soft);
  border: 1px solid #cbd5e1;
  color: #475569;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 2;
}
.kdg-action-btn-inline:hover {
  background: var(--kdg-brand-soft);
  color: var(--kdg-brand);
  border-color: #bae6fd;
}
.kdg-action-btn-inline svg { width: 13px; height: 13px; }

.kdg-pwd-wrap {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}
.kdg-pwd-wrap input {
  padding-right: 46px !important;
  padding-left: 14px !important;
}
.kdg-pwd-toggle {
  position: absolute;
  right: 8px !important;
  left: auto !important;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  transition: color 0.2s;
  z-index: 2;
}
.kdg-pwd-toggle:hover { color: var(--kdg-brand); }
.kdg-pwd-toggle svg { width: 19px; height: 19px; }

.kdg-btn-action {
  width: 100%;
  height: 52px;
  background: var(--kdg-brand);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.25s ease;
  box-shadow: 0 8px 20px -4px rgba(var(--kdg-brand-rgb), 0.35);
  margin-top: 14px;
  position: relative;
  z-index: 5;
}
.kdg-btn-action:hover {
  background: var(--kdg-brand-dark);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -4px rgba(var(--kdg-brand-rgb), 0.45);
}
.kdg-btn-action:disabled { opacity: 0.65; cursor: wait; transform: none; }
.kdg-btn-action svg { width: 18px; height: 18px; }

/* استایل ایزوله AltCha */
.kdg-canvas-hub .kdg-altcha-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: 10px;
  position: relative;
  z-index: 100;
}

.kdg-canvas-hub altcha-widget {
  display: block;
  position: relative;
}

.kdg-canvas-hub altcha-widget .altcha[data-floating],
.kdg-canvas-hub altcha-widget::part(floating) {
  position: relative !important;
  top: 0 !important;
  left: 0 !important;
  right: auto !important;
  margin: 10px auto 0 !important;
  transform: none !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
  border-radius: 14px !important;
  border: 1.5px solid #e2e8f0 !important;
}

/* لودینگ */
.kdg-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 340px;
  text-align: center !important;
}
.kdg-loading-inner { width: 100%; }
.kdg-spinner {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 4px solid rgba(var(--kdg-brand-rgb), 0.15);
  border-top-color: var(--kdg-brand);
  margin: 0 auto 18px;
  animation: kdgSpin 0.8s linear infinite;
}
@keyframes kdgSpin { to { transform: rotate(360deg); } }
.kdg-loading h2 { font-size: 17px; font-weight: 800; }
.kdg-loading p { font-size: 12.5px; color: var(--kdg-text-muted); margin-top: 6px; }

/* کیف پول */
.kdg-wallet {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--kdg-bg-soft);
  border: 1.5px dashed #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  margin-top: 14px;
}
.kdg-wallet-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--kdg-brand-soft);
  color: var(--kdg-brand);
  display: grid;
  place-items: center;
}
.kdg-wallet-icon svg { width: 20px; height: 20px; }
.kdg-wallet-info { flex: 1; min-width: 0; text-align: right !important; }
.kdg-wallet-label { display: block; font-size: 13px; font-weight: 700; }
.kdg-wallet-sub { display: block; font-size: 11.5px; color: #94a3b8; margin-top: 2px; }
.kdg-wallet-num {
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 26px;
  font-weight: 800;
  color: var(--kdg-brand);
}
.kdg-wallet-num small { font-size: 13px; font-weight: 700; color: var(--kdg-brand); }

.kdg-wallet.is-empty {
  border-color: var(--kdg-orange-border);
  background: var(--kdg-orange-soft);
}
.kdg-wallet.is-empty .kdg-wallet-icon { background: var(--kdg-orange); color: #fff; }
.kdg-wallet.is-empty .kdg-wallet-num,
.kdg-wallet.is-empty .kdg-wallet-num small { color: var(--kdg-orange); }
.kdg-wallet.is-empty .kdg-wallet-sub { color: var(--kdg-orange); font-weight: 700; }

.kdg-cap-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--kdg-orange-soft);
  border: 1px solid var(--kdg-orange-border);
  color: #92400e;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.8;
  margin-top: 12px;
}
.kdg-cap-notice svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--kdg-orange); }

.kdg-empty-help {
  background: var(--kdg-bg-soft);
  border: 1.5px dashed #e2e8f0;
  border-radius: 12px;
  padding: 13px 16px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--kdg-text-muted);
  line-height: 2;
  text-align: right !important;
}
.kdg-empty-line { display: flex; align-items: center; gap: 6px; }
.kdg-empty-line svg { width: 14px; height: 14px; flex-shrink: 0; color: #94a3b8; }
.kdg-empty-line a { color: var(--kdg-brand); font-weight: 800; text-decoration: none; }
.kdg-empty-line a:hover { text-decoration: underline; }

.kdg-after-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  color: #0f172a;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 16px;
  text-align: center;
  line-height: 1.8;
}
.kdg-after-note svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--kdg-brand); }

/* ═══ کارت هدیه کد شارژ (VIP Card) ═══ */
.kdg-giftcard {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background: linear-gradient(140deg, #092c4c 0%, #034b7a 50%, #026b9c 100%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 20px 40px -12px rgba(2, 44, 76, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.35);
  padding: 26px 24px 22px;
  color: #fff;
  margin-bottom: 20px;
  animation: kdgFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* کانتینرهای SVG دایره‌های هندسی */
.kdg-gc-deco-top {
  position: absolute;
  top: -65px;
  left: -65px;
  width: 210px;
  height: 210px;
  pointer-events: none;
  opacity: 0.18;
}

.kdg-gc-deco-bottom {
  position: absolute;
  bottom: -50px;
  right: -50px;
  width: 170px;
  height: 170px;
  pointer-events: none;
  opacity: 0.16;
}

/* انیمیشن چرخش با سرعت‌های مستقل و مخالف */
.kdg-spin-cw-slow {
  transform-origin: 100px 100px;
  animation: kdgSpinCW 38s linear infinite;
}

.kdg-spin-ccw-mid {
  transform-origin: 100px 100px;
  animation: kdgSpinCCW 22s linear infinite;
}

.kdg-spin-cw-bottom {
  transform-origin: 80px 80px;
  animation: kdgSpinCW 48s linear infinite;
}

@keyframes kdgSpinCW {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes kdgSpinCCW {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

/* ستاره‌های چهارپر چشمک‌زن */
.kdg-gc-sparkle {
  position: absolute;
  pointer-events: none;
  animation: kdgTwinkle 2.5s ease-in-out infinite alternate;
}
.kdg-gc-sparkle-1 { top: 20px; right: 28px; width: 13px; height: 13px; color: #bae6fd; animation-delay: 0.2s; }
.kdg-gc-sparkle-2 { top: 52%; right: 22px; width: 10px; height: 10px; color: #fde047; animation-delay: 1.4s; }

/* نقاط نئونی */
.kdg-gc-dot {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: kdgDotPulse 2.8s ease-in-out infinite alternate;
}
.kdg-gc-dot-1 {
  top: 30px;
  left: 45px;
  width: 4px;
  height: 4px;
  background: #38bdf8;
  box-shadow: 0 0 8px 2px #38bdf8;
  animation-delay: 0.5s;
}
.kdg-gc-dot-2 {
  bottom: 28px;
  left: 36px;
  width: 3.5px;
  height: 3.5px;
  background: #7dd3fc;
  box-shadow: 0 0 7px 2px #7dd3fc;
  animation-delay: 1.8s;
}
.kdg-gc-dot-3 {
  top: 75px;
  right: 60px;
  width: 3px;
  height: 3px;
  background: #fef08a;
  box-shadow: 0 0 6px 2px #fef08a;
  animation-delay: 1.1s;
}

@keyframes kdgTwinkle {
  0% { opacity: 0.25; transform: scale(0.7) rotate(0deg); }
  100% { opacity: 1; transform: scale(1.15) rotate(45deg); filter: drop-shadow(0 0 5px currentColor); }
}

@keyframes kdgDotPulse {
  0% { opacity: 0.15; transform: scale(0.6); }
  50% { opacity: 0.95; transform: scale(1.2); }
  100% { opacity: 0.15; transform: scale(0.6); }
}

/* برند کارت */
.kdg-gc-brand {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(240, 249, 255, 0.92);
  margin-bottom: 12px;
}
.kdg-gc-brand svg { width: 16px; height: 16px; color: #7dd3fc; }

/* ساعت شارژ */
.kdg-gc-hours-wrap {
  position: relative;
  z-index: 2;
  text-align: center;
  margin: 6px 0 16px;
}
.kdg-gc-hours-val {
  display: block;
  font-size: 60px;
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 0 20px rgba(56, 189, 248, 0.75), 0 0 40px rgba(14, 165, 233, 0.45);
  letter-spacing: -1px;
}
.kdg-gc-hours-label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: #bae6fd;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* کپسول کپی کد شارژ */
.kdg-gc-capsule {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(8, 28, 48, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 8px 10px 8px 14px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.kdg-gc-code {
  flex: 1;
  text-align: center;
  font-family: ui-monospace, Consolas, monospace !important;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ffffff;
  direction: ltr;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.25);
  white-space: nowrap;
}

.kdg-gc-copy {
  flex-shrink: 0 !important;
  width: 90px !important;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 0;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
}
.kdg-gc-copy:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.kdg-gc-copy svg { width: 14px; height: 14px; }

.kdg-gc-capsule.is-copied .kdg-gc-copy {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.4);
}

.kdg-gc-foot {
  position: relative;
  z-index: 2;
  margin-top: 12px;
  text-align: center;
  font-size: 11px;
  color: rgba(224, 242, 254, 0.75);
}

/* مودال */
.kdg-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.kdg-modal-card {
  background: #fff;
  border-radius: 20px;
  max-width: 440px;
  width: 100%;
  padding: 32px 24px;
  text-align: center !important;
  direction: rtl;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: kdgFadeUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.kdg-modal-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--kdg-red-soft);
  color: var(--kdg-red);
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
}
.kdg-modal-icon svg { width: 32px; height: 32px; }
.kdg-modal-title { font-size: 18px; font-weight: 800; color: #0f172a; margin-bottom: 8px; text-align: center !important; }
.kdg-modal-desc { 
  font-size: 14px; 
  color: var(--kdg-text-muted); 
  line-height: 1.8; 
  margin-bottom: 22px; 
  text-align: center !important; 
}
.kdg-modal-btn {
  width: 100%;
  height: 48px;
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s;
}
.kdg-modal-btn:hover { background: #1e293b; }

/* ═══ بهینه‌سازی اختصاصی کارت و فرم برای موبایل (بدون دستکاری دسکتاپ) ═══ */
@media (max-width: 520px) {
  /* تنظیم پدینگ کانتینر اصلی در موبایل */
  .kdg-canvas-hub {
    padding: 30px 18px !important;
    margin: 20px auto !important;
    border-radius: 22px !important;
  }

  /* تنظیم پدینگ کارت لوکس */
  .kdg-giftcard {
    padding: 22px 14px 18px !important;
    border-radius: 20px !important;
  }

  /* تغییر چینش کپسول در موبایل به حالت ستونی منظم */
  .kdg-gc-capsule {
    flex-direction: column !important;
    gap: 10px !important;
    padding: 12px 10px !important;
  }

  /* بهینه‌سازی اندازه قلم کد ۱۶ رقمی تا داخل کادر مهار شود */
  .kdg-gc-code {
    font-size: 15px !important;
    letter-spacing: 1.2px !important;
    width: 100% !important;
    text-align: center !important;
  }

  /* دکمه کپی به صورت تمام‌عرض و شکیل در زیر کد */
  .kdg-gc-copy {
    width: 100% !important;
    height: 40px !important;
  }

  /* اندازه عدد ساعت شارژ در موبایل */
  .kdg-gc-hours-val {
    font-size: 48px !important;
  }
}