/* Server-rendered adaptations of the prototype's markup. The design system styles `.nav button`,
   `.rail-foot button`, `.seg button` and `.views` buttons; the prototype drew them with script, and
   here each is a real submit button of a small form. A form that only carries its button must not
   become a layout box of its own, so it disappears from the layout and its button takes its place. */
.nav form, .rail-foot form, .seg form, .views form, .chips form { display: contents; }
.toast:empty { display: none; }
.tm:empty { display: none; } /* an amount field with nothing typed draws no toman line (family rule 34) */
.dh + .db { display: block; }
.login-body { margin: 0; }
/* The sign-in art draws itself in with staggered delays; the prototype set them inline. */
.rs-d-n1 { animation-delay: 1.2s; }
.rs-d-n2 { animation-delay: 1.33s; }
.rs-d-n3 { animation-delay: 1.46s; }
.rs-d-core { animation-delay: 1.65s; }
.rs-d-axis { animation-delay: 1.9s; }
.rs-d-area { animation-delay: 2s; }
.flat { margin: 0; }
.topic { justify-content: flex-start; }
.code-box { text-align: center; }
.code-box .code { font-size: 28px; font-weight: 700; letter-spacing: .12em; }
.page-dialog { position: static; margin-inline: auto; }
/* §4.5 and §4.8: the prototype set these inline. */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.pills.acts { gap: 6px; }
.acts form, form.inline { display: contents; }
.stack.tight { gap: 0; }
.nowrap { white-space: nowrap; }

/* «خانه» (phase 12): a stat card that opens its page keeps the muted label; «باز کردن» is a link that looks as the prototype's */
.stat.go .l a { color: inherit; }
.links a { font-weight: 600; font-size: 13.5px; min-height: 28px; display: inline-flex; align-items: center; }
@media (max-width: 860px) { .links a { min-height: 44px; } }

/* Phase 19 step 2 — the look list's fixes. Placement, spacing, wrapping and sizing only; the look stays Madar's (17b). */
/* A chart keeps its own height: the prototype let it shrink to nothing when its card had no taller neighbour. */
.widget .chart { flex: 1 0 auto; }
.links a { white-space: nowrap; flex: none; }
/* A phone card's number sits on its label's line, as in the prototype, even when it carries a stale mark or a source note. */
@media (max-width: 860px) { .t.cards td.n > .stack.tight { display: inline-flex; vertical-align: baseline; } }
/* A filter line holds a form's month choice beside the brand choice, label then field, as the prototype's. */
.filters .field { flex-direction: row; align-items: center; gap: 8px; }
.filters .field .lab { min-height: 0; }
.filters .field .in { width: auto; }
/* The scorecard strip: three or four figures in a row; in a narrow card (the booking's side column) four sit two by
   two so a ten-digit amount has its own room, and on a phone one under another. */
.strip.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.strip.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.strip .v { overflow-wrap: anywhere; }
.strip .cap { white-space: nowrap; }
@media (min-width: 861px) {
  @container (max-width: 560px) {
    .strip.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 8px; }
    .strip.c4 > div:nth-child(odd) { border-inline-start: 0; padding-inline-start: 0; }
    .strip.c4 > div:nth-child(n+3) { border-top: 1px dashed var(--line); padding-top: 12px; }
  }
}
@media (max-width: 860px) { .strip.c3, .strip.c4 { grid-template-columns: 1fr; } }
/* A form that holds the page's cards keeps the page's own gap between them. */
.page-form { display: flex; flex-direction: column; gap: 18px; }
/* A read-only value in a form grid sits at the top of its row beside the fields, its label in the field label's own style. */
.form-grid .field.ro { align-self: start; }
/* A card's one action takes the card's width, as the prototype's button directly in a stack does. */
.stack > form.full > .btn { width: 100%; }

/* ---- the side rail (family rule 15) ------------------------------------------------------------------------------
 * The fold itself — open at 248px or folded to a 72px strip of icons, `rail-mini` on <html>, the group hairlines, the badges on the
 * icons, the focus tooltip — is the family kit's `static/vendor/family/rail-fold.css` and `rail-fold.js`, byte for byte. The kit's
 * tokens (`--rail-muted`, `--bronze-2`, `--pine-deep`, …) are Rasad's own tokens; the organisation card is the kit's fixed card
 * (`.switcher-fixed`). What stays here is only what Rasad's markup needs beside it. */
.rail .rail-head { display: flex; align-items: center; gap: 6px; }
.rail .rail-head .lockup { flex: 1; min-width: 0; }
/* The design system's rail button sits at the end of its row (`margin-inline-start: auto`); folded, the foot is a column and the way
   out is centred under the avatar. */
@media (min-width: 861px) {
  html.rail-mini .rail .rail-foot .rail-out { margin-inline-start: 0; }
}

/* Phase 31 — the refusal an in-place control meets is drawn at the top of the page region (`#note`, base.html); sticky, so it is
   seen wherever the person has scrolled. Empty, it takes no room (the page is a column with a gap). */
.refusal:empty { display: none; }
.refusal { position: sticky; top: 72px; z-index: 15; }
@media (max-width: 860px) { .refusal { top: 58px; } }

/* Phase 33 — «راهنما» in the family's form (rule 32, Madar's help): the topics are a plain list at the start side and the open topic is
   lit with a light tint — not boxed, not a solid button. The bundle's own rule makes the grid one column on a phone. */
.help-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.help-nav .stack { gap: 2px; }
.help-nav .btn { width: 100%; white-space: normal; text-align: start; }
.help-nav .btn[aria-current="page"] { background: var(--surface-2); font-weight: 700; }

/* Phase 33 — the users table and the side sheet in Madar's measures (family rules 21 and 24). Madar draws them over base rules of its
   own that the design system's bundle does not carry: a heavier count line, a header row at 1.5 line height, the count line as a
   plain block in the phone's cards, and a side sheet with no browser-set maximum width — without it the sheet stops 35px short of
   the phone's edge. */
.t caption { font-weight: 500; }
.t th { line-height: 1.5; }
@media (max-width: 860px) { .t.cards caption { display: block; } }
dialog.sheet { max-width: none; }

/* Phase 21 step 2 — «کلیدهای Apify» and the Apify fields of «تنظیم‌های پیج». Placement and sizing only, tokens only.
   A key row's buttons are three equal columns on one line, always in the same order (a column the active key has no button in is
   left empty, so «ویرایش سقف» stays in its place); on a phone they stack, equal in width, the empty column gone. */
.pills.acts.even { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pills.acts.even .btn { width: 100%; }
@media (max-width: 860px) {
  .pills.acts.even { grid-template-columns: 1fr; margin-top: 6px; }
  .pills.acts.even > span:empty { display: none; }
}
/* Phase 23 — a long code (an API key, shown once) wraps at any character instead of running off a narrow sheet. */
.copy.wrap { max-width: 100%; }
.copy.wrap .ltr { min-width: 0; overflow-wrap: anywhere; text-align: left; }
/* An API key and its visible start are read by eye: Latin digits, not the Persian shapes the body's stylistic set draws. */
.latin { font-feature-settings: normal; }
/* A read time is one compact row: its field, and the × beside it. */
.stack.times { gap: 8px; }
.time-row { display: flex; gap: 6px; align-items: center; }
.time-row .field { flex: 1; }
/* A button only the no-script page needs (a select's «نمایش»): the select presses it itself while the script runs. */
html.js .nojs { display: none; }
/* Phase 24 — the developer guide: one text that wraps in a column, its code left to right, its tables scrolling inside themselves on a phone. */
.guide { line-height: 1.9; max-width: 920px; }
.guide h1 { font-size: 20px; margin: 0 0 12px; }
.guide h2 { font-size: 17px; margin: 28px 0 8px; }
.guide h3 { font-size: 15px; margin: 22px 0 6px; }
.guide p, .guide ul, .guide ol { margin: 8px 0; }
.guide pre { direction: ltr; text-align: start; overflow-x: auto; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 12.5px; line-height: 1.6; }
.guide code.ltr { font-size: 12.5px; background: var(--surface-2); border-radius: 6px; padding: 0 5px; }
.guide .t td, .guide .t th { white-space: normal; }
.guide .tw { margin: 8px 0; }
/* A webhook's address is read by eye and may be long: left to right, it breaks inside its cell so the row's three buttons keep their room. */
.addr { align-self: flex-start; max-width: 340px; overflow-wrap: anywhere; }
/* Phase 39 — «جفت کردن با پست»: the page's unpaired posts, one row each (the radio and the post's card, then its address); one column on a phone. */
.picks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--gap-sm); }
.picks li { display: flex; align-items: center; gap: var(--gap-md); border: 1px solid var(--line); border-radius: var(--r-control); padding: var(--gap-sm) var(--gap-md); }
.picks li:has(input:checked) { border-color: var(--bronze); background: var(--bronze-tint); }
.picks .check { flex: 1; min-width: 0; align-items: center; }
.picks .btn { flex: none; }
@media (max-width: 860px) { .picks li { flex-direction: column; align-items: stretch; } .picks .btn { align-self: flex-start; } }

/* Phase 44 — Jalali date-range picker overrides (base rules live in bundle.css) and `/posts` layout. */
.cal-panel { inset-inline-start: auto; inset-inline-end: 0; }
.cal-shortcut[hidden], .cal-typed[hidden] { display: none; }
.cal-typed { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cal-typed .field { flex: 1 1 130px; flex-direction: column; align-items: stretch; gap: 4px; }
.cal-typed .field .in { width: 100%; }

/* Posts filter bar, 6 summary cards, best/worst strip, «نمایش بیشتر» */
.posts-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.posts-filters .field { flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; }
.posts-filters .field.wide { flex: 1 1 220px; }
.posts-filters .field .in { width: 100%; }
.posts-filters .posts-filter-acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.posts-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 1180px) { .posts-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.posts-table th, .posts-table td { padding: 10px 6px; }
.posts-table th:first-child, .posts-table td:first-child { padding-inline-start: 14px; }
.posts-table th:last-child, .posts-table td:last-child { padding-inline-end: 14px; }
.posts-table .post-cell { max-width: 265px; min-width: 180px; }
.posts-table .post .pbody { max-width: 195px; }
.posts-hl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.posts-hl-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.posts-hl-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.posts-hl-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.posts-more { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 6px 0; }
.posts-more-row td { border-bottom: 0; }
@media (max-width: 860px) {
  .posts-filters { flex-direction: column; align-items: stretch; }
  .posts-filters .field.wide { flex: none; }
  .posts-filters .posts-filter-acts { display: grid; grid-template-columns: 1fr; }
  .posts-filters .posts-filter-acts .btn { width: 100%; min-height: var(--tap-min); }
  details.cal > summary { min-height: var(--tap-min); width: 100%; }
  .cal-panel { min-width: 0; width: auto; inset-inline: 0; max-width: calc(100vw - 32px); box-sizing: border-box; }
  .cal-shortcut, .cal-step, .cal-day { min-height: var(--tap-min); }
  .cal-step { min-width: var(--tap-min); }
  .posts-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .posts-hl { grid-template-columns: 1fr; }
  .t.cards tr.posts-more-row { border: 0; background: transparent; padding: 0; box-shadow: none; }
  .t.cards tr.posts-more-row td { display: block; padding: 4px 0; }
  .t.cards tr.posts-more-row td::before { display: none; }
  .posts-more { flex-direction: column; align-items: stretch; text-align: center; }
  .posts-more .btn { width: 100%; min-height: var(--tap-min); }
}

/* Phase 53 — Instagram booking wizard steps 1–2 (design §10.34): 4-step bar, filter sheet trigger,
   2-column desktop workspace with sticky cart, and sticky phone bottom cart bar + bottom sheet. */
.wiz-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.wiz-step { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); font-size: 13px; color: var(--muted); text-decoration: none; min-width: 0; }
.wiz-step b { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); font-size: 12px; flex: none; }
.wiz-step.on { border-color: var(--bronze); background: var(--bronze-tint); color: var(--ink); font-weight: 700; }
.wiz-step.on b { background: var(--pine); color: var(--on-pine); }
.wiz-step.done { border-color: var(--pine-tint-2); background: var(--pine-tint); color: var(--pine-ink); }
.wiz-step.done b { background: var(--ok); color: var(--on-bad); }
.wiz-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.wiz-cart-aside { position: sticky; top: 72px; max-height: calc(100dvh - 96px); overflow-y: auto; }
.wiz-filter-bar-mob { display: none; }
.wiz-cart-bar { display: none; }
.wiz-pub-list { display: flex; flex-direction: column; gap: 10px; }
.wiz-pub-row { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.wiz-pub-row.picked { border-color: var(--pine); background: var(--pine-tint); }
.wiz-pub-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.wiz-pub-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wiz-pub-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.wiz-cart-list { display: flex; flex-direction: column; gap: 10px; }
.wiz-cart-item { border: 1px solid var(--line); border-radius: var(--r-control); padding: 10px 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.wiz-cart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wiz-cart-alt { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.wiz-budget-rows { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px dashed var(--line-2); }
.wiz-budget-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.wiz-foot-acts { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.wiz-alt-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.wiz-alt-item { border: 1px solid var(--line); border-radius: var(--r-control); padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.wiz-alt-item:has(input:checked) { border-color: var(--pine); background: var(--pine-tint); }
@media (max-width: 960px) {
  .wiz-layout { grid-template-columns: 1fr; padding-bottom: 84px; }
  .wiz-cart-aside { display: none; }
  .wiz-cart-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: fixed; inset-inline: 0; bottom: 0; z-index: 25; padding: 10px var(--page-gutter-phone); background: var(--surface); border-top: 1px solid var(--line-2); box-shadow: var(--shadow-2); }
}
@media (max-width: 860px) {
  .wiz-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wiz-step { min-height: var(--tap-min); padding: 8px 10px; }
  .wiz-filters-desk { display: none; }
  .wiz-filter-bar-mob { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .wiz-filter-bar-mob .btn, .wiz-filter-bar-mob .in { min-height: var(--tap-min); }
  .wiz-pub-foot .btn, .wiz-cart-head .btn, .wiz-cart-alt .btn, .wiz-foot-acts .btn, .wiz-cart-bar .btn { min-height: var(--tap-min); }
  .wiz-layout .in, .wiz-layout select { min-height: var(--tap-min); width: 100%; }
}

/* Phase 54 mockup/wizard steps 3–4 — upload progress/retry, caption counter, order & payment rows, drafts. */
.wiz-upload-box { border: 1px dashed var(--line-2); border-radius: var(--r-control); padding: 12px 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.wiz-upload-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.wiz-upload-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.wiz-count-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.wiz-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.wiz-pay-row { border: 1px solid var(--line); border-radius: var(--r-control); padding: 12px 14px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.wiz-pay-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.wiz-pay-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .wiz-grid-2 { grid-template-columns: 1fr; }
  .wiz-upload-head .btn, .wiz-upload-foot .btn, .wiz-pay-acts .btn { min-height: var(--tap-min); }
  .wiz-pay-row .wiz-pub-foot { flex-direction: column; align-items: stretch; }
  .wiz-pay-acts { display: grid; grid-template-columns: 1fr; }
  .wiz-pay-acts .btn { width: 100%; }
}

/* Phase 57 reports: desktop + phone + A4 print refinement over bundle.css `.report`. */
.report { max-width: none; padding: 0; }
.report .t th, .report .t td { padding: 7px 8px; }
@media (max-width: 860px) {
  .filters .field { flex-wrap: wrap; width: 100%; min-width: 0; }
  .filters .field .in { max-width: 100%; width: 100%; }
}
@media print {
  .app { display: block !important; grid-template-columns: none !important; }
  .main, .page { width: 100% !important; max-width: none !important; padding: 0 !important; margin: 0 !important; }
  .report .widget, .report .chart, .report .prog, .report svg { break-inside: avoid; page-break-inside: avoid; }
  .report .tw { overflow: visible; }
  .report .t { width: 100%; }
  .report .t th, .report .t td { padding: 5px 6px; font-size: 11px; white-space: normal; }
  .report .strip.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .report .strip.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .report .gcol { grid-template-columns: 1fr !important; }
}

/* Phase 58 pairing queue: action row desktop + full-width stacked 44px phone buttons. */
.pair-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 860px) {
  .pair-acts { display: grid; grid-template-columns: 1fr; }
  .pair-acts .btn { width: 100%; min-height: var(--tap-min); }
}
