:root {
  color-scheme: light;
  --ink: #16202a;
  --muted: #627386;
  --line: #d9e2ea;
  --panel: #ffffff;
  --wash: #f5f7fa;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --gastro: #ea580c;
  --handwerker: #a16207;
  --salon: #db2777;
  --workshop: #525252;
  --other: #6b7280;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--wash);
}

.app {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  height: 100vh;
  min-height: 680px;
}

.sidebar {
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
}

header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

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

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 8px;
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
}

.sub {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.stat strong {
  display: block;
  font-size: 20px;
}

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

.filters {
  display: grid;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.primary-filters,
.advanced-filter-grid {
  display: grid;
  gap: 10px;
}

.advanced-filters {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.advanced-filters summary {
  cursor: pointer;
  padding: 10px;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
  list-style-position: inside;
}

.advanced-filter-grid {
  padding: 0 10px 10px;
}

.location-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 8px;
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input, select, button {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: white;
  font: inherit;
}

input[type="range"] {
  padding: 0;
}

output {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

button {
  cursor: pointer;
  border-color: #9fd4ce;
  background: #e9f7f5;
  color: var(--brand-dark);
  font-weight: 750;
}

button:hover { background: #d8f0ed; }

.filter-actions,
.route-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.plan {
  padding-top: 14px;
}

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

.section-title a {
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

#prospect-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.prospect {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.prospect.active {
  border-color: #14b8a6;
  box-shadow: 0 0 0 2px rgba(20,184,166,.12);
}

.prospect strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.tag {
  border-radius: 999px;
  padding: 2px 7px;
  color: white;
  font-weight: 800;
}

.tag.gastro { background: var(--gastro); }
.tag.restaurant { background: var(--gastro); }
.tag.handwerker { background: var(--handwerker); }
.tag.salon { background: var(--salon); }
.tag.beauty { background: var(--salon); }
.tag.cleaning { background: var(--brand); }
.tag.workshop { background: var(--workshop); }
.tag.mobility { background: var(--workshop); }
.tag.professional { background: #2563eb; }
.tag.retail { background: #7c3aed; }
.tag.fitness { background: #16a34a; }
.tag.other { background: var(--other); }

.contact.has-phone {
  color: #166534;
  font-weight: 750;
}

.contact.missing-phone {
  color: #9a3412;
}

.links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 7px;
  font-size: 12px;
}

.links a,
.link-button {
  width: auto;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.link-button:hover {
  background: transparent;
  text-decoration: underline;
}

.note-badge {
  border: 1px solid #bae6fd;
  border-radius: 999px;
  padding: 1px 7px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 800;
}

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

#map {
  position: absolute;
  inset: 0;
}

.map-count {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255,255,255,.96);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .12);
}

.pin {
  width: 18px;
  height: 18px;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(0,0,0,.35);
}

.pin.gastro { background: var(--gastro); }
.pin.restaurant { background: var(--gastro); }
.pin.handwerker { background: var(--handwerker); }
.pin.salon { background: var(--salon); }
.pin.beauty { background: var(--salon); }
.pin.cleaning { background: var(--brand); }
.pin.workshop { background: var(--workshop); }
.pin.mobility { background: var(--workshop); }
.pin.professional { background: #2563eb; }
.pin.retail { background: #7c3aed; }
.pin.fitness { background: #16a34a; }
.pin.other { background: var(--other); }

.popup h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

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

.popup a {
  color: var(--brand-dark);
  font-weight: 750;
}

.popup-note-button {
  width: auto;
  min-height: 30px;
  margin-top: 4px;
  padding: 5px 9px;
  font-size: 12px;
}

.notes-dialog {
  width: min(720px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.notes-dialog::backdrop {
  background: rgba(15, 23, 42, .42);
}

.notes-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: white;
  box-shadow: 0 18px 60px rgba(15, 23, 42, .24);
}

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

.notes-header h2 {
  margin-top: 2px;
  font-size: 20px;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.remarks-field textarea {
  width: 100%;
  min-height: 128px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  font: inherit;
}

.notes-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 130px;
  align-items: center;
  gap: 8px;
}

.save-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(430px, 48vh) 1fr;
    height: auto;
  }
  .sidebar {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .map-shell {
    min-height: 430px;
  }

  .notes-grid {
    grid-template-columns: 1fr;
  }

  .notes-actions {
    grid-template-columns: 1fr;
  }
}
