* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, sans-serif; color: #1f2937; background: #f8fafc; font-size: 14px; }
[hidden] { display: none !important; }

.app { display: flex; height: 100vh; height: 100dvh; }
.panel { width: 400px; flex: none; overflow-y: auto; background: #fff; border-right: 1px solid #e5e7eb; display: flex; flex-direction: column; }
.map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; }

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; }
.panel-head h1 { margin: 0; font-size: 19px; font-weight: 700; }
.byline { color: rgba(255, 255, 255, 0.8); font-size: 12px; text-decoration: none; }
.byline:hover { color: #fef08a; }

.chip { flex: none; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip-muted { background: rgba(255, 255, 255, 0.2); color: #fff; }
.chip-free { background: #dcfce7; color: #166534; }
.chip-live { background: #fef9c3; color: #854d0e; font-variant-numeric: tabular-nums; }
.chip-out { background: #fee2e2; color: #991b1b; }

.block { padding: 16px 20px; border-bottom: 1px solid #f1f5f9; }
.block h2 { margin: 0 0 10px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.step { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 999px; background: #4f46e5; color: #fff; font-size: 11px; }
.hint { margin: 8px 0; color: #6b7280; line-height: 1.45; }
.small { font-size: 12px; }
.credits { margin-top: 12px; color: #9ca3af; }

.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tabs button, .segmented button { border: 1px solid #e5e7eb; background: #fff; border-radius: 10px; padding: 9px 6px; font: inherit; font-size: 12.5px;
  font-weight: 600; color: #374151; cursor: pointer; }
.tabs button i { display: block; margin-bottom: 4px; font-size: 15px; color: #6366f1; }
.tabs button.active { border-color: #6366f1; background: #eef2ff; color: #3730a3; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: #f1f5f9; padding: 4px; border-radius: 12px; gap: 4px; }
.segmented button { border: 0; background: transparent; }
.segmented button.active { background: #fff; color: #3730a3; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.draw-ops { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.draw-ops button { border: 1px solid #e5e7eb; background: #fff; border-radius: 999px; padding: 7px 6px; font: inherit; font-size: 12.5px;
  font-weight: 600; color: #374151; cursor: pointer; }
.draw-ops button i { margin-right: 4px; color: #6366f1; }
.draw-ops button.active { border-color: #6366f1; background: #eef2ff; color: #3730a3; }
.draw-ops button[data-op="subtract"] i { color: #dc2626; }
.draw-ops button[data-op="subtract"].active { border-color: #dc2626; background: #fef2f2; color: #991b1b; }

.field { display: block; margin-top: 10px; font-size: 12px; font-weight: 600; color: #4b5563; }
.field input { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 10px; font: inherit; font-size: 14px; }
.field input:focus, select:focus { outline: 2px solid #c7d2fe; border-color: #6366f1; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; cursor: pointer; }
.check input { accent-color: #4f46e5; width: 16px; height: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 10px 16px;
  font: inherit; font-weight: 700; cursor: pointer; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; width: 100%; margin-top: 12px; }
.btn-small { padding: 6px 12px; font-size: 12px; background: #eef2ff; color: #3730a3; }

.autocomplete { position: relative; }
.suggestions { position: absolute; z-index: 10; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: #fff;
  border: 1px solid #e5e7eb; border-radius: 10px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12); max-height: 260px; overflow-y: auto; }
.suggestions li { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.suggestions li small { color: #6b7280; font-weight: 400; }
.suggestions li.active, .suggestions li:hover { background: #eef2ff; }

.results-block { flex: 1; }
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.results-head h2 { margin: 0; }
.results-tools { display: flex; gap: 6px; }
select { border: 1px solid #d1d5db; border-radius: 999px; padding: 5px 8px; font: inherit; font-size: 12px; background: #fff; }
.results { list-style: none; margin: 8px 0 0; padding: 0; }
.results li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.results li:hover { background: #f8fafc; }
.results li.selected { background: #eef2ff; border-color: #c7d2fe; }
.results .name { font-weight: 600; }
.results .dist { color: #4f46e5; font-weight: 600; font-variant-numeric: tabular-nums; }
.results .meta { grid-column: 1 / -1; color: #6b7280; font-size: 12px; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 600; background: #f1f5f9; color: #475569; margin-left: 4px; }
.badge-origin { background: #ffedd5; color: #9a3412; }

.rent-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.quote { text-align: right; padding-bottom: 6px; }
.quote span { display: block; color: #6b7280; font-size: 12px; }
.quote strong { font-size: 20px; }

.map-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(17, 24, 39, 0.85); color: #fff;
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; pointer-events: none; white-space: nowrap; }
.locked { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15, 23, 42, 0.18); z-index: 5; pointer-events: none; }
.locked[hidden] { display: none; }
.locked-card { pointer-events: auto; background: #fff; border-radius: 18px; padding: 24px; width: min(340px, 90%); text-align: center; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2); }
.locked-card i { font-size: 28px; color: #7c3aed; }
.locked-card h3 { margin: 10px 0 4px; }
.locked-card p { color: #6b7280; margin: 0; }
.toast { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 12px;
  font-weight: 500; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); z-index: 6; max-width: 90%; }

.maplibregl-popup-content { border-radius: 12px; padding: 12px 14px; font-family: Inter, system-ui, sans-serif; }
.popup-name { font-weight: 700; font-size: 14px; }
.popup-meta { color: #6b7280; margin-top: 2px; }
.popup-reason { margin-top: 6px; font-size: 12px; color: #4338ca; }
.drawing .maplibregl-canvas { cursor: crosshair; }
.panning .maplibregl-canvas { cursor: grab; }
.panning .maplibregl-canvas:active { cursor: grabbing; }
.hand-toggle { display: grid; place-items: center; color: #374151; font-size: 14px; }
.hand-toggle.active { background: #4f46e5 !important; color: #fff; }

@media (max-width: 820px) {
  .app { flex-direction: column-reverse; height: auto; min-height: 100vh; }
  .map-wrap { height: 60vh; flex: none; }
  .panel { width: 100%; border-right: 0; overflow: visible; }
}
