/* ── Sidebar brand ──────────────────────────────────────────── */
.brand {
  height: 64px;
  padding: 12px 10px 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--color-sidebar-divider);
  flex: 0 0 auto;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-default);
  background: var(--color-primary);
  color: var(--color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex: 0 0 auto;
}
.brand-mark svg { width: 20px; height: 20px; }
/* In dark mode --color-primary is a light blue, which turns the logo chip into a
   bright box on the dark sidebar. Drop the box so the logo sits on the sidebar. */
html[data-mode="dark"] .brand-mark { background: transparent; color: var(--color-sidebar-text); }
.brand-separator {
  width: 1px;
  height: 28px;
  background: var(--color-sidebar-divider);
  flex: 0 0 auto;
}
.brand-copy {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  flex: 1;
}
.brand-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-sidebar-text);
  line-height: 1.25;
}
.brand-subtitle {
  margin-top: 2px;
  font-size: 11px;
  color: var(--color-sidebar-text-secondary);
  line-height: 1.25;
}

/* ── Sidebar collapse button (inside brand) ─────────────────── */
.sidebar-collapse-button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-sidebar-icon);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  margin-inline-start: auto;
}
.sidebar-collapse-button:hover { color: var(--color-sidebar-text); }
.icon-svg { display: block; flex: 0 0 auto; }
.sidebar-collapse-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  transition: transform .18s ease;
}
.sidebar-collapse-icon svg, .sidebar-collapse-icon .icon-svg { width: 18px; height: 18px; display: block; }

/* ── Sidebar nav ────────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  overflow: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group-title {
  padding: 8px 10px 4px;
  color: var(--color-sidebar-text-muted);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.nav-item {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-default);
  color: var(--color-sidebar-text-secondary);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-sidebar-text);
}
.nav-item.is-active {
  background: var(--color-sidebar-active-bg);
  color: var(--color-sidebar-active-text);
  border-color: var(--color-sidebar-active-border);
  font-weight: 600;
}
.nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  flex: 0 0 auto;
}
.nav-icon svg { width: 19px; height: 19px; display: block; }
.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
}
.nav-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-default);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--status-info-text);
  background: var(--status-info-bg);
  border: 1px solid var(--status-info-border);
  font-size: 11px;
  line-height: 1;
  flex: 0 0 auto;
}

/* ── Sidebar footer + user card ─────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid var(--color-sidebar-divider);
  padding: 10px 8px;
  flex: 0 0 auto;
}
.user-card {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-default);
  border: 1px solid var(--color-sidebar-border);
  background: var(--color-sidebar-user-bg);
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-default);
  background: var(--color-sidebar-active-bg);
  color: var(--color-sidebar-active-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex: 0 0 auto;
}
.user-meta { min-width: 0; flex: 1; overflow: hidden; }
.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  margin-top: 1px;
  font-size: 11px;
  color: var(--color-sidebar-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.user-action-form { margin: 0; }
.user-action-button {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-default);
  border: 1px solid var(--color-sidebar-border);
  background: transparent;
  color: var(--color-sidebar-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  font-size: 0;
}
.user-action-button svg { width: 14px; height: 14px; flex: 0 0 auto; }
.user-action-button:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-sidebar-text);
  border-color: var(--color-sidebar-border);
}
.user-action-button.logout {
  color: var(--status-danger-text);
  border-color: var(--status-danger-border);
  background: transparent;
}
.user-action-button.logout:hover {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border-color: var(--status-danger-border);
}

/* ── Topbar elements ────────────────────────────────────────── */
.page-heading { min-width: 0; }
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  font-size: 11px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-title {
  margin: 0;
  color: var(--color-text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb-item { color: var(--color-text-secondary); }
a.breadcrumb-item:hover { color: var(--color-primary); text-decoration: underline; }
.breadcrumb-sep { color: var(--color-text-muted); }
.breadcrumb-current { color: var(--color-text); font-weight: 500; }

/* ── Subsystem nav (per-app section tabs) ───────────────────── */
.subnav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--color-divider);
}
.subnav-item {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subnav-item:hover { color: var(--color-text); }
.subnav-item.is-active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ── In-content page header (title + actions row) ───────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.page-header-title { margin: 0; font-size: 18px; font-weight: 600; color: var(--color-text); min-width: 0; }
.page-header-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
/* On phones, space-between would fling the action button(s) to the far edge,
   detached from the title. Stack them under the title, grouped at the start. */
@media (max-width: 720px) {
  .page-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .page-header-actions { justify-content: flex-start; flex-wrap: wrap; }
}

/* ── Data table ─────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--color-divider); text-align: start; }
.table thead th { color: var(--color-text-secondary); font-weight: 600; font-size: 12px; }
.table tbody tr:hover { background: var(--color-surface-muted); }
.table-empty { text-align: center; color: var(--color-text-muted); padding: 18px 10px; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
/* Fixed-width button: keeps toggle/action buttons the same size when they stack or
   sit in a column so they line up regardless of the (variable) label length. */
.btn-fixed { min-width: 7.5rem; justify-content: center; text-align: center; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* List filter bar */
.filter-panel { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; padding: 12px 14px; }
.filter-panel select, .filter-panel input { min-width: 140px; }
/* On phones, lay the filter controls out as an even two-column grid so each box
   fills its half of the width instead of wrapping raggedly (a wide box would
   otherwise leave empty space beside a narrow one). A button spans the full row. */
@media (max-width: 720px) {
  .filter-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: stretch; }
  .filter-panel select, .filter-panel input, .filter-panel .btn, .filter-panel button {
    min-width: 0; width: 100%;
  }
  .filter-panel button, .filter-panel .btn { grid-column: 1 / -1; }
}

/* Per-row action buttons in list tables */
.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-actions form { display: inline; margin: 0; }

/* Portal brand logo in the sidebar brand-mark box */
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Organization profile official assets (logo/stamp/signature previews) */
.org-assets { display: flex; flex-wrap: wrap; gap: 16px; }
.org-asset { margin: 0; text-align: center; border: 1px solid var(--color-border, #dde5ee); border-radius: 8px; padding: 12px; min-width: 150px; }
.org-asset figcaption { font-size: 12px; color: var(--color-text-secondary, #5b6b7d); margin-bottom: 8px; }
.org-asset img { max-width: 170px; max-height: 110px; object-fit: contain; display: block; margin: 0 auto; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.pagination-info { font-size: 13px; color: var(--muted, #6b7280); }
.btn.is-disabled { opacity: .45; pointer-events: none; }

/* ── Chips multi-select (ChipsSelectWidget) ─────────────────── */
.chips-widget { display: flex; flex-direction: column; gap: 8px; }
.chips-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-list:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 4px 0 10px;
  background: var(--color-primary-soft); color: var(--color-primary);
  border-radius: var(--radius-default); font-size: 12px; font-weight: 500;
}
.chip-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; min-height: 0; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--color-primary); font-size: 14px; line-height: 1;
}
.chip-remove:hover { background: rgba(0,0,0,0.08); }

/* ── Payslip ────────────────────────────────────────────────── */
/* Numeric cells: keep them start-aligned so digits sit under their header caption
   (do NOT flip direction — fa_amount already renders Persian digits). */
.table td.num, .table th.num { text-align: start; font-variant-numeric: tabular-nums; }
.table tr.row-total td { font-weight: 700; border-top: 2px solid var(--color-divider); color: var(--color-text); }
.payslip-net {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--color-primary-soft);
}
.payslip-net span { font-size: 14px; font-weight: 600; color: var(--color-text); }
.payslip-net strong { font-size: 18px; font-weight: 800; color: var(--color-primary); direction: ltr; unicode-bidi: plaintext; }

/* ── Jalali date picker (static/js/jalali.js) ───────────────── */
.jdp-pop { position: absolute; z-index: 1000; width: 244px; padding: 10px; direction: rtl;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-card); box-shadow: 0 8px 24px rgba(0,0,0,0.18); }
.jdp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.jdp-title { font-size: 13px; font-weight: 600; color: var(--color-text); }
.jdp-nav { width: 26px; height: 26px; min-height: 0; padding: 0; border: 0; background: transparent; cursor: pointer; font-size: 18px; color: var(--color-text-secondary); border-radius: var(--radius-sm); }
.jdp-nav:hover { background: var(--color-surface-muted); }
.jdp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.jdp-wd { text-align: center; font-size: 11px; color: var(--color-text-muted); padding: 4px 0; }
.jdp-day { height: 28px; min-height: 0; padding: 0; border: 0; background: transparent; cursor: pointer; font-size: 12px; color: var(--color-text); border-radius: var(--radius-sm); }
.jdp-day:hover { background: var(--color-primary-soft); color: var(--color-primary); }
.jdp-day.is-today { border: 1px solid var(--color-primary); color: var(--color-primary); }

/* ── Sales item/totals ──────────────────────────────────────── */
.sales-totals { display: flex; justify-content: flex-start; margin-top: 14px; }
.sales-totals .info-list { min-width: 300px; max-width: 380px; grid-template-columns: auto minmax(0, 1fr); column-gap: 0; }
.sales-reorder-cell { display: flex; gap: 6px; white-space: nowrap; }
.doc-name { display: block; font-size: 15px; font-weight: 600; }
.doc-sub { display: flex; flex-wrap: wrap; gap: 4px 30px; margin-top: 4px; font-size: 12px; font-weight: 500; color: var(--color-text-secondary); }
/* .doc-sub bdi keeps the Persian font — that rule lives in theme_tokens.css
   (typeface declarations are centralised there per the CSS policy). */
.sales-item-table input, .sales-item-table select { min-width: 0; width: 100%; }
.sales-item-table td, .sales-item-table th { vertical-align: middle; }
.item-row-remove { text-align: center; width: 40px; }
.item-row-remove .link-button { color: var(--status-danger-text); font-size: 14px; }
.dn { display: none; }

/* ── Org structure tree (hr/partials/_org_dept_node.html) ───── */
.org-root + .org-root { margin-top: 14px; }
.org-dept-head { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.org-dept-title { font-size: 14px; font-weight: 700; color: var(--color-text); }
.org-code { font-size: 11px; color: var(--color-text-muted); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 1px 6px; }
.org-positions { margin-top: 2px; }
.org-pos { padding: 7px 0; border-top: 1px solid var(--color-divider); }
.org-pos-title { font-size: 13px; font-weight: 600; color: var(--color-text); margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.org-emp { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px 0; font-size: 13px; }
.org-emp-name { color: var(--color-primary); font-weight: 500; }
.org-emp-code { font-size: 11px; color: var(--color-text-muted); }
.org-emp-mgr { font-size: 11px; color: var(--color-text-secondary); }
.org-empty { color: var(--color-text-muted); font-size: 12px; }
.org-children { margin-top: 10px; padding-inline-start: 16px; border-inline-start: 2px solid var(--color-divider); display: flex; flex-direction: column; gap: 12px; }

/* ── Permission matrix (role editor) ────────────────────────── */
.perm-hint { margin: 0 0 14px; font-size: 12px; color: var(--color-text-secondary); }
.perm-group { margin-bottom: 12px; }
.perm-group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.perm-group-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text); display: flex; align-items: center; gap: 8px; }
.perm-count { font-size: 11px; font-weight: 500; color: var(--color-text-muted); }
.perm-all { font-size: 12px; color: var(--color-text-secondary); }
.perm-matrix-wrap { overflow-x: auto; }
.perm-matrix { width: 100%; border-collapse: collapse; }
.perm-matrix th, .perm-matrix td { padding: 6px 8px; border-bottom: 1px solid var(--color-divider); text-align: center; font-size: 12px; }
.perm-matrix thead th { color: var(--color-text-secondary); font-weight: 600; white-space: nowrap; }
.perm-matrix .perm-res-head, .perm-matrix .perm-res { text-align: start; color: var(--color-text); white-space: nowrap; }
.perm-matrix .perm-res { font-weight: 500; }
.perm-cell input { width: 16px; height: 16px; min-height: 0; cursor: pointer; }
.perm-na { color: var(--color-text-muted); }
.perm-yes { color: var(--status-success-text); font-weight: 700; }

/* ── Notification button & dot ──────────────────────────────── */
.notification-button {
  position: relative;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-icon);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}
.notification-button:hover { color: var(--color-primary); }
.notification-button svg { width: 20px; height: 20px; display: block; }
.notification-dot {
  position: absolute;
  top: 4px;
  inset-inline-start: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-danger-text);
  border: 1.5px solid var(--color-bg);
  pointer-events: none;
}

/* ── Icon button (topbar) ───────────────────────────────────── */
.icon-button {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-default);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-icon);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-button:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-color: var(--color-primary-active-bg);
}
.icon-button svg { width: 18px; height: 18px; display: block; }

/* ── Cards ──────────────────────────────────────────────────── */
.card,
.login-card,
.profile-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 16px;
}
.login-card { width: min(420px, 100%); padding: 24px; }
.login-header { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 20px; }
.login-brand { display: flex; align-items: center; gap: 8px; }
.login-logo { max-height: 112px; max-width: 340px; width: auto; height: auto; object-fit: contain; }
.login-brand-mark {
  width: 32px; height: 32px;
  border-radius: var(--radius-default);
  background: var(--color-primary);
  color: var(--color-on-primary);
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.login-brand-mark svg { width: 18px; height: 18px; }
.login-brand-name { font-size: 13px; font-weight: 600; color: var(--color-text); }
.login-lang { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.login-lang a { color: var(--color-text-secondary); }
.login-lang a:hover { color: var(--color-primary); }
.login-lang .is-active { color: var(--color-primary); font-weight: 600; }
.login-title { margin: 0; font-size: 22px; font-weight: 700; color: var(--color-text); text-align: center; }
.login-subtitle { margin: 4px 0 20px; font-size: 13px; color: var(--color-text-secondary); text-align: center; }
.login-note { margin-top: 16px; text-align: center; }
.login-card .field-group { margin-bottom: 14px; }
.login-error {
  background: var(--status-danger-bg);
  border: 1px solid var(--status-danger-border);
  color: var(--status-danger-text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 14px;
}
.login-error ul { margin: 0; padding: 0; list-style: none; }
.login-verify { margin-bottom: 14px; }
.login-submit { width: 100%; margin-top: 6px; }
.profile-card-header { margin-bottom: 14px; }
.profile-card-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text); }
.profile-card-note { margin: 4px 0 0; font-size: 11px; color: var(--color-text-muted); }
.profile-card-fill { display: flex; flex-direction: column; flex: 1; }
.profile-card-fill .info-list { flex: 1; }
.profile-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}
.profile-identity { display: flex; align-items: center; gap: 14px; }
.profile-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-default);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex: 0 0 auto;
}
.profile-name { margin: 0; font-size: 15px; font-weight: 600; }
.profile-subtitle { margin: 3px 0 0; font-size: 11px; color: var(--color-text-secondary); }

/* ── Info list (read-only grid) ─────────────────────────────── */
.info-list {
  display: grid;
  /* Two label/value pairs per row (compact detail header). Collapses to one pair
     per row on narrow screens. Narrow contexts (e.g. .sales-totals) override back. */
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
  row-gap: 0;
  column-gap: 32px;
}
@media (max-width: 760px) {
  .info-list { grid-template-columns: auto minmax(0, 1fr); column-gap: 0; }
}
.info-label, .info-value {
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--color-divider);
  line-height: 1.5;
}
.info-list > *:nth-last-child(-n+2) { border-bottom: none; }
.info-label { color: var(--color-text); white-space: nowrap; font-size: 13px; font-weight: 700; }
.info-value { color: var(--color-text-secondary); font-size: 13px; font-weight: 400; }

/* ── Two-column read-only detail (includes/_detail_columns.html) ─ */
.detail-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 40px;
  align-items: start;
}
@media (max-width: 720px) { .detail-columns { grid-template-columns: 1fr; gap: 0; } }

/* ── Settings form ──────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 900px) { .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.settings-form .profile-actions { display: flex; justify-content: flex-end; }

/* ── Password form ──────────────────────────────────────────── */
.password-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}
@media (max-width: 720px) { .password-form { grid-template-columns: 1fr; } }
.password-form .form-actions { grid-column: 1 / -1; }

/* ── Form actions & hints (shared) ──────────────────────────── */
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.settings-hint { margin: 0; font-size: 12px; color: var(--color-text-muted); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn,
.button,
button.btn {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-default);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover, .button:hover { background: var(--color-surface-muted); color: var(--color-text); }
.btn-primary,
.button-primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-color: var(--color-primary);
}
.btn-primary:hover,
.button-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: var(--color-on-primary);
}
.btn-secondary,
.button-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover,
.button-secondary:hover {
  background: var(--color-surface-muted);
  border-color: var(--color-primary-active-bg);
}
.btn-danger { background: var(--status-danger-bg); color: var(--status-danger-text); border-color: var(--status-danger-border); }
.btn-danger:hover { background: var(--status-danger-text); border-color: var(--status-danger-text); color: var(--color-on-primary); }
/* The base rule above uses `button.btn` (type+class specificity) to beat the UA
   button style; that also outranks the single-class `.btn-*` variants, so a
   <button class="btn btn-primary"> would fall back to the neutral look. Re-assert
   the variant colors at matching specificity for <button> (source order wins). */
button.btn-primary { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
button.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: var(--color-on-primary); }
button.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
button.btn-danger { background: var(--status-danger-bg); color: var(--status-danger-text); border-color: var(--status-danger-border); }
button.btn-danger:hover { background: var(--status-danger-text); border-color: var(--status-danger-text); color: var(--color-on-primary); }
.link-button { background: transparent; border: 0; padding: 0; height: auto; min-height: 24px; cursor: pointer; color: var(--color-primary); font-size: 12px; }

/* ── Form inputs ────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; color: var(--color-text-secondary); font-weight: 500; }
input,
select,
textarea {
  min-height: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 4px 8px;
  font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}
/* .fa-number / .jalali-date keep the Persian font — that rule lives in
   theme_tokens.css (typeface declarations are centralised there per the CSS policy). */
.field-errors { margin: 4px 0 0; padding: 0; list-style: none; color: var(--status-danger-text); font-size: 11px; }
.field-req { color: var(--status-danger-text); }
.field-help { margin: 2px 0 0; font-size: 11px; color: var(--color-text-muted); }

/* ── Reusable form grid (includes/_form.html) ───────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .field-full,
.form-grid .field-group:has(textarea) { grid-column: 1 / -1; }
.form-nonfield-errors { margin: 0 0 12px; }
.checkbox-row { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-row input { min-height: 0; width: auto; }
.field-group-check { justify-content: flex-end; }

/* ── Status badges ──────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-default);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid;
}
.status-badge.success { background: var(--status-success-bg); color: var(--status-success-text); border-color: var(--status-success-border); }
.status-badge.warning { background: var(--status-warning-bg); color: var(--status-warning-text); border-color: var(--status-warning-border); }
.status-badge.danger { background: var(--status-danger-bg); color: var(--status-danger-text); border-color: var(--status-danger-border); }
.status-badge.info { background: var(--status-info-bg); color: var(--status-info-text); border-color: var(--status-info-border); }
.status-badge.neutral { background: var(--status-neutral-bg); color: var(--status-neutral-text); border-color: var(--status-neutral-border); }

/* ── Tables ─────────────────────────────────────────────────── */
table, .data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { border-bottom: 1px solid var(--color-border); padding: 9px 10px; }
th { font-weight: 600; color: var(--color-text-secondary); background: var(--color-surface-muted); font-size: 12px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--color-surface-muted); }
tr.is-unread td { font-weight: 600; }

/* ── Shell messages ─────────────────────────────────────────── */
.shell-messages { padding: 0 24px; }
.message-card {
  padding: 10px 14px;
  margin: 8px 0;
  background: var(--status-info-bg);
  border: 1px solid var(--status-info-border);
  border-radius: var(--radius-default);
  color: var(--status-info-text);
  font-size: 13px;
}

/* ── Misc utilities ─────────────────────────────────────────── */
.form-actions,
.actions,
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
html[dir="rtl"] .form-actions,
html[dir="rtl"] .actions { flex-direction: row-reverse; }
.empty-state { color: var(--color-text-muted); text-align: center; padding: 32px; }
.pc-sep { border: none; border-top: 1px solid var(--color-divider); margin: 16px 0; }
.metric-label { color: var(--color-text-secondary); }
.metric-card strong { display: block; margin-top: 6px; font-size: 18px; }
