:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1d2430;
  --muted: #6b7684;
  --line: #e2e7ec;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #16a34a;
  --warn: #ea8a00;
  --err: #dc2626;
  --offen: #94a3b8;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

#app { display: flex; height: 100vh; }

#sidebar {
  width: 360px;
  flex: 0 0 360px;
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 14px;
}

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

.brand {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.brand h1 { font-size: 18px; margin: 0; letter-spacing: -0.01em; }

.badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: #e5e7eb; color: #374151;
}
.badge.on { background: #dcfce7; color: #166534; }
.badge.off { background: #fee2e2; color: #991b1b; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}
.panel.subtle { background: transparent; border: none; padding: 4px; display: flex; gap: 8px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 0 0 10px; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
input[type=text], input[type=number], input[type=date], select {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px;
  font: inherit; color: var(--ink); background: #fff; margin-top: 3px;
}
input[type=file] { width: 100%; font-size: 12px; }
.latlon { display: flex; gap: 8px; }
.latlon label { flex: 1; }

button {
  cursor: pointer; font: inherit; font-weight: 600; border-radius: 7px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 12px; margin-top: 6px;
}
button:hover { border-color: #cbd2d9; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); width: 100%; }
button.primary:hover { filter: brightness(1.05); }
button.ghost { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-weight: 500; }
button.ghost.danger:hover { color: var(--err); border-color: var(--err); }

.hint { font-size: 12px; color: var(--muted); margin: 6px 0; }
.result { font-size: 12px; margin: 8px 0 0; min-height: 1em; }
.result.ok { color: var(--ok); }
.result.err { color: var(--err); }
.hidden { display: none !important; }

.counts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #eef1f4; }
.chip.ok { background: #dcfce7; color: #166534; }
.chip.unsicher { background: #fef3c7; color: #92400e; }
.chip.fehler { background: #fee2e2; color: #991b1b; }
.chip.offen { background: #e2e8f0; color: #475569; }

.map-field { display: grid; grid-template-columns: 1fr 1.2fr; gap: 6px; align-items: center; margin-bottom: 6px; }
.map-field span { font-size: 12px; color: var(--ink); }
.map-field select { margin-top: 0; }

.popup-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.popup-row { font-size: 12px; color: #334155; }
.popup-row b { color: #0f172a; }

.cust-list { max-height: 220px; overflow-y: auto; margin-top: 8px; }
.cust-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.cust-row:last-child { border-bottom: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.cust-name { flex: 1 1 auto; cursor: pointer; font-size: 13px; line-height: 1.2; }
.cust-name small { display: block; color: var(--muted); font-size: 11px; }
.cust-name:hover { color: var(--accent); }
.row-del { border: none; background: none; padding: 2px 6px; margin: 0; font-size: 14px; opacity: .6; }
.row-del:hover { opacity: 1; }

.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 1000; }
.edit-card { background: #fff; border-radius: 12px; padding: 20px; width: min(380px, 92vw);
  box-shadow: 0 10px 40px rgba(0,0,0,.25); max-height: 92vh; overflow-y: auto; }
.edit-card { position: relative; }
.edit-card h3 { margin: 0 0 14px; font-size: 16px; padding-right: 28px; }
.edit-x { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; padding: 0;
  border: none; background: #f1f5f9; border-radius: 7px; font-size: 15px; line-height: 1;
  color: var(--muted); margin: 0; }
.edit-x:hover { background: #e2e8f0; color: var(--ink); }
.edit-actions { display: flex; gap: 8px; margin-top: 14px; }
.edit-actions .primary { width: auto; flex: 1; }

.radio-row { display: flex; gap: 14px; margin-bottom: 8px; }
.radio-row label { display: inline-flex; align-items: center; gap: 5px; margin: 0; color: var(--ink); }
label.check { display: flex; align-items: center; gap: 6px; color: var(--ink); }
label.check input { width: auto; margin: 0; }
.cust-pick { width: auto; margin: 0; flex: 0 0 auto; }

.tour-result { margin-top: 10px; }
.tour-total { font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.tour-stop { font-size: 13px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.tour-stop small { display: block; color: var(--muted); font-size: 11px; }
.gmaps-btn { display: inline-block; margin-top: 10px; padding: 8px 12px; border-radius: 7px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; text-decoration: none; }
.gmaps-btn:hover { filter: brightness(1.05); }

.iso-row { display: flex; gap: 6px; margin-top: 3px; }
.iso-row input { flex: 1 1 auto; }
.iso-row button { margin-top: 0; white-space: nowrap; flex: 0 0 auto; }

.ics-box { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.ics-fields { display: flex; gap: 8px; }
.ics-fields label { flex: 1; }

@media (max-width: 760px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; flex: 0 0 auto; max-height: 45vh; border-right: none; border-bottom: 1px solid var(--line); }
  #map { flex: 1 1 auto; min-height: 55vh; }
}
