:root {
  --bg: #f3f5f8; --panel: #ffffff; --text: #18202c; --muted: #647084; --line: #e2e6ed;
  --line-strong: #cfd6e0; --head: #17233a; --head-text: #f2f5fa;
  --accent: #2459c4; --accent-hover: #1c479d; --on-accent: #ffffff; --accent-soft: #e8effc;
  --ok-bg: #e2f4e8; --ok-text: #14653a; --open-bg: #fdefd9; --open-text: #8a4a06;
  --error-bg: #fdecea; --error: #9b1c1c; --row-hover: #f5f8fd;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c; --panel: #1a2029; --text: #e7eaf0; --muted: #98a3b5; --line: #2a323f;
    --line-strong: #3a4454; --head: #0c1017; --head-text: #e7eaf0;
    --accent: #7eaaff; --accent-hover: #a3c2ff; --on-accent: #0d1420; --accent-soft: #1d2a44;
    --ok-bg: #173524; --ok-text: #86dba5; --open-bg: #3a2a12; --open-text: #f2bd76;
    --error-bg: #3a1d1d; --error: #ffb4ab; --row-hover: #1f2733;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Kopfzeile */
header.top { background: var(--head); color: var(--head-text); }
.top-inner { max-width: 1560px; margin: 0 auto; padding: 10px 20px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--head-text);
  font-weight: 650; font-size: 17px; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: #3b74e6; color: #fff; font-weight: 700; font-size: 15px; }
.user { display: flex; gap: 14px; align-items: center; margin: 0; }
.user-name { color: #b9c3d4; font-size: 14px; }

main { max-width: 1560px; margin: 0 auto; padding: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 4px 2px 16px; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 650; margin: 0; letter-spacing: -.01em; overflow-wrap: anywhere; }
h2 { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 20px 0 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.count { color: var(--muted); margin: 2px 0 0; font-size: 14px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.error { background: var(--error-bg); color: var(--error); padding: 9px 12px; border-radius: 8px; margin: 0; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Eingaben und Knöpfe */
input, select, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=search], input[type=date], select {
  height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--panel); max-width: 100%; }
input:hover, select:hover { border-color: var(--muted); }
button, .btn { height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--panel); cursor: pointer; display: inline-flex; align-items: center; font-weight: 550; }
.btn { color: var(--text); }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.off { color: var(--muted); opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ghost { background: transparent; border-color: rgba(255, 255, 255, .25); color: var(--head-text);
  height: 30px; padding: 0 12px; font-size: 14px; font-weight: 500; }
button.ghost:hover { border-color: rgba(255, 255, 255, .6); }

/* Anmeldung */
.login { max-width: 360px; margin: 9vh auto 0; padding: 28px; display: grid; gap: 16px; }
.login label { display: grid; gap: 5px; font-size: 14px; color: var(--muted); }
.login input { color: var(--text); width: 100%; height: 40px; }
.login button { justify-content: center; height: 40px; }

/* Filter */
.filter { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: end; padding: 14px 16px; margin-bottom: 16px; }
.filter > label { display: grid; gap: 4px; font-size: 12px; font-weight: 550; color: var(--muted); }
.filter > label > * { font-size: 15px; font-weight: 400; color: var(--text); }
.f-search { flex: 1 1 240px; min-width: 200px; }
.f-search input { width: 100%; }
.f-supplier select { width: 230px; }
.chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips legend { font-size: 12px; font-weight: 550; color: var(--muted); padding: 0; margin-bottom: 4px; }
.chips label { position: relative; cursor: pointer; }
.chips input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chips span { display: inline-flex; align-items: center; height: 36px; padding: 0 12px; border-radius: 18px;
  border: 1px solid var(--line-strong); font-size: 14px; }
.chips input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter .actions { display: flex; gap: 14px; align-items: center; margin-left: auto; }

/* Liste */
.table-wrap { overflow-x: auto; }
table.list { border-collapse: collapse; width: 100%; font-size: 14px; }
table.list th, table.list td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
table.list th.num, table.list td.num { text-align: right; }
table.list thead th { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); white-space: nowrap; background: color-mix(in srgb, var(--bg) 60%, var(--panel)); }
table.list thead th:first-child { border-top-left-radius: 12px; }
table.list thead th:last-child { border-top-right-radius: 12px; }
table.list tbody tr:last-child td { border-bottom: none; }
table.list tbody tr:hover { background: var(--row-hover); }
td.who { max-width: 230px; overflow-wrap: anywhere; }
.supplier { font-weight: 600; }
.sender { color: var(--muted); }
td.date { color: var(--muted); font-variant-numeric: tabular-nums; }
td.subject { min-width: 220px; overflow-wrap: anywhere; }
td.subject a { font-weight: 550; }
td.number { overflow-wrap: anywhere; max-width: 180px; }
.sub { display: block; color: var(--muted); font-size: 13px; }
td.status { white-space: nowrap; }
td.status .pill + .pill { margin-left: 4px; }
td.amount { font-weight: 650; font-size: 15px; }
.cur { color: var(--muted); font-weight: 500; font-size: 12px; }
td.att { color: var(--muted); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  line-height: 1.6; white-space: nowrap; }
.pill b { font-weight: 500; opacity: .85; font-variant-numeric: tabular-nums; }
.pill.ok { background: var(--ok-bg); color: var(--ok-text); }
.pill.open { background: var(--open-bg); color: var(--open-text); }

.pager { display: flex; gap: 8px; justify-content: center; align-items: center; margin: 18px 0 8px; flex-wrap: wrap; }
.pager .pos { color: var(--muted); padding: 0 10px; font-size: 14px; }

/* Detail: Beleg links, Angaben rechts (wie im Altsystem) */
.back { font-size: 14px; display: inline-block; margin-bottom: 6px; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .detail { grid-template-columns: minmax(0, 1fr); } }
.view { padding: 14px 16px 16px; min-width: 0; }
.fields { padding: 18px; position: sticky; top: 16px; }
@media (max-width: 1000px) { .fields { position: static; } }
.fields .status { display: flex; gap: 6px; flex-wrap: wrap; }
.bigamount { font-size: 28px; font-weight: 700; margin: 10px 0 16px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.bigamount .cur { font-size: 15px; }
.bigamount .muted { font-size: 16px; font-weight: 400; }
dl { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 7px 12px; margin: 0; font-size: 14px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; min-height: 1.5em; font-weight: 550; }
.remarks { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font-size: 14px; }

.tabs { display: flex; flex-wrap: wrap; gap: 2px 4px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 12px; color: var(--muted); font-weight: 550; font-size: 14px; border-bottom: 2px solid transparent;
  margin-bottom: -1px; overflow-wrap: anywhere; border-radius: 6px 6px 0 0; }
.tabs a:hover { color: var(--text); text-decoration: none; background: var(--row-hover); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.fileinfo { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--muted); font-size: 13px; margin: 0 0 10px; overflow-wrap: anywhere; }
iframe.doc { display: block; width: 100%; height: calc(100vh - 250px); min-height: 520px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; }
iframe.mailframe { height: calc(100vh - 340px); min-height: 420px; }
.doc-img { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.mailhead { grid-template-columns: 70px minmax(0, 1fr); margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.mailhead dd { font-weight: 400; }
pre.mail { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font: 13.5px/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--muted); font-size: 14px; }
