:root {
  --bg: #f4f2ee;
  --card: #ffffff;
  --ink: #1d2320;
  --muted: #69726d;
  --line: #e2ded6;
  --accent: #1f6b4e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0ea;
  --warn: #b86e00;
  --warn-soft: #fff3df;
  --hot: #b3261e;
  --hot-soft: #fdeceb;
  --ok: #2e7d4f;
  --ok-soft: #e6f4ec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; font-size: 16px; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; background: #f0ede7; padding: .05em .35em; border-radius: 4px; }
.wrapcode { word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.opt { color: var(--muted); font-weight: normal; font-size: .85em; }
.sub { display: block; color: var(--muted); font-size: .8rem; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 560px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }

/* Kopfzeile Backend */
.topbar { background: var(--accent); color: var(--accent-ink); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.brand { color: #fff; text-decoration: none; font-weight: 650; display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: #fff; position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 5px 5px 7px; border: 2px solid var(--accent); border-top-width: 4px; border-radius: 2px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .95rem; opacity: .9; }
.nav a:hover, .nav a.on { background: rgba(255,255,255,.16); opacity: 1; }

/* Buttons & Formulare */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 16px; border-radius: 10px; font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; min-height: 42px; }
.btn:hover { border-color: #c9c3b8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { width: 100%; min-height: 52px; font-size: 1.05rem; }
.btn:disabled { opacity: .6; cursor: wait; }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--accent); font: inherit; font-size: .9rem; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.btnrow form { margin: 0; }

.form label { display: block; margin-bottom: 14px; font-weight: 550; font-size: .95rem; }
.form input:not([type=checkbox]):not([type=radio]):not([type=file]), .form select, .form textarea, .filters input:not([type=checkbox]), .filters select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; font-weight: normal;
  border: 1px solid #cfc9bf; border-radius: 9px; background: #fff; color: var(--ink);
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.form small { display: block; font-weight: normal; color: var(--muted); margin-top: 4px; }
.form label.check, label.check { display: flex; align-items: center; gap: 8px; font-weight: normal; }
.form fieldset { border: 0; padding: 0; margin: 0 0 18px; }
.form legend { font-weight: 650; margin-bottom: 8px; padding: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 12px; }
textarea.code { width: 100%; font-family: ui-monospace, monospace; font-size: .8rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Hinweise */
.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid; }
.alert-ok { background: var(--ok-soft); border-color: #b9dcc6; }
.alert-err { background: var(--hot-soft); border-color: #f2c0bc; }
.alert-warn { background: var(--warn-soft); border-color: #f0d3a5; }
.alert-info { background: #eaf1f8; border-color: #c4d6e8; }
.notice { border-radius: 12px; padding: 14px 16px; margin: 14px 0; border-left: 5px solid; }
.notice strong { display: block; font-size: 1.05rem; margin-bottom: 2px; }
.notice p { margin: 4px 0 0; }
.notice-ok { background: var(--ok-soft); border-color: var(--ok); }
.notice-already { background: var(--warn-soft); border-color: var(--warn); }
.notice-err { background: var(--hot-soft); border-color: var(--hot); }
.big-ok strong { font-size: 1.25rem; }

/* Öffentliche Meldeseite */
.mode-public { background: linear-gradient(180deg, var(--accent) 0 140px, var(--bg) 140px); }
.public { padding-top: 28px; }
.public .card { padding: 22px 20px; }
.cont-head { display: flex; flex-direction: column; gap: 2px; padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.cont-no { font-size: 1.35rem; font-weight: 700; }
.cont-name { font-weight: 550; }
.cont-addr { color: var(--muted); font-size: .95rem; }
.lead { font-size: 1.05rem; }
.choice { display: flex !important; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid #d6d0c6; border-radius: 10px; margin-bottom: 8px !important; cursor: pointer; font-weight: 500 !important; }
.choice input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.field-err { color: var(--hot); font-weight: 600; margin: 4px 0 0; }
.field-err[hidden] { display: none; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.photo-pick { position: relative; margin-bottom: 8px !important; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.photo-btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border: 2px dashed #c6bfb3; border-radius: 10px; color: var(--accent); font-weight: 600; }
.photo-btn::before { content: "📷"; }
#preview { display: block; max-width: 100%; max-height: 260px; border-radius: 10px; margin: 6px 0; }
#preview[hidden] { display: none; }
.hero-icon { width: 64px; height: 64px; margin: 4px auto 12px; border-radius: 16px; background: var(--accent-soft); position: relative; }
.hero-icon::after { content: ""; position: absolute; inset: 14px 16px 16px; border: 4px solid var(--accent); border-top-width: 8px; border-radius: 4px; }
.legal { text-align: center; font-size: .85rem; padding: 8px 16px 28px; color: var(--muted); }
.legal a { color: var(--muted); }

/* Übersicht */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.tile-num { display: block; font-size: 1.8rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-lbl { color: var(--muted); font-size: .9rem; }
.tile-warn .tile-num { color: var(--warn); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 220px; width: auto; margin: 0; }
.filters select { width: auto; margin: 0; }
.filters label.check { white-space: nowrap; }
.bulkbar { display: none; position: sticky; top: 0; z-index: 5; background: #263a31; color: #fff; padding: 10px 14px; border-radius: 10px; margin-bottom: 10px; align-items: center; gap: 10px; flex-wrap: wrap; }
.bulkbar.show { display: flex; }
.bulkbar .btn { min-height: 36px; padding: 6px 12px; }

table.list { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.list th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #faf9f6; }
table.list td { padding: 10px 12px; border-bottom: 1px solid #eeebe5; vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.is-open td { background: #fffaf0; }
table.list td.no a { font-weight: 650; text-decoration: none; font-variant-numeric: tabular-nums; }
table.list td.loc a { color: var(--ink); text-decoration: none; }
table.list .sel { width: 36px; }
table.list input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
tr.is-inactive td { opacity: .55; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 650; white-space: nowrap; vertical-align: middle; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.hot { background: var(--hot-soft); color: var(--hot); }
.badge.off { background: #ecebe8; color: var(--muted); }
h1 .badge { font-size: .85rem; margin-left: 6px; }

/* Detailseite */
.pagehead { margin-bottom: 12px; }
.back { text-decoration: none; font-size: .9rem; }
.cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols > .col-side:only-child { grid-column: 1 / -1; max-width: 640px; }
.reports { list-style: none; padding: 0; margin: 0 0 12px; }
.reports li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #eeebe5; }
.reports img { width: 88px; height: 88px; object-fit: cover; border-radius: 8px; display: block; }
.reports form { margin: 2px 0 0; }
.nophoto { width: 88px; height: 88px; border-radius: 8px; background: #f2efe9; color: var(--muted); font-size: .75rem; display: flex; align-items: center; justify-content: center; flex: none; }
.emptyform { border-top: 1px solid var(--line); padding-top: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; }
table.mini { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.mini th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--line); padding: 6px 8px 6px 0; }
table.mini td { padding: 8px 8px 8px 0; border-bottom: 1px solid #eeebe5; vertical-align: top; }
.locphoto img { max-width: 100%; border-radius: 10px; margin-bottom: 10px; }
.qrpair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.qrpair figure { margin: 0; text-align: center; font-size: .85rem; }
.qr { background: #fff; padding: 0; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
.qr svg { display: block; width: 100%; height: auto; }
details.danger { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
details.danger summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
details.danger form { margin: 4px 0; }
.empty { text-align: center; }

/* Druck */
.printopts .checks { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 8px; }
.sheet { display: grid; grid-template-columns: repeat(var(--cols), max-content); gap: 0; justify-content: center; background: #fff; padding: 10mm; margin: 0 auto 30px; width: 210mm; max-width: 100%; box-shadow: var(--shadow); }
.label { width: calc(var(--qr) * 1.25 + 6mm); padding: 4mm 3mm; text-align: center; break-inside: avoid; page-break-inside: avoid; color: #000; font-family: system-ui, Arial, sans-serif; }
.sheet.cut .label { outline: 0.2mm dashed #999; }
.l-title { font-weight: 800; font-size: calc(var(--qr) * 0.13); line-height: 1.15; margin-bottom: 0; }
.l-qr { width: calc(var(--qr) * 1.25); height: calc(var(--qr) * 1.25); margin: 0 auto; } /* inkl. weißem Rand */
.l-qr svg { width: 100%; height: 100%; display: block; }
.l-text { font-size: max(7pt, calc(var(--qr) * 0.075)); line-height: 1.25; margin-top: 0; }
.l-no { font-size: max(6.5pt, calc(var(--qr) * 0.065)); font-weight: 650; margin-top: 1.5mm; font-family: ui-monospace, Menlo, Consolas, monospace; }
.l-addr { font-size: max(6pt, calc(var(--qr) * 0.06)); color: #333; margin-top: .5mm; }
.type-reset .l-title { background: #000; color: #fff; border-radius: 1mm; padding: .5mm 1mm; }

@media print {
  body { background: #fff; }
  .topbar, .no-print, .legal { display: none !important; }
  .sheet { box-shadow: none; padding: 0; margin: 0; width: auto; }
}

@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 12px; }
  .grid2 { grid-template-columns: 1fr; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; }
  table.list thead { display: none; }
  table.list tr { position: relative; padding: 10px 12px; border-bottom: 1px solid #eeebe5; }
  table.list tr:has(td.sel) { padding-left: 48px; }
  table.list td { border: 0; padding: 0; }
  table.list td.sel { position: absolute; left: 14px; top: 14px; }
  table.list td.no { font-size: 1.05rem; }
  table.list td.typ { display: none; }
  table.list td.st { margin-top: 6px; }
  table.list td.last { font-size: .8rem; color: var(--muted); }
  table.list td.last::before { content: "Letzte Leerung: "; }
  table.list tr.is-open { background: #fffaf0; }
  table.list tr.is-open td { background: none; }
}
