:root {
  --bg: #f4eedf;
  --bg-accent: #efe4d1;
  --paper: rgba(255, 252, 246, 0.72);
  --panel: rgba(255, 251, 244, 0.9);
  --stroke: rgba(48, 52, 47, 0.14);
  --text: #1d2d2a;
  --muted: #5d6c67;
  --deep: #163632;
  --teal: #2f6f66;
  --mint: #79b8a2;
  --sand: #d3b27b;
  --brick: #b75d44;
  --rose: #d38b76;
  --shadow: 0 24px 80px rgba(31, 35, 28, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(121, 184, 162, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(183, 93, 68, 0.16), transparent 30%),
    linear-gradient(160deg, var(--bg), var(--bg-accent));
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

h1,
h2,
.summary-value {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

.page-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.9fr);
  gap: 24px;
  align-items: stretch;
}

.hero-copy,
.hero-panel,
.panel,
.summary-card {
  border: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.hero-copy {
  border-radius: var(--radius-xl);
  padding: 36px;
  position: relative;
  overflow: hidden;
}

.hero-copy::after {
  content: "";
  position: absolute;
  inset: auto -60px -90px auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(211, 178, 123, 0.35), rgba(211, 178, 123, 0));
}

.eyebrow,
.panel-eyebrow {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  font-weight: 700;
  color: var(--brick);
}

.hero h1 {
  margin: 0;
  font-size: clamp(40px, 4.2vw, 76px);
  line-height: 0.94;
  max-width: 12ch;
}

.hero-text {
  margin: 22px 0 0;
  max-width: 56ch;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.hero-chips span {
  border-radius: 999px;
  border: 1px solid rgba(47, 111, 102, 0.2);
  background: rgba(47, 111, 102, 0.08);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--deep);
}

.hero-panel {
  border-radius: var(--radius-xl);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 220px;
  border-radius: var(--radius-lg);
  border: 2px dashed rgba(47, 111, 102, 0.32);
  background:
    linear-gradient(180deg, rgba(121, 184, 162, 0.08), rgba(255, 255, 255, 0)),
    rgba(255, 255, 255, 0.62);
  text-align: center;
  padding: 20px;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  transform: translateY(-2px);
  border-color: var(--teal);
  background:
    linear-gradient(180deg, rgba(121, 184, 162, 0.14), rgba(255, 255, 255, 0.08)),
    rgba(255, 255, 255, 0.88);
}

.dropzone input {
  display: none;
}

.dropzone-label {
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 30px;
  line-height: 1.1;
  color: var(--deep);
}

.dropzone-subtitle {
  margin-top: 10px;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-small {
  grid-column: span 1;
}

.control label {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.control input {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(29, 45, 42, 0.12);
  background: rgba(255, 255, 255, 0.88);
  padding: 0 14px;
  font: inherit;
  color: var(--text);
}

.secondary-button {
  min-height: 48px;
  border: none;
  border-radius: 14px;
  background: var(--deep);
  color: #f5f0e7;
  font: inherit;
  font-weight: 700;
  padding: 0 18px;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease;
}

.secondary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.secondary-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.status-panel {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(22, 54, 50, 0.06);
}

.status-line {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.subtle {
  color: var(--muted);
}

.dashboard {
  margin-top: 26px;
  display: grid;
  gap: 22px;
  animation: rise 320ms ease;
}

.hidden {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.compact-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-card {
  border-radius: var(--radius-md);
  padding: 18px;
}

.summary-label,
.summary-note {
  margin: 0;
}

.summary-label {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-value {
  margin: 12px 0 10px;
  font-size: clamp(28px, 2vw, 40px);
  line-height: 0.95;
}

.summary-note {
  color: var(--muted);
  line-height: 1.45;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 22px;
}

.range-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.range-toolbar-copy {
  display: grid;
  gap: 8px;
}

.range-toolbar h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
}

.two-up {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
}

.panel-note {
  margin: 0;
  max-width: 42ch;
  color: var(--muted);
  line-height: 1.5;
}

.chart-wrap,
.chart {
  min-height: 340px;
}

.chart,
.heatmap {
  position: relative;
}

.chart svg {
  width: 100%;
  height: 100%;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.heatmap {
  display: grid;
  grid-template-columns: 72px repeat(24, minmax(18px, 1fr));
  gap: 6px;
  align-items: stretch;
}

.heatmap-cell,
.heatmap-label {
  min-height: 26px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 12px;
}

.heatmap-label {
  color: var(--muted);
  font-weight: 700;
}

.heatmap-cell {
  border: 1px solid rgba(24, 38, 35, 0.06);
  aspect-ratio: 1 / 1;
  min-height: 0;
  cursor: pointer;
}

.heatmap-cell:hover {
  outline: 2px solid rgba(22, 54, 50, 0.24);
  outline-offset: 1px;
}

.chart-hit-area {
  cursor: pointer;
}

.chart-wrap svg {
  cursor: crosshair;
  touch-action: none;
}

.brush-rect {
  fill: rgba(22, 54, 50, 0.12);
  stroke: rgba(22, 54, 50, 0.44);
  stroke-width: 1.5;
}

.chart-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 280px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(22, 54, 50, 0.94);
  color: #fff8ef;
  box-shadow: 0 18px 45px rgba(22, 54, 50, 0.24);
  border: 1px solid rgba(255, 248, 239, 0.14);
  pointer-events: none;
  font-size: 13px;
  line-height: 1.45;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.chart-tooltip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.chart-tooltip-key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chart-tooltip-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 14px 10px;
  border-bottom: 1px solid rgba(29, 45, 42, 0.08);
  text-align: left;
}

th {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

td {
  font-size: 15px;
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.6);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .hero,
  .two-up {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .compact-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100vw - 20px, 100%);
    padding-top: 14px;
  }

  .hero-copy,
  .hero-panel,
  .panel {
    padding: 18px;
  }

  .hero h1 {
    font-size: 44px;
  }

  .controls,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .compact-summary-grid {
    grid-template-columns: 1fr;
  }

  .heatmap {
    overflow-x: auto;
  }

  .heatmap {
    min-width: 760px;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .range-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
