:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #61716d;
  --surface: rgba(252, 253, 249, 0.94);
  --line: rgba(23, 33, 31, 0.16);
  --accent: #b8412e;
  --accent-strong: #832d21;
  --focus: #126a7c;
  --success: #26734d;
  --warning: #a76318;
  --shadow: 0 20px 50px rgba(27, 35, 32, 0.18);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
#map {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: #e8ece7;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
}

#map {
  z-index: 0;
}

.panel {
  position: absolute;
  z-index: 500;
  top: 16px;
  left: 16px;
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  transition:
    max-height 180ms ease,
    width 180ms ease;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-body {
  display: block;
}

.panel.is-minimized {
  width: min(300px, calc(100vw - 32px));
  overflow: hidden;
}

.panel.is-minimized .panel-header {
  margin-bottom: 0;
}

.panel.is-minimized .panel-body {
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 1.5vw, 1.7rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.fit-icon,
.collapse-icon {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
}

.fit-icon::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(var(--ink), var(--ink)) 0 0 / 7px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 0 / 2px 7px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 100% 0 / 7px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 100% 0 / 2px 7px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 100% / 7px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 100% / 2px 7px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 100% 100% / 7px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 100% 100% / 2px 7px no-repeat;
}

.collapse-icon::before,
.collapse-icon::after {
  position: absolute;
  left: 3px;
  top: 7px;
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: var(--ink);
  content: "";
}

.collapse-icon::after {
  opacity: 0;
  transform: rotate(90deg);
}

.panel.is-minimized .collapse-icon::after {
  opacity: 1;
}

.icon-button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.drop-zone {
  display: grid;
  gap: 5px;
  padding: 18px;
  border: 1.5px dashed rgba(18, 106, 124, 0.52);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--focus);
  background: #fff;
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-title {
  font-weight: 800;
}

.drop-subtitle {
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.message {
  min-height: 22px;
  margin: 13px 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.message.is-error {
  color: var(--accent-strong);
}

.message.is-ok {
  color: var(--success);
}

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

.stats div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.stats dt {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stats dd {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

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

.control-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

input[type="date"] {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 32px 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 17px) 16px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 12px) 16px / 6px 6px no-repeat,
    #fff;
  appearance: none;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

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

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

.actions button:last-child {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

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

.point-marker {
  display: block;
  width: 7px;
  height: 7px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  background: rgba(18, 106, 124, 0.7);
  box-shadow: 0 0 0 2px rgba(18, 106, 124, 0.12);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 680px) {
  body {
    overflow: hidden;
  }

  .panel {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: 52vh;
    padding: 14px;
  }

  .panel.is-minimized {
    width: auto;
    max-height: 76px;
  }

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