/* ==========================================================================
   GMAP · اجزای رابط (Button, Field, Select, Checkbox, Radio, Switch, Tabs,
   Badge, Card, Table, Pagination, Breadcrumb, Avatar, Alert, Toast, Modal,
   Drawer, Menu, Tooltip, Progress, Skeleton, Empty, Dropzone, DatePicker…)
   ========================================================================== */

/* ============================== Icon ============================== */
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ============================== Button ============================== */
.btn {
  --btn-bg: var(--c-surface-3);
  --btn-bg-hover: var(--c-surface-3-hover);
  --btn-bg-active: var(--c-border);
  --btn-fg: var(--c-text);
  --btn-border: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: var(--h-md);
  padding-inline: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  text-decoration: none !important;
  transition: background-color var(--t-fast) ease, border-color var(--t-fast) ease, color var(--t-fast) ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--btn-bg-hover); }
.btn:active { background: var(--btn-bg-active); }
.btn:focus-visible { border-radius: var(--r-md); }
.btn .icon { width: 20px; height: 20px; }

.btn-primary { --btn-bg: var(--c-primary); --btn-bg-hover: var(--c-primary-hover); --btn-bg-active: var(--c-primary-pressed); --btn-fg: var(--c-on-primary); }
.btn-secondary { /* پیش‌فرض */ }
.btn-outline { --btn-bg: var(--c-surface); --btn-bg-hover: var(--c-surface-2); --btn-bg-active: var(--c-surface-3); --btn-border: var(--c-border); }
.btn-ghost { --btn-bg: transparent; --btn-bg-hover: var(--c-surface-3); --btn-bg-active: var(--c-surface-3-hover); }
.btn-danger { --btn-bg: var(--c-danger); --btn-bg-hover: var(--c-danger-hover); --btn-bg-active: var(--c-danger-hover); --btn-fg: #fff; }
:root[data-theme="dark"] .btn-danger { --btn-bg: #DC2626; --btn-bg-hover: #B91C1C; --btn-bg-active: #991B1B; }
.btn-danger-soft { --btn-bg: var(--c-danger-soft); --btn-bg-hover: var(--c-danger-soft-hover); --btn-bg-active: var(--c-danger-soft-hover); --btn-fg: var(--c-danger); }
.btn-soft { --btn-bg: var(--c-primary-soft); --btn-bg-hover: var(--c-primary-soft-2); --btn-bg-active: var(--c-primary-soft-2); --btn-fg: var(--c-primary-text); }
.btn-link { --btn-bg: transparent; --btn-bg-hover: transparent; --btn-bg-active: transparent; --btn-fg: var(--c-primary-text); padding-inline: var(--sp-1); height: auto; }
.btn-link:hover { text-decoration: underline !important; text-underline-offset: 3px; }

.btn-sm { height: var(--h-sm); padding-inline: var(--sp-3); font-size: 14px; border-radius: 10px; }
.btn-sm .icon { width: 18px; height: 18px; }
.btn-lg { height: var(--h-lg); padding-inline: var(--sp-5); font-size: 16px; }
.btn-block { width: 100%; }

.btn-icon { width: var(--h-md); padding: 0; }
.btn-icon.btn-sm { width: var(--h-sm); }
.btn-icon.btn-lg { width: var(--h-lg); }
@media (pointer: coarse) {
  .btn-icon.btn-sm { width: var(--touch); height: var(--touch); }
}

.btn:disabled, .btn[aria-disabled="true"] {
  --btn-bg: var(--c-surface-3) !important;
  --btn-bg-hover: var(--c-surface-3) !important;
  --btn-bg-active: var(--c-surface-3) !important;
  --btn-fg: var(--c-muted) !important;
  --btn-border: transparent !important;
  opacity: .75;
  cursor: not-allowed;
}
.btn[aria-busy="true"] { cursor: progress; pointer-events: none; }
.btn[aria-busy="true"] > .icon { display: none; }
.btn .spinner { --spinner-c: currentColor; }

.btn-group { display: inline-flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; }

/* ============================== Spinner ============================== */
.spinner {
  --spinner-c: var(--c-primary);
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--spinner-c) 25%, transparent);
  border-top-color: var(--spinner-c);
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================== Field ============================== */
.field { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.field-label {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-size: 14px; line-height: 22px; font-weight: 600; color: var(--c-text);
}
.field-label .req { color: var(--c-danger); font-weight: 700; }
.field-label .opt { color: var(--c-muted); font-weight: 400; font-size: 12px; }
.field-hint { font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--c-muted); }
.field-error {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--c-danger); font-weight: 500;
}
.field-error .icon { width: 16px; height: 16px; margin-top: 2px; }
.field-foot { display: flex; justify-content: space-between; gap: var(--sp-3); }
.field-counter { font-size: var(--fs-xs); color: var(--c-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.field-counter.is-over { color: var(--c-danger); font-weight: 600; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5) var(--sp-6); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 767px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.form-section + .form-section { margin-top: var(--sp-8); }
.form-section-title { font-size: 16px; font-weight: 700; margin-bottom: var(--sp-1); }
.form-section-desc { color: var(--c-muted); font-size: 13px; margin-bottom: var(--sp-5); }

.input {
  display: block;
  width: 100%;
  height: var(--h-md);
  padding-inline: 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 15px;
  line-height: 24px;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease, background-color var(--t-fast) ease;
  min-width: 0;
}
.input::placeholder { color: color-mix(in srgb, var(--c-muted) 85%, transparent); opacity: 1; }
.input:hover:not(:disabled):not(:focus) { border-color: var(--c-text-2); }
.input:focus, .input:focus-visible, .input.is-focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-focus) 60%, transparent);
  border-radius: var(--r-md);
}
.input[aria-invalid="true"] { border-color: var(--c-danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-danger) 22%, transparent); }
.input:disabled, .input[readonly].is-readonly { background: var(--c-surface-2); color: var(--c-muted); border-color: var(--c-border); cursor: not-allowed; }
.input-lg { height: var(--h-lg); }
.input-sm { height: var(--h-sm); font-size: 14px; border-radius: 10px; }
textarea.input { height: auto; min-height: 112px; padding-block: 10px; resize: vertical; line-height: 26px; }
.input.ltr, .input[dir="ltr"] { text-align: left; direction: ltr; }
.input.ltr::placeholder, .input[dir="ltr"]::placeholder { text-align: left; }
input[type="number"].input { -moz-appearance: textfield; }
input[type="number"].input::-webkit-outer-spin-button,
input[type="number"].input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="search"].input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ورودی با آیکن/پسوند */
.input-wrap { position: relative; display: flex; align-items: center; min-width: 0; }
.input-wrap > .input { flex: 1 1 auto; }
.input-wrap > .input-icon {
  position: absolute; inset-inline-start: 14px;
  color: var(--c-muted); pointer-events: none;
}
.input-wrap.has-icon > .input { padding-inline-start: 44px; }
.input-wrap > .input-end {
  position: absolute; inset-inline-end: 6px;
  display: flex; align-items: center; gap: 4px;
}
.input-wrap.has-end > .input { padding-inline-end: 48px; }
.input-wrap.has-addon > .input { padding-inline-end: 72px; }
/* ورودی LTR داخل محیط RTL: padding منطقی ورودی برعکس می‌شود، پس فیزیکی تنظیم می‌کنیم */
.input-wrap.has-icon > .input[dir="ltr"] { padding-left: 14px; padding-right: 44px; }
.input-wrap.has-end > .input[dir="ltr"] { padding-left: 48px; padding-right: 14px; }
.input-wrap.has-icon.has-end > .input[dir="ltr"] { padding-left: 48px; padding-right: 44px; }
.input-wrap.has-addon > .input[dir="ltr"] { padding-left: 72px; padding-right: 14px; }
.input-addon {
  position: absolute; inset-inline-end: 1px; top: 1px; bottom: 1px;
  display: flex; align-items: center; padding-inline: 14px;
  color: var(--c-muted); font-size: 13px; font-weight: 500;
  border-inline-start: 1px solid var(--c-border);
  border-start-end-radius: 11px; border-end-end-radius: 11px;
  background: var(--c-surface-2);
  pointer-events: none;
}
.input-clear { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--c-muted); }
.input-clear:hover { background: var(--c-surface-3); color: var(--c-text); }

/* OTP */
.otp { display: flex; gap: var(--sp-2); direction: ltr; justify-content: flex-start; }
.otp .input { width: 48px; height: 52px; padding: 0; text-align: center; font-size: 20px; font-weight: 700; }

/* ============================== Select / Combobox ============================== */
.select { position: relative; min-width: 0; }
.select-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  text-align: start; cursor: pointer;
}
.select-trigger .select-value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-trigger .select-value.is-placeholder { color: var(--c-muted); }
.select-trigger .icon { color: var(--c-muted); transition: transform var(--t-fast) ease; }
.select-trigger[aria-expanded="true"] .icon.chev { transform: rotate(180deg); }
.select-trigger .select-lead { color: var(--c-muted); }
.select.is-inline .select-trigger { /* انتخابگر فشرده در نوار ابزار */
  height: var(--h-md); border: 0; background: var(--c-surface-3); padding-inline: 14px 12px; font-weight: 500; font-size: 14px;
}
.select.is-inline .select-trigger:hover { background: var(--c-surface-3-hover); }
.select.is-inline.is-sm .select-trigger { height: var(--h-sm); border-radius: 10px; }

.listbox {
  position: fixed;
  z-index: var(--z-dropdown);
  min-width: 180px;
  max-width: min(420px, calc(100vw - 24px));
  max-height: 320px;
  display: flex; flex-direction: column;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  animation: pop-in var(--t-med) var(--ease);
}
.listbox-search { padding: 4px 4px 8px; border-bottom: 1px solid var(--c-divider); margin-bottom: 6px; }
.listbox-list { overflow-y: auto; overscroll-behavior: contain; }
.option {
  display: flex; align-items: center; gap: 10px;
  min-height: 40px; padding: 8px 12px; border-radius: 10px;
  cursor: pointer; font-size: 14px; color: var(--c-text);
}
.option .opt-check { width: 18px; height: 18px; color: var(--c-primary-text); visibility: hidden; }
.option[aria-selected="true"] { font-weight: 600; }
.option[aria-selected="true"] .opt-check { visibility: visible; }
.option.is-active { background: var(--c-surface-2); }
.option:hover { background: var(--c-surface-2); }
.option[aria-disabled="true"] { color: var(--c-muted); cursor: not-allowed; }
.option .opt-icon { color: var(--c-muted); }
.option .opt-desc { display: block; font-size: 12px; color: var(--c-muted); font-weight: 400; line-height: 18px; }
.listbox-empty, .listbox-loading { padding: 14px 12px; color: var(--c-muted); font-size: 13px; display: flex; gap: 8px; align-items: center; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ============================== Checkbox / Radio ============================== */
.check {
  display: inline-flex; align-items: flex-start; gap: 10px;
  cursor: pointer; font-size: 14px; line-height: 22px; user-select: none; min-width: 0;
}
.check > span { min-width: 0; }
.check .check-desc { display: block; color: var(--c-muted); font-size: 12px; line-height: 20px; }
.check.is-disabled { color: var(--c-muted); cursor: not-allowed; }
.cb, .rb {
  appearance: none; -webkit-appearance: none;
  flex-shrink: 0;
  width: 20px; height: 20px; margin: 1px 0 0;
  border: 1.5px solid var(--c-border-strong);
  background: var(--c-surface) no-repeat center / 14px 14px;
  cursor: pointer;
  transition: background-color var(--t-fast) ease, border-color var(--t-fast) ease;
}
.cb { border-radius: 6px; }
.rb { border-radius: 50%; }
.cb:hover:not(:disabled), .rb:hover:not(:disabled) { border-color: var(--c-primary); }
.cb:checked, .cb:indeterminate { background-color: var(--c-primary); border-color: var(--c-primary); }
.cb:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }
.cb:indeterminate { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E"); }
.rb:checked { border-color: var(--c-primary); border-width: 6px; }
.cb:disabled, .rb:disabled { background-color: var(--c-surface-2); border-color: var(--c-border); cursor: not-allowed; }
.cb:disabled:checked, .cb:disabled:indeterminate { background-color: var(--c-border-strong); border-color: var(--c-border-strong); }
.cb:focus-visible, .rb:focus-visible { outline-offset: 2px; }
.cb[aria-invalid="true"] { border-color: var(--c-danger); }
.choice-group { display: flex; flex-direction: column; gap: var(--sp-3); }
.choice-group.is-row { flex-direction: row; flex-wrap: wrap; gap: var(--sp-3) var(--sp-6); }

/* کارت‌انتخاب (radio card) */
.choice-card {
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border: 1px solid var(--c-border); border-radius: var(--r-lg);
  background: var(--c-surface); cursor: pointer;
  transition: border-color var(--t-fast) ease, background-color var(--t-fast) ease;
}
.choice-card:hover { border-color: var(--c-border-strong); }
.choice-card:has(input:checked) { border-color: var(--c-primary); background: var(--c-primary-soft); }
.choice-card:has(input:focus-visible) { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.choice-card input:focus-visible { outline: none; }
.choice-card strong { display: block; font-size: 14px; }
.choice-card small { display: block; color: var(--c-muted); font-size: 12px; line-height: 20px; }

/* ============================== Switch ============================== */
.switch-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.switch-row .switch-text { flex: 1 1 auto; min-width: 0; }
.switch-row .switch-text strong { display: block; font-size: 14px; font-weight: 600; }
.switch-row .switch-text small { display: block; color: var(--c-muted); font-size: 12px; line-height: 20px; }
.switch-state { font-size: 12px; color: var(--c-muted); min-width: 40px; }
.switch {
  position: relative; flex-shrink: 0;
  width: 44px; height: 24px;
  border-radius: var(--r-full);
  background: var(--c-border-strong);
  transition: background-color var(--t-med) var(--ease);
}
.switch::after {
  content: "";
  position: absolute; top: 2px; inset-inline-start: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .25);
  transition: inset-inline-start var(--t-med) var(--ease);
}
.switch[aria-checked="true"] { background: var(--c-primary); }
.switch[aria-checked="true"]::after { inset-inline-start: 22px; }
.switch:disabled { opacity: .5; }
.switch[aria-busy="true"]::after { animation: pulse 1s ease-in-out infinite; }
.switch:focus-visible { border-radius: var(--r-full); }
.switch-sm { width: 36px; height: 20px; }
.switch-sm::after { width: 16px; height: 16px; }
.switch-sm[aria-checked="true"]::after { inset-inline-start: 18px; }
@keyframes pulse { 50% { opacity: .55; } }

/* ============================== Tabs / Segmented ============================== */
.tabs {
  display: flex; gap: var(--sp-1);
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding-inline: 14px;
  color: var(--c-muted); font-weight: 600; font-size: 14px; white-space: nowrap;
  border-radius: 10px 10px 0 0;
  transition: color var(--t-fast) ease;
}
.tab:hover { color: var(--c-text); }
.tab[aria-selected="true"] { color: var(--c-primary-text); }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; inset-inline: 10px; bottom: -1px; height: 2px;
  border-radius: 2px 2px 0 0; background: var(--c-primary);
}
.tab .tab-count {
  min-width: 22px; height: 20px; padding-inline: 6px; border-radius: var(--r-full);
  background: var(--c-surface-3); color: var(--c-text-2); font-size: 11px; display: inline-grid; place-items: center;
}
.tab[aria-selected="true"] .tab-count { background: var(--c-primary-soft); color: var(--c-primary-text); }
.tab-panel:focus-visible { outline-offset: 4px; }

.segmented {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--c-surface-3); border-radius: var(--r-md);
}
.seg {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; min-width: 36px; padding-inline: 12px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--c-text-2);
  transition: background-color var(--t-fast) ease, color var(--t-fast) ease;
}
.seg:hover { background: color-mix(in srgb, var(--c-surface) 60%, transparent); }
.seg[aria-pressed="true"], .seg[aria-checked="true"] { background: var(--c-primary); color: var(--c-on-primary); }
.segmented.is-quiet .seg[aria-pressed="true"], .segmented.is-quiet .seg[aria-checked="true"] { background: var(--c-surface); color: var(--c-text); box-shadow: 0 1px 2px rgba(15,23,42,.08); }
.seg.is-icon { padding: 0; width: 36px; }
.segmented.is-lg .seg { height: 44px; min-width: 44px; }
.segmented.is-lg .seg.is-icon { width: 44px; }

/* ============================== Badge / Chip ============================== */
.badge {
  --b-bg: var(--c-surface-3); --b-fg: var(--c-text-2); --b-bd: transparent;
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding-inline: 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--b-bd);
  background: var(--b-bg); color: var(--b-fg);
  font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap;
}
.badge .icon { width: 14px; height: 14px; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { --b-bg: var(--c-success-soft); --b-fg: var(--c-success); --b-bd: var(--c-success-border); }
.badge-warning { --b-bg: var(--c-warning-soft); --b-fg: var(--c-warning); --b-bd: var(--c-warning-border); }
.badge-danger { --b-bg: var(--c-danger-soft); --b-fg: var(--c-danger); --b-bd: var(--c-danger-border); }
.badge-info, .badge-primary { --b-bg: var(--c-info-soft); --b-fg: var(--c-info); --b-bd: var(--c-info-border); }
.badge-purple { --b-bg: var(--c-folder-soft); --b-fg: #5B54C9; --b-bd: color-mix(in srgb, var(--c-folder) 40%, transparent); }
:root[data-theme="dark"] .badge-purple { --b-fg: #C4C0FF; }
.badge-sm { height: 22px; padding-inline: 8px; font-size: 11px; }

.count {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px; padding-inline: 6px;
  border-radius: var(--r-full);
  background: var(--c-primary); color: var(--c-on-primary);
  font-size: 11px; font-weight: 700; line-height: 1;
}
.count-danger { background: var(--c-danger); color: #fff; }

.trend {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding-inline: 8px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 700; border: 1px solid;
}
.trend .icon { width: 14px; height: 14px; }
.trend-up { color: var(--c-success); background: var(--c-success-soft); border-color: var(--c-success-border); }
.trend-down { color: var(--c-danger); background: var(--c-danger-soft); border-color: var(--c-danger-border); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px; padding-inline: 12px 6px;
  border-radius: var(--r-full);
  background: var(--c-primary-soft); color: var(--c-primary-text);
  font-size: 13px; font-weight: 600;
  max-width: 100%;
}
.chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-remove { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: inherit; }
.chip-remove:hover { background: color-mix(in srgb, var(--c-primary) 18%, transparent); }
.chip-remove .icon { width: 14px; height: 14px; }
.chip.is-neutral { background: var(--c-surface-3); color: var(--c-text-2); }

/* Tags input */
.tags-input {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: var(--h-md); padding: 6px 8px;
  border: 1px solid var(--c-border-strong); border-radius: var(--r-md);
  background: var(--c-surface); cursor: text;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
.tags-input:focus-within { border-color: var(--c-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-focus) 60%, transparent); }
.tags-input input { flex: 1 1 100px; min-width: 80px; border: 0; outline: 0; background: transparent; height: 30px; padding-inline: 6px; font-size: 14px; }

/* ============================== Card ============================== */
.card {
  background: var(--c-surface);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  min-width: 0;
  box-shadow: var(--shadow-card);
}
:root[data-theme="dark"] .card { border: 1px solid var(--c-border); }
.card-compact { padding: var(--sp-4); border-radius: var(--r-lg); }
.card-flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  margin-bottom: var(--sp-4); min-width: 0; flex-wrap: wrap;
}
.card-title { font-size: 18px; line-height: 28px; font-weight: 700; }
.card-sub { font-size: 13px; line-height: 22px; color: var(--c-muted); }
.card-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.card-foot { margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--c-divider); display: flex; gap: var(--sp-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.card-outline { box-shadow: none; border: 1px solid var(--c-border); }

/* Stat card */
.stat { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat-label { color: var(--c-muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.stat-value { font-size: 26px; line-height: 38px; font-weight: 700; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.stat-value .unit { font-size: 13px; color: var(--c-muted); font-weight: 500; }
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--c-primary-soft); color: var(--c-primary-text);
}
.stat-icon.is-purple { background: var(--c-folder-soft); color: #5B54C9; }
.stat-icon.is-green { background: var(--c-success-soft); color: var(--c-success); }
.stat-icon.is-orange { background: var(--c-warning-soft); color: var(--c-warning); }
:root[data-theme="dark"] .stat-icon.is-purple { color: #C4C0FF; }

/* ============================== Table ============================== */
.table-wrap {
  position: relative;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}
.table { width: 100%; font-size: var(--fs-sm); line-height: var(--lh-sm); }
.table th {
  height: 44px; padding: 0 16px;
  text-align: start; white-space: nowrap;
  color: var(--c-muted); font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}
.table td {
  height: 60px; padding: 10px 16px;
  border-bottom: 1px solid var(--c-divider);
  vertical-align: middle;
}
.table tbody tr { transition: background-color var(--t-fast) ease; }
.table tbody tr:hover { background: var(--c-surface-2); }
.table tbody tr[aria-selected="true"] { background: var(--c-primary-soft); }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .is-num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .is-center { text-align: center; }
.table .col-check { width: 52px; padding-inline-end: 0; }
.table .col-actions { width: 64px; text-align: end; }
.table .cell-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.table .cell-main strong { font-weight: 600; display: block; }
.table .cell-main small { display: block; color: var(--c-muted); font-size: 12px; line-height: 18px; }
.table.is-compact td { height: 48px; padding-block: 6px; }
.table-sticky th { position: sticky; top: 0; z-index: 1; }

.th-sort {
  display: inline-flex; align-items: center; gap: 4px;
  height: 32px; padding-inline: 6px; margin-inline: -6px;
  border-radius: 8px; color: inherit; font-weight: inherit; white-space: nowrap;
}
.th-sort:hover { background: var(--c-surface-3); color: var(--c-text); }
.th-sort .icon { width: 15px; height: 15px; opacity: .45; }
th[aria-sort="ascending"] .th-sort, th[aria-sort="descending"] .th-sort { color: var(--c-primary-text); }
th[aria-sort="ascending"] .th-sort .icon, th[aria-sort="descending"] .th-sort .icon { opacity: 1; }
.table .is-num .th-sort { flex-direction: row; }

.bulk-bar {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: var(--sp-3);
  background: var(--c-primary-soft); border: 1px solid var(--c-info-border);
  border-radius: var(--r-lg); color: var(--c-primary-text); font-weight: 600; font-size: 14px;
  animation: pop-in var(--t-med) var(--ease);
}
.bulk-bar .spacer { flex: 1; }

.table-state { padding: var(--sp-10) var(--sp-6); }

/* ============================== Pagination ============================== */
.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3) var(--sp-4);
  flex-wrap: wrap; padding-top: var(--sp-4);
}
.pagination-info { color: var(--c-muted); font-size: 13px; display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.pagination-nav { display: flex; align-items: center; gap: 4px; }
.page-btn {
  min-width: 36px; height: 36px; padding-inline: 10px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  font-size: 14px; font-weight: 600; color: var(--c-text-2);
  font-variant-numeric: tabular-nums;
}
.page-btn:hover:not(:disabled) { background: var(--c-surface-3); }
.page-btn[aria-current="page"] { background: var(--c-primary); color: var(--c-on-primary); }
.page-btn:disabled { color: var(--c-border-strong); }
.page-btn .icon { width: 18px; height: 18px; }
.page-gap { min-width: 24px; text-align: center; color: var(--c-muted); }
@media (pointer: coarse) { .page-btn { min-width: 44px; height: 44px; } }

/* ============================== Breadcrumb ============================== */
.breadcrumb ol { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 13px; color: var(--c-muted); }
.breadcrumb li { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.breadcrumb li + li::before {
  content: ""; width: 14px; height: 14px; flex-shrink: 0;
  background: currentColor; opacity: .7;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 18-6-6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 18-6-6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.breadcrumb a, .breadcrumb button { color: var(--c-muted); border-radius: 6px; padding: 2px 4px; margin: -2px -4px; }
.breadcrumb a:hover, .breadcrumb button:hover { color: var(--c-primary-text); text-decoration: none; background: var(--c-surface-3); }
.breadcrumb [aria-current="page"] { color: var(--c-text); font-weight: 600; }

/* ============================== Avatar ============================== */
.avatar {
  --av: 40px;
  position: relative;
  width: var(--av); height: var(--av); flex-shrink: 0;
  border-radius: var(--r-md);
  display: inline-grid; place-items: center;
  background: var(--c-primary-soft); color: var(--c-primary-text);
  font-weight: 700; font-size: calc(var(--av) * .42); line-height: 1;
  overflow: hidden; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { --av: 32px; border-radius: 10px; }
.avatar-xs { --av: 24px; border-radius: 7px; font-size: 11px; }
.avatar-lg { --av: 56px; border-radius: var(--r-lg); }
.avatar-xl { --av: 80px; border-radius: 20px; }
.avatar.is-round { border-radius: 50%; }
.avatar[data-tone="1"] { background: #E7F6EE; color: #137A43; }
.avatar[data-tone="2"] { background: #EFEEFE; color: #5B54C9; }
.avatar[data-tone="3"] { background: #FDEBF4; color: #B4236C; }
.avatar[data-tone="4"] { background: #FFF1E6; color: #A84B0C; }
:root[data-theme="dark"] .avatar[data-tone="1"] { background: rgba(34,197,94,.16); color: #6EE7A0; }
:root[data-theme="dark"] .avatar[data-tone="2"] { background: rgba(150,144,244,.18); color: #C4C0FF; }
:root[data-theme="dark"] .avatar[data-tone="3"] { background: rgba(236,72,153,.16); color: #F9A8D4; }
:root[data-theme="dark"] .avatar[data-tone="4"] { background: rgba(249,115,22,.16); color: #FDBA74; }
.avatar-status { position: absolute; bottom: -2px; inset-inline-end: -2px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--c-surface); background: var(--c-success); }
.avatar-group { display: inline-flex; }
.avatar-group .avatar { border: 2px solid var(--c-surface); }
.avatar-group .avatar + .avatar { margin-inline-start: -10px; }

/* ============================== Alert / Banner ============================== */
.alert {
  --a-bg: var(--c-info-soft); --a-fg: var(--c-info); --a-bd: var(--c-info-border);
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: var(--r-lg);
  background: var(--a-bg); border: 1px solid var(--a-bd); color: var(--c-text);
  font-size: 14px; line-height: 24px;
}
.alert > .icon { color: var(--a-fg); margin-top: 2px; }
.alert-body { flex: 1 1 auto; min-width: 0; }
.alert-title { font-weight: 700; color: var(--c-text); }
.alert-text { color: var(--c-text-2); }
.alert-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); flex-wrap: wrap; }
.alert-success { --a-bg: var(--c-success-soft); --a-fg: var(--c-success); --a-bd: var(--c-success-border); }
.alert-warning { --a-bg: var(--c-warning-soft); --a-fg: var(--c-warning); --a-bd: var(--c-warning-border); }
.alert-danger { --a-bg: var(--c-danger-soft); --a-fg: var(--c-danger); --a-bd: var(--c-danger-border); }
.alert-close { width: 32px; height: 32px; margin: -4px; border-radius: 8px; display: grid; place-items: center; color: var(--c-muted); }
.alert-close:hover { background: color-mix(in srgb, var(--a-fg) 12%, transparent); color: var(--c-text); }

.demo-flag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding-inline: 8px; border-radius: 6px;
  background: var(--c-warning-soft); color: var(--c-warning); border: 1px dashed var(--c-warning-border);
  font-size: 11px; font-weight: 700;
}

/* ============================== Toast ============================== */
.toast-region {
  position: fixed; z-index: var(--z-toast);
  bottom: 24px; inset-inline-end: 24px;
  display: flex; flex-direction: column-reverse; gap: 10px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  position: relative; overflow: hidden;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  background: var(--c-surface); color: var(--c-text);
  border: 1px solid var(--c-border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  animation: toast-in var(--t-slow) var(--ease);
}
.toast.is-leaving { animation: toast-out var(--t-med) ease forwards; }
.toast > .icon { margin-top: 2px; }
.toast-success > .icon { color: var(--c-success); }
.toast-error > .icon { color: var(--c-danger); }
.toast-warning > .icon { color: var(--c-warning); }
.toast-info > .icon { color: var(--c-info); }
.toast-error { border-color: var(--c-danger-border); }
.toast-body { flex: 1; min-width: 0; font-size: 14px; line-height: 24px; }
.toast-title { font-weight: 700; }
.toast-msg { color: var(--c-text-2); font-size: 13px; line-height: 22px; }
.toast-actions { display: flex; gap: 8px; margin-top: 6px; }
.toast-close { font-size: 13px; font-weight: 600; color: var(--c-muted); display: inline-flex; align-items: center; gap: 4px; height: 28px; padding-inline: 8px; border-radius: 8px; white-space: nowrap; }
.toast-close:hover { background: var(--c-surface-3); color: var(--c-text); }
.toast-timer { position: absolute; bottom: 0; inset-inline-start: 0; height: 3px; background: var(--c-success); transform-origin: right center; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (max-width: 767px) {
  .toast-region { inset-inline: 16px; bottom: 16px; width: auto; }
}

/* ============================== Overlay: Backdrop / Modal / Drawer ============================== */
.backdrop {
  position: fixed; inset: 0; z-index: var(--z-backdrop);
  background: var(--backdrop);
  animation: fade-in var(--t-med) ease;
}
.backdrop.is-leaving { animation: fade-out var(--t-med) ease forwards; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

.modal-layer {
  position: fixed; inset: 0; z-index: var(--z-dialog);
  display: grid; place-items: center;
  padding: 16px; overflow-y: auto;
}
.modal {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: var(--c-surface); color: var(--c-text);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-pop-lg);
  animation: modal-in var(--t-slow) var(--ease);
}
:root[data-theme="dark"] .modal { border: 1px solid var(--c-border); }
.modal.is-leaving { animation: modal-out var(--t-med) ease forwards; }
.modal-sm { width: min(420px, 100%); }
.modal-lg { width: min(720px, 100%); }
.modal-xl { width: min(980px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 24px 24px 8px; }
.modal-head .modal-icon { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; flex-shrink: 0; background: var(--c-primary-soft); color: var(--c-primary-text); }
.modal-head .modal-icon.is-danger { background: var(--c-danger-soft); color: var(--c-danger); }
.modal-head .modal-icon.is-warning { background: var(--c-warning-soft); color: var(--c-warning); }
.modal-titles { flex: 1; min-width: 0; padding-top: 6px; }
.modal-title { font-size: 20px; line-height: 30px; font-weight: 700; }
.modal-desc { color: var(--c-muted); font-size: 14px; margin-top: 2px; }
.modal-close { width: 40px; height: 40px; margin: -2px -8px 0 0; border-radius: 10px; display: grid; place-items: center; color: var(--c-muted); flex-shrink: 0; }
.modal-close:hover { background: var(--c-surface-3); color: var(--c-text); }
.modal-body { padding: 12px 24px 8px; overflow-y: auto; overscroll-behavior: contain; font-size: 15px; line-height: 26px; color: var(--c-text-2); }
.modal-body > p + p { margin-top: 4px; }
.modal-foot { display: flex; align-items: center; gap: 12px; padding: 16px 24px 24px; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes modal-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@media (max-width: 599px) {
  .modal-layer { place-items: end center; padding: 0; }
  .modal, .modal-sm, .modal-lg, .modal-xl { width: 100%; border-radius: var(--r-2xl) var(--r-2xl) 0 0; max-height: 92vh; max-height: 92dvh; animation-name: sheet-in; }
  .modal.is-leaving { animation-name: sheet-out; }
  .modal-foot { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; }
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { to { transform: translateY(100%); } }

.drawer {
  position: fixed; z-index: var(--z-dialog);
  top: 0; bottom: 0; inset-inline-end: 0;
  width: min(480px, 100vw);
  display: flex; flex-direction: column;
  background: var(--c-surface);
  box-shadow: var(--shadow-pop-lg);
  animation: drawer-in-end var(--t-slow) var(--ease);
}
:root[data-theme="dark"] .drawer { border-inline-start: 1px solid var(--c-border); }
.drawer.is-start { inset-inline-end: auto; inset-inline-start: 0; animation-name: drawer-in-start; }
.drawer.is-leaving { animation: drawer-out-end var(--t-med) ease forwards; }
.drawer.is-start.is-leaving { animation-name: drawer-out-start; }
.drawer-lg { width: min(640px, 100vw); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--c-divider); }
.drawer-title { font-size: 18px; line-height: 28px; font-weight: 700; flex: 1; min-width: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px; overscroll-behavior: contain; }
.drawer-foot { display: flex; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--c-divider); flex-wrap: wrap; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
/* در RTL: «end» = چپ و «start» = راست */
@keyframes drawer-in-end { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes drawer-out-end { to { transform: translateX(-100%); } }
@keyframes drawer-in-start { from { transform: translateX(100%); } to { transform: none; } }
@keyframes drawer-out-start { to { transform: translateX(100%); } }

/* ============================== Menu / Popover / Tooltip ============================== */
.menu, .popover {
  position: fixed; z-index: var(--z-dropdown);
  background: var(--c-surface); color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  animation: pop-in var(--t-med) var(--ease);
}
.menu { min-width: 220px; max-width: calc(100vw - 24px); padding: 6px; }
.menu.is-leaving, .popover.is-leaving, .listbox.is-leaving { animation: fade-out var(--t-fast) ease forwards; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 40px; padding: 8px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 500; color: var(--c-text); text-align: start;
  text-decoration: none !important; white-space: nowrap;
}
.menu-item .icon { color: var(--c-muted); width: 20px; height: 20px; }
.menu-item:hover, .menu-item:focus-visible, .menu-item.is-active { background: var(--c-surface-2); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--c-focus); }
.menu-item.is-danger, .menu-item.is-danger .icon { color: var(--c-danger); }
.menu-item.is-danger:hover { background: var(--c-danger-soft); }
.menu-item[aria-disabled="true"] { color: var(--c-muted); cursor: not-allowed; }
.menu-item[aria-disabled="true"]:hover { background: transparent; }
.menu-item .menu-kbd { margin-inline-start: auto; color: var(--c-muted); font-size: 12px; }
.menu-sep { height: 1px; background: var(--c-divider); margin: 6px 4px; }
.menu-label { padding: 8px 12px 4px; font-size: 12px; color: var(--c-muted); font-weight: 600; }
.popover { padding: 16px; max-width: calc(100vw - 24px); }

.tooltip {
  position: fixed; z-index: var(--z-tooltip);
  max-width: 260px;
  padding: 6px 10px; border-radius: 8px;
  background: var(--chart-tooltip-bg); color: var(--chart-tooltip-text);
  font-size: 12px; line-height: 20px; font-weight: 500;
  pointer-events: none;
  animation: fade-in var(--t-fast) ease;
  white-space: normal;
}

/* ============================== Progress ============================== */
.progress { position: relative; height: 8px; border-radius: var(--r-full); background: var(--c-surface-3); overflow: hidden; }
.progress-bar { height: 100%; border-radius: inherit; background: var(--c-primary); width: 0; transition: width var(--t-med) ease; }
.progress-sm { height: 4px; }
.progress.is-success .progress-bar { background: var(--c-success); }
.progress.is-danger .progress-bar { background: var(--c-danger); }
.progress.is-warning .progress-bar { background: #F59E0B; }
.progress.is-indeterminate .progress-bar { width: 35%; position: absolute; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { inset-inline-start: -35%; } to { inset-inline-start: 100%; } }

.ring { --p: 0; --c: var(--c-primary); width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--c-surface-3) 0); }
.ring > span { width: 44px; height: 44px; border-radius: 50%; background: var(--c-surface); display: grid; place-items: center; font-size: 12px; font-weight: 700; }

/* ============================== Skeleton ============================== */
.skeleton {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--c-surface-3) 0%, var(--c-surface-2) 50%, var(--c-surface-3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-text { height: 12px; border-radius: 6px; }
.skeleton-circle { border-radius: 50%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ============================== Empty / Error state ============================== */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 8px; padding: 48px 24px; min-height: 240px;
}
.empty-icon {
  width: 64px; height: 64px; border-radius: 20px; margin-bottom: 8px;
  display: grid; place-items: center;
  background: var(--c-surface-2); color: var(--c-muted);
}
.empty-icon .icon { width: 28px; height: 28px; }
.empty-icon.is-danger { background: var(--c-danger-soft); color: var(--c-danger); }
.empty-icon.is-primary { background: var(--c-primary-soft); color: var(--c-primary-text); }
.empty-title { font-size: 17px; line-height: 28px; font-weight: 700; color: var(--c-text); }
.empty-text { color: var(--c-muted); font-size: 14px; max-width: 380px; }
.empty-actions { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }

/* ============================== Dropzone / Upload queue ============================== */
.dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 32px 20px; text-align: center;
  border: 2px dashed var(--c-border-strong); border-radius: var(--r-lg);
  background: var(--c-surface-2);
  transition: border-color var(--t-fast) ease, background-color var(--t-fast) ease;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--c-primary); }
.dropzone.is-over { border-color: var(--c-primary); background: var(--c-primary-soft); }
.dropzone-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--c-surface); color: var(--c-primary-text); box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.dropzone-title { font-weight: 700; font-size: 15px; color: var(--c-text); }
.dropzone-hint { font-size: 12px; color: var(--c-muted); }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.uq { display: flex; flex-direction: column; gap: 10px; }
.uq-item {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px; border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface);
}
.uq-item.is-error { border-color: var(--c-danger-border); background: var(--c-danger-soft); }
.uq-item.is-done { border-color: var(--c-success-border); }
.uq-name { font-weight: 600; font-size: 14px; }
.uq-meta { font-size: 12px; color: var(--c-muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.uq-meta .t-danger { font-weight: 600; }
.uq-item .progress { margin-top: 6px; }

/* ============================== File-type icon ============================== */
.ftype {
  --ft: var(--c-primary);
  position: relative; width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--ft) 12%, var(--c-surface));
  color: var(--ft);
}
.ftype .icon { width: 20px; height: 20px; }
.ftype-pdf { --ft: #D92D20; }
.ftype-doc { --ft: #2563EB; }
.ftype-xls { --ft: #15803D; }
.ftype-ppt { --ft: #EA580C; }
.ftype-img { --ft: #8B5CF6; }
.ftype-zip { --ft: #657184; }
.ftype-folder { --ft: var(--c-folder); }

/* ============================== Date picker ============================== */
.dp { width: 312px; padding: 12px; }
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.dp-title { font-weight: 700; font-size: 15px; }
.dp-nav { display: flex; gap: 4px; }
.dp-week, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-week span { height: 32px; display: grid; place-items: center; font-size: 12px; color: var(--c-muted); font-weight: 600; }
.dp-day {
  height: 38px; border-radius: 10px; display: grid; place-items: center;
  font-size: 14px; font-variant-numeric: tabular-nums; color: var(--c-text);
}
.dp-day:hover:not(:disabled) { background: var(--c-surface-3); }
.dp-day.is-out { color: var(--c-border-strong); }
.dp-day.is-today { box-shadow: inset 0 0 0 1.5px var(--c-primary); font-weight: 700; }
.dp-day.is-friday { color: var(--c-danger); }
.dp-day.in-range { background: var(--c-primary-soft); border-radius: 0; }
.dp-day.is-selected, .dp-day.is-start, .dp-day.is-end { background: var(--c-primary) !important; color: var(--c-on-primary) !important; border-radius: 10px; }
.dp-day:disabled { color: var(--c-border); cursor: not-allowed; }
.dp-foot { display: flex; gap: 8px; justify-content: space-between; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--c-divider); }
.dp-error { margin-top: 8px; }
.dp-range { display: flex; gap: 0; }
.dp-presets { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-inline-end: 1px solid var(--c-divider); min-width: 150px; }
.dp-presets button { text-align: start; height: 36px; padding-inline: 12px; border-radius: 10px; font-size: 14px; font-weight: 500; }
.dp-presets button:hover { background: var(--c-surface-2); }
.dp-presets button[aria-pressed="true"] { background: var(--c-primary-soft); color: var(--c-primary-text); font-weight: 700; }
@media (max-width: 599px) {
  .dp-range { flex-direction: column; }
  .dp-presets { flex-direction: row; flex-wrap: wrap; border-inline-end: 0; border-bottom: 1px solid var(--c-divider); }
  .dp { width: 100%; }
}

/* ============================== Misc: Kbd, Divider, Accordion, Steps, Timeline ============================== */
kbd, .kbd {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px; padding-inline: 6px;
  border-radius: 6px; border: 1px solid var(--c-border); border-bottom-width: 2px;
  background: var(--c-surface-2); color: var(--c-text-2);
  font-family: var(--font); font-size: 11px; font-weight: 600; direction: ltr;
}
.divider { height: 1px; background: var(--c-divider); margin-block: var(--sp-5); }
.divider-v { width: 1px; align-self: stretch; background: var(--c-divider); }

.accordion { border: 1px solid var(--c-border); border-radius: var(--r-lg); overflow: hidden; }
.accordion details + details { border-top: 1px solid var(--c-border); }
.accordion summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; cursor: pointer; font-weight: 600; list-style: none;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary:hover { background: var(--c-surface-2); }
.accordion summary .icon { color: var(--c-muted); transition: transform var(--t-med) var(--ease); }
.accordion details[open] summary .icon { transform: rotate(180deg); }
.accordion .acc-body { padding: 0 18px 16px; color: var(--c-text-2); }

.steps { display: flex; gap: 8px; counter-reset: step; }
.step { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.step-bar { height: 4px; border-radius: 4px; background: var(--c-surface-3); }
.step.is-done .step-bar, .step.is-current .step-bar { background: var(--c-primary); }
.step-label { font-size: 12px; color: var(--c-muted); display: flex; gap: 6px; align-items: center; }
.step.is-current .step-label { color: var(--c-text); font-weight: 700; }
.step.is-done .step-label { color: var(--c-text-2); }

.timeline { display: flex; flex-direction: column; }
.tl-item { position: relative; display: flex; gap: 14px; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; inset-inline-start: 11px; top: 26px; bottom: 2px; width: 2px; background: var(--c-divider); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--c-surface-3); color: var(--c-muted); }
.tl-dot .icon { width: 14px; height: 14px; }
.tl-item.is-done .tl-dot { background: var(--c-success-soft); color: var(--c-success); }
.tl-item.is-current .tl-dot { background: var(--c-primary); color: #fff; }
.tl-body { min-width: 0; padding-top: 1px; }
.tl-title { font-weight: 600; font-size: 14px; }
.tl-meta { color: var(--c-muted); font-size: 12px; }

.desc-list { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 10px 16px; font-size: 14px; }
.desc-list dt { color: var(--c-muted); }
.desc-list dd { color: var(--c-text); font-weight: 500; min-width: 0; overflow-wrap: break-word; }

.code-block {
  position: relative;
  direction: ltr; text-align: left;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 20px;
  background: #0F172A; color: #E2E8F0;
  border-radius: var(--r-md); padding: 14px 16px;
  overflow-x: auto; white-space: pre; margin: 0;
}
.code-copy { position: absolute; top: 8px; right: 8px; }

/* ============================== جدول: جلوگیری از شکستن حرف‌به‌حرف کلمات فارسی ==============================
   جدول عرض طبیعی خودش را می‌گیرد و در wrapper مستقل اسکرول افقی می‌خورد (طبق سند، صفحه ۱۶) */
.table { min-width: 640px; overflow-wrap: normal; word-break: normal; }
.table.is-compact, .chart-data-table .table { min-width: 0; }
.table th, .table td { white-space: nowrap; }
.table td .cell-main { min-width: 220px; }
.table td .cell-main > span, .table td .cell-main > a, .table td .cell-main > button { min-width: 0; white-space: normal; }
.table td .cell-main strong, .table td .cell-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.table td .badge { white-space: nowrap; }
.table-wrap { scrollbar-gutter: stable; }

/* ستون‌های کم‌اهمیت در عرض کمتر حذف می‌شوند تا ستون‌های اصلی (نام، وضعیت، مبلغ، عملیات) دیده شوند */
@media (max-width: 1279px) { .table .hide-md { display: none; } }
@media (max-width: 767px) { .table .hide-sm { display: none; } .table td .cell-main { min-width: 180px; } }
@media (max-width: 1279px) {
  .table th, .table td { padding-inline: 8px; }
  .table td .cell-main { min-width: 0; gap: 10px; }
  .table td .cell-main strong, .table td .cell-main small { max-width: 140px; }
  .table .pthumb { width: 36px; height: 36px; }
  .table .pthumb svg { width: 30px; height: 30px; }
  .table .col-actions { width: 52px; }
  .table td .row > .avatar-xs { display: none; }
}

/* ============================== جدول در موبایل: هر ردیف یک کارت ==============================
   برچسب ستون از data-label خوانده می‌شود؛ ستون اصلی بالای کارت، انتخاب و عملیات در گوشه‌ها */
@media (max-width: 767px) {
  .table-wrap:has(> .table.is-stackable) { overflow: visible; }
  .table.is-stackable { min-width: 0; }
  .table.is-stackable thead { display: none; }
  .table.is-stackable, .table.is-stackable tbody, .table.is-stackable tr, .table.is-stackable td { display: block; width: 100%; }
  .table.is-stackable tbody tr {
    position: relative; padding: 12px 14px; margin-bottom: 10px;
    border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface);
  }
  .table.is-stackable tbody tr:has(> .col-check) { padding-inline-start: 46px; }
  .table.is-stackable tbody tr[aria-selected="true"] { border-color: var(--c-primary); background: var(--c-primary-soft); }
  .table.is-stackable td, .table.is-stackable td.hide-md, .table.is-stackable td.hide-sm {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    height: auto; padding: 5px 0; border: 0; white-space: normal; text-align: start;
  }
  .table.is-stackable td::before { content: attr(data-label); color: var(--c-muted); font-size: 12px; font-weight: 500; flex-shrink: 0; }
  .table.is-stackable td.td-main { padding: 0 0 10px; margin-bottom: 4px; border-bottom: 1px solid var(--c-divider); padding-inline-end: 40px; }
  .table.is-stackable td.td-main::before, .table.is-stackable td.col-check::before, .table.is-stackable td.col-actions::before { content: none; }
  .table.is-stackable td.col-check { position: absolute; top: 14px; inset-inline-start: 12px; width: auto; padding: 0; }
  .table.is-stackable td.col-actions { position: absolute; top: 8px; inset-inline-end: 6px; width: auto; padding: 0; }
  .table.is-stackable td .cell-main { min-width: 0; }
  .table.is-stackable td .cell-main strong, .table.is-stackable td .cell-main small { max-width: none; white-space: normal; }
  .table.is-stackable tbody tr:last-child td { border-bottom: 0; }
  .table.is-stackable tbody tr:last-child td.td-main { border-bottom: 1px solid var(--c-divider); }
  .bulk-bar { position: sticky; top: 84px; z-index: 5; }
}
@media (max-width: 767px) { .table.is-stackable .date-cell { display: inline-flex; gap: 8px; align-items: baseline; } .table.is-stackable .date-cell small { display: inline; } }
