@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; }
@font-face { font-family: Vazirmatn; src: url(fonts/Vazirmatn-Black.woff2) format("woff2"); font-weight: 900; font-display: swap; }

:root {
  --bg: #10131a;
  --bg-head: #232837;
  --surface: #171b25;
  --surface-2: #1f2431;
  --surface-3: #282e3d;
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .85);
  --text: #f3f4f8;
  --muted: #9aa1b5;
  --primary: #6c4ee0;
  --primary-2: #5a3dcc;
  --primary-soft: rgba(108, 78, 224, .16);
  --accent: #8d72ff;
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, .14);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, .14);
  --err: #f0506e;
  --err-soft: rgba(240, 80, 110, .14);
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f5fb;
  --bg-head: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f1f8;
  --surface-3: #e7e7f2;
  --border: rgba(20, 24, 36, .10);
  --border-strong: rgba(20, 24, 36, .85);
  --text: #151824;
  --muted: #646b80;
  --primary-soft: rgba(108, 78, 224, .10);
  --accent: #5a3dcc;
  --shadow: 0 10px 30px rgba(30, 30, 60, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Vazirmatn, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
.ltr { direction: ltr; unicode-bidi: plaintext; text-align: left; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hl { color: var(--primary); }
:root:not([data-theme="light"]) .hl { color: #7d5ff0; }

/* ---------- header (like brandafraz.ir) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--bg-head), var(--bg));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.topbar-in { max-width: 1200px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 24px; color: var(--text); letter-spacing: -.5px; }
.brand-mark {
  font-family: Georgia, serif; font-style: italic; font-weight: 400; font-size: 30px; line-height: 1;
  color: var(--text); padding-bottom: 4px;
}
.brand-mark b { color: var(--primary); font-weight: 400; }
.nav { display: flex; gap: 6px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px;
  color: var(--text); font-weight: 700; font-size: 16px; position: relative;
}
.nav a svg { width: 18px; height: 18px; opacity: .8; }
.nav a.active::after {
  content: ""; position: absolute; right: 14px; left: 14px; bottom: 2px; height: 2px; border-radius: 2px; background: var(--text);
}
.nav a:hover { background: var(--surface-2); }
.top-actions { display: flex; gap: 12px; align-items: center; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--border-strong); background: transparent;
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.sm { width: 36px; height: 36px; border-width: 1.5px; }
.state-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 10px; border: 2px solid var(--border-strong); font-weight: 700; font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.running { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); animation: pulse 1.6s infinite; }
.dot.paused { background: var(--warn); }
.dot.stopped { background: var(--err); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }

.bottom-nav { display: none; }

main { max-width: 1200px; margin: 0 auto; padding: 28px 20px 110px; }

/* ---------- section titles ---------- */
.title { font-size: 30px; font-weight: 900; margin: 6px 0 4px; position: relative; letter-spacing: -.5px; }
.title-sub { color: var(--muted); margin: 0 0 22px; border-right: 2px solid var(--primary); padding-right: 12px; }
.h2 { font-size: 19px; font-weight: 900; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.h2 svg, .banner svg { width: 20px; height: 20px; flex: none; }

/* ---------- cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1.15fr .85fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card.flat { background: var(--surface-2); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 26px; font-weight: 900; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px; border: 2px solid var(--border-strong); background: transparent;
  font-weight: 700; cursor: pointer; white-space: nowrap; transition: transform .08s, background .15s;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: -4px 4px 0 0 rgba(108, 78, 224, .35); }
.btn.primary:hover { background: var(--primary-2); }
.btn.ghost { border-color: var(--border); background: var(--surface-2); }
.btn.danger { border-color: var(--err); color: var(--err); }
.btn.ok { border-color: var(--ok); color: var(--ok); }
.btn.warn { border-color: var(--warn); color: var(--warn); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-width: 1.5px; border-radius: 10px; }
.btn.lg { padding: 14px 26px; font-size: 17px; }
.btn.block { width: 100%; }

/* ---------- forms ---------- */
label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; }
label.f .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.input, textarea.input, select.input {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2);
  outline: none; transition: border .15s;
}
.input:focus { border-color: var(--primary); }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.8; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 20px; background: var(--surface-3); cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; top: 3px; right: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(-20px); }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--primary); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--text); font-size: 13.5px; font-weight: 500; }
.chip button { border: 0; background: none; cursor: pointer; padding: 0; color: var(--muted); font-size: 16px; line-height: 1; }
.chips input { border: 0; background: transparent; outline: none; flex: 1; min-width: 120px; padding: 4px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.pri { background: var(--primary-soft); color: var(--accent); }

/* ---------- dashboard ---------- */
.hero { position: relative; overflow: hidden; }
.hero::after {
  content: ""; position: absolute; left: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(108, 78, 224, .35), transparent 70%); pointer-events: none;
}
.big-state { font-size: 26px; font-weight: 900; display: flex; align-items: center; gap: 12px; }
.now { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0; font-size: 14.5px; }
.now dt { color: var(--muted); }
.now dd { margin: 0; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.bar { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); border-radius: 8px; transition: width .4s; }
.lanes { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 6px; }
.lane { display: flex; gap: 10px; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.log {
  height: 440px; overflow-y: auto; background: var(--surface-2); border-radius: 12px; padding: 10px 12px;
  font-size: 13.5px; line-height: 1.9; border: 1px solid var(--border);
}
.log div { display: flex; gap: 8px; border-bottom: 1px dashed var(--border); padding: 2px 0; }
.log time { color: var(--muted); font-size: 12px; direction: ltr; flex: none; padding-top: 2px; }
.log .acc { color: var(--accent); font-weight: 700; flex: none; }
.log .ok { color: var(--ok); }
.log .warn { color: var(--warn); }
.log .error { color: var(--err); }
.log .alert { color: #fff; background: var(--primary); border-radius: 6px; padding: 0 6px; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: right; color: var(--muted); font-weight: 500; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 9px 8px; border-bottom: 1px solid var(--border); }
.table-wrap { overflow-x: auto; }

/* ---------- accounts ---------- */
.acc { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px 16px; }
.acc + .acc { border-top: 1px solid var(--border); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; background: var(--primary-soft); color: var(--accent); font-size: 18px; }
.acc.excluded { opacity: .55; }
.acc .name { font-weight: 900; font-size: 16px; }
.acc .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }
.acc-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.acc.running { background: linear-gradient(90deg, transparent, var(--primary-soft)); }

/* ---------- courses ---------- */
.course { display: grid; grid-template-columns: 110px 1fr; gap: 16px; }
.course img, .thumb { width: 110px; height: 110px; object-fit: cover; border-radius: 12px; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }
.course.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.variant { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface-2); }
.variant textarea { min-height: 160px; background: var(--surface); }
.variants { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.preview-img { max-width: 220px; border-radius: 12px; border: 1px solid var(--border); }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(5, 7, 12, .7); backdrop-filter: blur(4px); z-index: 50; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); max-height: calc(100vh - 32px); overflow-y: auto; }
.modal.wide { width: min(1100px, 100%); }
.modal h3 { margin: 0 0 14px; font-size: 20px; font-weight: 900; padding-left: 44px; }
.modal-x {
  position: sticky; top: 0; float: left; z-index: 3; margin: -6px -6px 0 0;
  width: 38px; height: 38px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--surface-2);
  color: var(--text); font-size: 24px; line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.modal-x:hover { border-color: var(--err); color: var(--err); }
#variants { scroll-margin-top: 12px; border-radius: 14px; }
#variants.flash { animation: flash 1.2s; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(108, 78, 224, .7); } 100% { box-shadow: 0 0 0 14px transparent; } }
.modal-foot { display: flex; gap: 10px; justify-content: flex-start; margin-top: 18px; flex-wrap: wrap; }

.auth-modal { border: 2px solid var(--primary); }
.auth-modal.alerting { animation: ring 1s infinite; }
@keyframes ring { 50% { box-shadow: 0 0 0 8px rgba(108, 78, 224, .35); } }
.code-input { font-size: 30px; letter-spacing: 10px; text-align: center; direction: ltr; font-weight: 900; }
.countdown { font-size: 34px; font-weight: 900; color: var(--accent); direction: ltr; }

.banner { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 700; margin-bottom: 16px; cursor: pointer; }
.banner.danger { background: var(--err-soft); color: var(--err); border: 1.5px solid var(--err); flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); cursor: default; }

/* ---------- toast ---------- */
#toast-root { pointer-events: none; position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; width: calc(100% - 32px); max-width: 420px; }
.toast { background: var(--surface-3); border: 1px solid var(--border); padding: 10px 18px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 700; animation: up .2s; }
.toast.err { border-color: var(--err); color: var(--err); }
.toast.ok { border-color: var(--ok); }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(400px, 100%); padding: 30px; text-align: center; }
.login .brand { justify-content: center; font-size: 30px; margin-bottom: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .nav, .top-actions .state-chip { display: none; }
  .topbar-in { padding: 10px 16px; justify-content: space-between; }
  .brand { font-size: 21px; }
  main { padding: 18px 16px 110px; }
  .title { font-size: 24px; }
  .form-2 { grid-template-columns: 1fr; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); font-weight: 700; padding: 4px; }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--accent); }
  .acc { grid-template-columns: auto 1fr; }
  .acc-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .course { grid-template-columns: 76px 1fr; }
  .course img, .thumb { width: 76px; height: 76px; }
  .log { height: 360px; }
  .variants { grid-template-columns: 1fr; }
  .controls .btn { flex: 1; }
}
