:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #697586;
  --line: #dde5ec;
  --green: #18a058;
  --green-dark: #0b7f43;
  --blue: #1f6feb;
  --red: #e5484d;
  --yellow: #f5b642;
  --shadow: 0 18px 48px rgba(27, 39, 51, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  min-height: 100vh;
  overflow: hidden;
  transition: grid-template-columns 220ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  z-index: 5;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 12px 0 32px rgba(33, 46, 59, 0.08);
  transition: opacity 180ms ease, transform 220ms ease, visibility 220ms;
}

.sidebar-collapsed .sidebar {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-100%);
}

.brand-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 24px 16px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 800;
}

.brand-bar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand-bar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.search-panel,
.filter-grid,
.market-strip {
  margin: 0 20px 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
}

.quick-tabs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 10px;
}

.quick-tabs button,
.layer-buttons button,
.list-heading button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-weight: 700;
}

.quick-tabs button {
  height: 38px;
}

.quick-tabs button.active,
.layer-buttons button.active {
  border-color: var(--green);
  background: #eaf8f0;
  color: var(--green-dark);
}

.quick-tabs button:disabled {
  cursor: default;
  opacity: 1;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

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

.filter-grid select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 700;
}

.filter-reset {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.filter-reset:hover {
  border-color: var(--green);
  background: #eaf8f0;
  color: var(--green-dark);
}

.filter-reset:focus-visible {
  outline: 3px solid rgba(24, 160, 88, 0.2);
  outline-offset: 2px;
}

.filter-reset span {
  font-size: 17px;
  line-height: 1;
}

.market-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.market-strip div {
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.market-strip strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-strip span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.list-wrap {
  min-height: 0;
  padding: 0 20px 20px;
  overflow: hidden;
}

.list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.list-heading h2 {
  margin: 0;
  font-size: 16px;
}

.eyebrow {
  display: block;
  margin-bottom: 2px;
  color: var(--green-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
}

.demo-notice {
  position: absolute;
  top: 70px;
  left: 50%;
  z-index: 650;
  padding: 8px 13px;
  border: 1px solid rgba(151, 165, 178, .4);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  color: #536273;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(23, 33, 43, .08);
  transform: translateX(-50%);
}

.list-heading button {
  height: 34px;
  padding: 0 12px;
}

.apartment-list {
  display: grid;
  max-height: calc(100vh - 334px);
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.apt-card {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: left;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.apt-card:hover,
.apt-card.active {
  border-color: var(--green);
  box-shadow: 0 10px 24px rgba(25, 160, 88, 0.12);
  transform: translateY(-1px);
}

.apt-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.apt-card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.apt-card .location {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.price {
  flex: 0 0 auto;
  color: var(--green-dark);
  font-size: 18px;
  font-weight: 800;
}

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

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

.average-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.average-row span {
  padding: 9px 10px;
  border-radius: 7px;
  background: #f1f8f4;
}

.average-row small,
.average-row strong {
  display: block;
}

.average-row small {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 10px;
}

.average-row strong {
  color: var(--green-dark);
  font-size: 13px;
}

.tag-row span {
  padding: 4px 7px;
  border-radius: 6px;
  background: #eef3f6;
  color: #405160;
  font-size: 11px;
  font-weight: 700;
}

.map-area {
  position: relative;
  min-width: 0;
  min-height: 100vh;
  overflow: hidden;
  background: #d9e1e7;
}

.panel-toggle {
  display: grid;
  place-items: center;
  border: 1px solid rgba(151, 165, 178, .5);
  background: rgba(255, 255, 255, .96);
  color: #344253;
  box-shadow: 0 8px 22px rgba(23, 33, 43, .16);
  font-weight: 800;
}

.sidebar-toggle {
  position: absolute;
  top: 50%;
  left: 10px;
  z-index: 850;
  width: 34px;
  height: 54px;
  border-radius: 9px;
  font-size: 26px;
  line-height: 1;
  transform: translateY(-50%);
}

.sidebar-toggle:hover,
.detail-toggle:hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.map-toolbar {
  position: absolute;
  top: 18px;
  right: 18px;
  left: 18px;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.map-toolbar nav,
.layer-buttons {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.map-toolbar a,
.layer-buttons button {
  display: grid;
  min-width: 56px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(151, 165, 178, 0.45);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: #344253;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(23, 33, 43, 0.08);
}

.map-canvas {
  position: absolute;
  inset: 0;
  height: 100vh !important;
  min-height: 620px;
  overflow: hidden;
  background: #d9e1e7;
}

.marker {
  min-width: 84px;
  padding: 7px 10px 8px;
  border: 2px solid white;
  border-radius: 8px;
  background: var(--green);
  color: white;
  box-shadow: var(--shadow);
  text-align: center;
}

.marker strong {
  display: block;
  font-size: 15px;
  line-height: 1.1;
}

.marker span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  opacity: 0.92;
}

.marker.hot {
  background: var(--red);
}

.marker.mid {
  background: var(--blue);
}

.marker.active {
  outline: 4px solid rgba(24, 160, 88, 0.24);
  transform: scale(1.08);
}

.price-marker {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.leaflet-price-icon {
  background: transparent;
  border: 0;
}

.complex-label-icon {
  border: 0;
  background: transparent;
}

.complex-label {
  display: grid;
  width: 150px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border: 1px solid rgba(11, 127, 67, .35);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 5px 14px rgba(23, 33, 43, .14);
  color: var(--ink);
  cursor: pointer;
  font-family: "Noto Sans KR", sans-serif;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.complex-label:hover,
.complex-label.active {
  z-index: 2;
  border-color: var(--green);
  box-shadow: 0 8px 20px rgba(24, 160, 88, .22);
  transform: translateY(-2px);
}

.complex-label strong {
  overflow: hidden;
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.complex-label span {
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.complex-label.neighborhood {
  width: 150px;
  border-color: var(--green);
  background: rgba(234, 248, 240, .96);
}

.complex-label.neighborhood strong {
  font-size: 12px;
}

.price-marker .marker {
  position: relative;
  transform-origin: center bottom;
}

.price-marker .marker::after {
  position: absolute;
  bottom: -8px;
  left: 50%;
  width: 12px;
  height: 12px;
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  background: inherit;
  content: "";
  transform: translateX(-50%) rotate(45deg);
}

.map-key-state {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: min(420px, calc(100% - 40px));
  gap: 8px;
  padding: 22px;
  border: 1px solid rgba(151, 165, 178, 0.38);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  text-align: center;
  transform: translate(-50%, -50%);
}

.map-key-state strong {
  font-size: 18px;
}

.map-key-state span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.map-popup {
  display: grid;
  width: 230px;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(151, 165, 178, .45);
  border-radius: 10px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 14px 34px rgba(23, 33, 43, .2);
  font-family: "Noto Sans KR", sans-serif;
  pointer-events: none;
}

.map-popup * {
  pointer-events: none;
}

.map-popup > strong,
.map-popup > span,
.map-popup > em {
  grid-column: 1 / -1;
}

.map-popup > strong {
  font-size: 15px;
}

.map-popup > span,
.map-popup > em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
}

.map-popup div {
  padding: 8px;
  border-radius: 7px;
  background: #f1f8f4;
}

.map-popup b,
.map-popup small {
  display: block;
}

.map-popup b {
  color: var(--green-dark);
  font-size: 13px;
}

.map-popup small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  background: #d9e1e7;
  font-family: "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.fallback-map {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

.leaflet-control-zoom {
  overflow: hidden;
  border: 1px solid rgba(151, 165, 178, 0.4) !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 22px rgba(23, 33, 43, 0.12) !important;
}

.leaflet-control-zoom a {
  color: #17212b !important;
  font-weight: 800;
}

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

.detail-dock {
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 4;
  width: min(380px, calc(100% - 44px));
}

.detail-panel {
  position: relative;
  width: 100%;
  border: 1px solid rgba(151, 165, 178, 0.38);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.detail-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 18px;
}

.detail-dock.collapsed {
  width: auto;
}

.detail-dock.collapsed .detail-panel {
  display: none;
}

.detail-dock.collapsed .detail-toggle {
  position: relative;
  top: auto;
  right: auto;
  width: auto;
  min-width: 76px;
  height: 38px;
  padding: 0 12px;
  font-size: 12px;
}

.detail-inner {
  padding: 20px;
  padding-right: 52px;
}

.detail-inner h2 {
  margin: 0;
  font-size: 22px;
}

.detail-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 800;
}

.detail-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.detail-inner .address {
  margin: 6px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.detail-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--green-dark);
  font-size: 30px;
  font-weight: 800;
}

.detail-price span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.facts div {
  padding: 11px 8px;
  border-radius: 8px;
  background: #f4f7f9;
}

.facts strong,
.facts span {
  display: block;
}

.facts strong {
  font-size: 14px;
}

.facts span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.trend {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: end;
  height: 72px;
  gap: 7px;
  padding-top: 6px;
}

.trend i {
  display: block;
  min-height: 16px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--green), #9bd9b7);
}

.empty-state {
  padding: 34px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar-collapsed .sidebar {
    display: none;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .apartment-list {
    max-height: 360px;
  }

  .map-area {
    min-height: 620px;
  }

  .map-canvas {
    height: 620px !important;
  }
}

@media (max-width: 640px) {
  .brand-bar {
    padding: 16px;
  }

  .search-panel,
  .filter-grid,
  .market-strip {
    margin-right: 16px;
    margin-left: 16px;
  }

  .filter-grid,
  .market-strip,
  .facts {
    grid-template-columns: 1fr 1fr;
  }

  .list-wrap {
    padding-right: 16px;
    padding-left: 16px;
  }

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

  .map-toolbar nav,
  .layer-buttons {
    max-width: 100%;
    overflow-x: auto;
  }

  .marker {
    min-width: 72px;
    padding: 6px 7px;
  }
}
