/* ============================================================
   Zysk CRM — Design System Theme
   Consistent look and feel across the entire CRM.
   ============================================================ */

:root {
  /* ── Page ── */
  --bg-page: #F5F1EA;
  --bg-card: #ffffff;

  /* ── Text ── */
  --text-primary: #1B3022;
  --text-secondary: #3d4f43;
  --text-muted: #4A6B5E;

  /* ── Borders ── */
  --border: #ddd8d0;
  --border-light: #EBE5DA;

  /* ── Shadows ── */
  --shadow-sm: 0 1px 2px rgba(27, 48, 34, 0.05);
  --shadow: 0 1px 3px rgba(27, 48, 34, 0.06), 0 1px 2px rgba(27, 48, 34, 0.04);
  --shadow-md: 0 4px 6px rgba(27, 48, 34, 0.06), 0 2px 4px rgba(27, 48, 34, 0.04);
  --shadow-lg: 0 10px 15px rgba(27, 48, 34, 0.08), 0 4px 6px rgba(27, 48, 34, 0.04);

  /* ── Radius ── */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;

  /* ── Spacing ── */
  --spacing-page: 24px;
  --spacing-card: 16px;

  /* ── Colors ── */
  --color-primary: #C5A059;
  --color-primary-hover: #9E7F3E;
  --color-primary-light: rgba(197, 160, 89, 0.12);
  --color-success: #2D6A4F;
  --color-success-light: rgba(45, 106, 79, 0.1);
  --color-danger: #8B3A2F;
  --color-danger-light: rgba(139, 58, 47, 0.08);
  --color-warning: #9A6B1F;
  --color-warning-light: rgba(154, 107, 31, 0.1);

  /* ── CRM specific ── */
  --crm-rail: #1B3022;
  --crm-gold: #C5A059;
  --crm-gold-light: rgba(197, 160, 89, 0.2);
  --crm-panel: #EDE8E0;
}

/* ── Base ── */
.crm-page {
  background: var(--bg-page);
}

/* ── Card ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-card);
}

.card-flat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--spacing-card);
}

/* ── Page Container ── */
.page-container {
  padding: var(--spacing-page);
  max-width: 1400px;
}

/* ── Search Bar ── */
.search-bar {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  min-width: 220px;
  transition: border-color 0.15s ease;
}
.search-bar:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.15);
}
.search-bar::placeholder {
  color: var(--text-muted);
}

/* ── Buttons ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: inherit;
}
.btn-primary:hover {
  background: var(--color-primary-hover);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  font-family: inherit;
}
.btn-secondary:hover {
  background: var(--bg-page);
  border-color: var(--color-primary);
}

.btn-success {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-success);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: inherit;
}
.btn-success:hover {
  background: #1e5e3d;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-danger);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: inherit;
}
.btn-danger:hover {
  background: #6d2e24;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  font-family: inherit;
}
.btn-ghost:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-blue {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.badge-green {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-red {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.badge-yellow {
  background: var(--color-warning-light);
  color: #7A5C1E;
}

.badge-gray {
  background: #F5F1EA;
  color: #4A6B5E;
}

.badge-purple {
  background: rgba(142, 68, 173, 0.1);
  color: #7c3aed;
}

.badge-cyan {
  background: rgba(8, 145, 178, 0.08);
  color: #0891b2;
}

/* ── Table Header ── */
.table-header {
  display: grid;
  padding: 10px 16px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* ── Section Header ── */
.section-header {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  font-family: 'Fraunces', Georgia, serif;
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

/* ── Filter Pill ── */
.filter-pill {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}
.filter-pill:hover {
  background: var(--bg-page);
  border-color: var(--text-muted);
}
.filter-pill.active {
  background: var(--text-primary);
  color: #ffffff;
  border-color: var(--text-primary);
}

/* ── Prospect Row ── */
.prospect-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.prospect-row:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--text-muted);
}

/* ── Status indicator dot ── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Priority icon wrapper ── */
.priority-icon {
  font-size: 14px;
  line-height: 1;
}

/* ── Prospect Compact Row ── */
.prospect-compact-row:hover .prospect-row-actions {
  opacity: 1 !important;
}
.prospect-compact-row:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border-color: var(--border2, #d4cfc8);
}
.status-pill-btn:hover {
  filter: brightness(0.92);
}
.inline-status-dropdown button:hover {
  background: var(--cream, #F5F1EA);
}

/* ── CRM Modal Tabs ── */
.crm-modal-tabs-wrapper {
  display: flex;
  justify-content: center;
  padding: 16px 24px 0 24px;
  border-bottom: 2px solid #e2e8f0;
}

.crm-modal-tabs {
  display: flex;
  gap: 8px;
}

.crm-modal-tab {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  color: #475569;
  border: none;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  background: transparent;
  transition: all 0.2s ease;
}

.crm-modal-tab:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.crm-modal-tab.active {
  color: #F5F1EA;
  background: #1B3022;
  border-bottom: 3px solid #1B3022;
}

/* ── Action buttons ── */
.crm-action-btn {
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.crm-action-btn-primary {
  background: #1B3022;
  color: #F5F1EA;
}
.crm-action-btn-primary:hover { background: #163a26; }

.crm-action-btn-success {
  background: #22c55e;
  color: white;
}
.crm-action-btn-success:hover { background: #16a34a; }

.crm-action-btn-danger {
  background: #ef4444;
  color: white;
}
.crm-action-btn-danger:hover { background: #dc2626; }

.crm-action-btn-outline {
  background: transparent;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.crm-action-btn-outline:hover { background: #f1f5f9; }

/* ── CRM Sidebar Rail ── */
.crm-rail {
  width: 56px;
  background: var(--crm-rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.crm-rail-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: rgba(245, 241, 234, 0.3);
  transition: background 0.15s, color 0.15s;
}
.crm-rail-btn:hover {
  background: rgba(245, 241, 234, 0.06);
  color: rgba(245, 241, 234, 0.6);
}
.crm-rail-btn.active {
  background: var(--crm-gold-light);
  color: var(--crm-gold);
}

.crm-rail-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--crm-gold);
  color: var(--crm-rail);
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* ── CRM Top Bar ── */
.crm-topbar {
  height: 46px;
  background: var(--crm-rail);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
}

.crm-topbar-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 15px;
  color: #F5F1EA;
}

.crm-topbar-subtitle {
  font-size: 11px;
  color: rgba(245, 241, 234, 0.65);
}

/* ── View Toggle ── */
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.view-toggle-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: none;
  border-right: 1px solid var(--border);
  transition: all 0.15s ease;
  font-family: inherit;
}
.view-toggle-btn:last-child {
  border-right: none;
}
.view-toggle-btn:hover {
  background: var(--bg-page);
}
.view-toggle-btn.active {
  background: var(--text-primary);
  color: #ffffff;
}

/* ── Content Scroll Area ── */
.crm-content {
  flex: 1;
  background: var(--bg-page);
  overflow-y: auto;
  padding: var(--spacing-page);
}

/* ── Sidebar Panel ── */
.crm-sidebar-panel {
  width: 230px;
  background: var(--crm-panel);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  gap: 12px;
}

/* ── Loading ── */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

/* ── Tab Row ── */
.crm-tab-row {
  display: flex;
  overflow-x: auto;
  flex-shrink: 0;
  background: var(--crm-panel);
  border-bottom: 1px solid var(--border);
}
.crm-tab-btn {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.crm-tab-btn:hover {
  color: var(--text-primary);
}
.crm-tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* ── Funnel Card ── */
.funnel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.funnel-card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.funnel-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.funnel-bar-label {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}
.funnel-bar-count {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
}

/* ── Analytics Card ── */
.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.analytics-card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── KPI Card (inline edit) ── */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}
.kpi-card:hover {
  box-shadow: var(--shadow-sm);
}
.kpi-card-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.kpi-card-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}
