/* ==========================================================================
   پنل معرف — دیده‌شو
   بدون هیچ وابستگیِ بیرونی (CDN/فونتِ ریموت) تا پشتِ فیلتر هم بالا بیاید.
   فونت از سیستم/سایت می‌آید؛ اگر Vazirmatn نصب نبود، پشته‌ی fallback خواناست.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* بوم */
  --bg: #f4f5fb;
  --bg-tint: #eceefb;
  --surface: #ffffff;
  --surface-2: #f6f7fc;
  --surface-3: #eef0f9;
  --border: #e3e6f2;
  --border-strong: #d2d7ea;

  /* متن */
  --text: #16192b;
  --text-2: #5a6076;
  --muted: #8b90a6;

  /* رنگِ برند — بنفشِ نیلی به فیروزه‌ای */
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-ink: #ffffff;
  --brand-weak: #eeecff;
  --accent: #0ea5a5;
  --accent-weak: #e2f6f4;

  --success: #0f9d58;
  --success-weak: #e6f6ee;
  --warning: #b4740b;
  --warning-weak: #fdf3e0;
  --danger: #d92d20;
  --danger-weak: #fdeceb;

  --radius-xl: 22px;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(16, 20, 45, .05);
  --shadow: 0 2px 4px rgba(16, 20, 45, .04), 0 12px 32px -12px rgba(16, 20, 45, .16);
  --shadow-lg: 0 24px 60px -24px rgba(46, 40, 120, .38);

  --ring: 0 0 0 3px rgba(79, 70, 229, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d17;
    --bg-tint: #10132250;
    --surface: #151827;
    --surface-2: #1b1f31;
    --surface-3: #232840;
    --border: #262b42;
    --border-strong: #333952;

    --text: #eceefb;
    --text-2: #a8aec7;
    --muted: #767c96;

    --brand: #8b83ff;
    --brand-2: #a78bfa;
    --brand-ink: #12142a;
    --brand-weak: #1e1c3d;
    --accent: #2dd4bf;
    --accent-weak: #10312f;

    --success: #3ecf8e;
    --success-weak: #102a1f;
    --warning: #e0a84a;
    --warning-weak: #2e2410;
    --danger: #f97066;
    --danger-weak: #351b1b;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow: 0 2px 4px rgba(0, 0, 0, .4), 0 12px 32px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, .8);
    --ring: 0 0 0 3px rgba(139, 131, 255, .22);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  background:
    radial-gradient(900px 420px at 100% -10%, var(--bg-tint), transparent 65%),
    radial-gradient(700px 380px at -10% 8%, var(--accent-weak), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: Vazirmatn, "Vazir", "IRANSansX", "IRANSans", "Segoe UI", Tahoma, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.45; letter-spacing: -.01em; }
h1 { font-size: 21px; }
h2 { font-size: 16px; }
p { margin: 0 0 8px; }
b, strong { font-weight: 700; }

.muted { color: var(--muted); font-size: 12px; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: right; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

::selection { background: var(--brand); color: var(--brand-ink); }

/* ==========================================================================
   ورود
   ========================================================================== */

.auth {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}

/* هالهٔ رنگیِ پس‌زمینه. `filter: blur` روی یک لایهٔ جدا می‌نشیند تا متنِ کارت
   هرگز نرم نشود. */
.auth__aurora {
  position: absolute;
  inset: -25%;
  background:
    radial-gradient(closest-side, #7c3aed55, transparent) 18% 22% / 46% 46% no-repeat,
    radial-gradient(closest-side, #0ea5a555, transparent) 78% 30% / 42% 42% no-repeat,
    radial-gradient(closest-side, #4f46e544, transparent) 50% 82% / 52% 52% no-repeat;
  filter: blur(46px);
  animation: drift 22s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .auth__aurora { animation: none; }
}

.auth__card {
  position: relative;
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 28px 24px 22px;
}

.auth__brand { text-align: center; margin-bottom: 20px; }
.auth__logo {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 10px;
  font-size: 27px;
  border-radius: 18px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 24px -10px var(--brand);
}
.auth__hint { font-size: 13px; color: var(--text-2); text-align: center; }
.auth__error {
  margin: 12px 0 0;
  padding: 9px 12px;
  background: var(--danger-weak);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: center;
}

.input--code {
  text-align: center;
  letter-spacing: .5em;
  font-size: 20px;
  font-weight: 700;
  padding-inline-start: .5em;
}

/* ==========================================================================
   پوسته
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__brand small { display: block; line-height: 1.2; }
.topbar__logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-size: 18px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
}
.topbar__side { display: flex; align-items: center; gap: 10px; }
.topbar__user { font-size: 12px; color: var(--text-2); direction: ltr; }

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 20px 16px 64px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ==========================================================================
   کارتِ دعوت (قهرمانِ صفحه)
   ========================================================================== */

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 24px;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 46%, #0ea5a5 130%);
  box-shadow: var(--shadow-lg);
}

/* بافتِ نرمِ روی گرادیان — بدون تصویر، فقط دو گرادیانِ شعاعی */
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(closest-side, rgba(255, 255, 255, .22), transparent) 88% -10% / 46% 120% no-repeat,
    radial-gradient(closest-side, rgba(255, 255, 255, .12), transparent) 8% 120% / 40% 130% no-repeat;
  pointer-events: none;
}

.hero > * { position: relative; z-index: 1; }

.hero__title { font-size: 19px; margin-bottom: 2px; }
.hero__sub { color: rgba(255, 255, 255, .78); font-size: 13px; margin-bottom: 18px; }

.hero__codebox {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .22);
  backdrop-filter: blur(6px);
}

.hero__code {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: .18em;
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}

.hero__links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.hero__rate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .24);
  font-size: 13px;
}
.hero__rate--none { background: rgba(0, 0, 0, .2); }

/* ==========================================================================
   کاشی‌های آمار
   ========================================================================== */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px;
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

/* نوارِ رنگیِ بالای کاشی — امضای بصریِ هر معیار */
.stat::before {
  content: '';
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}
.stat--accent::before { background: linear-gradient(90deg, var(--accent), #22d3ee); }
.stat--success::before { background: linear-gradient(90deg, var(--success), #6ee7b7); }
.stat--warning::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }

.stat__head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.stat__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--brand-weak);
  font-size: 15px;
}
.stat--accent .stat__icon { background: var(--accent-weak); }
.stat--success .stat__icon { background: var(--success-weak); }
.stat--warning .stat__icon { background: var(--warning-weak); }

.stat__label { font-size: 12px; color: var(--text-2); }
.stat__value {
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1.3;
}
.stat__unit { font-size: 12px; font-weight: 500; color: var(--muted); margin-inline-start: 4px; }
.stat__foot { font-size: 11.5px; color: var(--muted); }

/* ==========================================================================
   کارتِ عمومی
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card__body { padding: 16px; }
.card__body--flush { padding: 0; }

/* ==========================================================================
   نمودارِ میله‌ای (بدونِ کتابخانه)
   ========================================================================== */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 148px;
  padding: 8px 2px 0;
}

.chart__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.chart__bar {
  width: 100%;
  max-width: 46px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  transition: height .5s cubic-bezier(.22, 1, .36, 1);
  position: relative;
}
.chart__bar--empty { background: var(--surface-3); }

.chart__col:hover .chart__bar { filter: brightness(1.1); }

.chart__label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chart__value { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   تب‌ها
   ========================================================================== */

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1;
  min-width: max-content;
  padding: 8px 16px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s ease, color .18s ease;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  background: var(--surface);
  color: var(--brand);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.tab__count {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.tab.is-active .tab__count { background: var(--brand-weak); color: var(--brand); }

/* ==========================================================================
   ردیف‌ها
   ========================================================================== */

.rows { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .15s ease;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }

.row__media {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface-3);
  border: 1px solid var(--border);
}

.row__avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--brand-weak), var(--accent-weak));
  color: var(--brand);
  font-weight: 800;
  font-size: 15px;
}

.row__main { flex: 1; min-width: 0; }
.row__title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row__sub { font-size: 12px; color: var(--muted); }

.row__metric { flex: none; text-align: left; }
.row__metric b {
  display: block;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.row__metric span { font-size: 11px; color: var(--muted); }

/* ==========================================================================
   تراشه‌ها و نشان‌ها
   ========================================================================== */

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge--brand { background: var(--brand-weak); color: var(--brand); }
.badge--success { background: var(--success-weak); color: var(--success); }
.badge--warning { background: var(--warning-weak); color: var(--warning); }
.badge--danger { background: var(--danger-weak); color: var(--danger); }

/* ==========================================================================
   دکمه و فرم
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: 0; box-shadow: var(--ring); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn--primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px -10px var(--brand);
}
.btn--primary:hover { filter: brightness(1.06); background: linear-gradient(135deg, var(--brand), var(--brand-2)); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }

/* دکمه‌های روی گرادیانِ hero — شیشه‌ای، نه سفیدِ تخت */
.btn--glass {
  background: rgba(255, 255, 255, .16);
  border-color: rgba(255, 255, 255, .3);
  color: #fff;
}
.btn--glass:hover { background: rgba(255, 255, 255, .26); }

.btn--sm { padding: 6px 12px; font-size: 12px; }
.btn--block { width: 100%; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus { outline: 0; border-color: var(--brand); box-shadow: var(--ring); }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select { width: auto; min-width: 150px; padding: 7px 10px; font-size: 13px; border-radius: var(--radius-pill); }

/* ==========================================================================
   حالت‌ها
   ========================================================================== */

.empty {
  text-align: center;
  padding: 42px 20px;
  color: var(--muted);
}
.empty__icon { font-size: 34px; display: block; margin-bottom: 8px; opacity: .65; }
.empty b { display: block; color: var(--text-2); font-size: 14px; margin-bottom: 4px; }

/* اسکلتِ بارگذاری — درخششِ ملایم به‌جای اسپینر، چون چیدمانِ نهایی از همان
   لحظهٔ اول سرِ جایش است و صفحه هنگام آمدنِ داده نمی‌پرد. */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

.skeleton--stat { height: 104px; }
.skeleton--hero { height: 196px; border-radius: var(--radius-xl); }
.skeleton--row { height: 62px; margin-bottom: 1px; }

/* ==========================================================================
   توست
   ========================================================================== */

.toasts {
  position: fixed;
  inset-block-end: max(18px, env(safe-area-inset-bottom));
  inset-inline-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
  pointer-events: none;
}

.toast {
  padding: 11px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--brand);
  box-shadow: var(--shadow);
  font-size: 13px;
  transition: opacity .2s ease, transform .2s ease;
  animation: toast-in .24s cubic-bezier(.22, 1, .36, 1);
}
.toast--success { border-inline-start-color: var(--success); }
.toast--error { border-inline-start-color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ==========================================================================
   موبایل
   ========================================================================== */

@media (max-width: 640px) {
  .page { padding: 14px 12px 56px; gap: 14px; }
  .hero { padding: 20px 18px; border-radius: var(--radius); }
  .hero__code { font-size: 21px; letter-spacing: .14em; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 13px; }
  .stat__value { font-size: 20px; }
  .row { padding: 11px 13px; gap: 10px; }
  .row__media, .row__avatar { width: 40px; height: 40px; }
  .chart { height: 120px; gap: 6px; }
  .topbar__user { display: none; }
}
