@font-face { font-family: Vazirmatn; src: url(fonts/Vazirmatn-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(fonts/Vazirmatn-Medium.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(fonts/Vazirmatn-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #f4f2ee; --panel: #ffffff; --ink: #1d2321; --muted: #6b726f; --line: #e3e0d9;
  --accent: #0f6b5c; --accent-ink: #ffffff; --accent-soft: #e2f0ec;
  --tg: #2a8bc9; --wa: #1f9d55; --bale: #0f9e8a; --rb: #8a3fd1; --eitaa: #e8792b; --ig: #d62976; --warn: #b7791f; --warn-soft: #fbf1df; --bad: #b42318; --bad-soft: #fbe9e7;
  --ok-soft: #e3f4ea; --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131615; --panel: #1b1f1e; --ink: #e8ebe9; --muted: #98a19d; --line: #2c3230;
    --accent: #3fb59d; --accent-ink: #0d1110; --accent-soft: #1d322d;
    --warn-soft: #3a2e17; --bad-soft: #3d1f1c; --ok-soft: #1b3326; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Vazirmatn, Tahoma, sans-serif, "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji"; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.7; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, Consolas, monospace; direction: ltr; unicode-bidi: embed; font-size: 12.5px; }
.ltr { direction: ltr; text-align: left; }
.hidden { display: none !important; }

/* ---------- ورود ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 13px; }

/* ---------- چیدمان ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-left: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 15px; padding: 0 10px 18px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
.nav-btn { text-align: right; background: none; border: 0; padding: 9px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.nav-btn:hover { background: var(--bg); color: var(--ink); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); }
.side .spacer { flex: 1; }
.main { padding: 28px 32px; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- اجزا ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.btn { background: var(--panel); border: 1px solid var(--line); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.text { max-width: 380px; white-space: pre-wrap; word-break: break-word; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--wa); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.chan { font-size: 12px; font-weight: 700; }
.chan.telegram { color: var(--tg); }
.chan.whatsapp { color: var(--wa); }
.chan.bale { color: var(--bale); }
.chan.rubika { color: var(--rb); }
.chan.eitaa { color: var(--eitaa); }
.chan.instagram { color: var(--ig); }
.chan.messenger { color: #0084ff; }
.chan.x { color: inherit; font-weight: 700; }
.dir-in { color: var(--tg); font-weight: 500; }
.dir-out { color: var(--accent); font-weight: 500; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.acc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.acc .top { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.acc .name { font-weight: 700; font-size: 15px; }
.acc .meta { font-size: 12.5px; color: var(--muted); }
.acc .detail { font-size: 12.5px; color: var(--warn); }
.acc .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }

.secret { display: flex; gap: 6px; }
.secret input { font-family: ui-monospace, Consolas, monospace; direction: ltr; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; direction: ltr; text-align: left; font-size: 12.5px; line-height: 1.6; margin: 8px 0 14px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 12px; }

/* ---------- مودال ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border-radius: 14px; padding: 22px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-start; margin-top: 16px; }
.qr-box { display: grid; place-items: center; min-height: 300px; background: #fff; border-radius: 10px; margin: 8px 0; }
.qr-box img { width: 280px; height: 280px; }

.toast { position: fixed; bottom: 20px; left: 20px; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 100; max-width: 420px; font-size: 13px; }
.toast.err { background: var(--bad); color: #fff; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px; border-left: 0; border-bottom: 1px solid var(--line); }
  .brand { display: none; }
  .side .spacer { display: none; }
  .main { padding: 18px 16px; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- نسخه ۲: فروشنده با چند کانال ---------- */
.notice { border-color: var(--warn); background: var(--warn-soft); }
.acc.off { opacity: .65; }
.chan-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; background: var(--bg); }
.chan-row .actions { padding-top: 4px; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; margin-bottom: 14px; }
.tab { flex: 1; border: 0; background: none; padding: 7px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tab.active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.err-text { color: var(--bad); font-size: 13px; margin-top: 6px; }
.ok-big { color: var(--wa); font-size: 18px; }
label.check { display: flex; align-items: center; gap: 8px; margin: 4px 0; cursor: pointer; }
.lbl { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
div.f { margin-bottom: 12px; }
.sub-box { border: 1px dashed var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.modal.wide { max-width: 760px; }
.web-screen { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; min-height: 200px; display: grid; place-items: center; overflow: hidden; }
.web-screen img { width: 100%; height: auto; display: block; cursor: crosshair; }
.atts { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.att { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--panel); max-width: 320px; }
.att.bad { border-color: var(--bad); }
.att img { display: block; max-width: 100%; max-height: 220px; border-radius: 6px; margin-bottom: 4px; }
.att-row { font-size: 12.5px; word-break: break-all; }
.att-err { color: var(--bad); font-size: 12px; }
.web-screen { position: relative; }
.click-dot { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: rgba(15,107,92,.45); border: 2px solid var(--accent); pointer-events: none; animation: dotfade .6s ease-out forwards; }
@keyframes dotfade { to { transform: scale(2); opacity: 0; } }
.web-debug { margin-top: 10px; font-size: 13px; }
.web-debug summary { cursor: pointer; color: var(--muted); }
.cchips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cchip { font-size: 12px; padding: 2px 10px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.cchip.yes { background: var(--ok-soft); color: var(--wa); border-color: transparent; }
.cchip.no { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.cchip.unk { color: var(--muted); }
.cres { font-size: 13px; margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.tls-status { margin-top: 4px; font-size: 13px; }
.pair-box { display: grid; place-items: center; min-height: 160px; gap: 8px; margin: 10px 0; background: var(--bg); border-radius: 10px; padding: 16px; }
.pair-code { font-size: 34px; font-weight: 700; letter-spacing: 6px; font-family: ui-monospace, Consolas, monospace; color: var(--accent); }

/* ساعت پنل */
.panel-clock { display: block; font-size: 12px; color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 8px; direction: rtl; }
.panel-clock:hover { background: var(--bg); color: var(--ink, inherit); }
.att video { display: block; max-width: 100%; max-height: 260px; border-radius: 6px; margin-bottom: 4px; background: #000; }
.att audio { display: block; width: 260px; max-width: 100%; margin-bottom: 4px; }
.prof { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; font-size: 13px; line-height: 1.7; }
.pr-row { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.pr-l { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.pr-l::after { content: ':'; }
.pr-row.err-text { margin-top: 0; }

/* انتخاب ایموجی */
.emoji-pop { position: fixed; z-index: 200; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); overflow: hidden; }
.ep-tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--bg); }
.ep-tab { border: 0; background: none; font-size: 18px; padding: 4px 8px; border-radius: 8px; cursor: pointer; }
.ep-tab.on { background: var(--accent-soft); }
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); max-height: 220px; overflow-y: auto; padding: 6px; }
.ep-e { border: 0; background: none; font-size: 22px; line-height: 1; padding: 6px 0; border-radius: 8px; cursor: pointer; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
.ep-e:hover { background: var(--bg); }
.bub .tx.big-emoji { font-size: 34px; line-height: 1.3; }
.fmt-tools { display: inline-flex; gap: 3px; vertical-align: middle; }
.fmt-b { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 6px; min-width: 28px; height: 26px; font-size: 13px; cursor: pointer; font-family: inherit; }
.fmt-b:hover { background: var(--accent-soft); }
.fmt-row { display: flex; align-items: center; gap: 10px; padding: 6px 14px 0; background: var(--panel); border-top: 1px solid var(--line); }
.fmt-row + .composer { border-top: 0; }
.fmt-hint { font-size: 11.5px; direction: rtl; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) { .fmt-hint { display: none; } }
/* گزارش ترافیک */
.rep-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.rep-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.rep-form input, .rep-form select { min-width: 130px; }
.rep-totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
.rep-totals .stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.rep-totals .n { font-size: 20px; font-weight: 700; }
.rep-totals .l { font-size: 12px; color: var(--muted); }
table.rep td.num { text-align: center; font-variant-numeric: tabular-nums; }
table.rep th { white-space: nowrap; }
.rep-bar { display: flex; flex-direction: column; gap: 2px; }
.rep-bar i { display: block; height: 5px; border-radius: 3px; min-width: 1px; }
.rep-bar .s, .rep-key.s { background: var(--accent, #2f6fed); }
.rep-bar .r, .rep-key.r { background: var(--tg); }
.rep-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin-inline: 6px 2px; }
.share-req { border-inline-start: 4px solid var(--warn, #e6a100); }
.crm-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.crm-row:first-of-type { border-top: 0; }
.crm-row .nm { font-weight: 600; flex: 1; min-width: 140px; }
/* مسیرهای خودکار */
.flow-steps { margin: 10px 0; padding-inline-start: 22px; line-height: 2; font-size: 13.5px; }
.flow-modal { width: min(1100px, 92vw); }
.modal:has(.flow-modal) { max-width: none; width: auto; }
.ft-form { max-width: 520px; }
.ft-run { display: grid; grid-template-columns: 1fr 340px; gap: 14px; align-items: start; }
.ft-shot { position: relative; }
.ft-shot img { width: 100%; border: 1px solid var(--line); border-radius: 8px; display: block; min-height: 200px; background: var(--bg); }
.ft-shot img.pickable { cursor: crosshair; outline: 3px dashed var(--warn); outline-offset: 2px; }
.ft-banner { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.ft-side { display: flex; flex-direction: column; gap: 10px; max-height: 76vh; overflow: auto; }
.ft-status { background: var(--bg); border-radius: 8px; padding: 10px; font-size: 13.5px; }
.ft-outcome { margin-top: 8px; padding: 8px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); }
.ft-outcome.exists { border-color: var(--wa); } .ft-outcome.not_found { border-color: var(--bad); }
.ft-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ft-steps li { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; background: var(--panel); }
.ft-steps li.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ft-ctrl { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 800px) { .ft-run { grid-template-columns: 1fr; } }

/* سلامت سرور */
.hgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; font-size: 13.5px; }
.hgrid b { font-size: 18px; }
.hbar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.hbar i { display: block; height: 100%; border-radius: 3px; }

/* ویرایشگر قدم‌های مسیر */
.fe-row { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; background: var(--panel); }
.fe-num { width: 22px; font-weight: 700; color: var(--muted); padding-top: 6px; }
.fe-body { flex: 1; min-width: 0; }
.fe-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fe-line input, .fe-line select { min-width: 0; }
.fe-ms { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.fe-ms input { width: 80px; }
.fe-target { font-size: 12px; margin-top: 4px; word-break: break-all; }
.fe-adv { margin-top: 6px; font-size: 13px; }
.fe-ctl { display: flex; gap: 4px; }
.fe-line > input, .fe-line > select { width: auto; margin: 0; }
.fe-line > input[data-k="title"] { flex: 2 1 220px; }
.fe-line > select { flex: 1 1 150px; }
/* ارسال تبلیغاتی */
.cp-chans { display: flex; gap: 8px; flex-wrap: wrap; }
.cp-chan { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; background: var(--panel); }
.cp-text { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 10px; font-size: 13.5px; }

/* کلیک بیرون پنجره: پنجره بسته نمی‌شود، فقط کمی تکان می‌خورد */
@keyframes modal-nudge { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.015); } }
.modal.modal-nudge { animation: modal-nudge .22s ease; }

/* ربات‌ها و پست‌ها */
.bb-list { display: grid; gap: 10px; }
.bb-card { border: 1px solid var(--line, #e3e6ea); border-radius: 10px; padding: 10px 12px; background: var(--card, #fff); }
.bb-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bb-head .sp { flex: 1; }
.bb-targets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.bb-t { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line, #e3e6ea); border-radius: 999px; padding: 3px 10px; font-size: 13px; }
.lnk { background: none; border: 0; color: var(--accent, #2563eb); cursor: pointer; font: inherit; font-size: 12px; padding: 0 2px; }
.lnk.bad { color: var(--bad, #c62828); font-size: 15px; line-height: 1; }
.bp-text { font-size: 12.5px; white-space: pre-wrap; word-break: break-word; max-height: 4.8em; overflow: hidden; }

.ft-imgwrap { position: relative; }
.ft-dot { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 3px solid #e5484d; background: rgba(229,72,77,.25); box-shadow: 0 0 0 4px rgba(255,255,255,.7); pointer-events: none; animation: ftPulse 1s ease-in-out infinite; }
@keyframes ftPulse { 50% { transform: scale(1.35); } }
.ft-wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.55); border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted, #666); pointer-events: none; }
.st-sellers { max-height: 180px; overflow: auto; border: 1px solid var(--line, #e3e6ea); border-radius: 8px; padding: 6px 10px; display: grid; gap: 2px; }
