:root {
  --ink: #1a1a1a;
  --ink2: #3f3f46;
  --muted: #73737a;
  --faint: #a1a1aa;
  --line: #eaeaec;
  --line2: #f2f2f4;
  --tile: #f7f7f8;
  --page-bg: #f4f4f5;

  --green: #15803d;
  --green-bg: #dcfce7;
  --amber: #92400e;
  --amber-bg: #fef3c7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --blue: #1d4ed8;
  --blue-bg: #eef3ff;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  background: var(--page-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--ink);
}

.page {
  max-width: 1200px;
  margin: 28px auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 10px 30px rgba(0, 0, 0, .05);
  padding: 22px 24px 24px;
}

/* Header */

.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.head-l {
  display: flex;
  gap: 11px;
  align-items: center;
}

.appicon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex: 0 0 auto;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(37, 99, 235, .4);
}

.appicon svg {
  width: 16px;
  height: 16px;
}

.title {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.01em;
  line-height: 1.1;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.head-r {
  display: flex;
  gap: 7px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink2);
  background: var(--page-bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 8px;
  white-space: nowrap;
}

.pill.live {
  color: var(--green);
  background: var(--green-bg);
  border-color: #bbf7d0;
}

.pill.live .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

/* Filters */

.filters {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--line);
}

.filters label {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filters input[type="date"] {
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
}

/* Sections */

section {
  margin-top: 22px;
}

.sec-h {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 12px;
}

.sec-h .t, section h2, section h3 {
  font-size: 12.5px;
  font-weight: 620;
  color: var(--ink2);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin: 0 0 12px;
  border: none;
  padding: 0;
}

section h3 {
  margin-top: 18px;
}

/* KPI tiles */

.kpi-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.kpi-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tile);
  padding: 10px 12px 11px;
}

.kpi-card .value {
  font-size: 22px;
  font-weight: 660;
  letter-spacing: -.02em;
  line-height: 1.2;
  color: var(--ink);
}

.kpi-card .label {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 4px;
}

/* Tables */

table {
  border-collapse: collapse;
  width: 100%;
}

thead th {
  font-size: 10.5px;
  font-weight: 550;
  color: var(--faint);
  text-align: left;
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--line);
  text-transform: none;
}

.perf-table th:not(:first-child), .perf-table td:not(:first-child) {
  text-align: right;
}

tbody td {
  font-size: 13px;
  color: var(--ink2);
  padding: 9px 8px;
  border-bottom: 1px solid var(--line2);
  transition: background .12s;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: #fafafb;
}

/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 5px;
  padding: 2px 7px;
  white-space: nowrap;
}

.badge-green { color: var(--green); background: var(--green-bg); }
.badge-amber { color: var(--amber); background: var(--amber-bg); }
.badge-red { color: var(--red); background: var(--red-bg); }
.badge-gray { color: var(--faint); background: var(--line2); }

/* Funnel bars */

.funnel-row {
  display: grid;
  grid-template-columns: 200px 1fr 60px;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--ink2);
}

.funnel-bar-track {
  display: block;
  background: var(--line2);
  border-radius: 4px;
  height: 14px;
  overflow: hidden;
}

.funnel-bar-fill {
  display: block;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  height: 100%;
  border-radius: 4px;
}

.funnel-row .count {
  text-align: right;
  font-weight: 600;
  color: var(--ink);
}

/* Contact browser controls */

.browser-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

#browser-search, #browser-stage-filter {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

#browser-table tbody tr {
  cursor: pointer;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 0.75rem;
  background: var(--tile);
}

.detail-card h3 {
  text-transform: none;
  letter-spacing: normal;
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
}

.detail-card p {
  font-size: 12.5px;
  color: var(--ink2);
  margin: 4px 0;
}

/* Footer */

.foot {
  margin-top: 26px;
  padding-top: 12px;
  border-top: 1px solid var(--line2);
  font-size: 10.5px;
  color: var(--faint);
  display: flex;
  justify-content: space-between;
}

#error-message {
  color: var(--red);
  font-weight: 600;
  font-size: 13px;
}
