:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1e2430;
  --muted: #6b7280;
  --accent: #e4572e;
  --line: #e3e6ea;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

header {
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 500;
}

header h1 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.search-wrap {
  position: relative;
  flex: 1 1 240px;
  min-width: 180px;
  display: flex;
}

#address {
  width: 100%;
  padding: 9px 32px 9px 11px; /* right room for the clear button */
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.clear-x {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: none;             /* shown only when the field has text */
  background: transparent;
  color: #9aa0a8;
  font-size: 20px;
  line-height: 1;
  padding: 2px 7px;
  border-radius: 6px;
}
.clear-x.show { display: block; }
.clear-x:hover { color: var(--ink); background: #eef0f2; }

button {
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
button.secondary { background: #2e86ab; }
button:active { transform: translateY(1px); }

#status {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  min-height: 15px;
}

.body {
  flex: 1;
  position: relative;
  display: flex;
  min-height: 0;
}

#map {
  flex: 1;
  height: 100%;
}

.sidebar {
  width: 300px;
  max-width: 42vw;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 14px;
  overflow-y: auto;
}

.sidebar h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 8px;
}

#result.hidden { display: none; }

.r-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  word-break: break-word;
}

.r-badge {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 10px;
}
.r-badge.in { background: #e5f6ec; color: #12683b; }
.r-badge.out { background: #fdecea; color: #b0281a; }

.call-link {
  color: #12683b;
  font-weight: 600;
  text-decoration: none;
}
.call-link:hover { text-decoration: underline; }

.call-btn {
  display: block;
  margin-top: 10px;
  padding: 11px 14px;
  background: #1a9c5b;
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
}
.call-btn:active { background: #157a47; }

.r-note {
  font-size: 12px;
  color: #6b4a86;
  background: #f3ecf9;
  border-radius: 8px;
  padding: 8px 10px;
  margin: -4px 0 10px;
}

.r-metric {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.r-metric span { color: var(--muted); }

#legend {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 3px 0;
}
.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  opacity: 0.7;
}
.swatch.pin {
  background: #3388ff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  opacity: 1;
}

@media (max-width: 680px) {
  .body { flex-direction: column; }
  .sidebar {
    width: 100%;
    max-width: none;
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 44%;
  }
}
