:root {
  color-scheme: light;
  --bg: #eef2ef;
  --text: #16201a;
  --muted: #5e6b63;
  --panel: #ffffff;
  --line: #cdd8d1;
  --accent: #14735b;
  --accent-dark: #0f5b48;
  --accent-soft: #e7f3ef;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(178, 193, 184, 0.7);
  box-shadow: 0 8px 24px rgba(28, 45, 35, 0.08);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px 22px;
  position: relative;
  z-index: 500;
}

.brand {
  border-left: 4px solid var(--accent);
  align-items: center;
  display: flex;
  gap: 12px;
  padding-left: 14px;
}

.brand-logo {
  border-radius: 12px;
  box-shadow: 0 6px 14px rgba(20, 115, 91, 0.16);
  flex: 0 0 auto;
}

.topbar h1 {
  color: #12241b;
  font-size: 24px;
  font-weight: 750;
  line-height: 1.15;
  margin: 0;
}

.topbar p {
  color: var(--muted);
  font-size: 14px;
  margin: 4px 0 0;
}

.status {
  background: var(--accent-soft);
  border: 1px solid rgba(20, 115, 91, 0.18);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 650;
  max-width: 42ch;
  padding: 7px 12px;
  text-align: right;
  white-space: nowrap;
}

.map-wrap {
  height: 100%;
  min-height: 0;
  position: relative;
}

#map {
  height: 100%;
  min-height: calc(100vh - 76px);
  width: 100%;
}

.leaflet-popup-content {
  margin: 14px;
  min-width: 240px;
}

.leaflet-tooltip-pane {
  z-index: 760;
}

.location-button {
  appearance: none;
  background: #fff;
  border: 1px solid rgba(20, 115, 91, 0.24);
  border-radius: 7px;
  box-shadow: 0 8px 22px rgba(28, 45, 35, 0.16);
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  left: 62px;
  padding: 8px 11px;
  position: absolute;
  top: 12px;
  z-index: 710;
}

.location-button:hover {
  background: #f5faf7;
}

.location-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.popup {
  display: grid;
  gap: 10px;
}

.popup h2 {
  font-size: 17px;
  line-height: 1.25;
  margin: 0;
}

.popup img,
.popup-placeholder {
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  display: block;
  object-fit: cover;
  width: 100%;
}

.popup-placeholder {
  align-items: center;
  background: #e3e9e5;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  justify-content: center;
}

.popup dl {
  display: grid;
  gap: 5px 10px;
  grid-template-columns: max-content 1fr;
  margin: 0;
}

.popup dt {
  color: var(--muted);
  font-size: 12px;
}

.popup dd {
  font-size: 13px;
  margin: 0;
}

.popup p {
  color: #28362e;
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
}

.popup-description {
  display: grid;
  gap: 6px;
}

.popup-description.is-collapsed p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.description-toggle {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  justify-self: start;
  padding: 0;
}

.description-toggle:hover {
  text-decoration: underline;
}

.district-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(178, 193, 184, 0.85);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(28, 45, 35, 0.18);
  display: grid;
  gap: 10px;
  max-height: min(560px, calc(100vh - 112px));
  overflow: hidden;
  position: absolute;
  right: 16px;
  top: 16px;
  width: 320px;
  z-index: 720;
}

.district-panel[hidden] {
  display: none;
}

.district-panel-header {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 14px 10px;
}

.district-panel h2 {
  font-size: 17px;
  line-height: 1.25;
  margin: 0;
}

.district-panel-header p {
  color: var(--muted);
  font-size: 13px;
  margin: 3px 0 0;
}

.district-panel-close {
  align-items: center;
  appearance: none;
  background: var(--accent-soft);
  border: 1px solid rgba(20, 115, 91, 0.18);
  border-radius: 999px;
  color: var(--accent-dark);
  cursor: pointer;
  display: inline-flex;
  font-size: 20px;
  height: 30px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 30px;
}

.district-panel-list {
  display: grid;
  gap: 6px;
  max-height: min(470px, calc(100vh - 190px));
  overflow: auto;
  padding: 0 10px 12px;
}

.district-spring {
  appearance: none;
  background: #fff;
  border: 1px solid #dbe5df;
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  text-align: left;
}

.district-spring:hover {
  border-color: rgba(20, 115, 91, 0.35);
  background: #f5faf7;
}

.district-spring span {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.district-spring small {
  color: var(--muted);
  font-size: 12px;
}

.district-panel-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 4px;
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    display: grid;
    gap: 6px;
    min-height: 92px;
    padding: 10px 12px;
  }

  .brand {
    padding-left: 10px;
  }

  .brand-logo {
    height: 42px;
    width: 42px;
  }

  .status {
    justify-self: start;
    text-align: left;
    white-space: normal;
  }

  #map {
    min-height: calc(100vh - 92px);
  }

  .district-panel {
    left: 10px;
    max-height: min(460px, calc(100vh - 116px));
    right: 10px;
    top: 10px;
    width: auto;
  }

  .location-button {
    left: 60px;
    top: 10px;
  }

  .district-panel-list {
    max-height: min(360px, calc(100vh - 202px));
  }
}

.admin-body {
  background: #eef2ef;
  min-height: 100vh;
}

.admin-topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid rgba(178, 193, 184, 0.7);
  display: flex;
  justify-content: space-between;
  min-height: 68px;
  padding: 12px 22px;
}

.admin-brand {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  font-weight: 800;
  gap: 10px;
  text-decoration: none;
}

.admin-brand img {
  border-radius: 10px;
}

.admin-topbar nav {
  align-items: center;
  display: flex;
  gap: 14px;
}

.admin-topbar a,
.admin-topbar button {
  color: var(--accent-dark);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}

.admin-topbar button {
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
}

.admin-page {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 1120px;
  padding: 24px;
}

.admin-page-header {
  align-items: end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.admin-page h1,
.admin-page h2,
.admin-auth h1 {
  margin: 0;
}

.admin-page-header p,
.admin-help,
.admin-auth p {
  color: var(--muted);
  font-size: 14px;
  margin: 4px 0 0;
}

.admin-card {
  background: #fff;
  border: 1px solid rgba(178, 193, 184, 0.75);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(28, 45, 35, 0.08);
  padding: 18px;
}

.admin-auth {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.admin-login {
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-width: 380px;
  width: 100%;
}

.admin-form,
.admin-upload,
.admin-image-list {
  display: grid;
  gap: 14px;
}

.admin-form label,
.admin-login label {
  color: #2c3a31;
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

.admin-form input,
.admin-form textarea,
.admin-form select,
.admin-login input {
  border: 1px solid #cbd8d1;
  border-radius: 7px;
  font: inherit;
  padding: 9px 10px;
}

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

.admin-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-checks label {
  align-items: center;
  display: inline-flex;
  gap: 7px;
}

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

.admin-primary,
.admin-link-button {
  appearance: none;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  justify-content: center;
  padding: 9px 12px;
  text-decoration: none;
}

.admin-error {
  background: #fff1f0;
  border: 1px solid #f0b8b2;
  border-radius: 7px;
  color: #9b2d21;
  font-size: 14px;
  margin: 0;
  padding: 10px 12px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid #e1e9e4;
  font-size: 14px;
  padding: 10px 8px;
  text-align: left;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.admin-table a {
  color: var(--accent-dark);
  font-weight: 800;
}

.admin-images h2 {
  font-size: 18px;
  margin: 0 0 12px;
}

.admin-image-item {
  align-items: center;
  border: 1px solid #dbe5df;
  border-radius: 7px;
  cursor: pointer;
  display: grid;
  gap: 10px;
  grid-template-columns: auto 74px 1fr;
  padding: 9px;
}

.admin-image-item img {
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  object-fit: cover;
  width: 74px;
}

.admin-image-item span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.admin-image-item strong,
.admin-image-item em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-image-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

@media (max-width: 860px) {
  .admin-grid,
  .admin-two {
    grid-template-columns: 1fr;
  }

  .admin-page-header {
    align-items: start;
    display: grid;
  }
}
