
/* ============================================
   EON CRM — Design System
   Dark theme, glassmorphism, teal accents
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(25, 35, 55, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-sidebar: rgba(10, 14, 26, 0.95);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(56, 189, 248, 0.4);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #38bdf8;

  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-glow: rgba(56, 189, 248, 0.15);
  --accent-gradient: linear-gradient(135deg, #38bdf8, #818cf8);

  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;

  --status-new: #60a5fa;
  --status-contacted: #34d399;
  --status-followup: #fbbf24;
  --status-closed: #94a3b8;

  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --header-height: 60px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.1);

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Light Theme ---- */
[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(241, 245, 249, 0.95);
  --bg-glass: rgba(0, 0, 0, 0.02);
  --bg-input: rgba(0, 0, 0, 0.04);
  --bg-sidebar: rgba(255, 255, 255, 0.97);

  --border-color: rgba(0, 0, 0, 0.1);
  --border-active: rgba(14, 116, 214, 0.4);

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-accent: #0284c7;

  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-glow: rgba(2, 132, 199, 0.12);
  --accent-gradient: linear-gradient(135deg, #0284c7, #6366f1);

  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;

  --status-new: #2563eb;
  --status-contacted: #059669;
  --status-followup: #d97706;
  --status-closed: #64748b;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.25);
}

/* ============================================
   Layout
   ============================================ */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  z-index: 100;
  backdrop-filter: blur(20px);
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-height);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-name {
  font-size: 18px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  text-decoration: none;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--text-accent);
  border-color: var(--border-active);
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.sync-btn {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  font-family: inherit;
}

.sync-btn:hover {
  background: var(--accent-glow);
  border-color: var(--border-active);
  color: var(--text-accent);
}

.sync-btn.syncing { opacity: 0.6; pointer-events: none; }

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.content-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.content-header h1 {
  font-size: 20px;
  font-weight: 600;
}

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-primary);
}

/* ---- Mobile hamburger ---- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  z-index: 200;
  padding: 0 16px;
  align-items: center;
  gap: 12px;
}

.hamburger {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

/* ============================================
   KPI Cards
   ============================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  backdrop-filter: blur(10px);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: var(--transition);
}

.kpi-card:hover::before { opacity: 1; }
.kpi-card:hover {
  border-color: var(--border-active);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.kpi-card.danger .kpi-value {
  background: linear-gradient(135deg, #f87171, #fb923c);
  -webkit-background-clip: text;
  background-clip: text;
}

.kpi-card.success .kpi-value {
  background: linear-gradient(135deg, #34d399, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
}

.kpi-card.warning .kpi-value {
  background: linear-gradient(135deg, #fbbf24, #f97316);
  -webkit-background-clip: text;
  background-clip: text;
}

/* ============================================
   Data Tables
   ============================================ */
.table-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.search-box input:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box input::placeholder { color: var(--text-muted); }

.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.filter-date-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-date-group span {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.filter-date {
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  color-scheme: dark; /* Forces native dark mode picker where supported */
  transition: var(--transition);
}

.filter-date:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Specific styling for webkit/chrome */
.filter-date::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(0.6);
  cursor: pointer;
  transition: var(--transition);
}

.filter-date::-webkit-calendar-picker-indicator:hover {
  filter: invert(1) opacity(1);
}

.filter-select {
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.filter-select:focus {
  border-color: var(--border-active);
}

.filter-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.data-table tbody td {
  padding: 14px 16px;
  vertical-align: top;
}

.customer-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.customer-address {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-badge.new {
  background: rgba(96,165,250,0.12);
  color: var(--status-new);
}
.status-badge.new::before { background: var(--status-new); }

.status-badge.contacted {
  background: rgba(52,211,153,0.12);
  color: var(--status-contacted);
}
.status-badge.contacted::before { background: var(--status-contacted); }

.status-badge.follow-up {
  background: rgba(251,191,36,0.12);
  color: var(--status-followup);
}
.status-badge.follow-up::before { background: var(--status-followup); }

.status-badge.closed {
  background: rgba(148,163,184,0.12);
  color: var(--status-closed);
}
.status-badge.closed::before { background: var(--status-closed); }

/* ============================================
   Customer Detail Panel (Slide-out)
   ============================================ */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.detail-overlay.open {
  opacity: 1;
  visibility: visible;
}

.detail-panel {
  position: fixed;
  top: 0;
  right: -560px;
  width: 540px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  z-index: 301;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.detail-panel.open {
  right: 0;
}

.detail-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-shrink: 0;
}

.detail-header-info h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.3;
}

.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-meta-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
}

.detail-meta-icon {
  margin-top: 2px;
  flex-shrink: 0;
}

.close-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
  flex-shrink: 0;
}

.close-btn:hover {
  background: rgba(248,113,113,0.15);
  border-color: var(--danger);
  color: var(--danger);
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* Tabs */
.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.detail-tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}

.detail-tab:hover { color: var(--text-secondary); }

.detail-tab.active {
  color: var(--text-accent);
  border-bottom-color: var(--accent);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- Editable Fields ---- */
.edit-section {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.edit-field.full-width {
  grid-column: 1 / -1;
}

.edit-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.edit-field input,
.edit-field select,
.edit-field textarea {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.edit-field input:focus,
.edit-field select:focus,
.edit-field textarea:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.edit-field textarea {
  resize: vertical;
  min-height: 60px;
}

.edit-field select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

.edit-field select option {
  background: var(--bg-secondary);
}

.save-btn {
  padding: 10px 20px;
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  margin-top: 8px;
}

.save-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(56,189,248,0.3);
}

.save-btn:active { transform: translateY(0); }

/* ---- Purchase History in detail ---- */
.purchase-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.purchase-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.purchase-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-secondary);
}

.purchase-table tr:hover td {
  color: var(--text-primary);
  background: rgba(255,255,255,0.02);
}

/* ---- Log Interaction Form ---- */
.log-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.log-section h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Star rating */
.star-rating {
  display: flex;
  gap: 4px;
  direction: rtl;
  justify-content: flex-end;
}

.star-rating input {
  display: none;
}

.star-rating label {
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
}

.star-rating input:checked ~ label,
.star-rating label:hover,
.star-rating label:hover ~ label {
  color: var(--warning);
}

/* ---- Interaction History Cards ---- */
.interaction-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  transition: var(--transition);
}

.interaction-card:hover {
  border-color: var(--border-active);
}

.interaction-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.interaction-type {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-accent);
}

.interaction-date {
  font-size: 11px;
  color: var(--text-muted);
}

.interaction-outcome {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  margin-bottom: 6px;
}

.interaction-outcome.connected {
  background: rgba(52,211,153,0.12);
  color: var(--success);
}

.interaction-outcome.not-reachable {
  background: rgba(248,113,113,0.12);
  color: var(--danger);
}

.interaction-outcome.busy {
  background: rgba(251,191,36,0.12);
  color: var(--warning);
}

.interaction-outcome.callback {
  background: rgba(96,165,250,0.12);
  color: var(--info);
}

.interaction-outcome.completed {
  background: rgba(52,211,153,0.12);
  color: var(--success);
}

.interaction-notes {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.interaction-stars {
  color: var(--warning);
  font-size: 14px;
  margin-top: 4px;
}

/* ============================================
   Follow-up Queue
   ============================================ */
.followup-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: var(--transition);
  cursor: pointer;
}

.followup-card:hover {
  border-color: var(--border-active);
  box-shadow: var(--shadow-glow);
  transform: translateX(4px);
}

.followup-card.overdue {
  border-left: 3px solid var(--danger);
}

.followup-card.due-today {
  border-left: 3px solid var(--warning);
}

.followup-card.upcoming {
  border-left: 3px solid var(--success);
}

.followup-info {
  flex: 1;
  min-width: 0;
}

.followup-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.followup-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.followup-urgency {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.followup-urgency.overdue { color: var(--danger); }
.followup-urgency.today { color: var(--warning); }
.followup-urgency.upcoming { color: var(--success); }

.log-quick-btn {
  padding: 8px 14px;
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  font-family: inherit;
}

.log-quick-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(56,189,248,0.3);
}

/* ============================================
   Activity Log
   ============================================ */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.activity-icon.call { background: rgba(56,189,248,0.12); }
.activity-icon.feedback { background: rgba(251,191,36,0.12); }
.activity-icon.service { background: rgba(248,113,113,0.12); }
.activity-icon.complaint { background: rgba(248,113,113,0.15); }
.activity-icon.general { background: rgba(148,163,184,0.12); }

.activity-body { flex: 1; min-width: 0; }

.activity-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.activity-title a {
  color: var(--text-accent);
  text-decoration: none;
  cursor: pointer;
}

.activity-title a:hover { text-decoration: underline; }

.activity-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.activity-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ============================================
   Section titles
   ============================================ */
.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .icon {
  font-size: 18px;
}

/* ============================================
   Toast notifications
   ============================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.3s ease-out;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { background: linear-gradient(135deg, #059669, #34d399); }
.toast.error { background: linear-gradient(135deg, #dc2626, #f87171); }
.toast.info { background: linear-gradient(135deg, #2563eb, #60a5fa); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================
   Loading spinner
   ============================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner.lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================
   Empty state
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  max-width: 300px;
  margin: 0 auto;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    z-index: 100;
  }

  .sidebar.open { left: 0; }

  .mobile-header { display: flex; }
  .mobile-overlay.open { display: block; }

  .main-content {
    margin-top: var(--header-height);
  }

  .content-body {
    padding: 16px;
  }

  .content-header {
    display: none;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 24px; }

  .detail-panel {
    width: 100vw;
    right: -100vw;
  }

  .table-controls {
    flex-direction: column;
  }

  .search-box {
    max-width: none;
    width: 100%;
  }

  .edit-grid {
    grid-template-columns: 1fr;
  }

  .data-table {
    font-size: 13px;
  }

  .data-table thead th,
  .data-table tbody td {
    padding: 10px 10px;
  }

  .hide-mobile { display: none !important; }

  .followup-card {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .kpi-card { padding: 12px; }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 10px; }
}

/* ============================================
   Light Mode Overrides
   ============================================ */
[data-theme="light"] .filter-date {
  color-scheme: light;
}

[data-theme="light"] .filter-date::-webkit-calendar-picker-indicator {
  filter: none;
  opacity: 0.6;
}

[data-theme="light"] .filter-date::-webkit-calendar-picker-indicator:hover {
  filter: none;
  opacity: 1;
}

[data-theme="light"] .filter-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23475569' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
}

[data-theme="light"] .sidebar-logo {
  color: #fff;
}

/* ---- Theme Toggle ---- */
.theme-toggle {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  font-family: inherit;
  margin-top: 8px;
}

.theme-toggle:hover {
  background: var(--accent-glow);
  border-color: var(--border-active);
  color: var(--text-accent);
}

.theme-toggle .theme-icon {
  font-size: 16px;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover .theme-icon {
  transform: rotate(30deg);
}


/* ============================================
   Phase 1 Additions & UI Polishes
   ============================================ */

/* Kanban Pipeline */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  height: 100%;
}
.kanban-col {
  flex: 1;
  min-width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
}
.kanban-col-header {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-primary);
}
.kanban-col-count {
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.kanban-col-body {
  flex: 1;
  min-height: 100px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.kanban-col-body.drag-over {
  background: rgba(56, 189, 248, 0.05);
  border: 1px dashed var(--accent);
}
.kanban-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  cursor: grab;
  transition: transform 0.2s, box-shadow 0.2s;
}
.kanban-card:active {
  cursor: grabbing;
}
.kanban-card:hover {
  border-color: var(--border-active);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  transform: translateY(-2px);
}
.kanban-card h4 {
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text-primary);
}
.kanban-card p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.kanban-card-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

/* Analytics */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
}

/* Detail Panel Typography Polishes */
.detail-panel { width: 720px !important; }
.detail-header { padding: 24px 32px !important; }
.detail-header-info h2 { font-size: 24px !important; font-weight: 700 !important; margin-bottom: 8px !important; line-height: 1.2 !important; }
.detail-tabs { padding: 0 32px !important; gap: 24px !important; }
.detail-tab { padding: 10px 0 !important; }
.tab-content { padding: 24px 32px !important; }

.edit-field label {
  font-size: 13px !important;
  font-weight: 500 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  color: var(--text-secondary) !important;
}

.edit-field input, .edit-field select, .edit-field textarea {
  padding: 10px 14px !important;
  font-size: 15px !important;
}
.edit-field textarea {
  min-height: 80px !important;
  line-height: 1.5 !important;
}
.log-section {
  padding: 24px !important;
  margin-bottom: 24px !important;
}

/* Sticky Controls & Table Headers */
.table-controls {
  position: sticky !important;
  top: -24px !important;
  z-index: 10 !important;
  background: var(--bg-primary) !important;
  padding: 24px 0 16px 0 !important;
  margin-top: -24px !important;
  margin-bottom: 0 !important;
  border-bottom: 1px solid var(--border-color) !important;
}

@media (max-width: 768px) {
  .table-controls {
    top: -16px !important;
    padding-top: 16px !important;
    margin-top: -16px !important;
  }
}

.data-table thead th {
  top: 74px !important;
}

/* Fix for detail panel visibility when closed */
.detail-panel { right: -760px !important; }
.detail-panel.open { right: 0 !important; }

/* Fix for table headers overlapping data */
.data-table thead th { position: static !important; }

