/* CRM Styles — matches classes generated by crm.js */

.crm-page { padding: 0 0 2rem; }

/* Business Line Switcher */
.crm-biz-switcher, #crm-biz-switcher {
  display: flex; gap: 4px; padding: 12px 24px;
  background: var(--surface, #fff); border-bottom: 1px solid var(--border-color, #e5e5e5);
}
.crm-biz-btn {
  padding: 6px 16px; border-radius: 6px; border: 1px solid var(--border-color, #e5e5e5);
  background: transparent; color: var(--text-muted, #888); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.crm-biz-btn:hover { background: var(--bg, #faf9f6); }
.crm-biz-btn.active {
  background: var(--accent, #d4883a); color: #fff; border-color: var(--accent, #d4883a);
}

/* Stats */
.crm-stats, #crm-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 16px 24px;
}
.crm-stat-card {
  background: var(--surface, #fff); border: 1px solid var(--border-color, #e5e5e5);
  border-radius: 10px; padding: 16px 18px; text-align: center;
}
.crm-stat-value { font-size: 28px; font-weight: 700; color: var(--text, #2a1f23); }
.crm-stat-label { font-size: 12px; color: var(--text-muted, #888); margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }

/* Sub-tabs */
.crm-subtabs, #crm-subtabs {
  display: flex; gap: 0; padding: 0 24px; border-bottom: 1px solid var(--border-color, #e5e5e5);
  background: var(--surface, #fff);
}
.crm-subtab {
  padding: 10px 20px; border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--text-muted, #888);
  border-bottom: 2px solid transparent; transition: all .15s;
}
.crm-subtab:hover { color: var(--text, #2a1f23); }
.crm-subtab.active { color: var(--accent, #d4883a); border-bottom-color: var(--accent, #d4883a); }

/* Panels */
.crm-panel { display: none; padding: 16px 24px; }
.crm-panel.active { display: block; }

/* Buttons */
.crm-btn {
  padding: 8px 16px; border-radius: 6px; border: 1px solid var(--border-color, #e5e5e5);
  background: var(--surface, #fff); color: var(--text, #2a1f23); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap; display: inline-block;
}
.crm-btn:hover { background: var(--bg, #faf9f6); }
.crm-btn-primary { background: var(--accent, #d4883a); color: #fff; border-color: var(--accent, #d4883a); }
.crm-btn-primary:hover { opacity: .9; }
.crm-btn-danger { background: #ef4444; color: #fff; border-color: #ef4444; }
.crm-btn-danger:hover { opacity: .9; }
.crm-btn-success { background: #22c55e; color: #fff; border-color: #22c55e; }
.crm-btn-success:hover { opacity: .9; }
.crm-btn-sm { padding: 5px 12px; font-size: 12px; }
.crm-btn-xs { padding: 3px 8px; font-size: 11px; }

/* Filter Bar / Toolbar */
.crm-filters, .crm-table-toolbar, .crm-pipeline-toolbar, .crm-dashboard-toolbar {
  display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap;
}
.crm-search, .crm-input {
  padding: 8px 12px; border: 1px solid var(--border-color, #e5e5e5);
  border-radius: 6px; font-size: 13px; background: var(--surface, #fff);
  font-family: inherit;
}
.crm-search { flex: 1; min-width: 200px; }
.crm-select {
  padding: 8px 12px; border: 1px solid var(--border-color, #e5e5e5);
  border-radius: 6px; font-size: 13px; background: var(--surface, #fff);
  font-family: inherit;
}
.crm-textarea {
  padding: 8px 12px; border: 1px solid var(--border-color, #e5e5e5);
  border-radius: 6px; font-size: 13px; background: var(--surface, #fff);
  font-family: inherit; resize: vertical; min-height: 80px; width: 100%; box-sizing: border-box;
}

/* Table */
.crm-table-wrap { overflow-x: auto; }
.crm-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.crm-table th {
  text-align: left; padding: 10px 12px; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted, #888);
  border-bottom: 2px solid var(--border-color, #e5e5e5); white-space: nowrap;
}
.crm-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border-color, #e5e5e5);
  color: var(--text, #2a1f23); vertical-align: middle;
}
.crm-table tbody tr { transition: background .1s; }
.crm-table tbody tr:hover { background: var(--bg, #faf9f6); }
.crm-table-footer { padding: 12px 0; font-size: 12px; color: var(--text-muted, #888); }
.crm-empty { text-align: center; padding: 40px; color: var(--text-muted, #888); font-size: 14px; }
.crm-empty-row td { text-align: center; color: var(--text-muted, #888); padding: 40px 12px; }

/* Rows */
.crm-lead-row { cursor: pointer; }
.crm-table .crm-lead-name,
.crm-table .crm-col-name {
  font-weight: 600;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.crm-actions-cell { white-space: nowrap; }

/* Badges */
.crm-source-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px;
  font-weight: 600; background: #e0f2fe; color: #0369a1;
}
.crm-stage-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px;
  font-weight: 600; white-space: nowrap;
}
.crm-status-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px;
  font-weight: 600; text-transform: capitalize;
}
.crm-status-open { background: #dbeafe; color: #1d4ed8; }
.crm-status-won { background: #dcfce7; color: #15803d; }
.crm-status-lost { background: #fee2e2; color: #dc2626; }

/* Invoice status badges */
[class*="crm-inv-status-draft"] { background: #f3f4f6; color: #6b7280; }
[class*="crm-inv-status-sent"] { background: #dbeafe; color: #1d4ed8; }
[class*="crm-inv-status-paid"] { background: #dcfce7; color: #15803d; }
[class*="crm-inv-status-void"] { background: #fee2e2; color: #dc2626; }
[class*="crm-inv-status-viewed"] { background: #fef3c7; color: #92400e; }

/* Kanban Board */
.crm-kanban {
  display: flex; gap: 12px; overflow-x: auto; padding: 8px 0;
  min-height: 400px;
}
.crm-kanban-col {
  min-width: 240px; max-width: 280px; flex-shrink: 0;
  background: var(--bg, #faf9f6); border-radius: 10px; display: flex; flex-direction: column;
}
.crm-kanban-header {
  padding: 10px 12px; border-radius: 10px 10px 0 0; display: flex;
  align-items: center; justify-content: space-between;
}
.crm-kanban-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.crm-kanban-count {
  background: rgba(0,0,0,.1); border-radius: 10px; padding: 1px 7px;
  font-size: 11px; font-weight: 700;
}
.crm-kanban-cards {
  flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 8px;
  min-height: 60px; overflow-y: auto; max-height: calc(100vh - 380px);
}
.crm-kanban-cards.drag-over { background: rgba(212,136,58,.08); }
.crm-kanban-card {
  background: var(--surface, #fff); border: 1px solid var(--border-color, #e5e5e5);
  border-radius: 8px; padding: 10px 12px; cursor: grab; transition: box-shadow .15s, transform .15s;
}
.crm-kanban-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.crm-kanban-card.dragging { opacity: .5; transform: rotate(2deg); }
.crm-kanban-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.crm-kanban-card-name { font-size: 13px; font-weight: 600; color: var(--text, #2a1f23); }
.crm-kanban-card-meta { font-size: 11px; color: var(--text-muted, #888); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crm-card-value { font-weight: 600; color: var(--accent, #d4883a); }
.crm-kanban-card-age { font-size: 10px; color: var(--text-muted, #aaa); margin-top: 4px; }
.crm-owner-tag {
  display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 11px;
  font-weight: 500; background: #f3e8ff; color: #7c3aed;
}
.crm-space-tag {
  display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 11px;
  font-weight: 600; background: #fef3c7; color: #92400e;
}
.crm-kanban-card-space { font-size: 11px; color: var(--text-muted, #888); margin-bottom: 4px; }

/* Business line indicators (All view) */
.crm-card-biz-within { }
.crm-card-biz-ranch { }
.crm-biz-tag {
  display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 10px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
}
.crm-biz-tag-within { background: #d1fae5; color: #065f46; }
.crm-biz-tag-ranch { background: #d4883a; color: #fff; }

/* Modal System
 * z-index 1100 sits above the team-portal site header (.aap-header,
 * z-index 1000), so modals don't slip under the fixed banner. */
#crm-modal,
#clients-modal { position: fixed; inset: 0; z-index: 1100; }
.crm-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 1100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.crm-modal-content {
  background: var(--surface, #fff); border-radius: 12px; width: 100%;
  max-width: 560px; max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.crm-modal-large { max-width: 900px; }
.crm-modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border-color, #e5e5e5);
  display: flex; align-items: center; justify-content: space-between;
}
.crm-modal-header h2 { font-size: 18px; font-weight: 700; margin: 0; }
.crm-modal-close {
  background: none; border: none; font-size: 24px; cursor: pointer;
  color: var(--text-muted, #888); padding: 0 4px; line-height: 1;
}
.crm-modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.crm-modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border-color, #e5e5e5);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* Form elements inside modals */
.crm-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.crm-form-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.crm-form-field label {
  font-size: 12px; font-weight: 600; color: var(--text-muted, #888);
  text-transform: uppercase; letter-spacing: .5px;
}
.crm-form-field input, .crm-form-field select, .crm-form-field textarea {
  padding: 8px 12px; border: 1px solid var(--border-color, #e5e5e5); border-radius: 6px;
  font-size: 13px; width: 100%; box-sizing: border-box; font-family: inherit;
}
.crm-form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* =============================================
   LEAD DETAIL — modern CRM 3-column layout
   ============================================= */
.crm-modal-xlarge { max-width: 1280px; width: calc(100vw - 40px); }
.crm-lead-detail .crm-modal-body { padding: 0; display: flex; flex-direction: column; min-height: 0; }

/* Header bar */
.crm-lead-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 24px; border-bottom: 1px solid var(--border-color, #e5e5e5);
  background: var(--surface, #fff); flex-shrink: 0;
}
.crm-lead-header-main { display: flex; gap: 14px; align-items: center; min-width: 0; }
.crm-lead-header-info { min-width: 0; }
.crm-lead-header-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crm-lead-header .crm-lead-name { font-size: 22px; font-weight: 700; margin: 0; color: var(--text, #2a1f23); }
.crm-lead-subline {
  font-size: 13px; color: var(--text-muted, #888); margin-top: 4px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.crm-lead-subline a { color: var(--text, #2a1f23); text-decoration: none; }
.crm-lead-subline a:hover { color: var(--accent, #d4883a); text-decoration: underline; }
.crm-lead-subline .crm-dot { color: var(--text-muted, #ccc); }
.crm-lead-subline .crm-muted { color: var(--text-muted, #888); }
.crm-lead-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Avatar */
.crm-avatar {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 13px; color: #fff;
  background: var(--accent, #d4883a); flex-shrink: 0;
}
.crm-avatar-lg { width: 52px; height: 52px; font-size: 18px; }
.crm-avatar-within { background: linear-gradient(135deg, #d4883a, #b56d22); }
.crm-avatar-awkn_ranch { background: linear-gradient(135deg, #6b4226, #4a2d1a); }

/* Business tag */
.crm-biz-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 4px; color: #fff;
}
.crm-biz-tag-within { background: #10b981; }
.crm-biz-tag-awkn_ranch { background: #d4883a; }

/* More menu */
.crm-menu-wrap { position: relative; }
.crm-menu {
  position: absolute; top: calc(100% + 4px); right: 0; min-width: 200px;
  background: #fff; border: 1px solid var(--border-color, #e5e5e5); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px; z-index: 10;
}
.crm-menu-item {
  display: block; width: 100%; text-align: left; padding: 8px 12px; border: none;
  background: transparent; font-size: 13px; cursor: pointer; border-radius: 4px;
  color: var(--text, #2a1f23); font-family: inherit;
}
.crm-menu-item:hover { background: var(--bg, #faf9f6); }
.crm-menu-item-success { color: #15803d; }
.crm-menu-item-danger { color: #b91c1c; }

/* Body 3-column */
.crm-lead-body {
  display: grid; grid-template-columns: 280px 1fr 300px; gap: 0;
  flex: 1; min-height: 0; overflow: hidden;
}
.crm-lead-rail {
  padding: 16px; overflow-y: auto; background: var(--bg, #faf9f6);
  border-right: 1px solid var(--border-color, #e5e5e5);
}
.crm-lead-rail-right { border-right: none; border-left: 1px solid var(--border-color, #e5e5e5); }
.crm-lead-main { padding: 16px 20px; overflow-y: auto; min-width: 0; }

/* Property cards (left rail) */
.crm-prop-card {
  background: var(--surface, #fff); border: 1px solid var(--border-color, #e5e5e5);
  border-radius: 8px; padding: 12px; margin-bottom: 12px;
}
.crm-prop-card-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted, #888); margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.crm-prop-count {
  background: var(--bg, #faf9f6); color: var(--text-muted, #888);
  padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700;
}
.crm-prop-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; gap: 12px; font-size: 13px;
  border-bottom: 1px solid var(--border-color, #f0eeea);
}
.crm-prop-row:last-child { border-bottom: none; }
.crm-prop-row-stack { flex-direction: column; align-items: stretch; gap: 4px; }
.crm-prop-key { color: var(--text-muted, #888); font-size: 12px; flex-shrink: 0; }
.crm-prop-val { color: var(--text, #2a1f23); text-align: right; min-width: 0; word-break: break-word; }
.crm-prop-val-strong { font-weight: 700; }
.crm-prop-val a { color: var(--text, #2a1f23); text-decoration: none; }
.crm-prop-val a:hover { color: var(--accent, #d4883a); text-decoration: underline; }
.crm-select-sm { font-size: 13px; padding: 6px 8px; border-radius: 6px; }

/* Composer */
.crm-composer {
  background: var(--surface, #fff); border: 1px solid var(--border-color, #e5e5e5);
  border-radius: 10px; margin-bottom: 16px; overflow: hidden;
}
.crm-composer-tabs {
  display: flex; border-bottom: 1px solid var(--border-color, #e5e5e5);
  background: var(--bg, #faf9f6);
}
.crm-composer-tab {
  flex: 1; padding: 10px 12px; border: none; background: transparent;
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text-muted, #888);
  border-bottom: 2px solid transparent; font-family: inherit; transition: all .15s;
}
.crm-composer-tab:hover { color: var(--text, #2a1f23); }
.crm-composer-tab.active {
  background: var(--surface, #fff); color: var(--accent, #d4883a);
  border-bottom-color: var(--accent, #d4883a);
}
.crm-composer-body { padding: 12px; }
.crm-composer-body textarea {
  width: 100%; box-sizing: border-box; border: none; resize: vertical;
  font-family: inherit; font-size: 14px; outline: none; min-height: 60px;
  padding: 0; background: transparent;
}
.crm-composer-actions {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 10px; border-top: 1px solid var(--border-color, #f0eeea); margin-top: 8px;
}
.crm-composer-hint { font-size: 11px; color: var(--text-muted, #aaa); }

/* Activity feed */
.crm-activity-feed { }
.crm-activity-filters {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border-color, #e5e5e5);
}
.crm-chip {
  padding: 5px 12px; border-radius: 14px; border: 1px solid var(--border-color, #e5e5e5);
  background: var(--surface, #fff); font-size: 12px; cursor: pointer; font-family: inherit;
  color: var(--text-muted, #888); transition: all .15s; display: inline-flex; align-items: center; gap: 5px;
}
.crm-chip:hover { border-color: var(--accent, #d4883a); color: var(--text, #2a1f23); }
.crm-chip.active {
  background: var(--text, #2a1f23); color: #fff; border-color: var(--text, #2a1f23);
}
.crm-chip-count {
  background: rgba(255,255,255,.2); padding: 0 6px; border-radius: 8px; font-size: 10px; font-weight: 700;
}
.crm-chip:not(.active) .crm-chip-count { background: var(--bg, #faf9f6); color: var(--text-muted, #888); }

.crm-activity-day-group { margin-bottom: 18px; }
.crm-activity-day-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted, #888); margin-bottom: 8px; padding-bottom: 4px;
}
.crm-activity-item {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border-color, #f0eeea);
}
.crm-activity-item:last-child { border-bottom: none; }
.crm-activity-icon {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 13px; flex-shrink: 0;
  background: var(--bg, #faf9f6); color: var(--text-muted, #888);
}
.crm-activity-icon-note { background: #dbeafe; color: #1d4ed8; }
.crm-activity-icon-call { background: #dcfce7; color: #15803d; }
.crm-activity-icon-email { background: #fef3c7; color: #b45309; }
.crm-activity-icon-sms { background: #fae8ff; color: #a21caf; }
.crm-activity-icon-stage_change { background: #f3e8ff; color: #7c3aed; }
.crm-activity-icon-system { background: #f3f4f6; color: #6b7280; }
.crm-activity-content { flex: 1; min-width: 0; }
.crm-activity-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.crm-activity-label { font-size: 13px; font-weight: 600; color: var(--text, #2a1f23); }
.crm-activity-time { font-size: 11px; color: var(--text-muted, #aaa); flex-shrink: 0; }
.crm-activity-desc {
  font-size: 13px; color: var(--text, #2a1f23); margin-top: 3px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.45;
}

/* Stats card */
.crm-stats-card { padding: 14px; }
.crm-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.crm-stat { text-align: center; padding: 6px 0; }
.crm-stat-num { font-size: 22px; font-weight: 700; color: var(--text, #2a1f23); line-height: 1.1; }
.crm-stat-label {
  font-size: 10px; color: var(--text-muted, #888); margin-top: 4px;
  text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
}

/* Related rows (right rail) */
.crm-related-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 4px; border: none; background: transparent; width: 100%;
  cursor: pointer; border-bottom: 1px solid var(--border-color, #f0eeea);
  text-align: left; font-family: inherit;
}
.crm-related-row:hover { background: var(--bg, #faf9f6); border-radius: 6px; }
.crm-related-row:last-child { border-bottom: none; }
.crm-related-row-main { min-width: 0; }
.crm-related-row-title { font-size: 13px; font-weight: 600; color: var(--text, #2a1f23); }
.crm-related-row-sub { font-size: 11px; color: var(--text-muted, #888); text-transform: capitalize; margin-top: 2px; }
.crm-related-row-amt { font-size: 13px; font-weight: 700; color: var(--text, #2a1f23); flex-shrink: 0; }
.crm-rail-empty { font-size: 12px; color: var(--text-muted, #aaa); text-align: center; padding: 8px 0; font-style: italic; }

/* Inline action form (Mark Lost, Send Feedback) */
.crm-inline-action-form {
  background: var(--surface, #fff); border: 1px solid var(--accent, #d4883a);
  border-radius: 10px; padding: 16px; margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
}
.crm-inline-form-title {
  font-size: 14px; font-weight: 700; margin: 0 0 12px; color: var(--text, #2a1f23);
}

/* Invoice/Proposal Line Items */
.crm-line-item {
  display: grid; grid-template-columns: 2fr 70px 100px 100px 40px; gap: 8px;
  align-items: center; margin-bottom: 8px;
}
.crm-line-item:has(.crm-li-cat) {
  grid-template-columns: 100px 2fr 70px 100px 100px 40px;
}
.crm-line-item .crm-li-cat { min-width: 0; }
.crm-line-item .crm-li-desc { min-width: 0; resize: vertical; font-family: inherit; line-height: 1.4; white-space: pre-wrap; }
textarea.crm-li-desc { field-sizing: content; min-height: 36px; }
.crm-line-item .crm-li-qty { width: 70px; text-align: center; }
.crm-line-item .crm-li-price { width: 100px; min-width: 0; }
.crm-line-item .crm-li-total { font-weight: 600; font-size: 13px; white-space: nowrap; }
.crm-line-item .crm-li-remove {
  background: none; border: none; color: #ef4444; cursor: pointer;
  font-size: 16px; padding: 0 4px; line-height: 1;
}
.crm-invoice-totals, .crm-totals-display {
  border-top: 2px solid var(--border-color, #e5e5e5); padding-top: 12px; margin-top: 12px;
  text-align: right;
}
.crm-invoice-totals div, .crm-totals-display div { padding: 3px 0; font-size: 14px; }
.crm-invoice-totals strong, .crm-totals-display strong { font-size: 16px; }

/* Catalog Picker Overlay */
.crm-picker-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.crm-picker-content {
  background: var(--surface, #fff); border-radius: 12px; width: 100%; max-width: 600px;
  max-height: 70vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.crm-picker-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border-color, #e5e5e5);
  display: flex; align-items: center; justify-content: space-between;
}
.crm-picker-header h3 { font-size: 16px; font-weight: 700; margin: 0; }
.crm-picker-close {
  background: none; border: none; font-size: 24px; cursor: pointer;
  color: var(--text-muted, #888); padding: 0; line-height: 1;
}
.crm-picker-items {
  padding: 12px; overflow-y: auto; flex: 1;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px;
}
.crm-picker-item {
  padding: 10px; border: 1px solid var(--border-color, #e5e5e5); border-radius: 8px;
  cursor: pointer; transition: all .15s; font-size: 12px;
}
.crm-picker-item:hover { border-color: var(--accent, #d4883a); background: #fef7ed; }
.crm-picker-item-name { font-weight: 600; margin-bottom: 2px; }
.crm-picker-item-price { color: var(--accent, #d4883a); font-weight: 700; }
.crm-picker-item-desc { color: var(--text-muted, #888); font-size: 11px; }
.crm-picker-item--promo { border-color: #22c55e; background: #f0fdf4; }
.crm-picker-item--promo:hover { border-color: #16a34a; background: #dcfce7; }
.crm-picker-item-strike { text-decoration: line-through; color: var(--text-muted, #aaa); font-weight: 400; font-size: 11px; }
.crm-picker-item-badge {
  display: inline-block; margin-top: 4px; padding: 1px 6px; border-radius: 8px;
  font-size: 10px; font-weight: 700; background: #22c55e; color: #fff; text-transform: uppercase;
}

/* Dashboard */
.crm-dashboard-card {
  background: var(--surface, #fff); border: 1px solid var(--border-color, #e5e5e5);
  border-radius: 10px; padding: 20px; margin-bottom: 16px;
}
.crm-dashboard-card h3 { font-size: 14px; font-weight: 700; margin: 0 0 16px; color: var(--text, #2a1f23); }
.crm-dashboard-card-wide { grid-column: 1 / -1; }
.crm-dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.crm-period-btns { display: flex; gap: 4px; }
.crm-period-btn {
  padding: 6px 14px; border-radius: 6px; border: 1px solid var(--border-color, #e5e5e5);
  background: transparent; font-size: 12px; font-weight: 500; cursor: pointer;
  color: var(--text-muted, #888); transition: all .15s;
}
.crm-period-btn.active { background: var(--accent, #d4883a); color: #fff; border-color: var(--accent, #d4883a); }

/* Funnel bars */
.crm-funnel-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.crm-funnel-label { width: 160px; font-size: 12px; font-weight: 500; text-align: right; color: var(--text, #2a1f23); flex-shrink: 0; }
.crm-funnel-bar-wrap { flex: 1; height: 28px; background: var(--bg, #faf9f6); border-radius: 6px; overflow: hidden; }
.crm-funnel-bar { height: 100%; border-radius: 6px; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; transition: width .5s ease; }
.crm-funnel-count { font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.crm-funnel-drop { font-size: 11px; color: var(--text-muted, #888); width: 60px; text-align: center; flex-shrink: 0; }

/* Source chart */
.crm-source-chart { }
.crm-source-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.crm-source-label { width: 140px; font-size: 12px; text-align: right; flex-shrink: 0; }
.crm-source-bar-wrap { flex: 1; height: 22px; background: var(--bg, #faf9f6); border-radius: 4px; overflow: hidden; }
.crm-source-bar { height: 100%; background: var(--accent, #d4883a); border-radius: 4px; transition: width .5s ease; }
.crm-source-count { font-size: 12px; font-weight: 600; width: 40px; flex-shrink: 0; }

/* Won/Lost */
.crm-won-lost { display: flex; gap: 32px; align-items: center; justify-content: center; padding: 20px 0; }
.crm-won-lost-item { text-align: center; }
.crm-won-lost-num { font-size: 36px; font-weight: 700; }
.crm-won { color: #22c55e; }
.crm-lost { color: #ef4444; }
.crm-won-lost-label { font-size: 12px; color: var(--text-muted, #888); text-transform: uppercase; }

/* Responsive */
@media (max-width: 768px) {
  #crm-stats, .crm-stats { grid-template-columns: repeat(2, 1fr); }
  .crm-form-grid { grid-template-columns: 1fr; }
  .crm-lead-body { grid-template-columns: 1fr; overflow-y: auto; }
  .crm-lead-rail { border-right: none; border-bottom: 1px solid var(--border-color, #e5e5e5); max-height: none; }
  .crm-lead-rail-right { border-left: none; border-top: 1px solid var(--border-color, #e5e5e5); }
  .crm-lead-header { flex-direction: column; gap: 12px; align-items: stretch; }
  .crm-modal-xlarge { width: 100vw; max-width: 100vw; }
  .crm-dashboard-grid { grid-template-columns: 1fr; }
  .crm-kanban { flex-direction: column; }
  .crm-kanban-col { max-width: 100%; min-width: 100%; }
  .crm-line-item { grid-template-columns: 1fr; gap: 4px; }
  #crm-biz-switcher, .crm-biz-switcher { padding: 8px 12px; }
  .crm-modal-content { margin: 8px; max-height: 95vh; }
}

/* Mobile leads list: render table rows as tap-friendly cards. */
@media (max-width: 640px) {
  .crm-table-wrap { overflow-x: visible; }
  .crm-table { border: none; }
  .crm-table thead { display: none; }
  .crm-table, .crm-table tbody { display: block; width: 100%; }
  .crm-table tbody tr.crm-lead-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-gap: 4px 10px;
    align-items: center;
    padding: 12px 14px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color, #e5e5e5);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
  }
  .crm-table tbody tr.crm-lead-row:hover,
  .crm-table tbody tr.crm-lead-row:active { background: #faf9f6; }
  .crm-table tbody tr.crm-lead-row > td {
    display: block;
    padding: 0;
    border: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    max-width: none;
  }
  .crm-table tbody tr.crm-lead-row .crm-col-name {
    grid-column: 1 / 2;
    font-size: 16px;
    font-weight: 700;
    color: var(--text, #2a1f23);
    line-height: 1.25;
  }
  .crm-table tbody tr.crm-lead-row .crm-col-status {
    grid-column: 2 / 3;
    justify-self: end;
  }
  .crm-table tbody tr.crm-lead-row .crm-col-email,
  .crm-table tbody tr.crm-lead-row .crm-col-phone {
    grid-column: 1 / -1;
    font-size: 13px;
    color: var(--text-muted, #666);
  }
  .crm-table tbody tr.crm-lead-row .crm-col-email:empty,
  .crm-table tbody tr.crm-lead-row .crm-col-phone:empty,
  .crm-table tbody tr.crm-lead-row .crm-col-source:empty,
  .crm-table tbody tr.crm-lead-row .crm-col-stage:empty,
  .crm-table tbody tr.crm-lead-row .crm-col-owner:empty,
  .crm-table tbody tr.crm-lead-row .crm-col-value:empty,
  .crm-table tbody tr.crm-lead-row .crm-col-biz:empty { display: none; }
  .crm-table tbody tr.crm-lead-row .crm-col-source,
  .crm-table tbody tr.crm-lead-row .crm-col-stage,
  .crm-table tbody tr.crm-lead-row .crm-col-owner,
  .crm-table tbody tr.crm-lead-row .crm-col-biz {
    grid-column: auto;
    justify-self: start;
  }
  .crm-table tbody tr.crm-lead-row .crm-col-value,
  .crm-table tbody tr.crm-lead-row .crm-col-created {
    grid-column: 1 / -1;
    font-size: 12px;
    color: var(--text-muted, #888);
  }
  .crm-table tbody tr.crm-lead-row .crm-col-value {
    font-weight: 600;
    color: var(--text, #2a1f23);
  }
  .crm-table tbody tr.crm-lead-row .crm-col-value:not(:empty)::before { content: 'Value: '; font-weight: 400; color: var(--text-muted, #888); }
  .crm-table tbody tr.crm-lead-row .crm-col-created:not(:empty)::before { content: 'Created '; }
  .crm-table-footer { text-align: center; }
  .crm-table-toolbar { flex-wrap: wrap; }
  .crm-filters { flex: 1 1 100%; flex-wrap: wrap; gap: 8px; }
  .crm-filters > * { flex: 1 1 calc(50% - 4px); min-width: 0; }
}
