/* IRANSansX (licensed from fontiran.com) — files in public/fonts/iransans/.
   Regular covers weights 300–500 and Bold covers 600–900. If the files are missing, Vazirmatn is used. */
@font-face {
  font-family: 'IRANSans';
  src: url('/static/fonts/iransans/iransans-regular.woff2') format('woff2'), url('/static/fonts/iransans/iransans-regular.woff') format('woff');
  font-weight: 300 500;
  font-display: swap;
}
@font-face {
  font-family: 'IRANSans';
  src: url('/static/fonts/iransans/iransans-bold.woff2') format('woff2'), url('/static/fonts/iransans/iransans-bold.woff') format('woff');
  font-weight: 600 900;
  font-display: swap;
}

@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-display: swap;
}

:root {
  --ink: #15261d;
  --text: #26352c;
  --muted: #5d6b62;
  --line: #dde6e0;
  --bg: #f4f6f2;
  --surface: #ffffff;
  --soft: #eef3ee;
  --brand: #1f7a43;
  --brand-dark: #145a30;
  --brand-soft: #e4f2e8;
  --accent: #b9722a;
  --stage: #0f2419;
  --stage-2: #1a3d2a;
  --stage-text: #e9f1ec;
  --ok: #2e7d4f;
  --warn: #a86a12;
  --err: #b3362f;
  --radius: 10px;
  --lime: #a9c83b;
  --shadow: 0 1px 2px rgba(16, 32, 43, .06), 0 4px 16px rgba(16, 32, 43, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'IRANSans', 'Vazirmatn', Tahoma, sans-serif; font-size: 16px; line-height: 1.8;
  font-feature-settings: "ss01";
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.45; margin: 0 0 .5em; }
h2 { font-size: 1.25rem; }
button, input, select, textarea { font: inherit; color: inherit; }
code { background: var(--soft); padding: 0 .35em; border-radius: 4px; font-size: .9em; }
[dir="ltr"], .ltr { direction: ltr; unicode-bidi: isolate; font-family: "Segoe UI", Tahoma, Arial, sans-serif; font-feature-settings: normal; }
.skip { position: absolute; right: 8px; top: -60px; background: #fff; padding: 8px; z-index: 99; }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 2px; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.wrap.narrow { max-width: 960px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; margin: .25em 0 .75em; }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 8px;
  padding: .5em 1.1em; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-small { padding: .25em .8em; font-size: .9rem; }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-dark { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: var(--stage-text); font-weight: 500; }
.btn-dark:hover { background: rgba(255,255,255,.16); }
.btn-dark.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--err); border-color: var(--err); }
.btn.full { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger { color: var(--err); }

/* ---------- header ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none !important; }
.brand strong { display: block; font-size: 1.15rem; line-height: 1.2; }
.brand small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.3; }
.topsearch { flex: 1; display: flex; max-width: 560px; margin-inline-start: auto; }
.topsearch input { flex: 1; border: 1px solid var(--line); border-inline-end: 0; border-radius: 0 8px 8px 0; padding: .45em .9em; background: var(--bg); min-width: 0; }
.topsearch button { border: 1px solid var(--brand); background: var(--brand); color: #fff; border-radius: 8px 0 0 8px; padding: 0 .9em; cursor: pointer; display: grid; place-items: center; }
.usernav { display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.usernav form { margin: 0; }
.mainnav { background: var(--brand); }
.mainnav .wrap { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.mainnav a { color: #fff; padding: .7em 1em; font-weight: 500; white-space: nowrap; opacity: .92; }
.mainnav a:hover, .mainnav a.on { background: rgba(255,255,255,.12); text-decoration: none; opacity: 1; }

/* ---------- home ---------- */
.hero { background: linear-gradient(160deg, var(--stage) 0%, var(--stage-2) 100%); color: var(--stage-text); padding: 56px 0; }
.hero-inner { display: grid; grid-template-columns: 1fr auto; gap: 48px; align-items: center; }
.hero h1 { color: #fff; font-size: clamp(1.6rem, 3.4vw, 2.4rem); font-weight: 800; }
.hero p { color: #c6d8cc; max-width: 640px; }
.hero-note { font-size: .88rem; }
.hero-search { display: flex; gap: 8px; max-width: 620px; margin: 20px 0 8px; }
.hero-search input { flex: 1; border: 0; border-radius: 8px; padding: .75em 1em; min-width: 0; color: var(--text); background: #fff; }
.hero-search.big input { border: 1px solid var(--line); }
.hero-search .btn { background: var(--accent); border-color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, auto)); gap: 12px; margin: 0; }
.stats div { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius); padding: 14px 22px; text-align: center; }
.stats dt { font-size: .85rem; color: #a9c2b1; }
.stats dd { margin: 0; font-size: 1.9rem; font-weight: 800; color: #fff; line-height: 1.3; }
.stats.light { grid-template-columns: repeat(4, 1fr); margin: 16px 0 24px; }
.stats.light div { background: var(--surface); border-color: var(--line); }
.stats.light dt { color: var(--muted); }
.stats.light dd { color: var(--ink); }
.section { margin: 40px 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--brand-soft); color: var(--brand-dark); border: 1px solid transparent; border-radius: 999px; padding: .2em .9em; font-size: .9rem; cursor: pointer; }
.chip small { color: var(--muted); }
.chip:hover { text-decoration: none; border-color: var(--brand); }
.chip.plain { background: var(--soft); color: var(--text); cursor: default; }
.chip.plain:hover { border-color: transparent; }
.chip.on { background: var(--brand); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.card { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); color: var(--text); text-decoration: none !important; transition: transform .15s; }
.card:hover { transform: translateY(-2px); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--stage); display: block; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.dur { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.72); color: #fff; font-size: .78rem; padding: 0 6px; border-radius: 4px; direction: ltr; }
.progress { position: absolute; inset: auto 0 0 0; height: 4px; background: rgba(255,255,255,.3); }
.progress i { display: block; height: 100%; background: var(--accent); }
.card-body { padding: 10px 14px 14px; display: block; }
.card-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 600; color: var(--ink); line-height: 1.6; }
.card-meta { display: block; color: var(--muted); font-size: .85rem; margin-top: 4px; }

/* ---------- browse ---------- */
.crumbs { font-size: .9rem; color: var(--muted); margin: 18px 0 10px; }
.page-title { font-size: 1.6rem; margin: 8px 0 6px; }
.eyebrow { color: var(--accent); font-weight: 600; margin: 18px 0 0; font-size: .9rem; }
.lead { color: var(--muted); margin: 0 0 20px; }
.count { color: var(--muted); font-size: .9rem; }
.browse { display: grid; grid-template-columns: 230px 1fr; gap: 24px; margin-bottom: 48px; align-items: start; }
.browse-side { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); position: sticky; top: 130px; }
.side-head { background: var(--brand); color: #fff; padding: .7em 1.2em; font-weight: 600; }
.browse-side a { display: block; padding: .6em 1.2em; border-bottom: 1px solid var(--line); }
.browse-side a.on { background: var(--soft); color: var(--ink); font-weight: 600; border-inline-start: 4px solid var(--accent); }
.browse-main { min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 16px; background: var(--surface); padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow); flex-wrap: wrap; }
.letters { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
.letters a { min-width: 30px; text-align: center; padding: 0 6px; border-radius: 6px; font-weight: 500; }
.letters a.on { background: var(--brand); color: #fff; text-decoration: none; }
.per select { border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; margin-inline-start: 6px; background: #fff; }
.row { display: grid; grid-template-columns: 220px 1fr; gap: 18px; background: var(--surface); border-radius: var(--radius); padding: 14px; margin: 12px 0; box-shadow: var(--shadow); }
.row-thumb { position: relative; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--stage); align-self: start; }
.row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-body { min-width: 0; }
.row h3 { font-size: 1.1rem; margin: 0; }
.row .en { color: var(--muted); font-size: .85rem; margin: 0; text-align: right; }
.row .people { margin: 2px 0 6px; }
.row .snippet { font-size: .92rem; color: var(--text); background: var(--soft); border-radius: 6px; padding: 6px 10px; }
mark { background: #fbe3b8; color: inherit; padding: 0 2px; border-radius: 3px; }
.row-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.abstract { flex-basis: 100%; order: 3; }
.abstract summary { display: inline-flex; cursor: pointer; background: var(--soft); border-radius: 999px; padding: .2em .9em; font-size: .9rem; list-style: none; }
.abstract summary::before { content: '◂'; margin-inline-end: 6px; transition: transform .2s; }
.abstract[open] summary::before { transform: rotate(-90deg); }
.abstract p { margin: 8px 0 0; color: var(--text); font-size: .95rem; }
.row-actions > .abstract { order: 0; flex-basis: auto; }
.row-actions > .abstract[open] { flex-basis: 100%; }
.badge { font-size: .78rem; background: #fdf1e3; color: #8a531d; border-radius: 999px; padding: .15em .8em; }
.hits { margin: -6px 0 14px; padding: 6px 14px; display: flex; gap: 10px; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.hits a { direction: ltr; }
.pager { display: flex; justify-content: center; gap: 20px; margin: 24px 0; }
.groups { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.groups a { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); padding: .75em 1em; border-radius: 8px; box-shadow: var(--shadow); color: var(--ink); }
.groups b { background: var(--brand-soft); color: var(--brand-dark); border-radius: 999px; min-width: 28px; text-align: center; font-size: .85rem; padding: 0 8px; }
.groups small { color: var(--muted); }

/* ---------- video page ---------- */
.stage { background: var(--stage); color: var(--stage-text); padding: 24px 0 28px; }
.stage-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 0; border-radius: var(--radius); overflow: hidden; background: #000; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.stage-grid.no-side { grid-template-columns: 1fr; }
.player-col { background: #000; min-width: 0; display: flex; flex-direction: column; }
.player { display: flex; flex-direction: column; height: 100%; }
.player video { width: 100%; aspect-ratio: 16/9; background: #000; display: block; flex: 1; }
video::cue { font-family: 'IRANSans', 'Vazirmatn', Tahoma, sans-serif; font-size: 1.05em; line-height: 1.6; background: rgba(0,0,0,.72); color: #fff; }
.player-bar { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 8px 14px; background: #0a1a11; font-size: .88rem; color: #b8cabe; }
.speed { display: flex; align-items: center; gap: 4px; }
.speed button { background: transparent; border: 1px solid rgba(255,255,255,.15); color: #cfdbe3; border-radius: 6px; padding: 0 8px; cursor: pointer; font-size: .82rem; }
.speed button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.quality select { background: #13301f; color: #fff; border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: 0 6px; margin-inline-start: 6px; }
.subtoggle, .quality label { flex-direction: row; font-weight: 400; font-size: inherit; }
.subtoggle { display: flex; align-items: center; gap: 6px; cursor: pointer; margin-inline-start: auto; }
.locked { position: relative; aspect-ratio: 16/9; background: #000; }
.locked img { width: 100%; height: 100%; object-fit: cover; opacity: .35; }
.locked-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; gap: 6px; }
.locked-msg strong { font-size: 1.2rem; color: #fff; }
.locked-msg p { color: #c5d3dc; margin: 0; }
.locked-msg .btns { display: flex; gap: 10px; margin-top: 10px; }
.locked-msg .btn-ghost { color: #fff; border-color: rgba(255,255,255,.5); }
.locked-msg .btn-ghost:hover { background: rgba(255,255,255,.1); }

.side-panel { background: #fff; color: var(--text); display: flex; flex-direction: column; min-height: 0; max-height: 100%; position: relative; }
.stage-grid:not(.no-side) .side-panel { height: 0; min-height: 100%; }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab { flex: 1; background: none; border: 0; border-bottom: 3px solid transparent; padding: .7em .5em; cursor: pointer; font-weight: 600; color: var(--muted); }
.tab.on { color: var(--ink); border-bottom-color: var(--brand); }
.tab.icon { flex: none; width: 46px; color: var(--brand); font-size: 1.1rem; }
.tab.icon.off { color: #b6bfc6; }
.tabpane { display: none; flex: 1; min-height: 0; flex-direction: column; }
.tabpane.on { display: flex; }
.tsearch { display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); flex: none; }
.tsearch input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: .25em .7em; font-size: .9rem; background: var(--bg); }
.tcount { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.langpick select { border: 1px solid var(--line); border-radius: 6px; font-size: .85rem; padding: 2px 4px; background: #fff; }
.transcript { position: relative; overflow-y: auto; padding: 6px 16px 40px; flex: 1; font-size: .93rem; line-height: 1.95; overscroll-behavior: contain; }
.tseg { font-size: .9rem; color: var(--brand-dark); background: var(--brand-soft); padding: 4px 10px; border-radius: 6px; margin: 14px 0 6px; }
.para { margin: 10px 0 14px; }
.para-head { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.ts { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font-weight: 700; direction: ltr; }
.spk { font-weight: 700; color: var(--ink); }
.para p { margin: 2px 0 0; }
.cue { cursor: pointer; border-radius: 3px; transition: background .15s; }
.cue:hover { background: var(--soft); }
.cue.hit { background: #fbe3b8; }
.cue.on { background: var(--brand); color: #fff; box-shadow: 0 0 0 2px var(--brand); }
.segments { list-style: none; margin: 0; padding: 6px 0; overflow-y: auto; flex: 1; }
.seg { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; width: 100%; text-align: right; background: none; border: 0; border-bottom: 1px solid var(--line); padding: .7em 1em; cursor: pointer; }
.seg:hover { background: var(--soft); }
.seg.on { background: var(--brand-soft); }
.seg .n { background: var(--brand); color: #fff; border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; font-size: .8rem; }
.seg time { color: var(--muted); font-size: .85rem; direction: ltr; }

.stage-meta { padding-top: 18px; }
.stage-meta h1 { color: #fff; font-size: clamp(1.25rem, 2.4vw, 1.7rem); margin-bottom: 0; }
.stage-meta .en { color: #9fb8a7; margin: 0; font-size: .9rem; text-align: right; }
.stage-meta .people a { color: #b7de7a; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.video-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; padding-top: 28px; padding-bottom: 56px; align-items: start; }
.box-section { margin-bottom: 32px; }
.box-section > h2 { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.abstract-text { text-align: justify; }
.terms { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.term-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.term-box h3 { font-size: .95rem; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 10px; }
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: 220px; gap: 14px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x mandatory; }
.rail .card { scroll-snap-align: start; }
.rail .card.current { outline: 3px solid var(--accent); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.panel > :not(.panel-title):not(.kv):not(.panel-sub) { margin-inline: 16px; }
.panel > form:last-child, .panel > p:last-child, .panel > a:last-child { margin-bottom: 16px; }
.panel-title { display: block; font-size: 1.05rem; margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: default; }
details.panel > summary.panel-title { cursor: pointer; }
.panel-sub { background: var(--soft); font-weight: 600; font-size: .9rem; padding: 6px 16px; }
.kv { display: grid; grid-template-columns: 110px 1fr; margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); padding: 7px 16px; border-bottom: 1px solid var(--line); }
.kv dd { margin: 0; padding: 7px 0 7px 16px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.orig { display: inline-block; margin-top: 12px; }

/* ---------- forms / auth ---------- */
.auth { display: grid; place-items: center; padding: 48px 20px 72px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); padding: 28px; border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 1.4rem; margin: 0; }
.auth-card .alt { text-align: center; margin: 0; font-size: .92rem; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: .92rem; }
label small { color: var(--muted); font-weight: 400; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), textarea, select { border: 1px solid #cfd7de; border-radius: 8px; padding: .5em .8em; background: #fff; font-weight: 400; width: 100%; }
textarea { resize: vertical; line-height: 1.8; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.notice { padding: 10px 14px; border-radius: 8px; font-size: .92rem; margin: 10px 0; }
.notice.ok { background: #e4f3ea; color: var(--ok); }
.notice.err { background: #fbe9e7; color: var(--err); }
.notice.warn { background: #fdf1e3; color: var(--warn); }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- admin ---------- */
.adminnav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 10px 0 18px; overflow-x: auto; }
.adminnav a { padding: .6em 1em; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.adminnav a.on { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; text-decoration: none; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 48px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: right; background: var(--soft); padding: 10px 12px; font-weight: 600; white-space: nowrap; }
.table td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.nowrap { white-space: nowrap; }
form.inline { display: inline; }
.pill { display: inline-block; border-radius: 999px; padding: 0 .8em; font-size: .8rem; white-space: nowrap; }
.pill.green { background: #e4f3ea; color: var(--ok); }
.pill.amber { background: #fdf1e3; color: var(--warn); }
.pill.red { background: #fbe9e7; color: var(--err); }
.pill.grey { background: var(--soft); color: var(--muted); }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; margin-bottom: 56px; }
.admin-form fieldset { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 18px; margin: 0 0 18px; display: flex; flex-direction: column; gap: 12px; }
.admin-form legend { font-weight: 700; color: var(--ink); padding: 0 6px; }
.narrow-form { max-width: 680px; margin-bottom: 56px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 12px; }
.admin-side .panel > .stack, .admin-side .panel > p, .admin-side .panel > .bar, .admin-side .panel > ul, .admin-side .panel > form { margin: 12px 16px; }
.media-status { font-weight: 500; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); transition: width .4s; }
.sublist { list-style: none; padding: 0; }
.sublist li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.danger-zone { border-color: #f0c9c5; }
.danger-zone form { margin: 14px 16px !important; }

/* ---------- footer / toast ---------- */
.footer { background: var(--ink); color: #b5c2cc; padding: 32px 0; font-size: .9rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 32px; flex-wrap: wrap; }
.footer strong { color: #fff; }
.footer p { max-width: 560px; margin: 6px 0 0; }
.footer nav { display: flex; gap: 18px; }
.footer a { color: #cfe8d6; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: all .25s; z-index: 50; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .stage-grid { grid-template-columns: minmax(0, 1fr); }
  .stage-grid:not(.no-side) .side-panel { height: 420px; min-height: 0; }
  .video-body { grid-template-columns: minmax(0, 1fr); }
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 20px; gap: 10px; }
  .topsearch { order: 3; flex-basis: 100%; max-width: none; }
  .usernav { margin-inline-start: auto; }
  .topbar { position: static; }
  .hero-inner { grid-template-columns: 1fr; }
  .browse { grid-template-columns: minmax(0, 1fr); }
  .browse-side { position: static; display: flex; overflow-x: auto; }
  .side-head { display: none; }
  .browse-side a { border-bottom: 0; white-space: nowrap; }
  .browse-side a.on { border-inline-start: 0; border-bottom: 3px solid var(--accent); }
  .row { grid-template-columns: minmax(0, 1fr); }
  .terms, .two { grid-template-columns: minmax(0, 1fr); }
  .locked-msg strong { font-size: 1rem; }
  .locked-msg p { font-size: .85rem; }
  .stats.light { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .wrap { padding: 0 16px; }
  .brand small { display: none; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stats div { padding: 10px; }
  .stats dd { font-size: 1.4rem; }
  .hero-search { flex-direction: column; }
  .kv { grid-template-columns: 96px 1fr; }
}

/* ================= v2: subscription, watermark, taxonomy, AI, subtitle editor ================= */
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #a9651f; }
.subbadge { background: #e4f3ea; color: var(--ok); border-radius: 999px; padding: .1em .8em; font-size: .85rem; font-weight: 600; }
.count-dot { background: var(--err); color: #fff; border-radius: 999px; padding: 0 7px; font-size: .75rem; }
.freebadge { font-size: .8rem; background: var(--ok); color: #fff; border-radius: 999px; padding: .1em .8em; vertical-align: middle; }
.badge.free { background: #e4f3ea; color: var(--ok); }
.free-tag { position: absolute; right: 8px; top: 8px; background: var(--ok); color: #fff; font-size: .75rem; padding: 0 8px; border-radius: 4px; }
.support-note { text-align: center; color: var(--muted); margin: -40px 0 40px; }
.warn-text { color: var(--warn); } .ok-text { color: var(--ok); } .err-text { color: var(--err); }

/* plans */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin: 20px 0 56px; }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.plan.featured { border: 2px solid var(--accent); position: relative; }
.plan.featured::before { content: 'به‌صرفه‌تر'; position: absolute; top: -12px; right: 20px; background: var(--accent); color: #fff; font-size: .8rem; padding: 0 10px; border-radius: 999px; }
.plan h2 { margin: 0; }
.plan .price { font-size: 2rem; font-weight: 800; color: var(--ink); line-height: 1.3; }
.plan .price small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.plan .permonth { color: var(--ok); font-size: .9rem; margin-top: -6px; }
.plan p { margin: 0; color: var(--muted); }
.feat { margin: 4px 0 8px; padding-inline-start: 1.2em; font-size: .92rem; }
.auth-card.wide { max-width: 520px; }
.paybox { background: var(--soft); border-radius: 10px; padding: 12px 16px; display: grid; gap: 6px; }
.paybox div { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.paybox span { color: var(--muted); font-size: .9rem; }
.cardno { font-size: 1.15rem; letter-spacing: 1px; }
.result-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; color: #fff; margin: 0 auto; }
.result-icon.ok { background: var(--ok); } .result-icon.err { background: var(--err); }
.subcard { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #fdf1e3; border: 1px solid #f2d3ae; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 24px; flex-wrap: wrap; }
.subcard.on { background: #e9f5ee; border-color: #bfe0cc; }
.subcard strong { display: block; } .subcard span { color: var(--muted); font-size: .92rem; }

/* home categories */
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.cat { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-inline-start: 4px solid var(--brand); color: var(--text); }
.cat:hover { text-decoration: none; border-inline-start-color: var(--accent); }
.cat strong { color: var(--ink); } .cat span { font-size: .85rem; color: var(--muted); } .cat em { font-style: normal; font-size: .8rem; color: var(--brand); }

/* watermark + fullscreen frame */
.frame { position: relative; background: #000; flex: 1; display: flex; flex-direction: column; }
.frame video { flex: 1; min-height: 0; }
.wm { position: absolute; z-index: 3; pointer-events: none; user-select: none; color: rgba(255,255,255,.42); text-shadow: 0 0 3px rgba(0,0,0,.6); font-size: clamp(11px, 1.6vw, 17px); font-weight: 600; direction: ltr; white-space: nowrap; transition: top 2.5s ease, left 2.5s ease; top: 10%; left: 10%; }
.frame:fullscreen, .frame:-webkit-full-screen { width: 100vw; height: 100vh; }
.frame:fullscreen video { width: 100%; height: 100%; aspect-ratio: auto; }
.frame.pseudo-fs { position: fixed; inset: 0; z-index: 1000; }
.frame.pseudo-fs video { width: 100%; height: 100%; aspect-ratio: auto; }
body.noscroll { overflow: hidden; }
.fsbtn { background: transparent; border: 1px solid rgba(255,255,255,.2); color: #cfdbe3; border-radius: 6px; padding: 0 10px; cursor: pointer; font-size: .82rem; }
.fsbtn:hover { background: rgba(255,255,255,.1); }

/* admin: tabs, filters, payments */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.subtabs a { padding: .25em .9em; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font-size: .9rem; }
.subtabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; text-decoration: none; }
.filterbar { display: flex; gap: 8px; max-width: 480px; margin-bottom: 14px; }
.grant { display: flex; gap: 4px; align-items: center; }
.grant input { width: 64px !important; padding: .2em .4em !important; text-align: center; }
.review { display: flex; flex-direction: column; gap: 4px; min-width: 180px; }
.review input { padding: .2em .5em !important; font-size: .85rem; }
td.small { font-size: .85rem; }
.table .btn-small { font-size: .8rem; }
.plan-admin, .tax-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin-bottom: 56px; align-items: start; }
.stack.pad { padding: 12px 16px 16px; }
.panel > .stack.pad { margin: 0 !important; }
.row-btns { display: flex; align-items: center; gap: 14px; }
.tax-item.new { border-style: dashed; }
.pl-order { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; }
.pl-order > span { font-weight: 600; }
.pl-row { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
.pl-row input { width: 48px !important; padding: .1em .3em !important; text-align: center; }
.legend-link { font-size: .8rem; font-weight: 400; margin-inline-start: 8px; }
.suggest { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.suggest .chip { font-size: .78rem; padding: 0 .7em; background: var(--soft); border: 1px solid var(--line); }
.suggest .chip:hover { border-color: var(--brand); }
.job { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 0 16px 8px; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
#jobList { margin-top: 12px; }
.aibox { border-top: 1px solid var(--line); padding-top: 12px; }
.sublist li { align-items: flex-start; }

/* subtitle editor */
.subedit { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; margin-bottom: 56px; align-items: start; }
.subedit-player { position: sticky; top: 130px; order: 2; display: flex; flex-direction: column; gap: 10px; }
.subedit-player .frame video { aspect-ratio: 16/9; width: 100%; }
.live-sub { background: #0a1a11; color: #fff; min-height: 2.6em; padding: 8px 12px; border-radius: 0 0 8px 8px; margin-top: -10px; text-align: center; }
.subedit-tools { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.shift { display: flex; gap: 6px; }
.shift input { min-width: 0; }
.cue-list { display: flex; flex-direction: column; gap: 6px; }
.cue-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.cue-row.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.cue-times { display: flex; flex-direction: column; gap: 3px; }
.cue-times input { padding: .1em .4em !important; font-size: .8rem; text-align: center; }
.cue-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.c-speaker { padding: .15em .5em !important; font-size: .85rem; max-width: 180px; }
.c-text { font-size: .95rem; }
.c-ref { font-size: .82rem; color: var(--muted); background: var(--soft); border-radius: 6px; padding: 4px 8px; }
.cue-ops { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; }

@media (max-width: 1080px) {
  .subedit { grid-template-columns: minmax(0, 1fr); }
  .subedit-player { position: static; order: 0; }
}
@media (max-width: 520px) {
  .cue-row { grid-template-columns: 1fr; }
  .cue-ops { flex-direction: row; }
}
.wrap > .page-title:first-child { margin-top: 24px; }

/* ================= v3: SMS login, devices, coupons, notes, stats ================= */
.pad { padding: 10px 16px; }
.authtabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: 10px; padding: 4px; }
.authtabs a { text-align: center; padding: .4em; border-radius: 8px; color: var(--muted); font-weight: 600; }
.authtabs a.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); text-decoration: none; }
input.otp { font-size: 1.6rem; letter-spacing: .5em; text-align: center; }
.coupon { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }
.coupon input { width: 200px !important; }
.oldprice { color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.devices, .mynotes, .plainlist { list-style: none; margin: 0; padding: 0; }
.devices li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.mynotes li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: .93rem; }
.mynotes li.muted { display: block; }
.mynotes form { margin: 0; }
.mynotes .ts { direction: ltr; }
.plainlist li { padding: 4px 0; }
.copyrow { display: flex; gap: 8px; margin: 8px 0; }
.copyrow input { flex: 1; min-width: 0; background: var(--soft); }
.invite p { margin: 4px 0; }

/* teaching notes */
.an-pop { position: absolute; z-index: 4; top: 12px; right: 12px; max-width: min(420px, 70%); background: rgba(255, 250, 240, .96); color: var(--ink); border-inline-start: 4px solid var(--accent); border-radius: 10px; padding: 10px 14px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.35); font-size: .92rem; line-height: 1.8; }
.an-pop small { display: block; color: var(--accent); font-weight: 700; font-size: .75rem; }
.an-pop strong { display: block; }
.an-pop p { margin: 4px 0 0; }
.an-close { position: absolute; left: 6px; top: 2px; background: none; border: 0; font-size: 1.3rem; cursor: pointer; color: var(--muted); }
.anote { display: block; width: 100%; text-align: right; background: #fff7ec; border: 0; border-inline-start: 3px solid var(--accent); border-radius: 6px; padding: 6px 10px; margin: 10px 0; font-size: .88rem; cursor: pointer; color: var(--text); }
.anote b::before { content: '◆ '; color: var(--accent); }
.anote p { margin: 2px 0 0; color: var(--text); }
.anote .ts { font-size: .8rem; }
.anote.big { margin: 0 0 8px; }
.notes-list { overflow-y: auto; padding: 10px 14px; flex: 1; }
.tabcount { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 6px; font-size: .7rem; }
.tabs .tab { font-size: .85rem; padding-inline: .3em; }
.note-form { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.note-form textarea { font-size: .92rem; }
.note-bar { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; }
.tabpane[data-pane="mine"] .mynotes { overflow-y: auto; flex: 1; }
.tabpane[data-pane="mine"] .mynotes li { padding: 8px 12px; }

/* stats */
.stats.light.six { grid-template-columns: repeat(6, 1fr); }
.chart-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.chart svg { display: block; width: calc(100% - 32px); height: 150px; margin: 14px 16px; background: linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 25%; }
.chart.tall svg { height: 220px; }
.chart svg rect:hover { opacity: .75; }
.axis { display: flex; justify-content: space-between; padding: 0 16px 10px; font-size: .8rem; color: var(--muted); }
.meter { display: inline-block; width: 80px; height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; vertical-align: middle; }
.meter i { display: block; height: 100%; background: var(--brand); }
.selrow td { background: var(--brand-soft); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 1080px) { .stats.light.six { grid-template-columns: repeat(3, 1fr); } .chart-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .two-col { grid-template-columns: minmax(0, 1fr); } .an-pop { max-width: 85%; font-size: .82rem; } }
@media (max-width: 520px) { .stats.light.six { grid-template-columns: repeat(2, 1fr); } }
.copyrow input, input[dir="ltr"].mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

/* ================= v4: quiz, courses, certificates, organisations ================= */
.quiz fieldset.q { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 12px 16px; margin: 0 0 12px; }
.quiz legend { font-weight: 700; color: var(--ink); padding: 0 4px; }
.qn { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .8rem; margin-inline-end: 4px; }
.opt { flex-direction: row !important; align-items: flex-start; gap: 8px !important; font-weight: 400 !important; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.opt:hover { background: var(--soft); }
.opt input { margin-top: .45em; }
.opt.is-correct { background: #e4f3ea; }
.opt.is-chosen-wrong { background: #fbe9e7; }
.q.right { border-color: #bfe0cc; } .q.wrong { border-color: #f0c9c5; }
.qfeedback { margin-top: 6px; padding: 8px 10px; background: var(--soft); border-radius: 8px; font-size: .9rem; }
.qfeedback p { margin: 4px 0; }
.qfeedback b, .qfeedback .linkbtn { display: block; }
.quiz-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.quiz-result { font-weight: 600; }
.course-link { display: block; background: #fff7ec; border: 1px solid #f2d3ae; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 24px; color: var(--ink); }
.course-link:hover { text-decoration: none; border-color: var(--accent); }
.coursebox { margin: 10px 0 20px; }
.progress-line { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.meter.wide { width: 200px; height: 10px; }
.course-steps { margin: 8px 0 14px; padding-inline-start: 1.4em; }
.course-steps li { margin: 4px 0; }
.course-steps li small { display: block; color: var(--muted); }
.course-steps li.done a { color: var(--ok); }
.certcard { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; color: var(--text); }
.certcard:hover { text-decoration: none; border-color: var(--brand); }
.certcard .seal { width: 44px; height: 44px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; font-size: .85rem; }
.certcard.pending .seal { background: var(--soft); color: var(--brand-dark); border: 2px solid var(--brand); }
.orgbox { padding: 4px 0; }
.orgrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.orgrow form { margin: 0; }
.joinbox { margin-bottom: 24px; }
.small-dd { font-size: 1.1rem !important; }

/* certificate */
.cert-wrap { padding: 24px 20px 56px; }
.cert-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; font-size: .88rem; }
.certificate { background: #fffdf8; max-width: 1000px; margin: 0 auto; padding: 18px; box-shadow: var(--shadow); aspect-ratio: 1.414; display: flex; }
.cert-border { flex: 1; border: 3px double var(--brand); outline: 1px solid var(--accent); outline-offset: -12px; padding: 40px 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; position: relative; }
.cert-head { display: flex; align-items: center; gap: 12px; position: absolute; top: 32px; right: 40px; text-align: right; }
.cert-head strong { display: block; font-size: 1.2rem; color: var(--brand-dark); }
.cert-head small { color: var(--muted); }
.certificate h1 { font-size: clamp(1.6rem, 3.4vw, 2.6rem); color: var(--brand-dark); letter-spacing: 1px; margin: 24px 0 10px; }
.cert-line { margin: 0; color: var(--text); font-size: 1.05rem; }
.cert-name { font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 800; color: var(--ink); margin: 4px 0; border-bottom: 2px solid var(--accent); padding: 0 24px 4px; }
.cert-course { font-size: 1.35rem; font-weight: 700; color: var(--brand); margin: 4px 0; }
.cert-foot { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; width: 100%; margin-top: 28px; align-items: end; }
.cert-foot div { display: flex; flex-direction: column; gap: 2px; font-size: .92rem; }
.cert-foot .sign { border-top: 1px solid var(--muted); padding-top: 6px; }
.cert-note { font-size: .72rem; color: var(--muted); margin-top: 18px; max-width: 640px; }
.certificate.revoked { opacity: .45; filter: grayscale(1); }
@media (max-width: 720px) {
  .certificate { aspect-ratio: auto; }
  .cert-border { padding: 90px 18px 24px; }
  .cert-foot { grid-template-columns: 1fr; }
}
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  @page cert { size: A4 landscape; margin: 8mm; }
  .cert-wrap { page: cert; }
  body { background: #fff; }
  .topbar, .footer, .noprint, .notice, .skip { display: none !important; }
  .cert-wrap { padding: 0; max-width: none; }
  .certificate { box-shadow: none; max-width: none; width: 100%; height: 190mm; aspect-ratio: auto; padding: 0; }
}
.brand img.custom-logo { width: auto; max-width: 180px; height: 40px; object-fit: contain; }
.cert-logo { width: auto; max-width: 200px; height: 56px; object-fit: contain; }
.logo-preview { display: flex; align-items: center; gap: 14px; background: var(--soft); border-radius: 8px; padding: 10px; }
.logo-preview img { width: auto; max-width: 220px; height: 56px; object-fit: contain; }

/* ================= brand: Fekr Bonyan logo, Alachigh Ravan owner ================= */
.brand img.brand-mark { width: 46px; height: 46px; object-fit: contain; }
.hero { background: radial-gradient(120% 140% at 90% 0%, #24573a 0%, var(--stage) 55%); }
.hero h1 { position: relative; }
.mainnav { background: linear-gradient(90deg, var(--brand-dark), var(--brand)); }
.cert-logo.tall { height: 92px; max-width: 120px; }
.cert-head { top: 22px; }
.cert-issuer { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: .82rem; color: var(--muted); }
.cert-issuer img { height: 54px; width: auto; }
.foot-brand .owner { display: inline-flex; align-items: center; gap: 10px; margin-top: 12px; color: #cfe8d6; }
.foot-brand .owner:hover { text-decoration: none; }
.owner-logo { background: #fff; border-radius: 8px; padding: 4px 6px; display: inline-flex; }
.owner-logo img { height: 44px; width: auto; }

/* ================= v5: policy pages, verification, consent ================= */
.md-page { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 32px 28px; margin-bottom: 48px; line-height: 2; }
.md-page h2 { font-size: 1.3rem; margin: 26px 0 8px; color: var(--brand-dark); }
.md-page h3 { font-size: 1.12rem; margin: 26px 0 8px; color: var(--brand-dark); }
.md-page h4 { font-size: 1rem; margin: 18px 0 6px; }
.md-page ul, .md-page ol { padding-inline-start: 1.4em; }
.md-page li { margin: 4px 0; }
.md-page hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.md-note { background: var(--brand-soft); border-inline-start: 4px solid var(--brand); padding: 8px 14px; border-radius: 8px; margin: 12px 0; }
.md-page .updated { font-size: .85rem; margin-top: 24px; }
.terms-check { align-items: flex-start !important; font-weight: 400 !important; font-size: .88rem !important; }
.terms-check input { margin-top: .45em; }
.foot-cols { display: flex; gap: 40px; flex-wrap: wrap; align-items: flex-start; }
.footer .foot-cols nav { display: flex; flex-direction: column; gap: 6px; }
.enamad { background: #fff; border-radius: 10px; padding: 4px; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.radio-card { flex-direction: row !important; align-items: center; gap: 8px !important; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-weight: 500; }
.radio-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.radio-card input { width: auto !important; }
.pledge { align-items: flex-start !important; background: #fff7ec; border: 1px solid #f2d3ae; border-radius: 10px; padding: 12px; font-weight: 400 !important; margin-bottom: 8px; }
.pledge input { margin-top: .45em; }
.verif-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; margin-bottom: 48px; }
.verif-head { display: flex; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.verif .docs { display: flex; gap: 8px; flex-wrap: wrap; }
.review-row { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.review-row input { flex: 1; min-width: 160px; }
.pages-admin { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; margin-bottom: 48px; align-items: start; }
.pages-admin .plainlist a.on { font-weight: 700; color: var(--ink); }
.md-editor { font-size: .95rem; line-height: 1.9; }
.ptag { margin: 6px 0 0; font-size: .85rem; }
.ptag .pill { background: rgba(255,255,255,.12); color: #d9eadf; }
.ptag a { color: #b7de7a; font-size: .8rem; }
@media (max-width: 860px) { .pages-admin { grid-template-columns: minmax(0, 1fr); } .verif-list { grid-template-columns: minmax(0, 1fr); } .md-page { padding: 4px 18px 20px; } }
.verify-form .form-actions { position: static; background: none; }
.foot-contact a { color: #cfe8d6; } .foot-contact { margin-top: 10px; }

/* ================= v6: Q&A, invoices, group SMS, translation workspace ================= */
.qa .ask-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.qa .ask-form textarea { width: 100%; }
.ask-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.qa-item { border-top: 1px solid var(--line); padding: 14px 0; }
.qa-item.mine { background: var(--soft); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; border: 0; display: flex; flex-direction: column; gap: 4px; }
.qa-meta { font-size: .85rem; color: var(--muted); margin-bottom: 4px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.qa-meta b { color: var(--ink); }
.qa-meta .ts { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.qa-q { white-space: pre-line; }
.qa-a { white-space: pre-line; margin-top: 8px; background: var(--brand-soft); border-inline-start: 3px solid var(--brand); padding: 8px 12px; border-radius: 6px; }
.qa-a-label { display: block; font-size: .8rem; font-weight: 700; color: var(--brand-dark); margin-bottom: 2px; }
.qa-admin { display: grid; gap: 12px; }
.qa-admin .row-btns { flex-wrap: wrap; gap: 8px; }
.qa-admin .grow { flex: 1; min-width: 180px; }
.chip.warn { background: #fdf1e3; color: var(--warn); }
.inline-form { display: inline; margin-inline-start: 8px; }
.bc-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 20px; }
.bc-text { white-space: pre-line; font-size: .88rem; max-width: 380px; }
.section-title { font-size: 1.1rem; margin: 18px 0 10px; }
.tr-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.inv-rows { display: grid; gap: 6px; }
.inv-row { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 1fr) minmax(0, 2fr); gap: 8px; }
.inv-row.head { font-size: .82rem; color: var(--muted); }
@media (max-width: 760px) { .bc-grid, .tr-grid { grid-template-columns: minmax(0, 1fr); } }

/* printable invoice / receipt (A4 portrait) */
.inv-wrap { padding: 24px 20px 56px; }
.invoice { background: #fff; max-width: 860px; margin: 0 auto; padding: 36px 40px; box-shadow: var(--shadow); border-top: 6px solid var(--brand); }
.invoice.void { opacity: .55; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 2px solid var(--line); padding-bottom: 16px; }
.inv-brand { display: flex; gap: 12px; align-items: center; }
.inv-brand img { height: 64px; width: auto; }
.inv-title h1 { margin: 0 0 8px; font-size: 1.4rem; color: var(--brand-dark); }
.inv-title dl { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 0; font-size: .9rem; }
.inv-title dt { color: var(--muted); }
.inv-title dd { margin: 0; font-weight: 600; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 18px 0; }
.inv-parties > div { background: var(--soft); border-radius: 8px; padding: 12px 14px; }
.inv-parties h2 { font-size: .85rem; color: var(--muted); margin: 0 0 6px; }
.inv-parties p { margin: 2px 0; font-size: .9rem; }
.inv-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.inv-table th, .inv-table td { border: 1px solid var(--line); padding: 8px 10px; text-align: center; }
.inv-table thead th { background: var(--brand-soft); color: var(--brand-dark); }
.inv-table td.desc { text-align: right; }
.inv-table tfoot th { text-align: left; font-weight: 600; background: #fafbf9; }
.inv-table tfoot tr.grand th, .inv-table tfoot tr.grand td { font-weight: 800; background: var(--brand-soft); color: var(--brand-dark); }
.inv-words { margin: 12px 0 4px; font-size: .92rem; }
.inv-pay, .inv-note { font-size: .9rem; margin: 6px 0; white-space: pre-line; }
.inv-foot { display: flex; justify-content: space-around; gap: 20px; margin-top: 40px; }
.inv-foot .sign { border-top: 1px solid var(--muted); padding-top: 6px; min-width: 180px; text-align: center; }
@media (max-width: 640px) {
  .invoice { padding: 20px 14px; }
  .inv-head, .inv-parties { grid-template-columns: 1fr; flex-direction: column; }
  .inv-parties { display: grid; }
  .inv-table { font-size: .8rem; }
  .inv-table th, .inv-table td { padding: 5px 4px; }
  .inv-foot .sign { min-width: 0; flex: 1; }
}
@media print {
  .inv-wrap { padding: 0; }
  .invoice { box-shadow: none; max-width: none; padding: 0; border-top-width: 4px; }
  .inv-parties > div { background: none; border: 1px solid var(--line); }
}
@media (min-width: 761px) { .adminnav { flex-wrap: wrap; overflow: visible; } .adminnav a { padding: .5em .8em; } }

/* ---- form cards: legend as a header inside the card; Persian-safe inline code ---- */
code { font-family: inherit; }
code[dir="ltr"], pre code { font-family: ui-monospace, Consolas, monospace; }
.admin-form fieldset { padding-top: 0; }
.admin-form legend { float: right; width: 100%; font-size: 1.05rem; padding: 14px 0 10px; margin: 0 0 4px; border-bottom: 1px solid var(--line); }
.admin-form legend + * { clear: both; }

.filepick { display: flex; flex-direction: row !important; align-items: center; gap: 10px; position: relative; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; background: var(--bg); min-width: 0; }
.filepick:hover { border-color: var(--brand); }
.filepick input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.filepick-name { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; direction: ltr; unicode-bidi: plaintext; }
.filepick.has .filepick-name { color: var(--ink); }
