:root {
  --fg: #1a1a1a;
  --muted: #666;
  --line: #e2e2e2;
  --accent: #c0392b;
  --accent-soft: #fdecea;
  --bg: #fafafa;
  --panel: #fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.45;
  font-size: 14px;
}

header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 18px 24px;
}

header h1 {
  margin: 0 0 4px 0;
  font-size: 20px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 80ch;
  font-size: 13px;
}

main {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 18px;
  padding: 18px 24px;
  align-items: start;
}

@media (max-width: 1000px) {
  main { grid-template-columns: 1fr; }
}

section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}

#results {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

@media (max-width: 1000px) {
  #results { position: static; max-height: none; }
}

h2 {
  margin: 4px 0 10px 0;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.scheme-picker {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.scheme-picker label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 4px;
}

.scheme-picker label:hover { background: var(--bg); }

.scheme-note {
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  padding: 8px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
  min-height: 1.3em;
  white-space: pre-line;
}

.actions {
  display: flex;
  gap: 6px;
  margin: 10px 0;
  flex-wrap: wrap;
}

button {
  font: inherit;
  background: #f4f4f4;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
}

button:hover { background: #e9e9e9; }

.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 8px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  position: sticky;
  top: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.num { text-align: right; }
.small { font-weight: 400; font-size: 10px; text-transform: none; letter-spacing: 0; }

#countries-table tbody tr.dropped td { color: #bbb; }
#countries-table tbody tr.dropped td input[type="number"] { color: #bbb; }

input[type="number"] {
  width: 60px;
  font: inherit;
  padding: 2px 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  text-align: right;
}

input[type="number"]:disabled { background: #f4f4f4; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

@media (max-width: 700px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat {
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 5px;
  border: 1px solid var(--line);
}

.stat.headline {
  background: var(--accent-soft);
  border-color: #f5c2bd;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat.headline .stat-value { color: var(--accent); }

#plot { width: 100%; height: 480px; margin-top: 12px; }

details.reference {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

details.reference ul { margin: 6px 0 0 16px; padding: 0; }
details.reference li { margin: 3px 0; }
