/* ===== پایه و متغیرهای رنگ (سازگار با تم روشن/تیره تلگرام) ===== */
:root{
  --tg-bg: var(--tg-theme-bg-color, #0f1220);
  --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #161a2e);
  --tg-text: var(--tg-theme-text-color, #eef0fb);
  --tg-hint: var(--tg-theme-hint-color, #8b90ad);
  --tg-link: var(--tg-theme-link-color, #7c8bff);
  --tg-button: var(--tg-theme-button-color, #6c5ce7);
  --tg-button-text: var(--tg-theme-button-text-color, #ffffff);

  --accent: #6c5ce7;
  --accent-2: #00d4c8;
  --grad: linear-gradient(135deg, #6c5ce7 0%, #4361ee 45%, #00d4c8 100%);
  --grad-soft: linear-gradient(135deg, rgba(108,92,231,.18), rgba(0,212,200,.10));
  --card-bg: rgba(255,255,255,.045);
  --card-border: rgba(255,255,255,.08);
  --success: #2ecc71;
  --danger: #ff5c72;
  --warn: #ffb020;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-soft: 0 8px 30px rgba(0,0,0,.25);
}

@media (prefers-color-scheme: light){
  :root{
    --tg-bg: var(--tg-theme-bg-color, #f4f5fb);
    --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #ffffff);
    --tg-text: var(--tg-theme-text-color, #14162b);
    --tg-hint: var(--tg-theme-hint-color, #6b6f8d);
    --card-bg: rgba(20,22,50,.035);
    --card-border: rgba(20,22,50,.08);
    --shadow-soft: 0 8px 24px rgba(30,30,60,.10);
  }
}

*{ box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:"Vazirmatn", system-ui, sans-serif;
  background: var(--tg-bg);
  color: var(--tg-text);
  overscroll-behavior-y: none;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea{ font-family: inherit; }
::selection{ background: var(--accent); color:#fff; }

img{ max-width:100%; display:block; }

/* ===== هدر ===== */
.topbar{
  position: sticky; top:0; z-index: 20;
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 16px 12px;
  background: linear-gradient(180deg, var(--tg-bg) 60%, transparent);
  backdrop-filter: blur(6px);
}
.topbar-brand{ display:flex; align-items:center; gap:10px; }
.topbar-logo{
  width:40px; height:40px; border-radius: 12px;
  display:flex; align-items:center; justify-content:center;
  background: var(--grad); font-size:20px; box-shadow: var(--shadow-soft);
}
.topbar-name{ font-weight:800; font-size:15px; line-height:1.3; }
.topbar-sub{ font-size:11.5px; color:var(--tg-hint); }
.topbar-wallet{
  display:flex; align-items:center; gap:6px;
  background: var(--card-bg); border:1px solid var(--card-border);
  padding: 8px 12px; border-radius: 999px; font-size:13px; font-weight:700;
}
.wallet-icon{ font-size:14px; }

/* ===== محتوا ===== */
#screens{ padding: 4px 16px 96px; min-height: 60vh; }
.screen{ display:none; animation: fadein .25s ease; }
.screen.active{ display:block; }
@keyframes fadein{ from{ opacity:0; transform: translateY(6px);} to{opacity:1; transform:none;} }

/* ===== هیرو خانه ===== */
.hero{
  border-radius: var(--radius-lg);
  padding: 22px 18px;
  background: var(--grad);
  color:#fff;
  position: relative; overflow:hidden;
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
}
.hero::after{
  content:""; position:absolute; inset:-40% -20% auto auto; width:180px; height:180px;
  background: radial-gradient(circle, rgba(255,255,255,.25), transparent 70%);
}
.hero-title{ font-size:18px; font-weight:800; margin:0 0 6px; }
.hero-desc{ font-size:12.5px; opacity:.92; margin:0 0 14px; line-height:1.9; max-width: 80%; }
.hero-cta{
  display:inline-flex; align-items:center; gap:6px;
  background: rgba(255,255,255,.18); border:1px solid rgba(255,255,255,.35);
  padding: 9px 16px; border-radius: 999px; font-size:12.5px; font-weight:700; color:#fff;
  backdrop-filter: blur(4px);
}

.section-title{
  font-size:13.5px; font-weight:800; margin: 18px 2px 10px;
  display:flex; align-items:center; justify-content:space-between; color: var(--tg-text);
}
.section-title .more{ font-size:11.5px; color: var(--tg-link); font-weight:700; }

/* ===== کارت وضعیت اشتراک ===== */
.status-card{
  border-radius: var(--radius-md); padding:14px 16px; margin-bottom:12px;
  background: var(--card-bg); border:1px solid var(--card-border);
  display:flex; align-items:center; gap:12px;
}
.status-card .ico{ font-size:24px; }
.status-card .title{ font-size:13px; font-weight:800; }
.status-card .desc{ font-size:11.5px; color:var(--tg-hint); margin-top:2px; }
.status-card.active{ border-color: rgba(46,204,113,.35); background: linear-gradient(135deg, rgba(46,204,113,.12), transparent); }

/* ===== گرید اکشن سریع ===== */
.quick-grid{ display:grid; grid-template-columns: repeat(4,1fr); gap:10px; margin-bottom: 6px; }
.quick-item{
  display:flex; flex-direction:column; align-items:center; gap:6px;
  background: var(--card-bg); border:1px solid var(--card-border);
  border-radius: var(--radius-md); padding: 12px 4px; cursor:pointer;
  transition: transform .12s ease;
}
.quick-item:active{ transform: scale(.94); }
.quick-item .ico{ font-size:20px; }
.quick-item .lbl{ font-size:10.5px; font-weight:700; color:var(--tg-text); text-align:center; }

/* ===== گرید سرویس‌ها ===== */
.svc-grid{ display:grid; grid-template-columns: repeat(3,1fr); gap:10px; }
.svc-card{
  background: var(--card-bg); border:1px solid var(--card-border);
  border-radius: var(--radius-md); padding: 16px 8px; text-align:center;
  display:flex; flex-direction:column; align-items:center; gap:8px;
  cursor:pointer; transition: transform .12s ease, border-color .12s;
}
.svc-card:active{ transform: scale(.95); }
.svc-card .ico{
  width:44px; height:44px; border-radius:14px; display:flex; align-items:center; justify-content:center;
  background: var(--grad-soft); font-size:22px;
}
.svc-card .name{ font-size:11.5px; font-weight:700; }

/* ===== لیست پلن‌ها ===== */
.plan-row, .list-row{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  background: var(--card-bg); border:1px solid var(--card-border);
  border-radius: var(--radius-md); padding: 14px 16px; margin-bottom:10px;
  cursor:pointer; transition: transform .1s ease;
}
.plan-row:active, .list-row:active{ transform: scale(.98); }
.plan-row .left, .list-row .left{ display:flex; flex-direction:column; gap:4px; min-width:0; }
.plan-row .name, .list-row .name{ font-size:13.5px; font-weight:800; }
.plan-row .meta, .list-row .meta{ font-size:11px; color:var(--tg-hint); }
.plan-row .price{ font-size:13px; font-weight:800; color: var(--accent-2); white-space:nowrap; }
.plan-row .price.soldout{ color: var(--danger); font-size:11.5px; }
.chev{ color: var(--tg-hint); font-size:14px; }

.subgroup-row{
  display:flex; align-items:center; gap:10px;
  background: var(--card-bg); border:1px solid var(--card-border);
  border-radius: var(--radius-md); padding: 13px 16px; margin-bottom:10px; cursor:pointer;
}
.subgroup-row .ico{ font-size:16px; }
.subgroup-row .name{ font-weight:700; font-size:13px; flex:1; }

/* ===== breadcrumbs/back ===== */
.page-head{ display:flex; align-items:center; gap:10px; margin: 6px 0 14px; }
.back-btn{
  width:34px; height:34px; border-radius: 10px; border:1px solid var(--card-border);
  background: var(--card-bg); display:flex; align-items:center; justify-content:center;
  font-size:16px; cursor:pointer; color: var(--tg-text);
}
.page-head .h{ font-size:15px; font-weight:800; }
.page-head .s{ font-size:11px; color:var(--tg-hint); }

/* ===== خالی/لودینگ ===== */
.empty-state{ text-align:center; padding: 40px 10px; color: var(--tg-hint); }
.empty-state .ico{ font-size:34px; margin-bottom:10px; }
.skel{ border-radius: var(--radius-md); background: linear-gradient(90deg, var(--card-bg) 25%, rgba(255,255,255,.08) 50%, var(--card-bg) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; height: 62px; margin-bottom:10px; }
@keyframes shimmer{ 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.spinner{ width:22px; height:22px; border-radius:50%; border:3px solid rgba(255,255,255,.25); border-top-color:#fff; animation: spin .7s linear infinite; display:inline-block; }
@keyframes spin{ to{ transform: rotate(360deg);} }

/* ===== کارت جزئیات خرید ===== */
.buy-card{ background: var(--card-bg); border:1px solid var(--card-border); border-radius: var(--radius-lg); padding:18px; }
.buy-title{ font-size:15px; font-weight:800; margin-bottom:4px; }
.buy-desc{ font-size:12px; color:var(--tg-hint); line-height:1.9; margin-bottom:14px; white-space:pre-wrap; }
.price-lines{ display:flex; flex-direction:column; gap:8px; margin-bottom:14px; }
.price-line{ display:flex; align-items:center; justify-content:space-between; font-size:12.5px; }
.price-line .k{ color:var(--tg-hint); }
.price-line .v{ font-weight:700; }
.price-line.strike .v{ text-decoration: line-through; color:var(--tg-hint); font-weight:500; }
.price-line.off .v{ color: var(--success); }
.price-line.final{ border-top:1px dashed var(--card-border); padding-top:10px; margin-top:2px; }
.price-line.final .v{ font-size:17px; color: var(--accent-2); }
.usdt-hint{ text-align:left; font-size:11px; color:var(--tg-hint); margin-top:-6px; margin-bottom:14px; }

.wallet-toggle-row{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  background: var(--tg-secondary-bg); border-radius: var(--radius-sm); padding:12px 14px; margin-bottom:12px;
}
.wallet-toggle-row .lbl{ font-size:12.5px; font-weight:700; }
.wallet-toggle-row .sub{ font-size:10.5px; color:var(--tg-hint); }
.switch{ width:42px; height:24px; border-radius:999px; background: rgba(255,255,255,.15); position:relative; cursor:pointer; flex-shrink:0; transition: background .15s; }
.switch.on{ background: var(--grad); }
.switch .knob{ position:absolute; top:3px; right:3px; width:18px; height:18px; border-radius:50%; background:#fff; transition: transform .18s; box-shadow:0 1px 4px rgba(0,0,0,.3); }
.switch.on .knob{ transform: translateX(-18px); }

.discount-row{ display:flex; gap:8px; margin-bottom:14px; }
.discount-row input{
  flex:1; background: var(--tg-secondary-bg); border:1px solid var(--card-border); border-radius: var(--radius-sm);
  padding: 11px 12px; color: var(--tg-text); font-size:12.5px; text-transform:uppercase;
}
.btn{
  border:none; border-radius: var(--radius-sm); padding: 11px 16px; font-size:12.5px; font-weight:800;
  cursor:pointer; background: var(--tg-secondary-bg); color: var(--tg-text); border:1px solid var(--card-border);
}
.btn.primary{ background: var(--grad); color:#fff; border:none; box-shadow: 0 6px 18px rgba(108,92,231,.35); }
.btn.block{ display:block; width:100%; text-align:center; padding:13px; font-size:13.5px; }
.btn.ghost{ background:transparent; }
.btn.danger{ background: rgba(255,92,114,.12); color: var(--danger); border-color: rgba(255,92,114,.3); }
.btn:disabled{ opacity:.5; pointer-events:none; }
.chip-discount{
  display:inline-flex; align-items:center; gap:6px; background: rgba(46,204,113,.12); color: var(--success);
  border:1px solid rgba(46,204,113,.3); padding:8px 12px; border-radius:999px; font-size:11.5px; font-weight:700; margin-bottom:14px;
}
.chip-discount .x{ cursor:pointer; opacity:.8; }

.method-list{ display:flex; flex-direction:column; gap:10px; margin-top:6px; }
.method-btn{
  display:flex; align-items:center; gap:12px; background: var(--tg-secondary-bg); border:1px solid var(--card-border);
  border-radius: var(--radius-md); padding: 14px 16px; cursor:pointer; text-align:right;
}
.method-btn:active{ transform: scale(.98); }
.method-btn .ico{ font-size:20px; }
.method-btn .txt .t1{ font-size:13px; font-weight:800; }
.method-btn .txt .t2{ font-size:10.5px; color:var(--tg-hint); }
.method-btn .chev{ margin-right:auto; }

/* ===== شیت پایین ===== */
.sheet-overlay{
  position: fixed; inset:0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
  z-index: 100; display:none; align-items:flex-end; justify-content:center;
}
.sheet-overlay.open{ display:flex; }
.sheet{
  width:100%; max-width: 560px; background: var(--tg-bg); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y:auto; box-shadow: 0 -10px 40px rgba(0,0,0,.4);
  transform: translateY(100%); transition: transform .28s cubic-bezier(.32,.72,0,1);
}
.sheet-overlay.open .sheet{ transform: translateY(0); }
.sheet-handle{ width:38px; height:4px; border-radius:99px; background: var(--card-border); margin: 6px auto 14px; }
.sheet-title{ font-size:15px; font-weight:800; margin-bottom:4px; }
.sheet-sub{ font-size:11.5px; color:var(--tg-hint); margin-bottom:16px; }

.copy-field{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  background: var(--tg-secondary-bg); border:1px dashed var(--card-border); border-radius: var(--radius-sm);
  padding: 13px 14px; margin-bottom: 12px; cursor:pointer;
}
.copy-field .val{ font-size:14px; font-weight:800; letter-spacing:.5px; direction:ltr; text-align:right; word-break:break-all; }
.copy-field .lbl{ font-size:10.5px; color:var(--tg-hint); margin-bottom:4px; }
.copy-field .cpy{ font-size:16px; flex-shrink:0; }

.upload-box{
  border:2px dashed var(--card-border); border-radius: var(--radius-md); padding: 22px 12px; text-align:center;
  margin-bottom:14px; cursor:pointer; position:relative;
}
.upload-box.has-file{ border-color: var(--success); }
.upload-box .ico{ font-size:26px; margin-bottom:6px; }
.upload-box .t{ font-size:12px; font-weight:700; }
.upload-box .s{ font-size:10.5px; color:var(--tg-hint); margin-top:4px; }
.upload-box input{ position:absolute; inset:0; opacity:0; cursor:pointer; }
.upload-preview{ max-height:140px; border-radius:12px; margin: 0 auto 10px; }

textarea.field, input.field{
  width:100%; background: var(--tg-secondary-bg); border:1px solid var(--card-border); border-radius: var(--radius-sm);
  padding: 12px 14px; color: var(--tg-text); font-size:13px; margin-bottom:14px; direction:ltr; text-align:left;
}
textarea.field{ direction:rtl; text-align:right; min-height: 90px; resize:vertical; }

.status-pill{ display:inline-flex; align-items:center; gap:6px; font-size:11.5px; font-weight:700; padding:6px 12px; border-radius:999px; }
.status-pill.pending{ background: rgba(255,176,32,.14); color:var(--warn); }
.status-pill.approved{ background: rgba(46,204,113,.14); color:var(--success); }
.status-pill.rejected{ background: rgba(255,92,114,.14); color:var(--danger); }

/* ===== پروفایل ===== */
.profile-head{ display:flex; align-items:center; gap:14px; margin-bottom:16px; }
.avatar{ width:56px; height:56px; border-radius:16px; background: var(--grad); display:flex; align-items:center; justify-content:center; font-size:24px; color:#fff; font-weight:800; }
.profile-head .name{ font-size:15px; font-weight:800; }
.profile-head .uid{ font-size:11px; color:var(--tg-hint); direction:ltr; text-align:right; }

.stat-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; margin-bottom:16px; }
.stat-box{ background: var(--card-bg); border:1px solid var(--card-border); border-radius: var(--radius-md); padding:14px; }
.stat-box .k{ font-size:10.5px; color:var(--tg-hint); margin-bottom:6px; }
.stat-box .v{ font-size:15px; font-weight:800; }

.menu-list{ display:flex; flex-direction:column; gap:8px; }
.menu-item{
  display:flex; align-items:center; gap:12px; background: var(--card-bg); border:1px solid var(--card-border);
  border-radius: var(--radius-md); padding:13px 16px; cursor:pointer;
}
.menu-item .ico{ font-size:17px; width:22px; text-align:center; }
.menu-item .t{ font-size:12.5px; font-weight:700; flex:1; }

/* ===== تب‌بار ===== */
.tabbar{
  position: fixed; bottom:0; right:0; left:0; z-index: 30;
  display:flex; background: var(--tg-secondary-bg); border-top:1px solid var(--card-border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  backdrop-filter: blur(10px);
}
.tab-btn{
  flex:1; display:flex; flex-direction:column; align-items:center; gap:3px;
  background:none; border:none; padding:8px 2px; color: var(--tg-hint); cursor:pointer; font-size:10px; font-weight:700;
}
.tab-btn .tab-ico{ font-size:19px; filter: grayscale(1); opacity:.7; }
.tab-btn.active{ color: var(--tg-text); }
.tab-btn.active .tab-ico{ filter:none; opacity:1; }

/* ===== toast ===== */
.toast{
  position: fixed; top: 14px; left:50%; transform: translateX(-50%) translateY(-140%);
  background: #1b1e33; color:#fff; padding: 12px 18px; border-radius: 999px; font-size:12.5px; font-weight:700;
  z-index: 200; box-shadow: var(--shadow-soft); transition: transform .25s ease; max-width: 88vw; text-align:center;
  border: 1px solid rgba(255,255,255,.1);
}
.toast.show{ transform: translateX(-50%) translateY(0); }
.toast.err{ background: #3a1420; color:#ff8a9a; border-color: rgba(255,92,114,.3); }
.toast.ok{ background: #12331f; color:#7be3a4; border-color: rgba(46,204,113,.3); }
