:root {
  --bg: #f4efe6;
  --bg-strong: #efe3d0;
  --surface: rgba(255, 252, 247, 0.88);
  --surface-strong: #fffaf2;
  --ink: #1f2331;
  --muted: #5f6779;
  --line: rgba(31, 35, 49, 0.12);
  --accent: #b54d28;
  --accent-deep: #7b2f1a;
  --accent-soft: rgba(181, 77, 40, 0.14);
  --shadow: 0 24px 60px rgba(49, 34, 20, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(181, 77, 40, 0.24), transparent 28rem),
    radial-gradient(circle at right 10%, rgba(63, 112, 148, 0.18), transparent 26rem),
    linear-gradient(180deg, #f8f2e7 0%, var(--bg) 48%, #ede4d5 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(31, 35, 49, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 35, 49, 0.02) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent);
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 1.5rem;
  align-items: stretch;
}

.hero-copy,
.upload-card,
.panel,
.metric-card,
.empty-state,
.message {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-copy {
  padding: 2.5rem;
}

.hero-copy::after,
.upload-card::after,
.panel::after,
.metric-card::after {
  content: "";
  position: absolute;
  inset: auto auto -2rem -2rem;
  width: 9rem;
  height: 9rem;
  border-radius: 999px;
  background: var(--accent-soft);
  filter: blur(4px);
}

.eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

h1,
h2 {
  margin: 0;
  font-family: "IBM Plex Serif", Georgia, serif;
  line-height: 0.96;
}

h1 {
  max-width: 12ch;
  font-size: clamp(3rem, 8vw, 5.5rem);
}

h2 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
}

.lead {
  max-width: 58ch;
  margin: 1.25rem 0 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--muted);
}

.lead.compact {
  margin-top: 0.5rem;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.upload-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.9rem;
  padding: 1.75rem;
  background:
    linear-gradient(180deg, rgba(255, 250, 242, 0.92), rgba(247, 237, 222, 0.96));
}

.upload-label,
.metric-label,
.panel-meta,
.upload-note,
.panel-note,
.empty-state p,
.message {
  color: var(--muted);
}

input[type="file"] {
  width: 100%;
  padding: 0.95rem 1rem;
  border: 1px dashed rgba(31, 35, 49, 0.22);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.95rem 1.2rem;
  font: inherit;
  font-weight: 700;
  color: #fff7f2;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 14px 30px rgba(123, 47, 26, 0.24);
}

button:hover {
  transform: translateY(-1px);
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.85rem 1.15rem;
  border: 1px solid rgba(31, 35, 49, 0.14);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.82);
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

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

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

.metric-card {
  padding: 1.25rem 1.35rem;
}

.metric-card strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.2rem;
}

.metric-accent strong {
  color: var(--accent-deep);
}

.panel {
  margin-top: 1.5rem;
  padding: 1.5rem;
}

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

.panel-note {
  margin: 0 0 1.25rem;
  max-width: 70ch;
  line-height: 1.6;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.chart-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(255, 251, 246, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 1.25rem;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
}

.viz-note {
  max-width: 30ch;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--muted);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.legend-swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  flex: none;
}

.chart-host {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(248, 241, 230, 0.86));
  min-height: 20rem;
  padding: 0.4rem;
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid-line {
  stroke: rgba(31, 35, 49, 0.1);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 12px;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

.panel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1rem;
  font-size: 0.95rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

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

th,
td {
  padding: 0.95rem 1rem;
  text-align: left;
}

thead th {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

tbody tr + tr td {
  border-top: 1px solid var(--line);
}

tbody tr:hover {
  background: rgba(181, 77, 40, 0.04);
}

.accordion {
  display: grid;
  gap: 1rem;
}

.country-breakdown {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 242, 0.7);
}

.country-breakdown summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.2rem;
  cursor: pointer;
  list-style: none;
}

.country-breakdown summary::-webkit-details-marker {
  display: none;
}

.country-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.country-summary {
  color: var(--muted);
  font-size: 0.95rem;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 0 1rem 1rem;
}

.subpanel {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.56);
}

.subpanel h3 {
  margin: 0 0 0.9rem;
  font-size: 1rem;
}

.inner-cards {
  margin: 0 1rem 1rem;
}

.empty-state,
.message {
  margin-top: 1.5rem;
  padding: 1.5rem;
}

.message-error {
  border-color: rgba(181, 77, 40, 0.3);
  background: rgba(255, 245, 240, 0.92);
}

@media (max-width: 940px) {
  .hero,
  .cards,
  .chart-grid {
    grid-template-columns: 1fr;
  }

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

  .breakdown-grid {
    grid-template-columns: 1fr;
  }

  .chart-head {
    flex-direction: column;
    align-items: start;
  }
}

@media (max-width: 760px) {
  .country-breakdown summary {
    flex-direction: column;
    align-items: start;
  }

  .cards-three,
  .cards-four {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 1rem, 100%);
    padding-top: 1rem;
  }

  .hero-copy,
  .upload-card,
  .panel,
  .metric-card,
  .empty-state,
  .message {
    border-radius: 22px;
  }

  .hero-copy {
    padding: 1.5rem;
  }

  h1 {
    max-width: none;
  }
}
