:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --ink: #16181D;
  --ink-2: #4B5260;
  --ink-3: #6B7280;
  --line: #E3E5EA;
  --accent: #0E7490;
  --accent-ink: #FFFFFF;
  --accent-soft: #E0F2F7;
  --metal: #2B2D32;
  --good: #15803D;
  --good-soft: #DCFCE7;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --bad: #B91C1C;
  --bad-soft: #FEE2E2;
  --radius: 10px;
  --font: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1013; --surface: #17191E; --surface-2: #1D2026; --ink: #ECEEF2; --ink-2: #B9BEC8;
    --ink-3: #8C93A0; --line: #2A2E36; --accent: #22B8CF; --accent-ink: #06232A; --accent-soft: #10343B;
    --metal: #0B0C0F; --good: #4ADE80; --good-soft: #10301C; --warn: #FBBF24; --warn-soft: #3A2C0B;
    --bad: #F87171; --bad-soft: #3B1515;
  }
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.7; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
p { margin: 0 0 10px; }
code, pre, .mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; direction: ltr; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--line);
      border-radius: 8px; padding: 12px; font-size: 0.86rem; margin: 0; direction: rtl; text-align: right;
      font-family: var(--font); max-height: 420px; overflow: auto; }

.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 220px; max-width: 250px; background: var(--metal); color: #D7DAE0; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 700; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #3A3B3E, #9A9CA1 55%, #2E2F32);
              display: grid; place-items: center; color: #0B0C0F; font-weight: 800; font-size: 13px; }
.brand small { display: block; font-weight: 400; color: #9AA0AB; font-size: 0.78rem; }
.nav a { display: flex; justify-content: space-between; align-items: center; color: #D7DAE0; padding: 8px 10px;
         border-radius: 8px; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.nav a.on { background: rgba(34,184,207,0.16); color: #fff; }
.nav .sep { height: 1px; background: rgba(255,255,255,0.08); margin: 10px 6px; }
.pill { background: #22B8CF; color: #06232A; border-radius: 999px; font-size: 0.75rem; padding: 0 8px; font-weight: 700; }
.main { flex: 999 1 560px; min-width: 0; padding: 24px clamp(16px, 3vw, 36px) 60px; }
@media (max-width: 760px) { .side { max-width: none; flex-basis: 100%; } .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav a { padding: 6px 10px; } .nav .sep { display: none; } }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.sub { color: var(--ink-3); font-size: 0.9rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; }
.stat span { color: var(--ink-3); font-size: 0.85rem; }
.stat.hot { border-color: var(--accent); }

.flash { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--ink); padding: 10px 14px;
         border-radius: 8px; margin-bottom: 16px; }
.error { background: var(--bad-soft); border: 1px solid var(--bad); padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: right; color: var(--ink-3); font-weight: 600; font-size: 0.82rem; border-bottom: 1px solid var(--line); padding: 8px; white-space: nowrap; }
td { border-bottom: 1px solid var(--line); padding: 9px 8px; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.78rem; background: var(--surface-2);
         border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.b-good { background: var(--good-soft); border-color: transparent; color: var(--good); }
.b-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.b-bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.b-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

form.inline { display: inline; }
label { display: block; font-size: 0.85rem; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-height: 40px; }
textarea { min-height: 110px; resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.field { margin-bottom: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.row > .field { flex: 1 1 160px; margin-bottom: 0; }
button, .btn { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 6px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.primary:hover { filter: brightness(1.08); background: var(--accent); }
.danger { color: var(--bad); border-color: var(--bad); }
.small { min-height: 32px; padding: 2px 10px; font-size: 0.85rem; }

.funnel { display: grid; gap: 8px; }
.fbar { display: grid; grid-template-columns: 130px 1fr 70px; align-items: center; gap: 10px; font-size: 0.9rem; }
.fbar .track { background: var(--surface-2); border-radius: 6px; height: 26px; overflow: hidden; border: 1px solid var(--line); }
.fbar .fill { background: var(--accent); height: 100%; border-radius: 5px; min-width: 3px; }
.fbar .num { text-align: left; font-weight: 700; }

.timeline { list-style: none; margin: 0; padding: 0; font-size: 0.88rem; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; justify-content: space-between; gap: 10px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 12px; font-size: 0.92rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; word-break: break-word; }
.items .item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface-2); }
.item-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.85rem; color: var(--ink-3); margin-bottom: 4px; }
.msg { border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; max-width: 80%; }
.msg.cand { background: var(--surface-2); border: 1px solid var(--line); }
.msg.admin { background: var(--accent-soft); margin-right: auto; }
.rubric { display: grid; gap: 8px; }
.rubric .r { display: grid; grid-template-columns: 1fr 90px; gap: 10px; align-items: center; }
.muted { color: var(--ink-3); }
.right { text-align: left; }
.nowrap { white-space: nowrap; }
.spacer { height: 8px; }
details summary { cursor: pointer; color: var(--accent); }
.login { max-width: 380px; margin: 10vh auto; }
.copybox { position: relative; }
.copybox button { position: absolute; top: 8px; left: 8px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tabs a { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.tabs a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.empty { text-align: center; color: var(--ink-3); padding: 28px 10px; }
