:root {
  --bg: #0f1117;
  --surface: #171a23;
  --surface-2: #1e222d;
  --border: #2a2f3d;
  --text: #e7e9ee;
  --muted: #9aa1b1;
  --accent: #6c8cff;
  --accent-soft: rgba(108, 140, 255, 0.14);
  --ok: #3ecf8e;
  --warn: #f5a623;
  --danger: #f2555a;
  --radius: 12px;
  font-family: "Vazirmatn", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  font-size: 14px;
  line-height: 1.7;
}

a { color: var(--accent); }

.hidden { display: none !important; }

/* ─── ورود ─── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.login-wrap .card { width: min(380px, 100%); }

/* ─── چیدمان اصلی ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand small { color: var(--muted); font-weight: 400; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

.tab {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}

.tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 26px; line-height: 1.3; }
.stat span { color: var(--muted); font-size: 13px; }

h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 20px 0 10px; color: var(--muted); font-weight: 600; }

/* ─── فرم ─── */
label { display: block; margin-bottom: 14px; }
label > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

textarea { min-height: 150px; resize: vertical; line-height: 1.8; }

.switch { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.switch span { color: var(--text); margin: 0; }

.hint { color: var(--muted); font-size: 12px; margin-top: -8px; margin-bottom: 14px; }

button.btn {
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}

button.btn:hover { border-color: var(--accent); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b0e16; font-weight: 600; }
button.btn.ghost { background: transparent; }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ─── جدول ─── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.title-cell { max-width: 360px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.badge.sent { background: rgba(62, 207, 142, 0.15); color: var(--ok); }
.badge.pending { background: rgba(245, 166, 35, 0.15); color: var(--warn); }
.badge.failed { background: rgba(242, 85, 90, 0.15); color: var(--danger); }
.badge.skipped { background: var(--surface-2); color: var(--muted); }

.logs { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; direction: ltr; text-align: left; }
.log-line { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.log-line.error { color: var(--danger); }
.log-line.warn { color: var(--warn); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  z-index: 50;
  max-width: 420px;
}

.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--danger); }

/* ─── افزوده‌های نسخهٔ چندپروژه‌ای ─── */
.inline-field { display: flex; align-items: center; gap: 8px; margin: 0; }
.inline-field > span { margin: 0; white-space: nowrap; }
.inline-field select { width: auto; min-width: 150px; }

.token-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--ok);
  border-radius: 8px;
  background: rgba(62, 207, 142, 0.07);
}

.token-box code {
  flex: 1;
  display: block;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 13px;
  overflow-x: auto;
  white-space: nowrap;
}

pre.code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  margin: 0 0 14px;
}

code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 12.5px; }

.method { font-family: ui-monospace, monospace; font-weight: 700; margin-left: 8px; }
.method.post { color: var(--ok); }
.method.get { color: var(--accent); }

.badge.partial { background: rgba(245, 166, 35, 0.15); color: var(--warn); }
.badge.revoked { background: rgba(242, 85, 90, 0.15); color: var(--danger); }
.badge.active  { background: rgba(62, 207, 142, 0.15); color: var(--ok); }

tr.selected { background: var(--accent-soft); }
