:root {
  color-scheme: light;
  --blue: #164d84;
  --deep-blue: #102f53;
  --orange: #f4a348;
  --green: #24806b;
  --ink: #182b43;
  --muted: #4d5e73;
  --background: #f3f6fa;
  --line: #d9e2ec;
  --radius: 1rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--background);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
}

button, select { font: inherit; }
button:focus-visible, select:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.frame {
  width: min(100% - 2.5rem, 70rem);
  margin-inline: auto;
}

.site-header {
  color: white;
  background: var(--deep-blue);
  border-bottom: 3px solid var(--orange);
}

.masthead {
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.brand { font-weight: 760; }
.demo-mark {
  color: #ffe6c5;
  font-size: .8rem;
  font-weight: 650;
  text-align: right;
}

main { padding-block: clamp(1.75rem, 5vw, 3.25rem); }

.page-title { margin-bottom: 1.5rem; }
.eyebrow {
  margin: 0 0 .375rem;
  color: var(--blue);
  font-weight: 750;
  font-size: .9rem;
  letter-spacing: .03em;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: .5rem;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.08;
  letter-spacing: -.035em;
}

h2 { margin-bottom: .3rem; font-size: 1.25rem; line-height: 1.2; }
.intro, .secondary-text { color: var(--muted); margin-bottom: 0; }

.controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.15rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.period-control {
  display: grid;
  gap: .25rem;
  min-width: min(100%, 14rem);
}

.period-control label { font-size: .875rem; font-weight: 750; }

select, .button {
  min-height: 2.75rem;
  padding: .55rem .8rem;
  color: var(--ink);
  background: white;
  border: 1px solid #acbed0;
  border-radius: .55rem;
}

select { max-width: 100%; }

.dataset-control {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .65rem;
}

#data-source { color: var(--muted); font-size: .85rem; }
.button { cursor: pointer; font-weight: 680; }
.button:hover:not(:disabled) { background: #eef5fb; }
.button:disabled { cursor: wait; opacity: .64; }
.button-main {
  border-color: var(--orange);
  background: var(--orange);
  color: #241708;
}
.button-main:hover:not(:disabled) { background: #f9b667; }

.notice {
  margin: .75rem 0 0;
  padding: .65rem .85rem;
  background: #e4f4ed;
  color: #20493f;
  border-radius: .55rem;
}
.notice[data-type="error"] { background: #fbe9e7; color: #862e2a; }

.date-range {
  margin: 1.15rem 0 .55rem;
  color: var(--muted);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 0 0 1rem;
}

.metric {
  min-width: 0;
  padding: 1rem 1.15rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-primary {
  color: white;
  background: var(--blue);
  border-color: var(--blue);
}

.metric dt { font-size: .875rem; font-weight: 700; }
.metric dd {
  margin: .2rem 0 0;
  font-size: clamp(1.1rem, 3vw, 2rem);
  overflow-wrap: anywhere;
  line-height: 1.2;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(15rem, 1fr) minmax(0, 1.65fr);
  align-items: start;
  gap: 1rem;
}

.card {
  min-width: 0;
  padding: 1.15rem;
  border-radius: var(--radius);
  background: white;
  border: 1px solid var(--line);
}

.card .secondary-text { font-size: .875rem; }

.channel-list {
  display: grid;
  gap: 1rem;
  padding: 0;
  margin: 1.15rem 0 0;
  list-style: none;
}

.channel-heading {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .35rem;
  font-size: .9375rem;
}

.bar-track {
  height: .65rem;
  background: #e6edf5;
  border-radius: 2rem;
  overflow: hidden;
}

.bar { display: block; height: 100%; border-radius: inherit; background: var(--blue); }
.bar[data-channel="web"] { background: var(--orange); }
.bar[data-channel="whatsapp"] { background: var(--green); }
.channel-share { color: var(--muted); font-size: .8rem; }

.table-scroll { overflow: auto; max-height: 27rem; margin-top: .65rem; }
table { width: 100%; border-spacing: 0; font-size: .875rem; }
th, td {
  padding: .6rem .55rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  position: sticky;
  top: 0;
  background: #edf3fa;
  color: var(--deep-blue);
  font-size: .8rem;
}
td:nth-child(2) { min-width: 8rem; overflow-wrap: anywhere; }
td:first-child, td:nth-child(3), .amount { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.right { text-align: right; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; }

.import-help { margin-top: 1rem; color: var(--muted); font-size: .875rem; }
.import-help summary { color: var(--blue); cursor: pointer; font-weight: 750; }
.import-help p { margin: .65rem 0 0; }
.import-help pre {
  box-sizing: border-box;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  margin: .65rem 0 0;
  padding: .6rem .85rem;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: .55rem;
}

@media (max-width: 800px) {
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .frame { width: calc(100% - 1.5rem); }
  .controls, .card { padding: .85rem; }
  .metrics { gap: .45rem; }
  .metric { padding: .65rem .5rem; }
  .metric dt { font-size: .75rem; }
}
