/* ============================================================================
   components.css — دکمه، کارت، بج، کادر خطا، Toast
   مرجع: D4 §۳، §۸ و §۹

   کامپوننت‌های بصری سفارشی نوشته می‌شوند؛ Bootstrap فقط برای Grid و Utility.
   ========================================================================= */

/* ── دکمه ────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  font-weight: var(--fw-medium);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--bg-muted);
  color: var(--text);
  transition: background var(--transition), border-color var(--transition);
}

.btn:hover { background: var(--border); text-decoration: none; }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-primary);
  color: var(--on-brand);
}

.btn-primary:hover { background: var(--brand-primary-d); color: var(--on-brand); }

.btn-danger {
  background: var(--brand-danger);
  color: var(--on-brand);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}

/* فاصله‌ی حداقل ۸px بین دکمه‌های مجاور — D4 §۲ */
.btn + .btn { margin-inline-start: var(--space-2); }

@media (min-width: 992px) {
  .btn {
    padding: 0 var(--space-4);
    font-size: var(--fs-sm);
  }
}

/* ── کارت ────────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}

@media (min-width: 992px) {
  .card { padding: var(--space-3) var(--space-4); }
}

.card + .card { margin-top: var(--space-4); }

.card-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  margin-bottom: var(--space-3);
}

.card-lead {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-5);
}

.rtable .identifier {
  font-weight: var(--fw-bold);
}

/* ── بج وضعیت — D4 §۳ ────────────────────────────────────────────────────
   رنگ + آیکن + متن. هیچ اطلاعاتی صرفاً با رنگ منتقل نمی‌شود، تا برای
   کاربر کم‌بینا و در چاپ سیاه‌وسفید هم خوانا بماند. */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-sm);
  border: 1px solid currentColor;
  white-space: nowrap;
}

.badge-active       { color: var(--status-active-fg); background: var(--status-active-bg); }
.badge-expiring     { color: var(--status-expiring-fg); background: var(--status-expiring-bg); }
.badge-expired      { color: var(--status-expired-fg); background: var(--status-expired-bg); }
.badge-void         { color: var(--status-void-fg); background: var(--status-void-bg); }
.badge-not-started  { color: var(--status-not-started-fg); background: var(--status-not-started-bg); }

/* ── بج وضعیت پذیرش — Reception.md §۹، هفت وضعیت ────────────────────────── */
.badge-reception-received  { color: var(--status-not-started-fg); background: var(--status-not-started-bg); }
.badge-reception-progress  { color: var(--status-expiring-fg); background: var(--status-expiring-bg); }
.badge-reception-ready     { color: var(--status-active-fg); background: var(--status-active-bg); }
.badge-reception-delivered { color: var(--brand-primary-text); background: var(--brand-primary-soft); }
.badge-reception-sent      { color: var(--status-expired-fg); background: var(--status-expired-bg); }
.badge-reception-returned  { color: var(--status-returned-fg); background: var(--status-returned-bg); }
.badge-reception-cancelled { color: var(--status-void-fg); background: var(--status-void-bg); }

/* ── کادر خطای سه‌بخشی — CLAUDE.md §۵، D4 §۸ ────────────────────────────
   هر خطای عملیاتی: چه شد / چرا / چه کنید. */

.op-error {
  border: 1px solid var(--danger-border);
  border-inline-start: 4px solid var(--brand-danger);
  background: var(--danger-soft);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.op-error dt {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--brand-danger);
  margin-top: var(--space-2);
}

.op-error dt:first-child { margin-top: 0; }

.op-error dd {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-sm);
}

.op-error .op-error-actions { margin-top: var(--space-3); }

/* ── بنر وضعیت اشتراک — D3 §۷ ────────────────────────────────────────────── */

.banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  font-size: var(--fs-sm);
  border-inline-start-width: 3px;
  border-inline-start-style: solid;
}

.banner-warning {
  background: var(--warning-soft);
  border: 1px solid var(--warning-border);
  border-inline-start-width: 3px;
  border-inline-start-color: var(--brand-amber);
}

.banner-danger {
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  border-inline-start-width: 3px;
  border-inline-start-color: var(--brand-danger);
}

.banner .banner-text { flex: 1 1 240px; }

/* ── نوار مصرف پلن — D3 §۷ ───────────────────────────────────────────────── */

.meter {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-muted);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: var(--brand-teal);
  transition: width var(--transition);
}

.meter-fill.is-warning  { background: var(--brand-amber); }
.meter-fill.is-critical { background: var(--brand-danger); }

/* ── صفحه‌ی خالی — D4 §۸ ─────────────────────────────────────────────────
   هر صفحه‌ی خالی باید بگوید «چه چیزی اینجا می‌آید» و «چطور اولین مورد را بسازم». */

.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--text-muted);
}

.empty-state h3 { color: var(--text); }
.empty-state .empty-actions { margin-top: var(--space-4); }

/* ── فرم ─────────────────────────────────────────────────────────────────── */

.page-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.page-head-row .card-title {
  margin: 0;
}

.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.page-toolbar .btn + .btn {
  margin-inline-start: 0;
}

.page-toolbar form {
  margin: 0;
}

.form-split > .detail-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.form-split > .detail-stack > .form-section {
  margin-bottom: 0;
}

.form-section.is-success {
  border-color: var(--brand-teal);
}

.form-section.is-success .form-section-head::before {
  background: var(--brand-teal);
}

.def-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3) var(--space-4);
}

@media (min-width: 576px) {
  .def-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.def-grid .span-all {
  grid-column: 1 / -1;
}

.def-grid dt {
  margin: 0 0 var(--space-1);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}

.def-grid dd {
  margin: 0;
  font-weight: var(--fw-medium);
  word-break: break-word;
}

.def-well {
  padding: var(--space-2) var(--space-3);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  box-shadow: var(--input-inset);
}

.copy-field {
  display: flex;
  align-items: stretch;
  min-height: var(--tap);
  overflow: hidden;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  box-shadow: var(--input-inset);
}

.copy-field input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: var(--fs-sm);
}

.copy-field input:hover,
.copy-field input:focus {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.copy-field .btn {
  flex: 0 0 auto;
  margin: 0;
  border: 0;
  border-inline-start: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg-app);
}

.copy-field .btn + .btn {
  margin-inline-start: 0;
}

.copy-field .btn:hover {
  background: var(--bg-muted);
}

.copy-field .btn.is-copied {
  color: var(--brand-teal);
}

.disclosure {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.disclosure > summary {
  cursor: pointer;
  font-weight: var(--fw-semibold);
}

.disclosure[open] > summary {
  margin-bottom: var(--space-3);
}

.read-ids,
.read-lede {
  margin: var(--space-2) 0 0;
}

.read-ids {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.read-sep {
  margin-inline: var(--space-2);
  color: var(--text-subtle);
}

.read-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  margin-top: var(--space-4);
}

.read-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.read-stat strong {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.read-stat span {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}

.read-cluster .read-title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}

.read-cluster .read-lede {
  margin-top: var(--space-1);
}

.form-section.is-compact .form-section-head {
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
}

.form-section.is-compact .form-section-head h2 {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
}

.warranty-detail {
  padding-block: var(--space-2);
}

.warranty-detail .read-ids {
  margin-top: var(--space-2);
}

.warranty-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

@media (min-width: 992px) {
  .warranty-detail-actions { margin-top: var(--space-3); }
}

.warranty-detail-block {
  padding: var(--space-5);
}

@media (min-width: 992px) {
  .warranty-detail-block { padding: var(--space-4); }
}

.warranty-terms {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.warranty-term {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-muted);
  border-radius: var(--radius);
}

.warranty-term span {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
}

.warranty-term p,
.warranty-term div {
  margin: 0;
  line-height: 1.8;
}

.warranty-timeline {
  list-style: none;
  margin: 0;
  padding: 0 var(--space-2) 0 var(--space-4);
  border-inline-start: 2px solid var(--border);
}

.warranty-timeline li {
  padding: var(--space-3) var(--space-4);
  margin-inline-start: -1px;
  border-inline-start: 2px solid var(--brand-primary);
}

.page-head {
  margin-bottom: var(--space-4);
}

.page-head .card-title {
  margin-bottom: var(--space-1);
}

.page-head .page-head-row .card-title {
  margin: 0;
}

.page-head .card-lead {
  margin-bottom: 0;
  max-width: 52rem;
}

.form-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

@media (min-width: 992px) {
  .form-split {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    align-items: stretch;
  }

  .form-split.is-even {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.form-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

@media (min-width: 992px) {
  .form-section {
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-2);
  }
}

.form-split > .form-section {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}

.form-section-head {
  display: flex;
  align-items: stretch;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

@media (min-width: 992px) {
  .form-section-head {
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
  }
}

.form-section-head > div {
  flex: 1;
  min-width: 0;
}

.form-section-head::before {
  content: "";
  flex-shrink: 0;
  width: var(--space-1);
  align-self: stretch;
  min-height: var(--space-5);
  border-radius: var(--radius-sm);
  background: var(--brand-primary);
}

.form-section-head h2 {
  margin: 0;
  font-size: var(--fs-lg);
}

.form-section-lede {
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3) var(--space-4);
  align-items: start;
}

/* شبکه‌ی ۱۲ستونه‌ی داخلی — فقط برای این‌که هر فیلد عرض واقعی مورد نیازش را
   بگیرد، نه همیشه نصف یا تمام عرض. پیش‌فرض هر `.field` دقیقاً همان «نصف عرض»
   قبلی می‌ماند (span 6 از 12 = ۵۰٪) — این تغییر هیچ فرم دیگری را که این
   کلاس‌های اندازه را ندارد، به‌هم نمی‌زند. */
@media (min-width: 576px) {
  .form-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .form-grid > .field {
    grid-column: span 6;
  }

  /* باگ واقعی رفع‌شده: قبلاً این قاعده `.span-all` تنها بود (یک کلاس) و هرگز
     نمی‌توانست `.form-grid > .field` (دو کلاس) را در تخصیص ویژگی شکست بدهد —
     یعنی هر textarea/فیلد span-all در کل پنل، صرف‌نظر از ترتیب نوشتن CSS،
     همیشه نصف عرض می‌ماند. سلکتور اینجا باید همیشه هم‌تراز با
     `.is-quarter`/`.is-narrow`/`.is-wide` (که هر سه از `.form-grid > .field.is-X`
     استفاده می‌کنند) باشد، وگرنه دوباره شکست می‌خورد. */
  .form-grid > .field.span-all,
  .form-grid > .span-all {
    grid-column: 1 / -1;
    min-width: 0;
  }
}

/* عرض‌های کوچک‌تر/بزرگ‌تر از ۷۶۸px به بالا فعال می‌شوند — زیر آن، نصف عرض
   امن‌ترین اندازه برای فیلدهای کوتاه روی تبلت باریک است. */
@media (min-width: 768px) {
  .form-grid > .field.is-quarter {
    grid-column: span 3;
  }

  .form-grid > .field.is-narrow {
    grid-column: span 4;
  }

  .form-grid > .field.is-wide {
    grid-column: span 8;
  }

  .form-grid > .field.is-three-quarter {
    grid-column: span 9;
  }
}

/* دو `.form-grid` پیاپی داخل یک بخش — برای شکستن عمدی ردیف (مثلاً یک فیلد
   کوتاه و برجسته در ردیف خودش، بعد یک ردیف معمولیِ نصف+نصف). */
.form-grid + .form-grid {
  margin-top: var(--space-3);
}

.form-grid > .field {
  margin-bottom: 0;
  min-width: 0;
}

.form-section .field:last-child {
  margin-bottom: 0;
}

.field { margin-bottom: var(--space-4); }

@media (min-width: 992px) {
  .field { margin-bottom: var(--space-3); }
}

.field label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
}

.field .required { color: var(--brand-danger); }

.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="password"],
.field input[type="search"],
.field input[type="url"],
.field input[type="date"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: var(--input-inset);
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

@media (min-width: 992px) {
  .field input[type="text"],
  .field input[type="tel"],
  .field input[type="email"],
  .field input[type="password"],
  .field input[type="search"],
  .field input[type="url"],
  .field input[type="date"],
  .field input[type="file"],
  .field select {
    min-height: var(--tap-lg);
    padding: 0 var(--space-3);
  }

  .field textarea {
    padding: var(--space-1) var(--space-3);
  }
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-subtle);
}

.field select {
  cursor: pointer;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--text-subtle);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  background: var(--bg-surface);
  box-shadow: var(--focus-ring);
}

/* این برگه بوت‌استرپ را بار نمی‌کند؛ بدون این قاعده، display خودِ فیلد ویژگی hidden را بی‌اثر می‌کند. */
[hidden] {
  display: none !important;
}

.field .hint {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.field .field-error {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--fs-xs);
  color: var(--brand-danger);
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea,
.field.has-error .input-affix,
.field.has-error .plan-pick-item {
  border-color: var(--brand-danger);
}

.field.has-error input:focus,
.field.has-error select:focus,
.field.has-error textarea:focus,
.field.has-error .input-affix:focus-within {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.input-affix {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  min-height: var(--tap);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  box-shadow: var(--input-inset);
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

.input-affix:hover {
  border-color: var(--text-subtle);
}

.input-affix:focus-within {
  border-color: var(--brand-primary);
  background: var(--bg-surface);
  box-shadow: var(--focus-ring);
}

.input-affix-prefix {
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  background: var(--bg-app);
  border-inline-end: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.input-affix input[type="text"] {
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  min-height: calc(var(--tap) - 2px);
}

.input-affix input[type="text"]:hover,
.input-affix input[type="text"]:focus {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.plan-pick {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 576px) {
  .plan-pick {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

.plan-pick-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-height: var(--tap);
  padding: var(--space-3);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  box-shadow: var(--input-inset);
  cursor: pointer;
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

.plan-pick-item:hover {
  border-color: var(--text-subtle);
}

.plan-pick-item:has(input:checked) {
  border-color: var(--brand-primary);
  background: var(--brand-primary-soft);
  box-shadow: var(--focus-ring);
}

.plan-pick-item:has(input:focus-visible) {
  box-shadow: var(--focus-ring);
}

.plan-pick-item input[type="radio"] {
  position: absolute;
  inset-inline-end: var(--space-3);
  top: var(--space-3);
  margin: 0;
  accent-color: var(--brand-primary);
}

.plan-pick-quota {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--text);
}

.plan-pick-name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

.plan-pick-code {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

@media (min-width: 992px) {
  .form-actions { padding: var(--space-2) var(--space-3); }
}

.form-section .form-actions,
.sheet .form-actions,
.panel-body:not(.admin-body) .form-section .form-actions,
.panel-body:not(.admin-body) .sheet .form-actions,
.admin-body .form-section .form-actions,
.admin-body .sheet .form-actions {
  position: static;
  inset: auto;
  margin-top: var(--space-3);
  padding: var(--space-3) 0 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.form-actions .btn + .btn {
  margin-inline-start: 0;
}

.form-actions-meter {
  flex: 1 1 100%;
}

.panel-body:not(.admin-body) .form-actions {
  position: fixed;
  inset-inline: 0;
  z-index: 20;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  margin: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-md);
}

.admin-body .form-actions {
  position: sticky;
  z-index: 20;
  bottom: 0;
}

@media (min-width: 768px) {
  .panel-body:not(.admin-body) .form-actions,
  .admin-body .form-actions {
    position: static;
    margin-inline: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }

  .form-actions.is-sticky {
    position: sticky;
    z-index: 5;
    bottom: var(--space-3);
  }
}

.field input[readonly] {
  color: var(--text-muted);
}

.field-check label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  min-height: var(--tap);
  cursor: pointer;
  font-weight: var(--fw-medium);
}

.sms-meter,
.sms-review-status {
  margin: var(--space-1) 0 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.sms-review-status.is-pending {
  color: var(--text);
  font-weight: var(--fw-medium);
}

.sms-review-status.is-rejected {
  color: var(--brand-primary);
  font-weight: var(--fw-medium);
}

.sms-review-status.is-approved {
  color: var(--text);
}

.field-check input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin-top: 4px;
  accent-color: var(--brand-primary);
  flex-shrink: 0;
}

.field-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.field-row > input {
  flex: 1;
  min-width: 0;
}

.field-row .btn {
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════════
   فرم «کارروند» (workflow) — نسخه‌ی فشرده و آگاه از عرض فیلد، برای فرم‌های
   ورودی اصلی (صدور گارانتی، ثبت پذیرش). هر فیلد بر اساس نقشش (سریال کوتاه،
   نام محصول بلند، تاریخ کوتاه، …) عرض طبیعی خودش را می‌گیرد؛ Flexbox به‌جای
   Grid انتخاب شد چون فیلدهای پنهان‌شونده با جاوااسکریپت (مثلاً «محصول» در
   برابر «نام محصول دستی») در Flex بدون خلأ خالی در ردیف کنار هم می‌نشینند —
   هرکدام که پیدا باشد، فضای همان یکی دیگر را می‌گیرد.
   ══════════════════════════════════════════════════════════════════════ */

.workflow-surface {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.workflow-section {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.workflow-section:last-child {
  border-bottom: 0;
}

@media (min-width: 992px) {
  .workflow-section {
    padding: var(--space-3) var(--space-4);
  }
}

.workflow-section-head {
  margin-bottom: var(--space-3);
}

.workflow-section-head h2 {
  margin: 0;
  font-size: var(--fs-lg);
}

.workflow-section-head p {
  margin: 2px 0 0;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.workflow-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  gap: var(--space-3) var(--space-4);
}

.workflow-grid > .field {
  margin-bottom: 0;
  min-width: 0;
  flex: 1 1 240px;
}

.workflow-grid > .field.span-all,
.workflow-grid > .workflow-lookup-status,
.workflow-grid > .workflow-summary {
  flex-basis: 100%;
}

/* چک‌باکس‌های کوتاه — برخلاف بقیه‌ی فیلدها، به‌جای رشد یا سقف عرض، فقط
   به‌اندازه‌ی محتوایشان جا می‌گیرند و در وسط ارتفاع ردیف می‌نشینند. */
.workflow-grid > .field-check {
  flex: 0 1 auto;
  align-self: center;
}

/* نقش‌های کوتاه — روی موبایل هر فیلد تنها در ردیف خودش است، پس مثل بقیه
   تمام‌عرض می‌ماند (سقف عرض اینجا بی‌معنی است و فقط فضای خالی می‌سازد).
   سقف محدودکننده فقط از ۹۹۲px به بالا فعال می‌شود، جایی که چند فیلد
   واقعاً کنار هم در یک ردیف قرار می‌گیرند و باید کوتاه بمانند. */
@media (min-width: 992px) {
  .workflow-grid > .workflow-serial { flex: 1 1 180px; max-width: 260px; }
  .workflow-grid > .workflow-date   { flex: 1 1 160px; max-width: 220px; }
  .workflow-grid > .workflow-mobile { flex: 1 1 170px; max-width: 230px; }
  .workflow-grid > .workflow-type   { flex: 1 1 150px; max-width: 210px; }
}

/* نقش‌های بلند — رشد بیشتر برای جذب فضای باقی‌مانده‌ی همان ردیف. */
.workflow-grid > .workflow-product,
.workflow-grid > .workflow-manual,
.workflow-grid > .workflow-warranty,
.workflow-grid > .workflow-customer {
  flex: 1 1 100%;
  min-width: 0;
}

@media (min-width: 576px) {
  .workflow-grid > .workflow-product,
  .workflow-grid > .workflow-manual,
  .workflow-grid > .workflow-warranty,
  .workflow-grid > .workflow-customer { flex: 2 1 240px; }
}

@media (min-width: 992px) {
  .workflow-grid > .workflow-field-half  { flex: 1 1 calc(50% - var(--space-4) / 2); }
  .workflow-grid > .workflow-field-third { flex: 1 1 calc(33.333% - var(--space-4) * 2 / 3); }
}

/* ── وضعیت شناسایی زنده (سریال/مشتری) — همان کلاسی که warranty-issue.js و
   reception-create.js با جاوااسکریپت روی span وضعیت می‌گذارند. ── */

.field-status {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.field-status.is-success { color: var(--status-active); }
.field-status.is-warning { color: var(--brand-amber); }
.field-status.is-danger  { color: var(--brand-danger); }

.lookup-anchor { position: relative; }

.lookup-menu {
  position: absolute;
  z-index: 30;
  inset-inline: 0;
  top: calc(100% + 2px);
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow: auto;
}

.lookup-menu-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.lookup-menu-item:hover,
.lookup-menu-item.is-active {
  background: var(--bg-muted);
}

.lookup-menu-item span {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  direction: ltr;
}

.workflow-product .select2-container { font: inherit; }

.workflow-product .select2-container--default .select2-selection--single {
  height: var(--tap);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  box-shadow: var(--input-inset);
}

.workflow-product .select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text);
  line-height: calc(var(--tap) - 2px);
  padding-inline-end: var(--space-6);
  padding-inline-start: var(--space-3);
}

.workflow-product .select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: var(--text-subtle);
}

.workflow-product .select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 100%;
}

.workflow-product .select2-container--default.select2-container--focus .select2-selection--single,
.workflow-product .select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--brand-primary);
  background: var(--bg-surface);
  box-shadow: var(--focus-ring);
  outline: none;
}

.select2-dropdown {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 80;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  color: var(--text);
}

.select2-container--default .select2-results__option {
  color: var(--text);
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background: var(--brand-primary);
  color: var(--on-brand);
}

@media (min-width: 992px) {
  .workflow-product .select2-container--default .select2-selection--single {
    height: var(--tap-lg);
  }

  .workflow-product .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: calc(var(--tap-lg) - 2px);
  }
}

.workflow-lookup-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-muted);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
}

.workflow-lookup-status > span:first-child {
  color: var(--text-muted);
}

/* ── خلاصه‌ی نوع گارانتی — Warranties/Create، تا انتخاب نوع بلافاصله مدت/سقف/مبلغ را نشان دهد. ── */

.workflow-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-muted);
  border-radius: var(--radius);
}

.workflow-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--fs-xs);
}

.workflow-summary-item span { color: var(--text-muted); }
.workflow-summary-item strong { font-size: var(--fs-sm); }

/* ── اطلاعات تکمیلی — بسته به‌طور پیش‌فرض، تا فیلدهای غیرضروری فرم را طولانی
   نکنند؛ فقط وقتی خطای اعتبارسنجی داخلشان باشد، بازِ بارگذاری می‌شوند. ── */

.workflow-disclosure {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-top: var(--space-3);
  overflow: hidden;
}

.workflow-disclosure summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  list-style: none;
  font-weight: var(--fw-medium);
}

.workflow-disclosure summary::-webkit-details-marker {
  display: none;
}

.workflow-disclosure summary span:last-child {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-normal);
}

.workflow-disclosure summary::after {
  content: "";
  flex-shrink: 0;
  margin-inline-start: auto;
  width: 7px;
  height: 7px;
  border-inline-end: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform var(--transition);
}

.workflow-disclosure[open] summary::after {
  transform: rotate(-135deg);
}

.workflow-disclosure-body {
  padding-top: var(--space-3);
  padding-inline: var(--space-4);
  padding-bottom: var(--space-4);
  border-top: 1px solid var(--border);
}

.workflow-subsection + .workflow-subsection {
  margin-top: var(--space-4);
}

.workflow-subsection h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
}

/* ── نوار پایینی چسبان و مصرف سقف پلن ─────────────────────────────────── */

.workflow-quota {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.workflow-quota.is-warning {
  color: var(--brand-amber);
  font-weight: var(--fw-medium);
}

/* ── هشدار گارانتی تکراری روی همان سریال — قاعده‌ی W-08 ──────────────────── */

.field-check.has-warning {
  padding: var(--space-3);
  background: var(--warning-soft);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
}

.autofill-trap {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  padding: 0;
}

.form-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  margin-bottom: var(--space-4);
}

.form-filters .field {
  flex: 1 1 160px;
  margin-bottom: 0;
  min-width: 0;
  max-width: 240px;
}

.form-filters .field.is-wide {
  flex: 2 1 220px;
  max-width: 28rem;
}

.form-filters .field.is-actions {
  flex: 0 0 auto;
  max-width: none;
}

.form-section.is-danger {
  border-color: var(--brand-danger);
}

.form-section.is-danger .form-section-head::before {
  background: var(--brand-danger);
}

details.form-section > summary {
  list-style: none;
  cursor: pointer;
}

details.form-section > summary::-webkit-details-marker {
  display: none;
}

details.form-section > .form-section-head {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

details.form-section[open] > .form-section-head {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}

.asset-preview {
  display: block;
  max-width: 100%;
  max-height: 120px;
  margin-bottom: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--bg-surface);
}

/* ── Toast — پیام موفقیت پس از PRG، D4 §۸ ────────────────────────────────── */

.toast {
  position: fixed;
  inset-block-end: calc(var(--tabbar-h) + var(--space-4));
  inset-inline: var(--space-4);
  z-index: 60;
  padding: var(--space-3) var(--space-4);
  background: var(--brand-navy);
  color: var(--on-brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
}

@media (min-width: 768px) {
  .toast {
    inset-block-end: var(--space-5);
    inset-inline-start: auto;
    inset-inline-end: var(--space-5);
    max-width: 420px;
  }
}

/* ── ویرایشگر Rich Text محدود — D4 §۳.۵ ──────────────────────────────────── */

.richtext-toolbar {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
}

.richtext-toolbar button {
  min-width: var(--tap);
  min-height: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
}

.richtext-toolbar button:hover {
  background: var(--bg-muted);
}

.richtext-editor {
  min-height: 96px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: var(--lh-body);
}

.richtext-editor:focus {
  border-color: var(--brand-primary);
  outline: none;
}

.richtext-editor ul {
  padding-inline-start: var(--space-5);
}

.richtext-hidden {
  display: none;
}

/* ── نمودار روند ماهانه — گجت داشبورد، D1 §۷ ─────────────────────────────── */

.trend-chart-wrap {
  width: 100%;
  overflow-x: auto;
}

.trend-chart {
  display: block;
  width: 100%;
  min-width: 0;
}

@media (min-width: 480px) {
  .trend-chart {
    min-width: 480px;
  }
}

.trend-chart-grid {
  stroke: var(--table-line);
  stroke-width: 1;
}

.trend-chart-axis {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.trend-chart-bar-from {
  stop-color: var(--chart-bar-from);
}

.trend-chart-bar-to {
  stop-color: var(--chart-bar-to);
}

.trend-chart-bar {
  fill: url(#trendBarFill);
}

.trend-chart-bar:hover {
  filter: brightness(1.12);
}

.trend-chart-value {
  font-size: 11px;
  fill: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.trend-chart-label {
  font-size: 11px;
  fill: var(--text-subtle);
}

/* ── گجت‌های داشبورد — کارت عددی، کاشی گزارش، سر گجت ───────────────────── */

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.card-head .card-title {
  margin: 0;
}

.stat-card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.stat-card-grid.is-tiles {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.stat-card-grid.is-status {
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
  .stat-card-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
  }

  .stat-card-grid.is-tiles {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .stat-card-grid.is-status {
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  }

  /* دقیقاً ۴ کارت ضروری در یک ردیف — بدون تِرَک‌های خالی auto-fill (صفحه‌ی پذیرش‌ها). */
  .stat-card-grid.is-fixed-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  --stat-accent: var(--brand-magenta);
  --stat-wash: var(--wash-garnet);
  --stat-from: var(--gadget-slate-from);
  --stat-to: var(--gadget-slate-to);
  --stat-soft: var(--bg-muted);

  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 128px;
  padding: 14px 16px 10px;
  background:
    radial-gradient(160px 110px at 108% 60%, var(--stat-wash), transparent 64%),
    linear-gradient(160deg, var(--stat-from) 140%, var(--stat-to) 63%);
  border: 1px solid var(--gadget-edge);
  border-radius: var(--radius-lg);
  color: var(--gadget-fg);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(var(--gadget-mesh) 1px, transparent 1px),
    linear-gradient(90deg, var(--gadget-mesh) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, .45), transparent 72%);
  pointer-events: none;
}

.stat-card-orb {
  position: absolute;
  z-index: 0;
  width: 150px;
  height: 150px;
  border-radius: var(--radius-pill);
  inset-inline-end: -48px;
  top: -56px;
  background: var(--stat-wash);
  filter: blur(28px);
  pointer-events: none;
}

.stat-card-orb.is-alt {
  width: 120px;
  height: 120px;
  inset-inline-end: auto;
  inset-inline-start: -40px;
  top: auto;
  bottom: -52px;
  background: var(--wash-garnet);
}

.stat-card-top,
.stat-card-value,
.stat-card-label,
.stat-card-meter,
.stat-spark,
.stat-ring {
  position: relative;
  z-index: 1;
}

.stat-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.stat-card--issued {
  --stat-accent: var(--brand-magenta);
  --stat-wash: var(--wash-garnet);
  --stat-from: var(--gadget-issued-from);
  --stat-to: var(--gadget-issued-to);
  --stat-soft: var(--brand-primary-soft);
}

.stat-card--active {
  --stat-accent: var(--brand-teal);
  --stat-wash: var(--wash-teal);
  --stat-from: var(--gadget-active-from);
  --stat-to: var(--gadget-active-to);
  --stat-soft: var(--status-active-bg);
}

.stat-card--expiring {
  --stat-accent: var(--brand-amber);
  --stat-wash: var(--wash-amber);
  --stat-from: var(--gadget-amber-from);
  --stat-to: var(--gadget-amber-to);
  --stat-soft: var(--status-expiring-bg);
}

.stat-card--reception {
  --stat-accent: var(--status-not-started);
  --stat-wash: var(--wash-indigo);
  --stat-from: var(--gadget-indigo-from);
  --stat-to: var(--gadget-indigo-to);
  --stat-soft: var(--status-not-started-bg);
}

.stat-card--plan {
  --stat-accent: var(--brand-magenta);
  --stat-wash: var(--wash-teal);
  --stat-from: var(--gadget-plan-from);
  --stat-to: var(--gadget-plan-to);
  --stat-soft: var(--brand-primary-soft);
}

.stat-card--plan.is-warning {
  --stat-accent: var(--brand-amber);
  --stat-wash: var(--wash-amber);
  --stat-from: var(--gadget-amber-from);
  --stat-to: var(--gadget-amber-to);
}

.stat-card--plan.is-critical,
.stat-card--void {
  --stat-accent: var(--brand-danger);
  --stat-wash: var(--wash-danger);
  --stat-from: var(--gadget-issued-from);
  --stat-to: var(--gadget-issued-to);
  --stat-soft: var(--status-void-bg);
}

.stat-card--new,
.stat-card--pending {
  --stat-accent: var(--status-not-started);
  --stat-wash: var(--wash-indigo);
  --stat-from: var(--gadget-indigo-from);
  --stat-to: var(--gadget-indigo-to);
  --stat-soft: var(--status-not-started-bg);
}

.stat-card--muted,
.stat-card--tenants {
  --stat-accent: var(--chrome-fg);
  --stat-wash: var(--wash-slate);
  --stat-from: var(--gadget-slate-from);
  --stat-to: var(--gadget-slate-to);
  --stat-soft: var(--status-expired-bg);
}

.stat-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--gadget-icon-well);
  box-shadow: inset 0 1px 0 var(--gadget-edge);
  color: var(--stat-accent);
}

.stat-card-icon .icon {
  display: block;
}

.stat-card-value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--gadget-fg);
  white-space: nowrap;
}

.stat-card-value .stat-card-unit {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0;
  color: var(--gadget-muted);
}

.stat-card-label {
  color: var(--gadget-muted);
  font-size: var(--fs-xs);
  line-height: 1.35;
}

.stat-card-hint {
  display: none;
}

.stat-card-meter {
  margin-top: auto;
  padding-top: var(--space-2);
}

.stat-card-meter .meter {
  height: 6px;
  background: var(--gadget-icon-well);
}

.stat-spark {
  display: block;
  width: 100%;
  height: 36px;
  margin-top: auto;
  padding-top: var(--space-1);
}

.stat-spark-line {
  stroke: var(--stat-accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-spark-area {
  fill: var(--stat-accent);
  opacity: .2;
}

.stat-ring {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background: conic-gradient(
    from 210deg,
    var(--stat-accent) calc(var(--p) * 1%),
    var(--gadget-icon-well) 0
  );
  box-shadow: inset 0 0 0 1px var(--gadget-edge);
}

.stat-ring-hole {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  background: var(--stat-to);
  color: var(--gadget-fg);
  font-size: 10px;
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

a.stat-card:hover,
a.stat-card:focus-visible {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--stat-accent) 55%, var(--gadget-edge));
  box-shadow: 0 14px 28px color-mix(in srgb, var(--stat-accent) 28%, transparent);
  text-decoration: none;
  color: var(--gadget-fg);
}

.stat-card-grid.is-status .stat-card {
  min-height: 92px;
  background:
    linear-gradient(180deg, var(--stat-soft), var(--bg-surface) 58%);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--stat-accent);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.stat-card-grid.is-status .stat-card::before,
.stat-card-grid.is-status .stat-card-orb {
  display: none;
}

.stat-card-grid.is-status .stat-card-value {
  color: var(--text);
  font-size: var(--fs-xl);
}

.stat-card-grid.is-status .stat-card-label {
  color: var(--text-muted);
}

.stat-card-grid.is-status .stat-card-icon {
  background: var(--stat-soft);
  box-shadow: none;
  color: var(--stat-accent);
}

.stat-card-grid.is-status a.stat-card:hover,
.stat-card-grid.is-status a.stat-card:focus-visible {
  color: var(--text);
  box-shadow: var(--shadow-md);
}

@media (prefers-reduced-motion: reduce) {
  a.stat-card:hover,
  a.stat-card:focus-visible {
    transform: none;
  }
}

.stat-card--tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-height: 0;
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--brand-primary);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.stat-card--tile::before,
.stat-card--tile .stat-card-orb {
  display: none;
}

.stat-card--tile .stat-card-icon {
  background: var(--brand-navy);
  color: var(--on-brand);
}

.stat-card--tile .stat-card-label {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.stat-card--tile .stat-card-icon + .stat-card-label {
  font-weight: var(--fw-bold);
  color: var(--text);
}

.stat-card--tile .stat-card-hint {
  display: block;
  margin-top: auto;
  font-size: 11px;
  color: var(--text-subtle);
}

a.stat-card--tile:hover,
a.stat-card--tile:focus-visible {
  transform: none;
  color: var(--text);
  box-shadow: var(--shadow-md);
}

/* ── میانبر داشبورد — فقط از تبلت به بالا؛ موبایل نوار پایین دارد ──────── */

.dashboard-shortcuts {
  display: none;
}

@media (min-width: 768px) {
  .dashboard-shortcuts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-2);
    margin-bottom: var(--space-5);
  }
}

@media (min-width: 1280px) {
  .dashboard-shortcuts {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

.dashboard-shortcut {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 52px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.dashboard-shortcut:hover,
.dashboard-shortcut:focus-visible {
  border-color: var(--shortcut-accent, var(--brand-primary));
  color: var(--text);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.dashboard-shortcut-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: var(--shortcut-wash, var(--brand-primary-soft));
  color: var(--shortcut-accent, var(--brand-primary));
}

.dashboard-shortcut span {
  font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-shortcut.is-issue    { --shortcut-accent: var(--brand-primary); --shortcut-wash: var(--brand-primary-soft); }
.dashboard-shortcut.is-reception { --shortcut-accent: var(--status-not-started); --shortcut-wash: var(--status-not-started-bg); }
.dashboard-shortcut.is-product  { --shortcut-accent: var(--brand-amber); --shortcut-wash: var(--status-expiring-bg); }
.dashboard-shortcut.is-customer { --shortcut-accent: var(--brand-teal); --shortcut-wash: var(--status-active-bg); }
.dashboard-shortcut.is-warranty { --shortcut-accent: var(--brand-magenta); --shortcut-wash: var(--brand-primary-soft); }
.dashboard-shortcut.is-report   { --shortcut-accent: #6366F1; --shortcut-wash: var(--status-not-started-bg); }
.dashboard-shortcut.is-wallet   { --shortcut-accent: var(--brand-teal); --shortcut-wash: var(--status-active-bg); }

/* ── نوار مصرف سقف پلن — یک خط باریک، نه یک کارت جداگانه. اطلاعات مهم است
   اما هم‌وزن با معیارهای عملیاتی اصلی (صادرشده/فعال/...) نیست. ── */

.dashboard-quota {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
}

.dashboard-quota-label {
  flex-shrink: 0;
  color: var(--text-muted);
}

.dashboard-quota .meter {
  flex: 1;
  min-width: 0;
}

.dashboard-quota-value {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-weight: var(--fw-medium);
}

.dashboard-quota-value .stat-card-unit {
  color: var(--text-muted);
  font-weight: var(--fw-normal);
}

/* ── چیدمان داشبورد — گجت + فهرست، نه دو جدول تمام‌عرض ─────────────────── */

.dashboard-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 992px) {
  .dashboard-split {
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 1fr);
    align-items: start;
  }
}

.dashboard-split > .card {
  margin-top: 0;
  min-width: 0;
}

.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.feed-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}

.feed-list li:last-child .feed-item {
  border-bottom: 0;
  padding-bottom: 0;
}

.feed-list li:first-child .feed-item {
  padding-top: 0;
}

.feed-item:hover,
.feed-item:focus-visible {
  color: var(--text);
  text-decoration: none;
}

.feed-item:hover .identifier,
.feed-item:focus-visible .identifier {
  color: var(--brand-primary);
}

.feed-item-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.feed-item-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-item-meta {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
}

/* ── جدول گارنت ──────────────────────────────────────────────────────────
   جداسازی با سطح (هدر ملایم، کارت WhiteSmoke روی موبایل).
   زیر md هر ردیف کارت است (D4 §۲). از md به بعد جدول واقعی. */

.rtable {
  width: 100%;
}

.rtable thead {
  display: none;
}

.rtable tbody tr {
  display: block;
  background: var(--table-card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
}

.rtable td {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
}

.rtable td:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.rtable td:first-child {
  padding-top: 0;
}

.rtable td::before {
  content: attr(data-label);
  flex-shrink: 0;
  font-size: 11px;
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
  color: var(--text-subtle);
}

.rtable td[data-label=""] {
  justify-content: flex-end;
  padding-top: var(--space-2);
}

.rtable td[data-label=""]::before {
  content: none;
}

.rtable input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--brand-primary);
}

.table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding: var(--space-3) 0;
}

.table-footer-meta {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

.pager a,
.pager span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.pager a:hover,
.pager a:focus-visible {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  text-decoration: none;
}

.pager a.is-current {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--on-brand);
  font-weight: var(--fw-bold);
}

/* D4: روی موبایل اسکرول افقی جدول ممنوع — کارت‌ها جای آن را می‌گیرند */
.rtable.scroll-x {
  overflow: visible;
}

@media (min-width: 768px) {
  .rtable {
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--fs-sm);
    background: var(--bg-surface);
    border: 1px solid var(--table-line);
    border-radius: var(--radius-lg);
  }

  .rtable thead {
    display: table-header-group;
  }

  .rtable tbody tr {
    display: table-row;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
  }

  .rtable th,
  .rtable td {
    display: table-cell;
    padding: 11px 14px;
    text-align: right;
    vertical-align: middle;
    border: 0;
    border-bottom: 1px solid var(--table-line);
  }

  .rtable td::before,
  .rtable td[data-label=""]::before {
    content: none;
  }

  .rtable td:last-child,
  .rtable td:first-child {
    padding-top: 11px;
    padding-bottom: 11px;
  }

  /* هدر ملایم — جدا از بدنه، بدون بلوک سرمه‌ای */
  .rtable thead th {
    background: var(--table-head-bg);
    color: var(--table-head-fg);
    font-size: 11px;
    font-weight: var(--fw-medium);
    letter-spacing: 0.02em;
    white-space: nowrap;
    border-bottom: 1px solid var(--table-line);
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .rtable thead th:first-child {
    border-start-start-radius: calc(var(--radius-lg) - 1px);
  }

  .rtable thead th:last-child {
    border-start-end-radius: calc(var(--radius-lg) - 1px);
  }

  /* راه‌راه مشخص */
  .rtable tbody tr:nth-child(odd) td {
    background: var(--bg-surface);
  }

  .rtable tbody tr:nth-child(even) td {
    background: var(--table-stripe);
  }

  .rtable tbody tr:last-child td {
    border-bottom: 0;
  }

  .rtable tbody tr:last-child td:first-child {
    border-end-start-radius: calc(var(--radius-lg) - 1px);
  }

  .rtable tbody tr:last-child td:last-child {
    border-end-end-radius: calc(var(--radius-lg) - 1px);
  }

  .rtable tbody td {
    transition: background var(--transition), border-color var(--transition);
  }

  .rtable tbody td:first-child {
    border-inline-start: 3px solid transparent;
    font-weight: var(--fw-medium);
  }

  .rtable tbody tr:hover td,
  .rtable tbody tr:focus-within td {
    background: var(--table-hover);
  }

  .rtable tbody tr:hover td:first-child,
  .rtable tbody tr:focus-within td:first-child,
  .rtable tbody tr:has(input[type="checkbox"]:checked) td:first-child {
    border-inline-start-color: var(--brand-primary);
  }

  .rtable tbody tr:has(input[type="checkbox"]:checked) td {
    background: var(--brand-primary-soft);
  }

  .rtable tfoot td {
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    border-bottom: 0;
    padding: var(--space-3) var(--space-4);
  }

  /* فوتر هم‌سطح هدر */
  .rtable + .table-footer {
    margin-top: 0;
    padding: var(--space-3) var(--space-4);
    background: var(--table-head-bg);
    border: 1px solid var(--table-line);
    border-top: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }

  .rtable + .table-footer .table-footer-meta {
    background: transparent;
  }

  .rtable:has(+ .table-footer) {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: 0;
  }

  .rtable:has(+ .table-footer) tbody tr:last-child td:first-child {
    border-end-start-radius: 0;
  }

  .rtable:has(+ .table-footer) tbody tr:last-child td:last-child {
    border-end-end-radius: 0;
  }
}

/* ── فرم «درج آیتم» صورتحساب پذیرش — شرح نصف عرض با ارتفاع کامل، فیلدهای
   عددی زیر هم در نیمه‌ی دیگر؛ با کلیک روی «درج آیتم» به فهرست زیرش اضافه و
   خودش ریست می‌شود (بدون ویرایش مستقیم داخل فهرست — فقط حذف). ──────────── */

.invoice-item-entry {
  display: flex;
  gap: var(--space-4);
  align-items: stretch;
  flex-wrap: wrap;
}

.invoice-item-entry .entry-description,
.invoice-item-entry .entry-fields {
  flex: 1 1 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

@media (min-width: 576px) {
  .invoice-item-entry .entry-description,
  .invoice-item-entry .entry-fields {
    flex: 1 1 320px;
    min-width: 0;
  }
}

.invoice-item-entry .entry-description textarea {
  flex: 1;
  min-height: 160px;
  resize: vertical;
}

.invoice-item-entry .entry-fields .field {
  margin-bottom: var(--space-3);
}

.invoice-item-entry .entry-fields .field:last-of-type {
  margin-bottom: 0;
}

.btn-add-item {
  align-self: flex-start;
  margin-top: var(--space-2);
}
