/* پناه · استایل موبایل‌محور
   پایه = موبایل (۳۶۰px). با min-width برای صفحه‌های بزرگ‌تر گسترش می‌یابد. */

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

:root {
  --bg: #f3f6f4; --bg2: #eef4f1;
  --card: #ffffff; --ink: #1d2a27; --muted: #6f7f7a; --line: #e6ece9; --field: #f6f9f7;
  --accent: #0e9a80; --accent-strong: #0b7d68; --accent-ink: #ffffff; --accent-soft: #e2f5ef;
  --warn: #b4690e; --warn-soft: #fcf1dc; --bad: #c0392b; --bad-soft: #fdebe8;
  --good: #1d8a4a; --good-soft: #e3f5e9; --info: #5b4bc4; --info-soft: #eeebfb;
  --radius: 20px; --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(20,40,35,.04), 0 6px 20px rgba(20,40,35,.05);
  --gutter: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101614; --bg2: #121a17;
    --card: #19211e; --ink: #e8efec; --muted: #94a59f; --line: #26312d; --field: #141b18;
    --accent: #3fd0b0; --accent-strong: #5fe0c3; --accent-ink: #06201a; --accent-soft: #17352e;
    --warn: #f0b252; --warn-soft: #382c16; --bad: #f08a80; --bad-soft: #3b201d;
    --good: #6fd08a; --good-soft: #17301f; --info: #b3a8f5; --info-soft: #25213f;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); line-height: 1.8; font-weight: 400;
  font-family: Vazirmatn, "Vazir", Tahoma, system-ui, sans-serif;
  background: linear-gradient(180deg, var(--bg2), var(--bg) 320px) fixed, var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 700; line-height: 1.5; letter-spacing: 0; }
h1 { font-size: 1.35rem; margin: 0 0 .3rem; }
h2 { font-size: 1.02rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: 0 0 .25rem; font-weight: 600; }
p { margin: .25rem 0 .7rem; }
ul, ol { margin: .3rem 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1 1 14rem; min-width: 0; }
.narrow { max-width: 46rem; margin-inline: auto; }

/* ---------- هدر ---------- */
.topbar { background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-in { max-width: 1360px; margin: 0 auto; padding: .45rem var(--gutter); display: flex; flex-wrap: wrap; gap: .35rem .6rem; align-items: center; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--accent-strong); white-space: nowrap; }
.brand small { display: none; font-weight: 400; color: var(--muted); font-size: .7rem; margin-inline-start: .4rem; }
.userbox { display: flex; gap: .4rem; align-items: center; font-size: .78rem; margin-inline-start: auto; min-width: 0; }
.userbox > a { color: var(--muted); max-width: 7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox form { margin: 0; }
.userbox select { max-width: 8rem; padding: .2rem .5rem; font-size: .78rem; }

/* منوی مراحل: چیپ‌های ریز که مثل یک تایم‌لاین پیوسته به هم وصل‌اند */
.nav { order: 3; flex: 1 0 100%; display: flex; align-items: center; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: .25rem 0 .15rem; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); scroll-padding-inline: 2rem; }
.nav::-webkit-scrollbar { display: none; }
.nav a { flex: none; position: relative; padding: 0 .6rem; border-radius: 999px; color: var(--muted); font-size: .72rem; line-height: 1.6rem; white-space: nowrap; background: var(--field); border: 1px solid var(--line); }
.nav a + a { margin-inline-start: .7rem; }
.nav a + a::before { content: ""; position: absolute; inset-inline-end: 100%; top: 50%; width: .7rem; height: 2px; background: var(--line); transform: translateY(-50%); }
.nav a:hover { background: var(--accent-soft); color: var(--accent-strong); text-decoration: none; }
.nav a:has(~ a.on) { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.nav a:has(~ a.on)::before, .nav a.on::before { background: var(--accent); }
.nav a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.nav a.on:hover { color: var(--accent-ink); }
.badge { display: inline-block; min-width: 1.05rem; padding: 0 .3rem; border-radius: 999px; background: var(--warn); color: #fff; font-size: .62rem; line-height: 1.05rem; text-align: center; margin-inline-start: .25rem; }

.container { max-width: 1120px; margin: 0 auto; padding: 1rem var(--gutter) 4rem; }

/* ---------- کارت‌ها ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: .9rem; }
.card > h2:first-child, .card > .row:first-child > h2:first-child { display: flex; align-items: center; gap: .5rem; }
.card > h2:first-child::before, .card > .row:first-child > h2:first-child::before { content: ""; width: 4px; height: 1.05em; border-radius: 4px; background: var(--accent); flex: none; }
.card.soft { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.card.warn { background: var(--warn-soft); border-color: transparent; box-shadow: none; }
.card.bad { background: var(--bad-soft); border-color: transparent; box-shadow: none; }
.card.info { background: var(--info-soft); border-color: transparent; box-shadow: none; }
a.card { display: block; color: inherit; }
a.card:hover { text-decoration: none; border-color: var(--accent); }
.grid { display: grid; gap: .75rem; grid-template-columns: minmax(0, 1fr); }
.grid > .card { margin-bottom: 0; }
.grid.mb { margin-bottom: .9rem; }
.g2, .g3, .g-main { grid-template-columns: minmax(0, 1fr); }
.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.g4 > .card { padding: .75rem .85rem; }
@media (min-width: 560px) { .g2, .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 820px) { .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g-main { grid-template-columns: 2fr 1fr; gap: 1rem; } }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }

/* ---------- دکمه‌ها ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-height: 2.5rem; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); padding: .3rem 1.1rem; border-radius: 999px; cursor: pointer; font: inherit; font-size: .88rem; font-weight: 600; line-height: 1.4; transition: filter .15s, background .15s; }
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-strong); filter: none; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.danger { background: var(--card); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); box-shadow: none; }
.btn.sm { min-height: 2rem; padding: .1rem .8rem; font-size: .78rem; }
.inline { display: inline; margin: 0; }
.row > .btn { flex: 0 0 auto; }

/* ---------- فرم ---------- */
.input, select.input, textarea.input { width: 100%; min-height: 2.75rem; padding: .5rem .85rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--field); color: var(--ink); font: inherit; font-size: 1rem; /* ۱۶px؛ جلوی زوم خودکار iOS */ }
textarea.input { min-height: 5rem; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; background: var(--card); }
.input::placeholder { color: var(--muted); opacity: .8; }
.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 600; font-size: .84rem; margin-bottom: .25rem; }
.help { color: var(--muted); font-size: .78rem; margin-top: .2rem; }
.errorlist { list-style: none; margin: .2rem 0; padding: 0; color: var(--bad); font-size: .82rem; }
.check { width: 1.15rem; height: 1.15rem; vertical-align: middle; margin-inline-end: .3rem; accent-color: var(--accent); }
.radios { display: grid; gap: .5rem; grid-template-columns: minmax(0, 1fr); list-style: none; padding: 0; margin: 0; }
.radios ul { list-style: none; padding: 0; margin: 0; }
.radios li { margin: 0; }
.radios label { display: block; border: 1px solid var(--line); background: var(--field); border-radius: var(--radius-sm); padding: .6rem .8rem; cursor: pointer; font-weight: 500; font-size: .9rem; }
.radios label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
@media (min-width: 520px) { .radios { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.msgs { list-style: none; margin: 0 0 .9rem; padding: 0; }
.msgs li { padding: .6rem .9rem; border-radius: var(--radius-sm); margin-bottom: .4rem; background: var(--info-soft); color: var(--info); font-size: .9rem; }
.msgs li.success { background: var(--good-soft); color: var(--good); }
.msgs li.error { background: var(--bad-soft); color: var(--bad); }
.msgs li.warning { background: var(--warn-soft); color: var(--warn); }

/* ---------- چیپ و نوار ---------- */
.tag { display: inline-flex; align-items: center; gap: .3rem; padding: 0 .6rem; border-radius: 999px; font-size: .72rem; line-height: 1.6rem; background: var(--field); color: var(--ink); border: 1px solid var(--line); white-space: nowrap; }
.tag.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.tag.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tag.accent { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.bar { height: .5rem; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); border-radius: 999px; }
.bar.warn > i { background: var(--warn); }

.stat { text-align: center; }
.stat b { display: block; font-size: 1.7rem; line-height: 1.3; color: var(--accent-strong); font-weight: 700; }
.stat span { color: var(--muted); font-size: .8rem; }

.pipeline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.pipeline .step { text-align: center; padding: .7rem .4rem; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); font-size: .8rem; }
.pipeline .step:hover { text-decoration: none; filter: brightness(.98); }
.pipeline .step b { display: block; font-size: 1.5rem; line-height: 1.4; color: var(--accent-strong); }
.pipeline .arrow { display: none; }
@media (min-width: 720px) { .pipeline { display: flex; align-items: stretch; gap: .4rem; } .pipeline .step { flex: 1; } .pipeline .arrow { display: block; align-self: center; color: var(--muted); } }

.weeks { display: flex; gap: .3rem; flex-wrap: wrap; }
.wk { width: 1.9rem; height: 1.9rem; border-radius: 10px; background: var(--line); display: grid; place-items: center; font-size: .75rem; color: var(--muted); }
.wk.full { background: var(--accent); color: var(--accent-ink); }
.wk.rescue { background: var(--accent-soft); color: var(--accent-strong); border: 1px dashed var(--accent); }
.wk.freeze { background: var(--info-soft); color: var(--info); }
.wk.missed { background: var(--bad-soft); color: var(--bad); }
.wk.current { border: 2px solid var(--accent); background: transparent; }
.wk.before { opacity: .35; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: .65rem 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.crit { display: flex; gap: .5rem; align-items: flex-start; }
.crit.done .t { text-decoration: line-through; color: var(--muted); }
pre.sop { white-space: pre-wrap; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .8rem; font: inherit; font-size: .9rem; }
.quote { border-inline-start: 3px solid var(--accent); padding-inline-start: .8rem; color: var(--muted); }
.sparkbars { display: flex; align-items: flex-end; gap: .35rem; height: 6rem; padding-top: 1.4rem; }
.sparkbars div { flex: 1; background: var(--accent); border-radius: 8px 8px 0 0; min-height: 3px; position: relative; }
.sparkbars small { position: absolute; top: -1.3rem; width: 100%; text-align: center; color: var(--muted); font-size: .7rem; }
.login-box { max-width: 26rem; margin: 1.5rem auto; padding: 1.3rem; }

/* ---------- زبانه‌های صندوق و جایگاه مطالب ---------- */
.tabs { display: flex; gap: .4rem; margin: .5rem 0 .9rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; display: inline-flex; align-items: center; gap: .4rem; padding: 0 .9rem; line-height: 2.1rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: .85rem; font-weight: 500; }
.tabs a:hover { text-decoration: none; border-color: var(--accent); }
.tabs a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.tabs .count { min-width: 1.3rem; padding: 0 .35rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: .72rem; line-height: 1.3rem; text-align: center; }
.tabs a.on .count { background: rgba(255,255,255,.25); color: inherit; }
.shelf-card h3 { margin: 0; }
.shelf-card ul { margin: .5rem 0 .4rem; padding-inline-start: 1.1rem; color: var(--muted); font-size: .84rem; }
.shelf-card .more { color: var(--accent-strong); font-weight: 600; }

/* ---------- بازشوی تقویم شمسی ---------- */
input[data-jdate] { text-align: right; direction: ltr; unicode-bidi: plaintext; letter-spacing: .02em; background-image: none; }
.jd-pop { position: absolute; z-index: 50; width: 18.5rem; max-width: calc(100vw - 16px); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(10,30,25,.22); padding: .7rem; font-size: .9rem; }
.jd-pop.sheet { position: fixed; inset: auto 0 0 0; width: auto; max-width: none; border-radius: 22px 22px 0 0; padding: 1rem var(--gutter) calc(1rem + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(10,30,25,.25); }
.jd-head { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-bottom: .5rem; }
.jd-title { display: flex; gap: .3rem; flex: 1; justify-content: center; }
.jd-title select { appearance: none; -webkit-appearance: none; border: 1px solid var(--line); background: var(--field); color: var(--ink); border-radius: 999px; padding: .15rem .7rem; font: inherit; font-weight: 600; font-size: .88rem; text-align: center; }
.jd-nav { width: 2.1rem; height: 2.1rem; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 50%; font-size: 1.2rem; line-height: 1; cursor: pointer; }
.jd-nav:hover { border-color: var(--accent); color: var(--accent-strong); }
.jd-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.jd-wd { font-size: .72rem; color: var(--muted); padding: .2rem 0; }
.jd-day { border: 0; background: transparent; color: var(--ink); height: 2.3rem; border-radius: 50%; font: inherit; font-size: .88rem; cursor: pointer; }
.jd-day:hover { background: var(--accent-soft); }
.jd-day.fri { color: var(--bad); }
.jd-day.today { box-shadow: 0 0 0 1.5px var(--accent) inset; }
.jd-day.on { background: var(--accent); color: var(--accent-ink); }
.jd-foot { display: flex; justify-content: space-between; margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.jd-foot button { border: 0; background: none; color: var(--accent-strong); font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; padding: .2rem .5rem; }

/* ---------- جدول‌ها ---------- */
table.t { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.t th, table.t td { text-align: start; padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; font-size: .76rem; }
.scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); -webkit-overflow-scrolling: touch; }
.scroll table.t { min-width: 30rem; }
.scroll table.t td.n { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--accent-strong); font-weight: 700; }
.scroll table.t td.q { color: var(--warn); font-weight: 700; white-space: nowrap; }

/* روی موبایل، هر ردیف جدول یک کارت کوچک می‌شود (برچسب‌ها با JS از سرستون می‌آیند) */
@media (max-width: 639px) {
  :not(.scroll) > table.t, :not(.scroll) > table.t tbody { display: block; }
  :not(.scroll) > table.t tr, :not(.scroll) > table.t tbody > tr { display: block; padding: .55rem 0; border-bottom: 1px solid var(--line); }
  :not(.scroll) > table.t tr:last-child { border-bottom: 0; }
  :not(.scroll) > table.t tr:has(th):not(:has(td)) { display: none; }
  :not(.scroll) > table.t td, :not(.scroll) > table.t th { display: flex; justify-content: space-between; gap: .8rem; padding: .15rem 0; border: 0; width: auto !important; }
  :not(.scroll) > table.t td::before { content: attr(data-label); color: var(--muted); font-size: .74rem; flex: none; }
  :not(.scroll) > table.t td[data-label=""]::before { display: none; }
  :not(.scroll) > table.t td:first-child[data-label] { display: block; font-weight: 600; font-size: .95rem; padding-bottom: .3rem; }
  :not(.scroll) > table.t td:first-child[data-label]::before { display: none; }
  :not(.scroll) > table.t td[data-label]:not(:first-child) { align-items: center; }
}

/* ---------- راهنما ---------- */
.guide { max-width: 46rem; margin-inline: auto; display: grid; gap: 1.8rem; }
.help-head h1 { font-size: 1.6rem; color: var(--accent-strong); }
.seg { display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; margin-top: .8rem; }
@media (min-width: 560px) { .seg { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.seg a { display: block; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg a b { display: block; font-size: .95rem; }
.seg a span { font-size: .8rem; color: var(--muted); }
.seg a.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1.5px var(--accent) inset; }
.seg a:hover { text-decoration: none; border-color: var(--accent); }
.guide section { display: grid; gap: .8rem; scroll-margin-top: 6.5rem; }
.guide section > h2 { font-size: 1.15rem; color: var(--accent-strong); margin: 0; }
.guide section > h2::before { display: none; }
.guide .lead { font-size: 1.02rem; font-weight: 500; }
.guide p { margin: 0; }
.toc { display: flex; flex-wrap: wrap; gap: .4rem; }
.toc a { font-size: .78rem; padding: 0 .75rem; line-height: 1.8rem; border: 1px solid var(--line); background: var(--card); border-radius: 999px; color: var(--muted); }
.toc a:hover { border-color: var(--accent); color: var(--accent-strong); text-decoration: none; }
.hflow { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; counter-reset: s; }
.hflow li { counter-increment: s; display: grid; grid-template-columns: 2.1rem 1fr; gap: .7rem; align-items: start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; box-shadow: var(--shadow); }
.hflow li::before { content: counter(s, persian); display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: .9rem; }
.hflow b { display: block; font-size: .95rem; }
.hflow span { color: var(--muted); font-size: .86rem; }
.example { background: var(--accent-soft); border-radius: var(--radius); padding: .9rem 1rem; display: grid; gap: .3rem; }
.example h3 { font-size: .92rem; color: var(--accent-strong); }
.example ul { margin: 0; padding-inline-start: 1.1rem; display: grid; gap: .25rem; font-size: .9rem; }
.callout { background: var(--warn-soft); border-radius: var(--radius); padding: .8rem 1rem; font-size: .9rem; }
.callout b { color: var(--warn); }
.hsteps { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; counter-reset: t; }
.hsteps li { counter-increment: t; display: grid; grid-template-columns: 1.6rem 1fr; gap: .5rem; align-items: start; font-size: .92rem; }
.hsteps li::before { content: counter(t, persian) "."; color: var(--accent-strong); font-weight: 700; }
.qa { display: grid; gap: .9rem; }
.qa h3 { font-size: .95rem; }
.qa p { color: var(--muted); font-size: .9rem; }
.guide .grid .card h3 { font-size: .95rem; }

/* ---------- صفحه‌های بزرگ‌تر ---------- */
@media (min-width: 640px) {
  :root { --gutter: 20px; }
  html { font-size: 15.5px; }
  .brand small { display: inline; }
  .card { padding: 1.2rem 1.3rem; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.08rem; }
  table.t { font-size: .9rem; }
}
@media (min-width: 1024px) {
  .topbar-in { flex-wrap: nowrap; }
  .nav { order: 0; flex: 1 1 auto; min-width: 0; margin-inline: 0; padding-inline: 0; }
  .userbox { margin-inline-start: 0; font-size: .82rem; }
  .userbox > a { max-width: 10rem; }
  .container { padding-top: 1.5rem; }
}
@media (max-width: 1359px) and (min-width: 640px) { .brand small { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
