@font-face { font-family: "Vazirmatn"; src: url("/static/fonts/Vazirmatn.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #f4f6fb; --panel: #ffffff; --panel-2: #f8fafc; --ink: #0f172a; --ink-2: #475569; --ink-3: #94a3b8;
  --line: #e2e8f0; --brand: #2454d6; --brand-ink: #ffffff; --brand-soft: #e8eefc;
  --ok: #0f9d58; --ok-soft: #e6f6ee; --warn: #b7791f; --warn-soft: #fdf5e6; --bad: #d93025; --bad-soft: #fdecea;
  --info: #0b7285; --info-soft: #e3f6f8; --muted-soft: #eef1f5; --orange: #c2570c; --orange-soft: #fff1e6;
  --tg: #229ed9; --bale: #1fa55b; --ig: #d62976; --li: #0a66c2;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --panel: #111a2e; --panel-2: #0e1628; --ink: #e5e9f2; --ink-2: #a3b0c7; --ink-3: #8391ab;
    --line: #1f2a44; --brand: #6b97ff; --brand-ink: #0b1220; --brand-soft: #18264a;
    --ok: #34c37a; --warn: #e0a53a; --bad: #f2665b; --orange: #f08c3a; --info: #4fc3d6;
    --ok-soft: #10301f; --warn-soft: #33270f; --bad-soft: #3a1513; --info-soft: #0d2f36; --muted-soft: #172036; --orange-soft: #3a220f;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
    --bg: #0b1220; --panel: #111a2e; --panel-2: #0e1628; --ink: #e5e9f2; --ink-2: #a3b0c7; --ink-3: #8391ab;
    --line: #1f2a44; --brand: #6b97ff; --brand-ink: #0b1220; --brand-soft: #18264a;
    --ok: #34c37a; --warn: #e0a53a; --bad: #f2665b; --orange: #f08c3a; --info: #4fc3d6;
    --ok-soft: #10301f; --warn-soft: #33270f; --bad-soft: #3a1513; --info-soft: #0d2f36; --muted-soft: #172036; --orange-soft: #3a220f;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.75 "Vazirmatn", Tahoma, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.4; margin: 0 0 .6rem; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: .85em; direction: ltr; unicode-bidi: embed; }
.ltr { direction: ltr; unicode-bidi: embed; text-align: left; }

/* layout */
.layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-left: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 800; font-size: 1.02rem; }
.logo .mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), #7c3aed); display: grid; place-items: center; color: #fff; font-size: .95rem; }
.logo small { display: block; font-weight: 500; color: var(--ink-3); font-size: .72rem; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: var(--panel-2); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.nav svg { width: 18px; height: 18px; flex: none; }
.userbox { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; font-size: .88rem; }
.userbox .who { font-weight: 700; } .userbox .role { color: var(--ink-3); font-size: .78rem; }
.userbox form { display: inline; }
.main { padding: 26px 32px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar .sub { color: var(--ink-3); font-size: .85rem; margin-top: -4px; }
.menu-btn { display: none; }

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: .9rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { padding: 16px 18px; } .kpi .n { font-size: 1.9rem; font-weight: 800; line-height: 1.2; }
.kpi .l { color: var(--ink-2); font-size: .85rem; } .kpi.accent { border-top: 3px solid var(--brand); }
.kpi.warn { border-top: 3px solid var(--warn); } .kpi.ok { border-top: 3px solid var(--ok); } .kpi.bad { border-top: 3px solid var(--bad); }
.muted { color: var(--ink-3); } .small { font-size: .82rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; line-height: 1.4; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.btn.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.btn.sm { padding: 5px 10px; font-size: .82rem; border-radius: 8px; }
.btn svg { width: 16px; height: 16px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700; background: var(--muted-soft); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.pf { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .85rem; }
.pf::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }
.pf.telegram::before { background: var(--tg); } .pf.bale::before { background: var(--bale); }
.pf.instagram::before { background: var(--ig); } .pf.linkedin::before { background: var(--li); }

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; border: 1px solid transparent; }
.flash.ok { background: var(--ok-soft); color: var(--ok); } .flash.err { background: var(--bad-soft); color: var(--bad); }
.flash.info { background: var(--info-soft); color: var(--info); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-3); font-weight: 600; font-size: .8rem; background: var(--panel-2); }
tbody tr:hover { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }

/* forms */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
.hint { color: var(--ink-3); font-size: .78rem; font-weight: 400; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); font: inherit; }
textarea { min-height: 110px; resize: vertical; line-height: 1.8; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; direction: ltr; min-height: 260px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.field { margin-bottom: 14px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; margin-bottom: 8px; }
.check input { margin-top: 6px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 0 0 14px; }
legend { padding: 0 6px; font-weight: 700; }
.point-row { display: grid; grid-template-columns: 1fr 170px 1fr; gap: 8px; margin-bottom: 8px; }

/* platform previews */
.preview { white-space: pre-wrap; word-wrap: break-word; unicode-bidi: plaintext; font-size: .92rem; line-height: 1.9; }
.pv { border-radius: 14px; padding: 14px 16px; max-height: 520px; overflow: auto; }
.pv.telegram { background: #e7f3fb; color: #0f172a; border: 1px solid #cfe6f6; }
.pv.bale { background: #e9f7ef; color: #0f172a; border: 1px solid #cdebd8; }
.pv.linkedin { background: var(--panel); border: 1px solid var(--line); }
.pv.instagram { background: var(--panel); border: 1px solid var(--line); }
:root[data-theme="dark"] .pv.telegram { background: #10283a; color: var(--ink); border-color: #19405c; }
:root[data-theme="dark"] .pv.bale { background: #0f2c1d; color: var(--ink); border-color: #18452c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pv.telegram { background: #10283a; color: var(--ink); border-color: #19405c; } :root:not([data-theme="light"]) .pv.bale { background: #0f2c1d; color: var(--ink); border-color: #18452c; } }
.slides { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; margin-top: 10px; }
.slide { flex: 0 0 190px; aspect-ratio: 4/5; border-radius: 12px; padding: 14px; background: linear-gradient(160deg, var(--brand), #7c3aed); color: #fff; display: flex; flex-direction: column; }
.slide .h { font-weight: 800; font-size: 1rem; line-height: 1.5; } .slide .t { font-size: .82rem; margin-top: 8px; opacity: .95; }
.slide .v { margin-top: auto; font-size: .7rem; opacity: .8; border-top: 1px dashed rgba(255,255,255,.4); padding-top: 6px; }
.slide .n { font-size: .7rem; opacity: .75; }
.out { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 18px; box-shadow: var(--shadow); }
.out-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.out-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; padding: 16px 18px; }
.meta dt { color: var(--ink-3); font-size: .78rem; } .meta dd { margin: 0 0 8px; font-size: .9rem; }
.flags { margin: 0; padding-right: 18px; } .flags li { margin-bottom: 4px; font-size: .86rem; }
.decide { background: var(--panel-2); border-radius: 12px; padding: 12px; margin-top: 10px; }
.timeline { list-style: none; margin: 0; padding: 0; } .timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .85rem; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .wd { text-align: center; color: var(--ink-3); font-size: .8rem; font-weight: 700; padding: 4px 0; }
.cal .day { min-height: 110px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; font-size: .78rem; }
.cal .day.empty { background: transparent; border: 0; }
.cal .day.today { border: 2px solid var(--brand); }
.cal .num { font-weight: 800; color: var(--ink-2); }
.cal .ev { display: block; border-radius: 6px; padding: 2px 6px; margin-top: 4px; background: var(--muted-soft); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.published { background: var(--ok-soft); } .cal .ev.scheduled { background: var(--brand-soft); }
.cal .ev.failed, .cal .ev.unknown { background: var(--bad-soft); } .cal .ev.pending { background: var(--warn-soft); }

.bar { height: 10px; border-radius: 99px; background: var(--muted-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.health { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-left: 6px; background: var(--bad); }
.dot.on { background: var(--ok); }

.center-card { max-width: 420px; margin: 9vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 30px; box-shadow: var(--shadow); font-family: "Vazirmatn", Tahoma, sans-serif; direction: rtl; }
.login-brand { text-align: center; margin-bottom: 18px; } .login-brand .mark { width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 10px; background: linear-gradient(135deg, var(--brand), #7c3aed); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.3rem; }
.secret { background: var(--warn-soft); border: 1px dashed var(--warn); border-radius: 12px; padding: 14px; font-size: 1.15rem; text-align: center; letter-spacing: .5px; }
.perm-group { margin-bottom: 10px; } .perm-group h4 { margin: 6px 0; font-size: .85rem; color: var(--ink-2); }
.empty-state { text-align: center; padding: 36px 10px; color: var(--ink-3); }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .out-body { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 0 0 auto; width: 270px; z-index: 20; transform: translateX(100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: -10px 0 30px rgba(0,0,0,.2); }
  .menu-btn { display: inline-flex; }
  .main { padding: 18px 16px 50px; }
  .g2, .g3, .fields-2, .point-row { grid-template-columns: 1fr; }
  .cal .day { min-height: 70px; } .cal .ev { font-size: .68rem; }
}

/* utilities (no inline styles: CSP style-src 'self') */
.block { width: 100%; justify-content: center; } .mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .narrow { max-width: 560px; }
.bad { color: var(--bad); } .right { margin-right: auto; }
progress.meter { width: 100%; height: 10px; appearance: none; border: 0; border-radius: 99px; background: var(--muted-soft); overflow: hidden; }
progress.meter::-webkit-progress-bar { background: var(--muted-soft); border-radius: 99px; }
progress.meter::-webkit-progress-value { background: var(--brand); border-radius: 99px; }
progress.meter::-moz-progress-bar { background: var(--brand); border-radius: 99px; }

/* ---- v2: semantic colours, KPI links, charts, status cards, toasts, skeletons, motion ---- */
.badge.orange { background: var(--orange-soft); color: var(--orange); } .badge.muted { background: var(--muted-soft); color: var(--ink-3); }
.kpi-link { display: block; color: inherit; transition: transform .15s ease, box-shadow .15s ease; }
.kpi-link:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 22px rgba(15,23,42,.10); }
.kpi .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi .delta { font-size: .78rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--muted-soft); color: var(--ink-2); }
.kpi .delta.good { background: var(--ok-soft); color: var(--ok); } .kpi .delta.bad { background: var(--bad-soft); color: var(--bad); }
.kpi .go { font-size: .78rem; color: var(--brand); margin-top: 4px; }
.spark { width: 100%; height: 34px; margin-top: 6px; } .spark-line { fill: none; stroke: var(--brand); stroke-width: 2; vector-effect: non-scaling-stroke; }
.kpi.ok .spark-line { stroke: var(--ok); } .kpi.bad .spark-line { stroke: var(--bad); } .kpi.warn .spark-line { stroke: var(--warn); }
.chart { width: 100%; height: auto; } .grid-line { stroke: var(--line); stroke-dasharray: 3 4; }
.axis { fill: var(--ink-3); font-size: 10px; font-family: "Vazirmatn", Tahoma, sans-serif; }
.bar-ok { fill: var(--ok); } .bar-bad { fill: var(--bad); }
.donut { width: 150px; height: 150px; flex: none; } .donut-bg { stroke: var(--muted-soft); }
.seg.c-ok { stroke: var(--ok); } .seg.c-brand { stroke: var(--brand); } .seg.c-warn { stroke: var(--warn); }
.seg.c-orange { stroke: var(--orange); } .seg.c-bad { stroke: var(--bad); }
.donut-n { fill: var(--ink); font-size: 22px; font-weight: 800; font-family: "Vazirmatn", Tahoma, sans-serif; }
.legend { list-style: none; margin: 0; padding: 0; } .legend li { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: .86rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .c-ok { background: var(--ok); } .legend .c-brand { background: var(--brand); } .legend .c-warn { background: var(--warn); }
.legend .c-orange { background: var(--orange); } .legend .c-bad { background: var(--bad); }
.legend-inline { display: flex; gap: 14px; font-size: .8rem; color: var(--ink-2); } .legend-inline i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 5px; vertical-align: middle; }
.legend-inline .ok { background: var(--ok); } .legend-inline .bad { background: var(--bad); }

.targets-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.tcard { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--panel); border-top: 3px solid var(--ink-3); transition: border-color .3s; }
.tcard.ok { border-top-color: var(--ok); } .tcard.warn { border-top-color: var(--warn); } .tcard.bad { border-top-color: var(--bad); }
.tcard.orange { border-top-color: var(--orange); } .tcard.muted { border-top-color: var(--ink-3); }
.tcard .d { font-size: .8rem; color: var(--ink-2); margin: 6px 0 10px; min-height: 2.6em; }
.skeleton { position: relative; overflow: hidden; background: var(--muted-soft); border-radius: 8px; min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(-100%); } }
.sk-line { height: 12px; margin: 8px 0; } .sk-block { height: 96px; }

.toasts { position: fixed; bottom: 18px; left: 18px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { padding: 12px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); font-weight: 600; background: var(--panel);
  border: 1px solid var(--line); animation: toast-in .25s ease; cursor: pointer; }
.toast.ok { border-right: 4px solid var(--ok); } .toast.err { border-right: 4px solid var(--bad); } .toast.info { border-right: 4px solid var(--brand); }
.toast.hide { opacity: 0; transform: translateY(8px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.badge, .tcard, .card { transition: background-color .25s, color .25s, border-color .25s; }
.theme-btn { min-width: 38px; justify-content: center; }
.filters { display: grid; grid-template-columns: 2fr repeat(5, minmax(0, 1fr)) auto; gap: 8px; align-items: end; }
.filters label { font-size: .75rem; color: var(--ink-3); margin-bottom: 2px; }
.quick { display: flex; gap: 4px; flex-wrap: wrap; }
.err-box { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 6px 8px; font-size: .78rem; margin-top: 4px; }
@media (max-width: 1100px) { .targets-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .filters { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) { .targets-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::after { animation: none !important; transition: none !important; } }
