@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;700;800;900&display=swap');

:root {
  --ink: #20231f;
  --muted: #667064;
  --line: #42473f;
  --soft-line: #d9e1d3;
  --paper: #fffdfa;
  --surface: #f5f7ef;
  --field: #fff;
  --green: #3f7047;
  --green-dark: #24482e;
  --green-bright: #28a745;
  --gold: #c79833;
  --danger: #d64537;
  --shadow: 0 26px 80px rgba(34, 48, 32, 0.16);
  --kanban-bg: #eceee9;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body.ofarm-app.crm-app {
  direction: rtl;
  color: var(--ink);
  font-family: "Vazirmatn", "IRANSans", Tahoma, sans-serif;
  background:
    radial-gradient(circle at 10% 6%, rgba(199, 152, 51, 0.18), transparent 28rem),
    radial-gradient(circle at 94% 16%, rgba(63, 112, 71, 0.16), transparent 24rem),
    linear-gradient(135deg, #edf2e7 0%, #fbf4e8 52%, #e9f0e5 100%);
}

button, input, select, textarea {
  font: inherit;
  font-family: inherit;
}
button { cursor: pointer; }
input, textarea { color: var(--ink); }

/* ——— Shell (هم‌سبک حسابداری) ——— */
.app-shell { width: min(98vw, 1440px); margin: 22px auto; }
.wizard-panel {
  overflow: hidden;
  background: rgba(255, 253, 250, 0.94);
  border: 1px solid rgba(63, 112, 71, 0.22);
  border-radius: 30px;
  box-shadow: var(--shadow);
}
.crm-panel { padding-bottom: 28px; min-height: calc(100vh - 44px); }

.wizard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  background: linear-gradient(90deg, rgba(63, 112, 71, 0.13), rgba(199, 152, 51, 0.14));
  border-bottom: 1px solid var(--soft-line);
  flex-wrap: wrap;
}
.brand-block, .logo-wrap { display: flex; align-items: center; gap: 18px; }
.logo {
  width: 100px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-fallback-text { display: none; font-weight: 900; font-size: 28px; color: var(--green-dark); }
.logo.logo-fallback .logo-fallback-text { display: block; }
.eyebrow { margin: 0 0 6px; color: var(--green-dark); font-size: 14px; font-weight: 900; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(24px, 3.5vw, 40px); line-height: 1.1; font-weight: 900; }

.crm-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.header-search {
  min-width: 240px;
  max-width: 360px;
  flex: 1;
  margin: 0;
  padding: 8px 14px;
}
.header-search input {
  width: 100%;
  border: 1px solid var(--soft-line);
  border-radius: 12px;
  padding: 10px 14px;
  background: #fff;
}

.primary-btn, .secondary-btn, .ghost-btn, .danger-btn, .success-btn, .save-blue {
  border-radius: 12px;
  padding: 9px 16px;
  font-weight: 900;
  border: 0;
  white-space: nowrap;
}
.primary-btn { color: #fff; background: linear-gradient(135deg, var(--green-dark), var(--green)); }
.secondary-btn { color: var(--green-dark); background: #ecf2e8; border: 1px solid #cbdac5; text-decoration: none; display: inline-flex; align-items: center; }
.ghost-btn { color: var(--green-dark); background: #fff; border: 1px solid #cbdac5; }
.success-btn { color: #fff; background: linear-gradient(135deg, #1e6b32, var(--green-bright)); }
.danger-btn { color: #fff; background: var(--danger); }
.save-blue { color: #fff; background: linear-gradient(135deg, #4a7fa8, #7fb3d5); }
.icon-only { padding: 6px 12px; }

.db-pill {
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: #eef4ea;
  color: var(--green-dark);
  border: 1px solid rgba(63, 112, 71, 0.25);
}
.db-pill.off { background: #fdecea; color: var(--danger); border-color: rgba(214, 69, 55, 0.3); }

.badge-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  margin-right: 6px;
}

/* ——— Tabs ——— */
.crm-tabs {
  display: flex;
  gap: 8px;
  padding: 16px 24px 0;
  flex-wrap: wrap;
}
.crm-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(63, 112, 71, 0.25);
  background: #fff;
  color: var(--green-dark);
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 800;
  font-size: 14px;
  transition: 0.2s ease;
}
.crm-tab .tab-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.crm-tab.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(63, 112, 71, 0.25);
}
.crm-tab.active .tab-icon { background: rgba(255, 255, 255, 0.25); color: #fff; }

/* ——— Stats ——— */
.crm-stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--soft-line);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 4px 16px rgba(34, 48, 32, 0.05);
}
.stat-card.accent {
  background: linear-gradient(135deg, #f3f8ef, #fff9ea);
  border-color: rgba(199, 152, 51, 0.35);
}
.stat-label { display: block; font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.stat-card strong { display: block; font-size: 1.5rem; color: var(--green-dark); line-height: 1.2; }
.stat-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; direction: ltr; text-align: right; }

/* ——— Toolbar ——— */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.crm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  justify-content: flex-start;
  margin: 0 24px 16px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--soft-line);
}
.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar-right { margin-inline-start: auto; }
.pill-group { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-btn {
  border: 1px solid var(--soft-line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 12.5px;
  color: var(--muted);
}
.pill-btn.active { color: var(--green-dark); border-color: var(--green); background: #eaf2e6; }
.view-tabs { display: flex; gap: 4px; }
.view-tab {
  border: 1px solid var(--soft-line);
  background: #fff;
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 12.5px;
}
.view-tab.active { background: var(--green); color: #fff; border-color: var(--green); }

/* ——— Views ——— */
.crm-view { display: none; padding: 0 24px; }
.crm-view.is-visible { display: block; }

.search-card {
  margin: 0 0 16px;
  padding: 18px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--soft-line);
}
.field-card {
  display: block;
  font-weight: 800;
  font-size: 13px;
  color: var(--green-dark);
}
.field-card input {
  display: block;
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--soft-line);
  border-radius: 12px;
  padding: 10px 14px;
  background: #fff;
}
.field-card.wide { grid-column: 1 / -1; }
.hint { font-size: 0.82rem; color: var(--muted); }

/* ——— Kanban ——— */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 4px 0 16px;
  min-height: 420px;
  align-items: flex-start;
}
.kanban-col {
  min-width: 290px;
  max-width: 310px;
  flex-shrink: 0;
  background: var(--kanban-bg);
  border-radius: 16px;
  padding: 10px;
  border: 1px solid rgba(63, 112, 71, 0.12);
}
.kanban-col-header {
  position: relative;
  padding: 14px 16px 14px 32px;
  margin-bottom: 10px;
  border-radius: 12px;
  font-weight: 900;
  font-size: 14px;
  color: var(--green-dark);
  clip-path: polygon(14px 0, 100% 0, calc(100% - 14px) 50%, 100% 100%, 14px 100%, 0 50%);
}
.kanban-col-header .meta {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 4px;
  direction: ltr;
  text-align: right;
}
.kanban-cards {
  min-height: 100px;
  padding: 4px;
  border-radius: 10px;
  transition: background 0.15s;
}
.kanban-cards.drag-over { background: rgba(63, 112, 71, 0.12); }

.deal-card {
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  border: 1px solid #e8ece4;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.deal-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(63, 112, 71, 0.12); }
.deal-card:active { cursor: pointer; }
.deal-card h4 { margin: 0 0 8px; font-size: 14px; line-height: 1.45; font-weight: 800; }
.deal-card .contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.deal-card .amount {
  font-weight: 900;
  font-size: 13px;
  direction: ltr;
  text-align: right;
  color: var(--green-dark);
}
.deal-card .warn { color: var(--gold); font-size: 16px; }
.deal-card .stage-tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef3e9;
  color: var(--green-dark);
  font-weight: 800;
}

.quick-add-slot {
  border: 2px dashed var(--green);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  color: var(--green);
  font-weight: 800;
  font-size: 13px;
  background: rgba(63, 112, 71, 0.04);
  cursor: pointer;
  transition: background 0.15s;
}
.quick-add-slot:hover { background: rgba(63, 112, 71, 0.1); }

/* ——— Tables ——— */
.table-panel {
  border-radius: 18px;
  border: 1px solid var(--soft-line);
  background: #fff;
  overflow: hidden;
  max-height: min(62vh, 720px);
  display: flex;
  flex-direction: column;
}
.table-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--soft-line);
}
.table-panel-head h3 { margin: 0; font-size: 1rem; }
.table-scroll-inner { flex: 1; min-height: 0; overflow: auto; }

.crm-app .main-table.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.crm-app .main-table.crm-table th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #eef3e8;
  padding: 10px 12px;
  text-align: right;
  font-weight: 900;
  color: var(--green-dark);
  border-bottom: 2px solid var(--soft-line);
  white-space: nowrap;
}
.crm-app .main-table.crm-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf1e9;
  vertical-align: middle;
}
.crm-app .main-table.crm-table tr:hover td { background: #f8fbf5; }
.crm-app .main-table.crm-table .num { direction: ltr; text-align: right; font-weight: 800; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions .ghost-btn, .row-actions .danger-btn { padding: 5px 10px; font-size: 12px; }
.status-done { color: var(--green); font-weight: 800; }
.status-pending { color: var(--gold); font-weight: 800; }

/* ——— Contacts ——— */
.contacts-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.contacts-layout {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 16px;
  min-height: 400px;
}
.contacts-main { min-height: 0; }
.alpha-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.alpha-bar button {
  border: 0;
  background: #fff;
  padding: 5px 10px;
  font-weight: 800;
  color: var(--muted);
  border-radius: 8px;
  border: 1px solid transparent;
}
.alpha-bar button.active { background: var(--green); color: #fff; border-color: var(--green); }
.alpha-bar button:hover:not(.active) { border-color: var(--soft-line); }

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.contact-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #e5ebe0;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.contact-card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(63, 112, 71, 0.12); }
.contact-card .avatar-area {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  position: relative;
}
.contact-card .bookmark-star {
  position: absolute;
  top: 10px;
  left: 12px;
  color: var(--gold);
  font-size: 18px;
}
.contact-card .body {
  padding: 14px;
  border-top: 3px solid var(--green);
}
.contact-card h3 { margin: 0 0 6px; font-size: 15px; font-weight: 900; }
.contact-card p { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.contact-card .cat-tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef3e9;
  color: var(--green-dark);
  font-weight: 800;
}
.contact-card .owner {
  margin-top: 10px;
  font-size: 11px;
  text-align: left;
  color: var(--muted);
}

.category-sidebar {
  background: #fff;
  border: 1px solid var(--soft-line);
  border-radius: 16px;
  padding: 16px;
  height: fit-content;
  position: sticky;
  top: 12px;
}
.category-sidebar h3 {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 800;
}
.category-sidebar .cat-link {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  text-align: right;
}
.category-sidebar .cat-link:hover { background: #f1f6ed; }
.category-sidebar .cat-link.active {
  background: #eaf2e6;
  color: var(--green-dark);
  border: 1px solid rgba(63, 112, 71, 0.25);
}
.category-sidebar .cat-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 999px;
}

/* ——— Activities ——— */
.activities-toolbar { margin-bottom: 16px; }
.type-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--soft-line);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}
.type-chip.active { border-color: var(--green); background: #eaf2e6; color: var(--green-dark); }
.act-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-left: 8px;
  vertical-align: middle;
}
.act-icon.call { background: #fdecea; }
.act-icon.meeting { background: #e8f0ff; }
.act-icon.note { background: #f5f0e6; }
.act-icon.task { background: #eaf2e6; }
.act-icon.reminder { background: #fff3e0; }

/* ——— Modals ——— */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 20, 0.5);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 20px;
  width: min(96vw, 920px);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  border: 1px solid rgba(63, 112, 71, 0.15);
}
.modal.wide { width: min(96vw, 1100px); }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--soft-line);
  background: linear-gradient(90deg, rgba(63, 112, 71, 0.06), rgba(199, 152, 51, 0.06));
}
.modal-eyebrow { margin: 0 0 4px; font-size: 12px; color: var(--muted); font-weight: 800; }
.modal-header h3 { margin: 0; font-size: 20px; font-weight: 900; }
.modal-close {
  border: 0;
  background: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 22px;
  color: var(--muted);
  line-height: 1;
  border: 1px solid var(--soft-line);
}
.modal-body { padding: 22px; overflow: auto; flex: 1; }
.modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 22px;
  border-top: 1px solid var(--soft-line);
  background: #fafcf8;
}
.modal-spacer { flex: 1; }
.done-check { font-weight: 800; font-size: 13px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 800;
  font-size: 13px;
  color: var(--green-dark);
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid #d2dccb;
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--field);
}
.field textarea { min-height: 80px; resize: vertical; }
.amount-row { display: grid; grid-template-columns: 80px 1fr; gap: 8px; }

.modal-split {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  padding: 0;
  min-height: 400px;
}
.modal-form-pane { padding: 22px; overflow: auto; }
.modal-split .timeline-pane {
  background: #f4f6f2;
  border-right: 1px solid var(--soft-line);
  padding: 18px;
  overflow: auto;
}
.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-weight: 900;
}
.timeline-slots { position: relative; }
.timeline-slot {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px dashed #dde5d8;
  min-height: 44px;
}
.timeline-slot .time-label { min-width: 44px; font-weight: 800; }
.timeline-block {
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 12px;
  flex: 1;
}

.activity-type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.activity-type-row.compact { margin-bottom: 10px; }
.type-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--soft-line);
  background: #fff;
  font-size: 18px;
  transition: 0.15s;
}
.type-icon-btn.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  transform: scale(1.05);
}

/* ——— Quick popover & menu ——— */
.quick-popover {
  position: fixed;
  z-index: 900;
  top: 50%;
  left: 50%;
  width: min(92vw, 360px);
  max-height: calc(100vh - 32px);
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--soft-line);
  display: none;
  overflow: auto;
}
.quick-popover.open { display: block; }
.quick-popover-head {
  padding: 12px 16px;
  background: linear-gradient(90deg, rgba(63, 112, 71, 0.1), rgba(199, 152, 51, 0.1));
  font-weight: 900;
  font-size: 13px;
  color: var(--green-dark);
  border-bottom: 1px solid var(--soft-line);
}
.quick-popover-body { padding: 14px; }
.field-input {
  width: 100%;
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.quick-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.quick-actions .success-btn, .quick-actions .ghost-btn { flex: 1; }
.full-width { width: 100%; margin-top: 4px; }

.quick-menu {
  position: fixed;
  z-index: 950;
  background: #fff;
  border: 1px solid var(--soft-line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  min-width: 180px;
}
.quick-menu button {
  display: block;
  width: 100%;
  text-align: right;
  border: 0;
  background: transparent;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 800;
  color: var(--ink);
}
.quick-menu button:hover { background: #f1f6ed; color: var(--green-dark); }

/* ——— Toast & loading ——— */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--green-dark);
  color: #fff;
  padding: 12px 22px;
  border-radius: 14px;
  font-weight: 800;
  z-index: 2000;
  opacity: 0;
  transition: 0.25s ease;
  box-shadow: 0 8px 24px rgba(36, 72, 46, 0.3);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 253, 250, 0.75);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
  color: var(--green-dark);
}
.loading-overlay.show { display: flex; }
.hidden { display: none !important; }
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 1024px) {
  .crm-stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .crm-stats-row { grid-template-columns: 1fr; }
  .form-grid, .modal-split, .contacts-layout { grid-template-columns: 1fr; }
  .modal-split .timeline-pane { border-right: 0; border-top: 1px solid var(--soft-line); }
  .crm-toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left, .toolbar-right { justify-content: center; }
  .header-search { max-width: 100%; min-width: 0; }
  .wizard-header { flex-direction: column; align-items: stretch; }
  .crm-header-actions { justify-content: center; }
}

/* ══════════════════════════════════════════
   موبایل ≤ 480px — CRM
   1405.03.24
   ══════════════════════════════════════════ */
@media (max-width: 480px) {
  .app-shell { width: 100%; }
  /* جستجو: تمام‌عرض */
  .header-search { min-width: unset; width: 100%; }
}

/* ══════════════════════════════════════════
   بهبودهای دیدار — 1405.04.06
   ══════════════════════════════════════════ */

/* ستون‌های آمار برد/باخت */
.stat-card.stat-won { border-top: 3px solid var(--green-bright); }
.stat-card.stat-lost { border-top: 3px solid var(--danger); }
.stat-card.stat-won strong { color: var(--green); }
.stat-card.stat-lost strong { color: var(--danger); }

/* badge تعداد فعالیت‌های معلق روی کارت معامله */
.act-count-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(63, 112, 71, 0.12);
  color: var(--green-dark);
  white-space: nowrap;
}
.act-count-badge.no-act {
  background: rgba(214, 69, 55, 0.1);
  color: var(--danger);
}

/* کارت معامله موفق / ناموفق */
.deal-card.deal-won { border-right: 4px solid var(--green-bright); opacity: 0.85; }
.deal-card.deal-lost { border-right: 4px solid var(--danger); opacity: 0.75; }
.status-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 700;
  margin-right: 4px;
}
.status-tag.won { background: rgba(40, 167, 69, 0.15); color: var(--green); }
.status-tag.lost { background: rgba(214, 69, 55, 0.12); color: var(--danger); }
.status-tag.open { background: rgba(63, 112, 71, 0.1); color: var(--green-dark); }

/* فیلد دلیل باخت */
#lostReasonField { margin-top: 4px; }
.lost-reason-tag {
  font-size: 11px;
  color: var(--danger);
  font-style: italic;
  display: block;
  margin-top: 2px;
}

/* ══════ Contact Drawer ══════ */
.contact-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1100;
  backdrop-filter: blur(2px);
}
.contact-drawer-overlay.open { display: block; }

.contact-drawer {
  position: fixed;
  top: 0;
  right: 0;       /* RTL: drawer از راست می‌آید (سمت طبیعی RTL) */
  width: min(460px, 96vw);
  height: 100vh;
  background: var(--paper);
  border-left: 1px solid var(--soft-line);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.16);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);  /* شروع از خارج صفحه سمت راست */
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.contact-drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 18px 16px;
  background: linear-gradient(135deg, rgba(63, 112, 71, 0.08), rgba(199, 152, 51, 0.08));
  border-bottom: 1px solid var(--soft-line);
  flex-shrink: 0;
}
.drawer-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 900;
  flex-shrink: 0;
}
.drawer-info { flex: 1; min-width: 0; }
.drawer-info h2 { margin: 0 0 4px; font-size: 18px; font-weight: 900; }
.drawer-sub { margin: 0 0 2px; font-size: 13px; color: var(--muted); }
.drawer-sub.ltr { direction: ltr; text-align: right; }
.drawer-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.icon-only { font-size: 20px; padding: 4px 10px; }

.drawer-section {
  padding: 14px 18px 4px;
  border-bottom: 1px solid var(--soft-line);
  flex-shrink: 0;
  max-height: 35vh;
  overflow-y: auto;
}
.drawer-section:last-of-type { border-bottom: 0; flex: 1; max-height: none; }
.drawer-section-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Deals in drawer */
.drawer-deal-item {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 6px;
  font-size: 13px;
}
.drawer-deal-item.won { border-right: 3px solid var(--green-bright); }
.drawer-deal-item.lost { border-right: 3px solid var(--danger); opacity: 0.8; }
.drawer-deal-title { font-weight: 700; display: block; margin-bottom: 3px; }
.drawer-deal-meta { color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Activity timeline in drawer */
.drawer-timeline {
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--soft-line);
  font-size: 13px;
  position: relative;
}
.timeline-item.timeline-done { opacity: 0.6; }
.timeline-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-title { font-weight: 700; margin-bottom: 2px; }
.timeline-meta { color: var(--muted); font-size: 12px; }
.timeline-deal { margin-right: 4px; }
.timeline-notes { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.timeline-check { color: var(--green-bright); font-size: 14px; font-weight: 900; flex-shrink: 0; }

.drawer-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--soft-line);
  flex-shrink: 0;
}

.loading-hint { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* بارگذاری بیشتر فعالیت‌ها */
.load-more-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  justify-content: center;
}

@media (max-width: 760px) {
  .contact-drawer { width: 100vw; right: 0; }
  .crm-stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════════════════════════════
   Kanban scroll arrows — فلش‌های اسکرول افقی کانبان
   position: fixed → همیشه وسط صفحه — حتی اگر ستون‌ها خیلی بلند باشند
   ═══════════════════════════════════════════════════════════════ */
.kanban-scroll-wrap {
  position: relative;
}
.kanban-scroll-btn {
  position: fixed;          /* ثابت نسبت به viewport iframe — نه container */
  top: 50vh;
  transform: translateY(-50%);
  z-index: 500;
  width: 42px;
  height: 64px;
  border: none;
  border-radius: 12px;
  background: rgba(36, 72, 46, 0.88);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.kanban-scroll-btn:hover { background: var(--green-dark); }
/* در RTL: ks-right لبه راست iframe (کنار sidebar)، ks-left لبه چپ */
.kanban-scroll-btn.ks-right { right: 6px; }
.kanban-scroll-btn.ks-left  { left:  6px; }

/* Touch users can swipe the board horizontally; fixed arrows obscure cards. */
@media (max-width: 650px) {
  .kanban-scroll-btn { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   Contact Autocomplete — جستجوی شخص در مودال معامله و فعالیت
   ═══════════════════════════════════════════════════════════════ */
.contact-ac { position: relative; width: 100%; }

/* input سرچ — همان ظاهر field‌های دیگر */
.contact-ac-input {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--soft-line); border-radius: 10px;
  font-family: "Vazirmatn","IRANSans",Tahoma,sans-serif;
  font-size: 13px; color: var(--ink); direction: rtl;
  background: #fff; box-sizing: border-box;
}
.contact-ac-input:focus { outline: 2px solid var(--green); outline-offset: 1px; }

/* dropdown لیست نتایج */
.contact-ac-drop {
  position: absolute; top: calc(100% + 4px); right: 0; left: 0; z-index: 350;
  background: #fff; border: 1px solid #cbdac5; border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.13);
  max-height: 240px; overflow-y: auto;
}
/* هر آیتم در dropdown — دو ردیف: نام + ردیف جزئیات */
.ac-item {
  padding: 8px 14px; cursor: pointer; font-size: 13px;
  direction: rtl; color: var(--ink);
}
.ac-item:first-child { border-radius: 10px 10px 0 0; }
.ac-item:last-child  { border-radius: 0 0 10px 10px; }
.ac-item:hover, .ac-item.ac-highlighted { background: #f0f7ee; }

/* نام اصلی شخص */
.ac-name { font-weight: 500; }

/* ردیف جزئیات: تلفن + شرکت */
.ac-details {
  display: flex; gap: 10px; align-items: center;
  margin-top: 2px;
}
.ac-sub { font-size: 11px; color: #888; }
.ac-phone { font-size: 11px; color: #555; direction: ltr; text-align: right; }

/* آیتم ایجاد شخص جدید */
.ac-create {
  color: var(--green); font-weight: 600;
  border-top: 1px solid #e8f0e5;
}
.ac-empty { color: #aaa; font-size: 12px; cursor: default; }

/* کارت اطلاعات شخص انتخاب‌شده — زیر فیلد سرچ */
.contact-selected-card {
  margin-top: 6px; padding: 10px 14px;
  background: #f5faf3; border: 1px solid #c8ddc2;
  border-radius: 10px; direction: rtl;
  display: flex; flex-direction: column; gap: 4px;
}
.csc-name { font-weight: 600; font-size: 13px; color: var(--ink); }
.csc-row  { display: flex; flex-wrap: wrap; gap: 12px; }
.csc-item { font-size: 12px; color: #555; display: flex; align-items: center; gap: 4px; }
.csc-item .csc-lbl { color: #999; font-size: 11px; }
.csc-item a { color: var(--green); text-decoration: none; direction: ltr; }
.csc-item a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════
   Pipeline Switcher — انتخاب‌گر کاریز در toolbar
   ═══════════════════════════════════════════════════════════════ */
.pipe-switcher-wrap { display: flex; align-items: center; gap: 6px; }
.toolbar-select-field {
  display: flex;
  min-width: 0;
}
.toolbar-select-field .pipe-board-sel { width: 100%; max-width: none; }
.owner-filter-field { min-width: 0; }

/* select با ظاهر ghost-btn */
.pipe-board-sel {
  color: var(--green-dark);
  background: #fff;
  border: 1px solid #cbdac5;
  border-radius: 10px;
  padding: 6px 10px;
  font-family: "Vazirmatn", "IRANSans", Tahoma, sans-serif;
  font-size: 12.5px;
  cursor: pointer;
  min-width: 108px;
  max-width: 160px;
  direction: rtl;
}
.pipe-board-sel:focus { outline: 2px solid var(--green); outline-offset: 1px; }

/* دکمه + کاریز جدید */
.pipe-new-btn { font-size: 12.5px; white-space: nowrap; padding: 6px 12px; }

/* یکدست‌سازی ارتفاع دکمه‌های toolbar (ghost-btn) با pill/select‌ها */
.crm-toolbar .ghost-btn { min-height: 32px; padding: 6px 13px; font-size: 12.5px; }

/* فرم inline ایجاد کاریز */
.new-pipe-row { display: flex; align-items: center; gap: 6px; }
.new-pipe-row.hidden { display: none !important; }
.new-pipe-input {
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  padding: 6px 12px;
  font-family: "Vazirmatn", "IRANSans", Tahoma, sans-serif;
  font-size: 13px;
  width: 180px;
  color: var(--ink);
  direction: rtl;
}
.new-pipe-input:focus { outline: 2px solid var(--green); outline-offset: 1px; }

/* ═══════════════════════════════════════════════════════════════
   Pipeline Editor — ویرایشگر کاریز
   ═══════════════════════════════════════════════════════════════ */
.pipeline-editor {
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--soft-line);
  padding: 0;
  overflow: hidden;
}

/* نوار بالای ویرایشگر: نام کاریز + دکمه‌ها */
.pipe-editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--green-dark);
  color: #fff;
  flex-wrap: wrap;
}
.pipe-editor-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
}
.pipe-name-input {
  flex: 1;
  min-width: 160px;
  padding: 7px 12px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 9px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
}
.pipe-name-input::placeholder { color: rgba(255,255,255,0.5); }
.pipe-name-input:focus {
  outline: none;
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.6);
}
.pipe-toggle-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
}
.pipe-editor-btns {
  display: flex;
  gap: 8px;
  margin-right: auto;
}

/* ردیف مراحل — اسکرول افقی */
.pipe-stages-scroll {
  display: flex;
  gap: 14px;
  padding: 16px;
  overflow-x: auto;
  align-items: flex-start;
  min-height: 340px;
}

/* کارت هر مرحله در ویرایشگر */
.pipe-stage-card {
  min-width: 280px;
  max-width: 300px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--soft-line);
  padding: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.pipe-stage-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.pipe-stage-order {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  background: var(--surface);
  border-radius: 6px;
  padding: 2px 8px;
}
.pipe-stage-del {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.12s, background 0.12s;
}
.pipe-stage-del:hover { color: var(--danger); background: #fdecea; }
.pipe-field-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pipe-field-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  display: block;
  margin-bottom: 3px;
}
.pipe-field-group input[type="text"],
.pipe-field-group textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--soft-line);
  border-radius: 9px;
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  resize: none;
  transition: border-color 0.12s;
}
.pipe-field-group input[type="text"]:focus,
.pipe-field-group textarea:focus {
  outline: none;
  border-color: var(--green);
  background: #fff;
}
.pipe-field-group textarea { min-height: 52px; }
.pipe-field-group input[type="number"] {
  width: 80px;
  padding: 7px 10px;
  border: 1px solid var(--soft-line);
  border-radius: 9px;
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  text-align: center;
}
.pipe-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
/* toggle switch */
.pipe-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pipe-toggle {
  position: relative;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}
.pipe-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.pipe-toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s;
}
.pipe-toggle-slider::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  right: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.pipe-toggle input:checked + .pipe-toggle-slider { background: var(--green); }
.pipe-toggle input:checked + .pipe-toggle-slider::after { transform: translateX(-16px); }

/* کارت افزودن مرحله */
.pipe-add-stage-card {
  min-width: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(63, 112, 71, 0.04);
  border: 2px dashed var(--green);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 200px;
}
.pipe-add-stage-card:hover { background: rgba(63, 112, 71, 0.1); }
.pipe-add-stage-card span {
  font-size: 13px;
  font-weight: 800;
  color: var(--green);
}

/* کل کارت معامله به جزئیات می‌رود؛ فعالیت سریع دکمه مستقل دارد. */
.deal-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.deal-card-head .deal-card-title { flex: 1; margin: 0 0 8px; }
.deal-quick-activity {
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(63, 112, 71, .22);
  border-radius: 9px;
  background: #f5f9f2;
  color: var(--green-dark);
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.deal-quick-activity:hover {
  border-color: var(--green);
  background: #e8f1e4;
}

/* ══════════════════════════════════════════════════════════════════════
   Deal Detail Page — صفحه کامل جزئیات معامله (مانند دیدار CRM)
   1405.04.08
   ══════════════════════════════════════════════════════════════════════ */

/* هدر صفحه detail */
.dd-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px 10px;
  border-bottom: 1px solid var(--soft-line);
  background: linear-gradient(90deg, rgba(63,112,71,0.06), transparent);
  flex-wrap: wrap;
}
.dd-back-btn {
  border: 1px solid var(--soft-line);
  background: #fff;
  border-radius: 10px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--green-dark);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.12s;
}
.dd-back-btn:hover { background: var(--surface); }
.dd-title-wrap {
  flex: 1;
  min-width: 0;
}
.dd-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dd-pipeline-name {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.dd-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* نوار مراحل کاریز */
.dd-stage-bar {
  display: flex;
  align-items: center;
  padding: 10px 24px;
  overflow-x: auto;
  gap: 0;
  border-bottom: 1px solid var(--soft-line);
  background: #fafbf8;
  flex-wrap: nowrap;
}
.dd-stage-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
  cursor: default;
  flex-shrink: 0;
}
.dd-stage-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--soft-line);
  background: #fff;
  transition: background 0.15s, border-color 0.15s;
}
.dd-stage-step.past .dd-stage-dot {
  background: var(--green-bright);
  border-color: var(--green-bright);
}
.dd-stage-step.current .dd-stage-dot {
  background: var(--green-dark);
  border-color: var(--green-dark);
  box-shadow: 0 0 0 3px rgba(63,112,71,0.2);
}
.dd-stage-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}
.dd-stage-step.current .dd-stage-label { color: var(--green-dark); }
.dd-stage-step.past .dd-stage-label { color: var(--green); }
.dd-stage-connector {
  height: 2px;
  flex: 1;
  min-width: 20px;
  background: var(--soft-line);
  margin-top: -10px;
  align-self: flex-start;
  margin-top: 6px;
}

/* بدنه اصلی: دو ستون */
.dd-body {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0;
  min-height: calc(100vh - 200px);
  align-items: start;
}

/* ستون اصلی (فعالیت‌ها + یادداشت‌ها) */
.dd-main {
  padding: 16px 20px;
  border-left: 1px solid var(--soft-line);
  min-height: 100%;
}
.dd-action-btns {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* فعالیت‌های برنامه‌ریزی‌شده */
.dd-scheduled {
  background: rgba(199,152,51,0.06);
  border: 1px solid rgba(199,152,51,0.22);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.dd-section-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--green-dark);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dd-scheduled-list { display: flex; flex-direction: column; gap: 8px; }
.dd-sched-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--soft-line);
}
.dd-sched-info { flex: 1; min-width: 0; }
.dd-sched-info strong { display: block; font-weight: 700; }
.dd-sched-info span { color: var(--muted); font-size: 12px; }
.dd-sched-actions { display:flex; align-items:center; gap:7px; flex-shrink:0; }
.dd-done-btn {
  border: 1px solid var(--green-bright);
  background: transparent;
  color: var(--green-bright);
  border-radius: 8px;
  padding: 3px 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.dd-done-btn:hover { background: var(--green-bright); color: #fff; }
.activity-comments-modal { width:min(94vw, 560px); }
.activity-comments-modal .modal-body { max-height:min(52vh, 470px); overflow:auto; }
.activity-comments-empty { padding:24px 12px; color:var(--muted); font-size:12px; font-weight:700; text-align:center; }
.activity-comment-item { margin-bottom:10px; padding:12px; border:1px solid var(--soft-line); border-radius:12px; background:#fbfdf9; }
.activity-comment-item:last-child { margin-bottom:0; }
.activity-comment-item span { color:var(--green-dark); font-size:11px; font-weight:900; }
.activity-comment-item p { margin:7px 0 0; color:var(--ink); font-size:13px; line-height:2; white-space:pre-wrap; }
.activity-comment-meta { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.activity-comment-meta time { color:var(--muted); font-size:10px; font-weight:700; direction:rtl; }
.activity-comment-composer { display:flex; align-items:flex-end; gap:8px; padding:12px 18px; border-top:1px solid var(--soft-line); background:#fbfcfa; }
.activity-comment-composer textarea { flex:1; min-height:54px; max-height:120px; resize:vertical; }
.activity-comment-composer .success-btn { flex-shrink:0; }
.completion-result { margin:7px 0 0; color:var(--ink); font-size:12px; line-height:1.8; white-space:pre-wrap; }
.completion-result b { color:var(--green-dark); }

/* تب‌های history */
.dd-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--soft-line);
}
.dd-tab {
  border: none;
  background: none;
  padding: 7px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
  margin-bottom: -1px;
}
.dd-tab.active { color: var(--green-dark); border-bottom-color: var(--green-dark); }
.dd-tab:hover { color: var(--green-dark); }

/* فرم یادداشت */
.dd-note-form {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--soft-line);
}
.dd-note-form textarea {
  width: 100%;
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  resize: vertical;
  min-height: 80px;
}
.dd-note-form textarea:focus { outline: none; border-color: var(--green); }
.dd-note-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

/* timeline ترکیبی */
.dd-timeline { display: flex; flex-direction: column; gap: 0; }
.dd-timeline-empty {
  text-align: center;
  padding: 32px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}
.dd-timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--soft-line);
  position: relative;
}
.dd-tl-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}
.dd-tl-body { flex: 1; min-width: 0; }
.dd-tl-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.dd-tl-head strong { font-weight: 800; font-size: 14px; }
.dd-tl-date { font-size: 12px; color: var(--muted); font-weight: 700; }
.dd-tl-notes { font-size: 13px; color: #444; margin: 4px 0 0; white-space: pre-wrap; }
.dd-tl-owner { font-size: 12px; color: var(--muted); margin-top: 4px; display: block; }
.activity-record-card { margin:8px 0; padding:14px !important; border:1px solid rgba(63,112,71,.16) !important; border-radius:16px; background:linear-gradient(135deg,#fff,#fbfdf9); }
.activity-record-card:hover { border-color:rgba(63,112,71,.32) !important; box-shadow:0 8px 22px rgba(36,76,43,.06); }
.activity-final-note {
  display:flex;
  align-items:baseline;
  gap:7px;
  margin-top:7px;
  padding:6px 9px;
  border-right:3px solid var(--gold);
  border-radius:8px;
  background:#fffbed;
}
.activity-final-note span { flex-shrink:0; color:#6f5a20; font-size:10px; font-weight:900; }
.activity-final-note p { margin:0; color:#575142; font-size:11px; font-weight:600; line-height:1.75; white-space:pre-wrap; }
.activity-final-inline { margin:5px 0 0; max-width:460px; color:#625d50; font-size:10px; font-weight:600; line-height:1.65; }
.activity-final-inline b { color:#6f5a20; font-weight:900; }
.activity-card-actions { display:flex; flex-direction:column; align-items:center; gap:5px; flex-shrink:0; align-self:center; }
.activity-comment-indicator {
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:36px;
  height:36px;
  flex:0 0 36px;
  border:1px solid #dce6d8;
  border-radius:50%;
  padding:0;
  background:#f7faf5;
  color:var(--green-dark);
  font-family:inherit;
  cursor:pointer;
  transition:background .15s ease,border-color .15s ease,transform .15s ease;
}
.activity-comment-indicator:hover { background:#edf5ea; border-color:#8fb087; transform:translateY(-1px); }
.activity-comment-indicator:not(.has-comments) { color:#9aa59a; background:#fbfcfa; }
.activity-comment-glyph { font-size:17px; line-height:1; filter:saturate(.65); }
.activity-comment-badge {
  position:absolute;
  top:-6px;
  left:-6px;
  display:flex;
  align-items:center;
  justify-content:center;
  min-width:19px;
  height:19px;
  padding:0 5px;
  border:2px solid #fff;
  border-radius:999px;
  background:#df4338;
  color:#fff;
  font:900 10px/1 Vazirmatn,sans-serif;
  box-shadow:0 2px 7px rgba(177,43,34,.28);
}
.dd-timeline-item.note { background: rgba(199,152,51,0.04); border-radius: 8px; padding: 12px; margin-bottom: 2px; border-bottom: none; }
.dd-item-edit-btn, .dd-item-del-btn {
  border: none;
  background: none;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
}
.dd-timeline-item:hover .dd-item-edit-btn,
.dd-timeline-item:hover .dd-item-del-btn { opacity: 1; }
.dd-item-edit-btn:hover { background: var(--surface); color: var(--green-dark); }
.dd-item-del-btn:hover { background: #fdecea; color: var(--danger); }

/* ستون راست: اطلاعات معامله */
.dd-sidebar {
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
}
.dd-info-card {
  background: #fff;
  border: 1px solid var(--soft-line);
  border-radius: 14px;
  padding: 14px;
}
.dd-info-card-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.dd-contact-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.dd-contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
}
.dd-contact-info { flex: 1; min-width: 0; }
.dd-contact-info strong { display: block; font-weight: 800; font-size: 14px; }
.dd-contact-sub { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }
.dd-contact-sub.ltr { direction: ltr; text-align: right; }
.dd-contact-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.dd-comm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--soft-line);
  font-size: 18px;
  text-decoration: none;
  transition: background 0.12s;
}
.dd-comm-btn:hover { background: rgba(63,112,71,0.1); }

/* فیلدهای معامله */
.dd-fields { display: flex; flex-direction: column; gap: 8px; }
.dd-field-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  gap: 8px;
}
.dd-field-label { color: var(--muted); font-weight: 700; flex-shrink: 0; }
.dd-field-value { font-weight: 800; text-align: left; word-break: break-word; }

/* responsive: در صفحه کوچک sidebar زیر main می‌رود */
@media (max-width: 900px) {
  .dd-body { grid-template-columns: 1fr; }
  .dd-sidebar { position: static; }
  .dd-main { border-left: none; border-bottom: 1px solid var(--soft-line); }
}
@media (max-width:560px) {
  .activity-final-note { align-items:flex-start; flex-direction:column; gap:2px; }
  .activity-comment-composer { align-items:stretch; flex-direction:column; }
}

/* Standalone visual alignment with Havale: same typography, controls and rhythm. */
.app-shell { width: min(96vw, 1320px); }
.wizard-panel { overflow: clip; }
.logo { width: 124px; height: 76px; padding: 0; border: 0; background: transparent; }
.crm-panel { padding-bottom: 22px; }

.primary-btn, .secondary-btn, .ghost-btn, .danger-btn, .success-btn, .save-blue,
.view-tab, .pill-btn, .crm-tab, .modal-close, .quick-menu button {
  min-height: 42px;
  border-radius: 14px;
  padding: 9px 16px;
  font-weight: 800;
  box-shadow: none;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}
.primary-btn:hover, .success-btn:hover, .save-blue:hover { transform: translateY(-1px); }
.secondary-btn:hover, .ghost-btn:hover, .pill-btn:hover, .view-tab:hover {
  background: #f3f6f1;
  border-color: rgba(63, 112, 71, .45);
}
.crm-tab { border-radius: 18px; }
.crm-tab.active { box-shadow: none; transform: none; }

input, select, textarea,
.header-search input, .field-card input, .field-card select, .field-card textarea,
.contact-ac-input, .new-pipe-input, .pipe-field-group textarea {
  min-height: 46px;
  border-radius: 14px;
  border-color: var(--soft-line);
  background: var(--field);
}
input:focus, select:focus, textarea:focus,
.header-search input:focus, .field-card input:focus, .field-card select:focus, .field-card textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(63, 112, 71, .12);
}

.crm-stats-row { gap: 10px; }
.stat-card, .contact-card, .deal-card, .dd-info-card {
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(34, 48, 32, .055);
}
.stat-card { padding: 14px 16px; }
.deal-card:hover, .contact-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(63, 112, 71, .09);
}
.crm-toolbar, .search-card { border-radius: 18px; box-shadow: none; }
.modal { border-radius: 24px; box-shadow: 0 24px 70px rgba(20, 35, 25, .20); }

@media (max-width: 480px) {
  .app-shell { width: 100%; margin: 0; }
  .wizard-panel { border-radius: 16px; overflow: visible; }
  .wizard-header { padding: 12px 14px; }
  .logo { width: 80px; height: 50px; }
  h1 { font-size: 20px; }
  .crm-header-actions { width: 100%; }
  .header-search { min-width: 100%; max-width: none; padding: 0; }
}

/* Havale visual system — the standalone CRM follows the same clear wizard shell. */
body.ofarm-app.crm-app .app-shell {
  width: min(96vw, 1320px);
  margin: 24px auto;
}
body.ofarm-app.crm-app .wizard-panel {
  border-radius: 30px;
  border-color: rgba(63, 112, 71, .24);
  background: rgba(255, 253, 249, .97);
  box-shadow: 0 22px 60px rgba(34, 48, 32, .13);
}
body.ofarm-app.crm-app .wizard-header {
  padding: 15px 24px;
  background:
    radial-gradient(circle at 8% 20%, rgba(199, 152, 51, .18), transparent 18rem),
    linear-gradient(90deg, rgba(63, 112, 71, .15), rgba(255, 251, 239, .9));
}
.wizard-header .logo { width: 58px; height: 44px; }
.wizard-header h1 { font-size: clamp(22px, 3vw, 31px); }
.wizard-header .crm-header-actions { gap: 8px; }
.wizard-header .header-search { min-width: min(42vw, 300px); padding: 4px 9px; }
.wizard-header .header-search input { padding: 8px 10px; }
.wizard-header .user-account-pill { padding: 7px 10px; }
body:not(.is-admin) #pipeSwitcherWrap { display: none !important; }
.toolbar-right #btnRefresh { display: none !important; }
.toolbar-right .section-add-btn {
  min-height: 38px;
  padding-inline: 17px;
  white-space: nowrap;
}
.crm-tabs { padding-top: 14px !important; }
.crm-tab { min-height: 54px !important; padding: 9px 13px !important; }
.crm-tab .tab-icon, .crm-tab .tab-copy small { display: none !important; }
.crm-stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 8px !important; padding: 10px 24px !important; }
.crm-stats-row .stat-card:nth-child(n+4) { display: none; }
.crm-stats-row .stat-sub { display: none; }
.stat-card { padding: 10px 12px !important; }
@media (max-width: 650px) {
  .wizard-header { padding: 12px 15px !important; }
  .wizard-header .header-search { order: 3; min-width: 100%; }
  .crm-stats-row { grid-template-columns: 1fr !important; }
}

/* Header refinement: large brand, quiet controls, clear hierarchy. */
body.ofarm-app.crm-app .wizard-header {
  min-height: 106px;
  padding: 18px 28px;
  gap: 22px;
  background: linear-gradient(90deg, rgba(248, 249, 244, .96), rgba(237, 242, 232, .92));
}
body.ofarm-app.crm-app .brand-block { gap: 16px; }
body.ofarm-app.crm-app .wizard-header .logo {
  width: 128px;
  height: 92px;
  flex: 0 0 auto;
}
body.ofarm-app.crm-app .wizard-header h1 {
  font-size: clamp(25px, 3vw, 35px);
  letter-spacing: -.7px;
  color: var(--green-dark);
}
body.ofarm-app.crm-app .crm-header-actions {
  margin-inline-start: auto;
  gap: 7px;
  flex-wrap: nowrap;
}
body.ofarm-app.crm-app .header-search {
  min-width: clamp(230px, 25vw, 350px);
  padding: 0;
  border: 0;
  background: transparent;
}
body.ofarm-app.crm-app .header-search input {
  height: 42px;
  border-radius: 13px;
  border-color: rgba(63,112,71,.2);
  background: rgba(255,255,255,.8);
  font-size: 13px;
}
body.ofarm-app.crm-app .user-account-pill {
  max-width: 118px;
  padding: 7px 10px;
  border-color: transparent;
  background: transparent;
  font-size: 12px;
}
body.ofarm-app.crm-app .crm-header-actions .secondary-btn,
body.ofarm-app.crm-app .crm-header-actions .ghost-btn {
  min-height: 36px;
  padding: 7px 11px;
  border-radius: 11px;
  font-size: 12px;
}

/* Persian activity controls */
.jalali-date-input, .persian-time-input { direction: rtl; font-variant-numeric: normal; }
.jalali-calendar {
  position: fixed;
  z-index: 2200;
  width: 280px;
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: 16px;
  background: #fffdfa;
  box-shadow: 0 18px 44px rgba(20,35,25,.22);
}
.jalali-calendar-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; color:var(--green-dark); }
.jalali-calendar-head button { width:30px; height:30px; border:1px solid var(--soft-line); border-radius:9px; background:#fff; color:var(--green-dark); font-weight:900; }
.jalali-weekdays, .jalali-days { display:grid; grid-template-columns:repeat(7,1fr); gap:4px; text-align:center; }
.jalali-weekdays { margin-bottom:5px; color:var(--muted); font-size:11px; font-weight:800; }
.jalali-days button { height:31px; border:0; border-radius:8px; background:transparent; color:var(--ink); }
.jalali-days button:hover { background:#e7f0e4; color:var(--green-dark); font-weight:900; }
.deal-warning-field { justify-content: flex-end; }
.field .deal-warning-toggle {
  min-height: 44px;
  margin: 0;
  padding: 7px 11px;
  border: 1px solid var(--soft-line);
  border-radius: 12px;
  background: #fafcf8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}
.field .deal-warning-toggle:hover {
  border-color: rgba(63, 112, 71, .42);
  background: #f5f9f2;
}
.deal-warning-toggle .pipe-toggle { display: block; }
.deal-warning-copy {
  display: grid;
  gap: 1px;
  color: var(--green-dark);
}
.deal-warning-copy strong { font-size: 12px; }
.deal-warning-copy small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}
.activity-relative { display:block; margin-top:3px; color:var(--muted); font-weight:800; }
.activity-comment-preview { margin:4px 0 0; max-width:260px; color:var(--muted); font-size:11px; font-weight:600; line-height:1.65; }
.deal-next-activity { display:grid; gap:2px; margin-top:9px; padding:7px 8px; border-radius:10px; background:#f1f6ed; color:var(--green-dark); font-size:10px; }
.deal-next-activity strong { font-size:11px; }
.complete-activity-copy { margin:0 0 16px; padding:10px 12px; border-radius:11px; background:#f1f6ed; color:var(--green-dark); font-weight:800; }
.compact-modal { width:min(94vw,520px); }
@media (max-width: 760px) {
  body.ofarm-app.crm-app .wizard-header { min-height: 0; padding: 14px 16px; }
  body.ofarm-app.crm-app .wizard-header .logo { width: 92px; height: 68px; }
  body.ofarm-app.crm-app .wizard-header h1 { font-size: 24px; }
  body.ofarm-app.crm-app .crm-header-actions { width: 100%; flex-wrap: wrap; }
  body.ofarm-app.crm-app .header-search { order: 3; min-width: 100%; }
}
.header-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 9px; }
.header-chips span {
  padding: 4px 10px;
  border: 1px solid rgba(63, 112, 71, .22);
  border-radius: 999px;
  background: rgba(255, 255, 255, .7);
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 800;
}

body.ofarm-app.crm-app .crm-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 22px 24px 10px;
}
body.ofarm-app.crm-app .crm-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-height: 70px;
  padding: 12px 16px;
  border: 1px solid rgba(63, 112, 71, .2);
  border-radius: 18px;
  background: #fff;
  color: var(--green-dark);
  text-align: right;
}
body.ofarm-app.crm-app .crm-tab::after {
  content: "";
  position: absolute;
  right: 18px;
  left: 18px;
  bottom: -7px;
  height: 7px;
  border-radius: 0 0 9px 9px;
  background: transparent;
}
body.ofarm-app.crm-app .crm-tab .tab-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--green-dark);
  font-size: 15px;
  font-weight: 900;
}
.tab-copy { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.tab-copy small { color: var(--muted); font-size: 10px; font-weight: 700; }
.tab-copy strong { color: inherit; font-size: 14px; font-weight: 900; }
body.ofarm-app.crm-app .crm-tab.active {
  border-color: var(--green);
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
  box-shadow: 0 10px 24px rgba(63, 112, 71, .2);
}
body.ofarm-app.crm-app .crm-tab.active::after { background: var(--gold); }
body.ofarm-app.crm-app .crm-tab.active .tab-icon {
  background: rgba(255, 255, 255, .18);
  color: #fff;
}
body.ofarm-app.crm-app .crm-tab.active .tab-copy small { color: rgba(255, 255, 255, .72); }

body.ofarm-app.crm-app .crm-stats-row {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
  padding: 12px 24px 16px;
}
body.ofarm-app.crm-app .stat-card {
  position: relative;
  overflow: hidden;
  min-height: 96px;
  padding: 15px 16px;
  border-radius: 15px;
  box-shadow: none;
}
body.ofarm-app.crm-app .stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: rgba(63, 112, 71, .38);
}
body.ofarm-app.crm-app .stat-card.stat-won::before { background: var(--green-bright); }
body.ofarm-app.crm-app .stat-card.stat-lost::before { background: var(--danger); }
body.ofarm-app.crm-app .stat-card.accent::before { background: var(--gold); }

body.ofarm-app.crm-app .crm-toolbar {
  margin: 0 24px 18px;
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f6f8f3, #fffaf0);
  border-color: rgba(63, 112, 71, .2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
}
body.ofarm-app.crm-app .primary-btn,
body.ofarm-app.crm-app .success-btn,
body.ofarm-app.crm-app .save-blue {
  border-radius: 15px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  border-color: var(--green-dark);
  padding: 10px 17px;
  font-weight: 900;
}
body.ofarm-app.crm-app .secondary-btn,
body.ofarm-app.crm-app .ghost-btn {
  border-radius: 13px;
  padding: 7px 13px;
  font-weight: 900;
}
body.ofarm-app.crm-app .pill-btn,
body.ofarm-app.crm-app .view-tab {
  min-height: 32px;
  border-radius: 12px;
  padding: 6px 12px;
  font-weight: 900;
}
body.ofarm-app.crm-app .pill-btn.active,
body.ofarm-app.crm-app .view-tab.active {
  background: #e7f0e3;
  border-color: rgba(63, 112, 71, .45);
  color: var(--green-dark);
}
body.ofarm-app.crm-app .contact-card,
body.ofarm-app.crm-app .deal-card,
body.ofarm-app.crm-app .kanban-column,
body.ofarm-app.crm-app .table-panel,
body.ofarm-app.crm-app .search-card {
  border-radius: 16px;
  border-color: rgba(63, 112, 71, .18);
  box-shadow: none;
}

@media (max-width: 1050px) {
  body.ofarm-app.crm-app .crm-stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  body.ofarm-app.crm-app .app-shell { width: 100%; margin: 0; }
  body.ofarm-app.crm-app .wizard-panel { border-radius: 0; border-inline: 0; }
  body.ofarm-app.crm-app .crm-tabs { gap: 7px; padding-inline: 12px; }
  body.ofarm-app.crm-app .crm-tab { min-height: 60px; padding: 9px; gap: 7px; }
  body.ofarm-app.crm-app .crm-tab .tab-icon { width: 32px; height: 32px; flex-basis: 32px; border-radius: 10px; }
  .tab-copy small { display: none; }
  .tab-copy strong { font-size: 11px; }
  body.ofarm-app.crm-app .crm-stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-inline: 12px; }
  body.ofarm-app.crm-app .crm-toolbar { margin-inline: 12px; }
}

/* Off-canvas panels and dense toolbars must never widen the mobile document. */
html, body { max-width: 100%; overflow-x: clip; }
body.ofarm-app.crm-app .crm-toolbar,
body.ofarm-app.crm-app .app-shell,
body.ofarm-app.crm-app .wizard-panel { min-width: 0; }
@supports not (overflow: clip) {
  html, body { overflow-x: hidden; }
}

/* Login and user administration — aligned with anbar-sade, using CRM palette. */
.crm-login-overlay,
.admin-users-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(27, 45, 31, .55);
  backdrop-filter: blur(12px);
}
.crm-login-overlay[hidden], .admin-users-overlay[hidden] { display: none !important; }
.crm-login-box {
  width: min(94vw, 430px);
  padding: 30px;
  border: 1px solid rgba(63, 112, 71, .24);
  border-radius: 28px;
  background: rgba(255, 253, 249, .98);
  box-shadow: 0 28px 80px rgba(20, 35, 25, .28);
  text-align: center;
}
.crm-login-logo { width: 112px; height: 72px; object-fit: contain; margin-bottom: 8px; }
.crm-login-box h1 { margin: 4px 0 8px; font-size: 25px; color: var(--green-dark); }
.login-sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-field { display: block; margin-bottom: 14px; text-align: right; }
.login-field span, .admin-user-form label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
.login-field input, .admin-user-form input, .admin-user-form select { width: 100%; }
.login-submit { width: 100%; margin-top: 4px; }
.login-error { margin: 0 0 12px; padding: 9px 12px; border-radius: 10px; background: #fff0ed; color: var(--danger); font-size: 12px; font-weight: 800; }
.user-account-pill { max-width: 180px; padding: 8px 12px; overflow: hidden; border: 1px solid rgba(63,112,71,.25); border-radius: 999px; background: #fff; color: var(--green-dark); font-size: 12px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
body:not(.is-admin) .admin-only { display: none !important; }
body:not(.is-admin) .owner-filter-field { display: none !important; }
.admin-users-sheet { width: min(95vw, 860px); max-height: 90vh; overflow: auto; padding: 24px; border-radius: 26px; background: #fffdfa; box-shadow: 0 28px 80px rgba(20,35,25,.3); }
.admin-users-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.admin-users-head h2 { margin: 2px 0 0; color: var(--green-dark); }
.admin-user-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; padding: 16px; border: 1px solid var(--soft-line); border-radius: 18px; background: linear-gradient(135deg,#f6f8f3,#fffaf0); }
.admin-user-form .primary-btn { align-self: end; }
.admin-users-help { margin: 12px 2px; color: var(--muted); font-size: 12px; }
.admin-users-list { display: grid; gap: 8px; }
.admin-user-row { display: grid; grid-template-columns: minmax(180px,1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--soft-line); border-radius: 14px; background: #fff; }
.admin-user-name strong { display: block; color: var(--ink); }
.admin-user-name small { color: var(--muted); }
.admin-user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-user-card { display: grid; grid-template-columns: minmax(180px,1fr) auto; gap: 10px 14px; align-items: center; padding: 13px 14px; border: 1px solid var(--soft-line); border-radius: 14px; background: #fff; }
.admin-user-main strong { display: block; color: var(--ink); }
.admin-user-main span { color: var(--muted); font-size: 12px; }
.admin-user-state { padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 900; }
.admin-user-state.active { background: #e8f5e9; color: var(--green-dark); }
.admin-user-state.inactive { background: #f3ece9; color: var(--danger); }
.admin-user-card .admin-user-actions { grid-column: 1 / -1; }
.role-badge { display: inline-block; margin-right: 6px; padding: 2px 7px; border-radius: 999px; background: var(--surface); color: var(--green-dark); font-size: 10px; font-weight: 900; }
.admin-user-row.is-inactive { opacity: .55; }
@media (max-width: 650px) {
  .admin-user-form { grid-template-columns: 1fr; }
  .admin-user-row { grid-template-columns: 1fr; }
  .admin-user-card { grid-template-columns: 1fr auto; }
}
