/* Vazirmatn v33.0.3 (SIL OFL 1.1, see fonts/OFL.txt), self-hosted so it loads without any CDN */
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-wght.woff2") format("woff2-variations"),
       url("/static/fonts/Vazirmatn-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --surface-3: #e8edf3;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #0f172a;
  --on-primary: #ffffff;
  --brand: #b42318;
  --brand-soft: #fdecea;
  --success: #15803d;  --success-soft: #e7f6ec;
  --warning: #b45309;  --warning-soft: #fef3e2;
  --danger: #b91c1c;   --danger-soft: #fdecec;
  --info: #1d4ed8;     --info-soft: #e8efff;
  --violet: #6d28d9;   --violet-soft: #f1ebff;
  --ring: #2563eb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 12px rgba(15, 23, 42, .04);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 248px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #172033;
    --surface-3: #1f2a40;
    --text: #f1f5f9;
    --text-2: #a3b1c6;
    --text-3: #8392a8;
    --border: #243045;
    --border-strong: #334159;
    --primary: #f1f5f9;
    --on-primary: #0f172a;
    --brand: #f87171;
    --brand-soft: #3a1717;
    --success: #4ade80;  --success-soft: #11291b;
    --warning: #fbbf24;  --warning-soft: #2e2311;
    --danger: #f87171;   --danger-soft: #331616;
    --info: #93b4ff;     --info-soft: #172241;
    --violet: #c4b5fd;   --violet-soft: #241b3d;
    --ring: #93b4ff;
    --shadow-sm: none;
    --shadow: none;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.7 "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.35; }
h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: plaintext; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 22px; height: 22px; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; inset-inline-start: 12px; top: -48px; z-index: 100; background: var(--primary);
  color: var(--on-primary); padding: 8px 14px; border-radius: var(--radius-sm); }
.skip:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px; background: var(--surface); border-inline-end: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: #b42318; color: #fff; }
.brand b { display: block; font-size: 1rem; }
.brand span { font-size: .78rem; color: var(--text-3); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; min-height: 40px;
  border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-weight: 500;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-3); color: var(--text); font-weight: 700; }
.nav a[aria-current="page"] .icon { color: var(--brand); }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); display: grid;
  place-items: center; color: var(--text-2); flex: none; }
.sidebar-foot .who { flex: 1; min-width: 0; font-size: .88rem; }
.sidebar-foot .who b { display: block; overflow: hidden; text-overflow: ellipsis; }
.content { min-width: 0; padding: 28px 32px 64px; }
.content-in { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

@media (max-width: 1023px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; z-index: 20; height: auto; flex-direction: row; align-items: center;
    padding: 8px 12px; border-inline-end: 0; border-bottom: 1px solid var(--border); gap: 8px; }
  .sidebar .brand { padding: 0; }
  .sidebar .brand > div { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; scrollbar-width: none; }
  .nav a { white-space: nowrap; padding: 8px 10px; }
  .nav a span { font-size: .88rem; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; }
  .sidebar-foot .who, .sidebar-foot .avatar { display: none; }
  .content { padding: 20px 16px 48px; }
}
@media (max-width: 560px) { .nav a span { display: none; } .nav a { padding: 8px 12px; } }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; color: var(--text-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  font: inherit; font-weight: 600; font-size: .92rem; text-decoration: none; white-space: nowrap;
  transition: background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease);
  touch-action: manipulation;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: .85rem; }
.btn-icon { width: 40px; padding: 0; }
.btn[aria-busy="true"] { opacity: .6; pointer-events: none; }
@media (prefers-color-scheme: dark) { .btn-success { color: #052e16; } }
form.inline { display: inline-flex; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head p { color: var(--text-2); font-size: .88rem; margin-top: 2px; }
.card-body { padding: 18px 20px; }
.card-body.flush { padding: 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 4px; }
.section-title span { color: var(--text-3); font-size: .88rem; }

/* ---------- stats ---------- */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-2);
  font-size: .88rem; font-weight: 500; }
.chip-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; }
.tone-neutral { background: var(--surface-3); color: var(--text-2); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-violet { background: var(--violet-soft); color: var(--violet); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.stat-value { font-size: 1.9rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: .95rem; color: var(--text-3); font-weight: 600; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--success); }

/* ---------- status hero ---------- */
.status { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; padding: 20px; }
.status-main { display: flex; gap: 14px; align-items: flex-start; }
.status-dot { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.status h2 { font-size: 1.1rem; }
.status p { color: var(--text-2); margin-top: 2px; }
.status-meta { display: flex; gap: 6px 18px; flex-wrap: wrap; margin-top: 10px; color: var(--text-2); font-size: .86rem; }
.status-meta span { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 720px) { .status { grid-template-columns: 1fr; } }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px;
  font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.queued, .badge.pending, .badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.posted, .badge.success { background: var(--success-soft); color: var(--success); }
.badge.skipped, .badge.rejected { background: var(--surface-3); color: var(--text-2); }
.badge.has-phone { background: var(--info-soft); color: var(--info); }
.badge.plain::before { display: none; }

/* ---------- alerts ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid; font-size: .92rem; }
.alert .icon { margin-top: 3px; }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); color: var(--text); }
.alert-warning .icon { color: var(--warning); }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert-success .icon { color: var(--success); }
.alert-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-danger .icon { color: var(--danger); }

/* ---------- logs ---------- */
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 92px 84px 1fr; gap: 12px; align-items: baseline;
  padding: 10px 20px; border-bottom: 1px solid var(--border); font-size: .88rem; }
.log li:last-child { border-bottom: 0; }
.log time { color: var(--text-3); font-variant-numeric: tabular-nums; }
.log .msg { overflow-wrap: anywhere; }
.kind { font-size: .78rem; font-weight: 600; }
.kind-error { color: var(--danger); } .kind-post { color: var(--success); } .kind-prep { color: var(--info); }
.kind-home { color: var(--violet); } .kind-auth, .kind-settings { color: var(--text-2); }
@media (max-width: 640px) { .log li { grid-template-columns: 1fr auto; } .log .msg { grid-column: 1 / -1; } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: .9rem; }
.hint { color: var(--text-3); font-size: .82rem; font-weight: 400; }
.input, .textarea, select {
  font: inherit; font-size: .95rem; width: 100%; min-height: 42px; padding: 8px 12px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:focus, .textarea:focus { outline: none; border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 22%, transparent); }
.textarea { min-height: 140px; resize: vertical; line-height: 1.8; }
.textarea.tall { min-height: 300px; }
.input.ltr, .textarea.ltr { direction: ltr; text-align: left; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.check input { width: 18px; height: 18px; margin-top: 4px; accent-color: var(--primary); }
input[type=file] { font: inherit; font-size: .9rem; }
.settings-section { display: grid; grid-template-columns: 240px 1fr; gap: 24px; padding: 22px 20px;
  border-bottom: 1px solid var(--border); }
.settings-section:last-child { border-bottom: 0; }
.settings-section > div:first-child p { color: var(--text-2); font-size: .86rem; margin-top: 4px; }
@media (max-width: 860px) { .settings-section { grid-template-columns: 1fr; gap: 14px; } }
.sticky-save { position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 20px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- queue ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border-strong); color: var(--text-2);
  text-decoration: none; font-size: .86rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tab:hover { background: var(--surface-2); }
.tab[aria-current="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.ad { display: grid; grid-template-columns: 148px 1fr; gap: 18px; padding: 18px 20px; }
.thumb { width: 148px; aspect-ratio: 1; border-radius: 10px; object-fit: cover; background: var(--surface-3);
  display: grid; place-items: center; color: var(--text-3); }
.ad-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.ad-title { font-weight: 700; font-size: 1rem; }
.ad-index { color: var(--text-3); font-variant-numeric: tabular-nums; margin-inline-end: 6px; }
.ad-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; color: var(--text-2); font-size: .86rem; }
.ad-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); }
.ad form { margin-top: 14px; }
.ad-fields { display: grid; grid-template-columns: 220px 1fr; gap: 14px; align-items: start; }
.ad-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
details.ai { margin-top: 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px; }
details.ai summary { cursor: pointer; font-weight: 600; font-size: .9rem; display: flex; gap: 8px; align-items: center;
  list-style: none; color: var(--text-2); }
details.ai summary::-webkit-details-marker { display: none; }
details.ai[open] summary { margin-bottom: 10px; }
@media (max-width: 760px) {
  .ad { grid-template-columns: 1fr; }
  .thumb { width: 100%; aspect-ratio: 16 / 9; }
  .ad-fields { grid-template-columns: 1fr; }
}
.preview { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; line-height: 1.85; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: start; font-weight: 600; color: var(--text-3); font-size: .8rem; padding: 10px 20px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table td { padding: 12px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table a { color: var(--text); font-weight: 600; text-decoration: none; }
.table a:hover { text-decoration: underline; }
@media (max-width: 640px) { .table th:nth-child(2), .table td:nth-child(2) { display: none; } }

/* ---------- empty / login / misc ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty .chip-icon { margin: 0 auto 12px; width: 48px; height: 48px; border-radius: 14px; }
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 400px; padding: 28px; }
.login .brand { padding: 0 0 22px; }
.steps { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--text-2); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; background: var(--surface-3);
  padding: 2px 6px; border-radius: 6px; direction: ltr; unicode-bidi: isolate; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
