:root {
  color-scheme: light;

  --surface: #FDF6E9;
  --surface-raised: #FFFFFF;
  --surface-line: #F0E2C4;
  --ink: #17414F;
  --ink-muted: #5B7A87;
  --ink-faint: #93AEB8;

  --accent: #FF7A59;
  --accent-ink: #2A1206;

  --status-pending: #2E9BD6;
  --status-authorized: #F2A93B;
  --status-settled: #1FAE7A;
  --status-failed: #E85D4E;
  --critical: #E85D4E;

  --hero-sky-top: #BFEAF5;
  --hero-sky-bottom: #FDECC8;
  --hero-sun: #FFC94D;
  --hero-sand: #F4DFAF;
  --hero-palm-trunk: #7A5A3A;
  --hero-palm-leaf: #2B6B4F;
  --hero-ocean-top: #3FB6C9;
  --hero-ocean-bottom: #146E8C;
  --hero-wave: rgba(255, 255, 255, 0.5);
  --hero-wave-dim: rgba(255, 255, 255, 0.28);
  --hero-pelican-body: #F4F2EC;
  --hero-pelican-wing: #DCD6C6;
  --hero-pelican-pouch: #D98E4B;
  --hero-pelican-eye: #17414F;
  --hero-pelican-leg: #D98E4B;
  --hero-coin: #FFD166;

  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --display: "Baloo 2", var(--sans);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
}

/* ---- hero ---- */
.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--surface-line);
}

.hero-art {
  display: block;
  width: 100%;
  height: clamp(180px, 32vw, 280px);
}

@media (prefers-reduced-motion: no-preference) {
  .wave { animation: wave-scroll linear infinite; }
  .wave-1 { animation-duration: 9s; }
  .wave-2 { animation-duration: 14s; animation-direction: reverse; }
  .wave-3 { animation-duration: 20s; }
  .wave path { fill: var(--hero-wave); }
  .wave-2 path { fill: var(--hero-wave-dim); }
  .wave-3 path { fill: var(--hero-ocean-bottom); opacity: 0.6; }

  .hero-pelican { animation: pelican-bob 3.6s ease-in-out infinite; transform-origin: center; }
  .hero-wing { animation: wing-flap 1.1s ease-in-out infinite; transform-origin: 520px 140px; }
  .hero-coin { animation: coin-catch 3.6s ease-in-out infinite; transform-origin: 604px 150px; }
}
@keyframes wave-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-960px); }
}
@keyframes pelican-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes wing-flap {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-12deg); }
}
@keyframes coin-catch {
  0%, 15% { opacity: 1; transform: translate(0, 0) scale(1); }
  45% { opacity: 0.3; transform: translate(-14px, 8px) scale(0.6); }
  46%, 100% { opacity: 0; }
}
.hero-coin-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  fill: var(--accent-ink);
}

.hero-copy {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 clamp(1.25rem, 5vw, 3rem);
  max-width: 640px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface) 24%, transparent 78%);
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 0.5rem;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(2.1rem, 4.4vw, 3rem);
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.subtitle {
  color: var(--ink-muted);
  margin: 0.6rem 0 0;
  max-width: 44ch;
  font-size: 0.98rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2rem) 3rem;
}

section { margin-top: 2rem; }

/* ---- stat tiles ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--surface-line);
  border: 1px solid var(--surface-line);
  border-radius: 14px;
  overflow: hidden;
}

.stat {
  background: var(--surface-raised);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-value.has-errors {
  color: var(--critical);
}

.stat-label {
  color: var(--ink-muted);
  font-size: 0.78rem;
}

/* ---- charts ---- */
.charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}
@media (max-width: 780px) {
  .charts { grid-template-columns: 1fr; }
}

.chart-card {
  background: var(--surface-raised);
  border: 1px solid var(--surface-line);
  border-radius: 14px;
  padding: 1.1rem 1.25rem 0.8rem;
  box-shadow: 0 2px 10px rgba(23, 65, 79, 0.05);
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.chart-head h2 {
  font-size: 0.98rem;
  margin: 0;
  font-weight: 600;
  font-family: var(--display);
}

.chart-legend-hint {
  font-size: 0.74rem;
  color: var(--ink-faint);
  font-family: var(--mono);
}

.chart {
  width: 100%;
  height: 200px;
  overflow: visible;
}

.chart .grid-line {
  stroke: var(--surface-line);
  stroke-width: 1;
}

.chart .axis-label {
  fill: var(--ink-faint);
  font-family: var(--mono);
  font-size: 9px;
}

.chart .area-fill { fill: var(--accent); opacity: 0.18; }
.chart .area-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart .area-point {
  fill: var(--surface-raised);
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0;
}
.chart .hover-target:hover ~ .area-point,
.chart .area-point.active { opacity: 1; }

.chart .bar {
  rx: 3;
}
.chart .bar-label, .chart .bar-value {
  font-family: var(--mono);
  font-size: 10.5px;
  fill: var(--ink-muted);
}
.chart .bar-value { fill: var(--ink); font-weight: 600; }

.chart .hover-target { cursor: default; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--surface);
  font-family: var(--sans);
  font-size: 0.76rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(23, 65, 79, 0.25);
  opacity: 0;
  transition: opacity 0.1s ease;
  z-index: 5;
  transform: translate(-50%, -100%);
}
.chart-card { position: relative; }

.legend-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}
.legend-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
  margin-right: 0.35rem;
  vertical-align: middle;
}

/* ---- live stream ---- */
.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-authorized);
  margin-right: 0.4rem;
  vertical-align: middle;
}
@media (prefers-reduced-motion: no-preference) {
  .live-dot { animation: live-pulse 1.4s ease-in-out infinite; }
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in oklab, var(--status-authorized) 55%, transparent); }
  50% { opacity: 0.55; box-shadow: 0 0 0 5px transparent; }
}

.live-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--status-authorized);
  margin-left: 0.6rem;
  vertical-align: middle;
}

.chart-head h2 {
  display: flex;
  align-items: center;
}

.live-feed-card { padding-bottom: 1rem; }

.live-feed {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--surface-line);
  border-radius: 10px;
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
}

.live-feed-item {
  background: var(--surface-raised);
  padding: 0.5rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

@media (prefers-reduced-motion: no-preference) {
  .live-feed-item.enter {
    animation: feed-in 0.35s ease-out;
  }
}
@keyframes feed-in {
  from { background: color-mix(in oklab, var(--status-authorized) 20%, var(--surface-raised)); transform: translateX(-4px); opacity: 0; }
  to { background: var(--surface-raised); transform: translateX(0); opacity: 1; }
}

.live-feed-item .amount {
  margin-left: auto;
  color: var(--ink-muted);
}

/* ---- controls ---- */
.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

label {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

button, select {
  background: var(--surface-raised);
  color: var(--ink);
  border: 1px solid var(--surface-line);
  border-radius: 999px;
  padding: 0.55rem 1.05rem;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: var(--sans);
}

button:hover { border-color: var(--ink-faint); }
button:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.ghost {
  background: transparent;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 700;
}
button.primary:hover { filter: brightness(1.06); }

#timing {
  color: var(--ink-muted);
  font-size: 0.85rem;
  font-family: var(--mono);
}

/* ---- table ---- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-raised);
  border: 1px solid var(--surface-line);
  border-radius: 14px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--surface-line);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

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

th {
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--mono);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  text-transform: capitalize;
}
.status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--pill-color);
}

.types-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0 0;
}
.type-pill {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--surface-line);
  color: var(--ink-muted);
  background: var(--surface-raised);
}

@media (max-width: 620px) {
  table { font-size: 0.8rem; }
  th, td { padding: 0.45rem 0.6rem; }
}
