/* تم داشبورد مطالبات — بازسازی ظاهر نسخه Lovable (راست‌چین، فونت وزیرمتن) */
:root {
  --radius: 0.625rem;
  --background: #f4f7f9;
  --foreground: #1e293b;
  --surface: #eef2f5;
  --card: #ffffff;
  --primary: #0e7490;
  --primary-fg: #ffffff;
  --muted: #f1f5f9;
  --muted-fg: #64748b;
  --accent: #f1f5f9;
  --border: #e2e8f0;
  --ring: #94a3b8;
  --success: #15803d;
  --success-bg: #dcfce7;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
}

* { box-sizing: border-box; }

/* المنت‌های مخفی (مودال، سایدبار، ...) باید واقعاً مخفی بمانند */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
  background: var(--background);
  color: var(--foreground);
  font-size: 14px;
  line-height: 1.7;
}

a { color: inherit; text-decoration: none; }

/* ---------- هدر ---------- */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-inner {
  max-width: 1720px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}
.topbar-titles { min-width: 0; flex: 1; }
.topbar-titles h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--muted-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { flex-shrink: 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.userbox { display: flex; align-items: center; gap: 8px; }
.userchip {
  font-size: 12px; font-weight: 600;
  background: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; white-space: nowrap;
}
.logout-form { margin: 0; }
.upload-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.upload-group form { margin: 0; }

/* ---------- دکمه‌ها ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 6px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn-xs { height: 28px; padding: 0 8px; font-size: 12px; }
.btn-icon { width: 36px; height: 36px; padding: 0; flex-shrink: 0; }
.btn-icon svg { width: 20px; height: 20px; }
.btn-outline { border-color: var(--border); background: var(--card); box-shadow: 0 1px 2px rgb(0 0 0 / 0.05); }
.btn-outline:hover { background: var(--accent); }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { filter: brightness(0.92); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-icon.danger, .btn-ghost.danger { color: var(--muted-fg); }
.btn-icon.danger:hover, .btn-ghost.danger:hover { color: var(--danger); background: var(--danger-bg); }

/* ---------- سایدبار ---------- */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgb(0 0 0 / 0.5);
  z-index: 49;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 310px; max-width: 85vw;
  background: var(--card);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgb(0 0 0 / 0.12);
}
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-title { margin: 0; font-weight: 800; font-size: 16px; }
.drawer-sub { margin: 0; font-size: 12px; color: var(--muted-fg); }
.drawer-nav { display: flex; flex-direction: column; gap: 4px; padding: 12px; }
.drawer-link {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 12px;
  border-radius: 6px; font-weight: 500; font-size: 14px;
}
.drawer-link:hover { background: var(--accent); }
.drawer-link.active { background: var(--primary); color: var(--primary-fg); }

/* ---------- بدنه ---------- */
.container {
  max-width: 1720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}
.card h2 { margin: 0; font-size: 15px; font-weight: 700; }

/* ---------- شاخص‌ها ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .kpi-grid { grid-template-columns: repeat(5, 1fr); } }
.kpi { padding: 16px; transition: box-shadow 0.15s; }
.kpi:hover { box-shadow: 0 4px 12px rgb(0 0 0 / 0.08); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-label { margin: 0; font-size: 13px; color: var(--muted-fg); }
.kpi-icon { border-radius: 8px; padding: 8px; display: inline-flex; }
.tone-primary { background: rgb(14 116 144 / 0.1); color: var(--primary); }
.tone-info { background: rgb(37 99 235 / 0.1); color: var(--info); }
.tone-success { background: rgb(22 163 74 / 0.1); color: var(--success); }
.tone-danger { background: rgb(220 38 38 / 0.1); color: var(--danger); }
.tone-warning { background: rgb(180 83 9 / 0.12); color: var(--warning); }
.kpi-value { margin: 12px 0 0; font-size: 23px; font-weight: 800; letter-spacing: -0.5px; }
.kpi-unit { margin: 2px 0 0; font-size: 12px; color: var(--muted-fg); }

/* ---------- پنل‌ها ---------- */
.panels { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .panels { grid-template-columns: 1fr 1fr; } }
.panel { padding: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.link { color: var(--primary); font-size: 12px; }
.link:hover { text-decoration: underline; }
.scroll-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding-left: 4px; }
.team-row {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  transition: background 0.15s;
}
.team-row:hover { background: var(--accent); }
.team-row.selected { border-color: var(--primary); background: rgb(14 116 144 / 0.05); }
.team-row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.team-name { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 14px; }
.team-name.sm { font-size: 13px; font-weight: 600; }
.team-name svg.muted { color: var(--muted-fg); }
.team-amount { font-size: 13px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.team-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; font-size: 12px; color: var(--muted-fg); }
.progress { margin-top: 8px; height: 6px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--primary); }
.progress-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.progress-row .progress { flex: 1; margin-top: 0; }
.share-pct { font-size: 11px; color: var(--muted-fg); white-space: nowrap; }
.placeholder { padding: 64px 16px; text-align: center; font-size: 13px; color: var(--muted-fg); margin: 0; }
.empty { text-align: center; color: var(--muted-fg); font-size: 13px; padding: 12px; margin: 0; }

/* ---------- جدول ---------- */
.table-card { overflow: hidden; }
.table-head { padding: 16px; border-bottom: 1px solid var(--border); }
.table-head h2 { margin-bottom: 12px; }
.toolbar { display: flex; flex-direction: column; gap: 12px; }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.search-form { position: relative; min-width: 240px; flex: 1; }
.search-wrap { position: relative; min-width: 240px; flex: 1; }
.search-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-fg); pointer-events: none; }
.input {
  height: 36px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  padding: 4px 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--foreground);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}
.input::placeholder { color: var(--muted-fg); }
.input:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 1px var(--ring); }
.input.search { padding-right: 36px; }
select.input { width: auto; min-width: 150px; height: 32px; font-size: 12px; }
.pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  transition: background 0.15s;
}
.pill:hover { background: var(--accent); }
.pill.active { border-color: var(--primary); background: var(--primary); color: var(--primary-fg); }
.muted-text { font-size: 12px; color: var(--muted-fg); }
.clear-filters { display: inline-flex; align-items: center; gap: 4px; }
.active-filter { margin: 0; font-size: 12px; color: var(--muted-fg); }

.table-meta { padding: 12px 16px 0; }
.row-count { color: var(--foreground); font-size: 14px; }
.table-wrap { overflow: auto; max-height: 68vh; margin-top: 8px; border-top: 1px solid var(--border); }
table { width: 100%; min-width: 1000px; border-collapse: separate; border-spacing: 0; font-size: 13px; text-align: right; }
thead { font-size: 12px; color: var(--muted-fg); }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
  padding: 10px; font-weight: 500; white-space: nowrap;
}
.th-sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.th-sort:hover { color: var(--primary); }
.th-sort.active { color: var(--primary); font-weight: 700; }
.th-arrow { font-size: 10px; line-height: 1; }
.th-arrow-dim { opacity: 0.3; }
th:hover .th-arrow-dim { opacity: 0.9; }
tbody tr:hover { background: rgb(241 245 249 / 0.6); }
td { padding: 8px 10px; vertical-align: middle; border-top: 1px solid var(--border); }
.cell-name { max-width: 240px; font-weight: 500; }
.cell-address { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.muted { color: var(--muted-fg); }
.bounced { font-weight: 600; color: var(--danger); }
.tel { display: inline-flex; align-items: center; gap: 4px; color: var(--primary); }
.tel:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-under10 { background: #fef9c3; color: #a16207; }
.badge-10to30 { background: #ffedd5; color: #c2410c; }
.badge-over30 { background: var(--danger-bg); color: var(--danger); }

.follow-cell { display: flex; align-items: center; gap: 4px; }
.follow-latest { min-width: 105px; font-size: 12px; }
.follow-time { font-size: 12px; }
.count-badge {
  background: rgb(14 116 144 / 0.1);
  color: var(--primary);
  border-radius: 999px;
  padding: 0 6px;
  font-size: 11px;
}
.count-badge:empty { display: none; }

.empty-row { text-align: center; color: var(--muted-fg); padding: 32px !important; }
.row-num { text-align: center; white-space: nowrap; }
td.row-num { color: var(--muted-fg); }
.loading-row { text-align: center; color: var(--muted-fg); padding: 16px !important; cursor: pointer; }
.spinner {
  display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-left: 6px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- لاگ‌های فعالیت ---------- */
.log-filters { flex-direction: row; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.log-filters .input { width: auto; }
.log-filters select.input { max-width: 220px; }
.log-filters .log-search { flex: 1; min-width: 200px; }
.badge-log { background: var(--muted); color: var(--foreground); }
.badge-log-fail { background: var(--danger-bg); color: var(--danger); }
.cell-detail { max-width: 520px; white-space: pre-wrap; }

/* ---------- گزارش‌های تحلیلی ---------- */
.kpi-grid.kpi-row-6 { grid-template-columns: repeat(6, 1fr); }
.kpi-grid.kpi-row-6 .kpi-value { font-size: 16px; overflow-wrap: break-word; line-height: 1.5; }
@media (max-width: 1400px) { .kpi-grid.kpi-row-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .kpi-grid.kpi-row-6 { grid-template-columns: repeat(2, 1fr); } }
.kpi-grid.kpi-row-7 { grid-template-columns: repeat(7, 1fr); }
.kpi-grid.kpi-row-7 .kpi-value { font-size: 15px; overflow-wrap: break-word; line-height: 1.5; }
@media (max-width: 1500px) { .kpi-grid.kpi-row-7 { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 640px) { .kpi-grid.kpi-row-7 { grid-template-columns: repeat(2, 1fr); } }
.aging-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1024px) { .aging-panels { grid-template-columns: 1fr; } }
.aging-panel { padding: 16px; }
.aging-panel h3 { margin: 0 0 4px; font-size: 14px; font-weight: 700; }
.panel-total { margin: 0 0 12px; font-size: 12px; color: var(--muted-fg); }
.panel-total strong { color: var(--foreground); }
.legend-nums strong { overflow-wrap: break-word; }
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut { width: 180px; height: 180px; flex-shrink: 0; }
.donut-label { font-size: 4px; fill: var(--muted-fg); }
.donut-value { font-size: 3px; font-weight: 800; fill: var(--foreground); }
.donut-legend { flex: 1; min-width: 230px; display: flex; flex-direction: column; gap: 10px; }
.legend-row { display: flex; align-items: center; gap: 8px; }
.legend-row .dot { width: 12px; height: 12px; border-radius: 999px; flex-shrink: 0; }
.legend-text { flex: 1; display: flex; flex-direction: column; font-size: 13px; }
.legend-nums { display: flex; flex-direction: column; text-align: end; font-size: 13px; }
.legend-text small, .legend-nums small { font-size: 11px; }
.share-col { min-width: 220px; }
.share-cell { display: flex; align-items: center; gap: 8px; }
.share-cell .progress { flex: 1; margin-top: 0; }
.table-head-inner { border-top: 1px solid var(--border); }

/* ---------- مدیریت تیم‌ها ---------- */
.teams-toolbar { padding: 16px; }
.add-sup { display: flex; align-items: center; gap: 8px; }
.add-sup .input { width: 192px; }
.team-card { padding: 16px; }
.team-card.unassigned { border-color: rgb(180 83 9 / 0.4); }
.teams-grid { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: start; }
@media (min-width: 900px) { .teams-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1280px) { .teams-grid { grid-template-columns: repeat(3, 1fr); } }
.teams-grid .seller-row { flex-wrap: wrap; }
.teams-grid .seller-info { flex: 1 1 140px; }
.teams-grid .seller-meta { overflow-wrap: break-word; }
.teams-grid .team-card { height: 440px; display: flex; flex-direction: column; }
.teams-grid .seller-list { flex: 1; min-height: 0; overflow-y: auto; }
.teams-grid .seller-list.capped { max-height: none; }
.team-card-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.team-title { display: flex; align-items: center; gap: 4px; }
.team-title h2 { flex: 1; }
.team-head-actions { display: flex; gap: 2px; }
.team-head-actions .btn-icon { width: 32px; height: 32px; }
.team-title-edit { display: flex; align-items: center; gap: 8px; }
.team-title-edit .input { max-width: 280px; height: 32px; }
.team-title-edit .btn-icon { width: 32px; height: 32px; }
.seller-list { display: flex; flex-direction: column; gap: 8px; }
.seller-list.capped { max-height: 320px; overflow-y: auto; padding-left: 4px; }
.seller-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
}
.seller-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.seller-name { font-weight: 600; font-size: 13px; }
.seller-meta { font-size: 12px; color: var(--muted-fg); }
.seller-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.seller-actions .btn-icon { width: 32px; height: 32px; }

/* ---------- مودال ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgb(0 0 0 / 0.5);
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%; max-width: 560px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.2);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.follow-item {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 8px;
}
.follow-item .when { font-size: 13px; font-weight: 600; }
.follow-item .followup-author { font-size: 11px; color: var(--muted-fg); margin-top: 1px; }
.follow-item .note { font-size: 12px; color: var(--muted-fg); margin-top: 2px; white-space: pre-wrap; }
.note-form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.note-form textarea {
  font-family: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 12px; min-height: 70px; resize: vertical;
}
.note-form textarea:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 1px var(--ring); }
.info-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--muted-fg); white-space: nowrap; }
.info-row .v { font-weight: 600; text-align: left; overflow-wrap: anywhere; }

/* ---------- توست ---------- */
.toasts {
  position: fixed;
  bottom: 16px; left: 16px;
  z-index: 70;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(360px, 90vw);
}
.toast {
  background: var(--foreground);
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
  animation: toast-in 0.25s ease;
}
.toast.error { background: var(--danger); }
.toast small { display: block; opacity: 0.8; font-size: 12px; }
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 640px) {
  .topbar-titles h1 { font-size: 15px; }
  .add-sup .input { width: 140px; }
  .seller-row { flex-direction: column; align-items: stretch; }
  .seller-actions { justify-content: flex-end; }
}

/* ---------- ورود ---------- */
.login-page { background: #062a36; }
.login-bg {
  position: fixed; inset: 0; overflow: hidden;
  background: linear-gradient(135deg, #062a36 0%, #0b4a5e 45%, #0e7490 100%);
}
.login-bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgb(255 255 255 / 0.09) 1px, transparent 1px);
  background-size: 28px 28px;
}
.blob { position: absolute; border-radius: 50%; filter: blur(90px); }
.blob-1 { width: 480px; height: 480px; background: #22d3ee; opacity: 0.32; top: -160px; left: -120px; }
.blob-2 { width: 440px; height: 440px; background: #34d399; opacity: 0.28; bottom: -170px; right: -110px; }
.blob-3 { width: 300px; height: 300px; background: #818cf8; opacity: 0.25; top: 38%; left: 56%; }

.login-wrap {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 24px 24px; gap: 18px;
}
.login-card {
  width: 100%; max-width: 420px;
  padding: 52px 36px 30px;
  border-radius: 22px; border: none;
  box-shadow: 0 24px 70px rgb(0 0 0 / 0.35);
  position: relative;
  animation: card-in 0.45s ease;
}
@keyframes card-in {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.login-badge {
  position: absolute; top: -34px; right: 50%; transform: translateX(50%);
  width: 68px; height: 68px; border-radius: 20px;
  background: linear-gradient(135deg, #0e7490, #164e63);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 30px rgb(14 116 144 / 0.45);
  border: 4px solid rgb(255 255 255 / 0.95);
}
.login-head { text-align: center; }
.login-head h1 { margin: 0 0 6px; font-size: 22px; font-weight: 800; }
.login-head p { margin: 0 0 20px; font-size: 13px; color: var(--muted-fg); }
.login-alert { display: flex; align-items: center; justify-content: center; gap: 8px; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.field-label { font-weight: 700; padding-right: 2px; }
.input-with-icon { position: relative; display: block; }
.input-with-icon > svg:first-child {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted-fg); pointer-events: none;
}
.login-input {
  height: 50px; border-radius: 13px;
  background: #f8fafc; border: 1.5px solid var(--border);
  padding-right: 46px; font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.login-input.has-toggle { padding-left: 46px; }
.login-input::placeholder { color: #94a3b8; }
.login-input:focus {
  background: #fff; border-color: var(--primary);
  box-shadow: 0 0 0 4px rgb(14 116 144 / 0.14);
  outline: none;
}
.icon-btn {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--muted-fg); padding: 8px; display: flex; border-radius: 8px;
}
.icon-btn:hover { color: var(--primary); background: rgb(14 116 144 / 0.08); }
.login-btn {
  width: 100%; height: 52px; border-radius: 13px;
  font-size: 15px; font-weight: 800;
  background: linear-gradient(135deg, #0e7490, #155e75);
  color: #fff; border: none; cursor: pointer;
  box-shadow: 0 10px 25px rgb(14 116 144 / 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  margin-top: 6px;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgb(14 116 144 / 0.45); }
.login-btn:active { transform: translateY(0); }
.login-hint { text-align: center; font-size: 12px; color: var(--muted-fg); margin: 18px 0 0; }
.login-foot { color: rgb(255 255 255 / 0.75); font-size: 12px; margin: 0; }

/* ---------- مدیریت کاربران ---------- */
.users-toolbar {
  padding: 14px 16px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
}
.role-chips { display: flex; flex-wrap: wrap; gap: 16px; }
.role-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.role-superadmin { background: var(--danger-bg); color: var(--danger); font-weight: 700; }
.role-admin { background: rgb(14 116 144 / 0.12); color: var(--primary); }
.role-supervisor { background: var(--warning-bg); color: var(--warning); }
.role-seller { background: var(--success-bg); color: var(--success); }
.status-active { background: var(--success-bg); color: var(--success); }
.status-inactive { background: var(--muted); color: var(--muted-fg); }
.users-table { min-width: 900px; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #0e7490, #155e75);
  color: #fff; font-weight: 800; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
}
.self-tag { font-size: 11px; color: var(--primary); font-weight: 700; }
.row-inactive { opacity: 0.65; }
.row-actions { display: flex; align-items: center; gap: 4px; }
.danger-text { color: var(--danger); }
.danger-text:hover { background: var(--danger-bg); color: var(--danger); }
.modal-form { display: flex; flex-direction: column; gap: 12px; }
.col-toggle-list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px;
  max-height: 320px; overflow-y: auto; padding: 4px 2px;
}
.col-toggle-list .check-row { padding: 6px 8px; border-radius: 6px; }
.col-toggle-list .check-row:hover { background: var(--accent); }
.modal-form-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
@media (max-width: 480px) { .col-toggle-list { grid-template-columns: 1fr; } }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- بررسی چک‌ها: هماهنگ با کارت و جدول مطالبات ---------- */
.check-records-page { display: flex; flex-direction: column; gap: 16px; }
.check-filter-card, .check-table-card { overflow: hidden; }
.check-filter-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.check-filter-head h2 { margin: 0 0 3px; font-size: 15px; }
.check-filter-head p { margin: 0; }
.scope-chip { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 999px; background: var(--muted); color: var(--muted-fg); padding: 5px 10px; font-size: 11px; white-space: nowrap; }
.check-filter-form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; padding: 14px 16px 16px; }
.check-filter-item, .check-filter-search { display: flex; flex-direction: column; gap: 5px; min-width: 170px; font-size: 12px; font-weight: 600; }
.check-filter-item { flex: 0 1 210px; }
.check-filter-search { flex: 1 1 340px; }
.check-filter-item .input, .check-filter-search .input { width: 100%; min-width: 0; height: 36px; }
.check-filter-buttons { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.check-table-head { padding: 15px 16px; }
.check-table-headline { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.check-table-title { display: flex; align-items: center; gap: 11px; min-width: 240px; }
.check-table-number { display: inline-flex; flex: 0 0 38px; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid rgb(14 116 144 / 0.2); border-radius: 9px; background: rgb(14 116 144 / 0.08); color: var(--primary); font-size: 13px; font-weight: 800; }
.check-table-number-returned { border-color: rgb(180 83 9 / 0.2); background: var(--warning-bg); color: var(--warning); }
.check-table-title h2 { margin: 0 0 2px; font-size: 16px; font-weight: 800; }
.check-table-title p { margin: 0; }
.check-table-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.check-table-stat { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--card); color: var(--muted-fg); font-size: 11px; white-space: nowrap; }
.check-table-stat strong { color: var(--foreground); font-size: 13px; }
.check-table-stat small { font-size: 10px; font-weight: 500; }
.check-table-amount { border-color: #facc15; background: #fef08a; color: #713f12; }
.check-table-amount strong { color: #713f12; }
.check-table-amount-returned { border-color: #f4ce58; background: #fff4c2; }
.check-add-button { min-height: 36px; padding: 0 14px; font-size: 13px; font-weight: 700; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.check-add-button svg { flex: 0 0 auto; }
.check-table-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 16px; border-top: 1px solid var(--border); }
.check-record-table-wrap { margin-top: 0; max-height: 62vh; border-top: 0; }
.check-record-table { width: 100%; font-size: 13px; }
.check-record-table-unregistered { min-width: 1460px; }
.check-record-table-returned { min-width: 1740px; }
.check-record-table thead th { padding: 10px 11px; white-space: nowrap; }
.check-record-table tbody td { padding: 8px 10px; }
.check-record-table .cell-name { min-width: 140px; white-space: nowrap; }
.check-record-description { min-width: 170px; max-width: 260px; white-space: normal; }
.check-record-description span { display: block; max-width: 250px; overflow-wrap: anywhere; white-space: pre-wrap; }
.check-description-edit { margin-top: 2px; padding: 0; border: 0; background: transparent; color: var(--primary); font-family: inherit; font-size: 11px; cursor: pointer; }
.check-description-edit:hover { text-decoration: underline; }
.check-record-table .empty-row { height: 72px; text-align: center; color: var(--muted-fg); }
.check-record-total-row td { border-top: 1px solid #facc15; background: #fef08a; color: #713f12; font-weight: 700; }
.check-record-total-returned td { background: #fff4c2; }
.check-record-total-row td:first-child { text-align: left; }
.checks-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px 16px 14px; border-top: 1px solid var(--border); }
.disabled-page { color: var(--muted-fg); opacity: 0.55; cursor: default; }

/* فرم افزودن / ویرایش در مودال مشترک سایت */
.modal:has(.check-form) { max-width: 800px; }
.check-form { display: flex; flex-direction: column; gap: 14px; }
.check-customer-pair, .check-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.check-form .field { min-width: 0; }
.check-form .input { width: 100%; min-width: 0; height: 38px; font-size: 13px; }
.check-form textarea.input { height: auto; min-height: 78px; resize: vertical; }
.check-form .jalali-date { direction: ltr; text-align: left; }
.check-customer-field { position: relative; }
.customer-suggestions { position: absolute; top: calc(100% - 1px); right: 0; left: 0; z-index: 8; max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 0 0 8px 8px; background: var(--card); box-shadow: 0 8px 20px rgb(15 23 42 / 0.12); }
.customer-suggestion { display: block; width: 100%; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--border); background: var(--card); color: var(--foreground); text-align: right; font: inherit; cursor: pointer; }
.customer-suggestion:last-child { border-bottom: 0; }
.customer-suggestion:hover { background: var(--accent); color: var(--primary); }
.customer-suggestion-empty { padding: 10px 12px; color: var(--muted-fg); font-size: 12px; }
.error-text { color: var(--danger); }
.check-form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.check-description-input { min-height: 92px !important; }
.check-note-form textarea { width: 100%; font-family: inherit; font-size: 13px; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; resize: vertical; }
.check-note-form textarea:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 1px var(--ring); }

@media (max-width: 900px) {
  .check-filter-head { align-items: flex-start; flex-direction: column; }
  .check-filter-item, .check-filter-search { flex: 1 1 100%; min-width: 100%; }
  .check-table-headline { align-items: flex-start; flex-direction: column; }
  .check-table-actions { width: 100%; justify-content: flex-start; }
  .check-table-actions .check-add-button { flex: 0 0 auto; }
  .check-table-meta { align-items: flex-start; flex-direction: column; }
  .check-record-table-wrap { max-height: 58vh; }
}
@media (max-width: 600px) {
  .check-filter-form { align-items: stretch; }
  .check-filter-buttons { width: 100%; }
  .check-filter-buttons .btn { flex: 1 1 auto; }
  .check-table-title { min-width: 0; }
  .check-table-actions { align-items: stretch; }
  .check-table-stat { flex: 1 1 auto; justify-content: space-between; }
  .check-table-actions .check-add-button { flex: 1 1 100%; }
  .check-customer-pair, .check-form-grid { grid-template-columns: 1fr; }
  .check-form-actions .muted-text { flex: 1 1 100%; }
}

/* عملیات کامل رکورد چک */
.check-record-table-unregistered { min-width: 1540px; }
.check-record-table-returned { min-width: 1840px; }
.check-actions-heading, .check-row-actions { min-width: 150px; }
.check-row-actions { display: table-cell; white-space: nowrap; }
.check-row-actions .btn { margin: 1px 2px; }
.check-delete-button { border-color: rgb(185 28 28 / 0.3); color: var(--danger); }
.check-delete-button:hover { border-color: var(--danger); background: var(--danger-bg); }
.btn-danger-solid { border: 1px solid var(--danger); background: var(--danger); color: #fff; }
.btn-danger-solid:hover { filter: brightness(0.92); }

/* انتخاب تاریخ شمسی با تقویم داخلی */
.jalali-picker { position: relative; width: 100%; }
.jalali-picker-input { direction: ltr; text-align: left; padding-left: 42px; cursor: pointer; background: var(--card); }
.jalali-picker-input[readonly] { cursor: pointer; }
.jalali-picker-toggle { position: absolute; z-index: 1; left: 5px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: 5px; background: transparent; color: var(--muted-fg); cursor: pointer; }
.jalali-picker-toggle:hover { background: var(--accent); color: var(--primary); }
.jalali-picker-toggle svg { width: 17px; height: 17px; }
.jalali-calendar { position: fixed; top: 12px; right: 12px; z-index: 90; width: 310px; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); overflow-y: auto; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); box-shadow: 0 12px 32px rgb(15 23 42 / 0.2); direction: rtl; }
.jalali-calendar-head { display: grid; grid-template-columns: 36px minmax(0,1fr) 36px; align-items: center; gap: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--border); text-align: center; }
.jalali-calendar-head strong { font-size: 13px; color: var(--foreground); }
.jalali-calendar-nav { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 7px; background: var(--card); color: var(--foreground); font-size: 22px; line-height: 1; cursor: pointer; }
.jalali-calendar-nav:hover { border-color: var(--primary); color: var(--primary); background: var(--accent); }
.jalali-calendar-weekdays, .jalali-calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 3px; text-align: center; }
.jalali-calendar-weekdays { padding: 8px 0 4px; color: var(--muted-fg); font-size: 10px; font-weight: 600; }
.jalali-calendar-weekdays span { overflow: hidden; white-space: nowrap; }
.jalali-calendar-days { padding-top: 3px; }
.jalali-calendar-day, .jalali-calendar-blank { display: inline-flex; align-items: center; justify-content: center; min-width: 0; height: 34px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--foreground); font: inherit; font-size: 12px; cursor: pointer; }
.jalali-calendar-day:hover { border-color: var(--primary); background: rgb(14 116 144 / 0.08); color: var(--primary); }
.jalali-calendar-day.is-today { border-color: rgb(14 116 144 / 0.45); color: var(--primary); font-weight: 800; }
.jalali-calendar-day.is-selected { border-color: var(--primary); background: var(--primary); color: #fff; font-weight: 800; }
.jalali-calendar-footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.jalali-calendar-today, .jalali-calendar-clear { padding: 5px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--primary); font: inherit; font-size: 11px; cursor: pointer; }
.jalali-calendar-today:hover, .jalali-calendar-clear:hover { background: var(--accent); }
.jalali-calendar-clear { color: var(--muted-fg); }

/* مودال تأیید حذف با خلاصهٔ کامل ردیف */
.modal:has(.check-delete-confirm) { width: 100%; max-width: 900px; }
.check-delete-confirm { display: flex; flex-direction: column; gap: 12px; }
.check-delete-warning { margin: 0; padding: 9px 12px; border: 1px solid rgb(185 28 28 / 0.22); border-radius: 7px; background: var(--danger-bg); color: var(--danger); font-size: 12px; }
.check-delete-details { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; max-height: 48vh; overflow-y: auto; margin: 0; }
.check-delete-item { min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.check-delete-item dt { margin-bottom: 2px; color: var(--muted-fg); font-size: 10px; }
.check-delete-item dd { margin: 0; color: var(--foreground); font-size: 12px; font-weight: 600; overflow-wrap: anywhere; white-space: pre-wrap; }
.check-delete-actions { display: flex; justify-content: flex-start; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
@media (max-width: 600px) {
  .check-delete-details { grid-template-columns: 1fr; max-height: 42vh; }
  .jalali-calendar { width: 290px; }
}
