/* ===================================
   PILATES IN PINK — STUDIO DASHBOARD
   Brand Palette: #f1889b · #f7b1bd · #fbe0e2 · #b67651 · #f6eee7
   Fonts: DM Sans (body), DM Mono (data)
=================================== */

/* ---- TOKENS ---- */
:root,
[data-theme='light'] {
  --color-bg: #f6eee7;
  --color-surface: #ffffff;
  --color-surface-2: #fbe0e2;
  --color-surface-offset: #f7d8dc;
  --color-border: #f0c8cf;
  --color-divider: #f5dde0;

  --color-text: #1a0c10;
  --color-text-muted: #5a3a42;
  --color-text-faint: #c4a0a8;
  --color-text-inverse: #fff;

  --color-pink: #f1889b;
  --color-pink-hover: #e06a80;
  --color-pink-active: #c94e67;
  --color-pink-highlight: #fbe0e2;

  --color-primary: #f1889b;
  --color-primary-hover: #e06a80;
  --color-warm: #b67651;
  --color-warm-hover: #9a5e3a;

  --color-success: #3d7a4e;
  --color-success-bg: #d4ecdb;
  --color-error: #b03434;
  --color-error-bg: #fde8e8;
  --color-warning: #a06830;
  --color-warning-bg: #fdecd5;

  --color-sidebar-bg: #ffffff;
  --color-sidebar-text: #2a1a1e;
  --color-sidebar-muted: #b08890;
  --color-sidebar-active-bg: #fbe0e2;
  --color-sidebar-active-text: #d45a72;
  --color-sidebar-hover: rgba(241,136,155,0.08);
  --color-sidebar-border: #f0c8cf;

  --shadow-sm: 0 1px 3px rgba(180,80,100,0.07);
  --shadow-md: 0 4px 16px rgba(180,80,100,0.09);
  --shadow-lg: 0 12px 40px rgba(180,80,100,0.13);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --sidebar-width: 220px;
  --topbar-height: 60px;

  --transition: 180ms cubic-bezier(0.16,1,0.3,1);

  --font-body: 'DM Sans', 'Helvetica Neue', sans-serif;
  --font-mono: 'DM Mono', 'Courier New', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
}

[data-theme='dark'] {
  --color-bg: #1a1013;
  --color-surface: #231518;
  --color-surface-2: #2a1b1f;
  --color-surface-offset: #321f24;
  --color-border: #3d2830;
  --color-divider: #342028;

  --color-text: #f0e4e8;
  --color-text-muted: #9a7d84;
  --color-text-faint: #5e4850;
  --color-text-inverse: #1a1013;

  --color-pink: #f1889b;
  --color-pink-hover: #f7a8b8;
  --color-pink-active: #fbc4d0;
  --color-pink-highlight: #3d1f28;

  --color-primary: #f1889b;
  --color-primary-hover: #f7a8b8;
  --color-warm: #c98a62;
  --color-warm-hover: #dba07a;

  --color-success: #5da874;
  --color-success-bg: #1a2e22;
  --color-error: #dd6b6b;
  --color-error-bg: #2e1a1a;
  --color-warning: #d49550;
  --color-warning-bg: #2e2015;

  --color-sidebar-bg: #1a1013;
  --color-sidebar-text: #f0e4e8;
  --color-sidebar-muted: #7a5c62;
  --color-sidebar-active-bg: rgba(241,136,155,0.15);
  --color-sidebar-active-text: #f7b1bd;
  --color-sidebar-hover: rgba(241,136,155,0.07);
  --color-sidebar-border: #3d2830;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ---- LAYOUT ---- */
.app {
  display: none;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100dvh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  background: var(--color-sidebar-bg);
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--color-sidebar-border);
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--color-sidebar-border);
}
.logo-wordmark {
  font-size: var(--text-base);
  font-weight: 600;
  color: #e8607a;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-sidebar-text);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--color-sidebar-hover); color: #c94e67; }
.nav-item.active {
  background: var(--color-sidebar-active-bg);
  color: #c94e67;
}
.nav-item svg { opacity: 0.7; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }

.sidebar-logo-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--color-sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--color-sidebar-muted);
}
.meta-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6b7280;
}
.meta-dot.live { background: #4ade80; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.theme-toggle {
  color: var(--color-sidebar-muted);
  padding: 5px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.theme-toggle:hover { color: var(--color-sidebar-text); background: var(--color-sidebar-hover); }

/* ---- SIGN OUT BUTTON ---- */
.signout-btn {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--color-sidebar-muted);
  padding: 5px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.signout-btn:hover {
  color: var(--color-error);
  background: var(--color-error-bg);
}

/* ---- MAIN AREA ---- */
.main {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ---- TOPBAR ---- */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
  gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.menu-toggle {
  display: none;
  color: var(--color-text-muted);
  padding: 5px;
  border-radius: var(--radius-sm);
}
.page-title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.data-range, .txn-count {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}
.data-range-btn {
  font-size: var(--text-xs);
  color: var(--color-pink);
  background: var(--color-pink-highlight);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 4px 12px;
  cursor: pointer;
  font-weight: 500;
  transition: background var(--transition);
}
.data-range-btn:hover { background: var(--color-surface-offset); }
.data-range-detail {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ---- SCROLL CONTENT ---- */
.content-section {
  display: none;
  flex-direction: column;
  gap: 20px;
  padding: 24px 28px 40px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
  min-height: 0;
}
.content-section.active { display: flex; }

.section-intro p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 600px;
  line-height: 1.6;
}
.section-intro strong { color: var(--color-text); }

/* ---- KPI CARDS ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-card.accent {
  background: var(--color-pink);
  border-color: transparent;
  color: white;
}
.kpi-card.accent .kpi-label,
.kpi-card.accent .kpi-sub { color: rgba(255,255,255,0.75); }
.kpi-card.accent .kpi-delta { color: rgba(255,255,255,0.9); }
.kpi-card.accent-warm {
  background: var(--color-warm);
  border-color: transparent;
  color: white;
}
.kpi-card.accent-warm .kpi-label,
.kpi-card.accent-warm .kpi-sub { color: rgba(255,255,255,0.75); }

.kpi-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums lining-nums;
  font-family: var(--font-mono);
  margin-bottom: 6px;
}
.kpi-value.text-md {
  font-size: 1.1rem;
  font-family: var(--font-body);
  font-variant-numeric: normal;
}
.kpi-sub {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.4;
}
.kpi-delta {
  font-size: var(--text-xs);
  font-weight: 600;
  margin-bottom: 4px;
}
.kpi-delta.positive { color: var(--color-success); }
.kpi-delta.negative { color: var(--color-error); }

/* ---- CARDS ---- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.card-row {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
}
.card.wide { /* inherits */ }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-badge {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.card-badge.pink {
  background: var(--color-pink-highlight);
  color: var(--color-pink);
  border-color: transparent;
}
.card-badge.muted {
  background: var(--color-surface-offset);
  color: var(--color-text-faint);
}

/* ---- MONTH LABELS ---- */
.month-labels {
  display: flex;
  justify-content: space-between;
  padding: 4px 0 0;
}
.month-labels span {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-family: var(--font-mono);
}

/* ---- PIE LEGEND ---- */
.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 12px;
  /* no max-height — all items visible without scrollbar */
}
.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.pie-dot {
  width: 9px; height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ---- TABLES ---- */
.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}
.data-table {
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums lining-nums;
}
.data-table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
  white-space: nowrap;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--color-surface-2); }
.data-table .num { text-align: right; font-family: var(--font-mono); }
.data-table .total-row td { font-weight: 700; background: var(--color-surface-offset); }
.data-table .tier-name { font-weight: 500; }
.data-table .founding { color: var(--color-text-muted); font-style: italic; }

/* BAR IN TABLE */
.mini-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.mini-bar-track { flex: 1; height: 6px; background: var(--color-border); border-radius: 3px; overflow: hidden; }
.mini-bar-fill { height: 100%; border-radius: 3px; background: var(--color-pink); transition: width 0.6s ease; }
.mini-bar-label { font-size: var(--text-xs); color: var(--color-text-muted); min-width: 30px; text-align: right; }

/* ---- CHART IMAGES ---- */
.chart-img-wrap {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-img {
  width: 100%;
  height: auto;
  display: block;
}

/* ---- INSIGHT BOX ---- */
.insight-box {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--color-pink-highlight);
  border-left: 3px solid var(--color-pink);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.6;
}
[data-theme='dark'] .insight-box { background: rgba(232,121,155,0.1); }
.insight-box strong { color: var(--color-pink); }

/* ---- EXPORT BTN ---- */
.export-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  transition: all var(--transition);
}
.export-btn:hover {
  border-color: var(--color-pink);
  color: var(--color-pink);
  background: var(--color-pink-highlight);
}

/* ---- ANALYSIS SECTION ---- */
.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.analysis-card {
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  padding: 18px 20px !important;
}
.analysis-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--color-pink);
}
.analysis-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  background: var(--color-pink-highlight);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-pink);
  flex-shrink: 0;
}
[data-theme='dark'] .analysis-icon { background: rgba(232,121,155,0.12); }
.analysis-info { flex: 1; }
.analysis-title {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 3px;
}
.analysis-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
}
.analysis-arrow {
  font-size: 1.2rem;
  color: var(--color-text-faint);
  flex-shrink: 0;
  transition: color var(--transition), transform var(--transition);
}
.analysis-card:hover .analysis-arrow { color: var(--color-pink); transform: translateX(3px); }

/* ---- REQUEST FORM ---- */
.analysis-request-card { margin-top: 4px; }
.request-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: 14px;
  line-height: 1.6;
}
.request-form {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.request-textarea {
  flex: 1;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  resize: vertical;
  line-height: 1.5;
  transition: border-color var(--transition);
}
.request-textarea:focus {
  outline: none;
  border-color: var(--color-pink);
}
.request-textarea::placeholder { color: var(--color-text-faint); }
.request-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-pink);
  color: white;
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.request-btn:hover { background: var(--color-pink-hover); transform: translateY(-1px); }
.request-btn:active { transform: translateY(0); }

/* ---- RESULT AREA ---- */
.request-result {
  margin-top: 20px;
  border-top: 1px solid var(--color-divider);
  padding-top: 16px;
}
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.result-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}
.result-body { font-size: var(--text-sm); color: var(--color-text); line-height: 1.7; }
.result-body table { margin-top: 10px; }
.result-body th {
  text-align: left;
  padding: 7px 11px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
}
.result-body td {
  padding: 8px 11px;
  border-bottom: 1px solid var(--color-divider);
  font-variant-numeric: tabular-nums;
}
.result-body .highlight { color: var(--color-pink); font-weight: 600; }

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
  z-index: 100;
  max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ---- PROSPECT BADGES ---- */
.prospect-streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-success-bg);
  color: var(--color-success);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.plan-badge {
  display: inline-block;
  background: var(--color-pink-highlight);
  color: var(--color-pink);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
[data-theme='dark'] .plan-badge { background: rgba(232,121,155,0.15); }

/* ---- LOADING SPINNER ---- */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-pink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .card-row { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100dvh;
    width: var(--sidebar-width);
    z-index: 50;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { grid-column: 1; }
  .menu-toggle { display: block; }
  .topbar { padding: 0 16px; }
  .content-section { padding: 16px 16px 40px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── New classes for v2 ── */
.card-footer-note {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  padding: 10px 20px 14px;
  border-top: 1px solid var(--color-border);
  margin-top: 0;
}

.card-badge.green {
  background: rgba(72, 199, 142, 0.15);
  color: var(--color-success, #48c78e);
  border: 1px solid rgba(72, 199, 142, 0.3);
}

.tier-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ── Login Screen ── */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f6eee7;
}

.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 40px;
  background: #ffffff;
  border: 1px solid #f0c8cf;
  border-radius: 20px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(241,136,155,0.12);
}

.login-logo {
  margin-bottom: 4px;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 600;
  color: #2a1a1e;
  margin: 0;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 0.88rem;
  color: #7a5c62;
  margin: 0 0 8px;
  line-height: 1.5;
}

.login-error {
  font-size: 0.82rem;
  color: #ff6b6b;
  background: rgba(255,107,107,0.1);
  border: 1px solid rgba(255,107,107,0.2);
  border-radius: 8px;
  padding: 10px 16px;
  width: 100%;
}

.login-note {
  font-size: 0.75rem;
  color: var(--color-text-muted, #6b5f62);
  margin: 4px 0 0;
}

/* Sidebar user info */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-sidebar-border);
  margin-top: auto;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--color-pink-highlight);
}

.user-detail {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 0.68rem;
  color: var(--color-sidebar-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- TIER BREAKDOWN ---- */
.tier-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding-top: 4px;
}

.tier-block {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border-left: 4px solid var(--tier-color, #f1889b);
}

.tier-block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.tier-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tier-color, #f1889b);
  flex-shrink: 0;
}

.tier-block-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.tier-product-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tier-product-list li {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding-left: 10px;
  position: relative;
  line-height: 1.5;
}

.tier-product-list li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--tier-color, #f1889b);
  font-weight: 700;
}

.tier-product-list em {
  font-style: italic;
  opacity: 0.75;
}

/* Tier colors */
.tier-intro      { --tier-color: #f1889b; }
.tier-explorer   { --tier-color: #f7b1bd; }
.tier-mid        { --tier-color: #e8976e; }
.tier-uppermid   { --tier-color: #b67651; }
.tier-ilike      { --tier-color: #c06080; }
.tier-ifancy     { --tier-color: #a84868; }
.tier-ilove      { --tier-color: #8c3054; }
.tier-premium    { --tier-color: #6b2040; }
.tier-founding   { --tier-color: #b67651; }
.tier-events     { --tier-color: #8aa86e; }
.tier-retail     { --tier-color: #7a9ab8; }

.kpi-clickable {
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.kpi-clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-pink);
}
.kpi-clickable.active-kpi {
  border-color: var(--color-pink);
  box-shadow: 0 0 0 2px var(--color-pink-highlight), var(--shadow-md);
}
.kpi-detail-card {
  margin-top: 0;
  background: rgba(251, 245, 218, 0.55) !important;
  border-color: rgba(215, 195, 120, 0.4) !important;
}
[data-theme='dark'] .kpi-detail-card {
  background: rgba(80, 65, 20, 0.28) !important;
  border-color: rgba(180, 150, 60, 0.3) !important;
}

/* ---- KPI DETAIL ARROW ---- */
.kpi-detail-arrow {
  display: none;
  position: absolute;
  top: -10px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 10px solid var(--color-border);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 2;
}
.kpi-detail-arrow::after {
  content: '';
  position: absolute;
  top: 2px;
  left: -9px;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 9px solid var(--color-surface);
}

/* ---- ANALYSIS PROGRESS BAR ---- */
.analysis-progress {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0;
}
.progress-bar {
  height: 6px;
  background: var(--color-surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-pink), var(--color-warm));
  border-radius: 99px;
  transition: width 300ms ease;
}
.progress-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ---- CONVERSION DETAIL PANEL ---- */
#conv-detail-panel {
  background: rgba(251, 245, 218, 0.55);
  border: 1px solid rgba(215, 195, 120, 0.4);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
  margin-top: 0;
}
[data-theme='dark'] #conv-detail-panel {
  background: rgba(80, 65, 20, 0.28);
  border-color: rgba(180, 150, 60, 0.3);
}
#conv-detail-arrow {
  display: none;
  position: absolute;
  top: -10px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 10px solid rgba(215, 195, 120, 0.4);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 2;
}
#conv-detail-arrow::after {
  content: '';
  position: absolute;
  top: 2px;
  left: -9px;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 9px solid rgba(251, 245, 218, 0.9);
}
[data-theme='dark'] #conv-detail-arrow::after {
  border-bottom-color: rgba(60, 48, 15, 0.95);
}

/* ---- TIER FILTER DROPDOWN ---- */
.tier-filter-wrap {
  position: relative;
  display: inline-block;
}
.tier-filter-btn {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.tier-filter-btn:hover {
  border-color: var(--color-pink);
  color: var(--color-pink);
}
.tier-filter-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  min-width: 200px;
  padding: 6px 0;
  display: none;
}
.tier-filter-dropdown.open { display: block; }
.tier-filter-option {
  padding: 8px 14px;
  font-size: var(--text-xs);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tier-filter-option:hover { background: var(--color-surface-2); }
.tier-filter-option.selected { color: var(--color-pink); font-weight: 600; }
.tier-color-dot {
  width: 9px; height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ---- PIE MONTH SELECT ---- */
.pie-month-select {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  cursor: pointer;
  font-family: var(--font-body);
  appearance: none;
  -webkit-appearance: none;
  padding-right: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}
.pie-month-select:focus { outline: none; border-color: var(--color-pink); }

/* ---- SWIM LANES (Active Customers tile & Tiers page) ---- */
.tier-swim-lanes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}
.swim-lane {
  flex: 1 1 180px;
  min-width: 160px;
  max-width: 240px;
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--lane-color, #f1889b);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  padding: 0;
  overflow: hidden;
}
.swim-lane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0,0,0,0.04);
  border-bottom: 1px solid var(--color-border);
}
[data-theme="dark"] .swim-lane-header {
  background: rgba(255,255,255,0.04);
}
.swim-lane-name {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--lane-color);
}
.swim-lane-total {
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--color-text);
}
.swim-lane-body { padding: 8px 0; }
.swim-lane-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  gap: 6px;
}
.swim-lane-row:hover { background: var(--color-surface-offset); }
.swim-product-name {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  flex: 1;
  line-height: 1.4;
}
.swim-product-count {
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--color-text);
  flex-shrink: 0;
}

/* Tiers page swim lanes — product list style */
.tiers-swim-lanes {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 4px;
}
.tier-swim-card {
  flex: 1 1 160px;
  min-width: 150px;
  max-width: 220px;
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--lane-color, #f1889b);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  overflow: hidden;
}
.tier-swim-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: rgba(0,0,0,0.04);
  border-bottom: 1px solid var(--color-border);
}
[data-theme="dark"] .tier-swim-card-header {
  background: rgba(255,255,255,0.04);
}
.tier-swim-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lane-color, #f1889b);
  flex-shrink: 0;
}
.tier-swim-name {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--lane-color);
  line-height: 1.3;
}
.tier-swim-products {
  padding: 8px 0;
  list-style: none;
  margin: 0;
}
.tier-swim-products li {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  padding: 3px 12px;
  line-height: 1.4;
}
.tier-swim-products li em {
  font-style: normal;
  opacity: 0.7;
}

/* ---- Mobile table scroll for result-body / kpi-detail-body ---- */
.result-body table,
#kpi-detail-body table,
#conv-detail-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}
.result-body table td,
.result-body table th,
#kpi-detail-body table td,
#kpi-detail-body table th,
#conv-detail-body table td,
#conv-detail-body table th {
  white-space: nowrap;
}
/* Allow multi-line cells that have inline style white-space:normal */
.result-body table td[style*="normal"],
#kpi-detail-body table td[style*="normal"],
#conv-detail-body table td[style*="normal"] {
  white-space: normal;
  min-width: 100px;
  max-width: 180px;
}
@media (max-width: 768px) {
  .result-body,
  #kpi-detail-body,
  #conv-detail-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Tighten table cells on mobile */
  .result-body table td,
  .result-body table th,
  #kpi-detail-body table td,
  #kpi-detail-body table th,
  #conv-detail-body table td,
  #conv-detail-body table th {
    padding: 6px 8px;
    font-size: 0.78rem;
  }
}

/* ---- CONVERSION PAGE: 3-TAB + PROSPECTS LAYOUT ---- */
.conv-top-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.conv-tabs-card {
  flex: 2 1 320px;
  min-width: 280px;
  padding: 0;
  overflow: hidden;
}
.conv-tabs-header {
  border-bottom: 1px solid var(--color-border);
}
.conv-tabs {
  display: flex;
}
.conv-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 10px 12px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--font-body);
}
.conv-tab:hover { background: var(--color-surface-offset); }
.conv-tab.active {
  border-bottom-color: var(--color-pink);
  background: color-mix(in srgb, var(--color-pink) 6%, transparent);
}
.conv-tab-val {
  font-size: 1.4rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--color-text);
  line-height: 1;
}
.conv-tab.active .conv-tab-val { color: var(--color-pink); }
.conv-tab-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.conv-tab.active .conv-tab-label { color: var(--color-pink); }
.conv-tab-legend {
  padding: 6px 14px 8px;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  min-height: 22px;
}
#conv-tab-body {
  padding: 12px 14px;
}
#conv-tab-body table { margin-top: 0; }

/* Customer tags: DC / SA */
.cust-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 5px;
  vertical-align: middle;
  letter-spacing: 0.04em;
}
.cust-tag.dc {
  background: rgba(91,158,207,0.18);
  color: #3a7da0;
}
.cust-tag.sa {
  background: rgba(80,168,80,0.16);
  color: var(--color-success);
}

/* Warmest prospects highlighted card */
.conv-prospects-card {
  flex: 1 1 200px;
  min-width: 180px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border: 1.5px solid rgba(241,136,155,0.35);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.conv-prospects-card:hover {
  border-color: var(--color-pink);
  box-shadow: 0 0 0 3px rgba(241,136,155,0.15);
}
.conv-prospects-card.active-kpi {
  border-color: var(--color-pink);
  box-shadow: 0 0 0 3px rgba(241,136,155,0.2);
}
.prospects-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top left, rgba(241,136,155,0.1), transparent 70%);
  pointer-events: none;
}
.prospect-hint {
  font-size: 0.76rem;
  color: var(--color-pink);
  font-weight: 600;
}

/* ---- ASK PiP AI PAGE ---- */
.ask-pip-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  height: calc(100vh - 200px);
  min-height: 400px;
}
.ask-pip-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.chat-msg.user { flex-direction: row-reverse; }
.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 4px 14px 14px 14px;
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: 0.875rem;
  line-height: 1.55;
}
.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, #f1889b, #c0336d);
  color: #fff;
  border-radius: 14px 4px 14px 14px;
}
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chat-suggestion {
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-family: var(--font-body);
  color: var(--color-pink);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}
.chat-suggestion:hover { background: rgba(241,136,155,0.12); }
.ask-pip-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}
.ask-pip-textarea {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.875rem;
  background: var(--color-surface-2);
  color: var(--color-text);
  resize: none;
  font-family: var(--font-body);
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}
.ask-pip-textarea:focus { border-color: var(--color-pink); }
.ask-pip-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f1889b, #c0336d);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.ask-pip-send:hover { transform: scale(1.05); }
.chat-typing { display: flex; gap: 4px; padding: 6px 0; }
.chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-text-muted);
  animation: chatBounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ---- IMAGE MODAL ---- */
#img-modal { display: none; }
#img-modal.open {
  display: flex !important;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

