/* ==========================================================================
   بانک‌رادار — سیستم طراحی
   لایه‌ها: توکن‌ها ← پایه ← چیدمان ← اجزا ← نمودار ← واکنش‌گرا ← چاپ
   ========================================================================== */

/* ---------- ۱. توکن‌های طراحی ---------- */
:root {
  color-scheme: dark;

  /* پالت پایه */
  --ink-900: #05070f;
  --ink-850: #070b17;
  --ink-800: #0a0f20;
  --ink-750: #0e1428;
  --ink-700: #131a33;
  --ink-600: #1b2444;

  /* سطوح شیشه‌ای */
  --surface-1: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.09);
  --surface-4: rgba(255, 255, 255, 0.13);
  --hairline: rgba(255, 255, 255, 0.1);
  --hairline-strong: rgba(255, 255, 255, 0.18);

  /* متن */
  --text-1: #f2f6ff;
  --text-2: #c3cfe4;
  --text-3: #8f9fbb;
  --text-4: #6b7a96;

  /* رنگ‌های معنایی */
  --brand: #2fe0a8;
  --brand-dim: #1aa87c;
  --brand-soft: rgba(47, 224, 168, 0.13);
  --brand-line: rgba(47, 224, 168, 0.32);

  --accent: #7c8cff;
  --accent-soft: rgba(124, 140, 255, 0.14);
  --accent-line: rgba(124, 140, 255, 0.32);

  --warn: #f6c66b;
  --warn-soft: rgba(246, 198, 107, 0.13);
  --warn-line: rgba(246, 198, 107, 0.32);

  --danger: #ff6b81;
  --danger-soft: rgba(255, 107, 129, 0.13);
  --danger-line: rgba(255, 107, 129, 0.32);

  --info: #63c8ff;
  --info-soft: rgba(99, 200, 255, 0.13);

  /* دسته‌بندی محصولات */
  --cat-deposits: #2fe0a8;
  --cat-credit: #7c8cff;
  --cat-loans: #f6c66b;
  --cat-loyalty: #ff8fb0;
  --cat-funds: #00d2ff;

  /* تایپوگرافی */
  --font-sans: 'Vazirmatn', 'IRANSansX', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --font-mono: 'Vazirmatn Code', ui-monospace, 'SF Mono', Menlo, monospace;

  --fs-3xs: 0.6875rem;
  --fs-2xs: 0.75rem;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 1.9375rem;
  --fs-4xl: 2.5rem;

  /* فاصله‌گذاری (مقیاس ۴) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;

  /* شعاع */
  --r-xs: 0.5rem;
  --r-sm: 0.75rem;
  --r-md: 1rem;
  --r-lg: 1.25rem;
  --r-xl: 1.75rem;
  --r-full: 999px;

  /* سایه */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.65);
  --shadow-xl: 0 40px 100px -30px rgba(0, 0, 0, 0.8);
  --glow-brand: 0 0 0 1px var(--brand-line), 0 12px 40px -14px rgba(47, 224, 168, 0.5);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 140ms;
  --dur: 220ms;
  --dur-slow: 420ms;

  --header-h: 68px;
}

/* ---------- ۲. پایه ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--sp-4));
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.75;
  color: var(--text-1);
  background: var(--ink-900);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01' 1, 'ss02' 1;
}

/* پس‌زمینه لایه‌ای */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 55% at 82% -8%, rgba(124, 140, 255, 0.24), transparent 60%),
    radial-gradient(ellipse 70% 50% at 12% 4%, rgba(47, 224, 168, 0.17), transparent 58%),
    radial-gradient(ellipse 100% 60% at 50% 108%, rgba(124, 140, 255, 0.1), transparent 62%),
    linear-gradient(178deg, var(--ink-850) 0%, var(--ink-900) 55%, #030509 100%);
}

/* بافت ظریف */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.032'/%3E%3C/svg%3E");
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

a {
  color: var(--brand);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color var(--dur-fast) var(--ease);
}
a:hover { color: #7bffd0; text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection { background: var(--brand-soft); color: #fff; }

/* نوار اسکرول */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.03); }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); background-clip: padding-box; }

/* ---------- ۳. اعداد و متن ---------- */
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  letter-spacing: -0.01em;
}

.eyebrow {
  font-size: var(--fs-3xs);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-4);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--sp-4);
  top: -100px;
  z-index: 200;
  padding: var(--sp-3) var(--sp-5);
  background: var(--brand);
  color: var(--ink-900);
  font-weight: 700;
  border-radius: var(--r-sm);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--sp-4); }

/* ---------- ۴. چیدمان ---------- */
.shell {
  width: min(100% - 2 * var(--sp-5), 1480px);
  margin-inline: auto;
  padding-block: var(--sp-6) var(--sp-12);
}

.stack { display: flex; flex-direction: column; }
.stack-2 { gap: var(--sp-2); }
.stack-3 { gap: var(--sp-3); }
.stack-4 { gap: var(--sp-4); }
.stack-6 { gap: var(--sp-6); }

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.row-between { justify-content: space-between; }

.panel {
  background: linear-gradient(160deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}

.panel-pad { padding: var(--sp-5); }

.main-grid {
  display: grid;
  grid-template-columns: 302px minmax(0, 1fr);
  gap: var(--sp-5);
  align-items: start;
}
.main-grid > * { min-width: 0; }

/*
  ستون محتوا. بدون min-width: 0، آیتم شبکه به‌طور پیش‌فرض min-width: auto
  می‌گیرد و جدول‌های عریض مقایسه، چیدمان را از قاب بیرون می‌زنند.
*/
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

/* ---------- ۵. نوار بالا ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding-inline: var(--sp-5);
  background: rgba(6, 9, 20, 0.78);
  border-bottom: 1px solid var(--hairline);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
  color: inherit;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--brand), var(--accent));
  color: var(--ink-900);
  font-size: 21px;
  box-shadow: 0 8px 22px -8px rgba(47, 224, 168, 0.7);
}

.brand-text b { display: block; font-size: var(--fs-md); line-height: 1.35; }
.brand-text span { display: block; font-size: var(--fs-3xs); color: var(--text-4); line-height: 1.4; }

.topbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  height: 42px;
  padding-inline: 42px var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-full);
  color: var(--text-1);
  font-size: var(--fs-sm);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.topbar-search input::placeholder { color: var(--text-4); }
.topbar-search input:focus {
  outline: none;
  border-color: var(--brand-line);
  background: var(--surface-2);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.topbar-search .icon {
  position: absolute;
  inset-inline-start: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  pointer-events: none;
  font-size: var(--fs-lg);
}

.search-suggestions {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 9px);
  z-index: 80;
  max-height: min(60vh, 420px);
  overflow: auto;
  padding: var(--sp-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-lg);
  background: rgba(11, 16, 31, 0.98);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
}
.search-suggestions[hidden] { display: none; }
.search-suggestion {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-1);
  text-align: start;
  cursor: pointer;
}
.search-suggestion:hover,
.search-suggestion[aria-selected="true"] {
  background: var(--surface-3);
  outline: none;
}
.search-suggestion__main { min-width: 0; display: grid; gap: 3px; }
.search-suggestion__name {
  overflow: hidden;
  color: var(--text-1);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-suggestion__meta {
  overflow: hidden;
  color: var(--text-4);
  font-size: var(--fs-3xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-suggestion__side { flex: 0 0 auto; display: grid; justify-items: end; gap: 3px; }
.search-suggestion__rate { color: var(--brand); font-size: var(--fs-xs); font-weight: 700; }
.search-suggestion__category { color: var(--text-4); font-size: var(--fs-3xs); }
.search-suggestions__empty {
  padding: var(--sp-4);
  color: var(--text-3);
  font-size: var(--fs-xs);
  text-align: center;
}

.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-2); }

.refresh-icon {
  display: inline-block;
  font-size: 1.1em;
  line-height: 1;
  transition: transform 0.2s ease;
}

.refresh-icon.is-spinning {
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 0 var(--brand-line);
  animation: pulse 2.4s ease-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 224, 168, 0.5); }
  70% { box-shadow: 0 0 0 9px rgba(47, 224, 168, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 224, 168, 0); }
}

/* ---------- ۶. دکمه‌ها ---------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text-1);
  --btn-line: var(--hairline);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0.6rem 1rem;
  min-height: 40px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-line);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--hairline-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.btn--primary {
  --btn-bg: linear-gradient(135deg, var(--brand), #45f0c0);
  --btn-fg: #04170f;
  --btn-line: transparent;
  font-weight: 700;
  box-shadow: 0 10px 28px -12px rgba(47, 224, 168, 0.75);
}
.btn--primary:hover { background: linear-gradient(135deg, #4ff0bd, #6bffe0); }

.btn--ghost { --btn-bg: transparent; --btn-line: transparent; --btn-fg: var(--text-2); }
.btn--ghost:hover { --btn-bg: var(--surface-2); --btn-fg: var(--text-1); }

.btn--danger { --btn-bg: var(--danger-soft); --btn-line: var(--danger-line); --btn-fg: #ffd3da; }
.btn--danger:hover { background: rgba(255, 107, 129, 0.22); }

.btn--sm { min-height: 32px; padding: 0.3rem 0.65rem; font-size: var(--fs-2xs); border-radius: var(--r-xs); }
.btn--icon { min-width: 40px; padding-inline: 0.6rem; }
.btn--block { width: 100%; }

.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  gap: 2px;
}
.seg button {
  padding: 0.4rem 0.8rem;
  background: transparent;
  border: 0;
  border-radius: calc(var(--r-sm) - 3px);
  color: var(--text-3);
  font-size: var(--fs-2xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.seg button:hover { color: var(--text-1); }
.seg button[aria-pressed='true'] {
  background: var(--surface-3);
  color: var(--text-1);
  box-shadow: var(--shadow-sm);
}

/* ---------- ۷. نشان‌ها ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-size: var(--fs-3xs);
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  line-height: 1.7;
}
.chip--good { background: var(--brand-soft); border-color: var(--brand-line); color: #9dffdc; }
.chip--warn { background: var(--warn-soft); border-color: var(--warn-line); color: #ffe6b5; }
.chip--bad { background: var(--danger-soft); border-color: var(--danger-line); color: #ffc4cd; }
.chip--info { background: var(--accent-soft); border-color: var(--accent-line); color: #d3d9ff; }
.chip--cat-deposits { background: rgba(47, 224, 168, 0.12); border-color: rgba(47, 224, 168, 0.3); color: #9dffdc; }
.chip--cat-credit { background: rgba(124, 140, 255, 0.12); border-color: rgba(124, 140, 255, 0.3); color: #d3d9ff; }
.chip--cat-loans { background: rgba(246, 198, 107, 0.12); border-color: rgba(246, 198, 107, 0.3); color: #ffe6b5; }
.chip--cat-loyalty { background: rgba(255, 143, 176, 0.12); border-color: rgba(255, 143, 176, 0.3); color: #ffd3e0; }
.chip--cat-funds { background: rgba(0, 210, 255, 0.12); border-color: rgba(0, 210, 255, 0.3); color: #7de8ff; }

/* ---------- ۸. بخش قهرمان ---------- */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: var(--sp-6);
  padding: var(--sp-8);
  overflow: hidden;
  border-radius: var(--r-xl);
}
.hero::before {
  content: '';
  position: absolute;
  inset-block-start: -55%;
  inset-inline-end: -12%;
  width: 420px; height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 224, 168, 0.2), transparent 68%);
  filter: blur(28px);
  pointer-events: none;
}
.hero::after {
  content: '';
  position: absolute;
  inset-block-end: -60%;
  inset-inline-start: -10%;
  width: 380px; height: 380px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 140, 255, 0.18), transparent 68%);
  filter: blur(30px);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }

.hero h1 {
  font-size: clamp(1.5rem, 1.1rem + 1.7vw, 2.35rem);
  line-height: 1.45;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-block: var(--sp-3) var(--sp-3);
  background: linear-gradient(112deg, #ffffff 8%, #b8ffe6 52%, #c8d2ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lead {
  color: var(--text-2);
  font-size: var(--fs-md);
  line-height: 2.05;
  max-width: 62ch;
}

.pill-live {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px 13px;
  border-radius: var(--r-full);
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  color: #a5ffe0;
  font-size: var(--fs-2xs);
  font-weight: 600;
}

/* نوار شاخص‌های کلان */
.macro-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: var(--sp-2);
  margin-block-start: var(--sp-5);
}
.macro-cell {
  padding: var(--sp-3);
  background: rgba(6, 10, 22, 0.55);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.macro-cell:hover { border-color: var(--hairline-strong); transform: translateY(-2px); }
.macro-cell .k { font-size: var(--fs-3xs); color: var(--text-4); display: block; margin-block-end: 2px; }
.macro-cell .v { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -0.02em; }

/* هشدار نرخ واقعی */
.real-rate-callout {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-block-start: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: linear-gradient(100deg, rgba(255, 107, 129, 0.11), rgba(255, 107, 129, 0.03));
  border: 1px solid var(--danger-line);
}
.real-rate-callout .ic { font-size: 1.3rem; line-height: 1.4; flex-shrink: 0; }
.real-rate-callout b { color: #ffd6de; font-size: var(--fs-md); }
.real-rate-callout p { color: var(--text-2); font-size: var(--fs-xs); line-height: 1.95; margin-block-start: 2px; }

/* پنل سلامت داده */
.health-list { display: grid; gap: var(--sp-2); }
.health-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: rgba(6, 10, 22, 0.5);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}
.health-row .lbl { font-size: var(--fs-2xs); color: var(--text-3); }
.health-row .val { font-size: var(--fs-lg); font-weight: 800; }
.health-row .val small { font-size: var(--fs-3xs); font-weight: 500; color: var(--text-4); margin-inline-start: 3px; }

.progress {
  height: 5px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width var(--dur-slow) var(--ease);
}
.progress--warn > i { background: linear-gradient(90deg, var(--warn), #ff9f6b); }
.progress--bad > i { background: linear-gradient(90deg, var(--danger), #ff9f6b); }

/* ---------- ۹. نوار فیلتر ---------- */
.filters {
  position: sticky;
  top: calc(var(--header-h) + var(--sp-4));
  max-height: calc(100vh - var(--header-h) - var(--sp-8));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--sp-5);
  scrollbar-width: thin;
}

/* دکمه‌های پروفایل نباید عرض ذاتی شبکه را در موبایل بزرگ کنند. */
.filters .seg { display: flex; flex-wrap: wrap; max-width: 100%; }

.filter-group + .filter-group {
  margin-block-start: var(--sp-5);
  padding-block-start: var(--sp-5);
  border-block-start: 1px solid var(--hairline);
}
.filter-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: var(--fs-2xs);
  font-weight: 700;
  color: var(--text-2);
  margin-block-end: var(--sp-3);
}
.filter-legend .reset {
  background: none;
  border: 0;
  color: var(--text-4);
  font-size: var(--fs-3xs);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--r-xs);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.filter-legend .reset:hover { color: var(--danger); background: var(--danger-soft); }

.field { display: block; }
.field + .field { margin-block-start: var(--sp-3); }
.field > label,
.field-label {
  display: block;
  font-size: var(--fs-3xs);
  font-weight: 600;
  color: var(--text-4);
  margin-block-end: 5px;
}

select,
input[type='text'],
input[type='number'],
input[type='url'],
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: rgba(5, 8, 18, 0.6);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-size: var(--fs-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
select {
  appearance: none;
  cursor: pointer;
  padding-inline-end: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238f9fbb' d='M1.4.6 6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.7rem center;
}
select option { background: var(--ink-750); color: var(--text-1); }
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-line);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { min-height: 130px; resize: vertical; direction: ltr; text-align: left; font-family: var(--font-mono); font-size: var(--fs-2xs); }

/* چک‌باکس سفارشی */
.check {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 8px;
  border-radius: var(--r-xs);
  font-size: var(--fs-2xs);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.check:hover { background: var(--surface-2); }
.check input { accent-color: var(--brand); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }

/* لغزنده وزن */
.weight { margin-block-end: var(--sp-3); }
.weight-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--fs-3xs);
  color: var(--text-3);
  margin-block-end: 3px;
}
.weight-head b { color: var(--brand); font-size: var(--fs-2xs); font-variant-numeric: tabular-nums; }

input[type='range'] {
  width: 100%;
  height: 4px;
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--r-full);
  cursor: pointer;
  margin: 6px 0;
}
input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--ink-800);
  box-shadow: 0 0 0 3px rgba(47, 224, 168, 0.2);
  transition: transform var(--dur-fast) var(--ease);
}
input[type='range']::-webkit-slider-thumb:hover { transform: scale(1.18); }
input[type='range']::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--ink-800);
  cursor: pointer;
}

/* ---------- ۱۰. برگه‌های دسته‌بندی ---------- */
/*
 * نوار دسته‌ها هنگام اسکرول در فهرست‌های بلند می‌چسبد (زیر نوار بالا) تا
 * جابه‌جایی میان دسته‌ها بدون بازگشت به بالای صفحه ممکن باشد. پس‌زمینهٔ
 * نیمه‌شفاف با blur، خوانایی محتوا را در حالت عبور حفظ می‌کند.
 */
.cat-tabs {
  position: sticky;
  top: var(--header-h);
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-block-end: var(--sp-4);
  padding-block: var(--sp-2);
  margin-block-start: calc(-1 * var(--sp-2));
  background: rgba(6, 9, 20, 0.72);
  border-radius: var(--r-md);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}
.cat-tab {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: start;
  color: var(--text-3);
  transition: all var(--dur) var(--ease);
  position: relative;
  overflow: hidden;
}
.cat-tab::before {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 3px;
  background: var(--tab-color, var(--brand));
  transform: scaleY(0);
  transition: transform var(--dur) var(--ease);
}
.cat-tab:hover { background: var(--surface-2); color: var(--text-1); border-color: var(--hairline-strong); }
.cat-tab[aria-selected='true'] {
  background: var(--surface-3);
  color: var(--text-1);
  border-color: var(--hairline-strong);
  box-shadow: var(--shadow-md);
}
.cat-tab[aria-selected='true']::before { transform: scaleY(1); }
.cat-tab .ic { font-size: 1.25rem; line-height: 1; }
.cat-tab .tt { font-size: var(--fs-2xs); font-weight: 700; line-height: 1.5; }
.cat-tab .ct { font-size: var(--fs-3xs); color: var(--text-4); }

/* ---------- ۱۱. نوار ابزار ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  margin-block-end: var(--sp-4);
  flex-wrap: wrap;
}
.toolbar .count { font-size: var(--fs-2xs); color: var(--text-3); }
.toolbar .count b { color: var(--text-1); font-size: var(--fs-sm); }
.toolbar-spacer { margin-inline-start: auto; }

/* ---------- ۱۲. کارت محصول ---------- */
/*
 * ارتفاع یکدست در هر ردیف:
 *
 * align-items: start (حالت پیشین) هر کارت را به ارتفاع محتوای خودش فشرده
 * می‌کرد؛ توضیحات طولانی یا برچسب‌های بیشتر، برخی کارت‌ها را بلندتر از
 * هم‌ردیفشان می‌کردند و شبکه نامنظم به نظر می‌رسید. با stretch (مقدار
 * پیش‌فرض گرید) همه کارت‌های یک ردیف هم‌ارتفاع می‌شوند و کارت خودش — که
 * ستون flex است — فاصلهٔ مازاد را به پاورقی (margin-block-start: auto)
 * واگذار می‌کند، پس دکمه‌ها و تاریخ کنترل همیشه در یک خط پایین‌دست می‌نشینند.
 */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--sp-4);
  align-items: stretch;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--sp-5);
  background: linear-gradient(165deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  transition: transform var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset-block-start: -70px;
  inset-inline-end: -70px;
  width: 170px; height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--card-accent, rgba(47, 224, 168, 0.16)), transparent 70%);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
  opacity: 0.85;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--hairline-strong);
  box-shadow: var(--shadow-lg);
}
.card:hover::before { opacity: 1; }
.card.is-compared { border-color: var(--brand-line); box-shadow: var(--glow-brand); }
.card.is-stale { opacity: 0.82; }

.card-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  position: relative;
  z-index: 1;
}
.card-logo {
  width: 44px; height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(140deg, var(--surface-4), var(--surface-2));
  border: 1px solid var(--hairline-strong);
  font-weight: 800;
  font-size: var(--fs-md);
  letter-spacing: -0.03em;
}
.card-title { min-width: 0; flex: 1; }
.card-title h3 {
  font-size: var(--fs-md);
  font-weight: 700;
  line-height: 1.6;
  margin: 0;
  letter-spacing: -0.01em;
}
.card-title .bank {
  font-size: var(--fs-2xs);
  color: var(--text-3);
  margin-block-start: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

/* حلقه امتیاز */
.score-ring {
  position: relative;
  width: 62px; height: 62px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.score-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.score-ring .track { stroke: rgba(255, 255, 255, 0.09); }
.score-ring .fill { transition: stroke-dashoffset var(--dur-slow) var(--ease); stroke-linecap: round; }
.score-ring .txt {
  position: relative;
  text-align: center;
  line-height: 1.1;
}
.score-ring .txt b { display: block; font-size: var(--fs-lg); font-weight: 800; letter-spacing: -0.03em; }
.score-ring .txt span { font-size: 9px; color: var(--text-4); }

/*
 * rate-hero — نرخ به‌عنوان اصلی‌ترین عدد کارت.
 *
 * پیش‌تر نرخ، سقف و مدت سه سلول هم‌اندازه بودند و نرخِ تعیین‌کنندهٔ تصمیم در
 * انبوهی از برچسب‌های ریز گم می‌شد. حالا نرخ درشت‌نویس با رنگ دسته نمایش
 * داده می‌شود و سقف/مدت به یک ستون فرعی کنارش می‌روند؛ اسکن عمودی فهرست
 * (مقایسهٔ چشمی نرخ‌ها) ممکن می‌شود.
 */
.rate-hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-block: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: rgba(4, 7, 16, 0.45);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}
.rate-main { display: grid; align-content: center; gap: 2px; min-width: 0; }
.rate-main .v {
  font-size: var(--fs-3xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--card-c, var(--brand));
}
.rate-main .k { font-size: var(--fs-3xs); color: var(--text-4); }
.rate-side {
  display: grid;
  align-content: center;
  gap: var(--sp-1);
  flex-shrink: 0;
  max-width: 58%;
}
.rate-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
}
.rate-stat .k { font-size: 10px; color: var(--text-4); white-space: nowrap; }
.rate-stat .v {
  font-size: var(--fs-2xs);
  font-weight: 700;
  line-height: 1.55;
  text-align: end;
  word-break: break-word;
  /* حداکثر دو خط: متن‌های بلند سقف («از ۱ میلیون تا ۲۵ میلیارد تومان») کارت را
     نمی‌کِشند؛ متن کامل در کشوی جزئیات هست. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-desc {
  font-size: var(--fs-xs);
  line-height: 1.95;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-block-end: var(--sp-3);
}

.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-block-end: var(--sp-3); }
.tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: #d5dbff;
  white-space: nowrap;
}
.tag-more {
  background: transparent;
  border-style: dashed;
  color: var(--text-4);
  cursor: help;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-block-start: auto;
  padding-block-start: var(--sp-3);
  border-block-start: 1px solid var(--hairline);
  flex-wrap: wrap;
}
.freshness {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-3xs);
  color: var(--text-4);
}
.freshness.good { color: #8fe9c4; }
.freshness.warn { color: var(--warn); }
.freshness.bad { color: var(--danger); }
.card-actions { display: flex; gap: var(--sp-2); }

/* ---------- ۱۳. رتبه‌بندی ---------- */
.rank-list { display: grid; gap: var(--sp-2); }
.rank-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: rgba(4, 7, 16, 0.4);
  border: 1px solid transparent;
  transition: all var(--dur) var(--ease);
}
.rank-item:hover { background: var(--surface-2); border-color: var(--hairline); }
.rank-item .pos {
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--text-4);
  text-align: center;
}
.rank-item:nth-child(1) .pos { color: #ffd76b; }
.rank-item:nth-child(2) .pos { color: #cfd8e6; }
.rank-item:nth-child(3) .pos { color: #e8a87c; }
.rank-item .body { min-width: 0; }
.rank-item .top {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: var(--fs-2xs);
  margin-block-end: 4px;
}
.rank-item .top .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-item .top .sc { font-weight: 800; color: var(--brand); flex-shrink: 0; }
.rank-item .bar { height: 5px; border-radius: var(--r-full); background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.rank-item .rk-meta {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
  font-size: 10px;
  color: var(--text-4);
  margin-block-start: 4px;
}
.rank-item .bar i {
  display: block; height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width var(--dur-slow) var(--ease);
}

/* ---------- ۱۴. جدول مقایسه ---------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--hairline);
  background: rgba(4, 7, 16, 0.45);
}
table.compare {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
  font-size: var(--fs-2xs);
}
table.compare th,
table.compare td {
  padding: var(--sp-3);
  text-align: start;
  border-block-end: 1px solid var(--hairline);
  vertical-align: middle;
}
table.compare thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--ink-750);
  font-size: var(--fs-3xs);
  font-weight: 700;
  color: var(--text-3);
  white-space: nowrap;
  border-block-end: 1px solid var(--hairline-strong);
}
table.compare tbody tr:hover { background: var(--surface-1); }
table.compare tbody tr:last-child td { border-block-end: 0; }
table.compare th[scope='row'] {
  font-weight: 400;
  color: var(--text-3);
  background: rgba(4, 7, 16, 0.35);
  font-size: var(--fs-3xs);
  white-space: nowrap;
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
}
table.compare td.best {
  background: var(--brand-soft);
  color: #a8ffe2;
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--brand);
}
table.compare .prod-name { font-weight: 700; color: var(--text-1); }
table.compare .prod-bank { color: var(--text-4); font-size: var(--fs-3xs); }

/* ---------- ۱۵. نمودار ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: var(--sp-4);
}
.chart-card { padding: var(--sp-5); }
.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-block-end: var(--sp-4);
  flex-wrap: wrap;
}
.chart-head h3 { font-size: var(--fs-sm); font-weight: 700; margin: 0; }
.chart-head p { font-size: var(--fs-3xs); color: var(--text-4); margin: 2px 0 0; }

.ladder { display: grid; gap: var(--sp-3); }
.ladder-row { display: grid; grid-template-columns: 128px minmax(0, 1fr) 52px; align-items: center; gap: var(--sp-3); }
.ladder-row .lbl { font-size: var(--fs-3xs); color: var(--text-3); }
.ladder-row .val { font-size: var(--fs-2xs); font-weight: 700; text-align: end; font-variant-numeric: tabular-nums; }
.ladder-track {
  position: relative;
  height: 22px;
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.ladder-track i {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--brand-dim), var(--brand));
  transition: width var(--dur-slow) var(--ease);
}
.ladder-track i.negative { background: linear-gradient(90deg, #8a2b3c, var(--danger)); }

/*
 * tooltip شناور سطرهای نردبان.
 *
 * چرا translateX نداریم: درس قفل‌شدهٔ RTL همین ریپو — transform فیزیکی است
 * و با جهت سند نمی‌چرخد. tooltip تمام‌عرضِ سطر، بالای آن شناور می‌شود؛
 * نه به مرکز نیازی است نه به translate. focus هم پشتیبانی می‌شود (tabindex
 * روی سطر در charts.js) و متن note به‌صورت sr-only هم هست.
 */
.ladder-row.has-tip { position: relative; cursor: help; outline-offset: 2px; }
.ladder-row.has-tip::after {
  content: attr(data-tip);
  position: absolute;
  inset-inline: 0;
  inset-block-end: calc(100% + 6px);
  z-index: 40;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: var(--ink-750);
  color: var(--text-1);
  border: 1px solid var(--hairline-strong);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-3xs);
  line-height: 1.85;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), visibility var(--dur-fast);
  pointer-events: none;
}
.ladder-row.has-tip:hover::after,
.ladder-row.has-tip:focus::after {
  opacity: 1;
  visibility: visible;
  transform: none;
}
html[data-theme='light'] .ladder-row.has-tip::after { background: #fff; color: var(--text-1); }

/* ---------- ۱۶. کشو (Drawer) ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(2, 4, 10, 0.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

/*
  کشو به لبه «شروع» چسبیده است (inset-inline-start) یعنی در صفحه راست‌به‌چپ
  لبه راست. اما translateX همیشه فیزیکی است: مقدار منفی به سمت چپ می‌برد.
  اگر حالت بسته با translateX(-102%) تعریف شود، در RTL کشو به‌جای رفتن به
  بیرونِ صفحه، به وسط صفحه کشیده می‌شود و یک قاب تمام‌قد روی محتوا می‌نشیند.
  پس جهت جابه‌جایی باید با جهت سند هم‌خوان شود.

  visibility هم افزوده شده تا حتی اگر جابه‌جایی در مرورگری درست کار نکند،
  کشوی بسته هیچ‌وقت دیده نشود، کلیک نخورد و در ترتیب Tab قرار نگیرد.
  مقدار visibility در طول انتقال «visible» می‌ماند و فقط در پایانِ بستن،
  hidden می‌شود؛ بنابراین انیمیشن خروج هم کامل دیده می‌شود.
*/
.drawer {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 100;
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--ink-750), var(--ink-850));
  border-inline-end: 1px solid var(--hairline-strong);
  box-shadow: var(--shadow-xl);
  transform: translateX(-102%);           /* LTR: لبه چپ ← پنهان به چپ */
  visibility: hidden;
  pointer-events: none;
  transition: transform var(--dur-slow) var(--ease),
              visibility var(--dur-slow) var(--ease);
}
[dir='rtl'] .drawer { transform: translateX(102%); } /* RTL: لبه راست ← پنهان به راست */
.drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border-block-end: 1px solid var(--hairline);
  flex-shrink: 0;
}
.drawer-head h2 { font-size: var(--fs-lg); line-height: 1.6; margin: 0; }
.drawer-body { padding: var(--sp-5); overflow-y: auto; flex: 1; }
.drawer-foot {
  padding: var(--sp-4) var(--sp-5);
  border-block-start: 1px solid var(--hairline);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  flex-shrink: 0;
}
.drawer-foot a { max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: start; }

.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-2);
  margin-block-end: var(--sp-5);
}
.spec {
  padding: var(--sp-3);
  background: rgba(4, 7, 16, 0.5);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
}
.spec .k { font-size: 10px; color: var(--text-4); display: block; margin-block-end: 2px; }
.spec .v { font-size: var(--fs-2xs); font-weight: 600; line-height: 1.7; word-break: break-word; }

.section-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-2xs);
  font-weight: 700;
  color: var(--text-2);
  margin-block: var(--sp-5) var(--sp-3);
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

.req-list { display: grid; gap: var(--sp-2); }
.req-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  line-height: 1.9;
  color: var(--text-2);
  list-style: none;
}
.req-list li::before { content: '◆'; color: var(--brand); font-size: 8px; margin-block-start: 7px; flex-shrink: 0; }

/* ---------- ۱۷. ماشین‌حساب اقساط ---------- */
.calc { display: grid; gap: var(--sp-3); }
.calc-out {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--sp-2);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: linear-gradient(120deg, var(--brand-soft), transparent);
  border: 1px solid var(--brand-line);
}
.calc-out .k { font-size: 10px; color: var(--text-3); display: block; }
.calc-out .v { font-size: var(--fs-md); font-weight: 800; letter-spacing: -0.02em; }

/* ---------- ۱۸. نمودار دونات ---------- */
.donut-wrap { display: flex; align-items: center; gap: var(--sp-5); flex-wrap: wrap; }
.donut { position: relative; width: 160px; height: 160px; flex-shrink: 0; }
.donut svg { transform: rotate(-90deg); }
.donut .center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}
.donut .center b { display: block; font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -0.03em; }
.donut .center span { font-size: var(--fs-3xs); color: var(--text-4); }
.legend { display: grid; gap: var(--sp-2); flex: 1; min-width: 160px; }
.legend-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-2xs);
  color: var(--text-2);
}
.legend-row .swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-row .n { margin-inline-start: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- ۱۹. حالت‌ها ---------- */
.empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  gap: var(--sp-3);
  padding: var(--sp-12) var(--sp-5);
  text-align: center;
  color: var(--text-3);
}
.empty-state .ic { font-size: 2.4rem; opacity: 0.55; }
.empty-state h3 { font-size: var(--fs-md); color: var(--text-2); font-weight: 700; }
.empty-state p { font-size: var(--fs-xs); max-width: 46ch; line-height: 2; }

.skeleton {
  border-radius: var(--r-lg);
  background: linear-gradient(100deg, var(--surface-1) 30%, var(--surface-3) 50%, var(--surface-1) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.5s linear infinite;
  min-height: 260px;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---------- ۲۰. گفتگو و اعلان ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: rgba(2, 4, 10, 0.78);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.modal-backdrop.is-open { opacity: 1; pointer-events: auto; }

.modal {
  width: min(880px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--ink-750), var(--ink-850));
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  transform: translateY(14px) scale(0.985);
  transition: transform var(--dur-slow) var(--ease);
}
.modal-backdrop.is-open .modal { transform: none; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border-block-end: 1px solid var(--hairline);
}
.modal-head h2 { font-size: var(--fs-lg); margin: 0; }
.modal-body { padding: var(--sp-5); overflow-y: auto; }

.toast-stack {
  position: fixed;
  inset-block-end: var(--sp-5);
  inset-inline-start: var(--sp-5);
  z-index: 130;
  display: grid;
  gap: var(--sp-2);
  pointer-events: none;
  max-width: min(400px, calc(100vw - 2 * var(--sp-5)));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--ink-700);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-xs);
  line-height: 1.8;
  animation: toast-in var(--dur) var(--ease);
  pointer-events: auto;
}
.toast--good { border-color: var(--brand-line); }
.toast--bad { border-color: var(--danger-line); }
.toast--warn { border-color: var(--warn-line); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- ۲۱. پاصفحه ---------- */
.footer {
  margin-block-start: var(--sp-12);
  padding-block-start: var(--sp-6);
  border-block-start: 1px solid var(--hairline);
  display: grid;
  gap: var(--sp-4);
  font-size: var(--fs-2xs);
  color: var(--text-4);
  line-height: 2;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--sp-5);
}
.footer h4 { font-size: var(--fs-2xs); color: var(--text-2); margin-block-end: var(--sp-2); font-weight: 700; }
.footer ul { list-style: none; padding: 0; display: grid; gap: 5px; }
.footer a { color: var(--text-3); }
.footer a:hover { color: var(--brand); }
.footer-note {
  padding-block-start: var(--sp-4);
  border-block-start: 1px solid var(--hairline);
  text-align: center;
  font-size: var(--fs-3xs);
}

/* ---------- ۲۲. واکنش‌گرا ---------- */
@media (max-width: 1180px) {
  .main-grid { grid-template-columns: minmax(0, 1fr); }
  .filters { position: static; max-height: none; }
  .hero { grid-template-columns: 1fr; padding: var(--sp-6); }
  .cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

@media (max-width: 860px) {
  .cat-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { gap: var(--sp-2); padding-inline: var(--sp-3); }
  .topbar-search { max-width: none; }
  .brand-text { display: none; }
}

@media (max-width: 620px) {
  .shell { width: calc(100% - 2 * var(--sp-3)); padding-block-start: var(--sp-4); }
  .hero { padding: var(--sp-5) var(--sp-4); }
  .cat-tabs { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
  .macro-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-actions { gap: 2px; }
  .topbar-actions .btn { padding-inline: 0.4rem; }
  .topbar-actions .btn span.lbl { display: none; }
  .topbar-search { min-width: 0; }
  .topbar-search input { padding-inline: 30px 8px; }
  .topbar-search .icon { inset-inline-start: 10px; }
  /* فهرست پیشنهادها در موبایل عرض نوار جست‌وجوی کوچک را به ارث نمی‌برد. */
  .search-suggestions { position: fixed; top: calc(var(--header-h) + var(--sp-2)); inset-inline: var(--sp-3); }
  .drawer { width: 100%; }
  .ladder-row { grid-template-columns: 92px minmax(0, 1fr) 44px; gap: var(--sp-2); }
}

/* ---------- ۲۳. ترجیح کاربر ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- ۲۴. چاپ ---------- */
@media print {
  body { background: #fff; color: #000; }
  body::before, body::after { display: none; }
  .topbar, .filters, .toolbar, .card-actions, .drawer, .modal-backdrop, .toast-stack, .footer, .cat-tabs { display: none !important; }
  .panel, .card { border: 1px solid #ccc; box-shadow: none; background: #fff; }
  .rate-hero, .rank-item { background: #fff; }
  .main-grid { grid-template-columns: 1fr; }
  .hero h1 { -webkit-text-fill-color: #000; color: #000; }
  .card { break-inside: avoid; }
  .table-wrap { overflow: visible; }
}

/* مقادیر فرضی در جدول مقایسه (سقف مشروط) — از مقدار قطعی قابل تشخیص باشد */
.compare td.estimated {
  color: var(--text-4);
  font-style: italic;
}

/*
 * مقایسهٔ تمام‌عرض: وضعیت روی body است نه روی خود سکشن — چون renderResults
 * هر بار #compare را از نو می‌سازد و کلاسِ روی سکشن با هر تغییر سبد می‌پرید.
 * ESC و دکمهٔ همان حالت آن را می‌بندد.
 */
body.compare-zoom #compare-section {
  position: fixed;
  inset: 0;
  z-index: 90;
  margin: 0 !important;
  border-radius: 0;
  border-inline: 0;
  overflow-y: auto;
  background: var(--ink-900);
}
html[data-theme='light'] body.compare-zoom #compare-section { background: #eef1f7; }
body.compare-zoom .table-wrap { max-width: 1600px; margin-inline: auto; }

/* ---------- ۲۵. تم روشن ---------- */
/*
 * تم روشن به‌صورت لایهٔ بازنویسی روی همان توکن‌هاست، نه قالب دوم:
 * تیره پیش‌فرض می‌ماند (html بدون data-theme)، و انتخاب کاربر با کلید
 * bankradar.v2.bank-radar-theme در اسکریپت ابتدای index.html زودتر از
 * نخستین رنگ‌آمیزی اعمال می‌شود.
 *
 * توجه: توکن‌های ink-* عمداً بازنویسی نمی‌شوند — دکمهٔ اصلی متن تیره روی
 * گرین سبک دارد و در تم روشن هم باید تیره بماند.
 */
html[data-theme='light'] {
  color-scheme: light;
  --surface-1: rgba(13, 20, 36, 0.04);
  --surface-2: rgba(13, 20, 36, 0.07);
  --surface-3: rgba(13, 20, 36, 0.1);
  --surface-4: rgba(13, 20, 36, 0.15);
  --hairline: rgba(13, 20, 36, 0.14);
  --hairline-strong: rgba(13, 20, 36, 0.26);
  --text-1: #0e1626;
  --text-2: #313e5b;
  --text-3: #526181;
  --text-4: #7585a4;
  --brand: #0b9d72;
  --brand-dim: #087c5a;
  --brand-soft: rgba(11, 157, 114, 0.11);
  --brand-line: rgba(11, 157, 114, 0.4);
  --accent: #5060e6;
  --accent-soft: rgba(80, 96, 230, 0.1);
  --accent-line: rgba(80, 96, 230, 0.38);
  --warn: #9a6400;
  --warn-soft: rgba(199, 138, 16, 0.13);
  --warn-line: rgba(199, 138, 16, 0.42);
  --danger: #cc2b4b;
  --danger-soft: rgba(204, 43, 75, 0.09);
  --danger-line: rgba(204, 43, 75, 0.38);
  --info: #0c7ec2;
  --info-soft: rgba(12, 126, 194, 0.1);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.07);
  --shadow-md: 0 8px 24px -8px rgba(16, 24, 40, 0.16);
  --shadow-lg: 0 24px 60px -20px rgba(16, 24, 40, 0.22);
  --shadow-xl: 0 40px 100px -30px rgba(16, 24, 40, 0.28);
  --glow-brand: 0 0 0 1px var(--brand-line), 0 12px 40px -14px rgba(11, 157, 114, 0.35);
}

html[data-theme='light'] body { background: #eef1f7; }
html[data-theme='light'] body::before {
  background:
    radial-gradient(ellipse 80% 55% at 82% -8%, rgba(80, 96, 230, 0.1), transparent 60%),
    radial-gradient(ellipse 70% 50% at 12% 4%, rgba(11, 157, 114, 0.09), transparent 58%),
    radial-gradient(ellipse 100% 60% at 50% 108%, rgba(80, 96, 230, 0.06), transparent 62%),
    linear-gradient(178deg, #f7f9fd 0%, #eef1f7 55%, #e3e8f2 100%);
}
html[data-theme='light'] body::after { opacity: 0.22; }
html[data-theme='light'] a:hover { color: var(--brand-dim); }
html[data-theme='light'] ::selection { color: var(--text-1); }
html[data-theme='light'] .topbar { background: rgba(248, 250, 253, 0.82); }
html[data-theme='light'] .cat-tabs { background: rgba(248, 250, 253, 0.75); }
html[data-theme='light'] ::-webkit-scrollbar-track { background: rgba(13, 20, 36, 0.04); }
html[data-theme='light'] ::-webkit-scrollbar-thumb { background: rgba(13, 20, 36, 0.26); background-clip: padding-box; }
html[data-theme='light'] ::-webkit-scrollbar-thumb:hover { background: rgba(13, 20, 36, 0.4); background-clip: padding-box; }

/* متن‌های سفارشی که برای پس‌زمینهٔ تیره ساخته شده بودند */
html[data-theme='light'] .chip--good { color: #075c40; }
html[data-theme='light'] .chip--warn { color: #6e4a00; }
html[data-theme='light'] .chip--bad { color: #8f1b31; }
html[data-theme='light'] .chip--info { color: #2b39ab; }
html[data-theme='light'] .chip--cat-deposits { color: #075c40; }
html[data-theme='light'] .chip--cat-credit { color: #2b39ab; }
html[data-theme='light'] .chip--cat-loans { color: #6e4a00; }
html[data-theme='light'] .chip--cat-loyalty { color: #92274d; }
html[data-theme='light'] .chip--cat-funds { color: #0c6f96; }
html[data-theme='light'] .tag { color: #3b46b8; }
html[data-theme='light'] .btn--danger { color: #8f1b31; }
html[data-theme='light'] .freshness.good { color: #07714f; }

/* سطح‌های تیرهٔ هاردکد مؤلفه‌ها */
html[data-theme='light'] .rate-hero { background: rgba(255, 255, 255, 0.72); }
html[data-theme='light'] .rank-item { background: rgba(255, 255, 255, 0.6); }
html[data-theme='light'] .rank-item .bar { background: rgba(13, 20, 36, 0.1); }
html[data-theme='light'] .score-ring .track { stroke: rgba(13, 20, 36, 0.12); }
html[data-theme='light'] .macro-cell { background: rgba(255, 255, 255, 0.75); }
html[data-theme='light'] .health-row { background: rgba(255, 255, 255, 0.7); }
html[data-theme='light'] .spec { background: rgba(255, 255, 255, 0.65); }
html[data-theme='light'] .table-wrap { background: #fff; }
html[data-theme='light'] table.compare thead th { background: #eef1f7; }
html[data-theme='light'] table.compare th[scope='row'] { background: #f4f6fb; }
html[data-theme='light'] .ladder-track { background: rgba(13, 20, 36, 0.07); }
html[data-theme='light'] .progress { background: rgba(13, 20, 36, 0.1); }
html[data-theme='light'] .search-suggestions { background: rgba(252, 253, 255, 0.98); }
html[data-theme='light'] .modal { background: linear-gradient(160deg, #f8fafd, #eef1f7); }
html[data-theme='light'] .toast { background: #fff; }
html[data-theme='light'] .pill-live { color: var(--brand-dim); }
html[data-theme='light'] .real-rate-callout b { color: #8f1b31; }
html[data-theme='light'] .hero h1 {
  background: linear-gradient(112deg, #10233f 8%, #0b7c5c 52%, #3c4cc0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
html[data-theme='light'] .drawer { background: linear-gradient(160deg, #f7f9fc, #eef1f7); }
