/* گزارش تراکنش‌ها (CRM) — مکمل استایل‌های درون panel.html */
.crm-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.crm-filters .field:first-child { grid-column: span 2; }
.crm-filters .field input, .crm-filters .field select { width: 100%; min-width: 0; }
@media (min-width: 1100px) { #page-crm .stats-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
#page-crm .stat-card, .crm-insights > div { min-width: 0; }
.crm-filter-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.crm-filter-actions .spacer { flex: 1; }
.field input[type="date"] { direction: ltr; color-scheme: dark; }

.crm-muted { color: var(--text-faint); font-size: 12px; }
.crm-ok { color: var(--success); }
.crm-bad { color: var(--danger); cursor: help; }
.crm-warn { margin-top: 12px; font-size: 12px; color: var(--warning); }
.crm-row-label { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.crm-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.crm-chip {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; white-space: nowrap;
}
.crm-click { cursor: pointer; }
tr.crm-click:hover td { background: var(--surface-2); }

.crm-insights { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.crm-chart {
  display: flex; align-items: flex-end; gap: 3px; height: 110px;
  border-bottom: 1px solid var(--border); padding-top: 6px;
}
.crm-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 3px; }
.crm-bar-fill {
  width: 100%; background: var(--surface-3); border-radius: 3px 3px 0 0;
  display: flex; align-items: flex-end; overflow: hidden;
}
.crm-bar:hover .crm-bar-fill { background: var(--border-strong); }
.crm-bar-ok { width: 100%; background: var(--success); }
.crm-legend { display: flex; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--text-faint); }
.crm-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-inline-end: 5px; }

.crm-link { background: none; border: 0; color: var(--gold); font-size: 12px; padding: 0 4px; text-decoration: underline; cursor: pointer; }
.crm-err { font-size: 11px; color: var(--danger); opacity: .8; overflow-wrap: anywhere; }
.crm-links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.crm-resend { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); margin-inline-start: auto; }
.crm-resend select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 6px 8px; font-family: inherit; font-size: 13px;
}
.crm-invoice-sum {
  background: var(--gold-soft); border: 1px solid rgba(242,179,14,.3); border-radius: var(--r-sm);
  padding: 10px 14px; margin-bottom: 12px; font-size: 14px;
}
.crm-invoice-form {
  background: var(--surface-2); border: 1px solid rgba(242,179,14,.35); border-radius: var(--r-md);
  padding: 16px; margin-bottom: 16px;
}
.crm-invoice-form h4 { margin: 0 0 12px; font-size: 14px; color: var(--gold); }
.crm-invoice-form .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .crm-invoice-form .form-grid { grid-template-columns: 1fr 1fr; }
  .crm-resend { margin-inline-start: 0; }
}

/* صفحه‌ی پیام‌ها و فاکتور */
.ntf-channels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.ntf-toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; }
.ntf-toggle input { display: none; }
.ntf-switch {
  flex: none; width: 42px; height: 24px; border-radius: 12px; background: var(--surface-3);
  border: 1px solid var(--border-strong); position: relative; transition: .2s;
}
.ntf-switch::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-muted); transition: .2s;
}
.ntf-toggle input:checked + .ntf-switch { background: var(--gold); border-color: var(--gold); }
.ntf-toggle input:checked + .ntf-switch::after { right: 21px; background: #0A0B0E; }
.ntf-ok { font-size: 12px; color: var(--success); }
.ntf-brand-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.ntf-brand-grid .field { margin-bottom: 12px; }
.ntf-pay-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.ntf-pay { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 14px; }
.ntf-pay summary { cursor: pointer; font-size: 14px; font-weight: 600; }
.ntf-pay textarea {
  width: 100%; margin-top: 10px; background: var(--bg-soft); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); color: var(--text); font-family: inherit; font-size: 14px; padding: 10px 12px;
  resize: vertical; unicode-bidi: plaintext;
}
.ntf-pay textarea:focus { outline: none; border-color: var(--gold); }
.ntf-warn { font-size: 12px; color: var(--warning); }
.ntf-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; }
.ntf-grid .field { margin-bottom: 14px; }
.ntf-grid textarea { font-size: 14px; line-height: 1.9; }
.ntf-ph-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.ntf-ph-wrap .crm-row-label { width: 100%; }
.ntf-ph {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 4px 9px;
  color: var(--gold); font-family: var(--font-mono); font-size: 12px; direction: ltr; text-align: center;
}
.ntf-ph small { display: block; color: var(--text-faint); font-family: var(--font-body); font-size: 10.5px; direction: rtl; }
.ntf-ph:hover { border-color: var(--gold); }
.ntf-phone {
  background: #0B141A url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23ffffff10'/%3E%3C/svg%3E");
  border-radius: var(--r-md); padding: 18px 14px; min-height: 320px; border: 1px solid var(--border);
}
.ntf-bubble {
  background: #005C4B; color: #E9EDEF; border-radius: 10px 0 10px 10px; padding: 9px 12px 18px;
  font-size: 14px; line-height: 1.85; max-width: 92%; margin-inline-start: auto; position: relative;
  overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0,0,0,.25);
}
.ntf-url { color: #53BDEB; direction: ltr; unicode-bidi: isolate; }
.ntf-time { position: absolute; bottom: 3px; left: 9px; font-size: 10.5px; color: #8696A0; }
.ntf-mail { width: 100%; height: 70vh; border: 0; border-radius: var(--r-sm); background: #F2F4F7; }
.ntf-save {
  position: sticky; bottom: 0; display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  padding: 14px 0; background: linear-gradient(transparent, var(--bg) 35%); margin-top: 8px;
}
@media (max-width: 900px) {
  .ntf-channels, .ntf-grid, .ntf-pay-grid, .ntf-brand-grid { grid-template-columns: 1fr; }
}

/* مودال جزئیات */
#crm-modal {
  display: none; position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.65);
  align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto;
}
#crm-modal.open { display: flex; }
.crm-modal-card {
  position: relative; width: 100%; max-width: 940px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 24px;
  box-shadow: var(--shadow);
}
.crm-modal-close {
  position: absolute; top: 14px; left: 14px; width: 32px; height: 32px; border-radius: 8px;
  color: var(--text-muted); font-size: 18px; background: var(--surface-2);
}
.crm-modal-close:hover { color: var(--text); }
.crm-modal-head {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-inline-end: 44px;
}
.crm-modal-head h3 { font-size: 18px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crm-actions { display: flex; gap: 8px; }
.crm-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.crm-cols h4 { font-size: 13px; color: var(--gold); margin: 18px 0 8px; }
.crm-cols > div > h4:first-child { margin-top: 0; }
.crm-kv {
  display: flex; justify-content: space-between; gap: 12px; padding: 7px 0;
  border-bottom: 1px dashed var(--border); font-size: 14px;
}
.crm-kv > span:first-child { color: var(--text-muted); white-space: nowrap; }
.crm-kv > span:last-child { text-align: left; overflow-wrap: anywhere; }
.crm-pre {
  background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px; margin: 8px 0;
  font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.crm-timeline { display: flex; flex-direction: column; gap: 10px; }
.crm-tl { display: flex; gap: 10px; font-size: 13px; }
.crm-tl-ico { flex: none; width: 22px; text-align: center; }
.crm-note {
  background: var(--surface-2); border-radius: var(--r-sm); padding: 9px 12px; margin-bottom: 8px;
  font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .crm-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .crm-filters .field:first-child { grid-column: 1 / -1; }
  .crm-insights, .crm-cols { grid-template-columns: 1fr; }
}

/* صفحه‌ی معرف‌ها و بلاگرها */
.ref-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.ref-toolbar .spacer { flex: 1; }
@media (min-width: 1100px) { .ref-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.ref-stats .stat-card { min-width: 0; }
.ref-board { display: flex; flex-direction: column; gap: 10px; }
.ref-board-row { display: grid; grid-template-columns: 34px minmax(0, 1.2fr) minmax(0, 2fr) auto; gap: 12px; align-items: center; padding: 4px 6px; border-radius: 8px; }
.ref-board-row:hover { background: var(--surface-2); }
.ref-rank { font-size: 18px; text-align: center; }
.ref-board-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-bar { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.ref-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #FFC836); border-radius: 6px; }
.ref-board-val { color: var(--gold); font-weight: 700; }
.ref-links { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.ref-link { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.ref-link code { flex: 1; min-width: 0; overflow-wrap: anywhere; background: var(--bg-soft); padding: 6px 10px; border-radius: 6px; font-size: 12px; }
.ref-h { font-size: 14px; color: var(--gold); margin: 20px 0 10px; }
.ref-pay-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto; gap: 12px; align-items: end; }
@media (max-width: 700px) {
  .ref-pay-form { grid-template-columns: 1fr; }
  .ref-board-row { grid-template-columns: 30px minmax(0, 1fr) auto; }
  .ref-bar { display: none; }
}
