/* =========================================================
   Bot Maker — design tokens
   Primary: AI purple · Accent: cyan · Glass for chrome only
   ========================================================= */
:root {
  --bg: #f6f4fd;
  --bg-mesh-1: rgba(124, 58, 237, .10);
  --bg-mesh-2: rgba(6, 182, 212, .09);
  --surface: #ffffff;
  --surface-2: #f8f7fc;
  --surface-3: #f1eff8;
  --glass: rgba(255, 255, 255, .72);
  --glass-line: rgba(124, 58, 237, .10);
  --ink: #1e1b4b;
  --ink-2: #3f3d63;
  --mute: #5d5b7c;
  --line: #e6e3f2;
  --line-2: #efedf7;
  --pri: #7c3aed;
  --pri-ink: #6d28d9;
  --pri-2: #a78bfa;
  --pri-soft: #f1eafe;
  --acc: #0891b2;
  --acc-soft: #e2f6fa;
  --ok: #059669;
  --ok-soft: #e3f7ef;
  --bad: #dc2626;
  --bad-soft: #fdeceb;
  --warn: #b45309;
  --warn-soft: #fef3dc;
  --c-msg: #7c3aed;
  --c-sub: #059669;
  --c-usr: #06b6d4;
  --ring: 0 0 0 3px rgba(124, 58, 237, .28);
  --sh-1: 0 1px 2px rgba(30, 27, 75, .05);
  --sh-2: 0 1px 2px rgba(30, 27, 75, .04), 0 12px 32px -16px rgba(30, 27, 75, .18);
  --sh-3: 0 30px 70px -24px rgba(30, 27, 75, .45);
  --grad: linear-gradient(135deg, #7c3aed 0%, #6d28d9 45%, #0891b2 100%);
  --r-sm: 10px; --r: 16px; --r-lg: 22px;
  --side-w: 268px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0b1a; --bg-mesh-1: rgba(124, 58, 237, .18); --bg-mesh-2: rgba(6, 182, 212, .10);
    --surface: #16132a; --surface-2: #1b1832; --surface-3: #221e3d;
    --glass: rgba(22, 19, 42, .72); --glass-line: rgba(167, 139, 250, .12);
    --ink: #eeecfb; --ink-2: #cfcbe8; --mute: #a19dc2; --line: #2b2748; --line-2: #231f3d;
    --pri: #a78bfa; --pri-ink: #c4b5fd; --pri-2: #c4b5fd; --pri-soft: #2a2150;
    --acc: #22d3ee; --acc-soft: #0f2f3a; --ok: #34d399; --ok-soft: #10302a; --bad: #f87171; --bad-soft: #3a1a22;
    --warn: #fbbf24; --warn-soft: #3a2c12; --c-msg: #a78bfa; --c-sub: #34d399; --c-usr: #22d3ee;
    --ring: 0 0 0 3px rgba(167, 139, 250, .35);
    --sh-1: 0 1px 2px rgba(0, 0, 0, .3); --sh-2: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -16px rgba(0, 0, 0, .7); --sh-3: 0 30px 70px -24px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0b1a; --bg-mesh-1: rgba(124, 58, 237, .18); --bg-mesh-2: rgba(6, 182, 212, .10);
  --surface: #16132a; --surface-2: #1b1832; --surface-3: #221e3d;
  --glass: rgba(22, 19, 42, .72); --glass-line: rgba(167, 139, 250, .12);
  --ink: #eeecfb; --ink-2: #cfcbe8; --mute: #a19dc2; --line: #2b2748; --line-2: #231f3d;
  --pri: #a78bfa; --pri-ink: #c4b5fd; --pri-2: #c4b5fd; --pri-soft: #2a2150;
  --acc: #22d3ee; --acc-soft: #0f2f3a; --ok: #34d399; --ok-soft: #10302a; --bad: #f87171; --bad-soft: #3a1a22;
  --warn: #fbbf24; --warn-soft: #3a2c12; --c-msg: #a78bfa; --c-sub: #34d399; --c-usr: #22d3ee;
  --ring: 0 0 0 3px rgba(167, 139, 250, .35);
  --sh-1: 0 1px 2px rgba(0, 0, 0, .3); --sh-2: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -16px rgba(0, 0, 0, .7); --sh-3: 0 30px 70px -24px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Vazirmatn, Tahoma, sans-serif; font-size: 14.5px; line-height: 1.7; color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(900px 500px at 100% -10%, var(--bg-mesh-1), transparent 60%),
                    radial-gradient(700px 500px at -10% 110%, var(--bg-mesh-2), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--pri); text-decoration: none; }
a:hover { color: var(--pri-ink); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
b { font-weight: 600; }
small, .mute { color: var(--mute); font-size: 12.5px; }
h2, h3 { margin: 0; line-height: 1.4; }
code, .ltr { font-family: 'Fira Code', Consolas, monospace; }
.ltr { direction: ltr; text-align: left; font-size: 12.5px; }
:focus-visible { outline: none; box-shadow: var(--ring); }
::selection { background: var(--pri-soft); color: var(--ink); }
.i { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.i.sm { width: 15px; height: 15px; }
.i.lg { width: 22px; height: 22px; }
.i.xl { width: 30px; height: 30px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: var(--side-w); flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px; padding: 18px 14px 14px;
  background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-left: 1px solid var(--glass-line);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.logo { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: #fff; background: var(--grad); box-shadow: 0 10px 22px -10px rgba(124, 58, 237, .8); flex: none; }
.brand b { display: block; font-size: 16.5px; line-height: 1.3; font-weight: 700; }
.brand small { display: block; line-height: 1.4; }
.side-close { display: none !important; margin-right: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .side-bots a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 11px; color: var(--ink-2); font-weight: 500;
  transition: background .18s var(--ease), color .18s var(--ease); position: relative; min-height: 42px;
}
.nav a .i { color: var(--mute); transition: color .18s; }
.nav a:hover, .side-bots a:hover { background: var(--surface-3); color: var(--ink); }
.nav a.on, .side-bots a.on { background: var(--pri-soft); color: var(--pri-ink); }
.nav a.on .i { color: var(--pri); }
.nav a.on::before { content: ''; position: absolute; right: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px 0 0 3px; background: var(--pri); }
.side-title { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; font-weight: 600; color: var(--mute); padding: 18px 12px 6px; }
.side-bots { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-bots a { font-weight: 400; font-size: 13.5px; min-height: 40px; }
.side-bots a .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-av { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; flex: none; position: relative; }
.mini-av .dot { position: absolute; bottom: -2px; left: -2px; border: 2px solid var(--surface); width: 10px; height: 10px; box-shadow: none !important; }
.side-foot { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.theme-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-3); }
.theme-seg button { border: 0; background: transparent; color: var(--mute); border-radius: 9px; padding: 6px; cursor: pointer; display: grid; place-items: center; min-height: 32px; transition: background .18s, color .18s; }
.theme-seg button:hover { color: var(--ink); }
.theme-seg button.on { background: var(--surface); color: var(--pri); box-shadow: var(--sh-1); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 28px;
  background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--glass-line);
}
.crumb { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.crumb > * { flex: none; }
.crumb .t { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb a { color: var(--mute); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.crumb a:hover { color: var(--pri); }
.crumb .sep { color: var(--line); }
.crumb .page-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--pri-soft); color: var(--pri); }
.top-actions { display: flex; gap: 8px; align-items: center; }
main#app { width: 100%; max-width: 1280px; margin: 0 auto; padding: 26px 28px 70px; }
.burger { display: none !important; }
.backdrop { position: fixed; inset: 0; z-index: 29; background: rgba(13, 11, 26, .45); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; }

@media (max-width: 960px) {
  .side { position: fixed; right: 0; top: 0; z-index: 30; transform: translateX(105%); transition: transform .25s var(--ease); box-shadow: var(--sh-3); background: var(--surface); }
  .side.open { transform: none; }
  body.side-open .backdrop { opacity: 1; pointer-events: auto; }
  .side-close, .burger { display: inline-grid !important; }
  .topbar { padding: 10px 14px; }
  main#app { padding: 18px 14px 70px; }
  .top-actions .btn .lbl { display: none; }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 7px 15px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; line-height: 1.4; box-shadow: var(--sh-1);
  transition: background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease), filter .18s;
}
.btn:hover { border-color: var(--pri-2); color: var(--pri-ink); }
.btn.primary { background: var(--grad); background-size: 140% 140%; color: #fff; border-color: transparent; box-shadow: 0 8px 20px -10px rgba(124, 58, 237, .9); }
.btn.primary:hover { color: #fff; filter: brightness(1.08) saturate(1.1); }
.btn.ok { background: var(--ok); color: #fff; border-color: transparent; }
.btn.ok:hover { color: #fff; filter: brightness(1.08); }
.btn.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; box-shadow: none; }
.btn.bad:hover { background: var(--bad); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.soft { background: var(--pri-soft); color: var(--pri-ink); border-color: transparent; box-shadow: none; }
.btn.soft:hover { background: var(--pri); color: #fff; }
.btn.sm { min-height: 32px; padding: 4px 11px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled, .icon-btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  cursor: pointer; display: inline-grid; place-items: center; font: inherit; flex: none; padding: 0;
  transition: background .18s, color .18s, border-color .18s;
}
.icon-btn:hover:not(:disabled) { border-color: var(--pri-2); color: var(--pri); background: var(--pri-soft); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn.danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
label { display: block; font-size: 12.5px; color: var(--mute); margin: 12px 0 5px; font-weight: 500; }
label.inline { display: inline-flex; align-items: center; gap: 7px; margin: 0; color: var(--ink-2); font-weight: 400; cursor: pointer; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); color: var(--ink);
  font: inherit; transition: border-color .18s, box-shadow .18s, background .18s;
}
input::placeholder, textarea::placeholder { color: var(--mute); opacity: .75; }
input:hover, select:hover, textarea:hover { border-color: var(--pri-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pri); box-shadow: var(--ring); background: var(--surface); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--pri); cursor: pointer; }
textarea { min-height: 96px; resize: vertical; }
select {
  appearance: none; cursor: pointer; padding-left: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237c7a9c' stroke-width='2.4' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: left 11px center;
}
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; margin: 0; color: var(--ink); font-weight: 500; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .tr { width: 42px; height: 24px; border-radius: 20px; background: var(--line); position: relative; transition: background .2s var(--ease); flex: none; }
.switch .tr::after { content: ''; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .22s var(--ease); box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.switch input:checked + .tr { background: var(--pri); }
.switch input:checked + .tr::after { transform: translateX(-18px); }
.switch input:focus-visible + .tr { box-shadow: var(--ring); }
.switch .i { color: var(--pri); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { min-width: 0; }
.row.center { align-items: center; }
.grow { flex: 1; min-width: 150px; }
.search { position: relative; }
.search .i { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--mute); pointer-events: none; }
.search input { padding-right: 36px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 10px; border-radius: 30px; background: var(--surface-3); color: var(--mute); font-weight: 500; white-space: nowrap; line-height: 1.5; }
.badge.run { background: var(--ok-soft); color: var(--ok); }
.badge.err { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.pri { background: var(--pri-soft); color: var(--pri-ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mute); flex: none; display: inline-block; }
.dot.run { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: pulse 2.2s infinite; }
.dot.err { background: var(--bad); }
.dot.warn { background: var(--warn); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--ok-soft); } 50% { box-shadow: 0 0 0 5px var(--ok-soft); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { padding: 2px 10px; border: 1px dashed var(--line); border-radius: 30px; font: inherit; font-size: 12px; cursor: pointer; background: transparent; color: var(--ink-2); direction: ltr; font-family: 'Fira Code', Consolas, monospace; transition: all .15s; }
.chips button:hover { border-style: solid; border-color: var(--pri); color: var(--pri); background: var(--pri-soft); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--sh-2); margin-bottom: 18px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h3 { font-size: 15.5px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.card-h h3 .i { color: var(--pri); }
.sec-title { display: flex; align-items: center; justify-content: space-between; margin: 8px 2px 14px; }
.sec-title h3 { font-size: 16px; font-weight: 700; }
.sec-title a { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; font-size: 13.5px; }

/* ---------- empty / skeleton ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--mute); }
.empty .em-ic { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 22px; display: grid; place-items: center; background: var(--pri-soft); color: var(--pri); }
.empty b { color: var(--ink); font-size: 16.5px; display: block; margin-bottom: 4px; }
.empty p { margin: 0 auto 16px; max-width: 420px; }
.skel { border-radius: var(--r); background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- dashboard ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: var(--r-lg); padding: 26px 28px; margin-bottom: 20px; color: #fff;
  background: var(--grad); box-shadow: 0 24px 50px -28px rgba(124, 58, 237, .9);
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.hero::before, .hero::after { content: ''; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .10); pointer-events: none; }
.hero::before { width: 260px; height: 260px; left: -60px; top: -120px; }
.hero::after { width: 180px; height: 180px; left: 160px; bottom: -110px; background: rgba(255, 255, 255, .07); }
.hero h2 { font-size: 22px; font-weight: 700; }
.hero p { margin: 4px 0 0; color: rgba(255, 255, 255, .86); font-size: 13.5px; }
.hero .stat-pills { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.hero .pill { display: inline-flex; align-items: center; gap: 7px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22); padding: 4px 12px; border-radius: 30px; font-size: 12.5px; backdrop-filter: blur(6px); }
.hero .btn { background: #fff; color: var(--pri-ink); border-color: transparent; position: relative; z-index: 1; }
.hero .btn:hover { background: rgba(255, 255, 255, .9); color: #6d28d9; }
.hero > * { position: relative; z-index: 1; }
:root[data-theme="dark"] .hero .btn { color: #6d28d9; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
@media (max-width: 1240px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .tiles { grid-template-columns: 1fr; } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--sh-2); display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; transition: border-color .2s; }
.tile:hover { border-color: color-mix(in srgb, var(--tc) 40%, var(--line)); }
.tile-top { display: flex; align-items: center; gap: 10px; color: var(--mute); font-size: 13px; font-weight: 500; }
.tile-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: var(--tc); background: color-mix(in srgb, var(--tc) 13%, transparent); }
.tile .v { font-size: 28px; font-weight: 700; line-height: 1.25; letter-spacing: -.3px; margin-top: 4px; }
.tile .v small { font-size: 13px; font-weight: 500; margin-right: 4px; }
.tile-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.tile .sub { font-size: 12px; color: var(--mute); }
.tile .sub.up { color: var(--ok); }
.tile .sub.down { color: var(--bad); }
.spark { width: 92px; height: 32px; direction: ltr; flex: none; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 18px; }
.grid-2.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 1060px) { .grid-2, .grid-2.even { grid-template-columns: 1fr; } }
.chart { width: 100%; height: auto; direction: ltr; display: block; overflow: visible; }
.chart text { font-family: Vazirmatn, sans-serif; font-size: 11px; fill: var(--mute); }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 5; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover { fill: var(--pri-soft); opacity: .6; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--mute); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.recent { display: flex; flex-direction: column; }
.recent .r { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.recent .r:last-child { border: 0; padding-bottom: 0; }
.recent .r .ric { width: 36px; height: 36px; border-radius: 11px; background: var(--acc-soft); color: var(--acc); display: grid; place-items: center; flex: none; }
.recent .r .t { flex: 1; min-width: 0; }
.recent .r .t > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .r time { font-size: 11.5px; color: var(--mute); white-space: nowrap; }

/* ---------- bot cards ---------- */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.bot-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--sh-2); display: flex; flex-direction: column; gap: 14px; transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
.bot-card:hover { border-color: var(--pri-2); box-shadow: var(--sh-2), 0 0 0 4px var(--pri-soft); }
.bot-card .h { display: flex; align-items: center; gap: 12px; }
.avatar { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; background: var(--grad); flex: none; }
.bale { background: linear-gradient(135deg, #10b981, #0d9488); }
.telegram { background: linear-gradient(135deg, #38bdf8, #2563eb); }
.bot-card .h .t { flex: 1; min-width: 0; }
.bot-card .h b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-card .h small { display: inline-flex; align-items: center; gap: 5px; }
.bot-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bot-stats div { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 6px; text-align: center; }
.bot-stats b { display: block; font-size: 18px; line-height: 1.3; }
.bot-stats span { font-size: 11.5px; color: var(--mute); }
.bot-card .acts { display: flex; gap: 8px; }
.bot-card .acts .btn { flex: 1; }
.err-box { display: flex; gap: 8px; align-items: flex-start; background: var(--bad-soft); color: var(--bad); border-radius: 12px; padding: 10px 12px; font-size: 12.5px; }
.err-box .i { margin-top: 2px; }

/* ---------- editor tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 20px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-1); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px; color: var(--mute); font-weight: 500; white-space: nowrap; transition: background .18s, color .18s; min-height: 38px; }
.tabs a:hover { color: var(--ink); background: var(--surface-3); }
.tabs a.on { color: #fff; background: var(--grad); box-shadow: 0 6px 16px -8px rgba(124, 58, 237, .9); }

/* ---------- builder ---------- */
.builder { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1180px) { .builder { grid-template-columns: 1fr; } .tree { position: static !important; max-height: none !important; } }
.tree { position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow-y: auto; padding: 16px; }
.tree-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: right; padding: 8px 10px; margin-bottom: 2px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--ink-2); font: inherit; cursor: pointer; position: relative; min-height: 40px; transition: background .15s, color .15s; }
.tree-item:hover { background: var(--surface-3); color: var(--ink); }
.tree-item .nic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--mute); flex: none; }
.tree-item.on { background: var(--pri-soft); color: var(--pri-ink); font-weight: 600; }
.tree-item.on .nic { background: var(--pri); color: #fff; }
.tree-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item .tags { display: flex; gap: 3px; }
.tree-item .tag { font-size: 10.5px; padding: 0 6px; border-radius: 6px; background: var(--surface-3); color: var(--mute); font-weight: 500; }
.tree-item.on .tag { background: var(--surface); }
.tree-item .lvl { position: absolute; top: 4px; bottom: 4px; border-right: 1.5px solid var(--line); }
.tree .orph { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--warn); margin: 14px 6px 6px; font-weight: 500; }
.tip { display: flex; gap: 8px; font-size: 12.5px; color: var(--mute); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.tip .i { color: var(--warn); margin-top: 3px; }
.node-ed .title-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.node-ed .title-row .nic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--grad); color: #fff; flex: none; }
.node-ed .title-row input { font-size: 18px; font-weight: 700; background: transparent; border-color: transparent; padding-right: 4px; }
.node-ed .title-row input:hover { border-color: var(--line); }
.node-ed .title-row input:focus { padding-right: 12px; }
.section { border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 14px; background: var(--surface); transition: border-color .2s, background .2s; }
.section.off { background: var(--surface-2); border-style: dashed; }
.section.on-accent { border-color: color-mix(in srgb, var(--pri) 35%, var(--line)); }
.sec-h { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.sec-h h4 { margin: 0; font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.sec-h h4 .i { color: var(--pri); }
.sec-h + * { margin-top: 12px; }
.hint { font-size: 12.5px; color: var(--mute); margin-top: 8px; }
.item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 8px; background: var(--surface-2); transition: border-color .15s; }
.item:hover, .item:focus-within { border-color: var(--pri-2); }
.item .row.sub { margin-top: 8px; }
.num { width: 28px; height: 28px; border-radius: 9px; background: var(--pri-soft); color: var(--pri-ink); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex: none; }
.btn-group { display: inline-flex; gap: 4px; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); background: color-mix(in srgb, var(--bad-soft) 40%, var(--surface)); }
.danger-zone h4, .danger-zone h3 { color: var(--bad) !important; }
.danger-zone h4 .i, .danger-zone h3 .i { color: var(--bad) !important; }
.preview-kb { display: flex; flex-direction: column; gap: 4px; padding: 8px; border-radius: 12px; background: var(--surface-3); }
.preview-kb div { display: flex; gap: 4px; }
.preview-kb span { flex: 1; text-align: center; background: var(--surface); border-radius: 8px; padding: 5px 6px; font-size: 12px; box-shadow: var(--sh-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mute); margin: 12px 0 6px; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { position: sticky; top: 0; font-size: 12px; color: var(--mute); font-weight: 600; text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; max-width: 320px; overflow-wrap: anywhere; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--surface-2); }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell .mini-av { width: 32px; height: 32px; border-radius: 10px; background: var(--grad); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select { width: auto; min-width: 200px; }
.toolbar .search { min-width: 220px; }
.count { color: var(--mute); font-size: 12.5px; }

/* ---------- simulator ---------- */
.sim-wrap { display: grid; grid-template-columns: minmax(0, 470px) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .sim-wrap { grid-template-columns: 1fr; } }
.sim { padding: 0; overflow: hidden; display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 540px; border-radius: var(--r-lg); }
.sim-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.sim-head .t { flex: 1; min-width: 0; line-height: 1.5; }
.sim-head .t small { display: flex; align-items: center; gap: 6px; }
.sim-chat {
  flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 8px;
  background-color: var(--surface-2);
  background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 18px 18px;
}
.bubble { unicode-bidi: plaintext; max-width: 84%; padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.75; animation: pop .18s var(--ease); box-shadow: var(--sh-1); }
.bubble.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-top-right-radius: 5px; }
.bubble.user { align-self: flex-end; background: var(--grad); color: #fff; border-top-left-radius: 5px; }
.bubble.admin { align-self: center; background: var(--warn-soft); color: var(--ink); font-size: 12.5px; border: 1px dashed var(--warn); max-width: 94%; }
.bubble.admin .tag { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--warn); margin-bottom: 4px; font-weight: 600; }
.typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; border-top-right-radius: 5px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--mute); animation: blink 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
.sim-kb { padding: 8px 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; background: var(--surface-3); }
.sim-kb div { display: flex; gap: 6px; }
.sim-kb button { flex: 1; min-height: 38px; padding: 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; box-shadow: var(--sh-1); transition: border-color .15s, color .15s; }
.sim-kb button:hover { border-color: var(--pri); color: var(--pri-ink); }
.sim-in { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.sim-in input { flex: 1; border-radius: 30px; padding-right: 16px; }
.sim-in .icon-btn { border-radius: 50%; width: 40px; height: 40px; }
.sim-in .send { background: var(--grad); color: #fff; border-color: transparent; }
.sim-in .send:hover { color: #fff; filter: brightness(1.08); background: var(--grad); }
.guide { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.guide li { display: flex; gap: 11px; align-items: flex-start; color: var(--ink-2); font-size: 13.5px; }
.guide li .gi { width: 30px; height: 30px; border-radius: 9px; background: var(--pri-soft); color: var(--pri); display: grid; place-items: center; flex: none; }
.kbd { font-family: 'Fira Code', monospace; font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; color: var(--ink-2); background: var(--surface-2); }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(13, 11, 26, .5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .18s; }
.modal[hidden] { display: none; }
.modal .box { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; padding: 24px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-3); animation: rise .22s var(--ease); }
.modal .box .mh { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.modal .box .mh .mic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--pri-soft); color: var(--pri); flex: none; }
.modal .box .mh .mic.bad { background: var(--bad-soft); color: var(--bad); }
.modal .box h3 { font-size: 17px; font-weight: 700; }
.modal .box p { margin: 6px 0 0; }
.modal .acts { display: flex; gap: 8px; justify-content: flex-start; margin-top: 22px; }
.tpl-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tpl-pick label { margin: 0; display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--ink); transition: border-color .15s, background .15s; }
.tpl-pick label:has(input:checked) { border-color: var(--pri); background: var(--pri-soft); }
.tpl-pick input { margin-top: 4px; }
.tpl-pick small { display: block; line-height: 1.5; }
.plat-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plat-pick label { margin: 0; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--ink); font-weight: 500; transition: border-color .15s, background .15s; }
.plat-pick label:has(input:checked) { border-color: var(--pri); background: var(--pri-soft); }
.plat-pick input { position: absolute; opacity: 0; }
.plat-pick .mini-av { width: 30px; height: 30px; border-radius: 9px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(14px) scale(.98); opacity: 0; } }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60; display: none; align-items: center; gap: 9px; max-width: 92vw; padding: 11px 18px; border-radius: 14px; background: #1e1b4b; color: #fff; font-size: 13.5px; box-shadow: var(--sh-3); animation: rise .2s var(--ease); }
#toast.show { display: flex; }
#toast.err { background: #b91c1c; }
#toast.ok { background: #047857; }
.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  body { font-size: 15px; }
  input, select, textarea { font-size: 16px; }
  .btn { min-height: 42px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn.sm { width: 36px; height: 36px; }
  .hero { padding: 22px 20px; }
  .hero h2 { font-size: 19px; }
  .tile .v { font-size: 24px; }
  .card { padding: 16px; }
  .tpl-pick { grid-template-columns: 1fr; }
  .toolbar select, .toolbar .search { min-width: 0; flex: 1 1 100%; }
  .sim { height: calc(100vh - 170px); }
  .hide-sm { display: none !important; }
}

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- data dashboard ---------- */
.col-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.col-tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; min-height: 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink-2); font: inherit; font-weight: 500; cursor: pointer; box-shadow: var(--sh-1); transition: all .18s var(--ease); }
.col-tab .i { color: var(--mute); }
.col-tab b { font-size: 12px; padding: 1px 8px; border-radius: 20px; background: var(--surface-3); color: var(--mute); }
.col-tab:hover { border-color: var(--pri-2); color: var(--ink); }
.col-tab.on { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 18px -10px rgba(124, 58, 237, .9); }
.col-tab.on .i { color: #fff; } .col-tab.on b { background: rgba(255, 255, 255, .22); color: #fff; }
.dstats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.dstat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--sh-1); text-align: right; font: inherit; color: var(--ink); position: relative; min-height: 76px; }
.dstat .l { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mute); }
.dstat .l .i { color: var(--pri); }
.dstat b { font-size: 22px; line-height: 1.3; }
.dstat small { font-size: 11px; }
.dstat .spark { position: absolute; left: 12px; bottom: 10px; width: 70px; height: 26px; }
.st-stat { cursor: pointer; transition: border-color .15s, background .15s; }
.st-stat .l i { width: 9px; height: 9px; border-radius: 50%; background: var(--sc); display: inline-block; }
.st-stat:hover { border-color: var(--sc); }
.st-stat.on { border-color: var(--sc); background: color-mix(in srgb, var(--sc) 9%, var(--surface)); box-shadow: inset 0 0 0 1px var(--sc); }
.st { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--sc); background: color-mix(in srgb, var(--sc) 12%, transparent); }
.st i { width: 7px; height: 7px; border-radius: 50%; background: var(--sc); }
table.data th { padding: 6px 8px; }
.th-btn { display: inline-flex; align-items: center; gap: 4px; background: transparent; border: 0; padding: 4px 4px; border-radius: 6px; color: var(--mute); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.th-btn:hover { color: var(--ink); background: var(--surface-3); }
.th-btn.on { color: var(--pri); }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--pri); }
.nowrap { white-space: nowrap; }
.thumb { display: inline-block; width: 44px; height: 44px; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-3); vertical-align: middle; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.loc { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.pager { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pager select { width: auto; }
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 25; min-width: 200px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--sh-3); display: flex; flex-direction: column; gap: 6px; }
.menu[hidden] { display: none; }
.modal .box.wide { max-width: 980px; padding: 20px 22px; }
.rec .mh { margin-bottom: 14px; }
.rec .mh h3 { font-size: 16px; }
.rec-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 760px) { .rec-grid { grid-template-columns: 1fr; } }
.rec .section { margin-bottom: 12px; padding: 14px 16px; }
.rec label { margin-top: 8px; }
.st-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.st-opt { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border: 1.5px solid var(--line); border-radius: 20px; cursor: pointer; margin: 0; color: var(--ink-2); font-weight: 500; font-size: 13px; transition: all .15s; min-height: 36px; }
.st-opt i { width: 9px; height: 9px; border-radius: 50%; background: var(--sc); }
.st-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.st-opt:hover { border-color: var(--sc); }
.st-opt:has(input:checked) { border-color: var(--sc); background: color-mix(in srgb, var(--sc) 12%, transparent); color: var(--ink); }
.st-opt:has(input:focus-visible) { box-shadow: var(--ring); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }
.timeline li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.timeline .tl-ic { width: 28px; height: 28px; border-radius: 9px; background: var(--pri-soft); color: var(--pri); display: grid; place-items: center; flex: none; }
.timeline .tl-ic.bad { background: var(--bad-soft); color: var(--bad); }
.timeline small { display: block; }

/* ---------- جریان کاری ---------- */
.step-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.step-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; margin-top: 4px; font-size: 12.5px; font-weight: 700; color: #fff; background: var(--sc, var(--pri)); }
.step-acts { display: flex; flex-direction: column; gap: 2px; flex: none; }

/* ---------- کاربر پنل و صفحه‌ی ورود ---------- */
.user-box { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; background: var(--surface-3); }
.user-box .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; direction: ltr; text-align: right; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; padding: 28px 26px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-2); }
.login-card .logo { margin: 0 auto 14px; }
.login-card h1 { margin: 0; text-align: center; font-size: 20px; }
.login-card .sub { text-align: center; margin: 4px 0 18px; }
.login-card .err-box { margin-top: 12px; padding: 9px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: 13px; }
