:root {
  --ink: #141b1f;
  --muted: #65727a;
  --paper: #edf1ec;
  --panel: #fbfcf8;
  --field: #f2f5ef;
  --line: #d6ddd5;
  --green: #12624f;
  --green-dark: #0a3f34;
  --blue: #245f83;
  --amber: #9b6c18;
  --danger: #9e332b;
  --shadow: 0 18px 60px rgba(20, 27, 31, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(140deg, rgba(18, 98, 79, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(36, 95, 131, 0.14), transparent 36%),
    var(--paper);
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.workspace {
  min-height: calc(100vh - 56px);
  border: 1px solid rgba(20, 27, 31, 0.08);
  background: rgba(251, 252, 248, 0.76);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 28px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 72px);
  line-height: 0.94;
}

h2 {
  font-size: 18px;
}

.status-pill,
.panel-heading span,
.field-row span,
.search-box span,
.metrics span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-pill {
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(380px, 1.25fr) minmax(260px, 0.75fr);
  gap: 18px;
  padding: 18px;
  align-items: start;
}

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

.summary-panel {
  grid-column: 1 / -1;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.panel-heading span {
  max-width: 62%;
  text-align: right;
  overflow-wrap: anywhere;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 28px;
  border: 2px dashed #bfc9c1;
  background: var(--field);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--green);
  background: #e8f0e8;
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.drop-zone strong {
  margin-top: 8px;
  font-size: 20px;
  overflow-wrap: anywhere;
}

.drop-zone small {
  margin-top: 6px;
  color: var(--muted);
  font-weight: 700;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.field-row,
.search-box {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.field-row input,
.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ghost-button,
.secondary-button,
.primary-button {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 11px 13px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.ghost-button:hover,
.secondary-button:hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.ghost-button.muted {
  color: var(--muted);
}

.primary-button {
  width: 100%;
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  width: 100%;
  margin-top: 10px;
}

.country-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 420px;
  margin-top: 14px;
  overflow: auto;
  padding-right: 4px;
}

.country-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 9px;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  padding: 9px;
  cursor: pointer;
}

.country-row input {
  width: 16px;
  height: 16px;
}

.country-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  text-transform: uppercase;
}

.country-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.country-row:has(input:checked) {
  border-color: var(--green);
  background: #edf6ef;
}

.message {
  min-height: 56px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.message.error {
  color: var(--danger);
}

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

.metrics div {
  border: 1px solid var(--line);
  background: var(--field);
  padding: 14px;
}

.metrics strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.counts,
.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.count-row,
.column-row {
  border: 1px solid var(--line);
  background: #fff;
  padding: 11px;
}

.count-row strong,
.column-row strong {
  display: block;
  margin-bottom: 5px;
}

.count-row span,
.column-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

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

@media (max-width: 640px) {
  .shell {
    padding: 0;
  }

  .workspace {
    min-height: 100vh;
  }

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

  .tool-grid {
    padding: 12px;
  }

  .country-list,
  .metrics {
    grid-template-columns: 1fr;
  }
}
