/* StraßenCheck */
:root {
  --ink: #14202b;
  --ink-2: #3a4a5a;
  --muted: #6a7888;
  --line: #dfe5ea;
  --bg: #f3f5f7;
  --card: #ffffff;
  --accent: #0b6bcb;
  --accent-ink: #ffffff;
  --danger: #c8372d;
  --radius: 10px;
  --bar: 52px;
  --shadow: 0 6px 24px rgba(20, 32, 43, .16);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
h1 { font-size: 1.45rem; margin: 0 0 .3rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .7rem; }
a { color: var(--accent); }
code { background: #eef1f4; padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* ---------- Formularelemente ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid #c9d2da; border-radius: 8px; background: #fff; min-height: 42px;
}
textarea { resize: vertical; min-height: 90px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(11, 107, 203, .35); outline-offset: 1px;
}
input:disabled, select:disabled, textarea:disabled { background: #f2f4f6; color: var(--ink-2); }
label, .label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin: 0 0 .8rem; }
label > input, label > select, label > textarea, .label > div { margin-top: .3rem; font-weight: 400; font-size: 1rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 42px; padding: .5rem .95rem;
  border: 1px solid #c9d2da; border-radius: 8px; background: #fff; color: var(--ink); font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f4f7f9; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #095aab; }
.btn.danger { color: var(--danger); border-color: #e7b9b5; }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, .22); color: #fff; }
.btn.ghost:hover { background: rgba(255, 255, 255, .1); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: .3rem .7rem; font-size: .88rem; margin-bottom: .8rem; }
.alert, .notice { padding: .65rem .8rem; border-radius: 8px; margin: 0 0 1rem; }
.alert { background: #fdecea; color: #8c231b; border: 1px solid #f3c4bf; }
.notice { background: #e8f4ec; color: #17603a; border: 1px solid #bfdfcb; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--bar); z-index: 1100; display: flex; align-items: center; gap: .5rem;
  padding: 0 .6rem; padding-left: max(.6rem, env(safe-area-inset-left)); background: var(--ink); color: #fff;
}
.topbar.static { position: sticky; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; letter-spacing: -.01em; color: inherit; text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background: linear-gradient(90deg, #c8372d 0 20%, #e8793a 20% 40%, #e3b420 40% 60%, #7fbf4d 60% 80%, #1f9254 80%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .85);
}
.topbar select { width: auto; max-width: 42vw; min-height: 36px; padding: .3rem .5rem; background: #22313f; color: #fff; border-color: #3a4a5a; }
.topbar .btn { min-height: 36px; padding: .3rem .7rem; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: 44px; min-width: 200px; background: #fff; color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.menu-pop a { display: block; padding: .7rem .9rem; color: var(--ink); text-decoration: none; border-top: 1px solid var(--line); }
.menu-pop a:hover { background: #f4f7f9; }
.menu-user { padding: .7rem .9rem; font-weight: 700; }
.menu-user small { display: block; font-weight: 400; color: var(--muted); }

/* ---------- Karte ---------- */
body.app { overflow: hidden; }
#map { position: fixed; inset: var(--bar) 0 0 0; background: #e6eaed; }
#map.picking { cursor: crosshair; }
#map.picking .leaflet-interactive { cursor: crosshair; }
.leaflet-container { font: inherit; }
.pin-wrap { background: none; border: 0; }
.pin { position: relative; display: block; width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--c); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
.pin::after { content: "!"; position: absolute; inset: 0; display: grid; place-items: center; transform: rotate(45deg); color: #fff; font-weight: 800; font-size: 14px; }

.legend {
  position: fixed; top: calc(var(--bar) + 10px); left: 10px; z-index: 1000; display: flex; align-items: center; gap: .55rem;
  padding: .35rem .6rem; background: rgba(255, 255, 255, .94); border-radius: 8px; box-shadow: 0 1px 6px rgba(0, 0, 0, .18); font-size: .78rem;
}
.legend span { display: inline-flex; align-items: center; gap: .25rem; }
.legend i { width: 14px; height: 6px; border-radius: 3px; display: inline-block; }

.tools {
  position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1000;
  display: flex; gap: 2px; padding: 4px; background: var(--ink); border-radius: 14px; box-shadow: var(--shadow);
}
.tools button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 76px; padding: .45rem .5rem; border: 0; border-radius: 10px;
  background: transparent; color: #cfd8e0; font-size: .7rem; font-weight: 600; cursor: pointer;
}
.tools svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tools button:hover { color: #fff; }
.tools button.on { background: var(--accent); color: #fff; }

.drawbar {
  position: fixed; left: 50%; bottom: calc(max(22px, env(safe-area-inset-bottom)) + 74px); transform: translateX(-50%); z-index: 1000;
  display: flex; align-items: center; gap: .4rem; padding: .4rem .5rem .4rem .8rem; background: #fff; border-radius: 12px; box-shadow: var(--shadow); max-width: calc(100vw - 16px);
}
.drawbar span { font-size: .85rem; font-weight: 600; margin-right: .2rem; }
.drawbar .btn { min-height: 36px; padding: .3rem .65rem; }

.toast {
  position: fixed; left: 50%; top: calc(var(--bar) + 52px); transform: translateX(-50%); z-index: 1300; max-width: min(92vw, 460px);
  padding: .6rem .9rem; background: rgba(20, 32, 43, .95); color: #fff; border-radius: 10px; box-shadow: var(--shadow); font-size: .9rem; text-align: center;
}

/* ---------- Panel ---------- */
.panel {
  position: fixed; z-index: 1200; top: var(--bar); right: 0; bottom: 0; width: 400px; max-width: 100vw; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); box-shadow: -4px 0 24px rgba(20, 32, 43, .14); padding: 0 1rem 1rem;
}
.panel-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; background: var(--card); padding: .8rem 0 .6rem; margin-bottom: .4rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; }
.x { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eef1f4; font-size: 1.3rem; line-height: 1; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 .8rem; }
.chip { padding: .15rem .55rem; border-radius: 99px; background: #eef1f4; font-size: .78rem; font-weight: 600; color: var(--ink-2); }
.chip.soft { background: #e6f0fa; color: #0a5aa8; }
.avg { display: flex; align-items: center; gap: .7rem; padding: .6rem; margin: 0 0 .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fafbfc; }
.avg-num { min-width: 52px; padding: .35rem .3rem; border-radius: 8px; color: #fff; font-weight: 800; font-size: 1.15rem; text-align: center; font-variant-numeric: tabular-nums; }
.avg small { display: block; color: var(--muted); }
.crit { padding: .65rem 0; border-bottom: 1px solid var(--line); }
.crit-name small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.3; }
.rate { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: .45rem; }
.rate button, .seg button {
  min-height: 42px; border: 1.5px solid #c9d2da; border-radius: 8px; background: #fff; font-weight: 700; cursor: pointer;
}
.rate button.on, .seg button.on { background: var(--c); border-color: var(--c); color: #fff; }
.rate button:disabled, .seg button:disabled { cursor: default; opacity: .75; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.scale-hint { font-size: .76rem; color: var(--muted); margin: .5rem 0 1rem; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photos:empty { display: none; }
.photo { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #eef1f4; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.pending { outline: 2px dashed var(--accent); outline-offset: -2px; }
.photo .x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; background: rgba(20, 32, 43, .75); color: #fff; font-size: 1.05rem; }
.meta { font-size: .78rem; color: var(--muted); }
.form-actions { position: sticky; bottom: -1rem; display: flex; gap: .5rem; padding: .8rem 0 1rem; margin-top: .6rem; background: linear-gradient(transparent, var(--card) 14px); }
.form-actions .primary { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: .5rem 0 .8rem; }
.stats div { padding: .5rem .3rem; border: 1px solid var(--line); border-radius: 8px; text-align: center; font-size: .72rem; color: var(--muted); }
.stats b { display: block; font-size: 1.15rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.list { margin-top: .6rem; }
.item { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .6rem .2rem; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.item:hover { background: #f6f8fa; }
.dot { flex: none; width: 40px; padding: .25rem 0; border-radius: 7px; color: #fff; font-weight: 800; font-size: .85rem; text-align: center; font-variant-numeric: tabular-nums; }
.dot.pt { border-radius: 50%; width: 30px; margin: 0 5px; }
.item-text { min-width: 0; }
.item-text b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-text small { color: var(--muted); }
.empty { padding: 2rem .5rem; text-align: center; }

@media (min-width: 761px) {
  body.panel-open #map { right: 400px; }
  body.panel-open .tools, body.panel-open .drawbar { left: calc(50% - 200px); }
}
@media (max-width: 760px) {
  .brand-name { display: none; }
  .panel { top: auto; left: 0; width: auto; max-height: 62vh; border-radius: 16px 16px 0 0; box-shadow: 0 -6px 24px rgba(20, 32, 43, .2); padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  body.panel-open #map { bottom: 58vh; }
  body.panel-open .tools, body.panel-open .drawbar, body.panel-open .legend { display: none; }
  .tools button { min-width: 0; padding: .45rem .55rem; white-space: nowrap; }
  .leaflet-control-zoom { display: none; }
  .legend b { display: none; }
}

.ko { color: #c8372d !important; font-weight: 600; }
.weight { margin-left: .4rem; padding: 0 .35rem; border-radius: 5px; background: #eef1f4; color: var(--ink-2); font-size: .72rem; font-weight: 700; }
.inline { display: flex; gap: 6px; }
.inline input { flex: 1; min-width: 0; }
input[type=datetime-local] { width: 100%; padding: .5rem .6rem; border: 1px solid #c9d2da; border-radius: 8px; background: #fff; min-height: 42px; }
.progress { height: 6px; border-radius: 3px; background: #e3e8ec; overflow: hidden; margin: 0 0 .8rem; }
.progress i { display: block; height: 100%; background: var(--accent); }
.tabs3 { grid-template-columns: repeat(4, 1fr); margin-bottom: .6rem; }
.tabs3 button { min-height: 36px; font-size: .8rem; padding: 0 .2rem; }
.stats div { line-height: 1.25; }

/* ---------- Einfache Seiten (Login, Installer, Verwaltung) ---------- */
body.plain { padding: 1rem; }
body.plain.admin { padding: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem; margin: 0 0 1rem; }
.card.narrow { max-width: 440px; margin: 6vh auto; }
.card.narrow-left { max-width: 440px; }
.card.narrow h2 { margin-top: 1.3rem; }
.login .brand { font-size: 1.3rem; color: var(--ink); margin-bottom: .2rem; }
.login .brand-mark { box-shadow: none; }
.checks { list-style: none; padding: 0; margin: 0 0 1rem; }
.checks li { padding: .25rem 0 .25rem 1.6rem; position: relative; }
.checks li::before { position: absolute; left: 0; font-weight: 800; }
.checks .ok::before { content: "✓"; color: #1f9254; }
.checks .warn::before { content: "!"; color: #b97a06; }
.checks .bad::before { content: "✕"; color: var(--danger); }
.admin-wrap { max-width: 1040px; margin: 0 auto; padding: 1rem; }
.tabs { display: flex; gap: .3rem; margin: 0 0 1rem; overflow-x: auto; }
.tabs a { padding: .5rem .9rem; border-radius: 8px; color: var(--ink-2); font-weight: 600; text-decoration: none; white-space: nowrap; }
.tabs a.on { background: var(--ink); color: #fff; }
.row-form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.row-form:first-of-type { border-top: 0; }
.row-form input, .row-form select { flex: 1 1 150px; width: auto; }
.row-form .grow { flex: 3 1 220px; }
.row-form .sm { flex: 0 1 110px; }
.row-form .xs { flex: 0 0 74px; }
.row-form select.xs { flex: 0 0 74px; }
.row-form .check { display: inline-flex; align-items: center; gap: .3rem; margin: 0; font-weight: 400; font-size: .9rem; }
.row-form .check input { flex: none; width: 18px; height: 18px; min-height: 0; margin: 0; }
.row-form .count { font-size: .85rem; white-space: nowrap; }
.grid-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 .8rem; }
.grid-form .wide { grid-column: 1 / -1; }
.grid-form .actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
@media (max-width: 600px) { .grid-form { grid-template-columns: 1fr 1fr; } }
.choices { display: grid; gap: .1rem; margin: 0 0 1.1rem; }
.choices .check { display: flex; align-items: center; gap: .55rem; margin: 0; padding: .45rem 0; font-weight: 400; font-size: .95rem; color: var(--ink); }
.choices .check input { flex: none; width: 20px; height: 20px; min-height: 0; margin: 0; }
.actions-row { display: flex; flex-wrap: wrap; gap: .6rem; margin: 0 0 1rem; }
.tbl { border-collapse: collapse; width: 100%; max-width: 520px; margin: 0 0 .6rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { text-align: right; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { font-size: .78rem; color: var(--muted); }
.tbl .sum td { font-weight: 700; border-bottom: 0; }
.admin-wrap h2 { margin-top: 1.2rem; }
.admin-wrap .card > h2:first-child { margin-top: 0; }

/* ---------- 1.2: Begehung, Besonderheiten, Haltepunkte ---------- */
.btn.ok { background: #1f9254; border-color: #1f9254; color: #fff; min-height: 50px; font-size: 1.02rem; margin: 0 0 .9rem; }
.btn.ok:hover { background: #197a46; }
.rate.quick button { min-height: 46px; }
.rate.muted-row { opacity: .45; }
.tagbox, .catgrid { display: flex; flex-wrap: wrap; gap: 6px; }
.tagbox button, .catgrid button {
  min-height: 40px; padding: .35rem .7rem; border: 1.5px solid #c9d2da; border-radius: 99px; background: #fff; font-weight: 600; font-size: .86rem; cursor: pointer;
}
.tagbox button.on { background: #14202b; border-color: #14202b; color: #fff; }
.catgrid { display: grid; grid-template-columns: 1fr 1fr; margin: 0 0 .9rem; }
.catgrid button { border-radius: 10px; min-height: 48px; text-align: left; line-height: 1.2; }
.catgrid button.on { background: #14202b; border-color: #14202b; color: #fff; }
.seg.two { grid-template-columns: 1fr 1fr; margin: .2rem 0 .7rem; }
.fold { border: 1px solid var(--line); border-radius: var(--radius); padding: 0 .7rem; margin: 0 0 .9rem; }
.fold summary { padding: .75rem 0; font-weight: 700; cursor: pointer; }
.fold[open] summary { border-bottom: 1px solid var(--line); }
.fold .crit:last-child { border-bottom: 0; }
.fold .scale-hint { margin: .6rem 0 0; }
.pin.stop { border-radius: 8px; transform: none; }
.pin.stop::after { content: "H"; transform: none; }
.toast button { margin-left: .7rem; padding: .25rem .6rem; border: 1px solid rgba(255, 255, 255, .5); border-radius: 6px; background: transparent; color: #fff; font-weight: 700; cursor: pointer; }
.legend .pre { color: var(--muted); }
.tools button { min-width: 68px; }
@media (max-width: 760px) {
  .tools button { padding: .45rem .4rem; font-size: .66rem; }
  .legend .pre { display: none; }
}
.tbl.wide { max-width: none; }
.tbl.wide th { vertical-align: bottom; }
.scroll-x { overflow-x: auto; }
.score-chip { display: inline-block; min-width: 40px; padding: .1rem .4rem; border-radius: 6px; color: #fff; font-weight: 800; text-align: center; }
@media print { .topbar, .btn { display: none !important; } body { background: #fff; } .card { border: 0; } }

/* ---------- 1.3: Breite und Ausweichrouten ---------- */
.chip.bad { background: #fdecea; color: #8c231b; }
.hint { display: block; margin-top: .3rem; font-weight: 400; color: var(--muted); }
