:root {
  --bg: #0e1117;
  --panel: #161b24;
  --panel2: #1d2430;
  --line: #2a3340;
  --text: #e7ecf3;
  --muted: #8b97a8;
  --brand: #e1306c;
  --brand2: #c13584;
  --ok: #2ea56b;
  --warn: #d9a13b;
  --err: #e05252;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  font-size: 14px;
  line-height: 1.8;
}

a { color: #6fb2ff; }

.hidden { display: none !important; }

/* ---------- layout ---------- */
header {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.logo { font-weight: 800; font-size: 16px; }
.logo span { background: linear-gradient(45deg, var(--brand), var(--brand2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.grow { flex: 1; }

main { max-width: 1050px; margin: 0 auto; padding: 20px; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font-family: inherit; font-size: 13px;
}
.tabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- cards ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card h3 { margin: 0 0 4px; font-size: 15px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; font-weight: 800; }
.stat small { color: var(--muted); }

/* ---------- buttons ---------- */
button, .btn {
  font-family: inherit; font-size: 13px; cursor: pointer;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); padding: 9px 16px;
  transition: .15s;
}
button:hover { border-color: #3d4a5c; }
.primary { background: linear-gradient(45deg, var(--brand), var(--brand2)); border: none; color: #fff; font-weight: 700; }
.ghost { background: transparent; }
.danger { color: var(--err); }
.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

/* ---------- forms ---------- */
label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
label .req { color: var(--brand); }
input[type=text], input[type=password], input[type=url], textarea, select {
  width: 100%; padding: 10px 12px; font-family: inherit; font-size: 14px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; line-height: 1.9; }
.hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 680px) { .row { grid-template-columns: 1fr; } }

.check { display: flex; align-items: center; gap: 8px; margin: 12px 0; color: var(--text); }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; min-width: 120px; }
.seg button.on { border-color: var(--brand); background: rgba(225,48,108,.15); color: #fff; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: rgba(46,165,107,.4); background: rgba(46,165,107,.1); }
.badge.off { color: var(--muted); }
.badge.err { color: var(--err); border-color: rgba(224,82,82,.4); background: rgba(224,82,82,.1); }
.badge.warn { color: var(--warn); border-color: rgba(217,161,59,.4); background: rgba(217,161,59,.1); }
.kw { display: inline-block; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 2px 9px; margin: 2px 0 2px 4px; font-size: 12px; }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.wrap { max-width: 260px; word-break: break-word; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow: auto; z-index: 50;
}
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; width: 100%; max-width: 720px; padding: 22px; }
.modal h2 { margin: 0 0 4px; font-size: 17px; }

/* ---------- media picker ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; max-height: 260px; overflow: auto; margin-top: 10px; }
.media-grid figure { margin: 0; cursor: pointer; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--panel2); }
.media-grid figure.on { border-color: var(--brand); }
.media-grid img { width: 100%; height: 92px; object-fit: cover; display: block; }
.media-grid figcaption { font-size: 10px; color: var(--muted); padding: 3px 5px; text-align: center; }

.thumb { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }

/* ---------- login ---------- */
.login { max-width: 360px; margin: 14vh auto; }

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #232c3a; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 18px; z-index: 99; max-width: 90vw; box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
#toast.err { border-color: var(--err); }
#toast.ok { border-color: var(--ok); }

.note { background: rgba(217,161,59,.08); border: 1px solid rgba(217,161,59,.35); border-radius: 12px; padding: 12px 14px; font-size: 13px; }
code { background: var(--panel2); padding: 1px 6px; border-radius: 6px; font-size: 12px; direction: ltr; display: inline-block; }

/* ---------- toolbar / search / pager ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search { flex: 1; min-width: 180px; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin: 14px 0; flex-wrap: wrap; }
.pager .muted { color: var(--muted); font-size: 12px; }

hr { border: none; border-top: 1px solid var(--line); margin: 22px 0; }

.check label { margin: 0; color: var(--text); cursor: pointer; }

/* ---------- keyword picker ---------- */
.picker { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.picker input[type=text] { background: var(--panel); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chips:empty::before { content: 'هنوز کلمه‌ای انتخاب نشده'; color: var(--muted); font-size: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(225,48,108,.16); border: 1px solid rgba(225,48,108,.45);
  color: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px;
}
.chip b { font-weight: 600; }
.chip span { cursor: pointer; opacity: .7; font-size: 14px; line-height: 1; }
.chip span:hover { opacity: 1; color: var(--err); }

.pick-list {
  max-height: 210px; overflow: auto; margin-top: 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.pick-row { display: flex; align-items: center; gap: 9px; padding: 7px 11px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick-row:last-child { border-bottom: none; }
.pick-row:hover { background: var(--panel2); }
.pick-row input { width: 17px; height: 17px; accent-color: var(--brand); }
.pick-row .own { color: var(--ok); font-size: 11px; margin-right: auto; }
.pick-add { display: flex; gap: 8px; margin-top: 10px; }
.pick-add input { flex: 1; }

/* ---------- message card ---------- */
.mcard { display: flex; gap: 12px; align-items: flex-start; }
.mcard .body { flex: 1; min-width: 0; }
.mcard .acts { display: flex; flex-direction: column; gap: 6px; }
.kwline { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

td.act { white-space: nowrap; }
.rep { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.rep ul { margin: 6px 0 0; padding-inline-start: 18px; }

/* ---------- big primary button ---------- */
button.big {
  font-size: 15px; font-weight: 800; padding: 14px 26px; border-radius: 14px; width: 100%;
  box-shadow: 0 6px 20px rgba(225,48,108,.25);
}
@media (min-width: 560px) { button.big { width: auto; min-width: 240px; } }

/* ---------- steps inside the form ---------- */
.step {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px; margin: 16px 0;
}
.step-head { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.step-head .num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(45deg, var(--brand), var(--brand2)); color: #fff;
  font-size: 12px; font-weight: 800; flex: none;
}
.step input[type=text], .step textarea, .step select { background: var(--panel); }
details.step summary { list-style: none; }
details.step summary::-webkit-details-marker { display: none; }
details.step summary::after { content: '▾'; margin-inline-start: auto; color: var(--muted); }
details.step[open] summary::after { content: '▴'; }
