/* Rechnungen – ruhige Arbeitsoberfläche; die Firmenfarbe (--brand) zeigt immer, für wen man gerade arbeitet */
:root {
  --ink: #1E2433;
  --muted: #5F6874;
  --canvas: #EEF1F0;
  --paper: #FFFFFF;
  --line: #D3D9D7;
  --paid: #2E7D4F;
  --danger: #B3261E;
  --brand: #2F5D8C;
  --radius: 6px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; }
a { color: var(--brand); }
h1 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.015em; margin: 0; font-weight: 700; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Seitenleiste */
.side {
  width: 230px; flex-shrink: 0; background: var(--paper); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.tenant {
  background: var(--brand); color: #fff; padding: 22px 18px 20px; min-height: 96px;
  display: flex; align-items: flex-end;
}
.tenant strong, .tenant select {
  font-size: 1.15rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; color: #fff;
}
.tenant select {
  width: 100%; background: transparent; border: 0; border-bottom: 1px solid rgba(255,255,255,.5);
  padding: 2px 18px 4px 0; appearance: none; cursor: pointer; font-family: inherit;
  background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%);
  background-position: right 6px center, right 1px center; background-size: 5px 5px; background-repeat: no-repeat;
}
.tenant select option { color: var(--ink); }
.side nav { display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; }
.side nav a {
  text-decoration: none; color: var(--ink); padding: 8px 10px; border-radius: var(--radius);
  border-left: 3px solid transparent;
}
.side nav a:hover { background: var(--canvas); }
.side nav a.on { border-left-color: var(--brand); background: var(--canvas); font-weight: 600; }
.nav-group { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 16px 10px 4px; }
.side { overflow-y: auto; }
.nav-sub { margin-top: 6px; }
.nav-sub summary {
  list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: var(--radius); color: var(--ink); border-left: 3px solid transparent;
}
.nav-sub summary::-webkit-details-marker { display: none; }
.nav-sub summary::after { content: ''; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s; margin-right: 4px; }
.nav-sub[open] summary::after { transform: rotate(45deg); }
.nav-sub summary:hover { background: var(--canvas); }
.nav-sub[data-active] > summary { font-weight: 600; }
.nav-sub .nav-items { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 4px 12px; padding-left: 8px; border-left: 1px solid var(--line); }
.nav-sub .nav-items a { padding: 6px 10px; font-size: .93rem; }
.me { margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.me a { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me a.on, .me a:hover { text-decoration: underline; }
.me .logout { color: var(--muted); flex-shrink: 0; }
.company-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; margin-bottom: 14px; }
.company-check { border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; }
.company-check:has([data-access]:checked) { border-color: var(--ink); }
.company-check label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.company-check label.sub { margin: 4px 0 0 24px; font-size: .85rem; color: var(--muted); }
.company-check label.sub:has(input:disabled) { opacity: .45; cursor: default; }
.company-checks input { width: auto; }
.admin-note { padding: 10px 12px; background: var(--canvas); border-radius: 4px; margin: 0 0 14px; }
[data-admin-hides][hidden] { display: none; }
.role { font-size: .8rem; font-weight: 600; }
tr.inactive td { color: var(--muted); }

/* ---------- Inhalt */
.main { flex: 1; padding: 28px 40px 64px; max-width: none; min-width: 0; }
/* Breite Bildschirme (z. B. 1920 × 1080): volle Breite nutzen; Formulare bleiben gut lesbar */
.main > .form, .main > form.form { max-width: 1400px; }
@media (min-width: 1600px) {
  .main { padding: 28px 48px 64px; }
  .side { width: 250px; }
}
.bare { flex: 1; display: grid; place-items: center; padding: 24px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.head > div:first-child { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.head-actions form { margin: 0; }
.search input { width: 260px; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 18px; background: var(--paper); border-left: 4px solid var(--paid); }
.flash-error { border-left-color: var(--danger); }

.summary { margin: -8px 0 18px; color: var(--muted); }
.summary strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.summary .overdue { color: var(--danger); }

/* ---------- Tabellen */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
.list th, .list td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.list th { font-size: .82rem; font-weight: 600; color: var(--muted); background: #F7F8F8; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tbody tr:hover { background: #FAFBFB; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
.actions > * { margin-left: 12px; display: inline; }
.actions form { display: inline; }
.mono-ish { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: 1px; }
.tag { font-size: .75rem; border: 1px solid var(--brand); color: var(--brand); padding: 0 6px; border-radius: 3px; margin-left: 6px; }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: 999px; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { background: var(--ink); color: #fff; }

.status { display: inline-block; font-size: .8rem; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.status-sent { border-color: var(--brand); color: var(--brand); }
.status-overdue { background: var(--danger); border-color: var(--danger); color: #fff; }
.status-paid { background: var(--paid); border-color: var(--paid); color: #fff; }
.status-cancelled { text-decoration: line-through; }

.empty { background: var(--paper); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; }
.empty p { margin: 0 0 16px; color: var(--muted); }

/* ---------- Buttons */
.btn {
  display: inline-block; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper); color: var(--ink);
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(.92); }
.btn.paid { border-color: var(--paid); color: var(--paid); }
.btn.small { padding: 5px 12px; font-size: .9rem; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }
.danger { color: var(--danger) !important; }

/* ---------- Formulare */
.form fieldset { border: 0; margin: 0 0 20px; padding: 20px 22px 8px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.form legend { font-weight: 700; font-size: 1.05rem; padding: 0; float: left; width: 100%; margin-bottom: 4px; }
.form legend + * { clear: both; }
.legend-note { clear: both; margin: 0 0 12px; color: var(--muted); font-size: .9rem; max-width: 70ch; }
.grid { clear: both; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 16px; }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; margin-bottom: 14px; min-width: 0; }
.field label, .field .label { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.field small { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.field.check { justify-content: center; }
.field.check label { color: var(--ink); font-size: 1rem; display: flex; gap: 8px; align-items: center; }
.err, .field small.err { color: var(--danger); }
.has-error input, .has-error select { border-color: var(--danger); }
input, select, textarea {
  font: inherit; color: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; background: #fff; width: 100%;
}
input[type=color] { padding: 2px; height: 38px; }
input[type=checkbox] { width: auto; accent-color: var(--brand); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea { resize: vertical; }
.ref { padding: 7px 0; font-variant-numeric: tabular-nums; letter-spacing: .03em; }
.form-actions { display: flex; gap: 10px; }
.secondary-actions { display: flex; gap: 24px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.secondary-actions form { margin: 0; }

/* Positionen */
.items th { font-size: .82rem; color: var(--muted); font-weight: 600; text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.items td { padding: 6px; vertical-align: top; border-bottom: 1px solid #EDF0EF; }
.items td[data-line] { padding-top: 13px; }
.items textarea { min-height: 38px; overflow: hidden; resize: none; }
.items input[data-f=quantity], .items input[data-f=unit_price] { text-align: right; }
.items [data-remove] { font-size: 1.3rem; line-height: 1; text-decoration: none; padding: 8px 4px; }
.w-desc { width: 44%; } .w-qty { width: 9%; } .w-unit { width: 9%; } .w-price { width: 12%; } .w-vat { width: 10%; } .w-line { width: 12%; }
.fieldset-note { color: var(--muted); }
[data-add-item] { margin: 12px 0 4px; }
.totals {
  display: grid; grid-template-columns: auto auto; justify-content: end; gap: 4px 28px;
  margin: 8px 0 14px; font-variant-numeric: tabular-nums;
}
.totals dt { color: var(--muted); text-align: right; }
.totals dd { margin: 0; text-align: right; min-width: 110px; }
.totals .grand { font-size: 1.3rem; font-weight: 700; color: var(--ink); padding-top: 6px; border-top: 2px solid var(--brand); }

/* Wer hat was gemacht */
.byline { width: 100%; margin: 4px 0 0; color: var(--muted); font-size: .88rem; }
.byline strong { color: var(--ink); font-weight: 600; }
td.by { font-size: .92rem; }
.history { margin-top: 28px; }
.history h2 { font-size: 1.05rem; margin: 0 0 10px; }
.history ol, .log-list { list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.history li, .log-list li {
  display: grid; grid-template-columns: 130px 120px 130px 1fr; gap: 12px; align-items: baseline;
  padding: 9px 14px; border-bottom: 1px solid #EDF0EF; font-size: .92rem;
}
.history li:last-child, .log-list li:last-child { border-bottom: 0; }
.history time, .log-list time { color: var(--muted); font-variant-numeric: tabular-nums; }
.who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.what { font-weight: 600; }
.log-created { color: var(--paid); } .log-deleted { color: var(--danger); } .log-status { color: var(--brand); }
.details { color: var(--ink); }
.log-list .inv { grid-column: 4; }
.log-filter { display: flex; gap: 8px; align-items: center; }
.log-filter select { width: auto; }
@media (max-width: 820px) {
  .history li, .log-list li { grid-template-columns: 1fr 1fr; }
  .history .details, .log-list .details { grid-column: 1 / -1; }
}

/* Kunde direkt anlegen */
.with-button { display: flex; gap: 8px; }
.with-button select { flex: 1; min-width: 0; }
.with-button .btn { white-space: nowrap; padding: 7px 12px; }
.dialog {
  border: 0; border-radius: 8px; padding: 0; width: min(560px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(30,36,51,.25); color: var(--ink);
}
.dialog::backdrop { background: rgba(30,36,51,.45); }
.dialog form.form { margin: 0; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px 0; border-top: 4px solid var(--brand); }
.dialog-head h2 { margin: 0; font-size: 1.2rem; }
.dialog-head .link { font-size: 1.6rem; line-height: 1; text-decoration: none; color: var(--muted); }
.dialog-body { padding: 14px 22px 0; }
.dialog-body .legend-note { margin-top: 0; }
.dialog-foot { display: flex; gap: 10px; padding: 12px 22px 20px; }

/* Zahlungen */
.upload-box { display: flex; gap: 20px; justify-content: space-between; align-items: flex-end; flex-wrap: wrap;
  background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 22px; }
.upload-box p { margin: 4px 0 0; max-width: 70ch; font-size: .92rem; }
.upload-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.upload-controls input[type=file] { width: auto; max-width: 280px; }
.small-text { font-size: .88rem; max-width: 320px; overflow-wrap: anywhere; }
.assign { display: flex; gap: 6px; align-items: center; }
.assign select { width: auto; max-width: 280px; font-size: .88rem; }
.list.import select { font-size: .88rem; max-width: 320px; margin-top: 4px; }
.match { display: inline-block; font-size: .78rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid; }
.match-ok { color: var(--paid); border-color: var(--paid); }
.match-warn { color: #8a5a00; border-color: #d9a441; background: #fff7e6; }
.match-none { color: var(--muted); border-color: var(--line); }
.match-skip { color: var(--muted); border-color: var(--line); text-decoration: line-through; }
.match-detail { display: block; font-size: .8rem; color: var(--muted); margin-top: 3px; }
.match-detail.warn { color: #8a5a00; }
.partial { color: #8a5a00; font-weight: 600; }
.payment-state { margin: 10px 0; }
.payment-add { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; background: var(--paper); border: 1px dashed var(--line); border-radius: var(--radius); padding: 12px 14px; }
.payment-add strong { width: 100%; font-size: .92rem; }
.payment-add label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 3px; }
.payment-add input { width: 150px; }
form.inline { display: inline; margin-left: 8px; }

/* Abgleich */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 26px; }
.kpi { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  color: var(--muted); text-decoration: none; font-size: .88rem; line-height: 1.35; }
.kpi:hover { border-color: var(--ink); }
.kpi-n { display: block; font-size: 1.7rem; font-weight: 700; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi small { display: block; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.attention { border-left: 4px solid #d9a441; }
.rec { margin-bottom: 30px; scroll-margin-top: 16px; }
.rec h2 { font-size: 1.1rem; margin: 0 0 4px; }
.rec-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.rec-head form { margin: 0; }
.rec .assign select[name=reason] { max-width: 190px; }
.rec input[type=date] { width: auto; font-size: .88rem; padding: 4px 6px; }
.small-link { display: inline-block; margin-top: 4px; font-size: .85rem; }

.domain-warning { grid-column: 1 / -1; font-size: .88rem; border-left-color: #d9a441; margin: 0 0 14px; }

.transport-choice { gap: 8px; }
.transport-option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; color: var(--ink) !important; font-size: .95rem !important; }
.transport-option:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 5%, transparent); }
.transport-option input { width: auto; margin-top: 4px; accent-color: var(--brand); }
.transport-option small { color: var(--muted); font-size: .82rem; }
.smtp-fields[hidden] { display: none; }
.smtp-fields > .grid { margin: 0; }

.mail-readonly dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 4px 0 8px;
  padding: 10px 12px; background: var(--canvas); border-radius: 4px; font-size: .92rem; }
.mail-readonly dt { color: var(--muted); }
.mail-readonly dd { margin: 0; overflow-wrap: anywhere; }

/* Anhänge */
.attach-list { list-style: none; margin: 6px 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.attach-list li, .attach-list label { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink); font-size: .92rem; }
.attach-list input[type=checkbox] { width: auto; accent-color: var(--brand); }
.attach-list .check-inline { margin: 0 0 0 auto; border: 0; padding: 0; }
.std-attachments { grid-column: 1 / -1; margin-top: 6px; }
.std-attachments > small { margin: 0 0 4px; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; margin: 0; max-width: 420px;
  box-shadow: 0 8px 24px rgba(30,36,51,.18); }
a.busy { opacity: .5; pointer-events: none; cursor: progress; }

.copyright { margin: 0; padding: 0 20px 14px; font-size: .75rem; color: var(--muted); display: flex; flex-direction: column; line-height: 1.5; }
.copyright span { white-space: nowrap; }
.copyright-bare { text-align: center; align-items: center; padding: 16px 0 0; }
.bare { flex-direction: column; }
@media (max-width: 820px) { .side .copyright { display: none; } }

.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.footer-col { display: flex; flex-direction: column; gap: 4px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; }
.footer-col label { font-size: .8rem; color: var(--muted); }
.footer-col input + label { margin-top: 4px; }
.footer-preview { display: grid; gap: 12px; border-top: 1px solid #A0A8B0; padding: 8px 4px 4px; margin-bottom: 14px;
  font-family: Helvetica, Arial, sans-serif; background: #fff; }
.footer-preview div { display: flex; flex-direction: column; min-width: 0; }
.footer-preview small { font-size: .72rem; color: #6E7480; }
.footer-preview span { font-size: .86rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.footer-link { margin: -6px 0 20px; }

/* Mahnwesen */
.dunning-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-bottom: 22px; }
.dunning-levels .dl { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px;
  display: flex; flex-direction: column; font-size: .88rem; color: var(--muted); }
.dunning-levels .dl strong { color: var(--ink); font-size: 1rem; }
.dunning-badge { display: inline-block; font-size: .76rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap;
  background: #fff3d6; color: #8a5a00; border: 1px solid #e3b75a; }
.dunning-badge.level-2 { background: #ffe5d0; color: #9a4300; border-color: #e89a5a; }
.dunning-badge.level-3 { background: var(--danger); color: #fff; border-color: var(--danger); }
.dunning-badge.level-4 { background: #2b2f36; color: #fff; border-color: #2b2f36; }
.batch-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dunning-edit { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 14px; }
.dunning-level { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px 0; }
.dunning-level h3 { margin: 0 0 8px; font-size: .95rem; }
.dl-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dl-row .field label { font-size: .75rem; }

/* Buchhaltung */
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 20px; }
.inline-form label { display: flex; flex-direction: column; gap: 3px; font-size: .8rem; color: var(--muted); }
.inline-form input, .inline-form select { width: auto; }
.inline-form strong { width: 100%; }
.acc-edit { display: flex; gap: 8px; align-items: center; }
.acc-edit input[name=name] { border-color: transparent; background: transparent; padding: 3px 6px; }
.acc-edit input[name=name]:hover, .acc-edit input[name=name]:focus { border-color: var(--line); background: #fff; }
.roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; margin-bottom: 14px; }
.roles label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: .88rem; color: var(--muted); }
.roles input { width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
.src { font-size: .72rem; padding: 0 6px; border-radius: 3px; background: var(--canvas); color: var(--muted); }
.src-invoice, .src-payment, .src-dunning { background: #e8f0f8; color: var(--brand); }
.list.journal td { vertical-align: top; }
.list.journal tr.entry-start td { border-top: 2px solid var(--line); }
.list.journal tr:not(.entry-start) td { border-bottom: 0; }
tr.cancelled td { color: var(--muted); }
tr.cancelled td.num { text-decoration: line-through; }
tr.matched td { color: var(--muted); }
.journal-lines td select { width: 100%; }
.journal-lines td input { text-align: right; }
.journal-lines tfoot td { padding: 8px 6px; font-weight: 600; }
.vat-form .z { font-variant-numeric: tabular-nums; color: var(--muted); }
.list tr.section td { background: #F7F8F8; font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.list tr.strong td { font-weight: 700; }
.list tr.total td { border-top: 2px solid var(--ink); font-size: 1.05rem; }
.vat-actions { margin-top: 18px; }
.statements { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; margin-bottom: 20px; }
.statements h2 { font-size: 1.1rem; margin: 0 0 8px; }
.list.statement { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.list.statement td:first-child { width: 60px; }
.checks { list-style: none; padding: 0; margin: 0 0 12px; }
.checks li { padding: 6px 10px; background: #fff7e6; border-left: 3px solid #d9a441; margin-bottom: 6px; font-size: .92rem; }

@media print {
  .side, .no-print, .flash, .head-actions, .filters, form[data-confirm] { display: none !important; }
  body { background: #fff; display: block; }
  .main { padding: 0; max-width: none; }
  .table-wrap, .list.statement { border: 0; }
  a { color: inherit; text-decoration: none; }
}

.bankrec-bulk select { max-width: 240px; }
.bankrec-bulk { margin: 0 0 12px; }

/* Projekte */
.budget { height: 6px; background: var(--canvas); border-radius: 3px; overflow: hidden; margin: 4px 0 2px; }
.budget span { display: block; height: 100%; background: var(--paid); }
.budget span.warn { background: #d9a441; }
.budget span.over { background: var(--danger); }
.entry-form .grow { flex: 1; min-width: 200px; }
.entry-form .grow input { width: 100%; }
.entry-form .check-inline { flex-direction: row; align-items: center; color: var(--ink); font-size: .9rem; margin: 0 0 8px; }
.day { margin-bottom: 14px; }
.day h2 { font-size: 1rem; margin: 0 0 6px; display: flex; gap: 8px; align-items: baseline; }
.day .day-total { margin-left: auto; font-variant-numeric: tabular-nums; }
.day.today h2 { color: var(--brand); }
.day .list { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.price-table input, .price-table select { width: 100%; }
.price-table input[type=checkbox] { width: auto; }
.price-table tr.new-row td { background: #fbfcfc; }

[data-rebill][hidden] { display: none; }
[data-rebill] .check-inline { display: flex; gap: 8px; align-items: center; color: var(--ink); margin-bottom: 6px; }

/* Zeitenliste (angelehnt an gängige CH-Business-Software) */
.btn.dark { background: #2b2f36; border-color: #2b2f36; color: #fff; }
.btn.dark:hover { background: #111; }
.tl { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.tl-top { margin-bottom: 12px; }
.tl-new summary { list-style: none; display: inline-block; }
.tl-new summary::-webkit-details-marker { display: none; }
.tl-new[open] summary { margin-bottom: 10px; }
.tl-new .inline-form { margin-bottom: 4px; }
.tl-filterbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.tl-quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tl-filter { position: relative; }
.tl-filter summary { list-style: none; cursor: pointer; color: var(--brand); padding: 5px 8px; }
.tl-filter summary::-webkit-details-marker { display: none; }
.tl-filter-fields { position: absolute; z-index: 15; top: 100%; left: 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: 0 8px 24px rgba(30,36,51,.12); width: min(720px, 90vw); }
.tl-filter-fields label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 3px; }
.tl-filter-fields select, .tl-filter-fields input { width: auto; max-width: 220px; }
.tl-search input { width: 220px; }
.tl-table th { font-size: .82rem; }
.tl-table td, .tl-table th { padding: 7px 10px; }
.tl-table tbody tr:nth-child(even) td { background: #fafbfb; }
.tl-table tr.selected td { background: color-mix(in srgb, var(--brand) 8%, transparent) !important; }
.tl-table .c { text-align: center; }
.tl-table tfoot td { border-top: 1px solid var(--line); font-size: .9rem; }
.st { display: inline-block; font-size: .75rem; font-weight: 700; color: #fff; padding: 1px 7px; border-radius: 3px; white-space: nowrap; }
.st-open { background: #8a94a1; }
.st-done { background: #3d8fb0; }
.st-billed { background: #4caf50; }
.link.dotted { text-decoration: none; border-bottom: 1px dotted var(--brand); }
.info { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #2b2f36; color: #fff;
  font: italic 700 .7rem/1 Georgia, serif; cursor: help; }
.row-menu { position: relative; display: inline-block; }
.row-menu summary { list-style: none; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu-items { position: absolute; right: 0; top: 100%; z-index: 25; min-width: 190px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(30,36,51,.15); padding: 4px; display: flex; flex-direction: column; text-align: left; }
.row-menu.up .row-menu-items { top: auto; bottom: 100%; left: 0; right: auto; }
.row-menu-items a, .row-menu-items .link { display: block; width: 100%; text-align: left; padding: 6px 10px; text-decoration: none; color: var(--ink); border-radius: 4px; font-size: .9rem; }
.row-menu-items a:hover, .row-menu-items .link:hover { background: var(--canvas); }
.row-menu-items a.on { font-weight: 600; }
.row-menu-items form { margin: 0; }
.tl-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.tl-paging-info { display: flex; gap: 6px; }
.pager { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.pager a { padding: 5px 11px; text-decoration: none; color: var(--brand); border-left: 1px solid var(--line); }
.pager a:first-child { border-left: 0; }
.pager a.on { background: var(--canvas); color: var(--ink); font-weight: 600; }
.pager a[aria-disabled] { color: var(--muted); pointer-events: none; }
.tl-go { display: flex; gap: 6px; }
.tl-go select { width: auto; min-width: 260px; }
.timer-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #2b2f36; color: #fff; padding: 8px 14px;
  border-radius: var(--radius); margin-bottom: 16px; }
.timer-bar strong { font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.timer-bar .btn:not(.primary) { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.timer-dot { width: 10px; height: 10px; border-radius: 50%; background: #e53935; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.ctabs { border-bottom: 1px solid var(--line); gap: 0; margin-bottom: 0; }
.ctabs a { border-radius: 0; padding: 10px 14px; border-bottom: 2px solid transparent; color: var(--ink); }
.ctabs a.on { background: none; color: var(--brand); border-bottom-color: var(--brand); }
.ctabs small { color: var(--muted); }
.ctab-body { padding-top: 16px; }

.howto { margin: 0; padding-left: 20px; line-height: 1.7; }
.import-list { margin: 0; padding: 10px 14px 10px 30px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); font-size: .92rem; }

.budget.big { height: 14px; border-radius: 7px; margin: 12px 0; }
.budget.big span { transition: width .3s; }

/* Auswahllisten mit Suche (select-search.js) */
.ss { position: relative; display: inline-block; vertical-align: middle; max-width: 100%; min-width: 8em; }
.field .ss, td .ss, .with-button .ss, .roles .ss, .footer-col .ss, .inline-form label .ss, .tl-filter-fields label .ss { display: block; width: 100%; }
.with-button .ss { flex: 1; min-width: 0; }
.ss-native { position: absolute !important; inset: 0; width: 100% !important; height: 100% !important; opacity: 0; pointer-events: none; margin: 0; }
.ss-btn {
  font: inherit; color: inherit; width: 100%; text-align: left; cursor: pointer; position: relative;
  padding: 7px 30px 7px 10px; border: 1px solid var(--line); border-radius: 4px; background: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 38px; line-height: 1.4;
}
.ss-btn::after {
  content: ''; position: absolute; right: 11px; top: 50%; width: 6px; height: 6px; margin-top: -5px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg);
}
.ss-btn:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.ss-btn[aria-expanded="true"] { border-color: var(--brand); }
.ss-btn:disabled { opacity: .55; cursor: not-allowed; background: var(--canvas); }
.ss-btn.ss-invalid, .has-error .ss-btn { border-color: var(--danger); }
.items .ss-btn, .price-table .ss-btn, .assign .ss-btn, .tl-go .ss-btn, .bulk-bar .ss-btn { min-height: 34px; padding-top: 5px; padding-bottom: 5px; }
.ss-panel {
  position: fixed; z-index: 1000; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px;
  box-shadow: 0 12px 32px rgba(30,36,51,.18); max-width: min(560px, 96vw);
}
.ss-search { width: 100%; margin-bottom: 5px; padding: 6px 9px; }
.ss-list { max-height: 300px; overflow-y: auto; }
.ss-opt { padding: 6px 10px; border-radius: 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.ss-opt.act { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.ss-opt.sel { font-weight: 600; }
.ss-opt.sel::before { content: '✓ '; color: var(--brand); }
.ss-opt.dis { color: var(--muted); cursor: default; }
.ss-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px 2px; }
.ss-empty { padding: 8px 10px; color: var(--muted); font-size: .92rem; }
.tenant .ss { display: block; width: 100%; }
.tenant .ss-btn { background: transparent; color: #fff; border: 0; border-bottom: 1px solid rgba(255,255,255,.5); border-radius: 0;
  font-size: 1.15rem; font-weight: 700; padding: 2px 22px 4px 0; min-height: 0; }
.tenant .ss-btn::after { border-color: #fff; right: 4px; }
.tenant .ss-btn:focus { box-shadow: none; border-bottom-color: #fff; }
@media print { .ss-panel { display: none; } .ss-btn::after { display: none; } }

.select-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.table-search input { width: 280px; }
tr[hidden] { display: none; }

.btn.danger-btn { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Offerten und Aufträge */
.ost { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); white-space: nowrap; }
.ost-draft, .ost-open { color: var(--muted); }
.ost-sent, .ost-progress { border-color: var(--brand); color: var(--brand); }
.ost-accepted, .ost-done { background: var(--paid); border-color: var(--paid); color: #fff; }
.ost-billed { background: #4caf50; border-color: #4caf50; color: #fff; }
.ost-declined, .ost-cancelled { text-decoration: line-through; color: var(--muted); }
.ost-expired { background: #d9a441; border-color: #d9a441; color: #fff; }
.flow-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 10px 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.flow-bar form { margin: 0; }

/* Produkte */
.items-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dialog.pp { width: min(820px, 96vw); }
.pp-top { display: flex; gap: 10px; align-items: end; margin-bottom: 8px; }
.pp-top input[type=search] { flex: 1; }
.pp-qty { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); }
.pp-qty input { width: 80px; }
.pp-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.pp-row { display: grid; grid-template-columns: 24px 90px 1fr 120px 130px; gap: 8px; align-items: center; padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.pp-row:last-child { border-bottom: 0; }
.pp-row.act { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.pp-name { display: flex; flex-direction: column; min-width: 0; }
.pp-name small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-no { font-size: .85rem; color: var(--muted); }
.pp-price { text-align: right; font-variant-numeric: tabular-nums; }
.pp-hint { font-size: .8rem; margin: 6px 0 0; }
.pp-manage { margin-left: auto; align-self: center; font-size: .9rem; }
@media (max-width: 640px) { .pp-row { grid-template-columns: 24px 1fr 90px; } .pp-no, .pp-unit { display: none; } }

fieldset[hidden] { display: none; }

.sort-cell { white-space: nowrap; }
.drag-handle { cursor: grab; color: var(--muted); padding: 0 4px; user-select: none; }
.sort-btn { font-size: .7rem; color: var(--muted); padding: 0 2px; text-decoration: none; }
.sort-btn:hover { color: var(--brand); }
[data-sort-body] tr.dragging { opacity: .4; }
[data-sort-body].saved tr { transition: background .3s; background: color-mix(in srgb, var(--paid) 10%, transparent); }

.assign-vat[hidden] { display: none; }
.assign-vat { display: inline-block; margin-left: 4px; }
.assign-vat select { width: auto; max-width: 220px; }

.receipt-pick { display: inline-flex; align-items: center; cursor: pointer; padding: 0 4px; position: relative; }
.receipt-pick input { width: 0; height: 0; opacity: 0; position: absolute; }
.receipt-pick.has-file { color: var(--paid); font-weight: 700; }

.menu-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 24px; margin: 8px 0; }
.menu-group { display: flex; flex-direction: column; gap: 4px; }
.menu-group strong { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.menu-group .check-inline { display: flex; gap: 8px; align-items: center; font-size: .95rem; }

.rbulk { margin: 10px 0 0; flex-wrap: wrap; }
.rbulk select { width: auto; max-width: 260px; }
.btn.danger-outline { color: var(--danger); border-color: var(--danger); background: transparent; }

/* Filter */
.filters { margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer;
  text-decoration: none; font-size: .92rem; user-select: none;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:hover { border-color: var(--ink); }
.chip:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.chip .count { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.on .count { color: rgba(255,255,255,.75); }
.chip-overdue.on { background: var(--danger); border-color: var(--danger); }
.chip-paid.on { background: var(--paid); border-color: var(--paid); }
.chip-open.on { background: var(--brand); border-color: var(--brand); }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-row input[type=search] { width: 240px; }
.filter-row select { width: auto; max-width: 220px; }
.date-range { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .88rem; }
.date-range input { width: auto; }
.filter-row .reset { font-size: .9rem; }
.result-line { margin: 0 0 8px; color: var(--muted); font-size: .92rem; }
.result-line strong { color: var(--ink); font-variant-numeric: tabular-nums; }
@media (max-width: 820px) { .filter-row input[type=search] { width: 100%; } }

/* Sammelaktionen und Versand */
.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); color: var(--muted); position: sticky; top: 0; z-index: 2;
}
.bulk-bar.active { border-color: var(--brand); color: var(--ink); box-shadow: 0 2px 8px rgba(30,36,51,.08); }
.bulk-bar select { width: auto; }
.list th.sel, .list td.sel { width: 36px; padding-right: 0; }
.list td.sel input, .list th.sel input { width: auto; accent-color: var(--brand); }
.list tr.selected td { background: color-mix(in srgb, var(--brand) 7%, transparent); }
.mailed { color: var(--muted); white-space: nowrap; }
.result-ok { color: var(--paid); } .result-error { color: var(--danger); } .result-skip { color: var(--muted); }
.log-mailed { color: var(--ink); }
code { font-size: .85em; background: var(--canvas); padding: 1px 5px; border-radius: 3px; }
.legend-note code { margin-right: 2px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* Anmeldung */
.logo-field { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.logo-preview { width: 180px; height: 70px; border: 1px dashed var(--line); border-radius: 4px; display: grid; place-items: center; padding: 6px; }
.logo-preview img { max-width: 100%; max-height: 100%; }
.logo-field .field { flex: 1; min-width: 220px; }
.field .check-inline { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--ink); font-size: .95rem; }
input[type=file] { padding: 5px; }
.login { width: 100%; max-width: 380px; background: var(--paper); padding: 32px; border-radius: var(--radius); border-top: 4px solid var(--brand); }
.login h1 { margin-bottom: 12px; }
.login .btn { width: 100%; margin-top: 6px; }

/* ---------- Schmale Bildschirme */
@media (max-width: 820px) {
  body { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: stretch; }
  .tenant { width: 100%; min-height: 0; padding: 14px 18px; }
  .side nav { flex-direction: row; padding: 6px; }
  .side nav a { border-left: 0; border-bottom: 3px solid transparent; }
  .side nav a.on { border-bottom-color: var(--brand); }
  .nav-group { display: none; }
  .nav-sub { position: relative; margin: 0; }
  .nav-sub .nav-items { position: absolute; z-index: 20; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    margin: 0; padding: 4px; min-width: 200px; box-shadow: 0 8px 24px rgba(30,36,51,.15); }
  .me { margin: 0 0 0 auto; border-top: 0; padding: 14px 16px; }
  .main { padding: 20px 16px 48px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: 1 / -1; }
  .search input { width: 100%; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* camt-Viewer */
.camt-kv { display: grid; grid-template-columns: max-content 1fr; gap: .15rem 1rem; margin: .4rem 0; font-size: .9rem; }
.camt-kv dt { color: var(--muted, #666); }
.camt-kv dd { margin: 0; word-break: break-word; }
.camt-filter { display: inline-flex; gap: .25rem; }
.camt-filter .btn.on { background: var(--accent, #1f5fa8); color: #fff; }
.camt-table td { vertical-align: top; }
.camt-table td.num.success { color: #1a7f37; }
.kpi-n.success { color: #1a7f37; }
.camt-hidden { display: none !important; }
.camt-det { margin-top: .3rem; }
.camt-det > summary, .camt-xml > summary, .camt-bal > summary { cursor: pointer; color: var(--accent, #1f5fa8); font-size: .85rem; }
.camt-tx { border-left: 3px solid #ddd; padding: .2rem 0 .2rem .6rem; margin: .4rem 0; }
.camt-tx h4 { margin: .2rem 0; font-size: .9rem; }
.camt-parties { display: flex; flex-wrap: wrap; gap: .5rem 2rem; }
.camt-party { display: flex; flex-direction: column; font-size: .88rem; }
.camt-xml pre { max-height: 22rem; overflow: auto; background: #f6f8fa; padding: .5rem; font-size: .75rem; white-space: pre; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
@media print { .camt-det, .camt-bal { display: none; } }

/* Berichte: Kontenauswahl */
.account-picker .pick-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.account-picker .pick-bar input[type=search] { flex: 1 1 220px; max-width: 320px; }
.account-picker .pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 14px; max-height: 320px; overflow: auto;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; background: var(--paper); }
.account-picker .pick-item { display: flex; gap: 6px; align-items: baseline; font-size: .88rem; cursor: pointer; padding: 2px 0; }
.account-picker .pick-item small { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.account-picker .pick-item[hidden] { display: none; }
.report-ledger { margin-bottom: 22px; break-inside: avoid-page; }
.report-ledger h2 { font-size: 1.05rem; margin: 0 0 6px; }
@media print { .report-ledger { break-inside: auto; } }

/* Berichte: Vorlagen */
.report-templates { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 0 0 14px; padding: 10px 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.report-templates form { display: flex; gap: 8px; align-items: center; margin: 0; }
.report-templates .tpl-load select { min-width: 260px; }
.report-templates .tpl-save { margin-left: auto; }
.report-templates .tpl-save input[type=text] { width: 230px; }
.report-templates .check-inline { display: inline-flex; gap: 4px; align-items: center; font-size: .88rem; white-space: nowrap; }
