*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --cns-blue: #1a56db;
  --cns-dark: #1e293b;
  --cns-gray: #64748b;
  --cns-light: #f1f5f9;
  --cns-border: #e2e8f0;
  --cns-white: #ffffff;
  --cns-green: #16a34a;
  --cns-yellow: #d97706;
  --cns-red: #dc2626;
  --cns-orange: #ea580c;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cns-dark);
  background: var(--cns-light);
  -webkit-font-smoothing: antialiased;
}

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-container { width: 100%; max-width: 360px; }
.login-card {
  background: var(--cns-white);
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-subtitle { color: var(--cns-gray); margin-bottom: 24px; font-size: 13px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.login-card input[type="password"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--cns-border);
  border-radius: var(--radius); font-size: 15px; margin-bottom: 16px;
}
.login-card input[type="password"]:focus {
  outline: none; border-color: var(--cns-blue); box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}

/* Buttons */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--cns-blue); color: var(--cns-white); border: none;
  border-radius: var(--radius); padding: 10px 20px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--cns-white); color: var(--cns-blue); border: 1px solid var(--cns-border);
  border-radius: var(--radius); padding: 8px 16px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.btn-secondary:hover { border-color: var(--cns-blue); background: #f8fafc; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid var(--cns-border);
  border-radius: var(--radius); background: var(--cns-white); cursor: pointer;
  font-size: 18px; line-height: 1;
}
.btn-icon:hover { background: var(--cns-light); }
.btn-small { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; }

.error-message { color: var(--cns-red); font-size: 13px; margin-top: 12px; }

/* Search bar */
.search-bar {
  position: sticky; top: 0; z-index: 100;
  background: var(--cns-white); border-bottom: 1px solid var(--cns-border);
  padding: 10px 12px; box-shadow: var(--shadow);
}
.search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.search-row input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--cns-border);
  border-radius: var(--radius); font-size: 15px;
}
.search-row input:focus { outline: none; border-color: var(--cns-blue); }
.suggestions {
  background: var(--cns-white); border: 1px solid var(--cns-border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 200px; overflow-y: auto; position: absolute;
  left: 12px; right: 12px; z-index: 200;
}
.suggestions div {
  padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--cns-border);
  font-size: 13px;
}
.suggestions div:last-child { border-bottom: none; }
.suggestions div:hover { background: var(--cns-light); }
.search-controls { display: flex; justify-content: space-between; align-items: center; }
.radius-group { flex: 1; margin-right: 12px; }
.radius-group label { font-size: 12px; color: var(--cns-gray); font-weight: 600; }
.radius-group input[type="range"] { width: 100%; margin-top: 2px; }

/* Filter panel */
.filter-panel {
  margin-top: 12px; padding: 12px; background: var(--cns-light);
  border-radius: var(--radius); border: 1px solid var(--cns-border);
}
.category-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--cns-border); background: var(--cns-white); cursor: pointer;
  transition: all .15s; user-select: none;
}
.chip.active { background: var(--cns-blue); color: var(--cns-white); border-color: var(--cns-blue); }
.filter-toggles { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.toggle-row {
  display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer;
}
.toggle-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* Loading / Error */
.loading { display: flex; flex-direction: column; align-items: center; padding: 40px; }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--cns-border);
  border-top-color: var(--cns-blue); border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { margin-top: 12px; color: var(--cns-gray); font-size: 13px; }
.error-banner {
  margin: 12px; padding: 12px; background: #fef2f2; border: 1px solid #fecaca;
  border-radius: var(--radius); color: var(--cns-red); font-size: 13px;
}

/* Tab bar */
.tab-bar {
  display: flex; border-bottom: 1px solid var(--cns-border);
  background: var(--cns-white); position: sticky; top: 0; z-index: 50;
}
.tab {
  flex: 1; padding: 10px; text-align: center; font-size: 13px; font-weight: 600;
  color: var(--cns-gray); background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--cns-blue); border-bottom-color: var(--cns-blue); }

/* Lead cards */
.main-content { padding-bottom: 80px; }
.lead-card {
  background: var(--cns-white); margin: 8px 12px; padding: 14px;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--cns-border);
}
.lead-card .lead-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 4px;
}
.lead-card .lead-name { font-size: 15px; font-weight: 600; }
.lead-card .lead-distance { font-size: 12px; color: var(--cns-gray); white-space: nowrap; }
.lead-card .lead-address { font-size: 12px; color: var(--cns-gray); margin-bottom: 4px; }
.lead-card .lead-contacts {
  display: flex; gap: 8px; margin-bottom: 6px; flex-wrap: wrap;
}
.lead-card .lead-contacts a {
  font-size: 12px; color: var(--cns-blue); text-decoration: none;
}
.lead-card .lead-contacts a:hover { text-decoration: underline; }

/* Badges */
.badges { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.badge-corp { background: #fef3c7; color: #92400e; }
.badge-tiny { background: #fce7f3; color: #9d174d; }
.badge-neu { background: #e0e7ff; color: #3730a3; }
.badge-besucht { background: #d1fae5; color: #065f46; }
.badge-interessiert { background: #fef3c7; color: #92400e; }
.badge-kein_interesse { background: #fee2e2; color: #991b1b; }

/* Status */
.lead-card .lead-status { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.status-btn {
  padding: 4px 10px; border-radius: var(--radius); border: 1px solid var(--cns-border);
  font-size: 11px; font-weight: 500; cursor: pointer; background: var(--cns-white);
  transition: all .15s;
}
.status-btn.active { background: var(--cns-blue); color: white; border-color: var(--cns-blue); }
.status-btn.status-besucht.active { background: var(--cns-green); border-color: var(--cns-green); }
.status-btn.status-interessiert.active { background: var(--cns-yellow); border-color: var(--cns-yellow); }
.status-btn.status-kein_interesse.active { background: var(--cns-red); border-color: var(--cns-red); }

.lead-card .lead-actions { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.lead-card .lead-note {
  flex: 1; padding: 6px 8px; border: 1px solid var(--cns-border);
  border-radius: var(--radius); font-size: 12px;
}
.lead-card .hide-btn {
  font-size: 11px; color: var(--cns-gray); cursor: pointer; background: none; border: none;
  padding: 4px; text-decoration: underline;
}
.lead-card .tour-check {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  font-size: 13px; cursor: pointer;
}
.lead-card .tour-check input { width: 18px; height: 18px; cursor: pointer; }

.attribution {
  text-align: center; padding: 8px 12px; font-size: 10px; color: var(--cns-gray);
}

/* Tour bar */
.tour-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--cns-white); border-top: 1px solid var(--cns-border);
  box-shadow: 0 -2px 6px rgba(0,0,0,.08);
}
.tour-bar-inner {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px;
}
.tour-details { border-top: 1px solid var(--cns-border); padding: 10px 12px; max-height: 200px; overflow-y: auto; }
.tour-details ol { margin: 0 0 8px 18px; font-size: 13px; }
.tour-details li { margin-bottom: 4px; }
.tour-actions { display: flex; gap: 8px; }

/* Map */
#mapContainer { width: 100%; height: calc(100vh - 120px); }
.map-marker-label {
  color: white; font-weight: 600; font-size: 12px; padding: 2px 8px;
  border-radius: 4px; white-space: nowrap;
}
.bottom-sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--cns-white); border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,.15);
  transform: translateY(100%); transition: transform .3s ease;
  max-height: 60vh; overflow-y: auto;
}
.bottom-sheet.open { transform: translateY(0); }
.bottom-sheet-handle {
  width: 40px; height: 4px; background: var(--cns-border); border-radius: 2px;
  margin: 8px auto;
}
.bottom-sheet-content { padding: 0 16px 16px; }

/* Name prompt */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-card {
  background: var(--cns-white); border-radius: var(--radius);
  padding: 24px; max-width: 340px; width: 100%; box-shadow: var(--shadow-lg);
}
.modal-card h2 { font-size: 18px; margin-bottom: 8px; }
.modal-card p { font-size: 13px; color: var(--cns-gray); margin-bottom: 16px; }
.modal-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--cns-border);
  border-radius: var(--radius); font-size: 15px; margin-bottom: 12px;
}
.modal-card input:focus { outline: none; border-color: var(--cns-blue); }
.modal-card .btn-primary { width: 100%; }

/* Responsive */
@media (min-width: 768px) {
  .lead-cards { max-width: 640px; margin: 0 auto; }
}
