:root {
  color-scheme: light;
  --ink: #18312b;
  --muted: #61736d;
  --line: #dfe7e2;
  --paper: #ffffff;
  --ground: #f3f6f3;
  --green: #17624e;
  --green-dark: #104c3c;
  --mint: #e7f4ee;
  --amber: #f5bc4d;
  --red: #b91c1c;
  font-family: "Noto Sans Thai", Tahoma, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--ground);
}

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px clamp(16px, 3vw, 38px);
  background: var(--green-dark);
  color: #ffffff;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 26%);
  border-radius: 15px;
  background: #ffffff1c;
  color: #d5f3e5;
  font-size: 17px;
  font-weight: 800;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.topbar .eyebrow {
  color: #c2dcd1;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(18px, 2.3vw, 23px);
  line-height: 1.35;
}

.disclaimer {
  max-width: 350px;
  margin: 0 0 0 auto;
  padding: 8px 12px;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 999px;
  background: rgb(255 255 255 / 8%);
  color: #f8e7bb;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 390px);
  gap: 16px;
  min-height: calc(100vh - 88px);
  padding: 16px;
}

.map-panel,
.details-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 10px 30px rgb(25 60 45 / 5%);
}

.map-panel {
  display: flex;
  min-height: 600px;
  flex-direction: column;
}

.map-toolbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.crumb {
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--green-dark);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.crumb:hover,
.crumb:focus-visible {
  border-color: #c8e0d5;
  background: var(--mint);
  outline: none;
}

.crumb[aria-current="page"] {
  border-color: #cfe2d9;
  background: var(--mint);
  color: #164c3c;
  font-weight: 700;
}

.crumb-separator {
  color: #9eada7;
  font-size: 13px;
}

.synthetic-badge {
  flex: 0 0 auto;
  padding: 5px 10px;
  border: 1px solid #edcb83;
  border-radius: 999px;
  background: #fff6de;
  color: #785414;
  font-size: 12px;
  font-weight: 700;
}

#map {
  position: relative;
  min-height: 400px;
  flex: 1 1 auto;
  background: #eaf0ed;
}

#map .maplibregl-canvas {
  outline: none;
}

.map-message {
  position: absolute;
  z-index: 5;
  top: 14px;
  left: 14px;
  max-width: min(380px, calc(100% - 28px));
  padding: 10px 13px;
  border: 1px solid #eccd8a;
  border-radius: 10px;
  background: #fff9e9;
  color: #62470e;
  box-shadow: 0 4px 16px rgb(31 47 39 / 10%);
  font-size: 13px;
}

.map-footer {
  display: flex;
  min-height: 50px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 16px;
  border-top: 1px solid var(--line);
}

.admin-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  max-height: 110px;
  overflow-y: auto;
  padding: 6px 0;
}

.map-layer-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 18px;
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  background: #f5f9fc;
}

.flood-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  font-size: 12px;
  cursor: pointer;
}

.flood-toggle input {
  accent-color: #087ec4;
  width: 17px;
  height: 17px;
}

.flood-swatch {
  display: inline-block;
  background: #087ec4;
  border-color: #07517f;
}

#flood-layer-status,
.flood-explanation,
.map-color-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.6;
  color: #435851;
}

.map-key {
  min-width: 0;
}

.map-key strong {
  font-size: 12px;
}

.map-color-note {
  margin-top: 4px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #435851;
  font-size: 11px;
  line-height: 1.4;
}

.legend-swatch,
.class-swatch {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border: 1px solid rgb(20 49 41 / 18%);
  border-radius: 3px;
}

.map-issue-link {
  flex: 0 0 auto;
  color: #496a5d;
  font-size: 11px;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.details-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 19px;
}

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

.panel-heading h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.4;
}

.run-selector-wrap {
  display: grid;
  flex: 0 1 145px;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.run-selector-wrap select {
  width: 100%;
  min-height: 37px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

.run-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 22px;
}

.meta-pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1f5f2;
  color: #596b64;
  font-size: 11px;
  line-height: 1.35;
}

.meta-pill.status-success {
  background: #e5f4eb;
  color: #226244;
}

.meta-pill.status-no_coverage,
.meta-pill.status-failed {
  background: #fff1e8;
  color: #9a4b24;
}

.status-message {
  padding: 12px 13px;
  border: 1px solid #edcf8d;
  border-radius: 11px;
  background: #fff7df;
  color: #62470e;
  font-size: 13px;
  line-height: 1.7;
}

.status-message.is-error {
  border-color: #ecc3bf;
  background: #fff1ef;
  color: #7a2822;
}

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

.metric-card {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 13px 14px;
  border: 1px solid #e3ece7;
  border-radius: 13px;
  background: #f8fbf9;
}

.metric-impact {
  border-color: #f0e5c9;
  background: #fffaf0;
}

.metric-label,
.metric-unit {
  color: var(--muted);
  font-size: 11px;
}

.metric-card strong {
  overflow-x: auto;
  color: var(--green-dark);
  font-size: clamp(20px, 1.8vw, 24px);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
}

.metric-impact strong {
  color: #81580c;
}

.data-section {
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.section-heading h3 {
  margin: 0;
  font-size: 14px;
}

.section-heading span {
  color: var(--muted);
  font-size: 10px;
}

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

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

th,
td {
  padding: 8px 7px;
  border-bottom: 1px solid #e8eeea;
  text-align: right;
  vertical-align: middle;
}

th {
  background: #f7f9f7;
  color: #566961;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

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

.total-row td {
  border-top: 2px solid #d7e2dc;
  background: #f5f8f6;
  color: var(--green-dark);
  font-weight: 700;
}

.class-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 112px;
}

.class-name span:last-child {
  line-height: 1.45;
}

.numeric {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ranking-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  background: #f7f9f7;
  color: #455a51;
  font-size: 12px;
}

.ranking-button {
  overflow: hidden;
  padding: 0;
  border: 0;
  background: none;
  color: var(--green-dark);
  cursor: pointer;
  font: inherit;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-button:hover,
.ranking-button:focus-visible {
  color: #0d7a56;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.data-footnote {
  margin: auto 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.maplibregl-popup-content {
  padding: 10px 13px;
  border-radius: 10px;
  color: var(--ink);
  font-family: inherit;
  line-height: 1.65;
}

.popup-title {
  margin-bottom: 4px;
  font-weight: 700;
}

.popup-line {
  color: #53665e;
  font-size: 12px;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) minmax(290px, 340px);
    gap: 12px;
    padding: 12px;
  }

  .details-panel {
    padding: 15px;
  }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 0;
    align-items: flex-start;
    padding: 13px 14px;
  }

  .brand-mark {
    width: 39px;
    height: 39px;
    border-radius: 12px;
    font-size: 15px;
  }

  .topbar .eyebrow {
    font-size: 10px;
  }

  h1 {
    max-width: 250px;
    font-size: 16px;
  }

  .disclaimer {
    max-width: 145px;
    padding: 6px 8px;
    font-size: 10px;
  }

  .workspace {
    display: flex;
    min-height: auto;
    flex-direction: column;
    padding: 10px;
  }

  .map-panel {
    min-height: 510px;
  }

  #map {
    min-height: 390px;
  }

  .details-panel {
    gap: 14px;
  }
}

@media (max-width: 480px) {
  .topbar {
    flex-wrap: wrap;
  }

  .brand-copy {
    flex: 1 1 calc(100% - 56px);
  }

  .disclaimer {
    max-width: none;
    margin: 0 0 0 52px;
  }

  .map-panel {
    min-height: 470px;
    border-radius: 14px;
  }

  #map {
    min-height: 350px;
  }

  .map-toolbar {
    align-items: flex-start;
    padding: 8px 9px;
  }

  .breadcrumbs {
    gap: 1px;
  }

  .crumb {
    min-height: 31px;
    padding: 4px 7px;
    font-size: 11px;
  }

  .synthetic-badge {
    padding: 4px 7px;
    font-size: 10px;
  }

  .map-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    padding: 8px 10px;
  }

  .map-key {
    grid-column: 1;
    grid-row: 1;
    max-width: none;
  }

  .admin-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px 10px;
  }

  .legend-item {
    max-width: none;
    font-size: 10px;
  }

  .map-issue-link {
    grid-column: 2;
    grid-row: 1;
    font-size: 10px;
  }

  .map-layer-controls {
    padding: 7px 10px;
  }

  .panel-heading h2 {
    font-size: 18px;
  }

  .run-selector-wrap {
    flex-basis: 125px;
  }

  .details-panel {
    padding: 14px;
  }
}
