:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #dcdfe4;
  --text: #1c1f23;
  --muted: #5f6672;
  --accent: #2d5bd7;
  --kritisch: #c02626;
  --kritisch-bg: #fdecec;
  --warnung: #b06a00;
  --warnung-bg: #fdf3e3;
  --hinweis: #2d5bd7;
  --hinweis-bg: #eaf0fd;
  --ok: #1d7a48;
  --ok-bg: #e8f5ee;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --panel: #1e2126;
    --border: #333941;
    --text: #e8eaed;
    --muted: #9aa3b0;
    --accent: #6f9bff;
    --kritisch: #ff7b7b;
    --kritisch-bg: #3a1f1f;
    --warnung: #f0b45e;
    --warnung-bg: #3a2e1a;
    --hinweis: #7fa8ff;
    --hinweis-bg: #1f2a3f;
    --ok: #6ed69a;
    --ok-bg: #1c3328;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 20px 80px; }

header.top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
header.top h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
header.top .sub { color: var(--muted); font-size: 13px; }

button {
  font: inherit; cursor: pointer; border-radius: 6px; padding: 7px 14px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { opacity: .9; color: #fff; }
button.link {
  border: none; background: none; color: var(--accent); padding: 2px 4px;
  text-decoration: underline;
}

/* ---------------------------------------------------------------- Urteil */
.verdict {
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px;
  border: 1px solid var(--border); background: var(--panel);
  border-left: 5px solid var(--muted);
}
.verdict.kritisch { border-left-color: var(--kritisch); background: var(--kritisch-bg); }
.verdict.warnung  { border-left-color: var(--warnung);  background: var(--warnung-bg); }
.verdict.ok       { border-left-color: var(--ok);       background: var(--ok-bg); }
.verdict h2 { margin: 0 0 4px; font-size: 18px; }
.verdict p { margin: 0; color: var(--muted); }
.verdict .money {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 15px;
}
.verdict .money strong { font-size: 19px; }

/* ---------------------------------------------------------------- Dropzone */
.drop {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 34px 20px; text-align: center; background: var(--panel);
  transition: border-color .15s, background .15s; margin-bottom: 20px;
}
.drop.hot { border-color: var(--accent); background: var(--hinweis-bg); }
.drop p { margin: 0 0 4px; font-weight: 600; }
.drop small { color: var(--muted); }
.drop input { display: none; }

.uploadlog {
  margin-top: 14px; font-size: 13px; text-align: left;
  max-height: 220px; overflow-y: auto;
}
.uploadlog div { padding: 3px 0; border-bottom: 1px solid var(--border); }
.uploadlog .warn { color: var(--warnung); }

/* ---------------------------------------------------------------- Kacheln */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px;
}
.tile .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tile .value { font-size: 22px; font-weight: 600; margin-top: 3px; }
.tile .value.kritisch { color: var(--kritisch); }
.tile .value.ok { color: var(--ok); }
.tile .hint { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ Tabs */
nav.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
nav.tabs button {
  border: none; background: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 9px 14px; color: var(--muted);
}
nav.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
nav.tabs button:hover { color: var(--text); }

section.tab { display: none; }
section.tab.active { display: block; }

/* --------------------------------------------------------------- Befunde */
.finding {
  background: var(--panel); border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: var(--radius); margin-bottom: 10px; overflow: hidden;
}
.finding.kritisch { border-left-color: var(--kritisch); }
.finding.warnung  { border-left-color: var(--warnung); }
.finding.hinweis  { border-left-color: var(--hinweis); }
.finding.ok       { border-left-color: var(--ok); }

.finding > summary {
  padding: 12px 16px; cursor: pointer; display: flex; gap: 10px;
  align-items: baseline; list-style: none;
}
.finding > summary::-webkit-details-marker { display: none; }
.finding > summary:hover { background: rgba(127,127,127,.05); }
.finding .badge {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px; white-space: nowrap;
}
.badge.kritisch { background: var(--kritisch-bg); color: var(--kritisch); }
.badge.warnung  { background: var(--warnung-bg);  color: var(--warnung); }
.badge.hinweis  { background: var(--hinweis-bg);  color: var(--hinweis); }
.badge.ok       { background: var(--ok-bg);       color: var(--ok); }
.finding .title { font-weight: 600; flex: 1; }
.finding .amount { color: var(--muted); font-size: 13px; white-space: nowrap; }
.finding .body { padding: 0 16px 14px 16px; }
.finding .body pre {
  white-space: pre-wrap; font: inherit; margin: 0 0 10px;
  color: var(--text);
}
.finding .law {
  display: inline-block; font-size: 12px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 7px; margin-bottom: 8px;
}
.finding .action {
  background: var(--hinweis-bg); border-radius: 6px; padding: 9px 12px;
  font-size: 14px; margin-top: 8px;
}

/* -------------------------------------------------------------- Protokoll */
.checklist { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.checklist .row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 15px; border-bottom: 1px solid var(--border);
}
.checklist .row:last-child { border-bottom: none; }
.checklist .state {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  min-width: 92px; text-align: center; padding: 2px 6px; border-radius: 4px;
}
.state.bestanden { background: var(--ok-bg); color: var(--ok); }
.state.kritisch { background: var(--kritisch-bg); color: var(--kritisch); }
.state.warnung { background: var(--warnung-bg); color: var(--warnung); }
.state.hinweis { background: var(--hinweis-bg); color: var(--hinweis); }
.state.nicht_geprueft { background: var(--bg); color: var(--muted); }
.checklist .desc { flex: 1; }
.checklist .desc small { display: block; color: var(--muted); }
.checklist h3 { margin: 0; padding: 11px 15px; background: var(--bg); font-size: 13px;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--border); }

/* ---------------------------------------------------------------- Tabellen */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--bg); font-size: 12px; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: none; }
td.neg { color: var(--kritisch); font-weight: 600; }
td.pos { color: var(--ok); }
tr.problem { background: var(--kritisch-bg); }
tr.fehlt td { color: var(--muted); font-style: italic; }

/* --------------------------------------------------------------- Formular */
.form { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.form .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.form small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 2px; }
.form input, .form select {
  width: 100%; font: inherit; padding: 7px 9px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.form .actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.saved { color: var(--ok); font-size: 13px; }

h2.section { font-size: 16px; margin: 24px 0 10px; }
h2.section:first-child { margin-top: 0; }
p.note { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

.docs { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.docs .row { display: flex; gap: 12px; align-items: center; padding: 8px 15px; border-bottom: 1px solid var(--border); font-size: 14px; }
.docs .row:last-child { border-bottom: none; }
.docs .kind { font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 7px; color: var(--muted); }
.docs .name { flex: 1; overflow: hidden; text-overflow: ellipsis; }

textarea.report {
  width: 100%; min-height: 460px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
}

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.disclaimer {
  margin-top: 30px; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--panel);
  color: var(--muted); font-size: 13px;
}
