:root {
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #f0f2f8; --border: #e2e5ee;
  --text: #1b1f2a; --muted: #667085; --primary: #4f46e5; --primary-ink: #ffffff; --primary-soft: #eef0ff;
  --ok: #12b76a; --ok-soft: #e7f8ef; --warn: #f79009; --warn-soft: #fff4e5; --err: #d92d20; --err-soft: #fdecea;
  --info: #2e90fa; --info-soft: #e8f2ff; --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1218; --surface: #171b24; --surface-2: #1f2430; --border: #2a3040; --text: #e7e9ef; --muted: #98a2b3;
    --primary: #8b85ff; --primary-ink: #0f1218; --primary-soft: #252650; --ok-soft: #12301f; --warn-soft: #3a2a10;
    --err-soft: #3a1714; --info-soft: #132a45; --shadow: none; }
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Vazirmatn", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.65; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); } .small { font-size: .86rem; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .inner { max-width: 1240px; margin: 0 auto; padding: .6rem 16px; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.1rem; color: var(--text); }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a { padding: .35rem .7rem; border-radius: 8px; color: var(--muted); }
.nav a.active, .nav a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.top-right { display: flex; gap: .6rem; align-items: center; }
.container { max-width: 1240px; margin: 0 auto; padding: 20px 16px 60px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.layout-step { display: grid; grid-template-columns: 290px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .layout-step { grid-template-columns: 1fr; } .sidebar { order: 2; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card h2 { display: flex; align-items: center; gap: .5rem; }
.banner { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 16px; }
.banner.warn { background: var(--warn-soft); } .banner.err { background: var(--err-soft); } .banner.info { background: var(--info-soft); } .banner.ok { background: var(--ok-soft); }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: .55rem 1rem; border-radius: 10px; cursor: pointer; font: inherit; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.sm { padding: .3rem .65rem; font-size: .86rem; }
.btn.danger { color: var(--err); }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
label.f { display: block; font-weight: 600; margin-bottom: .35rem; }
.field { margin-bottom: 1.1rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; }
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
.req { color: var(--err); }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip input { display: none; }
.chip span { display: inline-block; padding: .35rem .8rem; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; background: var(--surface); }
.chip input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.scale { display: flex; gap: .4rem; }
.scale label span { display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.scale input { display: none; }
.scale input:checked + span { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.check-item { display: flex; gap: .7rem; align-items: flex-start; padding: .65rem .3rem; border-bottom: 1px dashed var(--border); }
.check-item input { width: 20px; height: 20px; margin-top: .2rem; accent-color: var(--ok); }

/* status pills */
.pill { display: inline-block; padding: .1rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.review { background: var(--warn-soft); color: var(--warn); }
.pill.running { background: var(--info-soft); color: var(--info); }
.pill.in_progress, .pill.active, .pill.available { background: var(--primary-soft); color: var(--primary); }
.pill.locked, .pill.skipped { background: var(--surface-2); color: var(--muted); }

/* progress */
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--ok)); border-radius: 999px; }
.ring { --p: 0; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring > div { width: 104px; height: 104px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 1.7rem; font-weight: 800; }
.hero { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }

/* journey map */
.journey { list-style: none; margin: 0; padding: 0; }
.stage { position: relative; padding-inline-start: 46px; padding-bottom: 18px; }
.stage::before { content: ""; position: absolute; inset-inline-start: 17px; top: 36px; bottom: 0; width: 2px; background: var(--border); }
.stage:last-child::before { display: none; }
.stage .dot { position: absolute; inset-inline-start: 0; top: 0; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); border: 2px solid var(--border); font-size: 1rem; }
.stage.done .dot { background: var(--ok-soft); border-color: var(--ok); }
.stage.active .dot, .stage.available .dot { border-color: var(--primary); background: var(--primary-soft); }
.stage.skipped { opacity: .55; }
.stage-head { display: flex; justify-content: space-between; gap: .8rem; align-items: center; flex-wrap: wrap; }
.stage-steps { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .3rem; }
.stage-steps li a, .stage-steps li span.lk { display: flex; justify-content: space-between; gap: .6rem; padding: .4rem .6rem; border-radius: 8px; color: var(--text); }
.stage-steps li a:hover { background: var(--surface-2); text-decoration: none; }
.stage-steps li.current a { background: var(--primary-soft); outline: 1px solid var(--primary); }
.stage-steps li span.lk { color: var(--muted); }
.here { color: var(--primary); font-weight: 700; font-size: .8rem; }

/* sidebar mini journey */
.mini a { display: flex; justify-content: space-between; gap: .4rem; padding: .3rem .5rem; border-radius: 8px; color: var(--text); font-size: .9rem; }
.mini a.cur { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.mini .st { margin-top: .7rem; font-weight: 700; font-size: .85rem; color: var(--muted); }

/* kpi cards */
.kpi { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.kpi .v { font-size: 1.5rem; font-weight: 800; }
.kpi .rows { display: grid; gap: .15rem; font-size: .84rem; margin-top: .4rem; }
.kpi .rows div { display: flex; justify-content: space-between; gap: .5rem; }
.up { color: var(--ok); } .down { color: var(--err); }

/* tables & markdown */
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align: start; vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; font-size: .9rem; }
.table-wrap { overflow-x: auto; }
.md { overflow-wrap: anywhere; }
.md table { display: block; overflow-x: auto; margin: .8rem 0; }
.md h1 { font-size: 1.35rem; } .md h2 { font-size: 1.18rem; margin-top: 1.4rem; } .md h3 { font-size: 1.02rem; margin-top: 1.1rem; }
.md blockquote { margin: .8rem 0; padding: .5rem 1rem; border-inline-start: 4px solid var(--warn); background: var(--warn-soft); border-radius: 6px; }
.md code { background: var(--surface-2); padding: .1rem .3rem; border-radius: 4px; }

/* charts & shots */
.chart-box { position: relative; height: 320px; }
.palette { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 120px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-size: .8rem; }
.swatch i { display: block; height: 70px; }
.swatch div { padding: .4rem; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.shot { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.shot img { width: 100%; height: 160px; object-fit: cover; object-position: top; display: block; background: var(--surface-2); }
.shot .cap { padding: .45rem .6rem; font-size: .8rem; display: flex; justify-content: space-between; gap: .4rem; align-items: center; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .35rem 0; border-bottom: 1px dashed var(--border); font-size: .88rem; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--info-soft); border-top-color: var(--info); border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth { max-width: 420px; margin: 8vh auto; }

@media print {
  .topbar, .no-print, .actions { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; break-inside: avoid; }
  .page-break { break-before: page; }
  .chart-box { height: 260px; }
}
