/* ── CRM Component Styles ── */

/* ── Activity Timeline ── */
.activity-quick-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.activity-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.activity-btn:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

.activity-timeline {
  position: relative;
  padding-left: 20px;
}
.activity-timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.activity-item {
  position: relative;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--accent-light);
}
.activity-item:last-child { border-bottom: none; margin-bottom: 0; }
.activity-item::before {
  content: "";
  position: absolute;
  left: -17px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 2px solid var(--sidebar-bg);
}
.activity-item[data-type="call"]::before { background: #3498db; }
.activity-item[data-type="email"]::before { background: #9b59b6; }
.activity-item[data-type="meeting"]::before { background: #e67e22; }
.activity-item[data-type="note"]::before { background: #95a5a6; }
.activity-item[data-type="task"]::before { background: #2ecc71; }
.activity-item[data-type="stage_change"]::before { background: #f39c12; }
.activity-item[data-type="data_edit"]::before { background: #7f8c8d; }

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.activity-type-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.activity-time {
  font-size: 10px;
  color: var(--text-muted);
}
.activity-subject {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}
.activity-notes {
  font-size: 12px;
  color: var(--text-muted);
  white-space: pre-wrap;
}
.activity-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  gap: 10px;
}
.activity-user {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.activity-form-inline {
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 12px;
}
.activity-form-inline label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
  margin-top: 8px;
}
.activity-form-inline label:first-child { margin-top: 0; }
.aform-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-left: 8px;
  border-left: 3px solid var(--accent);
}
.aform-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}
.aform-close:hover { color: var(--text); }
.aform-row { margin-bottom: 6px; }
.aform-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.activity-form-inline input,
.activity-form-inline select,
.activity-form-inline textarea {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text);
  background: var(--sidebar-bg);
}
.activity-form-inline textarea { min-height: 60px; resize: vertical; }
.activity-form-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.btn-primary-sm {
  padding: 5px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.btn-primary-sm:hover { background: var(--accent-hover); }
.btn-secondary-sm {
  padding: 5px 14px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.btn-secondary-sm:hover { border-color: var(--accent); color: var(--accent); }
.aq-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.aq-btn:hover { background: var(--accent-light); }
.aq-btn.selected, .ga-type-btn.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-ghost-sm {
  padding: 5px 14px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
}
.btn-ghost-sm:hover { border-color: var(--accent); color: var(--accent); }

/* ── Task List ── */
.task-list { margin-top: 6px; }
.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--accent-light);
  font-size: 12px;
}
.task-item:last-child { border-bottom: none; }
.task-item input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}
.task-title { flex: 1; }
.task-item.completed .task-title {
  text-decoration: line-through;
  opacity: 0.5;
}
.task-due {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
  white-space: nowrap;
}
.task-due.overdue { background: rgba(231,76,60,0.1); color: var(--danger); }
.task-due.today { background: rgba(243,156,18,0.1); color: #f39c12; }
.task-due.upcoming { background: rgba(46,204,113,0.1); color: var(--success); }
.task-priority {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.task-priority.urgent { background: var(--danger); }
.task-priority.high { background: #e67e22; }
.task-priority.normal { background: var(--text-muted); }
.task-priority.low { background: var(--border); }
.task-badge {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
}

/* ── Contact Cards ── */
.contact-list { margin-top: 6px; }
.contact-card {
  display: flex;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  align-items: flex-start;
}
.contact-card.primary { border-left: 3px solid var(--accent); }
.contact-info { flex: 1; min-width: 0; }
.contact-name {
  font-weight: 600;
  font-size: 13px;
}
.contact-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.contact-details {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.contact-primary-badge {
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 2px;
  text-transform: uppercase;
}
.contact-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.contact-actions button {
  background: none;
  border: none;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 4px;
}
.contact-actions button:hover { color: var(--accent); }

/* ── Pipeline Controls in Detail Panel ── */
.pipeline-stage-select {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.pipeline-stage-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
}
.pipeline-stage-btn.active {
  color: #fff;
  border-color: transparent;
}
.pipeline-stage-btn:hover:not(.active) { background: var(--accent-light); }

.assign-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
.assign-row label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.assign-row select {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text);
  background: var(--sidebar-bg);
}

/* ── Bulk Actions ── */
.bulk-toolbar {
  position: fixed;
  bottom: 0;
  left: 256px;
  right: 0;
  background: var(--header-bg);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 500;
  font-size: 12px;
  animation: slideUp 0.15s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.bulk-btn {
  padding: 5px 12px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius);
  background: transparent;
  color: #fff;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}
.bulk-btn:hover { background: rgba(255,255,255,0.1); }
.bulk-btn-clear { opacity: 0.7; }
.bulk-btn-clear:hover { opacity: 1; }

/* ── Export Modal ── */
.export-options {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}
.export-options label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.export-options select {
  padding: 5px 8px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  font-size: 12px;
}

/* ── Modal Wide (templates) ── */
.modal-wide { max-width: 700px; width: 700px; }
.template-preview {
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
}
.merge-field-btn {
  display: inline-block;
  font-size: 11px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: 2px;
  cursor: pointer;
  padding: 1px 6px;
  margin: 2px;
  color: var(--accent);
  font-family: var(--font-body);
}
.merge-field-btn:hover { background: var(--accent-mid); }

/* ── Notification Center ── */
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.notif-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 300;
}
.notif-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
}
.notif-item:hover { background: var(--accent-light); }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 12px; }
.notif-header {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
}

/* ── Pipeline Analytics ── */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.insight-card {
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 0;
  max-height: 400px;
  display: flex;
  flex-direction: column;
}
.insight-card-wide {
  grid-column: 1 / -1;
  max-height: none;
}
.insight-card h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  flex-shrink: 0;
}
.insight-card canvas {
  flex: 1;
  min-height: 0;
  max-height: 320px;
}
.insight-card > div:not(:first-child) {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
#insights-controls {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
  flex-shrink: 0;
}
#insights-period {
  padding: 5px 8px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 12px;
}

/* ── Activities Tab ── */
#activities-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
  flex-shrink: 0;
}
.activity-view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.avt-btn {
  padding: 5px 14px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.avt-btn:not(:last-child) { border-right: 1px solid var(--border); }
.avt-btn.active { background: var(--accent); color: #fff; }
.avt-btn:hover:not(.active) { background: var(--accent-light); }
#activities-list-global {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ── Inbox Summary Bar ── */
.inbox-summary {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.inbox-stat {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}
.inbox-stat-danger { color: var(--danger); background: rgba(192,57,43,0.1); }
.inbox-stat-warning { color: var(--warning); background: rgba(243,156,18,0.1); }
.inbox-stat-muted { color: var(--text-muted); background: var(--accent-light); }

/* ── Inbox Groups ── */
.inbox-group { margin-bottom: 20px; }
.inbox-group:last-child { margin-bottom: 0; }
.inbox-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius);
  margin-bottom: 4px;
  user-select: none;
}
.inbox-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.inbox-group-count {
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(0,0,0,0.08);
}
.inbox-group-danger { background: rgba(192,57,43,0.08); }
.inbox-group-danger .inbox-group-label { color: var(--danger); }
.inbox-group-danger .inbox-group-count { background: var(--danger); color: #fff; }
.inbox-group-warning { background: rgba(243,156,18,0.08); }
.inbox-group-warning .inbox-group-label { color: var(--warning); }
.inbox-group-warning .inbox-group-count { background: var(--warning); color: #fff; }
.inbox-group-info { background: rgba(52,152,219,0.06); }
.inbox-group-info .inbox-group-label { color: #3498db; }
.inbox-group-info .inbox-group-count { background: #3498db; color: #fff; }
.inbox-group-success { background: rgba(39,174,96,0.06); }
.inbox-group-success .inbox-group-label { color: var(--success); }
.inbox-group-success .inbox-group-count { background: var(--success); color: #fff; }
.inbox-group-muted { background: var(--accent-light); }
.inbox-group-muted .inbox-group-label { color: var(--text-muted); }

/* ── Inbox Cards ── */
.inbox-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 2px;
  background: var(--bg);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.25s, transform 0.25s;
  min-height: 44px;
}
.inbox-card:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}
.inbox-card:active {
  transform: scale(0.995);
}
.inbox-card-overdue {
  border-left: 3px solid var(--danger);
}
.inbox-card-done {
  opacity: 0.7;
}
.inbox-card-done .inbox-card-subject {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Card sections */
.inbox-card-check {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.inbox-complete-btn,
.inbox-uncomplete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, transform 0.15s;
}
.inbox-complete-btn:hover {
  color: var(--success);
  transform: scale(1.15);
}
.inbox-uncomplete-btn:hover {
  opacity: 0.7;
}
.inbox-card-type {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  width: 20px;
}
.inbox-card-body {
  flex: 1;
  min-width: 0;
}
.inbox-card-subject {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inbox-card-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
  flex-wrap: wrap;
}
.inbox-card-pharmacy {
  font-weight: 500;
  cursor: pointer;
  transition: color 0.12s;
}
.inbox-card-pharmacy:hover {
  color: var(--accent);
  text-decoration: underline;
}
.inbox-card-stage {
  font-weight: 600;
  font-size: 10px;
}
.inbox-card-note-preview {
  font-style: italic;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-card-outcome {
  font-weight: 500;
  text-transform: capitalize;
}
.inbox-card-due {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 60px;
  text-align: right;
}
.inbox-due-overdue {
  color: var(--danger);
  font-weight: 700;
}
.inbox-card-actions {
  flex-shrink: 0;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  position: relative;
}
.inbox-card:hover .inbox-card-actions {
  opacity: 1;
}
.inbox-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  transition: background 0.12s, color 0.12s;
}
.inbox-action-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* ── Calendar ── */
.cal-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  min-height: 400px;
}

/* Loading */
.cal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.cal-loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: cal-spin 0.6s linear infinite;
}
@keyframes cal-spin { to { transform: rotate(360deg); } }

/* Navigation bar */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cal-nav-left, .cal-nav-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.cal-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  padding: 4px 6px;
  font-family: var(--font-body);
  font-size: 12px;
  transition: background 0.12s, border-color 0.12s;
  min-width: 28px;
  min-height: 28px;
}
.cal-nav-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}
.cal-today-btn {
  padding: 4px 12px;
  font-weight: 600;
}
.cal-today-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.cal-today-active:hover {
  background: var(--accent);
  opacity: 0.9;
}
.cal-week-label {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}
.cal-summary {
  font-size: 11px;
  color: var(--text-muted);
}

/* Grid */
.cal-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.cal-header-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cal-day-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  position: relative;
}
.cal-day-name {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.cal-day-num {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.cal-today-num {
  background: var(--accent);
  color: #fff;
}
.cal-day-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 4px;
}
.cal-past .cal-day-name,
.cal-past .cal-day-num {
  opacity: 0.5;
}

/* Day columns */
.cal-body-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  flex: 1;
  overflow-y: auto;
}
.cal-day-col {
  border-right: 1px solid var(--border);
  padding: 6px;
  min-height: 100px;
  transition: background 0.15s;
}
.cal-day-col:last-child { border-right: none; }
.cal-today-col {
  background: rgba(78, 204, 163, 0.04);
}
.cal-past-col {
  opacity: 0.7;
}

/* Empty day */
.cal-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 60px;
}

/* Activity block */
.cal-block {
  display: flex;
  border-radius: var(--radius);
  margin-bottom: 4px;
  cursor: pointer;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: box-shadow 0.15s, transform 0.12s;
  background: var(--bg);
}
.cal-block:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.cal-block:active {
  transform: scale(0.98);
}
.cal-block-done {
  opacity: 0.55;
}
.cal-block-done .cal-block-subject {
  text-decoration: line-through;
}
.cal-block-accent {
  width: 3px;
  flex-shrink: 0;
  border-radius: var(--radius) 0 0 var(--radius);
}
.cal-block-content {
  flex: 1;
  padding: 5px 6px;
  min-width: 0;
}
.cal-block-top {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}
.cal-block-icon {
  flex-shrink: 0;
}
.cal-block-time {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}
.cal-block-check {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 1px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.12s;
}
.cal-block:hover .cal-block-check {
  opacity: 1;
}
.cal-block-done .cal-block-check {
  opacity: 1;
}
.cal-block-check:hover {
  color: var(--success);
}
.cal-block-subject {
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-block-pharmacy {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* Dark mode — Calendar */
:root.dark .cal-block {
  background: #1a1a2e;
  border-color: rgba(255,255,255,0.08);
}
:root.dark .cal-block:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
:root.dark .cal-day-col {
  border-right-color: rgba(255,255,255,0.06);
}
:root.dark .cal-today-col {
  background: rgba(78,204,163,0.06);
}
:root.dark .cal-nav-btn {
  border-color: rgba(255,255,255,0.1);
  color: var(--text);
}
:root.dark .cal-nav-btn:hover {
  background: rgba(78,204,163,0.08);
  border-color: rgba(78,204,163,0.3);
}
:root.dark .cal-header-row {
  border-bottom-color: rgba(255,255,255,0.06);
}
:root.dark .cal-nav {
  border-bottom-color: rgba(255,255,255,0.06);
}

/* Responsive: stack on narrow screens */
@media (max-width: 640px) {
  .cal-header-row, .cal-body-row {
    grid-template-columns: 1fr;
  }
  .cal-day-header {
    flex-direction: row;
    justify-content: flex-start;
    gap: 8px;
    padding: 6px 12px;
  }
  .cal-day-col {
    border-right: none;
    border-bottom: 1px solid var(--border);
    min-height: auto;
    padding: 8px 12px;
  }
  .cal-day-badge {
    position: static;
  }
}

/* ── Inbox Empty State ── */
.inbox-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}
.inbox-empty p {
  font-size: 14px;
  margin: 0;
}

/* ── Snooze Menu ── */
.inbox-snooze-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 100;
  min-width: 140px;
  overflow: hidden;
}
.inbox-snooze-option {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.inbox-snooze-option:hover {
  background: var(--accent-light);
}
.inbox-snooze-date-input {
  position: absolute;
  right: 0;
  top: -4px;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  z-index: 101;
}

/* ── AVT Badge ── */
.avt-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  font-size: 9px;
  font-weight: 700;
  background: var(--danger);
  color: #fff;
  border-radius: 8px;
  margin-left: 4px;
  padding: 0 4px;
}

/* ── Dark mode: Inbox ── */
:root.dark .inbox-group-danger { background: rgba(192,57,43,0.12); }
:root.dark .inbox-group-warning { background: rgba(243,156,18,0.12); }
:root.dark .inbox-group-info { background: rgba(52,152,219,0.10); }
:root.dark .inbox-group-success { background: rgba(39,174,96,0.10); }
:root.dark .inbox-group-muted { background: rgba(255,255,255,0.03); }
:root.dark .inbox-card { background: #1a1a2e; border-color: rgba(255,255,255,0.08); }
:root.dark .inbox-card:hover { background: rgba(78,204,163,0.06); border-color: rgba(78,204,163,0.2); }
:root.dark .inbox-snooze-menu { background: #16213e; border-color: rgba(255,255,255,0.1); box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
:root.dark .inbox-snooze-option:hover { background: rgba(78,204,163,0.08); }
:root.dark .inbox-stat-danger { background: rgba(192,57,43,0.15); }
:root.dark .inbox-stat-warning { background: rgba(243,156,18,0.15); }
:root.dark .inbox-stat-muted { background: rgba(255,255,255,0.05); }
:root.dark .inbox-group-count { background: rgba(255,255,255,0.1); }
:root.dark .inbox-group-danger .inbox-group-count { background: var(--danger); }
:root.dark .inbox-group-warning .inbox-group-count { background: var(--warning); }
:root.dark .inbox-group-info .inbox-group-count { background: #3498db; }
:root.dark .inbox-group-success .inbox-group-count { background: var(--success); }

/* ── Keyboard Help ── */
#keyboard-help table { border-collapse: collapse; }
#keyboard-help td { padding: 5px 12px; }
#keyboard-help td:first-child { text-align: right; white-space: nowrap; }
kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
}

/* ── Saved Views ── */
.saved-views-wrapper {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.saved-views-wrapper select {
  max-width: 160px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  background: var(--sidebar-bg);
  color: var(--text);
}

/* ── Table row highlight for keyboard nav ── */
.table-row-highlight { background: var(--accent-light) !important; outline: 2px solid var(--accent); outline-offset: -2px; }

/* ── User Avatar ── */
.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── User Cards ── */
.user-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--sidebar-bg);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.user-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(2, 53, 39, 0.08);
}
.user-card-removing {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.3s, transform 0.3s;
}
.user-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}
.user-card .user-avatar {
  width: 36px;
  height: 36px;
  font-size: 13px;
}
.user-card-info { min-width: 0; }
.user-card-name {
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 3px;
  transition: background 0.12s;
  border: 1px solid transparent;
}
.user-card-name:hover {
  background: var(--accent-light);
  border-color: var(--border);
}
.user-card-email {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-card-middle {
  display: flex;
  gap: 20px;
  flex: 1;
  align-items: center;
}
.user-card-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-card-field-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.user-card-field span:not(.user-card-field-label) {
  font-size: 13px;
}
.user-role-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s, transform 0.12s;
  position: relative;
}
.user-role-badge:hover {
  opacity: 0.85;
  transform: scale(1.05);
}
.user-card-territory {
  cursor: pointer;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 3px;
  transition: background 0.12s;
  border: 1px solid transparent;
  font-size: 13px;
}
.user-card-territory:hover {
  background: var(--accent-light);
  border-color: var(--border);
}
.user-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.user-you-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 10px;
}
.user-delete-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  opacity: 0;
}
.user-card:hover .user-delete-btn { opacity: 1; }
.user-delete-btn:hover {
  background: rgba(139, 0, 0, 0.08);
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Inline Edit Input ── */
.inline-edit-input {
  width: 100%;
  padding: 3px 6px;
  border: 2px solid var(--accent);
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  box-shadow: 0 0 0 3px rgba(2, 53, 39, 0.1);
}

/* ── Role Dropdown ── */
.role-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 260px;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 500;
  overflow: hidden;
}
.role-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.1s;
}
.role-option:hover { background: var(--accent-light); }
.role-option.active { background: var(--accent-light); }
.role-option-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}
.role-option-label {
  font-size: 13px;
  font-weight: 600;
}
.role-option-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ── Toast Notifications ── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 20000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: auto;
  max-width: 360px;
}
.toast-visible {
  transform: translateX(0);
  opacity: 1;
}
.toast-hiding {
  transform: translateX(100%);
  opacity: 0;
}
.toast-success {
  background: var(--accent);
  color: #fff;
}
.toast-error {
  background: var(--danger);
  color: #fff;
}
.toast-info {
  background: var(--sidebar-bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.toast-icon {
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.toast-msg {
  line-height: 1.3;
}

/* ── Inline Editable Detail Fields ── */
.detail-value-editable {
  cursor: pointer;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 3px;
  border: 1px dashed transparent;
  transition: background 0.12s, border-color 0.12s;
  min-height: 20px;
}
.detail-value-editable:hover {
  background: var(--accent-light);
  border-color: var(--border);
}
.detail-value-editable::after {
  content: " \270E";
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.12s;
}
.detail-value-editable:hover::after {
  opacity: 0.6;
}
.detail-value-editing {
  padding: 0;
}
.detail-value-editing input,
.detail-value-editing select,
.detail-value-editing textarea {
  width: 100%;
  padding: 4px 6px;
  border: 2px solid var(--accent);
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  box-shadow: 0 0 0 3px rgba(2, 53, 39, 0.1);
}

/* ── Inline Stage Badge in Table ── */
.stage-badge-inline {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.12s, transform 0.12s;
}
.stage-badge-inline:hover {
  opacity: 0.8;
  transform: scale(1.05);
}
.stage-dropdown {
  position: absolute;
  z-index: 600;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  overflow: hidden;
  min-width: 160px;
}
.stage-dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.1s;
}
.stage-dropdown-option:hover { background: var(--accent-light); }
.stage-dropdown-option.active { background: var(--accent-light); font-weight: 600; }
.stage-dropdown-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Inline Assign on Kanban Card ── */
.card-assign {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.card-assign-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.card-assign-avatar:hover { opacity: 0.8; }
.card-assign-name {
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
}
.card-assign-name:hover { color: var(--accent); text-decoration: underline; }

/* ── Save Indicator ── */
.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.2s;
}
.save-indicator.visible { opacity: 1; }

/* ── Dark mode CRM overrides ── */
:root.dark .activity-form-inline { background: rgba(78,204,163,0.04); }
:root.dark .activity-form-inline input,
:root.dark .activity-form-inline select,
:root.dark .activity-form-inline textarea { background: #1a1a2e; }
:root.dark .contact-card { border-color: rgba(255,255,255,0.08); }
:root.dark .bulk-toolbar { background: #0f3460; }
:root.dark .notif-dropdown { background: #16213e; }
:root.dark .insight-card { background: #16213e; }
:root.dark .template-preview { background: #1a1a2e; }
:root.dark .user-card { background: #16213e; border-color: rgba(255,255,255,0.08); }
:root.dark .user-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
:root.dark .user-card-name:hover { background: rgba(78,204,163,0.08); }
:root.dark .user-card-territory:hover { background: rgba(78,204,163,0.08); }
:root.dark .role-dropdown { background: #16213e; }
:root.dark .role-option:hover { background: rgba(78,204,163,0.08); }
:root.dark .stage-dropdown { background: #16213e; }
:root.dark .stage-dropdown-option:hover { background: rgba(78,204,163,0.08); }
:root.dark .detail-value-editable:hover { background: rgba(78,204,163,0.08); }
:root.dark .toast-info { background: #16213e; }
:root.dark .inline-edit-input { background: #1a1a2e; box-shadow: 0 0 0 3px rgba(78,204,163,0.15); }

/* ── Stage Progress Bar (Pipedrive-style) ── */
.stage-progress-bar {
  display: flex;
  align-items: center;
  padding: 12px 0;
  margin-bottom: 12px;
  overflow-x: auto;
}
.stage-progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  min-width: 60px;
  transition: transform 0.15s;
}
.stage-progress-step:hover { transform: scale(1.08); }
.stage-progress-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  transition: all 0.2s;
}
.stage-progress-step.completed .stage-progress-dot {
  background: var(--stage-color);
  border-color: var(--stage-color);
}
.stage-progress-step.current .stage-progress-dot {
  background: var(--stage-color);
  border-color: var(--stage-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--stage-color) 25%, transparent);
  width: 20px;
  height: 20px;
}
.stage-progress-step.terminal .stage-progress-dot {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--stage-color) 30%, transparent);
}
.stage-progress-label {
  font-size: 10px;
  margin-top: 4px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}
.stage-progress-step.current .stage-progress-label {
  color: var(--stage-color);
  font-weight: 700;
}
.stage-progress-step.completed .stage-progress-label {
  color: var(--text);
}
.stage-progress-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 16px;
  margin: 0 2px;
  margin-bottom: 18px;
}
.stage-progress-connector.filled {
  background: var(--accent);
}
.stage-days-indicator {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding: 4px 8px;
  background: var(--accent-light);
  border-radius: var(--radius);
  display: inline-block;
}
.stage-days-indicator.rotten {
  color: var(--danger);
  background: rgba(192, 57, 43, 0.08);
  font-weight: 600;
}

/* ── Lost Reason Modal ── */
.lost-reason-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.lost-reason-modal {
  background: white;
  border-radius: 8px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.lost-reason-modal h3 {
  color: var(--danger);
  margin-bottom: 8px;
  font-family: var(--font-heading);
}
.lost-reason-modal p { margin-bottom: 12px; font-size: 13px; }
.lost-reason-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.lost-reason-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.lost-reason-options label:hover { background: var(--accent-light); }
.lost-reason-modal textarea {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  padding: 8px;
  font-family: var(--font-body);
  font-size: 12px;
  margin-bottom: 12px;
  resize: vertical;
}
.lost-reason-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.btn-danger-sm {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: white !important;
}
.btn-danger-sm:hover { opacity: 0.9; }

/* ── Won Celebration ── */
.won-celebration {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
}
.won-celebration.visible { opacity: 1; }
.won-content {
  text-align: center;
  animation: wonBounce 0.6s ease-out;
}
.won-emoji { font-size: 72px; margin-bottom: 8px; }
.won-title {
  font-family: var(--font-heading);
  font-size: 28px;
  color: #27ae60;
  text-shadow: 0 2px 12px rgba(39,174,96,0.3);
  margin-bottom: 4px;
}
.won-pharmacy {
  font-size: 16px;
  color: var(--text);
  font-weight: 600;
}
@keyframes wonBounce {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Schedule Next Prompt ── */
.schedule-next-prompt {
  background: linear-gradient(135deg, rgba(39,174,96,0.05), rgba(52,152,219,0.05));
  border: 1px solid rgba(39,174,96,0.2);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
  animation: slideDown 0.2s ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.schedule-next-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
}
.schedule-next-icon { font-size: 16px; }
.schedule-next-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}
.schedule-next-btn { font-size: 11px !important; padding: 3px 8px !important; }
.schedule-next-dismiss { font-size: 11px !important; }

/* ── Quick Add Modal ── */
.quick-add-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  z-index: 10000;
}
.quick-add-modal {
  background: white;
  border-radius: 8px;
  padding: 20px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  animation: slideDown 0.2s ease-out;
}
.quick-add-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.quick-add-header h3 {
  font-family: var(--font-heading);
  font-size: 16px;
}
.quick-add-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}
.quick-add-types {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.quick-add-type-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: white;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-body);
}
.quick-add-type-btn:hover { background: var(--accent-light); }
.quick-add-type-btn.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.quick-add-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quick-add-form input, .quick-add-form textarea {
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 13px;
}
.quick-add-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.qa-pharmacy-results {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: none;
}
.qa-pharmacy-results:not(:empty) { display: block; }
.qa-pharmacy-option {
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.qa-pharmacy-option:last-child { border-bottom: none; }
.qa-pharmacy-option:hover { background: var(--accent-light); }

/* ── Forecast Progress Bars ── */
.forecast-prob-bar {
  position: relative;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 6px;
  overflow: visible;
}
.forecast-prob-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}
.forecast-prob-label {
  position: absolute;
  right: 0;
  top: -14px;
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Dark mode overrides for new components ── */
:root.dark .lost-reason-modal { background: #16213e; }
:root.dark .lost-reason-modal h3 { color: #ff6b6b; }
:root.dark .lost-reason-options label:hover { background: rgba(78,204,163,0.08); }
:root.dark .lost-reason-modal textarea { background: #1a1a2e; border-color: rgba(255,255,255,0.2); color: #e0e0e0; }
:root.dark .won-title { color: #51cf66; }
:root.dark .quick-add-modal { background: #16213e; }
:root.dark .quick-add-type-btn { background: #1a1a2e; border-color: rgba(255,255,255,0.1); color: #e0e0e0; }
:root.dark .quick-add-type-btn.selected { background: var(--accent); }
:root.dark .quick-add-form input, :root.dark .quick-add-form textarea { background: #1a1a2e; border-color: rgba(255,255,255,0.2); color: #e0e0e0; }
:root.dark .qa-pharmacy-results { background: #1a1a2e; border-color: rgba(255,255,255,0.1); }
:root.dark .qa-pharmacy-option:hover { background: rgba(78,204,163,0.08); }
:root.dark .schedule-next-prompt { background: rgba(78,204,163,0.05); border-color: rgba(78,204,163,0.15); }
:root.dark .stage-progress-dot { background: #1a1a2e; border-color: rgba(255,255,255,0.2); }

/* ══════════════════════════════════════
   Workflow Cards & Editor
   ══════════════════════════════════════ */
.wf-list { display: flex; flex-direction: column; gap: 10px; }
.wf-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--sidebar-bg);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.wf-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(2,53,39,0.06); }
.wf-card-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;
}
.wf-card-name { font-weight: 600; font-size: 14px; }
.wf-card-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-weight: 600; color: #fff;
}
.wf-card-badge.active { background: var(--success); }
.wf-card-badge.paused { background: var(--warning); color: var(--text); }
.wf-card-badge.draft { background: var(--text-muted); }
.wf-card-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 12px; }
.wf-card-stats { display: flex; gap: 16px; margin-top: 8px; font-size: 12px; }
.wf-card-stat { display: flex; flex-direction: column; }
.wf-card-stat-value { font-weight: 600; font-size: 16px; }
.wf-card-stat-label { font-size: 10px; color: var(--text-muted); }

/* Workflow Editor Modal */
.wf-editor-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 10000;
}
.wf-editor-modal {
  background: var(--sidebar-bg); border-radius: 8px; padding: 24px;
  max-width: 640px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.wf-editor-close {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--text-muted); line-height: 1;
}
.wf-editor-close:hover { color: var(--text); }
.wf-step-list { margin: 12px 0; }
.wf-step-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 6px; background: var(--bg);
}
.wf-step-icon { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.wf-step-body { flex: 1; min-width: 0; }
.wf-step-body select, .wf-step-body input {
  padding: 4px 8px; border: 1px solid var(--input-border); border-radius: var(--radius);
  font-family: var(--font-body); font-size: 12px; width: 100%; margin-bottom: 4px;
}
.wf-step-remove {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 14px;
}
.wf-step-remove:hover { color: var(--danger); }

/* Workflow Detail Panel */
.wf-detail { padding: 16px; }
.wf-detail-header { display: flex; justify-content: space-between; margin-bottom: 16px; }
.wf-step-timeline { position: relative; padding-left: 24px; }
.wf-step-timeline::before {
  content: ""; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px;
  background: var(--border);
}
.wf-step-timeline-item {
  position: relative; margin-bottom: 16px; padding: 10px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--sidebar-bg);
}
.wf-step-timeline-item::before {
  content: ""; position: absolute; left: -20px; top: 14px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-muted); border: 2px solid var(--sidebar-bg);
}
.wf-enrollment-table { width: 100%; font-size: 12px; border-collapse: collapse; margin-top: 12px; }
.wf-enrollment-table th, .wf-enrollment-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--border); }
.wf-enrollment-table th { font-size: 10px; text-transform: uppercase; color: var(--text-muted); }
.wf-preset-btn {
  padding: 8px 12px; border: 1px dashed var(--border); border-radius: var(--radius);
  background: transparent; cursor: pointer; text-align: left; width: 100%; margin-bottom: 6px;
  font-family: var(--font-body); font-size: 12px; transition: all 0.15s;
}
.wf-preset-btn:hover { border-color: var(--accent); background: var(--accent-light); }

/* ══════════════════════════════════════
   Territory Management
   ══════════════════════════════════════ */
.territory-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px; padding: 0;
}
.territory-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; background: var(--sidebar-bg);
}
.territory-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.territory-region { font-weight: 600; font-size: 14px; }
.territory-count { font-size: 11px; color: var(--text-muted); }
.territory-provinces { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; line-height: 1.4; }
.territory-assigned { display: flex; flex-wrap: wrap; gap: 4px; }
.territory-user {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-weight: 600; background: var(--accent-light); color: var(--accent);
}

/* Team Targets Table */
.team-targets-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.team-targets-table th, .team-targets-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.team-targets-table th { font-size: 10px; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.target-bar {
  height: 6px; background: var(--border); border-radius: 3px; width: 60px;
  display: inline-block; vertical-align: middle; margin-right: 6px;
}
.target-bar-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.3s; }
.target-input {
  width: 60px; padding: 3px 6px; border: 1px solid var(--input-border);
  border-radius: var(--radius); font-size: 12px; text-align: center;
}

/* Handoff Modal */
.handoff-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 10000;
}
.handoff-modal {
  background: var(--sidebar-bg); border-radius: 8px; padding: 24px;
  max-width: 480px; width: 90%; box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.handoff-modal h3 { font-family: var(--font-heading); margin-bottom: 8px; }
.handoff-modal select, .handoff-modal textarea {
  width: 100%; padding: 8px; border: 1px solid var(--input-border);
  border-radius: var(--radius); font-family: var(--font-body); font-size: 12px; margin-top: 4px;
}

/* Audit Table */
.audit-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.audit-table th, .audit-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--border); }
.audit-table th { font-size: 10px; text-transform: uppercase; color: var(--text-muted); }

/* Manager Dashboard */
.manager-dashboard { padding: 0; }
.manager-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px;
}
.manager-rep-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; background: var(--sidebar-bg);
}
.manager-rep-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.manager-rep-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.manager-rep-name { font-weight: 600; font-size: 14px; }
.manager-rep-role { font-size: 11px; color: var(--text-muted); }
.manager-rep-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; text-align: center; }
.manager-stat-value { font-weight: 700; font-size: 16px; }
.manager-stat-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; }
.manager-alert {
  font-size: 11px; color: var(--danger); font-weight: 600; margin-top: 8px;
  padding: 4px 8px; background: rgba(139,0,0,0.05); border-radius: var(--radius);
}
.manager-alert-banner {
  margin-top: 16px; padding: 10px 14px; background: rgba(248,190,0,0.08);
  border: 1px solid rgba(248,190,0,0.2); border-radius: var(--radius);
  font-size: 12px; display: flex; align-items: center; gap: 8px;
}

/* ══════════════════════════════════════
   Data Quality Dashboard
   ══════════════════════════════════════ */
.dq-dashboard { padding: 0; }
.dq-metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.dq-metric {
  text-align: center; padding: 12px; background: var(--sidebar-bg);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.dq-metric-value { font-size: 24px; font-weight: 700; }
.dq-metric-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.dq-section { margin-bottom: 16px; }
.dq-section h4 { font-size: 12px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; letter-spacing: 0.5px; }
.dq-missing-grid { display: flex; flex-direction: column; gap: 6px; }
.dq-missing-item {
  display: grid; grid-template-columns: 100px auto 1fr; gap: 8px; align-items: center; font-size: 12px;
}
.dq-missing-count { font-weight: 600; font-size: 12px; }
.dq-missing-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.dq-missing-bar > div { height: 100%; background: var(--danger); border-radius: 3px; }
.dq-chains { display: flex; flex-direction: column; gap: 4px; }
.dq-chain-item {
  display: flex; gap: 16px; font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--accent-light);
}
.dq-chain-name { font-weight: 600; min-width: 120px; }
.dq-flags { display: flex; flex-direction: column; gap: 4px; }
.dq-flag-item { display: flex; gap: 12px; font-size: 12px; padding: 4px 0; }
.dq-flag-msg { color: var(--text-muted); }

/* Enrichment Form */
.enrichment-form { display: flex; flex-direction: column; gap: 6px; }
.enrichment-field-row {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
}
.enrichment-field-row label { min-width: 100px; font-weight: 500; color: var(--text-muted); font-size: 11px; }
.enrichment-field-row input[type="text"],
.enrichment-field-row input[type="tel"],
.enrichment-field-row input[type="email"] {
  flex: 1; padding: 4px 8px; border: 1px solid var(--input-border);
  border-radius: var(--radius); font-family: var(--font-body); font-size: 12px;
}
.enrichment-field-row textarea {
  flex: 1; padding: 4px 8px; border: 1px solid var(--input-border);
  border-radius: var(--radius); font-family: var(--font-body); font-size: 12px; resize: vertical;
}

/* ══════════════════════════════════════
   AI Features
   ══════════════════════════════════════ */
.ai-summary {
  font-size: 12px; line-height: 1.5; padding: 8px; background: var(--accent-light);
  border-radius: var(--radius); white-space: pre-wrap;
}
.ai-recommendation {
  font-size: 12px; line-height: 1.5; padding: 8px;
  background: linear-gradient(135deg, rgba(52,152,219,0.05), rgba(155,89,182,0.05));
  border: 1px solid rgba(52,152,219,0.15); border-radius: var(--radius);
}
.ai-email-draft { margin-top: 4px; }

/* ══════════════════════════════════════
   Advanced Table Features
   ══════════════════════════════════════ */

/* Quick Filters */
.quick-filters {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0;
}
.quick-filter-btn {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 20px;
  background: transparent; font-family: var(--font-body); font-size: 11px;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.quick-filter-btn:hover { background: var(--accent-light); border-color: var(--accent); }
.quick-filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Advanced Filter Builder */
.adv-filter-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 10000;
}
.adv-filter-modal {
  background: var(--sidebar-bg); border-radius: 8px; padding: 24px;
  max-width: 600px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.adv-filter-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.adv-filter-header h3 { font-family: var(--font-heading); margin: 0; }
.adv-filter-logic { display: flex; gap: 16px; margin-bottom: 12px; font-size: 12px; }
.adv-filter-logic label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.adv-filter-rule {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px;
  margin-bottom: 6px; align-items: center;
}
.adv-filter-rule select, .adv-filter-rule input {
  padding: 5px 8px; border: 1px solid var(--input-border); border-radius: var(--radius);
  font-family: var(--font-body); font-size: 12px;
}
.adv-rule-remove {
  background: none; border: none; font-size: 16px; cursor: pointer;
  color: var(--text-muted); padding: 0 4px;
}
.adv-rule-remove:hover { color: var(--danger); }
.adv-filter-actions { display: flex; gap: 8px; margin-top: 16px; }

/* Duplicate Detection */
.duplicate-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 10000;
}
.duplicate-modal {
  background: var(--sidebar-bg); border-radius: 8px; padding: 24px;
  max-width: 700px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.duplicate-list { display: flex; flex-direction: column; gap: 8px; }
.duplicate-pair {
  display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 10px;
  align-items: center; padding: 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 12px;
}
.duplicate-name { font-weight: 600; display: block; }
.duplicate-city { font-size: 11px; color: var(--text-muted); }
.duplicate-address { font-size: 11px; color: var(--text-muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duplicate-match { text-align: center; }
.duplicate-similarity { font-weight: 700; color: var(--warning); display: block; }
.duplicate-reason { font-size: 10px; color: var(--text-muted); }

/* Row Comparison */
.compare-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 10001;
}
.compare-modal {
  background: var(--sidebar-bg); border-radius: 8px; padding: 24px;
  max-width: 800px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.compare-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.compare-table th, .compare-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.compare-table th { font-weight: 600; background: var(--accent-light); position: sticky; top: 0; }
.compare-label { font-weight: 600; color: var(--text-muted); min-width: 120px; }
.compare-diff { background: rgba(248,190,0,0.06); }

/* Import Modal */
.import-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 10000;
}
.import-modal {
  background: var(--sidebar-bg); border-radius: 8px; padding: 24px;
  max-width: 700px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.import-body table { width: 100%; border-collapse: collapse; font-size: 11px; }
.import-body th, .import-body td { padding: 4px 8px; border-bottom: 1px solid var(--border); }
.import-body select { padding: 3px 6px; font-size: 11px; border: 1px solid var(--input-border); border-radius: var(--radius); }
.import-actions { display: flex; gap: 8px; }

/* Reset Password Modal */
.reset-pwd-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 10000;
}

/* Workflow Editor, Territory Assign, Meeting Brief overlays */
.workflow-editor-overlay,
.territory-assign-overlay,
.meeting-brief-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 10000;
}

/* ══════════════════════════════════════
   Dark mode overrides for new modules
   ══════════════════════════════════════ */
:root.dark .wf-card { background: #16213e; border-color: rgba(255,255,255,0.08); }
:root.dark .wf-card:hover { border-color: var(--accent); }
:root.dark .wf-editor-modal { background: #16213e; }
:root.dark .wf-step-item { background: #1a1a2e; border-color: rgba(255,255,255,0.08); }
:root.dark .wf-step-body select, :root.dark .wf-step-body input { background: #1a1a2e; color: #e0e0e0; border-color: rgba(255,255,255,0.2); }
:root.dark .territory-card { background: #16213e; border-color: rgba(255,255,255,0.08); }
:root.dark .manager-rep-card { background: #16213e; border-color: rgba(255,255,255,0.08); }
:root.dark .handoff-modal { background: #16213e; }
:root.dark .handoff-modal select, :root.dark .handoff-modal textarea { background: #1a1a2e; color: #e0e0e0; border-color: rgba(255,255,255,0.2); }
:root.dark .dq-metric { background: #16213e; border-color: rgba(255,255,255,0.08); }
:root.dark .adv-filter-modal { background: #16213e; }
:root.dark .adv-filter-rule select, :root.dark .adv-filter-rule input { background: #1a1a2e; color: #e0e0e0; border-color: rgba(255,255,255,0.2); }
:root.dark .duplicate-modal { background: #16213e; }
:root.dark .duplicate-pair { border-color: rgba(255,255,255,0.08); }
:root.dark .compare-modal { background: #16213e; }
:root.dark .compare-table th { background: rgba(78,204,163,0.08); }
:root.dark .import-modal { background: #16213e; }
:root.dark .import-body select { background: #1a1a2e; color: #e0e0e0; }
:root.dark .ai-summary { background: rgba(78,204,163,0.05); }
:root.dark .enrichment-field-row input, :root.dark .enrichment-field-row textarea { background: #1a1a2e; color: #e0e0e0; border-color: rgba(255,255,255,0.2); }

/* ── Zip Code Chips ── */
.zip-chip {
  display: inline-block;
  background: rgba(0,128,128,0.1);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 3px;
}
.btn-zip-edit {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 10px;
  padding: 2px 6px;
}
.btn-zip-edit:hover { border-color: var(--accent); color: var(--accent); }
.zip-assigner-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; min-height: 24px; }
.zip-assigner-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,128,128,0.1);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.zip-assigner-chip .zip-count { font-weight: 400; color: var(--text-muted); font-size: 11px; }
.zip-assigner-chip .zip-remove {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 2px;
}
.zip-assigner-chip .zip-remove:hover { color: var(--danger); }

/* ── My Area Panel ── */
.btn-my-area-toggle {
  position: absolute; top: 10px; right: 10px; z-index: 1000;
  background: var(--sidebar-bg); border: 1px solid var(--border);
  padding: 6px 14px; border-radius: var(--radius); cursor: pointer;
  font-family: var(--font-body); font-size: 12px; color: var(--text);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.btn-my-area-toggle:hover { border-color: var(--accent); }
.btn-my-area-toggle.btn-reload-active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.my-area-panel {
  position: absolute; bottom: 20px; left: 20px; z-index: 1000;
  background: var(--sidebar-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px; max-width: 320px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15); font-size: 12px;
}
.my-area-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.my-area-territory { font-size: 11px; color: var(--text-muted); }
.my-area-prefixes { margin-bottom: 6px; }
.my-area-stats { display: flex; gap: 12px; margin-bottom: 6px; }
.my-area-stat-val { font-weight: 700; font-size: 16px; }
.my-area-pipeline { font-size: 11px; color: var(--text-muted); line-height: 1.6; }
.leaflet-marker-dimmed { opacity: 0.15 !important; }

/* ══════════════════════════════════════════
   Permissions & Roles UI
   ══════════════════════════════════════════ */

/* Users sub-tabs */
.users-sub-tabs {
  display: flex;
  gap: 2px;
  padding: 0 16px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}
.users-sub-tab {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.users-sub-tab:hover { color: var(--text); }
.users-sub-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.users-cards-grid { display: flex; flex-direction: column; gap: 8px; }

/* Roles manager */
.roles-manager { padding: 0 16px; }
.roles-manager-header { margin-bottom: 16px; }
.roles-manager-header h3 { font-size: 16px; margin: 0; }
.roles-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.role-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--bg);
  transition: box-shadow 0.15s;
}
.role-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.role-card-system { border-left: 3px solid var(--text-muted); }
.role-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.role-card-badge {
  display: inline-block;
  color: #fff;
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
}
.role-card-level {
  font-size: 11px;
  color: var(--text-muted);
}
.role-card-system-badge {
  font-size: 10px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 3px;
}
.role-card-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  margin-left: auto;
}
.role-card-delete:hover { color: var(--danger); }
.role-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 8px;
  line-height: 1.4;
}
.role-card-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Permission editor */
.perm-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}
.perm-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
}
.perm-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.perm-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.perm-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}
.perm-group-count {
  font-size: 11px;
  color: var(--text-muted);
}
.perm-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
  cursor: pointer;
}
.perm-checkbox-row input[type="checkbox"] {
  margin: 0;
  accent-color: var(--accent);
}
.perm-checkbox-label { flex: 1; }
.perm-checkbox-key {
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(0,0,0,0.04);
  padding: 1px 4px;
  border-radius: 2px;
}

/* Permission override three-state toggle */
.perm-override-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.perm-override-label { flex: 1; }
.perm-override-from-role { min-width: 50px; text-align: center; }
.perm-override-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.pot-btn {
  background: none;
  border: none;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 700;
  transition: background 0.1s, color 0.1s;
}
.pot-btn:hover { background: rgba(0,0,0,0.04); }
.pot-btn.pot-active { background: var(--bg); color: var(--text); }
.pot-btn.pot-grant.pot-active { background: rgba(39,174,96,0.12); color: #27ae60; }
.pot-btn.pot-revoke.pot-active { background: rgba(231,76,60,0.12); color: var(--danger); }

/* Teams manager */
.teams-manager { padding: 0 16px; }
.teams-manager-header { margin-bottom: 16px; }
.teams-manager-header h3 { font-size: 16px; margin: 0; }
.teams-org-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.team-tree-node {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--bg);
}
.team-tree-supervisor { border-left: 3px solid var(--accent); }
.team-tree-unassigned { border-left: 3px solid var(--text-muted); opacity: 0.8; }
.team-tree-node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.team-tree-reports {
  padding-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.team-tree-employee {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 12px;
}
.team-tree-employee:hover { background: rgba(0,0,0,0.02); }
.team-add-employee {
  padding: 4px 8px;
}
.team-add-select, .team-assign-select {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  cursor: pointer;
}
.team-add-select:hover, .team-assign-select:hover { border-color: var(--accent); color: var(--accent); }

/* Overrides list */
.overrides-manager { padding: 0 16px; }
.overrides-manager-header { margin-bottom: 16px; }
.overrides-manager-header h3 { font-size: 16px; margin: 0; }
.overrides-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.override-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
}
.override-row:hover { background: rgba(0,0,0,0.02); }
.override-row-active { border-color: var(--accent); background: rgba(0,128,128,0.03); }

/* Gear button on user cards */
.user-perms-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 6px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
}
.user-perms-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Dark mode overrides */
:root.dark .role-card { background: var(--bg); }
:root.dark .team-tree-node { background: var(--bg); }
:root.dark .team-tree-employee:hover { background: rgba(255,255,255,0.03); }
:root.dark .override-row:hover { background: rgba(255,255,255,0.03); }
:root.dark .perm-checkbox-key { background: rgba(255,255,255,0.06); }
:root.dark .perm-group { border-color: var(--border); }
:root.dark .pot-btn:hover { background: rgba(255,255,255,0.06); }
:root.dark .pot-btn.pot-active { background: rgba(255,255,255,0.08); }
:root.dark .pot-btn.pot-grant.pot-active { background: rgba(39,174,96,0.15); }
:root.dark .pot-btn.pot-revoke.pot-active { background: rgba(231,76,60,0.15); }

/* ══════════════════════════════════════════
   Map Card — Rich pharmacy card
   ══════════════════════════════════════════ */

.map-card-container {
  position: absolute;
  inset: 0;
  z-index: 1100;
  display: none;
  background: rgba(0,0,0,0.4);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.map-card {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 380px;
  max-height: calc(100% - 20px);
  overflow-y: auto;
  background: var(--sidebar-bg, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--text);
}

/* Photos */
.mc-photos { overflow: hidden; border-radius: 10px 10px 0 0; }
.mc-photos-scroll {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.mc-photo {
  width: 100%;
  min-width: 100%;
  height: 160px;
  object-fit: cover;
  scroll-snap-align: start;
}

/* Body */
.mc-body { padding: 12px 14px; }

/* Header */
.mc-header { margin-bottom: 8px; }
.mc-title-row { display: flex; align-items: center; gap: 6px; }
.mc-name { font-size: 15px; font-weight: 700; margin: 0; line-height: 1.3; font-family: var(--font-heading); }
.mc-biz-status { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 3px; text-transform: uppercase; }
.mc-biz-closed_temporarily { background: #f39c12; color: #fff; }
.mc-biz-closed_permanently { background: #c0392b; color: #fff; }

/* Badges */
.mc-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.mc-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.mc-badge-customer { background: rgba(39,174,96,0.12); color: #27ae60; }
.mc-badge-prospect { background: rgba(52,152,219,0.12); color: #3498db; }
.mc-badge-stage { color: #fff; }
.mc-badge-score { background: var(--accent-light, rgba(0,128,128,0.1)); color: var(--accent); }

/* Rating */
.mc-rating { display: block; font-size: 12px; margin-top: 4px; color: #f39c12; }
.mc-rating-count { color: var(--text-muted); font-size: 11px; }

/* Info rows */
.mc-info { margin-bottom: 8px; }
.mc-info-row { line-height: 1.6; color: var(--text-muted); }
.mc-info-row a { color: var(--accent); text-decoration: none; }
.mc-info-row a:hover { text-decoration: underline; }
.mc-phone a { font-weight: 600; color: var(--text); }

/* Brands */
.mc-brands { margin-bottom: 8px; }
.mc-brands-label { font-weight: 600; font-size: 11px; }
.mc-brand-chip {
  display: inline-block;
  background: var(--accent-light, rgba(0,128,128,0.08));
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  margin: 1px 2px;
}

/* Income */
.mc-income { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }

/* Editorial summary */
.mc-editorial {
  font-size: 12px;
  color: var(--text);
  font-style: italic;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: var(--accent-light, rgba(0,128,128,0.05));
  border-radius: 4px;
  line-height: 1.5;
}

/* Google extra details */
.mc-google-extra { border-top: 1px solid var(--border); padding-top: 6px; margin-bottom: 8px; }
.mc-extra-row { font-size: 11px; color: var(--text-muted); line-height: 1.7; }
.mc-extra-row a { color: var(--accent); text-decoration: none; }
.mc-extra-label { font-weight: 600; margin-right: 4px; }
.mc-type-chip {
  display: inline-block;
  background: rgba(0,0,0,0.05);
  padding: 0 4px;
  border-radius: 3px;
  font-size: 10px;
  margin: 0 1px;
}

/* Hours */
.mc-hours { margin-bottom: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.mc-hours-title { font-weight: 600; font-size: 11px; margin-bottom: 4px; }
.mc-hours-line { font-size: 11px; color: var(--text-muted); line-height: 1.5; }

/* Reviews */
.mc-reviews { margin-bottom: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.mc-reviews-title { font-weight: 600; font-size: 11px; margin-bottom: 6px; }
.mc-review { margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--accent-light); }
.mc-review:last-child { border-bottom: none; margin-bottom: 0; }
.mc-review-header { font-size: 11px; color: #f39c12; }
.mc-review-time { color: var(--text-muted); font-size: 10px; }
.mc-review-text { font-size: 11px; color: var(--text-muted); line-height: 1.4; margin-top: 2px; }

/* IDs and freshness */
.mc-ids { border-top: 1px solid var(--border); padding-top: 6px; margin-bottom: 8px; }
.mc-id-row { font-size: 10px; color: var(--text-muted); }
.mc-id-label { font-weight: 600; }
.mc-id-value { font-family: monospace; font-size: 10px; user-select: all; }
.mc-freshness { font-size: 10px; font-weight: 600; margin-top: 2px; }

/* Actions */
.mc-actions { border-top: 1px solid var(--border); padding-top: 8px; }
.mc-actions-row { display: flex; gap: 4px; margin-bottom: 4px; }
.mc-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--sidebar-bg);
  color: var(--text);
  font-size: 11px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.mc-btn:hover { border-color: var(--accent); color: var(--accent); }
.mc-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.mc-btn-gmaps { background: #4285f4; color: #fff; border-color: #4285f4; text-decoration: none; display: inline-block; text-align: center; }
.mc-btn-gmaps:hover { background: #3367d6; color: #fff; }
.mc-btn-details { background: var(--accent, teal); color: #fff; border-color: var(--accent, teal); flex: 1; }
.mc-btn-details:hover { opacity: 0.85; color: #fff; }
.mc-btn-refresh { width: 32px; text-align: center; padding: 5px; }
.mc-btn-assign { flex: 1; }
.mc-btn-stage { flex: 0 0 auto; }
.mc-btn-note { flex: 0 0 auto; }

/* Overlays inside card — bottom sheet anchored near action buttons */
.mc-overlay {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  padding: 10px 14px 14px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
  animation: mc-slide-up 0.2s ease-out;
}
@keyframes mc-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.mc-overlay-content {
  background: transparent;
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
}
.mc-overlay-content h4 { font-family: var(--font-heading); font-size: 13px; margin: 0 0 8px; }

/* Assign list */
.mc-assign-list { max-height: 200px; overflow-y: auto; margin-bottom: 8px; }
.mc-assign-option {
  padding: 8px 10px;
  min-height: 36px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.12s;
  display: flex;
  align-items: center;
}
.mc-assign-option:hover { background: var(--accent-light, rgba(0,128,128,0.08)); }
.mc-assign-option.mc-assign-active {
  background: var(--accent-light, rgba(0,128,128,0.12));
  font-weight: 600;
  border-left: 3px solid var(--accent);
}

/* Stage list */
.mc-stage-list { margin-bottom: 8px; }
.mc-stage-option {
  padding: 8px 10px;
  min-height: 36px;
  margin-bottom: 2px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.12s, transform 0.1s;
  display: flex;
  align-items: center;
}
.mc-stage-option:hover { background: var(--accent-light, rgba(0,128,128,0.08)); }
.mc-stage-option:active { transform: scale(0.98); }
.mc-stage-option.mc-stage-active { font-weight: 700; background: var(--accent-light, rgba(0,128,128,0.06)); }

/* Note input */
.mc-note-input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
}

/* Cancel button */
.mc-btn-cancel { width: 100%; text-align: center; }
.mc-btn-save { flex: 1; background: var(--accent); color: #fff; border-color: var(--accent); }

/* Responsive: smaller screens */
@media (max-width: 768px) {
  .map-card {
    position: fixed;
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
  }
}
