:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #63706a;
  --line: #d9e2dd;
  --surface: #f8faf9;
  --panel: #ffffff;
  --green: #0f8a5f;
  --green-soft: #e8f6ef;
  --blue: #2167d5;
  --blue-soft: #e9f1ff;
  --orange: #c96715;
  --orange-soft: #fff0df;
  --red: #b42318;
  --red-soft: #fee4e2;
  --dark: #24312c;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-height: 100%;
}

body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.panel {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

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

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

h1 {
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  font-size: 16px;
}

.badge,
.quality {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.neutral,
.quality.unknown {
  background: #edf1ef;
  color: #46514c;
}

.status {
  border-radius: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.45;
}

.status.info {
  background: var(--blue-soft);
  border-color: #b9cdf4;
}

.status.good {
  background: var(--green-soft);
  border-color: #a7dec6;
}

.status.warn {
  background: var(--orange-soft);
  border-color: #f0bf84;
}

.status.danger {
  background: var(--red-soft);
  border-color: #f3aaa6;
}

.actions,
.links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions .primary {
  grid-column: 1 / -1;
}

button,
.link-button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.primary {
  background: var(--dark);
  color: #fff;
}

.secondary,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-color: var(--line);
  color: var(--dark);
}

button:disabled,
.link-button.disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.meter-block {
  display: grid;
  gap: 8px;
}

.meter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.meter-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ebe8;
}

.meter-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--green);
  transition: width 180ms linear;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.stat span {
  display: block;
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  line-height: 1;
}

.guidance {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: #f3f6f4;
  border: 1px solid var(--line);
}

.guidance ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

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

.details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.details summary {
  cursor: pointer;
  color: var(--dark);
  font-size: 14px;
  font-weight: 800;
}

pre {
  max-height: 260px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: #111816;
  color: #d9f7e7;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.map-section {
  position: relative;
  min-width: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #e7ebe8;
}

.map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Critical Leaflet layout fallback. If the CDN stylesheet is blocked, tiles still render as a map. */
.leaflet-container {
  overflow: hidden;
  background: #e7ebe8;
  outline-offset: 1px;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile {
  border: 0;
  user-select: none;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-top .leaflet-control {
  margin-top: 10px;
}

.leaflet-left .leaflet-control {
  margin-left: 10px;
}

.leaflet-popup-pane,
.leaflet-marker-pane,
.leaflet-tooltip-pane,
.leaflet-shadow-pane,
.leaflet-overlay-pane,
.leaflet-tile-pane {
  position: absolute;
}

.map-help {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 500;
  max-width: min(360px, calc(100% - 32px));
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  color: var(--dark);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(23, 32, 28, 0.12);
}

.quality.excellent {
  background: var(--green-soft);
  color: #05603a;
}

.quality.good {
  background: var(--blue-soft);
  color: #1849a9;
}

.quality.acceptable {
  background: var(--orange-soft);
  color: #92400e;
}

.quality.poor,
.quality.bad {
  background: var(--red-soft);
  color: var(--red);
}

.leaflet-popup-content {
  margin: 10px 12px;
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .shell {
    display: flex;
    width: 100%;
    height: auto;
    min-height: 100vh;
    flex-direction: column;
    overflow: visible;
  }

  .panel {
    max-height: none;
    height: auto;
    padding: 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  h1 {
    font-size: 24px;
  }

  .map-section {
    height: 68vh;
    min-height: 460px;
  }
}

@media (max-width: 480px) {
  .brand-row {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .actions .primary {
    grid-column: auto;
  }
}
