:root {
  --ink: #12202f;
  --muted: #5f6e7d;
  --panel: #fffdf8;
  --line: #d6d0c5;
  --water: #2d8fd5;
  --water-deep: #0f6094;
  --pressure: #f0b429;
  --pressure-deep: #b7791f;
  --alert: #d64b45;
  --alert-deep: #9f2f2b;
  --unknown: #b8c0c7;
  --selected: #f0b429;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  overflow: hidden;
  height: 100vh;
  margin: 0;
  background: #d8e0e7;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.leaflet-tile-pane {
  opacity: 0.3;
  filter: grayscale(0.35) saturate(0.7) contrast(0.9);
  --tile-map-origin-x: 50vw;
  --tile-map-origin-y: 50vh;
  --tile-map-scale: 1;
}

.leaflet-tile-pane .leaflet-layer {
  transform: rotate(-58deg) scale(var(--tile-map-scale));
  transform-origin: var(--tile-map-origin-x) var(--tile-map-origin-y);
}

.map-title {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: min(92vw, 520px);
  padding: 14px 16px;
  border: 1px solid rgba(18, 32, 47, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 18px 40px rgba(18, 32, 47, 0.16);
  backdrop-filter: blur(10px);
}

.map-title p,
.map-title h1,
.report-sheet p,
.report-sheet h2 {
  margin-top: 0;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1;
}

.map-title p,
.eyebrow {
  margin: 0 0 4px;
  color: #a14634;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.map-title button,
.actions button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.map-title button {
  min-height: 38px;
  padding: 8px 12px;
  background: #152638;
  color: #fff;
}

.legend {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: min(92vw, 390px);
  padding: 11px 13px;
  border: 1px solid rgba(18, 32, 47, 0.14);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 18px 40px rgba(18, 32, 47, 0.14);
  color: var(--muted);
  font-size: 0.88rem;
  backdrop-filter: blur(10px);
}

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

.visitor-counter {
  position: fixed;
  right: 18px;
  top: 74px;
  z-index: 500;
  display: flex;
  align-items: baseline;
  gap: 8px;
  max-width: min(92vw, 260px);
  padding: 9px 12px;
  border: 1px solid rgba(18, 32, 47, 0.14);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 18px 40px rgba(18, 32, 47, 0.12);
  color: var(--muted);
  font-size: 0.82rem;
  backdrop-filter: blur(10px);
}

.visitor-counter span {
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 900;
}

.visitor-counter small {
  font-size: inherit;
  white-space: nowrap;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(18, 32, 47, 0.16);
}

.swatch.water {
  background: var(--water);
}

.swatch.low-pressure {
  background: var(--pressure);
}

.swatch.no-water {
  background: var(--alert);
}

.swatch.unknown {
  background: var(--unknown);
}

.report-sheet {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 500;
  width: min(420px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid rgba(18, 32, 47, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 22px 50px rgba(18, 32, 47, 0.22);
  backdrop-filter: blur(10px);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: #c9c1b5;
}

.report-sheet h2 {
  margin-bottom: 8px;
  font-size: 1.25rem;
}

.report-sheet p {
  margin-bottom: 0;
  color: var(--muted);
}

.report-sheet.collapsed {
  width: min(300px, calc(100vw - 24px));
  padding: 11px 13px;
}

.report-sheet.collapsed .sheet-handle,
.report-sheet.collapsed .eyebrow,
.report-sheet.collapsed #selectedStatus,
.report-sheet.collapsed .history-panel,
.report-sheet.collapsed .actions,
.report-sheet.collapsed #formMessage {
  display: none;
}

.report-sheet.collapsed h2 {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.2;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.actions button {
  min-height: 46px;
  color: white;
  padding: 10px;
}

.actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.water-action {
  background: var(--water-deep);
}

.pressure-action {
  background: var(--pressure-deep);
}

.alert-action {
  background: var(--alert-deep);
}

.history-panel {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(18, 32, 47, 0.13);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
}

.history-header strong {
  color: var(--alert-deep);
  white-space: nowrap;
}

.history-chart {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.history-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.history-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: rgba(18, 32, 47, 0.11);
}

.history-bar {
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: var(--alert);
}

.history-empty {
  color: var(--muted);
  font-size: 0.84rem;
}

#formMessage {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.leaflet-interactive {
  transition: fill-opacity 140ms ease, stroke-width 140ms ease;
}

.zone-label-marker {
  border: 0;
  background: transparent;
}

.zone-label-text {
  display: inline-block;
  transform: translate(-50%, -50%);
  transform-origin: center;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #152638;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.05;
  padding: 0;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.96);
}

.zone-label-marker.hidden {
  display: none;
}

@media (max-width: 760px) {
  .map-title {
    right: 12px;
    left: 12px;
    top: 12px;
    justify-content: space-between;
  }

  .legend {
    top: auto;
    right: 12px;
    bottom: 214px;
    left: 12px;
    justify-content: center;
  }

  .visitor-counter {
    top: 111px;
    right: 12px;
    left: 12px;
    justify-content: center;
    max-width: none;
  }

  .report-sheet {
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
  }

  .report-sheet.collapsed {
    width: auto;
    padding: 10px 12px;
  }

  .actions {
    gap: 8px;
  }

  .actions button {
    min-height: 44px;
    padding: 8px 6px;
    font-size: 0.86rem;
  }
}
