:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --text: #1c1d1a;
  --muted: #6a6c66;
  --line: #e2e0d8;
  --accent: #1f5f3a;
  --accent-text: #ffffff;
  --warn-bg: #fff3d6;
  --warn-text: #6b4a00;
  --err-bg: #fde4e1;
  --err-text: #8a1c12;
  --ok: #1f7a3d;
  --badge-bg: #e8eee9;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131412;
    --card: #1d1f1c;
    --text: #e9e8e3;
    --muted: #a3a59e;
    --line: #33362f;
    --accent: #6cc28f;
    --accent-text: #0e1a12;
    --warn-bg: #3a3017;
    --warn-text: #f2d48a;
    --err-bg: #3d1d19;
    --err-text: #f4b3aa;
    --ok: #6cc28f;
    --badge-bg: #26302a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 1rem 0 .5rem; }
h3 { font-size: .95rem; margin: .75rem 0 .25rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.container { max-width: 860px; margin: 0 auto; padding: 12px 16px 48px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.pad { padding: .25rem 1rem .75rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Kopfzeile mit Tabs */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 0 16px;
}
.tabs { display: flex; gap: 4px; }
.tab {
  display: inline-block; padding: 14px 16px; text-decoration: none; color: var(--muted);
  border-bottom: 3px solid transparent; font-weight: 600;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.logout { margin: 0; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 12px 0; min-height: 44px; }

/* Karten, Formulare, Knöpfe */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 0; }
label { display: block; font-size: .9rem; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 1rem; }
label.check input { width: 22px; height: 22px; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 600; min-height: 44px; padding: 8px 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  text-decoration: none; cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { background: none; color: var(--err-text); border-color: var(--err-text); }
button:disabled { opacity: .5; cursor: not-allowed; }
.small-btn { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.form-grid .wide, .form-grid fieldset, .form-grid button { grid-column: 1 / -1; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid button { justify-self: start; } }
fieldset { border: 1px dashed var(--line); border-radius: 8px; display: grid; gap: 12px; }
legend { color: var(--muted); font-size: .9rem; padding: 0 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.actions form { margin: 0; }
.danger-zone { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.login { max-width: 380px; margin: 10vh auto; }
.login form { display: grid; gap: 14px; }

.flash { border-radius: 8px; padding: 10px 12px; margin: 10px 0; background: var(--badge-bg); }
.flash ul { margin: 0; padding-left: 1.2rem; }
.flash-error { background: var(--err-bg); color: var(--err-text); }
.flash-error a { color: inherit; }
.warn { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 8px 12px; margin: 8px 12px; }
.warn a { color: inherit; }
.hint { color: var(--muted); font-size: .9rem; }

/* Fakten und Tabellen */
.facts { display: grid; gap: 8px 16px; grid-template-columns: 1fr; margin: 0; }
@media (min-width: 640px) { .facts { grid-template-columns: 1fr 1fr; } }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.list th, table.list td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .8rem; color: var(--muted); font-weight: 600; }
table.list form { margin: 0; }
tr.inactive td { opacity: .55; }
.status-ok { color: var(--ok); }
.status-fehler, .status-limit { color: var(--err-text); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.provider-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.provider-row form { margin: 0; }
.pager { display: flex; gap: 10px; }

/* News-Ansicht */
.filterbar { margin: 4px 0 12px; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; overflow: hidden; }
.day-head {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline;
  padding: 14px 16px; font-weight: 700; font-size: 1.05rem; min-height: 52px;
}
.day-head::before { content: "▸"; color: var(--muted); transition: transform .15s; display: inline-block; }
.day[open] > .day-head::before { transform: rotate(90deg); }
.day[open] > .day-head { border-bottom: 1px solid var(--line); }
.day-head .count { color: var(--muted); font-weight: 400; }
.rubrik { padding: 0 16px 8px; }
.rubrik h2 { border-bottom: 2px solid var(--accent); display: inline-block; padding-bottom: 2px; }
.items { list-style: none; margin: 0; padding: 0; }
.items > li { border-bottom: 1px solid var(--line); }
.items > li:last-child { border-bottom: 0; }
.item > summary { padding: 10px 0; min-height: 44px; display: block; }
.item .headline { display: block; font-weight: 600; line-height: 1.35; }
.item .meta { display: block; font-size: .85rem; color: var(--muted); margin-top: 2px; }
.item[open] .headline { color: var(--accent); }
.item-body { padding: 0 0 12px; }
.item-body p { margin: .3rem 0; }
.badge {
  display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .04em;
  background: var(--badge-bg); color: var(--muted); border-radius: 4px; padding: 1px 6px; margin-left: 4px; vertical-align: middle;
}
a.source { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
a.source::after { content: " ↗"; }
.empty { text-align: center; }
