/* رایزن — سیستم طراحی
   الهام: سنگ مرمر لابی، فیروزه کاشی، برنج دستگیره‌ها، جوهر لاجوردی دفاتر حساب. */

:root {
  /* مرمر سفید لابی، زمرد مالاکیت، مس قلمزنی */
  --bg: #f4f4f0;
  --bg-deep: #ebebe5;
  --surface: #ffffff;
  --surface-2: #f8f8f5;
  --surface-3: #efefe9;
  --line: #e4e3dc;
  --line-strong: #cbcac1;
  --ink: #1c211f;
  --ink-2: #414844;
  --muted: #6e7571;
  --faint: #9aa09c;
  --turq: #0b6b4f;
  --turq-strong: #07513c;
  --turq-tint: #e2f0e9;
  --turq-soft: #bcdccd;
  --brass: #b4602b;
  --brass-strong: #8e4a1f;
  --brass-tint: #f6e8de;
  --pom: #c0392b;
  --pom-tint: #fbe6e2;
  --leaf: #1d7a4b;
  --leaf-tint: #e3f1e8;
  --amber: #b97a0c;
  --amber-tint: #fbf0d7;
  --deep: #123a2f;
  --deep-2: #1a4a3d;
  --on-deep: #eaf3ee;
  --on-deep-muted: #a9c4b8;
  --on-deep-pos: #8ee0b5;
  --on-deep-neg: #ffb3a6;
  --rail: #fbfbf8;
  --rail-2: #f0f0ea;
  --rail-ink: #2c322f;
  --rail-faint: #7c827e;
  --focus: #0b6b4f;
  --marble: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='1200'%3E%3Cfilter id='m' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0022 0.0065' numOctaves='5' seed='11'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.42 0 0 0 0 0.44 0 0 0 0 0.42 1.4 0 0 0 -0.2'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='table' tableValues='0 0 0 0 0 0.02 0.19 0.02 0 0 0 0 0 0.01 0.11 0.01 0 0 0'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");
  --star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M32 4L40.2 12.2L51.8 12.2L51.8 23.8L60 32L51.8 40.2L51.8 51.8L40.2 51.8L32 60L23.8 51.8L12.2 51.8L12.2 40.2L4 32L12.2 23.8L12.2 12.2L23.8 12.2Z' fill='none' stroke='%23B4602B' stroke-width='0.8'/%3E%3Cpath d='M32 14L37.5 19.2L44.7 19.3L44.8 26.5L50 32L44.8 37.5L44.7 44.7L37.5 44.8L32 50L26.5 44.8L19.3 44.7L19.2 37.5L14 32L19.2 26.5L19.3 19.3L26.5 19.2Z' fill='none' stroke='%230B6B4F' stroke-width='0.6'/%3E%3C/svg%3E");
  --shadow: 0 1px 2px rgba(28, 33, 31, 0.05), 0 10px 30px -16px rgba(28, 33, 31, 0.16);
  --shadow-pop: 0 24px 60px -20px rgba(28, 33, 31, 0.32);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 22px;
  --font-ui: 'Vazirmatn FD', Tahoma, 'Segoe UI', sans-serif;
  --font-display: 'Vazirmatn FD', Tahoma, sans-serif;
  --font-brand: 'Rayzan Nastaliq', 'Vazirmatn FD', serif;
  --font-code: Consolas, 'Courier New', monospace;
  --fs-xs: 11.5px;
  --fs-sm: 12.5px;
  --fs-base: 14px;
  --fs-md: 15.5px;
  --fs-lg: 18px;
  --fs-xl: 23px;
  --fs-2xl: 30px;
  --fs-3xl: 40px;
  --rail-w: 256px;
  --top-h: 64px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  /* شب مرمر سیاه با رگه زمردی */
  --bg: #0f1412;
  --bg-deep: #0a0e0c;
  --surface: #161c19;
  --surface-2: #1b2320;
  --surface-3: #212a26;
  --line: #28322d;
  --line-strong: #3a4741;
  --ink: #e6ebe8;
  --ink-2: #bcc6c0;
  --muted: #8b9690;
  --faint: #6c7771;
  --turq: #3dbd8c;
  --turq-strong: #6fd6ad;
  --turq-tint: #16332a;
  --turq-soft: #215240;
  --brass: #e08a55;
  --brass-strong: #efa77a;
  --brass-tint: #3a2519;
  --pom: #ef7564;
  --pom-tint: #3b201c;
  --leaf: #58c28a;
  --leaf-tint: #15301f;
  --amber: #e3a64a;
  --amber-tint: #372a15;
  --deep: #0c2a22;
  --deep-2: #12382d;
  --rail: #121816;
  --rail-2: #1b2320;
  --rail-ink: #d7dfda;
  --rail-faint: #7f8a84;
  --marble: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='1200'%3E%3Cfilter id='m' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0022 0.0065' numOctaves='5' seed='11'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.7 0 0 0 0 0.78 0 0 0 0 0.74 1.4 0 0 0 -0.2'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='table' tableValues='0 0 0 0 0 0.01 0.07 0.01 0 0 0 0 0 0.005 0.045 0.005 0 0 0'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px -16px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 24px 60px -20px rgba(0, 0, 0, 0.75);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.75;
  color: var(--ink);
  background: var(--bg) var(--marble) 0 0 / 1200px 1200px;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.45; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--turq); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--turq-soft); }
svg { display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.pos { color: var(--leaf); }
.neg { color: var(--pom); }
.warn { color: var(--amber); }
.nowrap { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- اسکلت ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: color-mix(in srgb, var(--rail) 86%, transparent); color: var(--rail-ink);
  border-inline-end: 1px solid var(--line);
  backdrop-filter: blur(6px);
  display: flex; flex-direction: column; padding: 18px 14px 14px;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 6px 18px; position: relative; color: var(--ink); }
.brand svg { width: 44px; height: 44px; flex: none; }
.brand-name { font-family: var(--font-brand); font-size: 31px; line-height: 1.2; letter-spacing: 0; color: var(--ink); margin-top: -10px; }
.brand-sub { font-size: 11.5px; color: var(--rail-faint); margin-top: 14px; line-height: 1.3; }
.property { position: relative; margin: 0 0 12px; }
.property-btn {
  width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr) 16px; gap: 10px; align-items: center; text-align: start;
  padding: 9px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.property-btn:hover { border-color: var(--line-strong); }
.property-btn .p-ic { width: 34px; height: 34px; border-radius: 10px; background: var(--turq-tint); color: var(--turq); display: grid; place-items: center; }
.property-btn .p-ic svg { width: 18px; height: 18px; }
.property-btn b { display: block; font-size: 13.5px; font-weight: 700; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.property-btn small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.property-btn > svg { width: 16px; height: 16px; color: var(--muted); transition: transform 0.15s; }
.property-btn[aria-expanded='true'] > svg { transform: rotate(180deg); }
.property-menu {
  position: absolute; top: calc(100% + 6px); inset-inline: 0; z-index: 40; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-pop); padding: 6px; display: grid; gap: 2px; animation: fade 0.14s;
}
.property-menu button {
  display: grid; grid-template-columns: minmax(0, 1fr) 18px; gap: 8px; align-items: center; text-align: start; border: 0; background: transparent;
  padding: 8px 10px; border-radius: 10px; color: var(--ink);
}
.property-menu button:hover, .property-menu button:focus-visible { background: var(--surface-3); }
.property-menu button[aria-checked='true'] { background: var(--turq-tint); }
.property-menu b { font-size: 13px; font-weight: 600; display: block; }
.property-menu small { font-size: 11.5px; color: var(--muted); display: block; }
.property-menu svg { width: 16px; height: 16px; color: var(--turq); }
.nav-group { margin-top: 12px; position: relative; }
.nav-group-title { font-size: 11.5px; color: var(--rail-faint); padding: 4px 10px 4px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px; border: 0; background: transparent;
  color: var(--rail-ink); border-radius: 10px; font-size: 14px; text-align: start; position: relative;
}
.nav-item svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.nav-item:hover { background: var(--rail-2); color: var(--ink); }
.nav-item[aria-current='page'] { background: var(--turq-tint); color: var(--turq-strong); font-weight: 700; }
.nav-item[aria-current='page'] svg { color: var(--turq); }
.nav-item[aria-current='page']::before {
  content: ''; position: absolute; inset-inline-start: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0;
  background: var(--brass);
}
.nav-item .count { margin-inline-start: auto; font-size: 11px; background: var(--brass); color: #fff; border-radius: 99px; padding: 0 7px; line-height: 18px; font-weight: 600; }
.rail-foot { margin-top: auto; padding-top: 14px; display: grid; gap: 8px; position: relative; }
.mode-card { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.mode-card b { color: var(--ink); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.mode-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--brass); display: inline-block; }
.mode-dot.live { background: var(--turq); box-shadow: 0 0 0 3px var(--turq-soft); }
.rail-btn { display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 8px; font-size: 13px; font-weight: 600; }
.rail-btn:hover { border-color: var(--turq); color: var(--turq-strong); }
.rail-btn svg { width: 16px; height: 16px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 14px;
  padding: 0 28px; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.icon-btn.menu-btn { display: none; }
.present-bar[hidden] { display: none; }
.crumb { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.crumb h1 { font-size: 17px; font-weight: 700; white-space: nowrap; }
.crumb span { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.today {
  display: flex; flex-direction: column; align-items: flex-end; line-height: 1.35; padding-inline-end: 12px; margin-inline-end: 4px;
  border-inline-end: 1px solid var(--line); text-align: end;
}
.today b { font-size: 13.5px; font-weight: 600; }
.today small { color: var(--muted); font-size: 11.5px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.search-btn { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); min-width: 220px; }
.search-btn svg { width: 16px; height: 16px; }
.search-btn kbd { margin-inline-start: auto; font-family: var(--font-ui); font-size: 11px; border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; direction: ltr; }
.ask-btn { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 15px; border-radius: 10px; border: 0; background: var(--turq); color: #fff; font-weight: 700; font-size: 13.5px; box-shadow: 0 6px 16px -8px var(--turq); }
:root[data-theme='dark'] .ask-btn { color: #07231a; }
.ask-btn svg { width: 17px; height: 17px; }
.ask-btn:hover { filter: brightness(1.12); }

.content { padding: 26px 28px 60px; max-width: 1380px; width: 100%; margin: 0 auto; }
.present-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 28px; background: var(--deep); color: var(--on-deep); font-size: 13px; position: sticky; top: var(--top-h); z-index: 25;
}
.present-bar .steps { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.present-bar .step { border: 0; background: transparent; color: inherit; opacity: 0.6; padding: 4px 10px; border-radius: 99px; white-space: nowrap; font-size: 12.5px; }
.present-bar .step[aria-current='step'] { opacity: 1; background: rgba(255, 255, 255, 0.14); }
.present-bar .note { font-size: 12.5px; opacity: 0.85; max-width: 42ch; }
.present-bar button.nav { border: 1px solid rgba(255, 255, 255, 0.25); background: transparent; color: inherit; border-radius: 8px; padding: 3px 12px; }

/* ---------- صفحه ---------- */
.page-head, .brief-head {
  position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px 32px; align-items: end;
  margin-bottom: 22px; padding: 22px 26px 22px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow); isolation: isolate;
}
.page-head::before, .brief-head::before {
  content: ''; position: absolute; inset: 0; z-index: -2; background: var(--marble) 0 0 / 900px 900px; opacity: 0.9;
}
.page-head::after, .brief-head::after {
  content: ''; position: absolute; z-index: -1; width: 300px; height: 300px; inset-inline-end: -120px; bottom: -150px;
  background: var(--star) center / contain no-repeat; opacity: 0.1; pointer-events: none;
}
.page-head > div:first-child, .brief-head > div:first-child { min-width: 0; }
.page-head .lede, .brief-head .lede { font-family: var(--font-display); font-size: 25px; line-height: 1.65; font-weight: 800; max-width: 62ch; color: var(--ink); text-wrap: pretty; letter-spacing: -0.2px; }
.page-head .sub { color: var(--ink-2); max-width: 92ch; margin-top: 6px; font-size: 14.5px; line-height: 1.9; }
.page-head .tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { font-size: var(--fs-lg); }
.section-head p { color: var(--muted); font-size: 13px; }
.section-head .end { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main-side { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); }
.g-side-main { grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); }
.span-2 { grid-column: span 2; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; min-width: 0; box-shadow: var(--shadow); }
.panel.tight { padding: 14px 16px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.quiet { background: var(--surface-2); border-color: transparent; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-height: 26px; flex-wrap: wrap; }
.panel-head h3 { font-size: 15px; font-weight: 700; }
.panel-head .hint { color: var(--muted); font-size: 12.5px; }
.panel-head .end { margin-inline-start: auto; display: flex; gap: 6px; align-items: center; }
.divider { height: 1px; background: var(--line); margin: 14px 0; border: 0; }

/* ---------- برچسب منشأ داده (امضای اعتماد) ---------- */
.prov { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); white-space: nowrap; border: 0; background: transparent; padding: 0; }
.prov i { width: 8px; height: 8px; border-radius: 99px; display: inline-block; flex: none; }
.prov.obs i { background: var(--ink); }
.prov.gen i { background: linear-gradient(90deg, var(--brass) 50%, transparent 50%); box-shadow: inset 0 0 0 1.5px var(--brass); }
.prov.sim i { box-shadow: inset 0 0 0 1.5px var(--turq); }
.prov.cfg i { background: var(--faint); border-radius: 2px; }
button.prov:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- دکمه‌ها و کنترل‌ها ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--turq); border-color: var(--turq); color: #fff; }
:root[data-theme='dark'] .btn.primary { color: #04191b; }
.btn.primary:hover { background: var(--turq-strong); border-color: var(--turq-strong); }
.btn.ink { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; border-radius: 7px; padding: 4px 11px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 34, 51, 0.12); font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; border: 1px solid transparent; }
.chip.turq { background: var(--turq-tint); color: var(--turq-strong); }
.chip.brass { background: var(--brass-tint); color: var(--brass-strong); }
.chip.pom { background: var(--pom-tint); color: var(--pom); }
.chip.leaf { background: var(--leaf-tint); color: var(--leaf); }
.chip.amber { background: var(--amber-tint); color: var(--amber); }
.chip.outline { background: transparent; border-color: var(--line-strong); }
.chip svg { width: 12px; height: 12px; }
.field { display: grid; gap: 6px; }
.field label, .field .label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.input, select.input, textarea.input { height: 38px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); padding: 0 11px; width: 100%; }
textarea.input { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.7; }
.input:focus { outline: 2px solid var(--turq-soft); border-color: var(--turq); }
.range { display: grid; gap: 4px; }
.range-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; }
.range-top b { font-size: 14px; font-weight: 700; color: var(--ink); }
input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; direction: rtl; }
input[type='range']::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--line); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 99px; background: var(--surface); border: 2px solid var(--turq); margin-top: -7px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
input[type='range']::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line); }
input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border-radius: 99px; background: var(--surface); border: 2px solid var(--turq); }
.range-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); }
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.toggle input { appearance: none; -webkit-appearance: none; width: 36px; height: 20px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background 0.15s; margin: 0; flex: none; }
.toggle input::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 99px; background: #fff; transition: inset-inline-start 0.15s; }
.toggle input:checked { background: var(--turq); }
.toggle input:checked::after { inset-inline-start: 18px; }

/* ---------- شاخص‌ها ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.kpi { padding: 14px 16px 12px; border-inline-start: 1px solid var(--line); display: grid; gap: 2px; align-content: start; min-width: 0; position: relative; background: transparent; border-top: 0; border-bottom: 0; border-inline-end: 0; text-align: start; }
.kpis .kpi:first-child { border-inline-start: 0; }
button.kpi:hover { background: var(--surface-2); }
.kpi .k-label { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-size: 25px; font-weight: 700; letter-spacing: -0.2px; line-height: 1.35; white-space: nowrap; }
.kpi .k-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-inline-start: 3px; }
.kpi .k-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.kpi .k-spark { position: absolute; inset-inline-end: 14px; top: 16px; opacity: 0.9; }
.delta { font-weight: 600; font-size: 12px; white-space: nowrap; direction: rtl; }
.delta.up { color: var(--leaf); }
.delta.down { color: var(--pom); }
.delta.flat { color: var(--muted); }
.delta.bad-up { color: var(--pom); }
.delta.good-down { color: var(--leaf); }

/* ---------- جدول ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: start; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.n, .table th.n { text-align: end; white-space: nowrap; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.sel td { background: var(--turq-tint); }

/* ---------- کشوی شواهد و پنل دستیار ---------- */
.scrim { position: fixed; inset: 0; background: rgba(8, 18, 27, 0.38); z-index: 60; animation: fade 0.18s ease; }
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(480px, 100vw); background: var(--surface); z-index: 61;
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column; animation: slideIn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.drawer.wide { width: min(560px, 100vw); }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 16px; }
.drawer-head .end { margin-inline-start: auto; }
.drawer-body { padding: 18px 20px 28px; overflow-y: auto; flex: 1; }
@keyframes slideIn { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: end; }
.note { border-inline-start: 3px solid var(--amber); background: var(--amber-tint); padding: 9px 12px; border-radius: 0 8px 8px 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.75; }
.note.turq { border-color: var(--turq); background: var(--turq-tint); }
.note.pom { border-color: var(--pom); background: var(--pom-tint); }
.note.ink { border-color: var(--ink); background: var(--surface-3); }

.toast-host { position: fixed; bottom: 22px; inset-inline-start: 50%; transform: translateX(50%); z-index: 90; display: grid; gap: 8px; }
.toast { background: var(--deep); color: var(--on-deep); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow-pop); font-size: 13.5px; display: flex; align-items: center; gap: 10px; animation: fade 0.2s; max-width: 90vw; }
.toast svg { width: 18px; height: 18px; color: var(--on-deep-pos); }

.tooltip { position: fixed; z-index: 95; pointer-events: none; background: var(--deep); color: var(--on-deep); border-radius: 10px; padding: 8px 11px; font-size: 12px; line-height: 1.7; box-shadow: var(--shadow-pop); max-width: 280px; }
:root[data-theme='dark'] .tooltip { background: #e6ebe8; color: #10201a; }
.tooltip b { font-weight: 700; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .sw { width: 9px; height: 3px; border-radius: 2px; display: inline-block; }

.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: start center; padding: 10vh 16px; }
.modal-card { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-pop); width: min(640px, 100%); overflow: hidden; animation: fade 0.15s; }
.palette-input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 16px 20px; font-size: 16px; background: transparent; outline: none; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; padding: 10px 14px; border-radius: 10px; text-align: start; }
.palette-item svg { width: 17px; height: 17px; color: var(--muted); }
.palette-item small { margin-inline-start: auto; color: var(--faint); font-size: 12px; }
.palette-item[aria-selected='true'] { background: var(--turq-tint); }

/* ---------- نمودارها ---------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .axis text { font-size: 10.5px; fill: var(--muted); font-family: var(--font-ui); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .zero-line { stroke: var(--line-strong); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.band { height: 10px; border-radius: 3px; opacity: 0.6; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; height: 2px; }

.bar-row { display: grid; grid-template-columns: minmax(90px, 150px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; padding: 5px 0; }
.bar-track { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--turq); }
.stack { display: flex; height: 12px; border-radius: 99px; overflow: hidden; gap: 2px; }
.stack span { display: block; height: 100%; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }

/* ---------- بارگذاری ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg) var(--marble) 0 0 / 1200px 1200px; z-index: 100; color: var(--ink); transition: opacity 0.4s; }
.boot.done { opacity: 0; pointer-events: none; }
.boot-inner { display: grid; justify-items: center; gap: 14px; }
.boot svg { width: 72px; height: 72px; }
.boot .brand-name { font-size: 38px; }
.boot-status { font-size: 12.5px; color: var(--muted); min-height: 20px; }
.boot-mark .star { stroke-dasharray: 260; stroke-dashoffset: 260; animation: draw 1.1s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- واکنش‌گرا ---------- */
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main-side, .g-side-main { grid-template-columns: minmax(0, 1fr); }
  .search-btn { min-width: 0; }
  .search-btn span, .search-btn kbd { display: none; }
}
@media (max-width: 900px) {
  :root { --top-h: 58px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(300px, 86vw); z-index: 80; transform: translateX(110%); transition: transform 0.22s ease; }
  .rail.open { transform: none; box-shadow: var(--shadow-pop); }
  .icon-btn.menu-btn { display: grid; }
  .topbar { padding: 0 16px; gap: 10px; }
  .today { display: none; }
  .content { padding: 18px 16px 90px; }
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .page-head, .brief-head { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 18px; }
  .page-head .tools { justify-content: flex-start; }
  .page-head .lede, .brief-head .lede { font-size: 20px; }
  .rail { background: var(--rail); }
  .present-bar { padding: 8px 16px; }
  .present-bar .note { display: none; }
  .ask-btn span { display: none; }
  .crumb span { display: none; }
  .mobile-nav { display: flex; }
}
@media (max-width: 560px) {
  .g-4 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-inline-start: 0; border-top: 1px solid var(--line); }
  .kpi .k-value { font-size: 21px; }
  .panel { padding: 14px; }
  .bar-row { grid-template-columns: 96px minmax(0, 1fr) auto; }
}
.mobile-nav {
  display: none; position: fixed; bottom: 0; inset-inline: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around;
}
.mobile-nav button { border: 0; background: transparent; display: grid; justify-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); padding: 4px 6px; min-width: 56px; }
.mobile-nav button svg { width: 20px; height: 20px; }
.mobile-nav button[aria-current='page'] { color: var(--turq); }

@media print {
  .rail, .topbar, .mobile-nav, .present-bar { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
}
