/* ChatBoto — Professional Light CRM theme
   Audience: US small business owners (non-technical)
   Palette: clean white surface, ink text, indigo primary, emerald success */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:        #F6F8FB;
  --surface:   #FFFFFF;
  --raised:    #FFFFFF;
  --border:    #E5E9F0;
  --border-strong: #D1D7E0;
  --text:      #0F172A;
  --muted:     #475569;
  --dim:       #94A3B8;
  --primary:   #4F46E5;   /* indigo-600 */
  --primary-2: #4338CA;
  --accent:    #10B981;   /* emerald-500 — leads / positive */
  --accent-2:  #059669;
  --danger:    #DC2626;
  --warn:      #F59E0B;
  --info:      #2563EB;
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
  --shadow:    0 4px 12px -2px rgba(15,23,42,0.08), 0 2px 4px -2px rgba(15,23,42,0.05);
  --shadow-lg: 0 16px 40px -12px rgba(15,23,42,0.18);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4 { margin: 0 0 .4em; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
p { margin: 0 0 .8em; color: var(--muted); }
code, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px; margin-bottom: 28px; padding: 0 8px;
  color: var(--text);
}
.sidebar .brand .logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #818CF8);
  display: grid; place-items: center; color: white; font-weight: 700;
  box-shadow: 0 4px 12px -2px rgba(79,70,229,0.4);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s;
  font-size: 13.5px;
}
.nav a:hover { background: #F1F5F9; color: var(--text); text-decoration: none; }
.nav a.active { background: #EEF2FF; color: var(--primary); }
.nav a.active svg { stroke: var(--primary); }
.nav .sect {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--dim); padding: 14px 12px 6px; font-weight: 600;
}

.main { padding: 28px 32px 60px; max-width: 1400px; }
.topbar { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.topbar h1 { margin: 0; }
.topbar .actions { display: flex; gap: 8px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 12px; color: var(--muted); margin: 0 0 14px;
  text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 980px) {
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
}

/* KPI tiles */
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.kpi .value { font-family: 'Inter', sans-serif; font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.kpi .delta { font-size: 12px; color: var(--accent); font-weight: 500; }
.kpi-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 4px; }
.kpi-icon.indigo  { background: #EEF2FF; color: var(--primary); }
.kpi-icon.emerald { background: #D1FAE5; color: var(--accent-2); }
.kpi-icon.amber   { background: #FEF3C7; color: #B45309; }
.kpi-icon.blue    { background: #DBEAFE; color: var(--info); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.input, .textarea, .select {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font: inherit;
  font-size: 13.5px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
.textarea { min-height: 110px; font-family: 'JetBrains Mono', monospace; font-size: 12.5px; line-height: 1.55; }
.input::placeholder { color: var(--dim); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: background .12s, border-color .12s, transform .05s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: #F8FAFC; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: white;
  box-shadow: 0 1px 2px rgba(79,70,229,0.4); }
.btn.primary:hover { background: var(--primary-2); }
.btn.success { background: var(--accent); border-color: var(--accent); color: white; }
.btn.success:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: #F1F5F9; }
.btn.danger { color: var(--danger); border-color: #FECACA; background: #FEF2F2; }
.btn.danger:hover { background: #FEE2E2; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left; padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.table th { font-weight: 600; color: var(--muted); text-transform: uppercase;
  font-size: 11px; letter-spacing: .06em; background: #FAFBFD; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #FAFBFD; cursor: pointer; }
.table .mono { font-size: 12px; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: #F1F5F9; color: var(--muted);
  border: 1px solid var(--border);
}
.badge.lead     { background: #D1FAE5; color: #065F46; border-color: #6EE7B7; }
.badge.important{ background: #FEF3C7; color: #92400E; border-color: #FCD34D; }
.badge.normal   { background: #DBEAFE; color: #1E40AF; border-color: #93C5FD; }
.badge.spam     { background: #FEE2E2; color: #991B1B; border-color: #FCA5A5; }
.badge.new      { background: #EEF2FF; color: #3730A3; border-color: #C7D2FE; }
.badge.contacted{ background: #FEF3C7; color: #92400E; border-color: #FCD34D; }
.badge.qualified{ background: #D1FAE5; color: #065F46; border-color: #6EE7B7; }
.badge.closed_won  { background: #DCFCE7; color: #166534; border-color: #86EFAC; }
.badge.closed_lost { background: #F1F5F9; color: #475569; border-color: #CBD5E1; }
.badge.dot::before { content:'•'; margin-right: 4px; }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 20px;
  z-index: 100; overflow-y: auto;
  animation: fade .15s ease;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 24px; width: 100%; max-width: 760px;
  box-shadow: var(--shadow-lg);
}
.modal h2 { font-size: 18px; color: var(--text); text-transform: none; letter-spacing: -0.01em; margin-bottom: 16px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--r); padding: 12px 16px; font-size: 13px;
  box-shadow: var(--shadow-lg); z-index: 200;
  animation: slideup .25s ease;
}
.toast.ok  { border-left-color: var(--accent); }
.toast.err { border-left-color: var(--danger); }
@keyframes slideup { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Chat viewer ---------- */
.chat-log { display: flex; flex-direction: column; gap: 10px; padding: 8px 0;
  max-height: 420px; overflow-y: auto; }
.chat-bubble { max-width: 78%; padding: 10px 14px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.chat-bubble.user { align-self: flex-end; background: var(--primary); color: white;
  border-bottom-right-radius: 4px; }
.chat-bubble.assistant { align-self: flex-start; background: #F1F5F9; color: var(--text);
  border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-bubble .meta { display:block; font-size: 10.5px; color: var(--dim); margin-top: 4px; }
.chat-bubble.user .meta { color: rgba(255,255,255,0.7); }

/* ---------- Pipeline (Kanban) ---------- */
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px; min-height: 200px; }
.col h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 0 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; }
.col .count { background: #F1F5F9; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; color: var(--muted); }
.lead-card { background: white; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 10px 12px; margin-bottom: 8px; cursor: pointer; transition: box-shadow .15s, transform .05s;
  box-shadow: var(--shadow-sm); }
.lead-card:hover { box-shadow: var(--shadow); }
.lead-card:active { transform: translateY(1px); }
.lead-card .name { font-weight: 600; font-size: 13px; color: var(--text); }
.lead-card .meta { font-size: 11.5px; color: var(--muted); margin-top: 4px;
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lead-card .score {
  display: inline-block; font-family: 'JetBrains Mono', monospace; font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; padding: 1px 7px; border-radius: 4px; font-size: 11px;
}
.lead-card .score.low { background: #94A3B8; }
.lead-card .score.mid { background: var(--warn); }

@media (max-width: 1100px) {
  .pipeline { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .pipeline { grid-template-columns: 1fr; }
}

/* Login splash */
.splash { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(180deg, #F8FAFC, var(--bg)); }
.splash .card { width: 100%; max-width: 400px; padding: 32px; }
.splash .brand { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 22px;
  display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--text); }
.splash .brand .logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #818CF8);
  display: grid; place-items: center; color: white; font-weight: 700;
  box-shadow: 0 4px 12px -2px rgba(79,70,229,0.4);
}

/* Misc */
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--muted); }
.dim   { color: var(--dim); }
.hidden { display: none !important; }
.error { color: var(--danger); font-size: 12.5px; }
.sparkline { width: 100%; height: 72px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }
::-webkit-scrollbar-track { background: transparent; }
