/* Cards, KPIs, tables, pills, funnel bars, buttons */

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: var(--s-lg);
  box-shadow: var(--shadow-card);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-sm);
  margin-bottom: var(--s-md);
}
.card-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text-primary);
}
.card-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── KPI grid ───────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-md);
  margin-bottom: var(--s-lg);
}
.kpi {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: var(--s-md) var(--s-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: var(--s-xs);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--teal);
}
.kpi.kpi-gold::before { background: var(--gold); }
.kpi.kpi-danger::before { background: var(--danger); }
.kpi.kpi-success::before { background: var(--success); }

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.kpi-value {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.1;
  color: var(--teal-deep);
}
.kpi-sub {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ── Tables ──────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: var(--s-sm);
  border-bottom: 1px solid var(--divider);
  background: var(--bg-card);
  position: sticky;
  top: 0;
}
.data-table td {
  padding: 10px var(--s-sm);
  border-bottom: 1px solid var(--divider);
  vertical-align: top;
}
.data-table tbody tr:hover { background: var(--bg-card-muted); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.data-table .col-narrow { width: 1%; white-space: nowrap; }
.data-table .col-grow { width: auto; }
.data-table .partner-name {
  font-weight: 500;
  color: var(--teal-deep);
}
.data-table .partner-slug {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.table-wrap {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: var(--s-md) var(--s-lg);
  box-shadow: var(--shadow-card);
  overflow-x: auto;
}

/* ── Pills / badges ─────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-family: var(--font-body);
}
.pill-success { background: var(--success); color: white; }
.pill-danger { background: var(--danger); color: white; }
.pill-warning { background: var(--warning); color: white; }
.pill-muted { background: var(--bg-card-muted); color: var(--text-secondary); }
.pill-teal { background: var(--teal); color: white; }
.pill-gold { background: var(--gold); color: var(--teal-dark); }

/* ── Funnel bars ─────────────────────────────────────────── */
.funnel {
  display: flex;
  flex-direction: column;
  gap: var(--s-sm);
}
.funnel-row {
  display: grid;
  grid-template-columns: 180px 1fr 80px;
  align-items: center;
  gap: var(--s-md);
  padding: 8px 0;
}
.funnel-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.funnel-bar-track {
  height: 28px;
  background: var(--bg-card-muted);
  border-radius: var(--r-sm);
  position: relative;
  overflow: hidden;
}
.funnel-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--teal) 0%, var(--teal-light) 100%);
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: white;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  transition: width 360ms cubic-bezier(.4, 0, .2, 1);
}
.funnel-bar-fill.zero {
  background: var(--bg-card-muted);
  color: var(--text-secondary);
}
.funnel-row-meta {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
}

.funnel-group {
  border-bottom: 1px solid var(--divider);
  padding-bottom: var(--s-lg);
  margin-bottom: var(--s-lg);
}
.funnel-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}
.funnel-group-title {
  font-family: var(--font-display);
  font-size: 16px;
  margin-bottom: var(--s-sm);
  color: var(--teal-deep);
}
.funnel-group-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: var(--s-md);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-xs);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 10px var(--s-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms, transform 120ms;
}
.btn-primary {
  background: var(--teal);
  color: var(--bg-card);
}
.btn-primary:hover { background: var(--teal-light); }
.btn-ghost {
  background: transparent;
  color: var(--text-on-dark);
  border-color: var(--divider-dark);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }

/* ── States ──────────────────────────────────────────────── */
.loading,
.empty,
.error-block {
  padding: var(--s-xl);
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
}
.loading::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--divider);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-block {
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--r-md);
  padding: var(--s-md);
  text-align: left;
}

/* ── Timeline rows ───────────────────────────────────────── */
.timeline-row {
  display: grid;
  grid-template-columns: 140px 220px 1fr;
  gap: var(--s-md);
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 13px;
}
.timeline-row:last-child { border-bottom: none; }
.timeline-time {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  font-size: 11px;
  color: var(--text-secondary);
}
.timeline-user {
  font-weight: 500;
  color: var(--text-primary);
}
.timeline-user-sub {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.timeline-event {
  font-family: var(--font-mono);
  font-size: 12px;
}
.timeline-props {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Timeseries sparkline ────────────────────────────────── */
.sparkline-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: center;
  gap: var(--s-md);
  padding: 8px 0;
  border-bottom: 1px dashed var(--divider);
  font-size: 12px;
}
.sparkline-row:last-child { border-bottom: none; }
.sparkline-date {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  color: var(--text-secondary);
}
.sparkline-bars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.sparkline-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  font-size: 11px;
  color: var(--text-secondary);
}
.sparkline-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-card-muted);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  min-width: 30px;
}
.sparkline-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--teal);
  border-radius: 4px;
}
.sparkline-bar-fill.teal-light { background: var(--teal-light); }
.sparkline-bar-fill.gold { background: var(--gold); }
.sparkline-bar-fill.success { background: var(--success); }
.sparkline-bar-fill.danger { background: var(--danger); }
.sparkline-num {
  min-width: 40px;
  text-align: right;
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Section heading ─────────────────────────────────────── */
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-md);
  margin-top: var(--s-xl);
  margin-bottom: var(--s-md);
  padding-top: var(--s-sm);
}
.section-heading h2 { color: var(--bg-card); }
.section-heading .muted-on-dark { font-size: 12px; }
