/* ============================================================================
   FLUX.AI CRM — STUDIO ARTISAN DESIGN SYSTEM (LINEAR / RAYCAST / APPLE STYLE)
   Design Language: Precision Monospace Accents, Hairline Borders, Clean Canvas
   ============================================================================ */

:root {
  --bg-canvas: #f4f5f7;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-active: #f1f5f9;
  
  --border-light: #e4e4e7;
  --border-strong: #d4d4d8;

  --text-main: #09090b;
  --text-muted: #71717a;
  --text-subtle: #a1a1aa;

  /* Accent Palette - Refined & Muted */
  --accent-black: #09090b;
  --accent-blue: #0284c7;
  --accent-purple: #7c3aed;
  --accent-amber: #d97706;
  --accent-emerald: #059669;
  --accent-rose: #e11d48;
  --accent-cyan: #0891b2;

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.02);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-canvas);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 5rem;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.mono-font {
  font-family: var(--font-mono);
}

.hidden {
  display: none !important;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--accent-black);
  color: #ffffff;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.toast-error {
  background: var(--accent-rose);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KBD Shortcut Legend */
.kbd-shortcut {
  background: #f4f4f5;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  margin-left: 0.35rem;
}

/* Top System Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-black);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.company-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.workspace-name {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Sync Badge Indicator */
.sync-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
}

.sync-badge.demo-mode .sync-dot {
  background-color: var(--accent-amber);
}

/* Buttons System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  height: 32px;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--accent-black);
  color: #ffffff;
}

.btn-primary:hover {
  background: #27272a;
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-tertiary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

.btn-tertiary:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.btn-danger {
  background: #fef2f2;
  color: var(--accent-rose);
  border: 1px solid #fecdd3;
}

.btn-danger:hover {
  background: #ffe4e6;
}

.btn-sm {
  height: 28px;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

.btn-icon-only {
  width: 32px;
  padding: 0;
}

.btn-clean-search {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.3rem;
}

/* Main Container */
.main-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

/* SMART AI LEAD INGESTION CARD */
.ai-ingest-card {
  background: #ffffff;
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.05);
}

.ai-ingest-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ai-ingest-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: #6d28d9;
}

.ai-input-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ai-input-wrapper input {
  flex: 1;
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

.ai-input-wrapper input:focus {
  border-color: #7c3aed;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.btn-ai-submit {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: white;
  height: 42px;
  padding: 0 1.1rem;
  white-space: nowrap;
}

/* Metric Strip */
.kpi-strip {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
}

.kpi-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.kpi-title {
  font-size: 0.675rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.kpi-num {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

.kpi-divider {
  width: 1px;
  height: 28px;
  background: var(--border-light);
  margin: 0 1.25rem;
}

/* Filter Toolbar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0 0.65rem;
  height: 32px;
  min-width: 240px;
  flex: 1;
}

.search-field input {
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
  font-family: var(--font-body);
  font-size: 0.8rem;
  width: 100%;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.segmented-control {
  display: flex;
  background: #e4e4e7;
  padding: 2px;
  border-radius: var(--radius-sm);
}

.segment-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-xs);
  cursor: pointer;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
}

.segment-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.pill-count {
  background: #f4f4f5;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.05rem 0.35rem;
  border-radius: 10px;
}

.count-rose {
  background: #ffe4e6;
  color: var(--accent-rose);
}

.select-field {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 0 0.65rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.775rem;
  height: 32px;
  outline: none;
  cursor: pointer;
}

/* MOBILE STAGE TABS — HIDDEN ON DESKTOP */
.mobile-stage-tabs {
  display: none !important;
}

.fab-add-mobile {
  display: none;
}

/* Kanban Board Layout */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(260px, 1fr));
  gap: 0.85rem;
  overflow-x: auto;
  padding-bottom: 1rem;
}

.kanban-column {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  min-height: 600px;
}

.column-header {
  padding: 0.75rem 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-surface);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.column-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.column-title h3 {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.stage-blue .dot { background-color: var(--accent-blue); }
.stage-purple .dot { background-color: var(--accent-purple); }
.stage-amber .dot { background-color: var(--accent-amber); }
.stage-cyan .dot { background-color: var(--accent-cyan); }
.stage-emerald .dot { background-color: var(--accent-emerald); }
.stage-rose .dot { background-color: var(--accent-rose); }

.column-cards {
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
}

/* Lead Cards */
.lead-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  cursor: pointer;
  transition: all 0.12s ease;
  position: relative;
  box-shadow: var(--shadow-card);
}

.lead-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.card-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.lead-id-badge {
  font-family: var(--font-mono);
  font-size: 0.675rem;
  font-weight: 600;
  color: var(--text-muted);
  background: #f4f4f5;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  border: 1px solid var(--border-light);
}

.company-avatar-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.4rem;
}

.company-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 0.725rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.card-company {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.card-contact {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}

.tag {
  font-size: 0.675rem;
  font-weight: 500;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

.tag-founder {
  background: #f5f3ff;
  color: var(--accent-purple);
  border-color: #ede9fe;
}

.tag-service {
  background: #f0f9ff;
  color: var(--accent-blue);
  border-color: #e0f2fe;
}

.tag-high-value {
  background: #fff7ed;
  color: #c2410c;
  border-color: #ffedd5;
  font-weight: 600;
}

.tag-followup {
  background: #fffbeb;
  color: var(--accent-amber);
  border-color: #fef3c7;
}

.tag-overdue {
  background: #fff1f2;
  color: var(--accent-rose);
  border-color: #ffe4e6;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.5rem;
  border-top: 1px solid var(--bg-subtle);
}

.card-value {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-main);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.quick-stage-select {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  outline: none;
}

.card-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 3px;
  display: flex;
  align-items: center;
}

.card-action-btn:hover {
  color: var(--accent-emerald);
}

/* Table View */
.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-card);
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.8rem;
}

.leads-table th {
  padding: 0.75rem 1rem;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-light);
}

.leads-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
}

.leads-table tr:hover {
  background: var(--bg-subtle);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(9, 9, 11, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  padding: 1.5rem;
}

.modal-sm {
  max-width: 440px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.modal-subtitle {
  font-size: 0.775rem;
  color: var(--text-muted);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.col-span-2 {
  grid-column: span 2;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent-black);
  background: var(--bg-surface);
  box-shadow: 0 0 0 2px rgba(9, 9, 11, 0.08);
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.modal-footer-right {
  display: flex;
  gap: 0.6rem;
  margin-left: auto;
}

.sheets-panel {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-bottom: 1rem;
}

.sheets-status-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #166534;
  margin-bottom: 0.2rem;
}

.status-dot-active {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #16a34a;
}

.sheets-info-text {
  font-size: 0.75rem;
  color: #15803d;
}

/* MOBILE SPECIFIC RULES */
@media (max-width: 768px) {
  .app-header {
    padding: 0.65rem 1rem;
  }
  .header-right #btnNewLead {
    display: none;
  }
  .fab-add-mobile {
    display: flex;
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-black);
    color: white;
    font-size: 1.5rem;
    align-items: center;
    justify-content: center;
    border: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    z-index: 90;
  }
  .ai-input-wrapper {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-ai-submit {
    width: 100%;
  }
  .kpi-strip {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .kpi-divider {
    display: none;
  }
  .mobile-stage-tabs {
    display: flex !important;
    overflow-x: auto;
    gap: 0.4rem;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
  }
  .stage-tab-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    padding: 0.35rem 0.75rem;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
  }
  .stage-tab-btn.active {
    background: var(--accent-black);
    color: #ffffff;
  }
  .kanban-board.mobile-single-view {
    grid-template-columns: 1fr;
  }
  .kanban-board.mobile-single-view .kanban-column {
    display: none;
  }
  .kanban-board.mobile-single-view .kanban-column.mobile-active-stage {
    display: flex;
  }
}
