:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #6b7785;
  --line: #dfe3e8;
  --accent: #1f5fa6;
  --accent-dark: #16487d;
  --mvp: #fff8e1;
  --mvp-border: #f0c14b;
  --gruen: #2e9b4f;
  --gruen-bg: #e7f6ec;
  --gelb: #d8a200;
  --gelb-bg: #fdf6e0;
  --rot: #c0392b;
  --rot-bg: #fbeae8;
  --grau: #9aa5b1;
  --grau-bg: #eef1f4;
  --warn-bg: #fff4f0;
  --warn-border: #e8a08c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

header.app-header {
  background: var(--accent);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
header.app-header h1 { font-size: 20px; margin: 0; font-weight: 600; }
header.app-header .sub { font-size: 13px; opacity: .85; }
header.app-header nav { margin-left: auto; }
header.app-header nav a { color: #fff; text-decoration: none; font-size: 14px; opacity: .9; }
header.app-header nav a:hover { text-decoration: underline; }

main { max-width: 1100px; margin: 0 auto; padding: 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; color: var(--accent-dark); }
.card h2 .count { color: var(--muted); font-weight: 400; font-size: 13px; }

/* Dokumentdaten / Stammdaten grid */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px 16px;
}
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.field input, .field select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Eingabefelder: zweispaltige Jahre */
.unit-bar {
  display: flex; align-items: center; gap: 10px;
  background: #eef4fb; border: 1px solid #cfe0f2;
  padding: 10px 14px; border-radius: 6px; margin-bottom: 18px;
}
.unit-bar label { font-weight: 600; font-size: 14px; }
.unit-bar select { width: auto; padding: 6px 10px; }
.unit-bar .note { font-size: 12px; color: var(--muted); }

table.inputs { width: 100%; border-collapse: collapse; }
table.inputs th {
  text-align: left; font-size: 12px; color: var(--muted);
  padding: 6px 8px; border-bottom: 2px solid var(--line);
}
table.inputs th.num, table.inputs td.num { text-align: right; width: 150px; }
table.inputs td { padding: 5px 8px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
table.inputs tr.mvp td.feld { background: var(--mvp); border-left: 3px solid var(--mvp-border); }
table.inputs td .feldlabel { font-weight: 500; }
table.inputs td .feldbeschr { font-size: 11px; color: var(--muted); }
table.inputs input {
  width: 100%; text-align: right; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 5px; font-size: 14px;
  font-variant-numeric: tabular-nums;
}
table.inputs input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.badge-mvp {
  display: inline-block; font-size: 10px; font-weight: 700; color: #8a6d00;
  background: var(--mvp); border: 1px solid var(--mvp-border);
  padding: 0 5px; border-radius: 3px; margin-left: 6px; vertical-align: middle;
}

.actions { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
button.primary {
  background: var(--accent); color: #fff; border: none;
  padding: 11px 22px; font-size: 15px; border-radius: 6px; cursor: pointer; font-weight: 600;
}
button.primary:hover { background: var(--accent-dark); }
button.secondary {
  background: #fff; color: var(--accent); border: 1px solid var(--accent);
  padding: 10px 18px; font-size: 14px; border-radius: 6px; cursor: pointer;
}
button.secondary:hover { background: #eef4fb; }
.status-msg { font-size: 13px; color: var(--muted); }

/* Report */
.warn-banner {
  background: var(--warn-bg); border: 1px solid var(--warn-border);
  border-left: 5px solid var(--rot); border-radius: 6px;
  padding: 14px 16px; margin-bottom: 20px;
}
.warn-banner h3 { margin: 0 0 8px; color: var(--rot); font-size: 15px; }
.warn-banner ul { margin: 0; padding-left: 20px; font-size: 13px; }
.ok-banner {
  background: var(--gruen-bg); border: 1px solid #bfe3ca; border-left: 5px solid var(--gruen);
  border-radius: 6px; padding: 12px 16px; margin-bottom: 20px; font-size: 14px; color: #205b35;
}

.stamm { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 16px; }
.stamm .k { font-size: 12px; color: var(--muted); }
.stamm .v { font-size: 14px; font-weight: 500; }

table.kpi { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.kpi caption {
  text-align: left; font-size: 14px; font-weight: 600; color: var(--accent-dark);
  padding: 14px 0 6px;
}
table.kpi th {
  text-align: left; font-size: 12px; color: var(--muted);
  padding: 7px 10px; border-bottom: 2px solid var(--line);
}
table.kpi th.num, table.kpi td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.kpi td { padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.kpi td.label { font-weight: 500; }
table.kpi td .formel { font-size: 11px; color: var(--muted); font-family: "Consolas", monospace; }

.ampel {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  vertical-align: middle; border: 1px solid rgba(0,0,0,.15);
}
.ampel.gruen { background: var(--gruen); }
.ampel.gelb { background: var(--gelb); }
.ampel.rot { background: var(--rot); }
.ampel.grau { background: var(--grau); }
.ampel-cell { text-align: center; }
.statuslabel { font-size: 11px; color: var(--muted); font-style: italic; }
.trend.besser { color: var(--gruen); font-weight: 600; }
.trend.schlechter { color: var(--rot); font-weight: 600; }
.trend.neutral { color: var(--muted); }

.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* Uebersichtsliste */
table.liste { width: 100%; border-collapse: collapse; }
table.liste th { text-align: left; font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); }
table.liste td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.liste tr:hover td { background: #f7f9fb; cursor: pointer; }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px; }
.pill.review { background: var(--rot-bg); color: var(--rot); }
.pill.ok { background: var(--gruen-bg); color: var(--gruen); }

/* Upload / Dropzone */
.dropzone {
  border: 2px dashed #b9c6d4; border-radius: 8px; padding: 26px; text-align: center;
  background: #f7fafd; transition: background .15s, border-color .15s;
}
.dropzone.drag { background: #eaf3fc; border-color: var(--accent); }
.dropzone .dz-main { margin: 0 0 4px; font-size: 15px; }
.dropzone .dz-sub { margin: 0; font-size: 12px; color: var(--muted); }
.linklike { background: none; border: none; color: var(--accent); cursor: pointer; font-size: inherit; text-decoration: underline; padding: 0; }
#upload-status { margin-top: 10px; }
#upload-info { margin-top: 10px; font-size: 13px; }
#upload-info .doc { display: inline-block; background: #eef1f4; border-radius: 4px; padding: 2px 8px; margin: 2px 4px 2px 0; }
#upload-info .prov { color: var(--muted); }
.extract-summary { background: var(--gruen-bg); border: 1px solid #bfe3ca; border-radius: 6px; padding: 8px 12px; margin-top: 10px; font-size: 13px; color: #205b35; }

/* Confidence-Markierung an Eingabefeldern */
table.inputs td.num { position: relative; }
.conf-dot {
  position: absolute; top: 9px; right: 14px; width: 9px; height: 9px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.15); pointer-events: none;
}
.conf-dot.hoch { background: var(--gruen); }
.conf-dot.mittel { background: var(--gelb); }
.conf-dot.niedrig { background: var(--rot); }
table.inputs input.prefilled { background: #fbfdff; }
table.inputs td.feld .src { font-size: 10px; color: var(--accent-dark); margin-top: 2px; font-style: italic; }
.conf-legend { font-size: 11px; color: var(--muted); margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.conf-legend span { display: inline-flex; align-items: center; gap: 5px; }

@media print {
  header.app-header nav, .actions, .no-print { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .card { border: none; padding: 0 0 12px; margin-bottom: 12px; page-break-inside: avoid; }
  header.app-header { background: #fff; color: #000; border-bottom: 2px solid #000; padding: 8px 0; }
  table.kpi { page-break-inside: auto; }
  table.kpi tr { page-break-inside: avoid; }
  @page { size: A4; margin: 16mm; }
}
