/* E-Rechnung · AlfredsLAB – Oberfläche im Stil der macOS-Apps (Seitenleiste · Liste · Inhalt), Farben und Schrift wie alfredsmail */
:root {
  --bg: #ffffff;
  --side: #ffffff;
  --pane: #F5F6F7;
  --group: #ffffff;
  --fill: rgba(120, 120, 128, .12);
  --fill-2: rgba(120, 120, 128, .08);
  --sep: rgba(60, 60, 67, .14);
  --text: #1F2328;
  --text-2: #5C6670;
  --text-3: #7d868f;
  --brand: #6DB84A;             /* AlfredsLAB-Grün: Flächen und Knöpfe */
  --blue: #4E9A2F;              /* Akzent für Schrift und Symbole (dunkleres Grün, gut lesbar) */
  --blue-soft: #EEF7E9;
  --graphite: #33373d;
  --graphite-soft: rgba(51, 55, 61, .09);
  --green: #248a3d;
  --green-soft: rgba(52, 199, 89, .14);
  --red: #b0000e;
  --red-soft: rgba(255, 59, 48, .11);
  --orange: #c93400;
  --orange-soft: rgba(255, 149, 0, .15);
  --purple: #8944ab;
  --purple-soft: rgba(175, 82, 222, .12);
  --sel: #33373d;
  --sel-ink: #ffffff;
  --shadow: 0 0 0 .5px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .05);
  --win-shadow: 0 0 0 .5px rgba(0, 0, 0, .2), 0 24px 70px rgba(0, 0, 0, .3);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e1e;
    --side: #1e1e1e;
    --pane: #161618;
    --group: #232325;
    --fill: rgba(120, 120, 128, .28);
    --fill-2: rgba(120, 120, 128, .18);
    --sep: rgba(84, 84, 88, .55);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #7c7c80;
    --brand: #5FAE3D;
    --blue: #86CF63;
    --blue-soft: rgba(109, 184, 74, .16);
    --graphite: #d5d7da;
    --graphite-soft: rgba(213, 215, 218, .14);
    --green: #30d158;
    --green-soft: rgba(48, 209, 88, .16);
    --red: #ff453a;
    --red-soft: rgba(255, 69, 58, .17);
    --orange: #ff9f0a;
    --orange-soft: rgba(255, 159, 10, .17);
    --purple: #bf5af2;
    --purple-soft: rgba(191, 90, 242, .17);
    --sel: #4a4f57;
    --shadow: 0 0 0 .5px rgba(255, 255, 255, .08);
    --win-shadow: 0 0 0 .5px rgba(255, 255, 255, .15), 0 24px 70px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); overflow: hidden;
  font: 13.5px/1.45 "Nunito", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; letter-spacing: -.005em;
}
button { font: inherit; color: inherit; }
.muted { color: var(--text-2); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; letter-spacing: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: .5px solid var(--sep);
  border-radius: 4px; padding: 5px 9px; min-height: 30px; box-shadow: 0 .5px 1px rgba(0,0,0,.05);
}
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent); outline-offset: 0; border-color: var(--blue); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 50%, transparent); outline-offset: 1px; }

.btn {
  border: 0; border-radius: 4px; padding: 7px 15px; min-height: 32px; cursor: pointer; font-weight: 500;
  background: var(--fill); color: var(--text); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: color-mix(in srgb, var(--fill) 100%, var(--text) 6%); }
.btn.primary { background: var(--brand); color: #fff; font-weight: 800; }
.btn.primary:hover { background: var(--blue); filter: none; }
.btn.green { background: var(--green); color: #fff; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.plain { background: none; color: var(--blue); padding-inline: 8px; }
.btn.plain:hover { background: var(--blue-soft); }
.btn.big { padding: 9px 20px; min-height: 38px; font-size: 14px; font-weight: 600; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; text-decoration: none; font-size: 12.5px; }
.linkbtn:hover { text-decoration: underline; }
.iconbtn {
  border: 0; background: none; color: var(--text-2); width: 30px; height: 30px; border-radius: 4px;
  display: grid; place-items: center; cursor: pointer; position: relative; flex: none;
}
.iconbtn:hover, .iconbtn[aria-expanded="true"] { background: var(--fill); color: var(--text); }
.iconbtn i { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.tbtn {
  border: 0; background: none; color: var(--text); padding: 5px 10px; border-radius: 4px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.tbtn:hover { background: var(--fill); }
.tbtn svg { color: var(--blue); }
.tbtn.danger-t { color: var(--red); }
.tbtn.danger-t svg { color: var(--red); }
.tbtn:disabled { opacity: .4; cursor: default; }

/* Drei Spalten */
.app { display: grid; grid-template-columns: 228px 360px 1fr; grid-template-rows: minmax(0, 1fr); height: 100vh; }

/* Seitenleiste */
.sidebar {
  background: var(--side); border-right: .5px solid var(--sep); display: flex; flex-direction: column;
  padding: 14px 10px 12px; overflow: hidden; min-height: 0;
}
/* Logo, Ablagefläche und Menü bleiben stehen – nur die Fächer scrollen */
.sidebar > .brand, .sidebar > .add, .sidebar > .side-foot { flex: none; }
.brand { display: flex; justify-content: center; padding: 6px 8px 18px; }
/* Marke wie alfredsmail: Wortmarke, Produktname zentriert darunter */
.marke { display: inline-flex; flex-direction: column; align-items: center; gap: 5px; line-height: 1; }
.marke .wortmarke { height: 17px; width: auto; display: block; }
.marke b { font-size: 14px; font-weight: 800; letter-spacing: .02em; color: var(--text); }
@media (prefers-color-scheme: dark) { .marke .wortmarke { filter: invert(1) hue-rotate(180deg) brightness(1.1); } }
.logo {
  width: 30px; height: 30px; border-radius: 4px; display: grid; place-items: center; flex: none;
  background: var(--blue); color: #fff; font-weight: 700; font-size: 12px;
}
.brand b { display: block; font-size: 13.5px; }
.brand div span { display: block; font-size: 11.5px; color: var(--text-2); }
.add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; margin: 0 4px 16px;
  padding: 20px 12px 18px; min-height: 140px; text-align: center; cursor: pointer;
  border: 2px dashed color-mix(in srgb, var(--blue) 55%, transparent); border-radius: 6px;
  background: var(--blue-soft); color: var(--blue); transition: background .15s, border-color .15s;
}
.add svg { margin-bottom: 4px; }
.add b { font-size: 14px; font-weight: 800; }
.add span { font-size: 12px; color: var(--text-2); }
.add small { font-size: 10.5px; color: var(--text-3); margin-top: 4px; }
.add:hover, body.dragging .add { background: color-mix(in srgb, var(--blue-soft) 100%, var(--blue) 10%); border-color: var(--blue); }
.boxes { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.boxes h4 { margin: 14px 10px 4px; font-size: 11px; font-weight: 600; color: var(--text-3); letter-spacing: .02em; }
.boxes h4:first-child { margin-top: 0; }
.box {
  display: flex; align-items: center; gap: 9px; padding: 5px 10px; border-radius: 4px; border: 0; background: none;
  text-align: left; cursor: pointer; width: 100%; min-height: 30px;
}
.box:hover { background: var(--fill-2); }
.box.active { background: var(--fill); }
.box .ico { width: 18px; display: grid; place-items: center; color: var(--blue); flex: none; }
.box .ico.red { color: var(--red); } .box .ico.orange { color: var(--orange); } .box .ico.green { color: var(--green); }
.box .ico.grey { color: var(--text-3); }
.box .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.box .cnt { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.box .cnt.hot { background: var(--red); color: #fff; border-radius: 999px; padding: 0 7px; font-weight: 600; font-size: 11.5px; }
.box.main .lbl { font-weight: 600; }
.side-foot { border-top: .5px solid var(--sep); margin-top: 12px; padding: 12px 4px 0; display: flex; flex-direction: column; gap: 10px; }
.who span { display: block; font-size: 11px; color: var(--text-3); margin-bottom: 3px; }
.who input { width: 100%; }
.who input.missing { border-color: var(--orange); background: var(--orange-soft); }

/* Liste */
.listpane { background: var(--bg); border-right: .5px solid var(--sep); display: flex; flex-direction: column; min-width: 0; }
.list-top { padding: 16px 14px 10px; border-bottom: .5px solid var(--sep); }
.list-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.list-title h1 { font-size: 21px; margin: 0; letter-spacing: -.01em; font-weight: 800; }
.list-title .muted { font-size: 12px; white-space: nowrap; }
.box-hint { margin: 2px 0 10px; color: var(--text-2); font-size: 12px; }
.searchrow { display: flex; gap: 6px; align-items: center; }
.search { position: relative; flex: 1; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search input { width: 100%; padding-left: 29px; background: var(--fill-2); border-color: transparent; box-shadow: none; }
.filterbox {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin-top: 10px; padding: 10px;
  background: var(--pane); border-radius: 6px;
}
.filterbox label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--text-2); }
.filterbox .fb-actions { grid-column: 1 / -1; display: flex; justify-content: space-between; }
.upload-results { display: flex; flex-direction: column; }
.upload-results .res {
  display: flex; gap: 8px; align-items: center; padding: 7px 14px; font-size: 12.5px; cursor: pointer;
  background: var(--graphite-soft); border-bottom: .5px solid var(--sep);
}
.upload-results .res span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows { list-style: none; margin: 0; padding: 4px 8px 20px; overflow: auto; flex: 1; outline: none; }
.row {
  display: grid; grid-template-columns: 12px 1fr auto; column-gap: 8px; row-gap: 1px; padding: 9px 10px 10px;
  border-radius: 4px; cursor: default; position: relative;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 30px; right: 10px; border-top: .5px solid var(--sep); }
.row.sel + .row::before, .row.sel::before { display: none; }
.row:hover { background: var(--fill-2); }
.row.sel { background: var(--sel); color: var(--sel-ink); }
.row .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; grid-row: 1 / 3; }
.row .who2 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.row .meta { grid-column: 2; color: var(--text-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .apo { color: var(--text-3); font-size: 12px; text-align: right; }
.row .chips { grid-column: 2 / 4; display: flex; gap: 5px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.row.sel .meta, .row.sel .apo { color: rgba(255,255,255,.85); }
.row.sel .chip { background: rgba(255,255,255,.22) !important; color: #fff !important; }
.empty { text-align: center; color: var(--text-2); padding: 40px 24px; margin: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 1px 7px;
  border-radius: 3px; white-space: nowrap; background: var(--fill); color: var(--text-2);
}
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.orange { background: var(--orange-soft); color: var(--orange); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.blue { background: var(--graphite-soft); color: var(--graphite); }
.chip.purple { background: var(--purple-soft); color: var(--purple); }
.c-red { background: var(--red); } .c-orange { background: #ff9500; } .c-green { background: #34c759; }
.c-blue { background: var(--graphite); } .c-grey { background: var(--text-3); } .c-purple { background: #af52de; }

/* Inhalt */
.detailpane { background: var(--pane); min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.placeholder { margin: auto; text-align: center; color: var(--text-3); padding: 24px; max-width: 360px; }
.placeholder p { font-size: 17px; font-weight: 600; color: var(--text-2); margin: 10px 0 4px; }
#d-content { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.d-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 9px 16px; background: var(--bg);
  border-bottom: .5px solid var(--sep);
}
.d-toolbar .grow { flex: 1; }
.d-toolbar .back { display: none; font-size: 24px; color: var(--blue); }
.seg { display: inline-flex; background: var(--fill); border-radius: 4px; padding: 2px; gap: 2px; }
.seg button {
  border: 0; background: none; padding: 4px 14px; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 12.5px;
  color: var(--text);
}
.seg button.active { background: var(--bg); box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.06); }
.seg.small button { padding: 3px 11px; font-size: 12px; }
.d-scroll { flex: 1; overflow: auto; }
.d-scroll > section { max-width: 980px; margin: 0 auto; padding: 22px 28px 60px; }

/* Kopf der Rechnung */
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.inv-head .kick { font-size: 12px; color: var(--text-2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inv-head h2 { font-size: 25px; margin: 4px 0 2px; letter-spacing: -.01em; line-height: 1.2; font-weight: 800; }
.inv-head .sub { color: var(--text-2); font-size: 14px; }
.inv-head .amount { text-align: right; flex: none; }
.inv-head .amount b { display: block; font-size: 26px; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.inv-head .amount span { color: var(--text-2); font-size: 12.5px; }
.inv-head .amount .skonto { color: var(--green); font-weight: 600; }

/* Fortschritt */
.steps { display: flex; margin: 20px 0 16px; padding: 0; list-style: none; counter-reset: s; }
.steps li { flex: 1; position: relative; text-align: center; font-size: 11.5px; color: var(--text-3); padding-top: 24px; }
.steps li::before {
  content: ""; position: absolute; top: 4px; left: 50%; transform: translateX(-50%); width: 14px; height: 14px; border-radius: 50%;
  background: var(--pane); border: 2px solid var(--sep); z-index: 1;
}
.steps li::after { content: ""; position: absolute; top: 10px; left: -50%; width: 100%; height: 2px; background: var(--sep); }
.steps li:first-child::after { display: none; }
.steps li.done { color: var(--text-2); }
.steps li.done::before { background: var(--green); border-color: var(--green); }
.steps li.done::after, .steps li.now::after { background: var(--green); }
.steps li.now { color: var(--text); font-weight: 600; }
.steps li.now::before { background: var(--bg); border: 4px solid var(--blue); }
.steps li.stop::before { background: var(--red); border-color: var(--red); }
.steps li.stop { color: var(--red); font-weight: 600; }

/* Nächster Schritt */
.next {
  background: var(--group); border-radius: 6px; box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 22px;
  border-left: 4px solid var(--blue); display: grid; grid-template-columns: 1fr auto; gap: 6px 20px; align-items: center;
}
.next.red { border-left-color: var(--red); } .next.orange { border-left-color: #ff9500; } .next.green { border-left-color: #34c759; }
.next.grey { border-left-color: var(--text-3); }
.next .lab { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--blue); }
.next.red .lab { color: var(--red); } .next.orange .lab { color: var(--orange); } .next.green .lab { color: var(--green); }
.next.grey .lab { color: var(--text-3); }
.next h3 { margin: 2px 0 2px; font-size: 16px; letter-spacing: -.01em; }
.next p { margin: 0; color: var(--text-2); }
.next .acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.next .more { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; padding-top: 10px; border-top: .5px solid var(--sep); }
.next .inline { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

/* Gruppierte Listen (wie Systemeinstellungen) */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.grp { margin-bottom: 22px; min-width: 0; }
.grp > h4 { margin: 0 0 6px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.grp > .box2 { background: var(--group); border-radius: 6px; box-shadow: var(--shadow); overflow: hidden; }
.grp > .foot { margin: 6px 12px 0; font-size: 12px; color: var(--text-2); }
.li {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 38px; padding: 7px 14px;
  position: relative;
}
.li + .li::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; border-top: .5px solid var(--sep); }
.li .k { color: var(--text); white-space: nowrap; flex: none; }
.li .v { color: var(--text-2); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .v b { color: var(--text); font-weight: 600; }
.li.total .k, .li.total .v { color: var(--text); font-weight: 650; font-size: 14.5px; }
.li.warn .v { color: var(--red); font-weight: 600; }
.li.multi { align-items: flex-start; }
.li.multi .v { white-space: normal; }
.li select, .li input { border: 0; box-shadow: none; background: transparent; text-align: right; color: var(--text-2); padding: 4px 0; min-height: 26px; }
.li select { text-align-last: right; cursor: pointer; color: var(--blue); }
.li input { width: 60%; }
.li input:focus { outline: 0; color: var(--text); }
.li.edit:focus-within { background: var(--blue-soft); }
.li .ok { color: var(--green); font-weight: 600; }

/* Positionen */
table.lines { width: 100%; border-collapse: collapse; font-size: 13px; }
.lines th { text-align: left; color: var(--text-2); font-weight: 500; font-size: 11.5px; padding: 9px 14px 7px; border-bottom: .5px solid var(--sep); white-space: nowrap; }
.lines td { padding: 9px 14px; border-bottom: .5px solid var(--sep); vertical-align: top; }
.lines tr:last-child td { border-bottom: 0; }
.lines .art { font-weight: 500; }
.lines .art small { display: block; color: var(--text-2); font-weight: 400; font-size: 12px; }
.lines .no { color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines tfoot td { font-weight: 600; border-top: .5px solid var(--sep); }

details.archiv > summary { cursor: pointer; color: var(--text-2); font-size: 12.5px; margin: 0 0 6px 12px; font-weight: 600; list-style: none; }
details.archiv > summary::before { content: "›"; display: inline-block; margin-right: 6px; transition: transform .15s; }
details.archiv[open] > summary::before { transform: rotate(90deg); }
.hash { font: 11px ui-monospace, Menlo, monospace; color: var(--text-2); word-break: break-all; white-space: normal !important; }

/* Hinweisbanner */
.banner { display: flex; gap: 12px; padding: 12px 16px; border-radius: 6px; margin-bottom: 14px; background: var(--orange-soft); }
.banner.red { background: var(--red-soft); }
.banner .bi { font-size: 18px; line-height: 1.2; }
.banner b { display: block; }
.banner p { margin: 2px 0 0; color: var(--text-2); }

/* Prüfbericht und Verlauf */
.result { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.result .ring { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 22px; font-weight: 700; flex: none; }
.result h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.msg { display: grid; grid-template-columns: 70px 1fr; gap: 4px 12px; padding: 10px 14px; position: relative; font-size: 13px; }
.msg + .msg::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; border-top: .5px solid var(--sep); }
.msg .rid { font: 11.5px ui-monospace, Menlo, monospace; color: var(--text-2); }
.lvl-error { color: var(--red); font-weight: 600; }
.lvl-warning { color: var(--orange); font-weight: 600; }
.lvl-information { color: var(--graphite); font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding: 11px 14px; position: relative; }
.timeline li + li::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; border-top: .5px solid var(--sep); }
.timeline .when { color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.timeline .det { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.timeline pre { margin: 4px 0 0; font-size: 11.5px; white-space: pre-wrap; color: var(--text-3); }

/* Fenster für das Original */
.win-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .28); display: grid; place-items: center; animation: fade .15s; }
.win {
  width: min(1100px, 94vw); height: 92vh; background: var(--bg); border-radius: 6px; box-shadow: var(--win-shadow);
  display: flex; flex-direction: column; overflow: hidden; animation: pop .18s ease-out;
}
.win-bar {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 8px 10px 8px 18px;
  background: var(--side); border-bottom: .5px solid var(--sep);
}
.win-title { text-align: left; min-width: 0; }
.win-title b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-title span { font-size: 11.5px; color: var(--text-2); }
.win-tools { display: flex; gap: 4px; align-items: center; }
.win-note { padding: 10px 16px; background: var(--graphite-soft); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.win-note b { white-space: nowrap; }
.win-body { flex: 1; background: #fff; min-height: 0; }
.win-body iframe, .win-body img { width: 100%; height: 100%; border: 0; display: block; }
.win-body img { object-fit: contain; background: var(--pane); }
.win-body .nothing { padding: 60px 24px; text-align: center; color: var(--text-2); background: var(--pane); height: 100%; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }

/* Dialog, Drag, Toast */
dialog {
  border: 0; border-radius: 6px; padding: 22px; width: min(440px, 92vw); background: var(--bg); color: var(--text);
  box-shadow: var(--win-shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, .3); }
dialog h3 { margin: 0 0 4px; font-size: 15px; }
dialog p { margin: 0; color: var(--text-2); }
dialog textarea { width: 100%; margin: 12px 0 16px; resize: vertical; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 0; }
.dragcover {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: color-mix(in srgb, var(--blue) 16%, transparent); backdrop-filter: blur(3px);
}
.dragcover div { background: var(--bg); padding: 22px 34px; border-radius: 6px; font-weight: 600; font-size: 15px; box-shadow: var(--win-shadow); border: 2px dashed var(--blue); }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60; max-width: 90vw;
  background: color-mix(in srgb, var(--text) 88%, transparent); color: var(--bg); padding: 10px 18px; border-radius: 6px;
  backdrop-filter: blur(10px); box-shadow: var(--win-shadow); font-weight: 500;
}
.toast.err { background: var(--red); color: #fff; }

/* Schmalere Fenster */
@media (max-width: 1180px) {
  .app { grid-template-columns: 200px 320px 1fr; }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; grid-template-rows: none; height: auto; min-height: 100vh; }
  .sidebar { border-right: 0; border-bottom: .5px solid var(--sep); overflow: visible; }
  .boxes { flex-direction: row; flex-wrap: wrap; gap: 4px; overflow: visible; }
  .boxes h4 { width: 100%; margin: 6px 6px 0; }
  .box { width: auto; }
  .side-foot { flex-direction: row; align-items: end; justify-content: space-between; }
  .rows { overflow: visible; }
  .detailpane { position: fixed; inset: 0; z-index: 30; display: none; }
  body.detail-open .detailpane { display: flex; }
  .d-toolbar .back { display: grid; }
  .d-scroll > section { padding: 16px 16px 48px; }
  .inv-head { flex-direction: column; gap: 8px; }
  .inv-head .amount { text-align: left; }
  .next { grid-template-columns: 1fr; }
  .next .acts { justify-content: flex-start; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .win { width: 100vw; height: 100vh; border-radius: 0; }
  .win-bar { grid-template-columns: 1fr auto; }
  .win-bar .xclose { grid-row: 1; grid-column: 2; }
  .win-tools { grid-column: 1 / -1; justify-content: center; flex-wrap: wrap; }
}

/* Rechnungsbild (aus den XML-Daten) */
.paper-wrap { height: 100%; overflow: auto; background: var(--pane); padding: 28px 16px 48px; }
.paper {
  max-width: 820px; margin: 0 auto; background: #fff; color: #000; padding: 48px 56px 36px; box-shadow: 0 1px 4px rgba(0,0,0,.12);
  font-size: 12.5px; line-height: 1.5; min-height: 1000px; display: flex; flex-direction: column;
}
.pp-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid #e30613; padding-bottom: 14px; }
.pp-from b { display: block; font-size: 17px; font-weight: 800; }
.pp-from span { color: #707070; font-size: 11.5px; }
.pp-kind { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #e30613; }
.pp-addr { display: flex; justify-content: space-between; gap: 30px; margin: 34px 0 30px; }
.pp-to { font-size: 13px; }
.pp-to small { display: block; font-size: 9.5px; color: #707070; border-bottom: .5px solid #ccc; margin-bottom: 8px; padding-bottom: 2px; }
.pp-meta td { padding: 1px 0; }
.pp-meta td:first-child { color: #707070; padding-right: 16px; }
.pp-meta td:last-child { font-weight: 700; text-align: right; }
.pp-title { font-size: 21px; font-weight: 800; margin: 0 0 10px; }
.pp-note { margin: 0 0 6px; color: #33373d; }
.pp-lines { width: 100%; border-collapse: collapse; margin-top: 14px; }
.pp-lines th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: #707070; font-weight: 700; padding: 6px 6px; border-bottom: 1.5px solid #33373d; }
.pp-lines td { padding: 7px 6px; border-bottom: .5px solid #ddd; vertical-align: top; }
.pp-lines td small { display: block; color: #707070; font-size: 11px; }
.pp-lines .num, .pp-sum .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pp-sum { margin: 14px 0 0 auto; border-collapse: collapse; min-width: 300px; }
.pp-sum td { padding: 3px 6px; }
.pp-sum .pp-total td { font-weight: 800; font-size: 14px; border-top: 1.5px solid #33373d; padding-top: 6px; }
.pp-pay { margin-top: 30px; padding: 12px 14px; background: #f3f3f3; border-left: 3px solid #e30613; }
.pp-pay p { margin: 4px 0 0; }
.pp-foot { margin-top: auto; padding-top: 30px; display: flex; flex-wrap: wrap; gap: 4px 18px; color: #707070; font-size: 10.5px; border-top: .5px solid #ccc; }
@media (max-width: 900px) { .paper { padding: 28px 22px; } .pp-addr { flex-direction: column; } }

/* Angemeldeter Mitarbeiter */
.me { display: flex; align-items: center; gap: 9px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--graphite); color: #fff; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; flex: none; }
.me b { display: block; font-size: 13px; }
.me div span { display: block; font-size: 11.5px; color: var(--text-2); }
.foot-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 4px; }
.fbtn {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px 6px; border: 0; border-radius: 4px;
  background: var(--fill-2); color: var(--text-2); cursor: pointer; font-size: 10.5px; font-weight: 700;
}
.fbtn svg { color: var(--graphite); }
.fbtn:hover { background: var(--fill); color: var(--text); }
.fbtn:hover svg { color: var(--blue); }
.fbtn[hidden] + .fbtn { grid-column: auto; }
.norights { color: var(--orange) !important; margin-top: 6px !important; font-weight: 600; }
select:disabled { color: var(--text-2) !important; cursor: default; }

/* Anmeldung */
.login { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: var(--pane); padding: 16px; }
.login-card {
  width: min(380px, 100%); background: var(--bg); padding: 34px 32px 28px; border-radius: 6px; box-shadow: var(--shadow);
  border-top: 4px solid var(--brand); display: flex; flex-direction: column; gap: 12px;
}
.login-marke { display: flex; justify-content: center; margin-bottom: 4px; }
.login-marke .wortmarke { height: 24px; }
.login-marke b { font-size: 17px; }
.login-card > p { text-align: center; }
.login-card > strong { font-size: 16px; }
.login-card .pin { font-size: 26px; letter-spacing: .5em; text-align: center; min-height: 48px; }
.login-card label.login-check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 13px; }
.login-check input { min-height: 0; width: 16px; height: 16px; accent-color: var(--brand); }
.login-link { color: var(--blue); text-align: center; font-size: 13px; text-decoration: none; }
.login-link:hover { text-decoration: underline; }
.login-info { background: var(--blue-soft); border-radius: 6px; padding: 10px 12px; margin: 0 !important; color: var(--text) !important; font-size: 13px; }
.login-card > p#code-text { margin: 0; text-align: left; font-size: 13px; }
.login-card h1 { margin: 0; font-size: 22px; font-weight: 800; }
.login-card > p { margin: 0 0 6px; color: var(--text-2); }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.login-card input { min-height: 38px; font-size: 14px; }
.login-card .btn { justify-content: center; margin-top: 6px; }
.login-err { color: var(--red) !important; font-weight: 600; }

/* Verwaltung */
.win.admin { width: min(1000px, 96vw); }
.admin-body { flex: 1; display: grid; grid-template-columns: 260px 1fr; min-height: 0; }
.admin-list { border-right: .5px solid var(--sep); padding: 10px 8px; overflow: auto; background: var(--side); display: flex; flex-direction: column; gap: 2px; }
.al { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 4px; cursor: pointer; }
.al:hover { background: var(--fill-2); }
.al.active { background: var(--sel); color: #fff; }
.al.active span { color: rgba(255,255,255,.8); }
.al b { display: block; font-size: 13px; }
.al span { display: block; font-size: 11.5px; color: var(--text-2); }
.al.off b { color: var(--text-3); }
.al.add-al { color: var(--blue); font-weight: 700; margin-top: 6px; border: 1px dashed color-mix(in srgb, var(--blue) 45%, transparent); }
.al.add-al.active { background: var(--blue); color: #fff; }
.al-hint { font-size: 11.5px; color: var(--text-3); margin: 8px 10px; }
.admin-edit { overflow: auto; background: var(--pane); padding: 22px 28px 40px; }
.admin-edit h2 { margin: 0; font-size: 20px; font-weight: 800; }
.admin-edit > form > .muted { margin: 2px 0 18px; }
.li .k small { display: block; font-size: 11px; color: var(--text-3); font-weight: 400; }
.li.chk { cursor: pointer; }
.li.chk .k { white-space: normal; flex: 1; }
input.switch {
  appearance: none; width: 38px; height: 22px; min-height: 0; border-radius: 999px; background: var(--fill); border: 0;
  position: relative; cursor: pointer; flex: none; padding: 0; box-shadow: none; transition: background .15s;
}
input.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left .15s; }
input.switch:checked { background: var(--green); }
input.switch:checked::after { left: 18px; }
input.switch:disabled { opacity: .5; cursor: default; }
.adm-actions { display: flex; justify-content: flex-end; }
@media (max-width: 900px) { .admin-body { grid-template-columns: 1fr; } .admin-list { max-height: 30vh; border-right: 0; border-bottom: .5px solid var(--sep); } }

/* Löschdialog */
.del-reasons { display: flex; flex-direction: column; gap: 4px; margin: 14px 0 4px; }
.del-reasons label { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 4px; background: var(--pane); cursor: pointer; }
.del-reasons label:has(input:checked) { background: var(--red-soft); }
.del-reasons label.off { opacity: .45; cursor: not-allowed; }
.upload-results .del-up { color: var(--red); font-weight: 700; }

/* Häkchen im Dialog und Mail-Entwurf */
.dlg-check { display: flex; gap: 8px; align-items: center; margin: -6px 0 16px; cursor: pointer; font-weight: 600; }
.dlg-check input { min-height: 0; width: 16px; height: 16px; accent-color: var(--blue); }
dialog.mail { width: min(640px, 94vw); }
dialog.mail label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); margin-top: 10px; }
dialog.mail textarea { margin: 0 0 16px; font-size: 13px; line-height: 1.45; }
.mail-hint { color: var(--orange) !important; font-size: 12px; margin-top: 4px !important; }
.mailed { display: block; margin-top: 6px; color: var(--green); font-weight: 600; }

/* Postfächer */
.mb-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); margin-right: 7px; vertical-align: 1px; }
.mb-dot.ok { background: #34c759; } .mb-dot.err { background: var(--red); }
.mb-status { padding: 10px 14px; border-radius: 4px; background: var(--group); box-shadow: var(--shadow); margin-bottom: 18px; border-left: 3px solid var(--text-3); }
.mb-status.ok { border-left-color: #34c759; } .mb-status.fehler { border-left-color: var(--red); }
.mb-status.fehler b { color: var(--red); }
.mb-status b { display: block; } .mb-status span { font-size: 12.5px; color: var(--text-2); }
.adm-actions { gap: 8px; align-items: center; }
.adm-actions .grow { flex: 1; }
.btn.danger-l { color: var(--red); }
.unit { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; color: var(--text-2); }
.unit input { width: 60px !important; }
.mail-li .k { white-space: normal; min-width: 0; flex: 1; }
.mail-li .k b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-li .k small { display: block; color: var(--text-2); font-size: 11.5px; }

/* Schließen-Kreuz für alle Overlays */
.xclose {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--fill); color: var(--text);
  display: grid; place-items: center; cursor: pointer; flex: none; padding: 0; min-height: 0;
}
.xclose:hover { background: var(--blue); color: #fff; }
dialog { position: relative; }
dialog > form > .xclose { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; }
dialog h3 { padding-right: 36px; }

/* Mail-Dialog und Lieferanten */
.mail-sugg { font-size: 12px; color: var(--text-2); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.mail-sugg .chip { border: 0; cursor: pointer; }
.mail-opts { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 14px; }
.mail-opts .dlg-check { margin: 0; flex-direction: row !important; color: var(--text) !important; font-size: 13px !important; }
.al-search { margin: 0 2px 8px; min-height: 32px; }
.lf-add { margin-top: 8px; }

/* Sanfter Übergang nach Aktionen */
.row.ghost { opacity: .55; }
.row.ghost .who2 { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text) 35%, transparent); }
.row.ghost.sel { opacity: .9; }
.done-banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 18px; border-radius: 6px;
  background: var(--green-soft); animation: pop .25s ease-out;
}
.done-banner .ok-ring { width: 34px; height: 34px; border-radius: 50%; background: #34c759; color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.done-banner div { flex: 1; }
.done-banner b { display: block; font-size: 15px; }
.done-banner span { color: var(--text-2); font-size: 12.5px; }
.datev-open { display: block; margin-top: 6px; color: var(--orange); font-weight: 600; }
.datev-all { margin: 0 0 10px; width: 100%; justify-content: center; }
/* Bezahlen */
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 10px; }
.pay-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.pay-opts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.pay-opts label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-radius: 4px; background: var(--pane); cursor: pointer; }
.pay-opts label:has(input:checked) { background: var(--green-soft); }
.pay-opts small { color: var(--text-2); width: 100%; padding-left: 24px; }

/* Niedrige Fenster: Ablagefläche kompakter, damit Fächer und Menü Platz haben */
@media (max-height: 820px) and (min-width: 901px) {
  .add { min-height: 0; padding: 10px; flex-direction: row; gap: 8px; margin-bottom: 10px; }
  .add svg { width: 20px; height: 20px; margin: 0; }
  .add b { font-size: 13px; }
  .add span, .add small { display: none; }
  .brand { padding-bottom: 10px; }
}
@media (max-height: 640px) and (min-width: 901px) {
  .brand div { display: none; }
  .me div span { display: none; }
  .side-foot { padding-top: 8px; gap: 6px; }
}

/* Mein Konto */
.win.konto { width: min(640px, 96vw); }
.konto-body { overflow: auto; background: var(--pane); padding: 22px 28px 32px; display: grid; gap: 22px; }
.konto-body h2 { margin: 0 0 8px; font-size: 17px; font-weight: 800; }
.konto-body .karte { background: var(--bg); border-radius: 6px; box-shadow: var(--shadow); padding: 16px 18px; display: grid; gap: 12px; }
.konto-body p { margin: 0; }
.konto-body label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.konto-body .reihe { display: flex; gap: 8px; flex-wrap: wrap; }
.konto-body ol { margin: 0; padding-left: 18px; line-height: 1.6; }
.zf-qr { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.zf-qr .qr { width: 180px; height: 180px; background: #fff; border-radius: 6px; padding: 6px; box-shadow: var(--shadow); }
.zf-qr .qr svg { width: 100%; height: 100%; display: block; }
.zf-qr .geheim { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; color: var(--text); margin-top: 4px; }
.konto-body .pin { font-size: 22px; letter-spacing: .4em; text-align: center; max-width: 220px; }
.tag-ok { display: inline-block; background: var(--green-soft); color: var(--green); border-radius: 99px; padding: 1px 9px; font-size: 12px; font-weight: 700; }
