/* =========================================================================
   پوستهٔ رابط: فارسی، راست‌چین، روشن و تیره.

   ترتیب: توکن‌ها، چیدمان، اجزای گفت‌وگو، نمودار و جدول، صفحه‌ها، و در
   پایان سبکِ نمای «مسیر تحلیل» و صفحهٔ تنظیم مدل که از نسخهٔ قبل
   بدون تغییر آمده‌اند. هیچ منبع بیرونی (CDN، فونت راه‌دور) در کار
   نیست؛ صفحه باید در شبکهٔ بسته هم کامل بالا بیاید.
   ========================================================================= */

@font-face {
  font-family: "IRANSansX";
  src: url("fonts/IRANSansX-Regular.woff2") format("woff2"), url("fonts/IRANSansX-Regular.woff") format("woff");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IRANSansX";
  src: url("fonts/IRANSansX-Bold.woff2") format("woff2"), url("fonts/IRANSansX-Bold.woff") format("woff");
  font-weight: 700; font-style: normal; font-display: swap;
}

/* ============================================================ tokens */
:root {
  --font: "IRANSansX", Tahoma, "Segoe UI", system-ui, sans-serif;

  --bg:          #f3f6f6;
  --sidebar:     #eaf0f0;
  --surface:     #ffffff;
  --surface-2:   #f7f9f9;
  --surface-3:   #edf2f2;
  --line:        #dde5e6;
  --line-strong: #c5d1d3;
  --control-border: #6f8286;

  --fg:   #1b2a2d;
  --fg-2: #3f5155;
  --fg-3: #56676b;

  --accent:       #0e6f78;
  --accent-hover: #0a5c64;
  --accent-soft:  #e3f1f2;
  --accent-line:  #b5d9dc;
  --on-accent:    #ffffff;

  --ok:        #0b7a3e;
  --ok-soft:   #e3f4ea;
  --warn:      #8a5a0e;
  --warn-soft: #fbf1dd;
  --err:       #b3271e;
  --err-soft:  #fdecea;

  --grid: #e8eeee;
  --axis: #c5d1d3;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --s4: #eda100; --s5: #e87ba4; --s6: #008300;

  --scrim: rgba(12, 22, 24, .42);
  --sh-1: 0 1px 2px rgba(20, 40, 44, .06);
  --sh-2: 0 6px 20px rgba(20, 40, 44, .10);
  --sh-3: 0 18px 48px rgba(20, 40, 44, .20);

  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;

  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-base: 15px;
  --fs-lg: 17px; --fs-xl: 20px; --fs-2xl: 26px;

  --muted: var(--fg-3);
  --sidebar-w: 280px;
  --read-w: 72ch;
  --content-w: 1040px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1618; --sidebar: #121b1d; --surface: #172022; --surface-2: #1c2729;
    --surface-3: #223032; --line: #2a383b; --line-strong: #38494c; --control-border: #6b8286;
    --fg: #e6eeef; --fg-2: #c0cfd1; --fg-3: #9cb0b3;
    --accent: #48c1ca; --accent-hover: #6ad0d7; --accent-soft: #16353a;
    --accent-line: #245a60; --on-accent: #0b1a1c;
    --ok: #4fc47f; --ok-soft: #173125; --warn: #e3ac55; --warn-soft: #33281a;
    --err: #f08b83; --err-soft: #361e1c;
    --grid: #243133; --axis: #38494c;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
    --scrim: rgba(0, 0, 0, .6);
    --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-2: 0 6px 20px rgba(0, 0, 0, .45);
    --sh-3: 0 18px 48px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1618; --sidebar: #121b1d; --surface: #172022; --surface-2: #1c2729;
  --surface-3: #223032; --line: #2a383b; --line-strong: #38494c; --control-border: #6b8286;
  --fg: #e6eeef; --fg-2: #c0cfd1; --fg-3: #9cb0b3;
  --accent: #48c1ca; --accent-hover: #6ad0d7; --accent-soft: #16353a;
  --accent-line: #245a60; --on-accent: #0b1a1c;
  --ok: #4fc47f; --ok-soft: #173125; --warn: #e3ac55; --warn-soft: #33281a;
  --err: #f08b83; --err-soft: #361e1c;
  --grid: #243133; --axis: #38494c;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
  --scrim: rgba(0, 0, 0, .6);
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 6px 20px rgba(0, 0, 0, .45);
  --sh-3: 0 18px 48px rgba(0, 0, 0, .6);
}

/* ============================================================ base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
/* فقط پوستهٔ اصلی تمام‌صفحه است و خودش اسکرول می‌کند؛ صفحهٔ تنظیم مدل‌ها
   هم همین شیت را دارد و باید مثل یک صفحهٔ معمولی اسکرول شود. */
body.shell { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.4; text-wrap: balance; }
p { margin: 0; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none;
        stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================ layout */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

/* ---------- sidebar */
.sidebar {
  background: var(--sidebar);
  border-inline-start: 0;
  border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
  padding: 14px 12px 12px;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent);
              color: var(--on-accent); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-weight: 700; font-size: var(--fs-md); line-height: 1.35; }
.brand-sub { font-size: var(--fs-xs); color: var(--fg-3); }
.icon-btn.sidebar-close { margin-inline-start: auto; display: none; }

.new-chat {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  height: 42px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 700; font-size: var(--fs-md); color: var(--fg);
  box-shadow: var(--sh-1);
}
.new-chat:hover { border-color: var(--accent-line); background: var(--accent-soft); }

.side-search { position: relative; }
.side-search svg { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); color: var(--fg-3); width: 16px; height: 16px; }
.side-search input {
  width: 100%; height: 36px; border-radius: var(--r-md);
  border: 1px solid var(--control-border); background: var(--surface-3);
  padding-inline: 34px 10px; font-size: var(--fs-sm);
}
.side-search input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.conv-list { flex: 1; overflow-y: auto; min-height: 0; margin-inline: -4px; padding-inline: 4px; }
.conv-group + .conv-group { margin-top: 14px; }
.conv-group-title { font-size: var(--fs-xs); color: var(--fg-3); padding: 0 8px 4px; font-weight: 700; }
.conv {
  display: flex; align-items: flex-start; gap: 6px; width: 100%;
  border: 0; background: none; text-align: start;
  padding: 7px 10px; border-radius: var(--r-sm);
  font-size: var(--fs-sm); color: var(--fg-2); line-height: 1.6;
}
.conv .t { flex: 1; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; }
.conv .more { flex: none; width: 22px; height: 22px; margin-top: 1px; }
.conv:hover { background: var(--surface-3); color: var(--fg); }
.conv[aria-current="true"] { background: var(--surface); color: var(--fg); font-weight: 700; box-shadow: var(--sh-1); }
.conv .more { opacity: 0; color: var(--fg-3); display: grid; place-items: center; border-radius: 4px; }
.conv:hover .more, .conv[aria-current="true"] .more { opacity: 1; }

.side-foot { border-top: 1px solid var(--line); padding-top: 10px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding-inline: 10px;
  border: 0; background: none; border-radius: var(--r-sm); font-size: var(--fs-md); color: var(--fg-2); text-align: start;
}
.nav-item:hover { background: var(--surface-3); color: var(--fg); }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--fg); font-weight: 700; box-shadow: var(--sh-1); }
.side-label { font-size: var(--fs-xs); color: var(--fg-3); font-weight: 700; padding: 0 10px; }
.user-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none;
  padding: 8px; border-radius: var(--r-md); text-align: start;
}
.user-btn:hover, .user-btn[aria-current="page"] { background: var(--surface-3); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: var(--fs-xl); }
.user-btn .nm { font-size: var(--fs-md); font-weight: 700; line-height: 1.4; }
.user-btn .rl { font-size: var(--fs-xs); color: var(--fg-3); line-height: 1.4; }
.user-btn .i { margin-inline-start: auto; color: var(--fg-3); }
.role-user .admin-only { display: none !important; }
.cost { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding-inline: 10px; border-radius: 999px; background: var(--surface-3); color: var(--fg-2); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.cost svg { width: 14px; height: 14px; }

/* ---------- macro view */
.macro-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.calc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.calc h3 { font-size: var(--fs-base); font-weight: 700; }
.calc-form { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-xs); color: var(--fg-3); }
.calc-out { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.calc-out .kpi { background: var(--surface-2); }
.note { font-size: var(--fs-xs); color: var(--fg-3); line-height: 1.9; }
.section-title { font-size: var(--fs-lg); font-weight: 700; margin-top: 8px; }

/* ---------- pages (tables, profile) */
.page { flex: 1; overflow-y: auto; min-height: 0; }
.page-inner { max-width: var(--content-w); margin-inline: auto; padding: 28px 24px 48px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; }
.page-head h2 { font-size: var(--fs-2xl); font-weight: 700; flex: 1 1 260px; }
.page-head p { color: var(--fg-3); font-size: var(--fs-md); flex-basis: 100%; }
.crumb { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--accent); font-size: var(--fs-sm); padding: 0; }
.crumb svg { transform: scaleX(-1); width: 16px; height: 16px; }
.filters { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: center; }
.years { display: flex; gap: 4px; overflow-x: auto; max-width: 100%; padding: 2px; }
.years button { height: 32px; min-width: 56px; padding-inline: 10px; border-radius: 8px; border: 1px solid var(--control-border); background: var(--surface); font-size: var(--fs-sm); color: var(--fg-2); font-variant-numeric: tabular-nums; flex: none; }
.years button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.cat-group { display: flex; flex-direction: column; gap: 8px; }
.cat-group h3 { font-size: var(--fs-md); color: var(--fg-2); font-weight: 700; }
.cat-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.cat-row {
  display: grid; grid-template-columns: minmax(64px, max-content) minmax(0, 1fr) auto auto; align-items: center; gap: 14px;
  width: 100%; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: start;
}
.cat-list .cat-row:last-child { border-bottom: 0; }
.cat-row:hover { background: var(--surface-2); }
.cat-row:disabled { cursor: default; }
.cat-row:disabled:hover { background: none; }
.cat-no { font-size: var(--fs-xs); font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 3px 8px; justify-self: start; white-space: nowrap; }
.cat-title { font-size: var(--fs-md); line-height: 1.7; }
.cat-rows { font-size: var(--fs-xs); color: var(--fg-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.state { font-size: var(--fs-xs); font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.state.ok { background: var(--ok-soft); color: var(--ok); }
.state.no { background: var(--surface-3); color: var(--fg-3); }
.state.warn { background: var(--warn-soft); color: var(--warn); }
.cat-row:disabled .cat-title { color: var(--fg-3); }
.detail-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.prof-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.prof-card h3 { font-size: var(--fs-base); font-weight: 700; }
.prof-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.prof-top .nm { font-size: var(--fs-xl); font-weight: 700; }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 10px 16px; font-size: var(--fs-md); }
.kv dt { color: var(--fg-3); }
.kv dd { margin: 0; }
.set-row { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; justify-content: space-between; }
.set-row + .set-row { border-top: 1px solid var(--line); padding-top: 14px; }
.set-row .lb { font-size: var(--fs-md); }
.set-row .lb small { display: block; color: var(--fg-3); font-size: var(--fs-xs); }
.prof-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.prof-grid .wide { grid-column: 1 / -1; }
.btn.danger { color: var(--err); border-color: var(--control-border); }
@media (max-width: 700px) {
  .prof-grid { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .cat-row { grid-template-columns: minmax(0, 1fr) auto; }
  .cat-row .cat-no { grid-column: 1 / -1; }
  .cat-row .cat-rows { display: none; }
  .page-inner { padding: 20px 16px 36px; }
}

/* ---------- main column */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 8px;
  height: 56px; padding-inline: 16px;
  border-bottom: 1px solid var(--line); background: var(--bg);
  flex: none;
}
.topbar h1 { font-size: var(--fs-base); font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.icon-btn.menu-btn { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding-inline: 10px; border-radius: 999px;
  font-size: var(--fs-xs); border: 1px solid var(--line); background: var(--surface);
  color: var(--fg-2); white-space: nowrap;
}
.chip svg { width: 14px; height: 14px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-md);
  border: 1px solid transparent; background: none; color: var(--fg-2);
  display: inline-grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--fg); }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

.thread { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: smooth; }
.thread-inner {
  max-width: var(--content-w); margin-inline: auto;
  padding: 28px 24px 40px;
  display: flex; flex-direction: column; gap: 28px;
}

/* ---------- messages */
.msg-user { display: flex; justify-content: flex-start; }
.bubble {
  max-width: 85%;
  background: var(--accent-soft); color: var(--fg);
  border: 1px solid var(--accent-line);
  padding: 10px 16px; border-radius: 18px 18px 4px 18px;
  font-size: var(--fs-base);
}
.msg-bot { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.thread-inner > *, .msg-bot > * { min-width: 0; max-width: 100%; }
.bot-head { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); color: var(--fg-3); }
.bot-head .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
.bot-head .brand-mark svg { width: 16px; height: 16px; }
.bot-head b { color: var(--fg); font-weight: 700; }

.answer-text { font-size: var(--fs-lg); line-height: 1.95; color: var(--fg); }
.answer-text strong { font-weight: 700; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.kpi-label { font-size: var(--fs-sm); color: var(--fg-3); }
.kpi-value { font-size: var(--fs-2xl); font-weight: 700; line-height: 1.3; }
.kpi-unit { font-size: var(--fs-sm); color: var(--fg-2); font-weight: 400; margin-inline-start: 4px; }
.kpi-foot { font-size: var(--fs-xs); color: var(--fg-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; padding: 0 6px; border-radius: 999px; font-size: var(--fs-xs); }
.delta.up { color: var(--ok); background: var(--ok-soft); }
.delta.down { color: var(--err); background: var(--err-soft); }

/* data section header with unit control */
.data-head {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px 14px; flex-wrap: wrap;
}
.data-head h3 { font-size: var(--fs-md); font-weight: 700; color: var(--fg-2); }
.data-head .spacer { flex: 1; }
.unit-ctl { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--fg-3); }
.select {
  appearance: none; height: 34px; border-radius: var(--r-md);
  border: 1px solid var(--control-border); background: var(--surface);
  padding-inline: 12px 30px; font-size: var(--fs-sm); color: var(--fg);
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-3) 50%), linear-gradient(135deg, var(--fg-3) 50%, transparent 50%);
  background-position: 14px 15px, 19px 15px; background-size: 5px 5px; background-repeat: no-repeat;
}
.select:hover { border-color: var(--accent-line); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--fg-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 34px; height: 20px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: var(--sh-1); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(-14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { font-size: var(--fs-xs); color: var(--fg-3); }

/* chart grid */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.charts > .wide { grid-column: 1 / -1; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  min-width: 0;
}
.chart-card { container-type: inline-size; display: flex; flex-direction: column; }
.chart-head { display: flex; align-items: flex-start; gap: 10px 12px; padding: 14px 16px 6px; flex-wrap: wrap; }
.chart-titles { flex: 1 1 220px; min-width: 0; }
.chart-title { font-size: var(--fs-base); font-weight: 700; }
.chart-sub { font-size: var(--fs-xs); color: var(--fg-3); margin-top: 2px; }
.chart-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.seg {
  display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r-md);
  background: var(--surface-3); border: 1px solid var(--line);
}
.seg button {
  height: 30px; min-width: 32px; padding-inline: 7px; border: 0; border-radius: 7px;
  background: none; color: var(--fg-3); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: var(--fs-xs);
}
.seg button:hover { color: var(--fg); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--sh-1); }
.seg button svg { width: 17px; height: 17px; }
.tool-sep { width: 1px; height: 20px; background: var(--line); }
.chart-tools .icon-btn { width: 32px; height: 32px; border-radius: 8px; }
.chart-tools .icon-btn svg { width: 17px; height: 17px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 6px; padding: 2px 12px 0; }
.lg {
  display: inline-flex; align-items: center; gap: 7px; border: 0; background: none;
  padding: 3px 8px; border-radius: 6px; font-size: var(--fs-xs); color: var(--fg-2);
}
.lg:hover { background: var(--surface-3); }
.lg[aria-pressed="false"] { color: var(--fg-3); text-decoration: line-through; }
.lg[aria-pressed="false"] .sw { opacity: .3; }
.lg .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lg .sw.line { height: 3px; width: 14px; border-radius: 2px; }
.lg .lv { color: var(--fg); font-weight: 700; }
.lg:disabled { cursor: default; }
.lg:disabled:hover { background: none; }

.chart-body { position: relative; padding: 4px 8px 10px; }
.chart-host { width: 100%; height: 320px; }
.chart-card.compact .chart-host { height: 280px; }
.chart-table { padding: 4px 16px 16px; }
.chart-foot { display: flex; gap: 8px; align-items: center; padding: 0 16px 12px; font-size: var(--fs-xs); color: var(--fg-3); }

/* ---------- tables */
.tbl-wrap { display: flex; flex-direction: column; }
.tbl-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.tbl-bar h4 { font-size: var(--fs-md); font-weight: 700; }
.tbl-bar .count { font-size: var(--fs-xs); color: var(--fg-3); }
.tbl-bar .spacer { flex: 1; }
.tbl-search { position: relative; }
.tbl-search input {
  height: 32px; width: 200px; max-width: 100%; border-radius: 8px;
  border: 1px solid var(--control-border); background: var(--surface-2);
  padding-inline: 32px 10px; font-size: var(--fs-sm);
}
.tbl-search input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.tbl-search svg { position: absolute; inset-inline-start: 9px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--fg-3); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding-inline: 12px;
  border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: var(--fs-sm); color: var(--fg-2);
}
.btn:hover { border-color: var(--accent-line); color: var(--fg); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn:disabled, .btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.chips-filter { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.fchip { height: 28px; padding-inline: 10px; border-radius: 999px; border: 1px solid var(--control-border); background: none; font-size: var(--fs-xs); color: var(--fg-2); }
.fchip[aria-pressed="true"] { background: var(--fg); color: var(--surface); border-color: var(--fg); }

.tbl-scroll { overflow: auto; max-height: 440px; }
table.dt { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; table-layout: fixed; font-size: var(--fs-sm); }
.dt th, .dt td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.dt thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2);
  font-weight: 700; color: var(--fg-2); font-size: var(--fs-xs); white-space: nowrap;
  border-bottom: 1px solid var(--line-strong); padding: 0;
}
.dt th:first-child, .dt td:first-child { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface); }
.dt thead th:first-child { z-index: 3; background: var(--surface-2); }
.dt th + th, .dt td + td { border-inline-start: 1px solid var(--line); }
.th-btn {
  width: 100%; border: 0; background: none; display: flex; align-items: center; gap: 4px;
  padding: 10px 12px; font-weight: 700; color: inherit; text-align: start; font-size: var(--fs-xs);
}
.th-btn:hover { color: var(--fg); }
.th-btn .sort { opacity: .35; width: 14px; height: 14px; }
th[aria-sort="ascending"] .sort, th[aria-sort="descending"] .sort { opacity: 1; color: var(--accent); }
th[aria-sort="ascending"] .sort { transform: rotate(180deg); }
.dt th.n .th-btn { justify-content: flex-end; }
.dt td.n { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dt td.t { white-space: normal; overflow-wrap: anywhere; }
.dt tbody tr:hover td { background: var(--surface-2); }
.dt tbody tr.total td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-strong); }
.dt tbody tr.child td { color: var(--fg-2); }
.dt tbody tr.child td:first-child { padding-inline-start: 38px; }
.tree-btn { width: 22px; height: 22px; border: 0; background: none; border-radius: 5px; display: inline-grid; place-items: center; color: var(--fg-3); vertical-align: -5px; margin-inline-end: 4px; }
.tree-btn:hover { background: var(--surface-3); color: var(--fg); }
.tree-btn svg { width: 15px; height: 15px; transition: transform .15s; }
.tree-btn[aria-expanded="true"] svg { transform: rotate(-90deg); }
.pos { color: var(--ok); } .neg { color: var(--err); }
.resize {
  position: absolute; top: 0; bottom: 0; inset-inline-end: -4px; width: 8px; cursor: col-resize; z-index: 4;
}
.resize::after { content: ""; position: absolute; top: 25%; bottom: 25%; inset-inline-start: 3px; width: 2px; border-radius: 2px; background: transparent; }
.resize:hover::after, .resize.active::after, .resize:focus-visible::after { background: var(--accent); }
.dt thead th { position: sticky; }
.th-inner { position: relative; }
.tbl-empty { padding: 28px; text-align: center; color: var(--fg-3); font-size: var(--fs-sm); }
.tbl-foot { padding: 8px 14px; font-size: var(--fs-xs); color: var(--fg-3); border-top: 1px solid var(--line); }

/* details / provenance */
details.more-box { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
details.more-box > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; font-size: var(--fs-md); font-weight: 700; color: var(--fg-2);
}
details.more-box > summary::-webkit-details-marker { display: none; }
details.more-box > summary .chev { transition: transform .15s; color: var(--fg-3); }
details.more-box[open] > summary .chev { transform: rotate(-90deg); }
details.more-box > summary .count { font-weight: 400; font-size: var(--fs-xs); color: var(--fg-3); margin-inline-start: auto; }
details.more-box[open] > summary { border-bottom: 1px solid var(--line); }
details.more-box .tbl-wrap { border: 0; }

/* answer meta */
.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--fg-3); }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding-inline: 10px; border-radius: 999px; font-weight: 700; font-size: var(--fs-xs); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill svg { width: 14px; height: 14px; }
.meta .spacer { flex: 1; }
.ghost { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding-inline: 10px; border-radius: 8px; border: 0; background: none; color: var(--fg-2); font-size: var(--fs-xs); }
.ghost:hover { background: var(--surface-3); color: var(--fg); }
.ghost svg { width: 16px; height: 16px; }

/* clarification */
.clarify { background: var(--surface); border: 1px solid var(--accent-line); border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.clarify h3 { font-size: var(--fs-lg); font-weight: 700; }
.clarify .ctx { font-size: var(--fs-sm); color: var(--fg-3); }
.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.opt {
  text-align: start; border: 1px solid var(--control-border); background: var(--surface);
  border-radius: var(--r-md); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start;
}
.opt:hover { border-color: var(--accent-line); background: var(--surface-2); }
.opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.opt .radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--control-border); flex: none; margin-top: 3px; display: grid; place-items: center; }
.opt[aria-checked="true"] .radio { border-color: var(--accent); }
.opt[aria-checked="true"] .radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.opt-name { font-weight: 700; font-size: var(--fs-md); line-height: 1.6; }
.opt-meta { font-size: var(--fs-xs); color: var(--fg-3); }
.opt.other .opt-name { color: var(--accent); }
.combo { border: 1px solid var(--control-border); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.combo-search { position: relative; border-bottom: 1px solid var(--line); }
.combo-search input { width: 100%; height: 42px; border: 0; background: var(--surface-2); padding-inline: 38px 12px; font-size: var(--fs-md); }
.combo-search input:focus { outline: none; background: var(--surface); }
.combo-search svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--fg-3); }
.combo ul { list-style: none; margin: 0; padding: 4px; max-height: 240px; overflow-y: auto; }
.combo li { padding: 8px 12px; border-radius: 7px; cursor: pointer; font-size: var(--fs-sm); display: flex; gap: 8px; justify-content: space-between; }
.combo li small { color: var(--fg-3); }
.combo li[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.combo li.active { outline: 2px solid var(--accent); outline-offset: -2px; }
.combo li:hover { background: var(--surface-3); }
.combo mark { background: none; color: var(--accent); font-weight: 700; }
.clarify-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.clarify-foot .hint { flex: 1; }
.resolved { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--ok); font-weight: 700; }

/* loading */
/* حالِ کار تا رسیدنِ پاسخ */
.thinking { display: flex; flex-direction: column; gap: 10px; max-width: var(--read-w); padding: 2px 0; transition: opacity .28s ease, transform .28s ease; }
.thinking.leaving { opacity: 0; transform: translateY(-4px); }
.think-phase { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--fg-3); min-height: 22px; }
.think-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); opacity: .55; flex: none; animation: think-pulse 1.4s ease-in-out infinite; }
.think-label { transition: opacity .18s ease, transform .18s ease;
  background: linear-gradient(90deg, var(--fg-3) 0%, var(--fg-3) 40%, var(--fg) 50%, var(--fg-3) 60%, var(--fg-3) 100%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: think-shimmer 2.4s linear infinite; }
.think-label.out { opacity: 0; transform: translateY(3px); }
.think-notes { display: flex; flex-direction: column; gap: 8px; }
.think-note { margin: 0; color: var(--fg-2); font-size: var(--fs-md); line-height: 1.9; animation: think-in .45s cubic-bezier(.16, 1, .3, 1) both; }
.msg-bot.arrive { animation: think-in .35s cubic-bezier(.16, 1, .3, 1) both; }
@keyframes think-pulse { 0%, 100% { transform: scale(.85); opacity: .35; } 50% { transform: scale(1.1); opacity: .8; } }
@keyframes think-shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
@keyframes think-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .think-dot, .think-label, .think-note, .msg-bot.arrive { animation: none; }
  .think-label { color: var(--fg-3); background: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- composer */
.composer-wrap { flex: none; padding: 10px 24px 16px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.composer {
  max-width: calc(var(--content-w) - 48px); margin-inline: auto;
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 18px;
  padding: 8px 8px 8px 8px; box-shadow: var(--sh-2);
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  flex: 1; border: 0; resize: none; background: none; padding: 8px 10px;
  font-size: var(--fs-base); line-height: 1.7; max-height: 180px; min-height: 42px;
}
.composer textarea:focus { outline: none; }
.send { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.send:hover { background: var(--accent-hover); }
.send svg { transform: scaleX(-1); }
.mic { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg-2); display: grid; place-items: center; flex: none; cursor: pointer; }
.mic:hover { color: var(--accent); border-color: var(--accent); }
.mic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mic.recording { background: var(--err); border-color: var(--err); color: #fff; animation: mic-pulse 1.1s ease-in-out infinite; }
.mic.busy { opacity: .6; cursor: progress; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(179, 39, 30, .45); } 50% { box-shadow: 0 0 0 8px rgba(179, 39, 30, 0); } }
@media (prefers-reduced-motion: reduce) { .mic.recording { animation: none; } }
.composer-hint { text-align: center; font-size: var(--fs-xs); color: var(--fg-3); margin-top: 6px; }

/* welcome */
.welcome { max-width: 760px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 22px; align-items: center; text-align: center; }
.welcome .brand-mark { width: 56px; height: 56px; border-radius: 16px; }
.welcome .brand-mark svg { width: 30px; height: 30px; }
.welcome h2 { font-size: var(--fs-2xl); font-weight: 700; }
.welcome p { color: var(--fg-3); max-width: 56ch; }
.starters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
.starter { text-align: start; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-lg); padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.starter:hover { border-color: var(--accent-line); box-shadow: var(--sh-1); }
.starter .ico { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.starter b { display: block; font-size: var(--fs-md); }
.starter small { color: var(--fg-3); font-size: var(--fs-xs); }

/* ---------- overlays */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; }
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(560px, 100%);
  background: var(--surface); z-index: 50; box-shadow: var(--sh-3);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: var(--fs-lg); font-weight: 700; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }

.trace-q { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 14px; font-size: var(--fs-md); margin-bottom: 18px; }
.trace-q small { display: block; color: var(--fg-3); font-size: var(--fs-xs); }
.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tl::before { content: ""; position: absolute; top: 12px; bottom: 12px; inset-inline-start: 11px; width: 2px; background: var(--line); }
.tl li { position: relative; padding-inline-start: 38px; padding-bottom: 18px; }
.tl .mk { position: absolute; inset-inline-start: 0; top: 2px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); border: 2px solid var(--surface); }
.tl .mk svg { width: 13px; height: 13px; stroke-width: 2.6; }
.tl .mk.neutral { background: var(--surface-3); color: var(--fg-3); }
.tl h4 { font-size: var(--fs-md); font-weight: 700; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl h4 small { font-weight: 400; color: var(--fg-3); font-size: var(--fs-xs); }
.tl p { font-size: var(--fs-sm); color: var(--fg-2); margin-top: 2px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag { font-size: var(--fs-xs); padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--fg-2); border: 1px solid var(--line); }
.tag.model { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
pre.code { direction: ltr; text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; font-size: 12px; line-height: 1.6; overflow-x: auto; margin: 8px 0 0; font-family: ui-monospace, Consolas, monospace; color: var(--fg); }

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal-card { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3); width: min(1180px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.modal-card.sm { width: min(640px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; font-size: var(--fs-lg); font-weight: 700; min-width: 0; }
.modal-body { overflow: auto; padding: 16px 18px; }
.modal-body .chart-card { border: 0; }
.modal-body .chart-host { height: min(62vh, 560px); }
.export-img { display: block; width: 100%; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.export-pre { direction: rtl; white-space: pre; overflow: auto; max-height: 280px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; font-size: 12px; margin: 0; }
.export-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--line); }
.export-foot .hint { flex: 1; min-width: 200px; }

.menu {
  position: fixed; z-index: 70; min-width: 200px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--sh-2); padding: 4px;
}
.menu button { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 8px 10px; border-radius: 6px; font-size: var(--fs-sm); text-align: start; color: var(--fg); }
.menu button small { margin-inline-start: auto; color: var(--fg-3); font-size: var(--fs-xs); }
.menu button:hover, .menu button:focus-visible { background: var(--surface-3); outline: none; }
.menu .sep { border-top: 1px solid var(--line); margin: 4px; }

.toast:not(.show) { opacity: 0; pointer-events: none; }
.toast { transition: opacity .15s; position: fixed; bottom: 96px; inset-inline-start: 50%; transform: translateX(50%); z-index: 80; background: var(--fg); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-size: var(--fs-sm); box-shadow: var(--sh-2); }

.chart-tip { direction: rtl; text-align: right; font-family: var(--font) !important; }
.tip-h { font-weight: 700; font-size: 13px; margin-bottom: 4px; color: var(--fg); }
.tip-r { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--fg-3); line-height: 1.9; }
.tip-r .k { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.tip-r b { color: var(--fg); font-size: 13px; margin-inline-start: auto; padding-inline-start: 14px; font-variant-numeric: tabular-nums; }
.tip-u { font-size: 11px; color: var(--fg-3); margin-top: 2px; }

/* ============================================================ responsive */
@container (max-width: 520px) {
  .chart-head { padding-inline: 12px; }
  .seg button .lbl { display: none; }
  .chart-host { height: 260px; }
}
@media (max-width: 1100px) {
  .charts { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(300px, 86vw); z-index: 50;
    transform: translateX(100%); transition: transform .2s ease, visibility 0s .2s; box-shadow: var(--sh-3); visibility: hidden;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }
  .sidebar.open { transform: none; visibility: visible; transition: transform .2s ease; }
  .icon-btn.sidebar-close { display: inline-grid; }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding-inline: 8px 12px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 600px) {
  .thread-inner { padding: 18px 16px 28px; gap: 22px; }
  .composer-wrap { padding: 8px 16px 12px; }
  .composer-hint { display: none; }
  .answer-text { font-size: var(--fs-base); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: var(--fs-xl); }
  .starters { grid-template-columns: minmax(0, 1fr); }
  .bubble { max-width: 92%; }
  .tbl-search input { width: 150px; }
}

/* ---------- ردیف گفت‌وگو: عنوان و دکمهٔ گزینه‌ها کنار هم */
.conv-item { display: flex; align-items: flex-start; gap: 2px; border-radius: var(--r-sm); }
.conv-item:hover { background: var(--surface-3); }
.conv-item.current { background: var(--surface); box-shadow: var(--sh-1); }
.conv-item .conv, .conv-item .conv:hover, .conv-item .conv[aria-current="true"] { background: none; box-shadow: none; }
.conv-item.current .conv { color: var(--fg); font-weight: 700; }
.conv-more { flex: none; width: 28px; height: 28px; margin: 3px 0 0 4px; border: 0; background: none; border-radius: 6px; color: var(--fg-3); display: grid; place-items: center; opacity: 0; }
.conv-more svg { width: 16px; height: 16px; }
.conv-item:hover .conv-more, .conv-item.current .conv-more, .conv-more:focus-visible { opacity: 1; }
.conv-more:hover { background: var(--line); color: var(--fg); }
.menu .danger { color: var(--err); }
.user-btn .nm { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- اجزای پاسخ */
.notice { border-radius: var(--r-md); padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.notice h3 { font-size: var(--fs-md); font-weight: 700; }
.notice p { font-size: var(--fs-sm); color: var(--fg-2); }
.notice.warn { background: var(--warn-soft); border-color: transparent; }
.notice.warn h3 { color: var(--warn); }
.notice.err { background: var(--err-soft); border-color: transparent; }
.notice.err h3 { color: var(--err); }
.notice .btn { align-self: flex-start; }
.warn-list { margin: 0; padding-inline-start: 20px; color: var(--warn); font-size: var(--fs-sm); }
/* تحلیلِ مدل: زیرِ متنِ پاسخ، آرام و بی‌تیتر */
.analysis-box { border-inline-start: 3px solid var(--line-strong); border-radius: var(--r-sm); padding: 8px 14px; background: var(--surface-2); max-width: var(--read-w); }
.analysis-body, .breakdown-body { margin: 0; white-space: pre-wrap; font-family: inherit; font-size: var(--fs-md); line-height: 1.9; color: var(--fg); }
.analysis-box .analysis-body { color: var(--fg-2); font-size: var(--fs-sm); }
details.provenance pre.code { max-height: 280px; overflow: auto; margin: 0; }
details.more-box .prov-body { padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.prov-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; font-size: var(--fs-sm); }
.prov-key { color: var(--fg-3); min-width: 90px; }
.prov-chip { direction: ltr; unicode-bidi: isolate; font-size: 12px; background: var(--surface-3); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin-inline-end: 4px; }
.parts { display: flex; flex-direction: column; gap: 8px; }
.parts h4 { font-size: var(--fs-md); color: var(--fg-2); }
.part-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.part { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 14px; }
.part-q { font-size: var(--fs-sm); color: var(--fg-3); }
.part-a { font-size: var(--fs-md); margin-top: 2px; }
.part-meta { display: flex; gap: 6px; margin-top: 6px; }
.badge { font-size: var(--fs-xs); background: var(--surface-3); color: var(--fg-2); border-radius: 999px; padding: 1px 8px; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.clarify .why { font-size: var(--fs-sm); color: var(--fg-3); }
.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3), var(--line), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.pager { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--fg-3); }
.pager .spacer { flex: 1; }
.loading-note { padding: 24px; text-align: center; color: var(--fg-3); font-size: var(--fs-sm); }
.dt tbody tr.lvl-1 td:first-child { padding-inline-start: 28px; }
.dt tbody tr.lvl-2 td:first-child { padding-inline-start: 44px; color: var(--fg-2); }
.dt tbody tr.lvl-0 td { font-weight: 700; }
.muted { color: var(--fg-3); }

/* ═══ مسیر تحلیل — نمای تمام‌صفحه ═══════════════════════════════════
   چرا تمام‌صفحه: محتوای واقعیِ یک مرحله می‌تواند یک System Prompt
   بیست‌هزار نویسه‌ای باشد. در کشوی کناری، همان متن یک ستون باریک
   می‌شد و کسی تا آخرش نمی‌رفت — یعنی عملاً دیده نمی‌شد. */

body.pipe-open { overflow: hidden; }

/* `:not([hidden])` عمدی است — INV-UI-001. یک `display: flex` بی‌قید،
   صفتِ hidden را خنثی می‌کند و این پوشش تمام‌صفحه است: جلوی هر کلیک و
   تایپی را می‌گیرد، بی‌آنکه خطایی در Console دیده شود. */
.pipeline-view { position: fixed; inset: 0; z-index: 70; background: var(--bg, #fff); }
.pipeline-view:not([hidden]) { display: flex; flex-direction: column; }

.pipeline-head {
  flex: 0 0 auto; padding: 14px 20px 10px;
  border-bottom: 1px solid var(--line, #e3e6ea);
  background: var(--surface, #fafbfc);
}
.pipe-top { display: flex; align-items: flex-start; gap: 12px; }
/* `.icon-btn` پیش‌فرضش `display: none` است و هر جای استفاده خودش
   بازش می‌کند؛ بدون این خط، دکمهٔ بستن ابعادِ صفر می‌گیرد. */
.pipe-top .icon-btn { display: inline-flex; }
.pipe-top-main { flex: 1 1 auto; min-width: 0; }
.pipe-top h2 { margin: 0; font-size: 17px; }
.pipe-question {
  margin: 4px 0 0; font-size: 13px; color: var(--muted, #6b7280);
  line-height: 1.8;
}

.pipe-stats { display: flex; flex-wrap: wrap; gap: 18px; margin: 12px 0 10px; }
.pipe-stat { display: flex; flex-direction: column; gap: 2px; }
.pipe-stat-value { font-size: 15px; font-weight: 600; }
.pipe-stat-label { font-size: 11px; color: var(--muted, #6b7280); }

.pipe-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pipe-filter {
  border: 1px solid var(--line, #e3e6ea); background: transparent;
  border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 12px;
  cursor: pointer; color: inherit;
}
.pipe-filter:hover { background: var(--surface-2, #f1f3f5); }
.pipe-filter.is-on { background: var(--accent, #2a6df4); color: #fff; border-color: transparent; }
.pipe-filter-space { flex: 1 1 auto; }
.pipe-warn { font-size: 12px; color: #b45309; }

.pipeline-body { flex: 1 1 auto; overflow-y: auto; padding: 16px 20px 60px; }

.pipe-grid {
  display: grid; grid-template-columns: 240px minmax(0, 1fr);
  gap: 20px; align-items: start; max-width: 1400px; margin: 0 auto;
}
@media (max-width: 900px) {
  .pipe-grid { grid-template-columns: minmax(0, 1fr); }
  .pipe-rail { display: none; }
}

/* ─── نقشهٔ کنار ─── */
.pipe-rail {
  position: sticky; top: 0; max-height: calc(100vh - 190px);
  overflow-y: auto; font-size: 12px;
  border-inline-start: 1px solid var(--line, #e3e6ea); padding-inline-start: 10px;
}
.pipe-rail h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted, #6b7280); }
.pipe-rail-item {
  display: flex; gap: 8px; align-items: baseline; width: 100%;
  background: none; border: none; padding: 4px 6px; border-radius: 6px;
  font: inherit; font-size: 12px; cursor: pointer; text-align: start; color: inherit;
  border-inline-start: 3px solid transparent;
}
.pipe-rail-item:hover { background: var(--surface-2, #f1f3f5); }
.pipe-rail-seq { color: var(--muted, #6b7280); min-width: 22px; }
.pipe-rail-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe-rail-flag .pipe-rail-title { color: #b45309; }

/* ─── کارتِ مرحله ─── */
.pipe-list { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.pipe-stage {
  border: 1px solid var(--line, #e3e6ea); border-radius: 10px;
  padding: 10px 12px; background: var(--surface, #fafbfc);
  border-inline-start-width: 4px;
}
.pipe-ai     { border-inline-start-color: #7c3aed; }
.pipe-code   { border-inline-start-color: #0ea5e9; }
.pipe-check  { border-inline-start-color: #16a34a; }
.pipe-answer { border-inline-start-color: #d97706; }
.pipe-system { border-inline-start-color: #94a3b8; }
.pipe-warning { background: #fffbeb; }
.pipe-failed  { background: #fef2f2; }

.pipe-stage-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; padding: 0; font: inherit; color: inherit;
  cursor: pointer; text-align: start;
}
.pipe-seq {
  min-width: 26px; height: 22px; display: inline-flex; align-items: center;
  justify-content: center; border-radius: 6px; font-size: 12px;
  background: var(--surface-2, #eef1f4); color: var(--muted, #6b7280);
}
.pipe-kind { font-size: 11px; color: var(--muted, #6b7280); white-space: nowrap; }
.pipe-title-wrap { flex: 1 1 auto; min-width: 0; display: flex; gap: 8px; align-items: baseline; }
.pipe-title { font-weight: 600; font-size: 14px; }
.pipe-subtitle {
  font-size: 12px; color: var(--muted, #6b7280);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pipe-side { display: flex; align-items: center; gap: 10px; font-size: 11px;
             color: var(--muted, #6b7280); white-space: nowrap; }
.pipe-flag { color: #b45309; font-weight: 600; }
.pipe-chev { opacity: .6; }

.pipe-what {
  margin: 8px 0 0; font-size: 12.5px; line-height: 1.9;
  color: var(--muted, #6b7280);
}
.pipe-summary {
  margin: 4px 0 0; font-size: 12.5px; line-height: 1.9;
}

.pipe-body { margin-top: 10px; border-top: 1px dashed var(--line, #e3e6ea); padding-top: 10px; }

.pipe-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pipe-chip {
  font-size: 11px; background: var(--surface-2, #eef1f4);
  border-radius: 999px; padding: 2px 9px; color: var(--muted, #4b5563);
}

.pipe-section { margin-top: 12px; }
.pipe-section-title { margin: 0 0 6px; font-size: 12px; color: var(--muted, #6b7280); }

.pipe-block {
  border: 1px solid var(--line, #e3e6ea); border-radius: 8px;
  margin-bottom: 8px; background: var(--bg, #fff); overflow: hidden;
}
.pipe-block-head {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  background: var(--surface-2, #f4f6f8); font-size: 12px;
}
.pipe-block-label { flex: 1 1 auto; font-weight: 600; }
.pipe-block-tools { display: flex; align-items: center; gap: 8px; }
.pipe-chars { font-size: 11px; color: var(--muted, #6b7280); }
.pipe-copy {
  border: 1px solid var(--line, #e3e6ea); background: var(--bg, #fff);
  border-radius: 6px; padding: 2px 8px; font: inherit; font-size: 11px;
  cursor: pointer; color: inherit;
}
.pipe-copy:hover { background: var(--surface-2, #eef1f4); }
.pipe-block-note {
  margin: 0; padding: 5px 10px; font-size: 11.5px;
  color: var(--muted, #6b7280); border-bottom: 1px solid var(--line, #eef1f4);
}

.pipe-pre {
  margin: 0; padding: 10px 12px; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.85; max-height: 340px; overflow: auto;
}
.pipe-pre-tall { max-height: 60vh; }
.pipe-ltr { direction: ltr; text-align: left; }

.pipe-more {
  display: block; width: 100%; border: none; border-top: 1px solid var(--line, #eef1f4);
  background: var(--surface-2, #f4f6f8); padding: 6px; font: inherit; font-size: 12px;
  cursor: pointer; color: var(--accent, #2a6df4);
}
.pipe-more:hover { background: var(--surface, #eceff2); }

/* ═══ صفحهٔ تنظیمِ مدلِ هر مرحله ═════════════════════════════════════ */

body.models-page { max-width: 1100px; margin: 0 auto; padding: 0 20px 60px; }

.models-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 18px 0 14px; border-bottom: 1px solid var(--line, #e3e6ea);
}
.models-head h1 { margin: 0 0 4px; font-size: 19px; }
.models-head-side { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.models-head-side .pipe-filter { text-decoration: none; }

.models-intro { margin: 18px 0; font-size: 13.5px; line-height: 2; }
.models-intro p { margin: 0 0 8px; }

.models-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--line, #e3e6ea);
  position: sticky; top: 0; background: var(--bg, #fff); z-index: 5;
}
.models-bar .pipe-filter:disabled { opacity: .45; cursor: default; }

.models-status {
  margin: 12px 0; padding: 9px 12px; border-radius: 8px; font-size: 13px;
  background: var(--surface-2, #f1f3f5);
}
.models-status.ok   { background: #ecfdf5; color: #065f46; }
.models-status.warn { background: #fffbeb; color: #92400e; }

.models-stages { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

.models-stage {
  border: 1px solid var(--line, #e3e6ea); border-radius: 10px;
  padding: 12px 14px; background: var(--surface, #fafbfc);
}
.models-stage-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.models-stage-title { font-weight: 600; font-size: 14.5px; }
.models-stage-id {
  font-size: 11.5px; background: var(--surface-2, #eef1f4);
  padding: 1px 7px; border-radius: 5px; direction: ltr;
}
.models-what { margin: 8px 0 12px; font-size: 12.5px; line-height: 1.9; color: var(--muted, #6b7280); }

.models-fields { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.models-field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 340px; min-width: 0; }
.models-field-sm { flex: 0 0 190px; }
.models-label { font-size: 11.5px; color: var(--muted, #6b7280); }
.models-hint { font-size: 11px; color: var(--muted, #9aa3ad); }

.models-select {
  font: inherit; font-size: 13px; padding: 7px 9px; border-radius: 8px;
  border: 1px solid var(--line, #e3e6ea); background: var(--bg, #fff);
  color: inherit; width: 100%; direction: ltr; text-align: left;
}
.models-select:disabled { opacity: .5; }
.models-select-sm { direction: rtl; text-align: right; }

.models-effective {
  margin: 12px 0 0; padding-top: 10px; font-size: 12.5px;
  border-top: 1px dashed var(--line, #e3e6ea);
}
.models-effective strong { direction: ltr; display: inline-block; }
.models-dirty { color: #b45309; }
