:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --muted: #64748b;
  --text: #0f172a;
  --primary: #16a34a;
  --primary-dark: #15803d;
  --border: #e2e8f0;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: #f1f5f9;
}

/* --- Login --- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 20% -10%, #1e293b 0%, #0f172a 60%);
  padding: 20px;
}
.login-card {
  background: var(--panel);
  width: 100%;
  max-width: 400px;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 22px;
  margin: 0 0 4px;
}
.login-card .sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
}
.brand {
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--primary);
}
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], select, input[type=number] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  outline: none;
}
input:focus, select:focus { border-color: var(--primary); }
button {
  cursor: pointer;
  border: none;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 16px;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s;
}
button:hover { background: var(--primary-dark); }
button.secondary { background: #e2e8f0; color: var(--text); }
button.secondary:hover { background: #cbd5e1; }
button.danger { background: var(--danger); }
button.ghost { background: transparent; color: var(--muted); }
button:disabled { opacity: 0.6; cursor: default; }
.btn-full { width: 100%; margin-top: 20px; }
.error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* --- App shell --- */
.app-shell { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: var(--bg);
  color: #fff;
  flex: 0 0 auto;
}
.topbar .brand { color: #fff; font-size: 16px; }
.topbar .brand span { color: var(--primary); }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 13px; color: #cbd5e1; }
.topbar a, .topbar button { font-size: 13px; }
.topbar .link { color: #cbd5e1; text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.topbar .link:hover { background: rgba(255,255,255,0.1); }
.version-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  text-decoration: none;
  color: #fff;
  background: var(--primary);
}
.version-badge:hover { background: var(--primary-dark); }

/* --- Version-Seite --- */
.version-card { text-align: center; }
.version-big { font-size: 30px; font-weight: 800; color: var(--primary); margin-top: 6px; }
.changelog-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.changelog-item:last-child { border-bottom: none; }
.changelog-head { display: flex; align-items: baseline; gap: 10px; }
.changelog-version { font-weight: 700; font-size: 15px; }
.changelog-date { color: var(--muted); font-size: 12px; }
.changelog-changes { margin: 8px 0 0; padding-left: 20px; font-size: 14px; }
.changelog-changes li { margin: 2px 0; }

.main { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 300px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex: 0 0 auto;
}
.sidebar h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); padding: 16px 16px 8px; margin: 0; }
.layer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}
.layer-item:hover { background: #f8fafc; }
.layer-item input { width: auto; }
.layer-item .meta { flex: 1; min-width: 0; }
.layer-item .name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-item .sub { font-size: 12px; color: var(--muted); }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }

#map { flex: 1; }

.maplibregl-popup-content {
  font-size: 13px;
  max-height: 320px;
  overflow: auto;
  border-radius: 10px;
  padding: 12px 14px;
}
.popup-table { border-collapse: collapse; width: 100%; }
.popup-table td { padding: 3px 6px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.popup-table td.k { font-weight: 600; color: var(--muted); white-space: nowrap; }

/* --- Admin --- */
.admin-wrap { padding: 24px; max-width: 1100px; margin: 0 auto; width: 100%; overflow-y: auto; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 22px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 14px; font-size: 17px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1; min-width: 160px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.err { background: #fee2e2; color: #991b1b; }
.badge.idle { background: #f1f5f9; color: #475569; }
.muted { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tabs button { background: #e2e8f0; color: var(--text); }
.tabs button.active { background: var(--primary); color: #fff; }
.actions { display: flex; gap: 6px; }
.actions button { padding: 6px 10px; font-size: 12px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: flex; align-items: center; gap: 6px; padding: 4px 8px; background: #f1f5f9; border-radius: 8px; font-size: 12px; }
.chip input { width: auto; }
