:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #66706b;
  --paper: #f4f1e8;
  --panel: #fffdf7;
  --line: #d8d3c6;
  --accent: #176b52;
  --accent-dark: #104d3d;
  --shadow: 0 20px 60px rgb(35 48 42 / 12%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 12% 0%, rgb(218 232 209 / 75%), transparent 29rem),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-header,
main,
footer {
  width: min(1440px, calc(100% - 48px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 48px 0 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.65rem, 6vw, 5.6rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.9;
}

.lede {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.6;
}

.live-mark {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
  margin-bottom: 4px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.live-mark span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #21a47b;
  box-shadow: 0 0 0 5px rgb(33 164 123 / 13%);
}

.live-mark.test {
  color: #8b5a09;
}

.live-mark.test span {
  background: #d18a18;
  box-shadow: 0 0 0 5px rgb(209 138 24 / 15%);
}

.live-mark b {
  font: inherit;
}

.controls {
  display: flex;
  align-items: end;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: rgb(255 253 247 / 82%);
}

.controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

select,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

select {
  min-width: 180px;
  padding: 0 36px 0 12px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 750;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

:focus-visible {
  outline: 3px solid rgb(209 138 24 / 55%);
  outline-offset: 2px;
}

.status {
  align-self: center;
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
}

.status.error {
  color: #a53830;
  font-weight: 700;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  min-height: 610px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0 0 18px 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.map-frame {
  position: relative;
  min-height: 610px;
}

#map {
  position: absolute;
  inset: 0;
  background: #dfe6dc;
}

.leaflet-container {
  font-family: inherit;
}

.leaflet-control-attribution {
  font-size: 10px;
}

.legend {
  position: absolute;
  z-index: 500;
  top: 16px;
  left: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 10px 13px;
  border: 1px solid rgb(23 32 28 / 12%);
  border-radius: 10px;
  background: rgb(255 253 247 / 94%);
  box-shadow: 0 6px 22px rgb(23 32 28 / 12%);
  font-size: 0.72rem;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.excellent { background: #168568; }
.good { background: #2879a8; }
.fair { background: #d18a18; }
.poor { background: #c24c40; }
.no-cell { background: #9ba39e; }

.empty-state {
  position: absolute;
  z-index: 500;
  inset: 50% auto auto 50%;
  width: min(330px, calc(100% - 32px));
  padding: 22px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(255 253 247 / 96%);
  text-align: center;
  box-shadow: var(--shadow);
}

.empty-state span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.summary {
  position: relative;
  z-index: 600;
  padding: 30px 26px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.summary-heading {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.9rem;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.summary dl {
  margin: 0;
}

.summary dl > div {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.summary dt {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary dd {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.1rem;
  line-height: 1;
}

.summary dd.small-value {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
}

.method-note {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.map-popup strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.cell-quality-tooltip {
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(35 44 41 / 18%);
  color: var(--ink);
  font-size: 0.76rem;
  line-height: 1.45;
}

.cell-quality-tooltip strong {
  font-size: 0.8rem;
}

.map-popup-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.cell-quality-meter {
  height: 7px;
  margin: 8px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e0d6;
}

.cell-quality-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #c24c40, #d18a18 42%, #168568);
}

.map-popup dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  margin: 12px 0 2px;
  font-size: 0.78rem;
}

.map-popup dt {
  color: var(--muted);
}

.map-popup dd {
  margin: 0;
  text-align: right;
  font-weight: 650;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 0 32px;
  color: var(--muted);
  font-size: 0.75rem;
}

footer p {
  margin: 0;
}

a {
  color: var(--accent-dark);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent);
}

.policy-header {
  padding-bottom: 42px;
}

.policy-mark span {
  background: #d18a18;
  box-shadow: 0 0 0 5px rgb(209 138 24 / 15%);
}

.policy-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 820px);
  justify-content: center;
  gap: 38px;
  align-items: start;
}

.policy-index {
  position: sticky;
  top: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgb(255 253 247 / 86%);
}

.policy-index nav {
  display: grid;
  gap: 2px;
}

.policy-index nav a {
  padding: 8px 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  text-decoration: none;
}

.policy-index nav a:hover {
  color: var(--accent);
}

.policy-back-link {
  display: block;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 750;
}

.policy-document {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.policy-meta {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 34px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.policy-document section {
  position: relative;
  padding: 42px 50px;
  scroll-margin-top: 20px;
}

.policy-document section + section {
  border-top: 1px solid var(--line);
}

.section-number {
  position: absolute;
  top: 46px;
  left: 20px;
  margin: 0;
  color: #9ba39e;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.66rem;
}

.policy-document h2 {
  margin-bottom: 20px;
  font-size: clamp(1.75rem, 3vw, 2.35rem);
}

.policy-document h3 {
  margin: 28px 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.policy-document p,
.policy-document li {
  color: #4f5a54;
  font-size: 0.96rem;
  line-height: 1.72;
}

.policy-document p {
  margin-bottom: 16px;
}

.policy-document ul {
  padding-left: 1.25rem;
}

.policy-document li + li {
  margin-top: 8px;
}

.policy-callout {
  margin-top: 28px;
  padding: 20px 22px;
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: #edf4ec;
}

.policy-callout strong {
  color: var(--accent-dark);
}

.policy-callout p {
  margin: 5px 0 0;
}

.policy-service-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.policy-service-grid > div {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #faf8f1;
}

.policy-service-grid h3 {
  margin-top: 0;
}

.policy-service-grid p,
.policy-service-grid a {
  font-size: 0.78rem;
  line-height: 1.55;
}

.privacy-contact {
  display: inline-flex;
  padding: 12px 16px;
  border-radius: 9px;
  background: #edf4ec;
  font-weight: 750;
}

.privacy-contact.configuration-warning {
  background: #fff0d5;
  color: #8b5a09;
}

.policy-footer {
  width: min(1090px, calc(100% - 48px));
}

@media (max-width: 900px) {
  .site-header {
    align-items: flex-start;
    padding-top: 34px;
  }

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

  .map-frame {
    min-height: 540px;
  }

  .summary {
    display: none;
  }

  .policy-layout {
    grid-template-columns: 1fr;
  }

  .policy-index {
    position: static;
  }

  .policy-index nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .policy-service-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .site-header,
  main,
  footer {
    width: min(100% - 24px, 1440px);
  }

  .site-header {
    display: block;
  }

  .live-mark {
    margin-top: 22px;
  }

  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .controls label,
  select {
    width: 100%;
    min-width: 0;
  }

  .controls button {
    width: 100%;
  }

  .status {
    margin: 0;
    text-align: right;
  }

  .dashboard,
  .map-frame {
    min-height: 70vh;
  }

  .policy-document section {
    padding: 34px 28px 34px 42px;
  }

  .section-number {
    top: 38px;
    left: 14px;
  }

  .policy-meta {
    display: grid;
    padding-inline: 28px;
  }
}

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

  .status {
    text-align: left;
  }

  .legend {
    gap: 8px;
  }

  .policy-index nav {
    grid-template-columns: 1fr 1fr;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
