/* ============ Aurelia LTV — WellLTV-inspired design system ============ */
:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --ink: #1c2321;
  --ink-2: #3d4a45;
  --muted: #6b7672;
  --faint: #98a19d;
  --line: #e6e9e4;
  --green-900: #14532d;
  --green-700: #1b7a43;
  --green-600: #22995a;
  --green-500: #34b26f;
  --green-100: #e3f2e9;
  --green-50: #f0f7f2;
  --slate-bar: #a9b7ab;
  --amber: #c77700;
  --red: #c2410c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 40, 30, .05), 0 1px 6px rgba(20, 40, 30, .04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

/* ---------- Layout ---------- */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--card);
  border-right: 1px solid var(--line);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding: 18px 14px 28px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 2px 8px 16px;
  font-weight: 800; font-size: 17px; letter-spacing: -.02em;
}
.brand .bolt {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--green-900);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px;
}
.brand small { font-weight: 500; color: var(--faint); font-size: 11px; letter-spacing: .02em; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
  color: var(--faint);
  font-size: 12.5px;
  margin-bottom: 14px;
}
.search-box kbd {
  margin-left: auto; font-family: inherit; font-size: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px;
  color: var(--muted);
}

.nav-section { margin-top: 14px; }
.nav-section > h4 {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  color: var(--faint); text-transform: uppercase;
  padding: 6px 8px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6.5px 8px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  margin-bottom: 1px;
}
.nav-item i { width: 16px; text-align: center; font-size: 12.5px; color: var(--muted); }
.nav-item:hover { background: var(--bg); }
.nav-item.active {
  background: var(--green-50);
  color: var(--green-900);
  font-weight: 600;
}
.nav-item.active i { color: var(--green-700); }
.nav-item .star { margin-left: auto; color: #d8a400; font-size: 11px; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 14px 28px;
}
.topbar .search {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 12px; color: var(--faint); font-size: 12.5px; width: 220px;
}
.topbar .viewas {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 12px; font-size: 12.5px; color: var(--ink-2); font-weight: 500;
}
.topbar .viewas b { font-weight: 700; }
.topbar .viewas i { color: var(--faint); font-size: 11px; }
.topbar .leaf {
  width: 30px; height: 30px; border-radius: 8px; background: var(--green-900);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.topbar .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #d9b08c, #b2794d);
  border: 2px solid #fff; box-shadow: var(--shadow);
}

.content { padding: 4px 28px 48px; max-width: 1180px; width: 100%; }

.crumb {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  color: var(--faint); text-transform: uppercase; margin-bottom: 6px;
}
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.page-sub { color: var(--muted); font-size: 13.5px; margin-top: 5px; max-width: 640px; }

.window-picker {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--ink-2);
  cursor: pointer; box-shadow: var(--shadow);
}
.window-picker i { color: var(--faint); font-size: 12px; }
.window-picker select { border: 0; background: none; font: inherit; color: inherit; cursor: pointer; outline: none; }

.view-toggle { display: flex; gap: 2px; margin-top: 18px; border-bottom: 1px solid var(--line); }
.view-toggle button {
  border: 0; background: none; font: inherit;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  color: var(--faint); padding: 9px 14px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  text-transform: uppercase;
}
.view-toggle button.active { color: var(--green-900); border-bottom-color: var(--green-900); }
.view-toggle .lbl { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--faint); padding: 9px 14px 9px 0; text-transform: uppercase; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-top: 18px;
}
.card h3 { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.card .card-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.card-head .meta { font-size: 11px; font-weight: 700; letter-spacing: .07em; color: var(--faint); text-transform: uppercase; }

/* ---------- KPI grid ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); gap: 14px; margin-top: 18px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.kpi .label { font-size: 11px; font-weight: 600; letter-spacing: .05em; color: var(--muted); text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.kpi .label i { color: var(--green-700); font-size: 11px; }
.kpi .value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-top: 7px; }
.kpi .delta { font-size: 11.5px; font-weight: 600; margin-top: 4px; }
.kpi .delta.up { color: var(--green-700); }
.kpi .delta.down { color: var(--red); }
.kpi .hint { font-size: 11px; color: var(--faint); margin-top: 4px; }

/* ---------- Funnel (screenshot replica) ---------- */
.funnel-row {
  display: grid;
  grid-template-columns: 215px 1fr 150px;
  align-items: center;
  gap: 20px;
  padding: 15px 0;
}
.funnel-row + .funnel-row { border-top: 1px solid var(--line); }
.funnel-step .name { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.funnel-step .name .info {
  width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--faint);
  color: var(--faint); font-size: 8.5px; display: inline-flex; align-items: center; justify-content: center;
  font-style: normal; font-weight: 700; cursor: help;
}
.funnel-step .desc { font-size: 11.5px; color: var(--faint); margin-top: 3px; }

.funnel-bar-wrap { position: relative; height: 34px; }
.funnel-bar {
  height: 34px; border-radius: 7px;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 12px;
  color: #fff; font-size: 12.5px; font-weight: 700;
  min-width: 52px;
  transition: width .7s cubic-bezier(.22, .8, .3, 1);
}
.funnel-bar.c-slate { background: linear-gradient(90deg, #9fb0a5, var(--slate-bar)); }
.funnel-bar.c-mid { background: linear-gradient(90deg, #2e8b57, #35a06b); }
.funnel-bar.c-deep { background: linear-gradient(90deg, #17653a, #1e8049); }
.funnel-bar.c-deepest { background: linear-gradient(90deg, var(--green-900), #1c6b3e); }
.funnel-pct-below { font-size: 11px; color: var(--muted); margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.funnel-pct-below i { font-size: 9px; color: var(--faint); }

.funnel-count { text-align: right; }
.funnel-count .n { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.funnel-count .drop { font-size: 11px; color: var(--faint); margin-top: 2px; }

.outcome-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; color: var(--faint);
  text-transform: uppercase; margin: 10px 0 -4px;
}
.funnel-note { font-size: 12px; color: var(--muted); margin-top: 14px; line-height: 1.55; }
.funnel-note b { color: var(--ink-2); }

/* ---------- Insight callout ---------- */
.insight {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--green-50);
  border: 1px solid #d6e8dc;
  border-left: 3px solid var(--green-700);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 16px 0;
  font-size: 13px; color: var(--ink-2); line-height: 1.55;
}
.insight .big { font-size: 19px; font-weight: 800; color: var(--green-900); letter-spacing: -.02em; white-space: nowrap; padding-top: 1px; }
.insight b { color: var(--ink); }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; margin-top: 12px; }
table.data th {
  text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .07em;
  color: var(--faint); text-transform: uppercase;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th.r, table.data td.r { text-align: right; }
table.data td {
  padding: 10px 12px; border-bottom: 1px solid #f0f2ee;
  font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fafbf9; }
table.data td .primary { font-weight: 600; color: var(--ink); }
table.data td .secondary { font-size: 11.5px; color: var(--faint); }

.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
}
.pill.green { background: var(--green-100); color: var(--green-900); }
.pill.grey { background: #eef1ee; color: var(--muted); }
.pill.amber { background: #fdf3e0; color: var(--amber); }

.spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 22px; }
.spark span { width: 4px; background: var(--green-500); border-radius: 2px 2px 0 0; opacity: .85; }

/* ---------- Charts ---------- */
.chart-wrap { position: relative; height: 260px; margin-top: 14px; }
.chart-wrap.tall { height: 320px; }
.chart-wrap.short { height: 200px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
@media (max-width: 980px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Heatmap ---------- */
.heat { display: grid; grid-template-columns: 90px repeat(7, 1fr); gap: 4px; margin-top: 14px; }
.heat .h-label { font-size: 11px; font-weight: 600; color: var(--muted); display: flex; align-items: center; }
.heat .cell {
  border-radius: 8px; padding: 12px 8px; text-align: center;
  font-size: 12.5px; font-weight: 700; color: var(--ink-2);
  background: #f2f4f1;
}
.heat .cell .sub { display: block; font-size: 10px; font-weight: 500; color: var(--muted); margin-top: 2px; }

/* ---------- Progress bars in tables ---------- */
.mini-bar { height: 6px; border-radius: 3px; background: #edf0ec; width: 90px; display: inline-block; vertical-align: middle; margin-right: 8px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: var(--green-600); border-radius: 3px; }

/* ---------- Connections / integrations ---------- */
.conn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
@media (max-width: 980px) { .conn-grid { grid-template-columns: 1fr; } }
.conn-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px;
}
.conn-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.conn-logo {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 17px; flex: 0 0 40px;
}
.conn-logo.shopify { background: #5e8e3e; }
.conn-logo.klaviyo { background: #1c2321; }
.conn-head .name { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.conn-head .what { font-size: 12px; color: var(--muted); }
.conn-status { margin-left: auto; }
.form-row { margin-top: 14px; }
.form-row label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; letter-spacing: .02em; }
.form-row input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; font: inherit; font-size: 13px; color: var(--ink);
  background: #fbfcfb; outline: none; transition: border-color .15s;
}
.form-row input:focus { border-color: var(--green-500); background: #fff; }
.form-row .help { font-size: 11px; color: var(--faint); margin-top: 5px; line-height: 1.5; }
.form-row .help a { color: var(--green-700); }
.btn-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn {
  border: 0; border-radius: 9px; padding: 9px 16px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(.95); }
.btn.primary { background: var(--green-900); color: #fff; }
.btn.soft { background: var(--green-50); color: var(--green-900); border: 1px solid #d6e8dc; }
.btn.ghost { background: #fff; color: var(--ink-2); border: 1px solid var(--line); }
.btn.danger { background: #fdf0ec; color: var(--red); border: 1px solid #f3d4c8; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.conn-msg { margin-top: 12px; font-size: 12.5px; border-radius: 8px; padding: 10px 12px; display: none; }
.conn-msg.ok { display: block; background: var(--green-50); border: 1px solid #d6e8dc; color: var(--green-900); }
.conn-msg.err { display: block; background: #fdf0ec; border: 1px solid #f3d4c8; color: var(--red); }
.sync-log {
  background: #1c2321; color: #b9e6c9; border-radius: 10px; padding: 14px 16px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11.5px;
  line-height: 1.7; margin-top: 14px; max-height: 220px; overflow-y: auto; display: none;
}
.sync-log.show { display: block; }
.mode-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .03em; cursor: pointer; border: 1px solid var(--line); background: var(--card);
}
.mode-pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.mode-pill.demo { color: var(--amber); border-color: #f0dcb3; background: #fdf8ec; }
.mode-pill.demo .dot { background: var(--amber); }
.mode-pill.live { color: var(--green-900); border-color: #c6e2d0; background: var(--green-50); }
.mode-pill.live .dot { background: var(--green-600); animation: pulse 2s infinite; }
.mode-pill.empty { color: var(--muted); }
.mode-pill.empty .dot { background: var(--faint); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.steps { counter-reset: step; margin-top: 12px; }
.steps li {
  list-style: none; position: relative; padding: 0 0 14px 34px;
  font-size: 13px; color: var(--ink-2); line-height: 1.55;
}
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 1px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--green-100); color: var(--green-900);
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.steps b { color: var(--ink); }

/* ---------- Auth (sign-in / setup) ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(600px 400px at 20% 10%, rgba(27,122,67,.08), transparent),
    radial-gradient(500px 350px at 85% 85%, rgba(20,83,45,.07), transparent),
    var(--bg);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 8px 40px rgba(20, 40, 30, .08); padding: 36px 34px;
}
.auth-card .brand { justify-content: center; padding-bottom: 4px; font-size: 19px; }
.auth-tag { text-align: center; color: var(--muted); font-size: 13px; margin: 4px 0 24px; }
.auth-card h2 { font-size: 17px; font-weight: 800; letter-spacing: -.01em; margin-bottom: 4px; }
.auth-card .auth-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }
.auth-card .form-row { margin-top: 12px; }
.auth-card .btn.primary { width: 100%; justify-content: center; padding: 11px; margin-top: 18px; font-size: 14px; }
.auth-error {
  background: #fdf0ec; border: 1px solid #f3d4c8; color: var(--red);
  border-radius: 9px; padding: 10px 12px; font-size: 12.5px; margin-top: 14px; display: none;
}
.auth-error.show { display: block; }
.auth-note { text-align: center; color: var(--faint); font-size: 11.5px; margin-top: 18px; line-height: 1.5; }

/* ---------- Report page ---------- */
.report-toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 20px; margin-top: 18px;
}
.report-toolbar .field { display: flex; flex-direction: column; gap: 4px; }
.report-toolbar label { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; color: var(--faint); text-transform: uppercase; }
.report-toolbar input, .report-toolbar select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  font: inherit; font-size: 13px; background: #fbfcfb; outline: none;
}
.report-toolbar input:focus, .report-toolbar select:focus { border-color: var(--green-500); background: #fff; }
.report-toolbar .btn { margin-top: 16px; }

/* ---------- Utility ---------- */
.loading { display: flex; align-items: center; justify-content: center; padding: 80px 0; color: var(--faint); gap: 10px; font-size: 13px; }
.loading i { animation: spin 1s linear infinite; color: var(--green-700); }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { background: #fdf0ec; border: 1px solid #f3d4c8; border-radius: 10px; padding: 16px; color: var(--red); font-size: 13px; margin-top: 18px; }

.muted { color: var(--muted); }
.green { color: var(--green-700); }
.fw7 { font-weight: 700; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; }

.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; }
.legend .li { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); font-weight: 500; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .funnel-row { grid-template-columns: 1fr; gap: 8px; }
  .funnel-count { text-align: left; }
  .content { padding: 4px 16px 40px; }
}
