:root {
  --brand: #ec6b1d;
  --brand-dark: #d4540b;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --gold: #facc15;
  --red: #ef4444;
  --green: #16a34a;
  --slate: #475569;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --surface: #f8fafc;
  --top-h: 50px;
  --filter-h: 40px;
  --nav-h: 60px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; max-width: 100%; overflow-x: hidden;
  font-family: 'Manrope', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--surface); color: var(--ink); font-size: 13.5px; line-height: 1.45;
  word-break: keep-all;
}
button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
svg.icon { width: 20px; height: 20px; display: block; flex: none; }
.skip { position: fixed; top: -60px; left: 12px; background: var(--blue); color: #fff; padding: 10px 14px; z-index: 900; border-radius: 8px; }
.skip:focus { top: 10px; }

/* Top Orange Header (Ddangya Map-First Identity) */
.top-bar {
  position: sticky; top: 0; left: 0; right: 0; height: var(--top-h); z-index: 400;
  background: linear-gradient(90deg, #f2741f, #e45e13);
  color: #fff; display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; box-shadow: 0 2px 8px rgba(0, 0, 0, .14);
}
.top-bar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-pill { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; white-space: nowrap; }
.brand-pill img { width: 28px; height: 28px; border-radius: 7px; background: #fff; padding: 2px; }
.brand-pill strong { font-size: 18px; letter-spacing: -0.6px; }
.brand-sub { font-size: 11px; background: rgba(255, 255, 255, .2); padding: 2px 7px; border-radius: 999px; font-weight: 600; }
.top-links { display: flex; align-items: center; gap: 4px; }
.top-links .nav-item {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px;
  border-radius: 8px; font-size: 12.5px; font-weight: 700; color: rgba(255, 255, 255, .9); white-space: nowrap;
}
.top-links .nav-item:hover { background: rgba(255, 255, 255, .16); }
.top-links .nav-item.active { background: #fff; color: var(--brand-dark); }
.top-links .nav-item .icon { width: 15px; height: 15px; }

.top-bar-right { display: flex; align-items: center; gap: 4px; flex: none; }
.top-icon-btn {
  position: relative; width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
}
.top-icon-btn:hover { background: rgba(255, 255, 255, .18); }
.badge-g {
  position: absolute; top: 2px; right: 1px; background: #dc2626; color: #fff;
  font-size: 9px; font-weight: 900; width: 14px; height: 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; border: 1.5px solid #fff;
}
.badge-dot {
  position: absolute; top: 5px; right: 5px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--gold); border: 1.5px solid #e45e13;
}
.badge-dot[hidden] { display: none; }

/* Full Viewport Map Stage */
#content { min-height: calc(100dvh - var(--top-h)); width: 100%; max-width: 100%; }
.map-shell { display: flex; flex-direction: column; width: 100%; height: calc(100dvh - var(--top-h)); position: relative; overflow: hidden; }
.filter-ribbon {
  height: var(--filter-h); background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-around; gap: 4px;
  padding: 0 8px; overflow-x: auto; scrollbar-width: none; z-index: 320; flex: none;
}
.filter-ribbon::-webkit-scrollbar { display: none; }
.filter-tab {
  position: relative; font-size: 13px; font-weight: 700; color: #334155;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap; flex: none;
}
.filter-tab:hover, .filter-tab.active { background: #fff7ed; color: var(--brand-dark); }
.filter-tab.has-dot::after {
  content: ''; position: absolute; top: 5px; right: 2px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--gold);
}
.filter-popover {
  position: absolute; top: calc(var(--filter-h) + 4px); left: 10px; right: 10px; max-width: 480px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .18); z-index: 380;
}

.map-viewport { position: relative; flex: 1; width: 100%; height: 100%; background: #1e293b; overflow: hidden; }
#leaflet-map { width: 100%; height: 100%; z-index: 1; background: linear-gradient(135deg, #273b2c, #1f3328 55%, #192634); }
.cad-grid-overlay {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background-image: linear-gradient(rgba(250, 204, 21, .28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(250, 204, 21, .28) 1px, transparent 1px);
  background-size: 48px 48px;
}
.map-nl-pill {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 310;
  background: rgba(15, 23, 42, .86); color: #fff; padding: 5px 12px; border-radius: 999px;
  font-size: 11px; max-width: calc(100% - 140px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  backdrop-filter: blur(8px);
}

/* Floating Left Map Controls */
.map-left-dock {
  position: absolute; top: 10px; left: 10px; z-index: 300;
  display: flex; flex-direction: column; gap: 7px;
}
.pill-group {
  display: flex; flex-direction: column; width: 46px; background: rgba(255, 255, 255, .96);
  border-radius: 10px; overflow: hidden; box-shadow: 0 3px 12px rgba(0, 0, 0, .2);
  border: 1px solid rgba(15, 23, 42, .08);
}
.pill-btn {
  min-height: 33px; font-size: 11.5px; font-weight: 700; color: #334155;
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid #eef2f7; padding: 4px 2px; text-align: center;
}
.pill-btn:last-child { border-bottom: 0; }
.pill-btn.active { background: var(--gold); color: #0f172a; font-weight: 800; }
.pill-btn.active-blue { background: var(--blue); color: #fff; }

/* Floating Right Layer Stack */
.map-right-dock {
  position: absolute; top: 10px; right: 10px; z-index: 300;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
  max-height: calc(100% - 80px); overflow-y: auto; scrollbar-width: none;
}
.map-right-dock::-webkit-scrollbar { display: none; }
.layer-btn {
  position: relative; width: 46px; min-height: 36px; border-radius: 10px;
  background: rgba(255, 255, 255, .96); color: #1e293b; font-size: 10.5px; font-weight: 800;
  line-height: 1.15; padding: 4px 3px; text-align: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .22); display: flex; align-items: center; justify-content: center;
}
.layer-btn.gps { min-height: 38px; color: #0f172a; }
.layer-btn.on-blue { background: var(--blue); color: #fff; }
.layer-btn.on-red { background: var(--red); color: #fff; }
.layer-btn.on-green { background: var(--green); color: #fff; }
.layer-btn.on-dark { background: #334155; color: #fff; }
.layer-btn.on-amber { background: #d97706; color: #fff; }
.layer-btn .dot-g {
  position: absolute; top: -4px; right: -4px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--gold); color: #0f172a; font-size: 9px; font-weight: 900;
  display: flex; align-items: center; justify-content: center; border: 1.5px solid #fff;
}

/* Measure HUD */
.measure-hud {
  position: absolute; top: 44px; left: 66px; z-index: 320;
  background: rgba(15, 23, 42, .9); color: #fff; padding: 8px 12px; border-radius: 10px;
  font-size: 11.5px; display: flex; align-items: center; gap: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.measure-hud button { background: rgba(255,255,255,.18); color: #fff; padding: 3px 8px; border-radius: 6px; font-size: 11px; }

/* Bottom Floating Ddangya+Asil Dock */
.map-bottom-bar {
  position: absolute; bottom: 12px; left: 10px; right: 10px; z-index: 310;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; pointer-events: none;
}
.map-bottom-bar > * { pointer-events: auto; }
.bottom-left-cluster { display: flex; align-items: stretch; gap: 6px; }
.count-tile {
  background: var(--blue); color: #fff; border-radius: 10px; padding: 6px 11px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 52px; box-shadow: 0 4px 14px rgba(37, 99, 235, .36);
}
.count-tile small { font-size: 10px; opacity: .9; }
.count-tile strong { font-size: 18px; font-weight: 900; line-height: 1.1; }
.region-actions-card {
  background: rgba(255, 255, 255, .97); border-radius: 10px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}
.region-act-btn {
  display: flex; align-items: center; gap: 6px; padding: 7px 11px; font-size: 12px;
  font-weight: 700; color: #1e293b; border-bottom: 1px solid #eef2f7; white-space: nowrap;
}
.region-act-btn:last-child { border-bottom: 0; }
.region-act-btn:hover { background: #f8fafc; }

/* Preserve .hero contract on bottom-right dock */
.hero.map-hero-dock {
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap;
  background: rgba(255, 255, 255, .97); padding: 5px 8px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .24); min-height: 0;
}
.fav-stepper { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; color: #0f172a; }
.fav-stepper button { width: 24px; height: 24px; border-radius: 50%; background: #f1f5f9; font-weight: 800; }
.hero-add-btn {
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 800;
  padding: 7px 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.hero-add-btn .icon { width: 14px; height: 14px; }

/* Custom Leaflet Price Bubble Markers */
.ddangya-pin {
  background: #ef4444; color: #fff; font-weight: 800; font-size: 11px; padding: 4px 8px;
  border-radius: 8px; border: 2px solid #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .3);
  white-space: nowrap; transform: translate(-50%, -100%); cursor: pointer;
}
.ddangya-pin.trade { background: #2563eb; }
.ddangya-pin.onbid { background: #16a34a; }
.ddangya-pin.listing { background: #0f172a; }
.ddangya-pin::after {
  content: ''; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  border-width: 6px 5px 0; border-style: solid; border-color: #fff transparent transparent;
}

/* Sub-pages / Workspace Containers */
.page-wrap { max-width: 1180px; margin: 0 auto; padding: 18px 16px 86px; width: 100%; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.section-title h1, .section-title h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.section-title p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin-bottom: 14px; min-width: 0; overflow-wrap: anywhere;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; min-height: 38px; border-radius: 9px; font-size: 12.5px; font-weight: 700;
  background: #fff; border: 1px solid #cbd5e1; color: var(--ink); white-space: nowrap;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-secondary { background: #f1f5f9; border-color: #e2e8f0; color: #0f172a; }
.btn-orange { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-ghost { background: #f8fafc; border-color: #e2e8f0; color: #475569; padding: 6px 10px; min-height: 32px; font-size: 12px; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #f1f5f9; }
.tag { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.tag.blue { background: #dbeafe; color: #1e40af; }
.tag.green { background: #dcfce7; color: #166534; }
.tag.orange { background: #fef3c7; color: #92400e; }
.tag.red { background: #fee2e2; color: #991b1b; }
.notice {
  background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; border-radius: 10px;
  padding: 11px 13px; font-size: 12px; line-height: 1.6; margin-bottom: 12px;
}
.notice.warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.field-hint { font-size: 11.5px; color: var(--muted); margin: 4px 0; }
.text-link { display: inline-flex; align-items: center; gap: 4px; color: var(--blue); font-weight: 700; font-size: 13px; }
.text-link .icon { width: 15px; height: 15px; }

/* Search, Cards, Filters */
.searchbox {
  display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 6px 10px; margin-bottom: 12px;
}
.searchbox input { flex: 1; min-width: 0; border: 0; outline: none; font-size: 13.5px; }
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: none; }
.chip {
  padding: 7px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  font-size: 12px; font-weight: 700; color: #475569; white-space: nowrap;
}
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.property-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.property-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.property-card-top { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid #eef2f7; }
.property-kind { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; }
.property-body { padding: 12px; display: block; }
.property-body h3 { margin: 6px 0 4px; font-size: 14.5px; font-weight: 800; }
.property-address { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); margin: 0 0 8px; }
.property-prices { display: flex; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px dashed #e2e8f0; }
.property-prices span { font-size: 11px; color: var(--muted); }
.property-prices strong { display: block; font-size: 14px; color: var(--ink); }
.property-footer { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: #f8fafc; font-size: 11.5px; color: var(--muted); margin-top: auto; }
.heart-btn.active { color: #ef4444; }
.heart-btn.active svg { fill: #ef4444; }

/* Detail 11-Tab Workbench */
.details-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.details-header h1 { margin: 4px 0; font-size: 20px; }
.details-header .icon-btn { font-size: 0; flex: none; }
.details-header .icon-btn svg { width: 17px; height: 17px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-tabs {
  display: flex; overflow-x: auto; gap: 4px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 6px; margin-bottom: 14px; scrollbar-width: none;
}
.detail-tabs button {
  padding: 8px 12px; border-radius: 8px; font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap;
}
.detail-tabs button.active { background: var(--blue); color: #fff; }
.detail-layout { display: grid; grid-template-columns: 1fr 290px; gap: 14px; align-items: start; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.info-item { background: #f8fafc; border-radius: 8px; padding: 10px; }
.info-item span { display: block; font-size: 11px; color: var(--muted); }
.info-item strong { font-size: 13px; overflow-wrap: anywhere; }
.review-step { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid #eef2f7; }
.step-number { width: 24px; height: 24px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-weight: 800; font-size: 11px; display: flex; align-items: center; justify-content: center; flex: none; }
.check-row { display: flex; align-items: flex-start; gap: 8px; padding: 9px 0; border-bottom: 1px solid #eef2f7; font-size: 12.5px; }
.doc-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #eef2f7; }
.doc-copy { flex: 1; min-width: 0; }
.doc-copy small { display: block; font-size: 11px; color: var(--muted); }
.note-item { padding: 10px 0; border-bottom: 1px solid #eef2f7; }
.menu-row { display: flex; align-items: center; gap: 10px; padding: 12px; border-bottom: 1px solid #eef2f7; width: 100%; text-align: left; }
.menu-row:last-child { border-bottom: 0; }
.menu-row span { flex: 1; min-width: 0; }
.menu-row small { display: block; font-size: 11px; color: var(--muted); }
.key-value { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid #eef2f7; font-size: 12.5px; }

/* Forms & Modals */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: #334155; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-weight: 500;
}
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.sim-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.result-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.result-card { background: #f8fafc; border-radius: 10px; padding: 10px; }
.result-card span { display: block; font-size: 11px; color: var(--muted); }
.result-card strong { font-size: 15px; color: var(--blue); }
.table-scroll { overflow-x: auto; max-width: 100%; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th, .data-table td { padding: 8px 10px; border-bottom: 1px solid #e2e8f0; text-align: left; white-space: nowrap; }
.data-table th { background: #f8fafc; color: #475569; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stats article { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stats strong { display: block; font-size: 20px; color: var(--blue); }
.stats span { font-size: 11px; color: var(--muted); }

dialog {
  border: 0; border-radius: 16px; width: min(620px, 94vw); max-height: 88dvh;
  padding: 0; box-shadow: 0 24px 64px rgba(15, 23, 42, .35);
}
dialog::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px); }
.sheet-inner { padding: 18px; }
.sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-header h2 { margin: 0; font-size: 17px; }
.sheet-header .icon-btn { font-size: 0; flex: none; }
.sheet-header .icon-btn svg { width: 18px; height: 18px; }
.sheet-inner pre { background: #f8fafc; padding: 12px; border-radius: 10px; white-space: pre-wrap; max-height: 52vh; overflow-y: auto; font-size: 12px; }
#toast {
  position: fixed; bottom: 76px; left: 50%; transform: translate(-50%, 16px); z-index: 999;
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 12.5px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw;
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* Mobile Bottom Nav (Always visible <= 900px, exact 5 links for Playwright ui.spec.ts) */
.bottom-nav { display: none; }
.compare-bar { position: fixed; bottom: 74px; left: 50%; transform: translateX(-50%); background: var(--blue); color: #fff; padding: 10px 16px; border-radius: 999px; display: flex; align-items: center; gap: 12px; z-index: 350; }
.my-header { display: flex; align-items: center; gap: 12px; }
.my-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: flex; align-items: center; justify-content: center; }

@media (max-width: 900px) {
  .top-links, .brand-sub { display: none; }
  .map-shell { height: calc(100dvh - var(--top-h) - var(--nav-h)); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--nav-h); background: rgba(255, 255, 255, .98); border-top: 1px solid var(--line);
    z-index: 420; padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav .nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; font-size: 10.5px; font-weight: 700; color: var(--muted); min-width: 0;
  }
  .bottom-nav .nav-item.active { color: var(--brand); }
  .bottom-nav .nav-item .icon { width: 19px; height: 19px; }
  .property-grid, .detail-layout, .sim-layout, .form-grid, .result-cards, .info-grid { grid-template-columns: 1fr; }
  .hero.map-hero-dock { padding: 4px 6px; gap: 4px; }
  .hero-add-btn { padding: 6px 9px; font-size: 11px; }
  .region-act-btn { padding: 6px 8px; font-size: 11px; }
  .count-tile { padding: 5px 8px; min-width: 44px; }
  .count-tile strong { font-size: 16px; }
  .field input, .field select, .field textarea { font-size: 15px; }
}
