* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif; background: #f5f6f8; color: #1B2A4A; }

.header { background: #1B2A4A; color: white; padding: 16px 32px; display: flex; justify-content: space-between; align-items: center; }
.header h1 { font-size: 18px; font-weight: 600; }
.updated { font-size: 12px; opacity: 0.7; }

.tabs { background: #fff; border-bottom: 2px solid #e5e7eb; padding: 0 32px; display: flex; position: sticky; top: 0; z-index: 50; }
.tab { padding: 14px 24px; cursor: pointer; font-size: 14px; font-weight: 500; color: #666; border-bottom: 3px solid transparent; user-select: none; }
.tab.active { color: #1B2A4A; border-bottom-color: #3A6EA5; }
.tab:hover { color: #1B2A4A; }

.content { display: none; padding: 24px 32px; max-width: 1200px; margin: 0 auto; }
.content.active { display: block; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: white; border-radius: 8px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.kpi .label { font-size: 10px; text-transform: uppercase; color: #888; letter-spacing: 0.5px; margin-bottom: 4px; }
.kpi .value { font-size: 26px; font-weight: 700; }
.kpi .sub { font-size: 11px; color: #888; margin-top: 2px; }
.kpi .change.up { color: #27ae60; }
.kpi .change.down { color: #e74c3c; }

.section { background: white; border-radius: 8px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.section h2 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px 10px; background: #f8f9fa; color: #666; font-weight: 600; font-size: 10px; text-transform: uppercase; border-bottom: 2px solid #e5e7eb; cursor: pointer; user-select: none; white-space: nowrap; }
th:hover { background: #eef0f2; }
td { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.bar { height: 8px; background: #3A6EA5; border-radius: 4px; min-width: 2px; }
.chart-container { height: 250px; }

/* Badges */
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.badge.trialing { background: #dbeafe; color: #1e40af; }
.badge.active { background: #dcfce7; color: #166534; }
.badge.canceled { background: #fee2e2; color: #991b1b; }
.badge.omeda { background: #f3e8ff; color: #6b21a8; }
.badge.stripe { background: #dbeafe; color: #1e40af; }
.badge.both { background: #dcfce7; color: #166534; }

/* Omeda status badges (item 7) */
.badge.om-active { background: #dcfce7; color: #166534; }
.badge.om-trial { background: #dbeafe; color: #1e40af; }
.badge.om-none { background: #f3f4f6; color: #9ca3af; }
.badge.om-nosub { background: #fef3c7; color: #92400e; }

/* Filter sections */
.filter-section { padding: 14px 20px !important; margin-bottom: 14px !important; }
.filter-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 10px; font-weight: 600; text-transform: uppercase; color: #888; letter-spacing: 0.5px; }
.filter-group select, .filter-group input {
  padding: 6px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; font-family: inherit;
}

/* Checkbox filter panels (items 5-6) */
.cb-panel { min-width: 180px; }
.cb-header { display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 6px 10px; border: 1px solid #ddd; border-radius: 4px; background: #fff; user-select: none; font-size: 13px; }
.cb-header:hover { background: #f8f9fa; }
.cb-header .arrow { font-size: 10px; color: #999; transition: transform 0.2s; display: inline-block; }
.cb-header .arrow.open { transform: rotate(90deg); }
.cb-count { margin-left: auto; font-size: 11px; color: #888; }
.cb-body { display: none; border: 1px solid #e5e7eb; border-top: none; border-radius: 0 0 4px 4px; padding: 8px 10px; background: #fff; max-height: 200px; overflow-y: auto; }
.cb-body.open { display: block; }
.cb-actions { display: flex; gap: 12px; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid #f0f0f0; }
.cb-actions a { font-size: 11px; color: #3A6EA5; cursor: pointer; text-decoration: none; }
.cb-actions a:hover { text-decoration: underline; }
.cb-item { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: 12px; color: #444; cursor: pointer; }
.cb-item input { margin: 0; cursor: pointer; }

/* Funnel viz */
.funnel-step { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.funnel-label { width: 140px; text-align: right; font-size: 13px; font-weight: 500; color: #555; flex-shrink: 0; }
.funnel-bar-wrap { flex: 1; background: #f3f4f6; border-radius: 6px; height: 36px; overflow: visible; position: relative; }
.funnel-bar { height: 100%; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: white; font-size: 13px; font-weight: 700; min-width: 40px; transition: width 0.5s; }
.funnel-rate { width: 60px; font-size: 12px; color: #888; text-align: right; flex-shrink: 0; }
.f1 { background: #1B2A4A; }
.f-trial { background: #3A6EA5; }
.f-call { background: #0d9488; }
.f-signup { background: #9ca3af; }
.f4 { background: #27ae60; }
.funnel-connector { margin-left: 152px; height: 12px; border-left: 2px dashed #ddd; }

/* Source row drill-down */
.source-row { cursor: pointer; }
.source-row:hover { background: #f8f9fa; }

/* Referral legend */
.referral-legend { margin-top: 16px; padding-top: 16px; border-top: 1px solid #e5e7eb; }
.referral-legend h3 { font-size: 12px; font-weight: 600; color: #888; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.referral-legend p { font-size: 12px; color: #666; margin-bottom: 4px; line-height: 1.5; }
.referral-legend p strong { color: #444; }

/* Responsive */
@media (max-width: 768px) {
  .header { padding: 12px 16px; }
  .tabs { padding: 0 16px; overflow-x: auto; }
  .content { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-row { flex-direction: column; align-items: stretch; }
  .funnel-label { width: 100px; font-size: 11px; }
  .cb-panel { min-width: auto; }
}
