/* ===========================================
   CRM MODULE STYLES
   Follows candidlabs design system conventions.
   Uses CSS variables from styles.css for theming.
   Layout pattern matches budget.html tool-layout.
   =========================================== */

/* Main Tool Layout - Sidebar + Content */
.tool-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .tool-layout {
    grid-template-columns: 1fr;
  }
  .tool-sidebar {
    position: static !important;
  }
}

.tool-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  height: fit-content;
  position: sticky;
  top: 100px;
}

.sidebar-section {
  margin-bottom: 20px;
}

.sidebar-section:last-child {
  margin-bottom: 0;
}

.sidebar-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(27, 112, 139, 0.08);
  border-radius: 6px;
  border-left: 3px solid var(--color-primary);
}

.tool-btn {
  display: block;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-body);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.tool-btn:hover {
  color: var(--text-primary);
}

.tool-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* Tool Panel Show/Hide */
.tool-content {
  min-height: 500px;
}

.tool-panel {
  display: none;
}

.tool-panel.active {
  display: block;
}

.tool-panel-header {
  margin-bottom: 20px;
}

.tool-panel-header h2 {
  color: var(--text-primary);
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.tool-panel-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* CRM Stats Row */
.crm-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.crm-stats-grid {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 600px) {
  .crm-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.crm-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.crm-stat-link {
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  width: 100%;
  font: inherit;
}
.crm-stat-link:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 14px rgba(27, 112, 139, 0.12);
  transform: translateY(-2px);
}
.crm-stat-link:hover .crm-stat-label { color: var(--color-primary); }

.crm-stat-number {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 2px;
}

.crm-stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Action Bar (search + add button) */
.crm-action-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.crm-search {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.crm-search:focus {
  outline: none;
  border-color: var(--color-primary);
}

.crm-search::placeholder {
  color: var(--text-muted);
}

.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-add:hover {
  background: var(--color-accent);
}

/* Data Table */
.crm-table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
}

.crm-table th,
.crm-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
}

.crm-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-secondary);
}

.crm-table tbody tr {
  transition: background 0.15s;
}

.crm-table tbody tr:hover {
  background: rgba(27, 112, 139, 0.04);
}

.crm-table tbody tr:last-child td {
  border-bottom: none;
}

.crm-table .row-name {
  font-weight: 500;
  color: var(--text-primary);
}

.row-name-link {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  font-size: inherit;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}
.row-name-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.crm-table .row-secondary {
  color: var(--text-secondary);
}

/* Row Actions */
.row-actions {
  display: flex;
  gap: 6px;
}

.btn-row-action {
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-row-action:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-row-action.danger:hover {
  border-color: var(--color-error);
  color: var(--color-error);
}

/* Reach Actions (Email / WhatsApp icons in table rows) */
.reach-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.reach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  transition: all 0.15s;
  color: var(--text-secondary);
  text-decoration: none;
}

.reach-btn.reach-email:hover {
  color: var(--color-primary);
  background: rgba(27, 112, 139, 0.08);
}

.reach-btn.reach-wa:hover {
  color: #25D366;
  background: rgba(37, 211, 102, 0.08);
}

.reach-btn.reach-disabled {
  opacity: 0.2;
  cursor: default;
}

/* Inline reach button (detail drawer) */
.reach-btn-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  margin-left: 6px;
  vertical-align: middle;
  transition: all 0.15s;
  text-decoration: none;
}

.reach-btn-inline.reach-wa {
  color: #25D366;
}

.reach-btn-inline.reach-wa:hover {
  background: rgba(37, 211, 102, 0.12);
}

/* Status Badge (reuses site badge pattern) */
.crm-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  text-transform: capitalize;
}

.crm-status.active {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.crm-status.dormant {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.crm-status.lost {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

.crm-status.lead {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-info);
}

.crm-status.prospect {
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
}

.crm-status.inactive {
  background: rgba(107, 114, 128, 0.1);
  color: var(--text-secondary);
}

.reach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-secondary);
  text-decoration: none;
  font-size: 13px;
  border: none;
  cursor: pointer;
}
.reach-btn--wa {
  background: #dcf8c6;
}
.reach-btn--disabled {
  opacity: 0.35;
  cursor: default;
}

/* Deal stage badges */
.crm-stage {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
}

.crm-stage.prospecting {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-info);
}

.crm-stage.proposal {
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
}

.crm-stage.negotiation {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.crm-stage.closed-won {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.crm-stage.closed-lost {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

/* Form Drawer — slides in from right for add/edit forms */
.crm-form-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2000;
}
.crm-form-backdrop.active { display: block; }

.crm-form-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 95vw;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  z-index: 2100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.25);
}
.crm-form-drawer.active { transform: translateX(0); }

.crm-form-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.crm-form-drawer-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.btn-drawer-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 6px;
  transition: all 0.15s;
}
.btn-drawer-close:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.crm-form-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.crm-form-drawer-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.crm-form-group {
  margin-bottom: 16px;
}

.crm-form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.crm-form-group input,
.crm-form-group select,
.crm-form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.crm-form-group input:focus,
.crm-form-group select:focus,
.crm-form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.crm-form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.crm-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 480px) {
  .crm-form-row {
    grid-template-columns: 1fr;
  }
}

.crm-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.btn-modal {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-modal.primary {
  background: var(--color-primary);
  color: white;
  border: none;
}

.btn-modal.primary:hover {
  background: var(--color-accent);
}

.btn-modal.secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-modal.secondary:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

/* Empty State */
.crm-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.crm-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.crm-empty p {
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* Deal Value */
.deal-value {
  font-family: 'Monaco', 'Consolas', monospace;
  font-weight: 500;
}

/* Responsive table scroll */
@media (max-width: 768px) {
  .crm-table-container {
    overflow-x: auto;
  }
  .crm-table {
    min-width: 600px;
  }
}

/* Filter tabs for pipeline view */
.crm-filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.crm-filter-tab {
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.crm-filter-tab:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.crm-filter-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

/* ============================================================
   DETAIL DRAWER — slides in from right, shows record + comments
   ============================================================ */

.crm-detail-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1800;
}
.crm-detail-backdrop.active { display: block; }

.crm-detail-drawer {
  position: fixed;
  top: 0;
  right: -520px;
  width: 500px;
  max-width: 95vw;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  z-index: 1900;
  display: flex;
  flex-direction: column;
  transition: right 0.28s cubic-bezier(0.4,0,0.2,1);
  box-shadow: -12px 0 40px rgba(0,0,0,0.25);
}
.crm-detail-drawer.active { right: 0; }

.crm-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.crm-detail-header-left { flex: 1; min-width: 0; }
.crm-detail-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.crm-detail-meta .badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.crm-detail-meta .badge-type {
  background: rgba(45,156,186,0.15);
  color: var(--color-primary);
}
.crm-detail-meta .badge-status {
  background: rgba(16,185,129,0.12);
  color: var(--color-success);
}
.crm-detail-meta .meta-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.crm-detail-header-actions {
  display: flex;
  gap: 8px;
  margin-left: 12px;
  flex-shrink: 0;
}
.btn-detail-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.btn-detail-close:hover { color: var(--text-primary); background: var(--bg-hover, rgba(255,255,255,0.05)); }
.btn-detail-edit {
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-detail-edit:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* Fields grid */
.crm-detail-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.crm-detail-field {}
.crm-detail-field-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 3px;
}
.crm-detail-field-value {
  font-size: 0.88rem;
  color: var(--text-primary);
  word-break: break-word;
}
.crm-detail-field-value a {
  color: var(--color-primary);
  text-decoration: none;
}
.crm-detail-field-value a:hover { text-decoration: underline; }
.crm-detail-field.full-width { grid-column: 1 / -1; }

/* Comments section */
.crm-detail-comments {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.crm-comments-header {
  padding: 12px 24px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.crm-comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 8px;
}
.crm-comment-empty {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 8px 0;
  font-style: italic;
}
.crm-comment-item {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  animation: fadeInComment 0.2s ease;
}
@keyframes fadeInComment { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.crm-comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.crm-comment-body { flex: 1; min-width: 0; }
.crm-comment-byline {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
}
.crm-comment-author {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}
.crm-comment-time {
  font-size: 0.7rem;
  color: var(--text-secondary);
}
.crm-comment-text {
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.crm-comment-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  align-self: flex-start;
  margin-top: 2px;
}
.crm-comment-item:hover .crm-comment-delete { opacity: 1; }
.crm-comment-delete:hover { color: var(--color-error); }

/* New comment input */
.crm-comment-composer {
  padding: 12px 24px 16px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}
.crm-comment-composer textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  resize: none;
  height: 64px;
  transition: border-color 0.2s, height 0.1s;
  box-sizing: border-box;
}
.crm-comment-composer textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  height: 90px;
}
.crm-comment-composer-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 8px;
}
.btn-post-comment {
  padding: 7px 18px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn-post-comment:hover { background: var(--color-accent, var(--color-accent)); }
.btn-post-comment:disabled { opacity: 0.5; cursor: default; }

/* ============================================================
   DETAIL DRAWER — zone layout (prospecting)
   ============================================================ */

.detail-drawer-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.detail-zone {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
}

.detail-zone-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.detail-zone-activity {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.detail-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.875rem;
}

.detail-label {
  flex: 0 0 90px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.detail-value {
  flex: 1;
  color: var(--text-primary);
  word-break: break-word;
}

.detail-value a {
  color: var(--color-primary);
  text-decoration: none;
}
.detail-value a:hover { text-decoration: underline; }

.detail-field-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: 4px;
}

.detail-empty { color: var(--text-secondary); }

.detail-full-row {
  margin-bottom: 10px;
}

.detail-full-row .detail-label {
  display: block;
  margin-bottom: 4px;
}

.detail-full-row .detail-value {
  display: block;
  font-size: 0.84rem;
  line-height: 1.5;
}

.detail-monospace {
  font-family: var(--font-mono, monospace);
  font-size: 0.8rem;
  white-space: pre-wrap;
  background: var(--bg-hover, rgba(255,255,255,0.04));
  padding: 8px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
}

.detail-verified-icon { color: var(--color-success, #3ecf8e); font-weight: 700; }
.detail-invalid-icon  { color: var(--color-error); font-weight: 700; }

.detail-links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

/* Drawer footer — action buttons (Approve / Reject / Migrate) */
.crm-detail-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
  background: var(--bg-surface, var(--text-primary));
  flex-shrink: 0;
}

/* Enriched link buttons inside drawer fields */
.prosp-drawer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}
.prosp-drawer-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.12));
  background: transparent;
  color: var(--text-secondary, #aaa);
  font-size: 0.82rem;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.prosp-drawer-link-btn:hover {
  border-color: var(--color-primary, #4ea8de);
  color: var(--color-primary, #4ea8de);
}

@media (max-width: 600px) {
  .crm-detail-drawer { width: 100vw; }
  .crm-detail-fields { grid-template-columns: 1fr; }
}

/* ============================================================
   INLINE COMPANY CREATION in contact modal
   ============================================================ */

.crm-inline-company {
  background: var(--bg-primary);
  border: 1px dashed var(--color-primary);
  border-radius: var(--radius-md);
  padding: 14px 16px 4px;
  margin-bottom: 16px;
  animation: slideInInline 0.18s ease;
}
@keyframes slideInInline {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
.crm-inline-company-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.crm-inline-company-header::before {
  content: '＋';
  font-size: 0.9rem;
}

/* ============================================================
   SORT + FILTER
   ============================================================ */

.crm-sort-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: inherit;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  transition: color 0.15s;
}
.crm-sort-btn:hover { color: var(--color-primary); }
.sort-arrow { font-size: 0.7rem; color: var(--color-primary); }

.crm-filter-select {
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
}
.crm-filter-select:focus { outline: none; border-color: var(--color-primary); }

/* ============================================================
   DEALS TOOLBAR — filter tabs + view toggle row
   ============================================================ */

.crm-deals-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.crm-view-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  flex-shrink: 0;
}
.crm-view-btn {
  background: none;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.crm-view-btn:hover { color: var(--text-primary); }
.crm-view-btn.active {
  background: var(--color-primary);
  color: var(--bg-card);
}

/* ============================================================
   DEALS KANBAN BOARD
   ============================================================ */

.crm-kanban-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  padding: 4px 0 8px;
}
@media (max-width: 1100px) { .crm-kanban-board { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .crm-kanban-board { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .crm-kanban-board { grid-template-columns: 1fr; } }

.crm-kanban-col {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 160px;
}
.crm-kanban-col-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 8px;
  border-radius: 10px 10px 0 0;
  background: var(--bg-card);
}
.crm-kanban-col-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.crm-kanban-col-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: 1;
}
.crm-kanban-col-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border-radius: 10px;
  padding: 1px 7px;
}
.crm-kanban-col-value {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-primary);
}
.crm-kanban-col-cards {
  padding: 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.crm-kanban-empty {
  font-size: 0.8rem;
  color: var(--text-muted, var(--text-secondary));
  text-align: center;
  padding: 20px 0;
  opacity: 0.6;
}
.crm-kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}
.crm-kanban-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.crm-kanban-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
  line-height: 1.3;
}
.crm-kanban-card-company {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.crm-kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.crm-kanban-card-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-primary);
}
