/* =========================================================
   Lisa Aromano — Funnel Dashboard styles
   Light + dark theme via [data-theme] on <html>
   ========================================================= */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --sidebar-w: 250px;
  --grad-violet: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
  --grad-cyan: linear-gradient(135deg, #22d3ee 0%, #3b82f6 100%);
  --grad-pink: linear-gradient(135deg, #f472b6 0%, #a855f7 100%);
  --grad-green: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Dark theme (default) ---------- */
html[data-theme="dark"] {
  --bg: #0e0f1f;
  --bg-soft: #12142a;
  --card: #191b34;
  --card-alt: #1e2140;
  --border: #2a2d4d;
  --text: #f1f2fb;
  --text-muted: #9195b8;
  --text-faint: #6b6f92;
  --sidebar-bg: #12142a;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --accent: #a855f7;
  --accent-2: #22d3ee;
  --track: #262a4d;
}

/* ---------- Light theme ---------- */
html[data-theme="light"] {
  --bg: #f5f6fb;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --card-alt: #f8f7ff;
  --border: #e8e8f2;
  --text: #1c1d2e;
  --text-muted: #6a6d85;
  --text-faint: #9fa2b8;
  --sidebar-bg: #ffffff;
  --shadow: 0 10px 30px rgba(99,102,241,0.08);
  --accent: #7c3aed;
  --accent-2: #0ea5e9;
  --track: #e8e8f2;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  transition: background .25s ease, color .25s ease;
}

img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul { list-style: none; }

.app { display: flex; min-height: 100vh; }

/* ================= Sidebar ================= */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--grad-violet);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 15px;
}
.brand-text { line-height: 1.1; }
.brand-text strong { font-size: 14.5px; font-weight: 700; }
.brand-text span { font-size: 11.5px; color: var(--text-muted); }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint); padding: 10px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--card-alt); color: var(--text); }
.nav-item.active {
  background: var(--grad-violet);
  color: #fff;
  box-shadow: 0 6px 16px rgba(124,58,237,0.35);
}

.sidebar-footer { margin-top: auto; }
.export-card {
  background: var(--card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}
.export-card p { font-size: 12.5px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.4; }
.btn-grad {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px 14px; border-radius: 999px;
  background: var(--grad-violet); color: #fff; font-size: 13px; font-weight: 600;
}
.btn-grad svg { width: 15px; height: 15px; }

/* ================= Main ================= */
.main { flex: 1; min-width: 0; padding: 22px 28px 40px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.topbar h1 { font-size: 21px; font-weight: 700; }
.topbar .sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px; min-width: 220px;
}
.search-box svg { width: 15px; height: 15px; color: var(--text-faint); }
.search-box input {
  border: none; outline: none; background: transparent; color: var(--text);
  font-size: 13px; width: 100%;
}
.search-box input::placeholder { color: var(--text-faint); }

.range-pill {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; color: var(--text-muted);
}

.theme-toggle {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px; position: relative;
}
.theme-toggle button {
  width: 30px; height: 30px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); position: relative; z-index: 1;
  transition: color .2s ease;
}
.theme-toggle button svg { width: 15px; height: 15px; }
.theme-toggle button.on { color: #fff; }
.theme-toggle .knob {
  position: absolute; top: 5px; left: 5px; width: 30px; height: 30px;
  border-radius: 999px; background: var(--grad-violet);
  transition: transform .25s ease; z-index: 0;
}
html[data-theme="light"] .theme-toggle .knob { transform: translateX(30px); }

.avatar {
  width: 38px; height: 38px; border-radius: 999px;
  background: var(--grad-cyan);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px;
}

/* ================= Grid & cards ================= */
.grid { display: grid; gap: 18px; }
.stat-row { grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; }
.mid-row { grid-template-columns: 1.4fr 1fr; margin-bottom: 18px; align-items: stretch; }
.chart-row { grid-template-columns: 1fr 1fr 1fr; margin-bottom: 18px; }
.table-row { grid-template-columns: 1.2fr 1fr; }

@media (max-width: 1180px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .chart-row { grid-template-columns: 1fr 1fr; }
  .mid-row { grid-template-columns: 1fr; }
  .table-row { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .stat-row { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 10px;
}
.card-head h3 { font-size: 14.5px; font-weight: 700; }
.card-head p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-head .legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }

/* stat cards (gradient) */
.stat-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
  min-height: 128px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.stat-card.grad-1 { background: var(--grad-pink); }
.stat-card.grad-2 { background: var(--grad-cyan); }
.stat-card.grad-3 { background: var(--grad-violet); }
.stat-card.grad-4 { background: var(--grad-green); }
.stat-card .label { font-size: 13px; opacity: .92; font-weight: 500; }
.stat-card .value { font-size: 30px; font-weight: 700; margin-top: 10px; }
.stat-card .value small { font-size: 15px; font-weight: 600; opacity: .85; }
.stat-card .badge {
  align-self: flex-start;
  background: rgba(255,255,255,0.22);
  border-radius: 999px; padding: 4px 10px; font-size: 11.5px; font-weight: 600;
  margin-top: 12px;
}

/* neutral stat card (used in table row summary) */
.stat-plain .value { color: var(--text); }
.stat-plain .label { color: var(--text-muted); }

/* ================= Funnel ================= */
.funnel-card .funnel { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.funnel-step { display: grid; grid-template-columns: 160px 1fr 90px; align-items: center; gap: 14px; }
.funnel-step .fname { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.funnel-step .fbar-track { background: var(--track); border-radius: 999px; height: 28px; overflow: hidden; }
.funnel-step .fbar {
  height: 100%; border-radius: 999px;
  display: flex; align-items: center; justify-content: flex-end; padding-right: 12px;
  color: #fff; font-size: 12.5px; font-weight: 700;
  transition: width .6s ease;
}
.funnel-step .fmeta { font-size: 12px; color: var(--text-faint); text-align: right; }
.funnel-step .fmeta strong { color: var(--text); font-size: 13px; }

/* ================= Rings ================= */
.ring-row { display: flex; gap: 20px; margin-top: 6px; }
.ring-item { flex: 1; text-align: center; }
.ring-item svg { width: 92px; height: 92px; margin: 0 auto; }
.ring-item .ring-value { font-size: 18px; font-weight: 700; }
.ring-item .ring-label { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ================= Tables ================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600; padding: 0 10px 10px; border-bottom: 1px solid var(--border);
}
tbody td { padding: 11px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--card-alt); }
.cell-muted { color: var(--text-muted); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
}
.pill.completed { background: rgba(52,211,153,0.16); color: #10b981; }
.pill.abandoned { background: rgba(248,113,113,0.16); color: #f87171; }
.pill.renewal { background: rgba(168,85,247,0.16); color: #a855f7; }
.pill.new { background: rgba(34,211,238,0.16); color: #0891b2; }
.plan-tag { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 7px; }
.plan-weekly { background: rgba(56,189,248,0.15); color: #0284c7; }
.plan-monthly { background: rgba(168,85,247,0.15); color: #9333ea; }
.plan-quarterly { background: rgba(244,114,182,0.15); color: #db2777; }
.plan-yearly { background: rgba(52,211,153,0.15); color: #059669; }

footer.foot {
  margin-top: 24px; text-align: center; font-size: 12px; color: var(--text-faint);
}

/* ================= Views / nav ================= */
.nav-item { width: 100%; text-align: left; }
.view[hidden] { display: none; }

.select-pill {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.select-pill:focus { outline: none; border-color: var(--accent); }

.table-wrap.scroll { max-height: 480px; overflow-y: auto; }
tbody tr[data-lead-id] { cursor: pointer; }

/* ================= Modal ================= */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 10, 22, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto;
  padding: 26px; position: relative;
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 30px; height: 30px; border-radius: 999px;
  background: var(--card-alt); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.modal-close:hover { color: var(--text); }

.cust-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding-right: 30px; }
.cust-avatar {
  width: 50px; height: 50px; border-radius: 999px; background: var(--grad-violet);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.cust-head h2 { font-size: 17px; font-weight: 700; }
.cust-head p { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.cust-meta-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  background: var(--card-alt); border-radius: var(--radius-md); padding: 14px; margin-bottom: 20px;
}
.cust-meta-grid div span {
  display: block; font-size: 10.5px; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px;
}
.cust-meta-grid div strong { font-size: 13.5px; }

.cust-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); margin-bottom: 12px;
}

.timeline { margin-bottom: 22px; }
.timeline-item { display: grid; grid-template-columns: 14px 1fr; gap: 12px; position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { width: 12px; height: 12px; border-radius: 999px; background: var(--accent); margin-top: 3px; position: relative; z-index: 1; }
.timeline-dot.abandoned { background: #f87171; }
.timeline-item:not(:last-child)::before {
  content: ""; position: absolute; left: 5px; top: 16px; bottom: -4px; width: 2px; background: var(--border);
}
.timeline-item .t-label { font-size: 13px; font-weight: 600; }
.timeline-item .t-date { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

.cust-ltv {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--grad-violet); color: #fff; border-radius: var(--radius-md);
  padding: 14px 16px; margin-top: 2px;
}
.cust-ltv span { font-size: 12.5px; opacity: .9; }
.cust-ltv strong { font-size: 20px; }
