/* ==========================================================================
   اتوبفرست — سیستم طراحی رابط وب
   لاجوردی به‌عنوان رنگ اصلی روی زمینه‌ی کاغذیِ گرم؛ تم تیره با همان نقش‌ها.
   همه‌ی رنگ‌ها از توکن می‌آیند تا روشن/تیره در یک جا عوض شود.
   ========================================================================== */

/* وزیرمتن (مجوز OFL — fonts/OFL.txt)؛ کنار برنامه میزبانی می‌شود چون CSP فونت بیرونی را اجازه نمی‌دهد */
@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* سطح‌ها */
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f4f3ee;
  --surface-3: #eae8e1;
  --field-bg: #ffffff;
  --border: #e4e2da;
  --border-strong: #cfccc2;

  /* متن */
  --text: #1a1b1f;
  --text-2: #4e5158;
  --text-3: #6c6f77;

  /* رنگ اصلی */
  --accent: #2743c4;
  --accent-solid: #2743c4;
  --accent-solid-hover: #1e37a8;
  --accent-soft: #e9edfc;
  --accent-ink: #2038ae;
  --on-accent: #ffffff;

  /* وضعیت‌ها */
  --ok: #0f7a56;
  --ok-solid: #0f7f59;
  --ok-solid-hover: #0c6c4b;
  --ok-soft: #e1f4eb;
  --danger: #b92f26;
  --danger-solid: #c8372d;
  --danger-solid-hover: #ab2c23;
  --danger-soft: #fbe9e6;
  --warn: #8f5600;
  --warn-solid: #d98a00;
  --warn-soft: #fbf0d6;

  /* نمودارها — پالت دسته‌ای با ترتیب ثابت (اعتبارسنجی‌شده برای کوررنگی) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --grid: #eceae4;
  --axis: #cfccc2;

  --inverse-bg: #1f2126;
  --inverse-text: #ffffff;
  --inverse-muted: #b9bcc4;
  --overlay: rgba(22, 24, 30, .42);

  --shadow-1: 0 1px 2px rgba(22, 24, 30, .05);
  --shadow-2: 0 6px 20px rgba(22, 24, 30, .09), 0 1px 3px rgba(22, 24, 30, .06);
  --shadow-3: 0 22px 56px rgba(22, 24, 30, .2), 0 4px 14px rgba(22, 24, 30, .08);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --ring: 0 0 0 3px rgba(39, 67, 196, .24);

  --sidebar-w: 272px;
  --topbar-h: 68px;
  --bottom-nav-h: 0px;

  --font: "Vazirmatn", "Segoe UI Variable Text", "Segoe UI", Tahoma, system-ui, -apple-system, "Noto Sans Arabic", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e1014;
  --surface: #15181d;
  --surface-2: #1b1f26;
  --surface-3: #242932;
  --field-bg: #101318;
  --border: #272c35;
  --border-strong: #3a404c;

  --text: #eceef1;
  --text-2: #b6bac3;
  --text-3: #8d929d;

  --accent: #96a7ff;
  --accent-solid: #4a61e0;
  --accent-solid-hover: #5b71ea;
  --accent-soft: #1c2449;
  --accent-ink: #b3bfff;

  --ok: #4fd39d;
  --ok-solid: #15805a;
  --ok-solid-hover: #1a926a;
  --ok-soft: #10291f;
  --danger: #ff8e85;
  --danger-solid: #c9392f;
  --danger-solid-hover: #d9483e;
  --danger-soft: #371614;
  --warn: #f2b84f;
  --warn-solid: #c98500;
  --warn-soft: #30250e;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --grid: #20252d;
  --axis: #3a404c;

  --inverse-bg: #2a303b;
  --inverse-text: #ffffff;
  --inverse-muted: #aeb3bf;
  --overlay: rgba(0, 0, 0, .6);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, .6), 0 4px 14px rgba(0, 0, 0, .35);
  --ring: 0 0 0 3px rgba(150, 167, 255, .3);
}

/* ---------- پایه ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 12px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 19px; font-weight: 700; line-height: 1.4; letter-spacing: -.1px; }
h2 { font-size: 15.5px; font-weight: 650; line-height: 1.5; }
h3 { font-size: 14px; font-weight: 650; }
b, strong { font-weight: 650; }
small { font-size: 12.5px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }

code, kbd {
  font-family: var(--mono);
  font-size: 12px;
  direction: ltr;
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 5px;
  line-height: 1.6;
}

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

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hidden, [hidden] { display: none !important; }
.grow { flex: 1 1 0; min-width: 0; }
.muted { color: var(--text-3); font-size: 13px; }
.hint { color: var(--text-3); font-style: normal; font-size: 12px; font-weight: 400; margin-inline-start: 6px; }
.hint.saved { color: var(--ok); }
.danger-text { color: var(--danger); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.noscript { padding: 24px; text-align: center; }

body.no-accounts .needs-account { display: none !important; }
body:not(.is-admin) .admin-only { display: none !important; }

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.flip { transform: scaleX(-1); }

.skip-link {
  position: fixed;
  top: -60px;
  inset-inline-start: 12px;
  z-index: 200;
  background: var(--accent-solid);
  color: var(--on-accent);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top .15s;
}
.skip-link:focus { top: 12px; }

/* ---------- چیدمان کلی ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  z-index: 50;
}

.main-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }

main {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 26px 32px 120px;
  transition: opacity .2s;
}
body.booting main { opacity: 0; }

.panel { display: none; }
.panel.active { display: block; animation: panel-in .22s ease-out; }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- نوار کناری ---------- */
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 18px 12px;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--text); flex: 1; min-width: 0; }
.brand-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #3d5ce6, #1b2f96);
  box-shadow: 0 4px 12px rgba(39, 67, 196, .32), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.brand-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.brand-text b { font-size: 16px; font-weight: 750; letter-spacing: -.2px; }
.brand-text small { font-size: 11.5px; color: var(--text-3); }
.icon-btn.drawer-close { display: none; }

/* انتخاب اکانت */
.switcher { position: relative; padding: 4px 12px 10px; }
.switcher-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: start;
  transition: border-color .15s, background .15s;
}
.switcher-btn:hover { border-color: var(--border-strong); }
.switcher-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: var(--ring); }
.switcher-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.4; }
.switcher-text b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.switcher-text small { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.switcher-text small.on { color: var(--ok); }
.switcher-text small::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.switcher-text small.on::before { background: var(--ok); }
.chev { color: var(--text-3); width: 16px; height: 16px; transition: transform .15s; }
[aria-expanded="true"] > .chev { transform: rotate(180deg); }

.popover {
  position: absolute;
  inset-inline: 12px;
  top: calc(100% - 4px);
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  padding: 6px;
  max-height: min(60vh, 420px);
  overflow: auto;
  animation: pop-in .14s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.popover-label { font-size: 11.5px; color: var(--text-3); padding: 6px 8px 4px; }
.popover-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  text-align: start;
  font-size: 13.5px;
}
.popover-item:hover, .popover-item:focus-visible { background: var(--surface-2); }
.popover-item.current { background: var(--accent-soft); color: var(--accent-ink); }
.popover-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; direction: ltr; }
.popover-item .owner { font-size: 11.5px; color: var(--text-3); }
.popover-item .run-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.popover-item .run-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.popover-add { margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-xs) var(--radius-xs); padding-top: 10px; color: var(--accent); font-weight: 550; }
.popover-plus { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }

/* ناوبری */
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; scrollbar-width: thin; }
.nav-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 14px 10px 4px; letter-spacing: .1px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  margin-block: 1px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item .icon { color: var(--text-3); transition: color .12s; }
.nav-item > span:not(.count-badge) { flex: 1; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }
.nav-item.active .icon { color: var(--accent); }
.nav-item:focus-visible { outline-offset: -2px; }
.nav-dot { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--warn-solid); }
.nav-item.dirty .nav-dot { display: block; }

.count-badge {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger-solid);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  line-height: 20px;
  text-align: center;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.user-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.4; }
.user-text b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.user-text small { font-size: 11.5px; color: var(--text-3); }
:root[data-theme="dark"] .theme-moon, :root:not([data-theme="dark"]) .theme-sun { display: none; }

/* آواتار — رنگ از روی نام ساخته می‌شود (‎--hue‎) */
.avatar {
  --hue: 228;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  background: hsl(var(--hue) 62% 92%);
  color: hsl(var(--hue) 48% 34%);
  user-select: none;
}
:root[data-theme="dark"] .avatar { background: hsl(var(--hue) 34% 22%); color: hsl(var(--hue) 72% 82%); }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-bot { background: var(--accent-soft) !important; color: var(--accent-ink) !important; }

/* ---------- نوار بالا ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 32px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.icon-btn.menu-btn { display: none; }
.page-head { flex: 1; min-width: 0; }
.page-head p { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.5; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 550;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
}
.status i { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.status-on { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.status-on i { background: var(--ok); }
.status-on i::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--ok);
  opacity: 0;
  animation: ping 2s ease-out infinite;
}
@keyframes ping { 0% { transform: scale(.5); opacity: .7; } 80%, 100% { transform: scale(1.5); opacity: 0; } }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 550;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
}
.chip .icon { width: 15px; height: 15px; }
.chip-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }

/* ---------- دکمه ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, transform .06s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn .icon { width: 16px; height: 16px; }

.btn-primary { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--on-accent); box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--accent-solid-hover); border-color: var(--accent-solid-hover); }
.btn-go { background: var(--ok-solid); border-color: var(--ok-solid); color: #fff; box-shadow: var(--shadow-1); }
.btn-go:hover { background: var(--ok-solid-hover); border-color: var(--ok-solid-hover); }
.btn-danger { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
.btn-danger:hover { background: var(--danger-solid-hover); border-color: var(--danger-solid-hover); }
.btn-stop, .btn-danger-outline { background: var(--surface); border-color: var(--border-strong); color: var(--danger); }
.btn-stop:hover, .btn-danger-outline:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.btn-soft:hover { background: color-mix(in srgb, var(--accent-soft) 80%, var(--accent)); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn-icon { width: 40px; height: 40px; padding: 0; flex-shrink: 0; }
.btn kbd { background: rgba(255, 255, 255, .16); border: none; color: inherit; font-size: 10.5px; padding: 2px 5px; opacity: .85; }

.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading > * { visibility: hidden; }
.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-3);
  border-top-color: transparent;
  animation: spin .7s linear infinite;
}
.btn-primary.loading::after, .btn-go.loading::after, .btn-danger.loading::after { border-color: #fff; border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.icon-btn.spinning .icon { animation: spin .7s linear infinite; }

.link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 550; text-decoration: none; white-space: nowrap; }
.link:hover { text-decoration: underline; }
.link .icon { width: 15px; height: 15px; }

/* ---------- کارت و بخش ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 20px;
  margin-bottom: 16px;
  min-width: 0;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head > div:first-child { flex: 1; min-width: 0; }
.card-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px -20px -20px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; min-width: 0; }
.stack > .card, .section > .card, .grid-2 > .card, .grid-main > .card { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }

/* بخش تنظیمات: توضیح کنار، کنترل‌ها در کارت */
.section {
  display: grid;
  grid-template-columns: minmax(0, 250px) minmax(0, 1fr);
  gap: 16px 36px;
  align-items: start;
  padding-block: 22px;
  border-top: 1px solid var(--border);
}
.panel > .section:first-child, form > .section:first-child { border-top: none; padding-top: 4px; }
.section-info { position: sticky; top: calc(var(--topbar-h) + 18px); }
.section-info h2 { margin-bottom: 6px; }
.section-info p { color: var(--text-3); font-size: 13px; margin-bottom: 8px; }
.section-info .btn { margin-top: 4px; }

.list-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
.list-head h2 { display: flex; align-items: center; gap: 8px; }
.count {
  display: inline-block;
  min-width: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 22px;
  text-align: center;
}
.count:empty { display: none; }
.inline { display: inline-flex; align-items: center; gap: 8px; }

.callout, .banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  margin-bottom: 18px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
}
.callout .icon, .banner > .icon { margin-top: 3px; }
.callout p { color: inherit; }
.banner { align-items: center; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner > .icon { margin-top: 0; }
.banner .btn { margin-inline-start: auto; }
.banner:empty { display: none; }

.foreign-note {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 32px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 13px;
  font-weight: 550;
}

/* ---------- فرم ---------- */
.fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.fields.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields + .fields, .choice-grid + .fields { margin-top: 16px; }

.field { display: block; min-width: 0; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field-help { display: block; margin-top: 6px; color: var(--text-3); font-size: 12.5px; line-height: 1.65; }
.field-help:empty { display: none; }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: 6px; }
.field-block { padding-top: 16px; margin-top: 4px; border-top: 1px solid var(--border); }

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%;
  min-height: 40px;
  background: var(--field-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.6;
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: .75; }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input[type=number] { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[aria-invalid="true"], .input-wrap:has([aria-invalid="true"]) { border-color: var(--danger); }
input[type=search]::-webkit-search-cancel-button { cursor: pointer; }
textarea { resize: vertical; line-height: 1.9; min-height: 64px; display: block; }
select {
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23808590' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 10px center;
  background-size: 16px;
  cursor: pointer;
}
.select-sm { min-height: 32px; padding-block: 3px; font-size: 13px; width: auto; }
#system-prompt { font-size: 13.5px; }

/* ورودی با پیشوند/پسوند یا دکمه‌ی داخلی */
.input-wrap {
  display: flex;
  align-items: stretch;
  min-height: 40px;
  background: var(--field-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
  overflow: hidden;
}
.input-wrap:hover { border-color: var(--text-3); }
.input-wrap:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.input-wrap.ltr { direction: ltr; }
.input-wrap input { flex: 1; min-width: 0; min-height: 38px; border: none !important; box-shadow: none !important; background: transparent; border-radius: 0; }
.input-wrap.ltr input { padding-inline-start: 4px; }
.affix { display: flex; align-items: center; padding-inline: 12px; color: var(--text-3); font-size: 13px; white-space: nowrap; user-select: none; }
.input-wrap.ltr .affix { padding-inline-end: 0; font-size: 15px; }
.input-wrap input + .affix { padding-inline-start: 4px; border-inline-start: none; }
.input-action {
  display: grid;
  place-items: center;
  width: 40px;
  background: none;
  border: none;
  color: var(--text-3);
}
.input-action:hover { color: var(--text); }
.input-action:focus-visible { outline-offset: -3px; }

.inline-form { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.inline-form .input-wrap { min-width: 200px; }
#account-list:not(:empty) + .inline-form { margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--border); }

/* کلید روشن/خاموش */
.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 14px 0;
  cursor: pointer;
}
.switch-row + .switch-row { border-top: 1px solid var(--border); }
.switch-row:first-child { padding-top: 0; }
.switch-row:last-child { padding-bottom: 0; }
.switch-text { flex: 1; min-width: 0; }
.switch-text strong { display: block; font-size: 14px; }
.switch-text small { display: block; color: var(--text-3); font-size: 12.5px; line-height: 1.7; margin-top: 2px; }
.switch-text small b { color: var(--text-2); }

input.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 24px;
  min-height: 0;
  margin: 2px 0 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background .16s;
}
input.switch::before {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .16s cubic-bezier(.3, 1.3, .5, 1);
}
input.switch:checked { background: var(--accent-solid); }
input.switch:checked::before { transform: translateX(-18px); }
input.switch:hover { border: none; }
input.switch:focus-visible { box-shadow: var(--ring); }

.check-inline { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.check-inline input { width: 16px; height: 16px; accent-color: var(--accent-solid); margin: 0; }

/* انتخاب کارتی (سرویس هوش مصنوعی) */
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-body {
  display: block;
  height: 100%;
  padding: 13px 16px;
  padding-inline-start: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.choice-body::before {
  content: "";
  position: absolute;
  top: 16px;
  inset-inline-start: 15px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--field-bg);
  transition: border-color .12s, border-width .12s;
}
.choice-body strong { display: block; font-size: 14px; }
.choice-body small { display: block; color: var(--text-3); line-height: 1.65; }
.choice:hover .choice-body { border-color: var(--text-3); }
.choice input:checked + .choice-body { border-color: var(--accent); background: var(--accent-soft); }
.choice input:checked + .choice-body::before { border-color: var(--accent-solid); border-width: 6px; }
.choice input:focus-visible + .choice-body { box-shadow: var(--ring); }

/* ورودی برچسبی (کلیدواژه‌ها، لیست مسدودها) */
.tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 5px 8px;
  background: var(--field-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: text;
  transition: border-color .12s, box-shadow .12s;
}
.tags:hover { border-color: var(--text-3); }
.tags:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.tags input {
  flex: 1 1 120px;
  min-width: 80px;
  min-height: 28px;
  padding: 0 4px;
  border: none !important;
  box-shadow: none !important;
  background: transparent;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  height: 28px;
  padding-inline: 10px 3px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 550;
  animation: chip-in .14s ease-out;
}
@keyframes chip-in { from { transform: scale(.85); opacity: 0; } }
.tag-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-chip button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 6px;
  color: inherit;
  opacity: .65;
}
.tag-chip button:hover { opacity: 1; background: color-mix(in srgb, var(--accent) 16%, transparent); }
.tag-chip button .icon { width: 13px; height: 13px; stroke-width: 2.2; }

/* کنترل چندتکه */
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: 11px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.seg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.seg:hover { color: var(--text); }
.seg.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
:root[data-theme="dark"] .seg.active { background: var(--border-strong); }
.seg b { font-weight: 600; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.seg .icon { width: 15px; height: 15px; }
.seg .dot { margin: 0; }
label.seg { cursor: pointer; }
label.seg input { position: absolute; opacity: 0; pointer-events: none; }
label.seg:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
:root[data-theme="dark"] label.seg:has(input:checked) { background: var(--border-strong); }
label.seg:has(input:focus-visible) { box-shadow: var(--ring); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 200px;
}
.search .icon { position: absolute; inset-inline-start: 12px; color: var(--text-3); pointer-events: none; width: 16px; height: 16px; }
.search input { padding-inline-start: 36px; }

.chip-toggle { cursor: pointer; }
.chip-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.chip-toggle span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.chip-toggle span .icon { width: 15px; height: 15px; }
.chip-toggle:hover span { background: var(--surface-2); }
.chip-toggle input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.chip-toggle input:focus-visible + span { box-shadow: var(--ring); }

/* ---------- برچسب منبع ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--border-strong); }
.s-rule { background: var(--series-1); fill: var(--series-1); }
.s-ai { background: var(--series-2); fill: var(--series-2); }
.s-auto { background: var(--series-3); fill: var(--series-3); }
.s-fallback { background: var(--series-4); fill: var(--series-4); }
.s-muted { background: var(--border-strong); fill: var(--border-strong); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.role-admin { background: var(--accent-soft); color: var(--accent-ink); }
.st-pending { background: var(--warn-soft); color: var(--warn); }
.st-active { background: var(--ok-soft); color: var(--ok); }
.st-disabled { background: var(--danger-soft); color: var(--danger); }

/* ---------- حالت خالی و اسکلت بارگذاری ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 34px 20px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty .empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  background: var(--surface-2);
  color: var(--text-3);
}
.empty .empty-icon .icon { width: 22px; height: 22px; }
.empty strong { color: var(--text); font-size: 14px; }
.empty .btn { margin-top: 12px; }
.empty.compact { padding: 18px 12px; }

.skeleton {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 45%, var(--surface-2) 65%);
  background-size: 300% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
.skeleton-row { display: grid; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.skeleton-row:last-child { border-bottom: none; }

/* ---------- بنر کد تأیید ---------- */
.challenge {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 18px 32px 0;
  padding: 16px 20px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: var(--radius);
  color: var(--accent-ink);
  box-shadow: var(--shadow-2);
}
.challenge-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-solid); color: #fff; flex-shrink: 0; }
.challenge-body { flex: 1; min-width: 240px; }
.challenge-body strong { display: block; font-size: 15px; margin-bottom: 2px; }
.challenge-body p { font-size: 13px; }
.challenge-error { color: var(--danger); margin-top: 6px !important; font-weight: 550; }
.challenge-form { display: flex; gap: 8px; }
.challenge-form input {
  width: 168px;
  text-align: center;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 6px;
  padding: 4px 8px;
  border-color: var(--accent);
}

/* ---------- خوش‌آمد (بدون اکانت) ---------- */
.welcome {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 40px;
  align-items: center;
  max-width: 940px;
  margin: 6vh auto 0;
  padding: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-2);
}
.welcome-body h2 { font-size: 22px; font-weight: 750; margin-bottom: 10px; }
.welcome-body > p { color: var(--text-2); margin-bottom: 20px; }
.welcome-steps { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 12px; }
.welcome-steps li { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-3); }
.welcome-steps b { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; flex-shrink: 0; }
.welcome-steps strong { display: block; color: var(--text); font-size: 13.5px; }
.welcome-art {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px 20px;
  border-radius: 16px;
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
    var(--surface-2);
  border: 1px solid var(--border);
}
.mock-bubble { max-width: 86%; padding: 9px 14px; border-radius: 16px; font-size: 13px; line-height: 1.7; box-shadow: var(--shadow-1); }
.mock-bubble.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-start-start-radius: 5px; }
.mock-bubble.out { align-self: flex-end; background: var(--accent-solid); color: #fff; border-end-end-radius: 5px; }
.mock-typing, .typing { align-self: flex-end; display: inline-flex; gap: 4px; padding: 12px 14px; border-radius: 16px; background: var(--accent-soft); }
.mock-typing i, .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: typing 1.2s ease-in-out infinite; }
.mock-typing i:nth-child(2), .typing i:nth-child(2) { animation-delay: .15s; }
.mock-typing i:nth-child(3), .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: none; opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- نمای کلی: وضعیت ربات ---------- */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 24px 26px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 140% at 100% 0%, color-mix(in srgb, var(--hero-tint, var(--text-3)) 11%, transparent), transparent 70%);
  pointer-events: none;
}
.hero.is-on { --hero-tint: var(--ok); }
.hero.is-test { --hero-tint: var(--warn-solid); }
.hero > * { position: relative; }

.hero-orb { width: 64px; height: 64px; display: grid; place-items: center; }
.orb {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-3);
}
.orb .icon { width: 24px; height: 24px; }
.is-on .orb { background: var(--ok-solid); color: #fff; }
.is-on .orb::before, .is-on .orb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--ok);
  opacity: 0;
  animation: orb 2.6s ease-out infinite;
}
.is-on .orb::after { animation-delay: 1.3s; }
@keyframes orb { 0% { transform: scale(1); opacity: .5; } 100% { transform: scale(1.65); opacity: 0; } }

.hero-kicker { font-size: 12.5px; color: var(--text-3); text-align: right; font-weight: 550; }
.hero-title { font-size: 21px; font-weight: 750; line-height: 1.45; letter-spacing: -.2px; }
.hero-sub { color: var(--text-2); font-size: 13.5px; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hero-activity { display: flex; align-items: center; gap: 7px; margin-top: 12px; color: var(--text-3); font-size: 12.5px; min-width: 0; }
.hero-activity .icon { width: 14px; height: 14px; }
.hero-activity span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }

/* ---------- چک‌لیست راه‌اندازی ---------- */
.checklist { padding: 0; overflow: hidden; }
.checklist-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.checklist-head > div { flex: 1; min-width: 0; }
.progress-ring { width: 40px; height: 40px; flex-shrink: 0; transform: rotate(-90deg); }
.progress-ring circle { fill: none; stroke-width: 4; }
.progress-ring .track { stroke: var(--surface-3); }
.progress-ring .bar { stroke: var(--accent-solid); stroke-linecap: round; transition: stroke-dashoffset .4s ease; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; align-items: center; gap: 14px; padding: 12px 20px; }
.step + .step { border-top: 1px solid var(--border); }
.step-mark {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--border-strong);
  color: transparent;
}
.step-mark .icon { width: 13px; height: 13px; stroke-width: 2.6; }
.step.done .step-mark { background: var(--ok-solid); border-color: var(--ok-solid); color: #fff; }
.step-text { flex: 1; min-width: 0; }
.step-text strong { display: block; font-size: 13.5px; }
.step-text small { color: var(--text-3); }
.step.done .step-text strong { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--border-strong); font-weight: 500; }
.step.done .step-text small, .step.done .btn { display: none; }
.step .opt { font-size: 11px; color: var(--text-3); font-weight: 500; margin-inline-start: 6px; text-decoration: none; display: inline-block; }

/* ---------- کاشی‌های آمار ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.kpi-label { font-size: 12.5px; color: var(--text-3); font-weight: 550; }
.kpi-value { font-size: 27px; font-weight: 700; line-height: 1.35; letter-spacing: -.3px; }
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--text-3); margin-inline-start: 4px; letter-spacing: 0; }
.kpi-sub { font-size: 12px; color: var(--text-3); min-height: 20px; }
.kpi-sub .up { color: var(--ok); font-weight: 600; }
.kpi .spark { position: absolute; left: 16px; bottom: 16px; }
.kpi .meter { margin-top: 8px; }

.meter { display: block; height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent-solid); transition: width .3s ease; }
.meter.warn { background: var(--warn-soft); }
.meter.warn i { background: var(--warn-solid); }
.meter.full { background: var(--danger-soft); }
.meter.full i { background: var(--danger-solid); }
.meter-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.meter-row .meter { flex: 1; }

.quota-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.quota-top b { font-size: 24px; font-weight: 700; }
.quota-top span { color: var(--text-3); font-size: 13px; }
.quota p { margin-top: 10px; }

/* ---------- فهرست گفتگوها (تاریخچه و آخرین جواب‌ها) ---------- */
/* clip (نه hidden) تا برچسبِ چسبانِ روز نسبت به صفحه بچسبد، نه نسبت به خودِ فهرست */
.feed { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: clip; }
.feed:empty { display: none; }
.day-label {
  position: sticky;
  top: var(--topbar-h);
  z-index: 2;
  padding: 7px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
}
.exchange + .day-label { border-top: 1px solid var(--border); }
.exchange { display: flex; gap: 12px; padding: 16px 20px; }
.exchange + .exchange { border-top: 1px solid var(--border); }
.exchange-main { flex: 1; min-width: 0; }
.exchange-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.handle { color: var(--text); font-weight: 650; font-size: 13.5px; text-decoration: none; }
a.handle:hover { color: var(--accent); }
.time { color: var(--text-3); font-size: 12px; margin-inline-start: auto; white-space: nowrap; }
.thread { display: flex; flex-direction: column; gap: 6px; }
.bubble {
  max-width: min(86%, 620px);
  padding: 8px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble.in { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-start-start-radius: 5px; }
.bubble.out { align-self: flex-end; background: var(--accent-soft); color: var(--accent-ink); border-end-end-radius: 5px; }
#ov-recent .exchange { padding-inline: 0; }
#ov-recent .exchange:first-child { padding-top: 0; }
#ov-recent .exchange:last-child { padding-bottom: 0; }
.list-note { text-align: center; margin-top: 12px; }

/* ---------- سهم منبع‌ها ---------- */
.mix-bar { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; margin-bottom: 14px; }
.mix-bar i { display: block; min-width: 3px; }
.mix-row { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 13px; }
.mix-row span:nth-child(2) { flex: 1; }
.mix-row b { font-variant-numeric: tabular-nums; }
.mix-row small { color: var(--text-3); width: 44px; text-align: left; font-variant-numeric: tabular-nums; }

/* ---------- ردیف‌های ساده (اکانت‌ها، گفتگوهای ساکت) ---------- */
.account-row, .row-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  min-width: 0;
}
.account-row:last-child, .row-item:last-child { margin-bottom: 0; }
.account-row.current { border-color: var(--accent); background: var(--accent-soft); }
.account-row b, .row-item b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-row .meta, .row-item .meta { flex: 1; min-width: 0; color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-row .status { height: 26px; padding: 0 10px; font-size: 12px; }

/* ---------- مشتری‌ها ---------- */
.lead { display: flex; gap: 12px; padding: 16px 20px; }
.lead + .lead { border-top: 1px solid var(--border); }
.lead-main { flex: 1; min-width: 0; }
.lead-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lead-user { display: inline-flex; align-items: center; gap: 4px; }
.lead-user .icon { width: 13px; height: 13px; color: var(--text-3); }
.lead-meta { color: var(--text-3); font-size: 12px; min-width: 120px; }
.lead-status {
  width: auto;
  min-height: 30px;
  padding-block: 2px;
  padding-inline: 12px 30px;
  border-radius: 999px;
  border-color: transparent;
  font-size: 12.5px;
  font-weight: 600;
  background-color: var(--surface-2);
  background-position: left 8px center;
}
.lead-status.st-new { background-color: var(--accent-soft); color: var(--accent-ink); }
.lead-status.st-contacted { background-color: var(--warn-soft); color: var(--warn); }
.lead-status.st-customer { background-color: var(--ok-soft); color: var(--ok); }
.lead-status.st-ignored { background-color: var(--surface-3); color: var(--text-3); }
.lead-status option { background: var(--surface); color: var(--text); }
.lead-contacts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.lead-contacts:empty, .lead-interest:empty { display: none; }
.contact-chip {
  display: inline-flex;
  align-items: center;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  font-size: 13px;
  background: var(--surface);
}
.contact-chip a { display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; height: 100%; color: var(--text); text-decoration: none; font-variant-numeric: tabular-nums; direction: ltr; }
.contact-chip a .icon { width: 14px; height: 14px; color: var(--ok); }
.contact-chip a:hover { background: var(--surface-2); }
.contact-chip button { display: grid; place-items: center; width: 30px; height: 100%; background: none; border: none; border-inline-start: 1px solid var(--border); color: var(--text-3); }
.contact-chip button:hover { background: var(--surface-2); color: var(--text); }
.contact-chip button .icon { width: 14px; height: 14px; }
.lead-interest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.lead-msg { margin-top: 8px; padding: 8px 13px; border-radius: 12px; border-start-start-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 720px; }
.lead-note { margin-top: 8px; min-height: 36px !important; font-size: 13px !important; background: transparent !important; border-style: dashed !important; max-width: 720px; }
.lead-note:focus { border-style: solid !important; }

/* ---------- قوانین ---------- */
.rules { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 8px; }
.rules:empty { display: none; }
.rule {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: border-color .15s, box-shadow .15s;
}
.rule.open { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.rule.flash { animation: flash 1s ease-out; }
@keyframes flash { 0% { box-shadow: var(--ring); border-color: var(--accent); } }
.rule-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 8px; }
.rule-num {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
}
.rule-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 4px;
  background: none;
  border: none;
  text-align: start;
  border-radius: 8px;
}
.rule-title { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rule-title.blank { color: var(--text-3); font-weight: 500; }
.rule-summary { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rule-summary.warn { color: var(--warn); }
.rule-tools { display: flex; align-items: center; gap: 2px; }
.rule-tools .chev { margin-inline: 6px 4px; }
.rule.open .rule-tools .chev { transform: rotate(180deg); }
.rule-body { display: none; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 4px 16px 18px; border-top: 1px solid var(--border); padding-top: 16px; }
.rule.open .rule-body { display: grid; }
.rule.static .rule-body { display: grid; border-top: none; padding-top: 16px; }
.rule-body .row-2 { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: end; }
.variant { display: flex; gap: 6px; align-items: flex-start; margin-bottom: 8px; }
.variant textarea { flex: 1; }
.variant .icon-btn { margin-top: 2px; }
.trigger-head { display: flex; align-items: flex-end; gap: 10px; }
.trigger-head .field { flex: 1; }

/* ---------- هوش مصنوعی ---------- */
.try-card { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.try-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); flex-shrink: 0; }
.try-icon .icon { width: 22px; height: 22px; }
.comments-grid { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); transition: opacity .15s; }
.comments-grid.is-off { opacity: .55; }

/* ---------- حذف اکانت ---------- */
.danger-card { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

/* ---------- لاگ ---------- */
.log-toolbar { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.log-toolbar .search { min-width: 150px; }
.log-toolbar .search input, .log-toolbar .segmented { min-height: 0; }
.log-toolbar .search input { height: 36px; min-height: 36px; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--ok); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: blink 1.6s ease-in-out infinite; }
.live.off { color: var(--text-3); }
.live.off i { background: var(--border-strong); animation: none; }
@keyframes blink { 50% { opacity: .3; } }

.logbox {
  direction: ltr;
  text-align: left;
  height: min(64vh, 640px);
  min-height: 320px;
  overflow: auto;
  padding: 12px 0;
  background: #0b0d11;
  color: #c8cdd8;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.8;
  scrollbar-color: #2c313b transparent;
}
.logbox:focus-visible { outline-offset: -2px; }
.log-line { display: flex; gap: 12px; padding: 0 16px; white-space: pre-wrap; word-break: break-word; }
.log-line:hover { background: rgba(255, 255, 255, .04); }
.log-time { color: #6b7280; flex-shrink: 0; }
.log-lvl { flex-shrink: 0; width: 44px; font-weight: 600; color: #6b9cf0; }
.log-src { flex-shrink: 0; color: #7c8494; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-msg { flex: 1; min-width: 0; unicode-bidi: plaintext; }
.log-warn .log-lvl, .log-warn .log-msg { color: #e8b84a; }
.log-error .log-lvl, .log-error .log-msg { color: #ff8a80; }
.log-error { background: rgba(255, 99, 88, .07); }
.log-empty { padding: 40px 16px; text-align: center; color: #7c8494; font-family: var(--font); direction: rtl; font-size: 13px; }

/* ---------- نمودارها ---------- */
.viz { direction: ltr; overflow: hidden; }
.viz svg { display: block; }
.viz-grid { stroke: var(--grid); stroke-width: 1; }
.viz-base { stroke: var(--axis); stroke-width: 1; }
.viz-tick { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.viz-hit { cursor: default; }
.viz-hit.on { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); padding-top: 4px; }
.viz-legend span { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend .dot, .viz-tip .dot { width: 10px; height: 10px; border-radius: 3px; }
.viz-tip {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  min-width: 150px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  font-size: 12px;
  line-height: 1.9;
}
.viz-tip b { display: block; font-size: 13px; }
.viz-tip div { display: flex; align-items: center; gap: 7px; }
.viz-tip div span { flex: 1; }
.viz-tip div em { font-style: normal; font-weight: 650; font-variant-numeric: tabular-nums; }
.viz-tip .total { color: var(--text-3); border-bottom: 1px solid var(--border); margin-bottom: 4px; padding-bottom: 2px; }

.viz-table { margin-top: 12px; font-size: 13px; }
.viz-table summary { cursor: pointer; color: var(--text-3); font-size: 12.5px; width: fit-content; border-radius: 6px; padding: 2px 4px; }
.viz-table summary:hover { color: var(--text); }
.table-wrap { overflow: auto; max-height: 320px; margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--text-2); }
td.num, th.num { text-align: left; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }

.hbar { display: grid; grid-template-columns: minmax(80px, 36%) 1fr auto; align-items: center; gap: 12px; padding: 5px 0; font-size: 13px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { display: block; height: 10px; }
.hbar-track i { display: block; height: 100%; background: var(--series-1); border-radius: 4px 0 0 4px; }  /* RTL: سرِ داده سمت چپ است */
.hbar b { font-weight: 650; min-width: 28px; text-align: left; font-variant-numeric: tabular-nums; }

/* ---------- پنل ادمین ---------- */
.user-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px; }
.user-row:last-child { margin-bottom: 0; }
.user-row.pending { border-color: color-mix(in srgb, var(--warn-solid) 55%, var(--border)); background: var(--warn-soft); }
.user-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-main .meta { flex: 1; min-width: 200px; color: var(--text-3); font-size: 12.5px; }
.user-controls { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.user-row.pending .user-controls { border-top-color: color-mix(in srgb, var(--warn-solid) 40%, transparent); }
.mini-field { display: flex; flex-direction: column; gap: 3px; }
.mini-field > span { font-size: 11.5px; color: var(--text-3); font-weight: 550; }
.mini-field input, .mini-field select { min-height: 32px; height: 32px; padding-block: 2px; font-size: 13px; width: 112px; }
.mini-field select { width: 128px; }

/* ---------- نوار ذخیره ---------- */
.savebar {
  position: fixed;
  z-index: 35;
  bottom: calc(var(--bottom-nav-h) + 20px);
  left: calc((100vw - var(--sidebar-w)) / 2);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 8px;
  padding-inline-start: 18px;
  background: var(--inverse-bg);
  color: var(--inverse-text);
  border-radius: 14px;
  box-shadow: var(--shadow-3);
  animation: savebar-in .22s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes savebar-in { from { opacity: 0; transform: translate(-50%, 16px); } }
.savebar-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn-solid); box-shadow: 0 0 0 4px rgba(217, 138, 0, .22); }
.savebar-text { font-size: 13.5px; font-weight: 550; margin-inline-end: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.savebar-ghost { background: transparent; border-color: transparent; color: var(--inverse-muted); }
.savebar-ghost:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.savebar.shake { animation: shake .4s; }
@keyframes shake {
  20% { transform: translateX(calc(-50% - 6px)); }
  40% { transform: translateX(calc(-50% + 6px)); }
  60% { transform: translateX(calc(-50% - 3px)); }
  80% { transform: translateX(calc(-50% + 3px)); }
}

/* ---------- شبیه‌ساز گفتگو ---------- */
.sheet {
  position: fixed;
  z-index: 60;
  inset-block: 0;
  left: 0;
  width: min(420px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  box-shadow: var(--shadow-3);
  transform: translateX(-104%);
  visibility: hidden;
  transition: transform .26s cubic-bezier(.3, .9, .3, 1), visibility 0s .26s;
}
.sheet.open { transform: none; visibility: visible; transition: transform .26s cubic-bezier(.3, .9, .3, 1); }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 14px 10px; border-bottom: 1px solid var(--border); }
.sheet-head strong { display: block; font-size: 14.5px; line-height: 1.4; }
.sheet-head small { display: block; color: var(--text-3); text-align: right; }
.sheet-note { display: flex; gap: 8px; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--text-3); font-size: 12px; line-height: 1.75; }
.sheet-note .icon { width: 14px; height: 14px; margin-top: 3px; }
.sheet-note b { color: var(--text-2); }
.sheet-note.warn { background: var(--warn-soft); color: var(--warn); font-weight: 550; }
.sheet-body { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.sheet-form { display: flex; gap: 8px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.sheet-form input { border-radius: 999px; padding-inline: 16px; }
.sheet-form .btn { border-radius: 50%; }

.msg { display: flex; flex-direction: column; gap: 4px; max-width: 88%; animation: msg-in .2s ease-out; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg.me { align-self: flex-start; align-items: flex-start; }
.msg.bot { align-self: flex-end; align-items: flex-end; }
.msg-bubble { padding: 9px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me .msg-bubble { background: var(--surface-2); border: 1px solid var(--border); border-start-start-radius: 5px; }
.msg.bot .msg-bubble { background: var(--accent-solid); color: #fff; border-end-end-radius: 5px; }
.msg.bot.err .msg-bubble { background: var(--danger-soft); color: var(--danger); }
.msg-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); }
.msg-note { font-size: 12px; color: var(--warn); background: var(--warn-soft); padding: 6px 10px; border-radius: 10px; line-height: 1.7; }
.suggests { margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; color: var(--text-3); font-size: 13px; padding: 20px 8px; }
.suggests > div { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.suggest { height: 34px; padding: 0 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border-strong); font-size: 13px; color: var(--text); }
.suggest:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- پنجره‌ی تأیید ---------- */
.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-3);
}
.dialog[open] { animation: dialog-in .18s cubic-bezier(.2, 1.1, .4, 1); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dialog::backdrop { background: var(--overlay); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog form { padding: 24px; }
.dialog-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; margin-bottom: 14px; background: var(--accent-soft); color: var(--accent-ink); }
.dialog-icon .icon { width: 22px; height: 22px; }
.dialog.danger .dialog-icon { background: var(--danger-soft); color: var(--danger); }
.dialog h2 { font-size: 17px; margin-bottom: 6px; }
.dialog p { color: var(--text-2); font-size: 13.5px; white-space: pre-line; }
.dialog .field { margin-top: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- اعلان ---------- */
.toasts {
  position: fixed;
  z-index: 80;
  bottom: calc(var(--bottom-nav-h) + 20px);
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 40px));
  pointer-events: none;
}
/* وقتی نوار ذخیره باز است، اعلان‌ها بالاتر می‌آیند تا روی دکمه‌هایش نیفتند */
body.has-savebar .toasts { bottom: calc(var(--bottom-nav-h) + 84px); }
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 14px;
  padding-inline-start: 14px;
  background: var(--inverse-bg);
  color: var(--inverse-text);
  border-radius: 13px;
  box-shadow: var(--shadow-3);
  font-size: 13.5px;
  line-height: 1.65;
  animation: toast-in .22s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s; }
.toast > .icon { color: var(--inverse-muted); }
.toast.ok > .icon { color: #5fe0a8; }
.toast.err > .icon { color: #ff9a90; }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-action { background: rgba(255, 255, 255, .14); border: none; color: #fff; height: 30px; padding: 0 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.toast-action:hover { background: rgba(255, 255, 255, .24); }
.toast-close { display: grid; place-items: center; width: 28px; height: 28px; background: none; border: none; border-radius: 8px; color: var(--inverse-muted); flex-shrink: 0; }
.toast-close:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.toast-close .icon { width: 14px; height: 14px; }

/* ---------- ناوبری پایین (موبایل) ---------- */
.bottom-nav { display: none; }
.scrim { display: none; }

/* ==========================================================================
   واکنش‌گرایی
   ========================================================================== */
@media (max-width: 1180px) {
  .section { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .section-info { position: static; }
  .section-info p { max-width: 640px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  :root { --bottom-nav-h: 62px; --topbar-h: 60px; }

  .sidebar {
    position: fixed;
    inset-block: 0;
    right: 0;
    width: min(300px, 86vw);
    transform: translateX(105%);
    visibility: hidden;
    box-shadow: var(--shadow-3);
    transition: transform .26s cubic-bezier(.3, .9, .3, 1), visibility 0s .26s;
  }
  body.drawer-open .sidebar { transform: none; visibility: visible; transition: transform .26s cubic-bezier(.3, .9, .3, 1); }
  .icon-btn.drawer-close { display: inline-grid; }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: var(--overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }
  body.drawer-open .scrim, body.sheet-open .scrim { opacity: 1; pointer-events: auto; }
  body.sheet-open .scrim { z-index: 55; }

  .icon-btn.menu-btn { display: inline-grid; margin-inline-start: -8px; }
  .topbar { padding: 8px 16px; gap: 8px; }
  .page-head p { display: none; }
  h1 { font-size: 17px; }
  #btn-tester .btn-label, #dry-badge span { display: none; }
  #btn-tester { width: 38px; padding: 0; }
  #dry-badge { width: 30px; padding: 0; justify-content: center; }
  #bot-status { padding: 0 9px; }
  #bot-status span { display: none; }
  .topbar-actions { gap: 6px; }

  main { padding: 16px 16px calc(var(--bottom-nav-h) + 96px); }
  .challenge { margin: 12px 16px 0; }
  .foreign-note { padding: 9px 16px; }
  .savebar { left: 50%; }

  .bottom-nav {
    position: fixed;
    z-index: 30;
    inset-inline: 0;
    bottom: 0;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 550;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav .icon { width: 21px; height: 21px; }
  .bottom-nav .active { color: var(--accent); }

  .welcome { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 22px; margin-top: 0; }
  .welcome-art { order: 2; }
  .hero { grid-template-columns: auto minmax(0, 1fr); padding: 18px; gap: 14px; }
  .hero-actions { grid-column: 1 / -1; flex-direction: row; }
  .hero-actions .btn { flex: 1; }
  .hero-title { font-size: 18px; }
  .hero-orb { width: 52px; height: 52px; align-self: start; }
  .orb { width: 44px; height: 44px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .day-label { top: var(--topbar-h); }
  .sheet { width: 100vw; border: none; }
}

@media (max-width: 620px) {
  body { font-size: 14px; }
  .fields.cols-2, .fields.cols-3, .choice-grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; }
  .card-foot { margin: 16px -16px -16px; padding: 12px 16px; }
  .kpis { gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi-value { font-size: 23px; }
  .kpi .spark { display: none; }
  .exchange, .lead { padding: 14px 16px; }
  .exchange > .avatar, .lead > .avatar { display: none; }
  .bubble { max-width: 94%; }
  .rule-body .row-2 { grid-template-columns: minmax(0, 1fr); }
  .rule-tools .icon-btn.sm { width: 34px; height: 34px; }
  .toolbar > .segmented { width: 100%; }
  .lead-user { flex: 1 1 auto; min-width: 0; }
  .lead-status { order: 1; margin-inline-start: auto; }
  .lead-del { order: 2; }
  .lead-src { order: 4; }
  .lead-meta { order: 5; flex: 1 1 0; }
  .log-toolbar .check-inline span { display: none; }
  .challenge-form { width: 100%; }
  .challenge-form input { flex: 1; width: auto; }
  .btn-go span, .btn-stop span { font-size: 13px; }
  #btn-start, #btn-stop { padding: 0 11px; }
  .toasts { left: 12px; width: calc(100vw - 24px); }
  .savebar kbd { display: none; }
  .savebar-text { margin-inline-end: 4px; }
  .log-src { display: none; }
  .inline-form .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   صفحه‌ی ورود
   ========================================================================== */
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }

.auth-side {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 44px 52px;
  color: #fff;
  background:
    radial-gradient(90% 70% at 0% 100%, rgba(42, 176, 190, .34), transparent 60%),
    radial-gradient(80% 60% at 100% 0%, rgba(120, 140, 255, .4), transparent 60%),
    linear-gradient(150deg, #2a45c8 0%, #172a86 70%, #101d63 100%);
  overflow: hidden;
}
.auth-side::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .13) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 75%);
  mask-image: linear-gradient(180deg, #000, transparent 75%);
  pointer-events: none;
}
.auth-side > * { position: relative; z-index: 1; }
.auth-side .brand { color: #fff; flex: none; }
.auth-side .brand-mark { background: rgba(255, 255, 255, .16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28); }
.auth-side .brand-text small { color: rgba(255, 255, 255, .72); }
.auth-pitch h2 { font-size: 30px; font-weight: 750; line-height: 1.55; letter-spacing: -.4px; margin-bottom: 12px; max-width: 460px; }
.auth-pitch > p { color: rgba(255, 255, 255, .8); font-size: 15px; max-width: 440px; }
.auth-points { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 12px; }
.auth-points li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: rgba(255, 255, 255, .92); }
.auth-points .icon { width: 30px; height: 30px; padding: 7px; border-radius: 9px; background: rgba(255, 255, 255, .14); }
.auth-mock { display: flex; flex-direction: column; gap: 10px; max-width: 400px; }
.auth-mock .mock-bubble { box-shadow: 0 6px 18px rgba(8, 14, 50, .28); }
.auth-mock .mock-bubble.in { background: rgba(255, 255, 255, .96); color: #1a1b1f; border: none; }
.auth-mock .mock-bubble.out { background: rgba(255, 255, 255, .17); border: 1px solid rgba(255, 255, 255, .26); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.auth-mock .mock-typing { background: rgba(255, 255, 255, .17); }
.auth-mock .mock-typing i { background: #fff; }

.auth-main { display: grid; place-items: center; padding: 32px 24px; position: relative; }
.auth-box { width: 100%; max-width: 384px; }
.auth-box > .brand { display: none; margin-bottom: 28px; }
.auth-box h1 { font-size: 24px; font-weight: 750; margin-bottom: 6px; }
.auth-lead { color: var(--text-3); margin-bottom: 22px; }
.auth-switch { display: flex; margin-bottom: 22px; }
.auth-switch .seg { flex: 1; justify-content: center; height: 36px; }
.auth-box form { display: grid; gap: 16px; }
.auth-box .btn-lg { width: 100%; margin-top: 4px; }
.auth-box .msg-line { min-height: 22px; font-size: 13px; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.auth-box .msg-line.err { color: var(--danger); }
.auth-box .msg-line.ok { color: var(--ok); }
.auth-box .notice { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; }
.auth-note { display: flex; gap: 8px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 12.5px; }
.auth-note .icon { width: 15px; height: 15px; margin-top: 3px; }
.auth-theme { position: absolute; top: 18px; left: 18px; }

@media (max-width: 900px) {
  .auth-page { grid-template-columns: minmax(0, 1fr); }
  .auth-side { display: none; }
  .auth-box > .brand { display: flex; }
  .auth-main { align-items: start; padding-top: 12vh; }
}
