:root {
  --dhl-yellow: #FFCC00;
  --dhl-yellow-dark: #c1a800;
  --dhl-red: #D40511;
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --hover: #f9fafb;
  --selected-bg: #fffbea;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

#app {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: 100vh;
  overflow: hidden;
}

#sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  min-height: 0;
}

#sidebar header {
  padding: 16px;
  border-bottom: 1px solid var(--dhl-yellow-dark);
  background: var(--dhl-yellow);
  flex-shrink: 0;
}
#sidebar h1 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
#sidebar h1 span { color: var(--dhl-red); font-weight: 700; }

.search {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.search input,
.search select {
  padding: 8px 10px;
  border: 1px solid var(--dhl-yellow-dark);
  border-radius: 4px;
  font-size: 14px;
  background: white;
  font-family: inherit;
}
.search input { flex: 1; min-width: 0; }
.search input:focus,
.search select:focus,
.search .icon-btn:focus { outline: 2px solid var(--dhl-red); outline-offset: 0; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: white;
  border: 1px solid var(--dhl-yellow-dark);
  border-radius: 4px;
  cursor: pointer;
  color: #333;
  flex-shrink: 0;
  transition: background 0.1s;
}
.icon-btn:hover { background: #fffbea; color: var(--dhl-red); }
.icon-btn.loading { color: var(--muted); cursor: wait; }
.icon-btn.loading svg { animation: spin 1s linear infinite; }
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.filters {
  display: flex;
  gap: 16px;
  font-size: 13px;
  flex-wrap: wrap;
}
.filters label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.filters input[type="checkbox"] { margin: 0; cursor: pointer; }

.badge {
  display: inline-block;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 4px;
  font-weight: 700;
  font-size: 12px;
  color: white;
  flex-shrink: 0;
}
.badge.packstation { background: var(--dhl-red); }
.badge.filiale { background: #2b2b2b; }

.selection-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--selected-bg);
  border-bottom: 1px solid var(--dhl-yellow-dark);
  border-left: 3px solid var(--dhl-yellow);
  font-size: 13px;
  flex-shrink: 0;
}
.selection-banner.hidden { display: none; }
.selection-banner .banner-info { flex: 1; min-width: 0; }
.selection-banner strong { display: block; font-size: 13px; }
.selection-banner small { color: var(--muted); font-size: 11px; display: block; }
.selection-banner .banner-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
  font-family: inherit;
}
.selection-banner .banner-close:hover { color: var(--dhl-red); }

.opening-hours {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text);
}
.opening-hours-label {
  font-weight: 600;
  margin-bottom: 2px;
  display: block;
}
.opening-hours table {
  border-collapse: collapse;
  font-size: 11px;
  line-height: 1.4;
}
.opening-hours td {
  padding: 1px 6px 1px 0;
  vertical-align: top;
}
.opening-hours td:first-child {
  color: var(--muted);
  font-weight: 500;
  width: 28px;
}
.opening-hours .closed { color: #9ca3af; font-style: italic; }
.opening-hours .always-open { font-size: 12px; color: #047857; font-weight: 600; }

.results {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.result-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  gap: 12px;
  transition: background 0.1s;
}
.result-item:hover { background: var(--hover); }
.result-item:focus { outline: 2px solid var(--dhl-red); outline-offset: -2px; background: var(--hover); }
.result-item:focus:not(:focus-visible) { outline: none; }
.result-item .badge { margin-top: 2px; }
.result-item .result-body { flex: 1; min-width: 0; }
.result-item .result-row { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.result-item .name { font-weight: 600; font-size: 14px; min-width: 0; }
.result-item .distance {
  font-size: 11px;
  color: var(--muted);
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
}
.result-item .addr { font-size: 12px; color: var(--muted); margin-top: 2px; }
.result-item.selected {
  background: var(--selected-bg);
  border-left: 3px solid var(--dhl-yellow);
  padding-left: 13px;
}

.empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.empty strong { color: var(--text); display: block; margin-bottom: 4px; }

.status-bar {
  font-size: 11px;
  color: var(--muted);
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  background: #fafafa;
  min-height: 24px;
}
.status-bar.error { color: var(--dhl-red); background: #fff5f5; }

#map-container { position: relative; min-height: 0; }
#map { width: 100%; height: 100%; }

.postnumber-panel {
  position: absolute;
  inset: 0;
  background: white;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 100;
}
.postnumber-panel.hidden { display: none; }
.postnumber-panel h2 { margin: 0; font-size: 16px; font-weight: 700; }
.postnumber-panel .hint { margin: 0; font-size: 13px; color: var(--muted); }
.postnumber-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
}
.postnumber-panel input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}
.postnumber-panel input:focus { outline: 2px solid var(--dhl-red); outline-offset: 0; }

.selected-locker-info {
  font-size: 12px;
  padding: 8px 12px;
  background: var(--selected-bg);
  border-left: 3px solid var(--dhl-yellow);
  border-radius: 0 4px 4px 0;
}
.selected-locker-info strong { display: block; }

.pn-status {
  font-size: 13px;
  min-height: 20px;
  font-weight: 500;
}
.pn-status.ok { color: #047857; }
.pn-status.err { color: var(--dhl-red); }
.pn-status.loading { color: var(--muted); font-weight: 400; }

.actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
}
.btn-primary, .btn-secondary {
  flex: 1;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  border: none;
}
.btn-primary {
  background: var(--dhl-yellow);
  color: #000;
}
.btn-primary:hover:not(:disabled) { background: #ffd633; }
.btn-primary:disabled { background: #e5e7eb; color: #9ca3af; cursor: not-allowed; }
.btn-secondary {
  background: white;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--hover); }

.popup-content { font-size: 13px; min-width: 220px; }
.popup-content strong { display: block; margin-bottom: 4px; font-size: 14px; }
.popup-content .addr { color: var(--muted); margin-bottom: 8px; }
.popup-content button {
  background: var(--dhl-yellow);
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}
.popup-content button:hover { background: #ffd633; }

.dhl-marker {
  background: var(--dhl-red);
  color: white;
  border-radius: 4px;
  padding: 4px 8px;
  font-weight: 800;
  font-size: 13px;
  border: 2px solid var(--dhl-yellow);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  text-align: center;
  white-space: nowrap;
}
.dhl-marker.servicepoint { background: #2b2b2b; }

@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  #sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}
