:root {
  --bg: #f4f7f4;
  --bg-deep: #e6ede7;
  --ink: #18201c;
  --muted: #59645e;
  --line: #d9e1db;
  --line-soft: #ebf1ec;
  --panel: #ffffff;
  --panel-soft: #eef5f0;
  --green: #176b4d;
  --green-dark: #0f4c39;
  --green-deep: #093224;
  --cyan: #0f6f7a;
  --amber: #a45f00;
  --amber-soft: #fff0d8;
  --red: #9f2f36;
  --red-soft: #ffe5e7;
  --shadow: 0 18px 45px rgba(28, 46, 36, 0.10);
  --shadow-lift: 0 8px 24px rgba(28, 46, 36, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 8%, rgba(15, 76, 57, 0.14), transparent 42%),
    radial-gradient(circle at 82% 92%, rgba(15, 111, 122, 0.13), transparent 50%),
    linear-gradient(180deg, #f6f9f6 0%, #e8efe9 100%);
  background-attachment: fixed;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
select,
textarea,
input {
  font: inherit;
}

button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 80ms ease;
}

button:hover {
  border-color: var(--green);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
.drop-zone:focus-within {
  outline: 3px solid rgba(15, 111, 122, 0.32);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  max-width: 1380px;
  margin: 0 auto;
}

.site-nav {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 14px;
}

.site-nav a {
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--green-dark);
  background: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  transition: background 120ms ease, border-color 120ms ease;
}

.site-nav a:hover {
  border-color: var(--green);
  background: #fff;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  color: var(--ink);
}

.topbar .lede {
  margin: 8px 0 0;
  max-width: 56ch;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

h1 {
  margin: 0;
  font-size: 44px;
  letter-spacing: -0.01em;
  color: var(--green-deep);
}

h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.status-pill {
  min-width: 124px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--green-dark);
  white-space: nowrap;
}

.status-pill[data-state="working"] {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: rgba(164, 95, 0, 0.32);
}

.status-pill[data-state="error"] {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(159, 47, 54, 0.32);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.results-panel {
  border: 1px solid rgba(217, 225, 219, 0.88);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.control-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 10px;
}

.results-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 10px;
  min-height: 320px;
}

.section-title {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sample-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

select {
  min-height: 40px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  min-height: 96px;
  padding: 10px;
  line-height: 1.45;
}

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

.static-hint {
  margin: -2px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(15, 111, 122, 0.08);
  color: var(--cyan);
  font-size: 12px;
  line-height: 1.4;
}

.drop-zone {
  display: grid;
  gap: 8px;
  min-height: 110px;
  padding: 18px;
  border: 1px dashed #9eb3a8;
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.drop-zone:hover {
  border-color: var(--green);
}

.drop-zone.drag-active {
  border-color: var(--green);
  border-style: solid;
  background: #e1efe7;
}

.drop-zone input {
  width: 100%;
}

.drop-zone-title {
  font-weight: 800;
  color: var(--green-dark);
}

#fileName {
  color: var(--muted);
  font-size: 13px;
}

.primary-button {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
  font-weight: 800;
}

.primary-button:hover {
  border-color: var(--green-dark);
  background: var(--green-dark);
}

.primary-button:disabled {
  border-color: var(--green);
  background: var(--green);
}

.ghost-button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--green-dark);
  background: #fff;
  border-color: var(--line);
}

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

.mini-stack {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.mini-stack span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.mini-stack span:last-child {
  border-bottom: none;
}

.mini-stack b {
  color: var(--green-dark);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 56px;
  color: var(--green);
  line-height: 1;
}

.empty-state h2 {
  font-size: 22px;
  color: var(--ink);
}

.empty-state p {
  margin: 0;
  max-width: 46ch;
  line-height: 1.5;
}

.empty-state button {
  margin-top: 8px;
  padding: 0 18px;
}

.report-content {
  display: grid;
  gap: 14px;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.summary-band > div {
  min-height: 88px;
  padding: 16px;
  background: #fff;
}

.metric-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-band strong {
  display: block;
  font-size: 18px;
  line-height: 1.25;
}

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

.panel-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.block-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.block-meta {
  color: var(--muted);
  font-size: 12px;
}

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

.map-container {
  height: 320px;
  border-radius: 0 0 8px 8px;
}

.map-container .leaflet-container {
  background: #e8efe9;
  font: inherit;
}

.signal-list {
  display: grid;
  gap: 8px;
  min-height: 72px;
  margin: 0;
  padding: 14px;
  list-style: none;
}

.signal-list li {
  padding-left: 12px;
  border-left: 3px solid var(--cyan);
  color: var(--ink);
  line-height: 1.4;
}

.warning-list li {
  border-color: var(--amber);
  color: var(--ink);
}

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

.question-card {
  display: grid;
  gap: 10px;
  min-height: 150px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.question-card.answerable {
  background: #f3faf5;
  border-color: rgba(23, 107, 77, 0.25);
}

.question-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 5px 9px;
  border-radius: 999px;
  background: #e9f2ed;
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tag.answerable {
  background: #dff2e8;
  color: #12603f;
}

.tag.partially_answerable {
  background: var(--amber-soft);
  color: var(--amber);
}

.tag.not_answerable {
  background: var(--red-soft);
  color: var(--red);
}

.question-card p,
.assessment-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.blocked-questions {
  margin: 0 14px 14px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfa;
}

.blocked-questions summary {
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.blocked-questions summary::-webkit-details-marker {
  display: none;
}

.blocked-questions summary::before {
  content: "▸ ";
  color: var(--green-dark);
}

.blocked-questions[open] summary::before {
  content: "▾ ";
}

.blocked-questions[open] summary {
  border-bottom: 1px solid var(--line);
}

.blocked-questions .question-list {
  padding: 10px 12px 12px;
}

.assessment-box {
  display: grid;
  gap: 12px;
  padding: 14px;
}

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

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

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

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

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  font-size: 14px;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #eef2ef;
  color: var(--ink);
}

.role-pill[data-role="coordinate"]    { background: #e0f0f3; color: var(--cyan); }
.role-pill[data-role="identifier"]    { background: #ecedef; color: #4b525c; }
.role-pill[data-role="name"]          { background: #eaeaf3; color: #4a3f8a; }
.role-pill[data-role="category"]      { background: #e9f2ed; color: var(--green-dark); }
.role-pill[data-role="administrative_area"] { background: #e6f3ee; color: var(--green); }
.role-pill[data-role="time"]          { background: #f1ebf6; color: #6f3a92; }
.role-pill[data-role="capacity"]      { background: #fdf3e3; color: var(--amber); }
.role-pill[data-role="population"]    { background: #ffe9d9; color: #b14b00; }
.role-pill[data-role="risk_indicator"]{ background: var(--red-soft); color: var(--red); }
.role-pill[data-role="measurement"]   { background: #e6f0fb; color: #245aa8; }
.role-pill[data-role="attribute"]     { background: #eef2ef; color: var(--muted); }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 28px;
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer a {
  color: var(--green-dark);
  text-decoration: none;
  font-weight: 700;
}

.site-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 16px;
  }

  .layout-grid,
  .content-grid,
  .question-list,
  .summary-band {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

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

  .topbar > div:first-child {
    width: 100%;
  }

  h1 {
    font-size: 34px;
  }

  .status-pill {
    align-self: flex-start;
  }

  .map-container {
    height: 240px;
  }
}
