:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #17212f;
  --muted: #667085;
  --line: #d9e0ea;
  --teal: #168a84;
  --blue: #2864b0;
  --amber: #c9851d;
  --rose: #c0445d;
  --shadow: 0 18px 48px rgba(23, 33, 47, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Noto Sans KR", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 410px) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 500;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid rgba(22, 138, 132, 0.28);
  border-radius: 999px;
  color: var(--teal);
  background: rgba(22, 138, 132, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.wide {
  grid-column: 1 / -1;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 138, 132, 0.14);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.toggle input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--teal);
}

.date-row {
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
}

.primary,
.actions button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary {
  color: #fff;
  background: var(--teal);
}

.primary:hover {
  background: #12736f;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.stats div {
  min-width: 0;
  padding: 14px 12px;
  background: #fbfcff;
}

.stats strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 20px;
  line-height: 1.1;
}

.stats span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 86px;
  gap: 10px;
  padding: 14px 22px 8px;
}

.actions button {
  color: var(--ink);
  background: #eef3f9;
  border-color: #d5dfeb;
}

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

.actions button:disabled,
.primary:disabled {
  cursor: wait;
  opacity: 0.62;
}

.status-line {
  margin: 0;
  padding: 0 22px 12px;
  color: var(--muted);
  font-size: 13px;
}

.project-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0 22px 22px;
  overflow: auto;
  list-style: none;
}

.project-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.project-item:hover,
.project-item:focus {
  border-color: rgba(40, 100, 176, 0.6);
  box-shadow: 0 8px 22px rgba(23, 33, 47, 0.09);
  outline: none;
}

.project-item h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.35;
}

.project-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  color: #233143;
  background: #eef3f9;
  font-size: 11px;
  font-weight: 800;
}

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  background: #dfe7ed;
}

/* Leaflet fallback styles. These keep the map usable even if CDN CSS is blocked. */
.leaflet-container {
  position: relative;
  overflow: hidden;
  background: #dfe7ed;
  outline: 0;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-pane {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

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

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-tile {
  max-width: none;
  max-height: none;
  user-select: none;
  visibility: hidden;
}

.leaflet-tile-loaded {
  visibility: inherit;
}

.leaflet-zoom-animated {
  transform-origin: 0 0;
}

.leaflet-zoom-anim .leaflet-zoom-animated {
  transition: transform 0.25s cubic-bezier(0, 0, 0.25, 1);
}

.leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile {
  transition: none;
}

.leaflet-zoom-anim .leaflet-zoom-hide {
  visibility: hidden;
}

.leaflet-interactive {
  cursor: pointer;
}

.leaflet-grab {
  cursor: grab;
}

.leaflet-dragging .leaflet-grab {
  cursor: grabbing;
}

.leaflet-container img.leaflet-tile {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-marker-icon,
.leaflet-marker-shadow {
  display: block;
}

.leaflet-control-container .leaflet-top,
.leaflet-control-container .leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
  float: left;
  clear: both;
}

.leaflet-right .leaflet-control {
  float: right;
  margin-right: 10px;
}

.leaflet-top .leaflet-control {
  margin-top: 10px;
}

.leaflet-bar a {
  display: block;
  width: 30px;
  height: 30px;
  border-bottom: 1px solid #cbd5e1;
  background: #fff;
  color: #17212f;
  text-align: center;
  text-decoration: none;
  line-height: 30px;
}

.leaflet-bar a:first-child {
  border-radius: 4px 4px 0 0;
}

.leaflet-bar a:last-child {
  border-bottom: 0;
  border-radius: 0 0 4px 4px;
}

.leaflet-popup {
  position: absolute;
  margin-bottom: 20px;
  text-align: center;
}

.leaflet-popup-content-wrapper {
  padding: 1px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 33, 47, 0.22);
  text-align: left;
}

.leaflet-popup-content {
  margin: 14px;
  min-width: 180px;
  line-height: 1.35;
}

.leaflet-popup-tip-container {
  overflow: hidden;
  width: 40px;
  height: 20px;
  margin: 0 auto;
}

.leaflet-popup-tip {
  width: 17px;
  height: 17px;
  margin: -10px auto 0;
  transform: rotate(45deg);
  background: #fff;
}

.legend {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: calc(100% - 36px);
  padding: 10px 12px;
  border: 1px solid rgba(23, 33, 47, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 30px rgba(23, 33, 47, 0.12);
  z-index: 450;
  font-size: 12px;
  font-weight: 800;
}

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

.legend-dot,
.project-dot {
  display: inline-block;
  border-radius: 999px;
}

.project-marker {
  display: flex;
  align-items: center;
  justify-content: center;
}

.legend-dot {
  width: 10px;
  height: 10px;
}

.legend-dot.active {
  background: var(--teal);
}

.legend-dot.planned {
  background: var(--amber);
}

.legend-dot.closed {
  background: var(--rose);
}

.project-dot {
  width: var(--size);
  height: var(--size);
  border: 2px solid #fff;
  background: var(--color);
  box-shadow: 0 5px 16px rgba(23, 33, 47, 0.24);
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(40, 100, 176, 0.22);
  border-radius: 20px;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  width: 30px;
  height: 30px;
  margin-left: 5px;
  margin-top: 5px;
  border-radius: 15px;
  color: #fff;
  background-color: var(--blue);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.marker-cluster span {
  line-height: 30px;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  color: var(--ink);
}

.popup h3 {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.3;
}

.popup p {
  margin: 4px 0;
  color: var(--muted);
}

.popup a {
  color: var(--blue);
  font-weight: 800;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 48vh) minmax(0, 1fr);
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    grid-row: 2;
    border-right: 0;
    box-shadow: none;
  }

  .map-panel {
    grid-row: 1;
  }

  #map {
    height: 48vh;
    min-height: 360px;
  }

  .legend {
    right: 12px;
    bottom: 12px;
    left: 12px;
    justify-content: center;
    max-width: none;
    gap: 8px;
  }

  .legend span {
    font-size: 11px;
  }
}

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

  .wide,
  .date-row {
    grid-column: auto;
  }

  .date-row {
    grid-template-columns: 1fr;
  }

  .stats strong {
    font-size: 17px;
  }
}
