/* ─────────────────────────────────────────────────────────────
   مینی‌اپ بی‌مرز — روی theme.css سوار است
   ───────────────────────────────────────────────────────────── */

body {
  padding-bottom: max(env(safe-area-inset-bottom), 20px);
}

/* ───────────────────────── بارگذاری ───────────────────────── */

.boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  background: var(--bg);
}
/* سه میله‌ی سیگنال — استعاره‌ی اتصال، نه اسپینر عمومی */
.boot-mark { display: flex; align-items: flex-end; gap: 5px; height: 30px; }
.boot-mark span {
  width: 5px;
  border-radius: var(--r-pill);
  background: var(--accent);
  animation: signal 1.1s ease-in-out infinite;
}
.boot-mark span:nth-child(1) { height: 12px; animation-delay: 0s; }
.boot-mark span:nth-child(2) { height: 21px; animation-delay: .15s; }
.boot-mark span:nth-child(3) { height: 30px; animation-delay: .3s; }
@keyframes signal {
  0%, 100% { opacity: .25; transform: scaleY(.55); }
  50%      { opacity: 1;   transform: scaleY(1); }
}
.boot-text { color: var(--muted); font-size: .88rem; }

.boot-fail { text-align: center; padding: 0 var(--s5); max-width: 380px; }
.boot-fail .glyph { font-size: 2.4rem; margin-bottom: var(--s3); }
.boot-fail h3 { margin-bottom: var(--s2); }
.boot-fail p { color: var(--muted); font-size: .88rem; line-height: 2; }
.boot-fail .btn { margin-top: var(--s4); }

/* ───────────────────────── پوسته ───────────────────────── */

/* نوار بالا ثابت، محتوا اسکرول می‌شود، نوار پایین ثابت.
   این شکل استاندارد اپ موبایل است و انگشت به همه‌جا می‌رسد. */
.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.bar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  padding-top: max(var(--s3), env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.bar-title {
  font-size: 1.02rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* فلش برگشت در RTL باید به راست اشاره کند */
:dir(rtl) #backBtn svg { transform: scaleX(-1); }

.view {
  flex: 1;
  padding: var(--s4);
  padding-bottom: calc(var(--s6) + 68px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.nav-bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 50;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--faint);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color .16s;
}
.nav-btn.is-on { color: var(--accent); }
.nav-ico { width: 21px; height: 21px; }
.nav-label { font-size: .68rem; font-weight: 600; }

.head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s4);
}

.who { display: flex; align-items: center; gap: 11px; min-width: 0; }
.avatar {
  width: 42px; height: 42px;
  flex: none;
  border: 0;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
}
/* در نوار بالا جمع‌وجورتر است تا جای عنوان را نگیرد */
.bar .avatar { width: 34px; height: 34px; font-size: .9rem; }
.who-text { min-width: 0; }
.who-name {
  font-weight: 700;
  font-size: .98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.who-sub { font-size: .74rem; color: var(--faint); }

.icon-btn {
  width: 38px; height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--accent); }

/* کیف پول در هدر — تنها جایی که «برجسته» می‌شود */
.purse {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s4);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
/* یک نوار باریک اکسنت به‌جای گرادیان تمام‌صفحه */
.purse::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 3px;
  background: var(--accent);
}
.purse-row { display: flex; align-items: center; justify-content: space-between; }
.purse-value {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 2px 0 var(--s2);
}
.purse-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  font-size: .8rem;
  color: var(--muted);
  padding-top: var(--s2);
  border-top: 1px solid var(--line);
}
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

/* ───────────────── کنترل بخش‌بندی (سوییچ افقی) ───────────────── */

.seg {
  display: flex;
  gap: 2px;
  background: var(--surface-sunk);
  border-radius: var(--r-md);
  padding: 3px;
}
.seg-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  padding: 8px 4px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .18s, color .18s;
}
.seg-btn.is-on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ───────────────────────── فهرست کنشی ───────────────────────── */

.list { display: flex; flex-direction: column; gap: 2px; }

.list-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: start;
  padding: 13px var(--s3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .15s;
}
.list-item:hover { background: var(--surface-2); }
.list-item.is-danger .list-title { color: var(--danger); }

.list-ico {
  width: 34px; height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  font-size: 1rem;
}
.list-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.list-title { font-size: .92rem; font-weight: 600; }
.list-note {
  font-size: .75rem;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-chev { color: var(--faint); font-size: 1.2rem; line-height: 1; }
:dir(rtl) .list-chev { transform: none; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  margin-top: var(--s3);
}

/* ───────────────────────── کارت سرویس ───────────────────────── */

.svc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s4);
  cursor: pointer;
  transition: border-color .16s, box-shadow .16s;
}
.svc:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.svc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: 10px;
}
.svc-name { font-weight: 700; font-size: .96rem; }
.svc-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px var(--s4);
  font-size: .8rem;
  color: var(--muted);
}
.svc-facts b { color: var(--ink-2); font-weight: 600; }
.svc .meter { margin-top: 12px; }

/* ───────────────────────── کارت پلن ───────────────────────── */

.plan {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s4);
}
.plan-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
}
.plan-name { font-weight: 700; font-size: .98rem; }
.plan-where { font-size: .76rem; color: var(--faint); margin-top: 1px; }
.plan-price {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
}
.plan-specs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  margin: var(--s3) 0;
}
.spec { background: var(--surface-2); padding: 9px 6px; text-align: center; }
.spec-k { display: block; font-size: .68rem; color: var(--faint); }
.spec-v { font-size: .88rem; font-weight: 700; }
.spec-countries { grid-column: 1 / -1; text-align: start; display: flex;
  align-items: baseline; justify-content: space-between; gap: 10px; }
.spec-countries .spec-v { overflow-wrap: anywhere; text-align: end; }
.plan-top { flex-wrap: wrap; }
.plan-top .grow { min-width: 110px; }
.plan-price { white-space: nowrap; }
.plan-btn { transition: border-color .15s; }
.plan-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ───────────────────────── تراکنش ───────────────────────── */

.tx { display: flex; align-items: center; gap: var(--s3); padding: 11px 0; border-bottom: 1px solid var(--line); }
.tx:last-child { border-bottom: 0; }
.tx-mark {
  width: 30px; height: 30px;
  flex: none;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font-size: .95rem;
  font-weight: 700;
}
.tx-in  { background: var(--ok-soft); color: var(--ok); }
.tx-out { background: var(--danger-soft); color: var(--danger); }
.tx-text { flex: 1; min-width: 0; }
.tx-what { font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-when { font-size: .72rem; color: var(--faint); }
.tx-amt { font-size: .88rem; font-weight: 700; white-space: nowrap; }
.tx-amt.plus  { color: var(--ok); }
.tx-amt.minus { color: var(--ink-2); }

/* ───────────────────────── نمایندگی ───────────────────────── */

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 13px;
}
.kpi-k { font-size: .72rem; color: var(--faint); }
.kpi-v { font-size: 1.05rem; font-weight: 800; margin-top: 1px; }
.kpi-v.is-ok { color: var(--ok); }
.kpi-v.is-danger { color: var(--danger); }

.cust { display: flex; align-items: center; gap: var(--s3); padding: 11px 0; border-bottom: 1px solid var(--line); }
.cust:last-child { border-bottom: 0; }
.cust-text { flex: 1; min-width: 0; }
.cust-name { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-meta { font-size: .74rem; color: var(--muted); }

/* ───────────────────────── جزئیات در شیت ───────────────────────── */

.kv { display: flex; justify-content: space-between; gap: var(--s3); padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.kv:last-of-type { border-bottom: 0; }
.kv-k { color: var(--muted); }
.kv-v { font-weight: 600; text-align: left; }

.sub-link {
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 12px;
  font-family: var(--mono);
  font-size: .72rem;
  line-height: 1.8;
  direction: ltr;
  text-align: left;
  word-break: break-all;
  max-height: 88px;
  overflow-y: auto;
}

.sheet-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }

/* ───────────────────────── خانه ───────────────────────── */

.hero { display: flex; flex-direction: column; gap: var(--s3); }

.hero-who { display: flex; align-items: center; gap: 11px; min-width: 0; }
.hero-hi { font-size: .78rem; color: var(--faint); }
.hero-name { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; }

/* شبکه‌ی میان‌بر — دسترسی یک‌ضربه‌ای به کارهای پرتکرار */
.tile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.tile {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 13px 4px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.tile:hover { background: var(--surface-2); border-color: var(--line-strong); }
.tile-ico { font-size: 1.25rem; line-height: 1; }
.tile-label { font-size: .7rem; font-weight: 600; color: var(--ink-2); text-align: center; }

/* هشدارها: سرویسی که دارد تمام می‌شود */
.alert {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 11px var(--s3);
  border-radius: var(--r-md);
  border: 1px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  font-size: .84rem;
}
.alert.is-danger { border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent); }
.alert-text { flex: 1; min-width: 0; }

/* ───────────────────────── ساخت سرویس سفارشی ───────────────────────── */

.builder { display: flex; flex-direction: column; gap: var(--s4); }

.dial { display: flex; flex-direction: column; gap: var(--s2); }
.dial-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
}
.dial-label { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.dial-value { font-size: 1.05rem; font-weight: 800; color: var(--accent); }

/* اسلایدر باید در هر دو تم دیده شود، پس رنگ‌ها از توکن می‌آیند */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
  direction: ltr;
}
.range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-sunk);
}
.range::-moz-range-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-sunk);
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
}
.range::-moz-range-thumb {
  width: 22px; height: 22px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
}
.range:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.dial-scale {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  color: var(--faint);
}

/* ریز محاسبات قیمت */
.breakdown { display: flex; flex-direction: column; gap: 7px; }
.bd-row { display: flex; justify-content: space-between; font-size: .82rem; }
.bd-row.is-off { color: var(--ok); }
.bd-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: var(--s3);
  margin-top: var(--s2);
  border-top: 1px solid var(--line);
}
.bd-total .num { font-size: 1.3rem; font-weight: 800; }

/* ───────────────────────── پرداخت ───────────────────────── */

.pay-opt {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: start;
  padding: 13px var(--s3);
  border-radius: var(--r-md);
  cursor: pointer;
}
.pay-opt:disabled { opacity: .5; cursor: not-allowed; }
.pay-opt.is-on { border-color: var(--accent); background: var(--accent-soft); }
.pay-ico { font-size: 1.3rem; }
.pay-text { flex: 1; }
.pay-name { font-size: .92rem; font-weight: 600; }
.pay-note { font-size: .74rem; color: var(--faint); }

/* ریزنوشته‌ی کارمزد: عمداً کم‌رنگ‌تر و ریزتر از توضیح روش پرداخت،
   ولی نه آن‌قدر که خوانده نشود — این متن یک افشای مالی است. */
.pay-fee {
  display: block;
  margin-top: 4px;
  font-size: .72rem;
  line-height: 1.7;
  color: var(--warn, var(--muted));
}

/* شماره کارت و آدرس کیف — باید یک‌ضربه کپی شوند */
.copy-field {
  display: flex;
  align-items: center;
  gap: var(--s2);
  background: var(--surface-sunk);
  border-radius: var(--r-md);
  padding: 11px var(--s3);
}
.copy-val {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: .95rem;
  direction: ltr;
  text-align: left;
  overflow-wrap: anywhere;
}

.qr-box {
  background: #fff;
  padding: 10px;
  border-radius: var(--r-md);
  line-height: 0;
  align-self: center;
}

/* آپلود رسید */
.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  padding: var(--s5) var(--s4);
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  cursor: pointer;
}
.dropzone.is-set { border-style: solid; border-color: var(--ok); color: var(--ok); }
.dropzone img { max-height: 180px; border-radius: var(--r-sm); margin-top: var(--s3); }

/* ───────────────────────── تیکت ───────────────────────── */

.chat { display: flex; flex-direction: column; gap: var(--s2); }
.msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: var(--r-md);
  font-size: .87rem;
  line-height: 1.9;
  overflow-wrap: anywhere;
}
.msg-me { align-self: flex-start; background: var(--accent); color: var(--accent-ink); }
.msg-them { align-self: flex-end; background: var(--surface-sunk); }
.msg-when { font-size: .68rem; opacity: .7; display: block; margin-top: 3px; }

.composer { display: flex; gap: var(--s2); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 42px; max-height: 120px; }

/* ───────────────────────── مشتریان نماینده ───────────────────────── */

.search-row { display: flex; gap: var(--s2); }
.search-row .input { flex: 1; }

.cust-list { display: flex; flex-direction: column; gap: var(--s2); }

/* ───────────────────────── فروشگاه ───────────────────────── */

/* نوار دسته‌بندی: وقتی دسته‌ها از عرض صفحه بیشتر شوند باید بلغزد،
   نه اینکه هر برچسب فشرده و ناخوانا شود */
.seg-x { overflow-x: auto; scrollbar-width: none; }
.seg-x::-webkit-scrollbar { display: none; }
.seg-x .seg-btn { flex: 0 0 auto; padding-inline: 14px; white-space: nowrap; }

/* کارت پلن به‌صورت دکمه، تا تمام کارت هدف انگشت باشد.
   محتوایش با span ساخته می‌شود (div داخل button معتبر نیست)، پس
   خطوطی که باید زیر هم بیایند اینجا بلوک می‌شوند. */
.plan-btn {
  display: block;
  width: 100%;
  text-align: start;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.plan-btn:disabled { opacity: .55; cursor: not-allowed; }
.plan-btn .plan-name,
.plan-btn .plan-where { display: block; }
.plan-btn .hint { display: block; margin-top: 2px; }

/* همان دلیل، برای دکمه‌ی روش پرداخت */
.pay-opt .pay-text { display: flex; flex-direction: column; }

/* ستون پایانی ردیف سفارش: وضعیت بالا، مبلغ زیر آن */
.ord-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex: none;
}
.ord-end .num { font-size: .74rem; color: var(--muted); }

/* ردیف تراکنشی که جزئیاتش باز می‌شود — همان بازخورد لمسی بقیه‌ی ردیف‌های کنشی */
.tx-tap { cursor: pointer; }
.tx-tap:active { opacity: .55; }

/* جدول پیش‌نمایش قیمت نماینده: باید روی عرض ۳۷۵ پیکسل جا شود، وگرنه
   «فروش شما» و «سود شما» — همان دو عددی که تصمیم نماینده به آن‌هاست —
   بیرون کادر می‌افتند. به همین دلیل قیمت پایه به زیر نام پلن رفته و واحد
   پول یک بار زیر جدول می‌آید تا در هر خانه تکرار نشود. */
.price-table { font-size: .74rem; }
.price-table th {
  /* سرستون دو کلمه‌ای زیر هم می‌شکند تا ستون به عرض عدد باشد، نه به عرض عنوان */
  white-space: normal;
  line-height: 1.4;
  padding: 0 4px 6px;
}
.price-table td { padding: 10px 4px; vertical-align: top; }
.price-table td.is-cost { color: var(--muted); }
.price-table td.is-profit { color: var(--ok); font-weight: 700; }
.price-table th:first-child,
.price-table td:first-child { padding-inline-start: 0; }
.price-table td:first-child { white-space: normal; }
.price-table td:first-child .hint { font-size: .68rem; }

/* سرتیتر مرحله‌های ساخت سرویس؛ شماره باید از خود عنوان جدا دیده شود */
.step-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.step-no {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--surface-sunk);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
}
.step-head.is-done .step-no { background: var(--ok-soft); color: var(--ok); }


/* مبلغِ پرداختی در صفحه‌ی درگاه — عددی که کاربر باید ببیند و با
   عددِ صفحه‌ی پرداخت مقایسه کند، پس از بقیه بزرگ‌تر است */
.money-lg {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent, currentColor);
}
.ref-form { display: flex; flex-direction: column; gap: 14px; }
.ref-form > label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; }
.ref-form > .ref-toggle { flex-direction: row; align-items: center; gap: 8px; }
.ref-form textarea { resize: vertical; min-height: 96px; font: inherit; }
.ref-rules > summary { cursor: pointer; font-weight: 600; }
