:root {
  --bg: #f6f7f4;
  --ink: #1d2424;
  --muted: #65706d;
  --line: #d8ded7;
  --panel: #ffffff;
  --blue: #145c7c;
  --green: #34715b;
  --amber: #a76417;
  --red: #9f3434;
  --map-height: calc(100vh - 156px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.kicker {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 22px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 16px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f8faf8;
  font-size: 13px;
  white-space: nowrap;
}

.status.ok {
  color: var(--green);
  border-color: #bdd8ca;
  background: #edf7f1;
}

.status.warn {
  color: var(--amber);
  border-color: #e5ccad;
  background: #fff6e9;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 14px;
  padding: 14px;
}

.map-section,
.panel {
  min-width: 0;
}

.map-section {
  position: relative;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--panel);
}

button {
  min-height: 32px;
  border: 1px solid #b9c8c3;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

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

.toolbar button,
.cad-tools button {
  padding: 5px 10px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.map {
  height: var(--map-height);
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: #dce5dc;
}

.map-legend {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: calc(100% - 36px);
  padding: 8px 10px;
  border: 1px solid rgba(31, 43, 39, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 12px;
  box-shadow: 0 6px 18px rgba(23, 31, 27, 0.12);
}

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

.map-legend i {
  display: inline-block;
  width: 22px;
  height: 0;
  border-top: 3px solid currentColor;
}

.legend-ward {
  color: var(--blue);
}

.legend-parcel {
  color: #4b7658;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.metrics article,
.info-block,
.cad-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metrics article {
  min-height: 82px;
  padding: 12px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
  letter-spacing: 0;
}

.info-block,
.cad-preview {
  padding: 13px;
}

dl {
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid #edf0ed;
}

dl div:first-child {
  border-top: 0;
}

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

dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.cad-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px;
  gap: 8px;
  margin-bottom: 10px;
}

.cad-tools input {
  min-width: 0;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#cadCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 12 / 7;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10221f;
}

.note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.footnote {
  padding: 0 14px 14px;
  color: var(--muted);
  font-size: 12px;
}

.leaflet-popup-content {
  min-width: 190px;
  font-size: 13px;
}

@media (max-width: 1060px) {
  :root {
    --map-height: 560px;
  }

  .topbar,
  .layout {
    display: block;
  }

  .status-strip {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .panel {
    margin-top: 14px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 12px;
  }

  .layout {
    padding: 10px;
  }

  h1 {
    font-size: 19px;
  }

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

  dl div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

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