:root {
  --bg: #0b1015;
  --panel: #131a21;
  --panel2: #1a232c;
  --line: #27333f;
  --text: #e7eef5;
  --muted: #8899aa;
  --accent: #3ea6ff;
  --accent-dim: #1d4a6e;
  --danger: #ff6b6b;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* hidden muss jede Autoren-Display-Regel schlagen */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-size: 14px;
}

#app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* Messpunkt erfassen – nur auf schmalen Geräten, direkt über der Karte */
#btnAddMobile { display: none; }

@media (max-width: 900px) {
  #btnAddMobile {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; right: 14px; bottom: 18px; z-index: 1100;
    height: 46px; padding: 0 18px; border: 0; border-radius: 23px;
    background: var(--accent); color: #04121d;
    font-size: 14px; font-weight: 650; letter-spacing: .01em;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .45); cursor: pointer;
  }
  #btnAddMobile.active { background: var(--danger); color: #200505; }
  body.sidebar-open #btnAddMobile { display: none; }
}

/* ---------- Seitenleiste ---------- */

#sidebar {
  flex: 0 0 344px;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.brandlogo {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: 10px;
  display: block; margin: 0 0 0 0; object-fit: contain;
}
.brand > div { flex: 1 1 auto; min-width: 0; }
.brand {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px; padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}
.brand h1 { margin: 0; font-size: 17px; letter-spacing: .2px; }
.brand .sub { margin: 3px 0 0; font-size: 11.5px; color: var(--muted); }

.scroll { overflow-y: auto; padding: 10px 12px 24px; flex: 1 1 auto; min-height: 0; }

.sidefoot {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 4px 10px; padding: 9px 14px; border-top: 1px solid var(--line);
  font-size: 12px; background: #101820;
}
.sidefoot .ver { margin-left: auto; }
.sidefoot a { color: var(--accent); text-decoration: none; }
.sidefoot a:hover { text-decoration: underline; }
.sidefoot .ver { color: var(--muted); font-size: 11px; }

.card {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 11px 12px;
  margin-bottom: 10px;
}
.card h2 {
  margin: 0 0 8px; font-size: 11px; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}

label.field { display: block; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
label.field input, label.field select { margin-top: 4px; }

input, select, button { font: inherit; }
input[type="text"], input[type="number"], select {
  width: 100%; padding: 7px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: #0e151b; color: var(--text);
  outline: none;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px rgba(62,166,255,.15);
}
input:disabled { opacity: .6; }

input[type="range"] {
  width: 100%; margin: 6px 0 2px; accent-color: var(--accent); height: 18px;
}
label.range output { float: right; color: var(--text); font-variant-numeric: tabular-nums; }

label.check { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
label.check input { accent-color: var(--accent); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 .field { margin-bottom: 6px; }

.hint { margin: 6px 0 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); }

button {
  padding: 7px 10px; border-radius: 6px; cursor: pointer;
  background: #223040; color: var(--text); border: 1px solid #2f4152;
  transition: background .12s, border-color .12s, transform .05s;
}
button:hover { background: #2a3b4d; }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent-dim); border-color: #2f6f9e; }
button.primary:hover { background: #235a83; }
button.primary.active { background: var(--accent); color: #04121e; border-color: var(--accent); font-weight: 600; }
button.ghost-danger { background: transparent; border-color: #5a2c2c; color: #ffb3b3; }
button.ghost-danger:hover { background: #3a1d1d; }
button.icon-only {
  background: transparent; border: none; color: var(--muted);
  font-size: 16px; line-height: 1; padding: 4px 6px;
}
button.icon-only:hover { color: var(--text); background: rgba(255,255,255,.06); }

.btnrow { display: flex; gap: 6px; margin-bottom: 8px; }
.btnrow > button { flex: 1 1 auto; }
.btnrow.wrap { flex-wrap: wrap; }
.btnrow.wrap > button { flex: 1 1 30%; font-size: 12px; padding: 6px 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.chip {
  font-size: 11.5px; padding: 4px 9px; border-radius: 20px;
  background: #1b2733; border: 1px solid var(--line); color: var(--muted);
}
.chip.active { background: var(--accent-dim); border-color: #3a80b5; color: #dff0ff; }

.badge {
  background: #24313d; color: var(--muted); border-radius: 10px;
  padding: 1px 7px; font-size: 10.5px; font-weight: 500; letter-spacing: 0;
}

/* ---------- Punktliste ---------- */

.tablewrap { max-height: 260px; overflow-y: auto; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: #18222b; color: var(--muted); text-align: left;
  font-weight: 500; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  padding: 6px 6px; border-bottom: 1px solid var(--line);
}
tbody td { padding: 5px 6px; border-bottom: 1px solid #1d2831; vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #1e2a35; }
tbody tr.out { opacity: .42; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c8d6e2; }
td.acts { text-align: right; width: 28px; }
td.acts button {
  background: transparent; border: none; color: #7d8f9f; padding: 2px 5px; font-size: 13px;
}
td.acts button:hover { color: var(--danger); background: transparent; }

/* ---------- Karte ---------- */

#mapwrap { position: relative; flex: 1 1 auto; min-width: 0; }
#map { position: absolute; inset: 0; background: #0f1a22; }
#map.picking { cursor: crosshair; }
.leaflet-container { background: #0f1a22; font-family: inherit; }

.field-canvas { will-change: transform; }

.readout {
  position: absolute; top: 10px; right: 10px; z-index: 500;
  background: rgba(9,14,19,.82); border: 1px solid rgba(255,255,255,.12);
  border-radius: 7px; padding: 6px 10px; font-size: 13px;
  display: flex; gap: 10px; align-items: baseline;
  backdrop-filter: blur(4px); pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.readout #roTemp { font-weight: 600; color: #ffd9a0; }
.readout .pos { font-size: 11px; color: var(--muted); }

.empty-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 480; background: rgba(9,14,19,.86); border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px; padding: 16px 18px; text-align: center; max-width: 300px;
  backdrop-filter: blur(4px); box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.empty-hint[hidden] { display: none; }
.empty-hint strong { display: block; font-size: 14px; margin-bottom: 6px; }
.empty-hint p { margin: 0 0 12px; font-size: 12px; line-height: 1.45; color: var(--muted); }

.legend {
  position: absolute; left: 12px; bottom: 26px; z-index: 500;
  background: rgba(9,14,19,.82); border: 1px solid rgba(255,255,255,.12);
  border-radius: 7px; padding: 8px 10px 10px;
  backdrop-filter: blur(4px); font-size: 11px; color: #dfe8f0;
}
.legend.hidden { display: none; }
.lrow { display: flex; gap: 8px; align-items: stretch; }
.lgrad {
  width: 14px; height: 132px; border-radius: 3px;
  border: 1px solid rgba(255,255,255,.35);
}
.lscale { display: flex; flex-direction: column; justify-content: space-between; font-variant-numeric: tabular-nums; }
.lmeta { margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.15;
         letter-spacing: .03em; display: flex; gap: 4px; }

.toast {
  position: absolute; left: 50%; bottom: 22px; transform: translate(-50%, 12px);
  background: #1d3a52; color: #dff1ff; border: 1px solid #2d5d80;
  padding: 8px 14px; border-radius: 8px; font-size: 12.5px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
  z-index: 900; max-width: 70%;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: #4a2323; border-color: #7a3434; color: #ffd7d7; }

#btnSidebarOpen { display: none; position: absolute; top: 10px; left: 10px; z-index: 600;
  background: rgba(9,14,19,.85); border: 1px solid rgba(255,255,255,.15); border-radius: 6px; padding: 6px 9px; }

/* ---------- Marker ---------- */

.thermo-pin { position: relative; }
.thermo-pin .dot {
  position: absolute; left: -7px; top: -7px; width: 14px; height: 14px;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.92);
  box-shadow: 0 1px 4px rgba(0,0,0,.65), 0 0 0 1px rgba(0,0,0,.35);
  cursor: pointer;
}
.thermo-pin .tag {
  position: absolute; left: 10px; top: -9px; white-space: nowrap;
  background: rgba(6,11,16,.78); color: #fff; font-size: 10.5px;
  padding: 1px 4px; border-radius: 3px; font-variant-numeric: tabular-nums;
  border: 1px solid rgba(255,255,255,.16); pointer-events: none;
}
.thermo-pin.out { opacity: .38; }
.thermo-pin.out .tag { text-decoration: line-through; }

.leaflet-tooltip.thermo-tip {
  background: rgba(8,14,20,.92); color: #e7eef5; border: 1px solid #35485a;
  border-radius: 6px; font-size: 12px; padding: 5px 8px; box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
.leaflet-tooltip.thermo-tip::before { border-top-color: #35485a; }

/* ---------- Dialog ---------- */

dialog#ptDialog {
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  color: var(--text); padding: 16px 18px; width: min(360px, 92vw);
  box-shadow: 0 18px 50px rgba(0,0,0,.6);
}
dialog#ptDialog::backdrop { background: rgba(4,8,12,.55); }
dialog#ptDialog h2 { margin: 0 0 12px; font-size: 15px; }
.dlgbtns { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.dlgbtns .spacer { flex: 1; }

/* ---------- Mobil ---------- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media (max-width: 900px) {
  #sidebar {
    position: fixed; inset: 0 auto 0 0; width: 340px; max-width: 88vw;
    z-index: 1200; transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  body.sidebar-open #sidebar { transform: none; }
  body.sidebar-open #btnSidebarOpen { visibility: hidden; }
  #btnSidebarOpen { display: block; }
  /* Zoom-Regler unter den Menü-Button schieben, sonst liegen sie übereinander */
  .leaflet-top.leaflet-left .leaflet-control-zoom { margin-top: 46px; }
  .legend { bottom: 34px; }
  .readout { top: auto; bottom: 74px; right: 10px; }
}

