:root {
  --bg: #f4f6fa;
  --card: #fff;
  --border: #e3e7ee;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --sidebar: #111827;
  --sidebar-text: #cbd5e1;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
[hidden] { display: none !important; }

/* Layout */
.layout-app { display: flex; min-height: 100vh; }
.layout-app .content { flex: 1; padding: 2rem 2.5rem; min-width: 0; }
.layout-auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.25rem 1.25rem 1.5rem;
  font-weight: 700; font-size: 1.2rem; color: #fff;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: auto; flex-shrink: 0; }
.menu { display: flex; flex-direction: column; gap: 2px; padding: 0 .75rem; flex: 1; }
.menu a {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .75rem; border-radius: 8px;
  color: var(--sidebar-text);
}
.menu a svg { width: 18px; height: 18px; fill: currentColor; opacity: .85; }
.menu a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.menu a.active { background: var(--primary); color: #fff; }
.menu-bottom-group { margin-top: auto; margin-bottom: .75rem; display: flex; flex-direction: column; gap: 2px; }
.user-role { font-size: .75rem; color: var(--sidebar-text); opacity: .8; }
.sidebar-user {
  display: flex; align-items: center; gap: .7rem;
  padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #374151; color: #fff; display: grid; place-items: center;
  font-size: .85rem; font-weight: 600; text-transform: uppercase;
}
.user-name { color: #fff; font-size: .9rem; }
.link { background: none; border: 0; padding: 0; color: var(--sidebar-text); cursor: pointer; font-size: .8rem; }
.link:hover { color: #fff; text-decoration: underline; }

/* Page structure */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
}
.card.no-pad { padding: 0; overflow-x: auto; }
.card.narrow { max-width: 720px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.pad { padding: 1rem 1.5rem; margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.grid-smtp { display: grid; grid-template-columns: 2fr 1fr 1.5fr; gap: 1rem; }
.grid-plz { display: grid; grid-template-columns: 140px 1fr; gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.gap-lg > .card { margin-bottom: 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin-bottom: 1.5rem; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem 1.5rem; color: var(--text);
}
.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 2rem; font-weight: 700; margin: .25rem 0; }
.stat-sub { color: var(--muted); font-size: .85rem; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .65rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafbfc; }
.table tbody tr:hover { background: #f9fafb; }
.table tbody tr:last-child td { border-bottom: 0; }
.card:not(.no-pad) .table th:first-child, .card:not(.no-pad) .table td:first-child { padding-left: 0; }
.card:not(.no-pad) .table th { background: none; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; margin: 0; }

/* Details */
.details { display: grid; grid-template-columns: 140px 1fr; gap: .5rem 1rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

/* Badges */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-business { background: #dbeafe; color: #1e40af; }
.badge-private { background: #f3e8ff; color: #6b21a8; }
.badge-open { background: #dcfce7; color: #166534; }
.badge-closed { background: #e5e7eb; color: #374151; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.small { font-size: .8rem; }
.inline-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .9rem; }

/* Toolbar / tabs */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs { display: flex; gap: .25rem; background: #e9edf3; padding: .25rem; border-radius: 8px; }
.tabs a { padding: .35rem .9rem; border-radius: 6px; color: var(--text); font-size: .9rem; }
.tabs a:hover { text-decoration: none; background: rgba(255,255,255,.6); }
.tabs a.active { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }
.search { display: flex; gap: .5rem; }
.search input { width: 240px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=search], select, textarea {
  font: inherit; padding: .55rem .7rem; border: 1px solid #cfd6e0; border-radius: 8px; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.25); border-color: var(--primary); }
textarea { resize: vertical; }
input.readonly { background: #f3f4f6; color: var(--muted); }
.segmented { border: 0; padding: 0; margin: 0; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.segmented legend { font-weight: 500; font-size: .9rem; margin-bottom: .3rem; padding: 0; width: 100%; }
.segmented label {
  flex-direction: row !important; align-items: center; gap: .4rem !important;
  border: 1px solid #cfd6e0; border-radius: 8px; padding: .45rem .9rem; cursor: pointer;
}
.segmented label:has(input:checked) { border-color: var(--primary); background: #eff6ff; color: var(--primary-dark); }
.project-picker { max-width: 720px; }
.test-mail { margin-top: .75rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.invoice-page { margin-bottom: 1.5rem; }
.invoice-page .invoice-doc { border: 1px solid var(--border); border-radius: var(--radius); }
.project-picker label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .9rem; }

/* Buttons */
.btn {
  display: inline-block; font: inherit; font-size: .9rem; font-weight: 500;
  padding: .5rem 1rem; border-radius: 8px; border: 1px solid #cfd6e0;
  background: #fff; color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: #f3f4f6; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f5c2c2; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: .25rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; }
.form .btn { align-self: flex-start; }
.form .btn-block { align-self: stretch; }

/* Buchhaltung */
.dropzone { display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: .35rem !important;
  border: 2px dashed #cfd6e0; border-radius: 10px; padding: 1.75rem 1rem; text-align: center; cursor: pointer; background: #fafbfc; position: relative; }
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: #eff6ff; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-text { font-weight: 500; }
.account-select { max-width: 100%; }
.search .account-select { width: 320px; }
.konto-nr { font-variant-numeric: tabular-nums; font-weight: 600; }
.beleg-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1.5rem; align-items: start; }
.beleg-layout > .card { margin-bottom: 0; }
.beleg-preview { padding: 0; overflow: hidden; }
.beleg-preview iframe { width: 100%; height: 78vh; border: 0; display: block; }
.beleg-preview img { width: 100%; height: auto; display: block; }
.beleg-preview p { padding: 1.25rem 1.5rem; margin: 0; }
@media (max-width: 1000px) { .beleg-layout { grid-template-columns: 1fr; } }

/* Buchhaltung: booking fields and statements */
.booking-fields { border: 1px solid var(--border); border-radius: 10px; padding: .75rem 1rem 1rem; margin: 0; display: flex; flex-direction: column; gap: 1rem; }
.booking-fields legend { font-weight: 600; font-size: .9rem; padding: 0 .35rem; }
.booking-fields [data-mwst-preview]:empty { display: none; }
.booking-fields [data-mwst-preview] { margin: -.25rem 0 0; }
.inline-label { display: flex; align-items: center; gap: .6rem; font-weight: 500; font-size: .9rem; }
.inline-label select { width: auto; }
.statement .table td, .statement .table th { padding: .45rem 1rem; }
.statement .st-section td { background: #fafbfc; font-weight: 600; padding-top: .75rem; }
.statement .st-account { padding-left: 1.75rem !important; }
.statement .st-account a { color: var(--text); }
.statement .st-account a:hover { color: var(--primary); }
.statement .st-total td { font-weight: 600; border-top: 1px solid #cfd6e0; }
.statement .st-subtotal td { font-weight: 700; background: #eff6ff; }
.statement .st-result td { font-weight: 700; font-size: 1.05rem; border-top: 2px solid var(--text); background: #f3f4f6; }
.statement .st-result.negative td:nth-child(2) { color: var(--danger); }
.bilanz { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.bilanz > .card { margin-bottom: 0; }
.row-disabled td { color: var(--muted); }
.grid-entry { display: grid; grid-template-columns: 150px 1fr 1fr 140px; gap: 1rem; }
.grid-entry-2 { display: grid; grid-template-columns: 2fr 1fr 1.5fr; gap: 1rem; }
.journal .tax-line td { background: #fbfaf7; }
.journal .tax-line td:nth-child(2) { padding-left: 1.75rem; }
.journal .closing-line td { background: #f7f7fb; }
.statement .st-warn td { color: #92400e; background: #fffbeb; }
.new-rate { margin-top: 1rem; }
.new-rate summary { list-style: none; display: inline-block; }
.new-rate[open] summary { margin-bottom: 1rem; }
.narrow-form { max-width: 720px; }
.delete-form { margin-top: 1rem; }
@media (max-width: 1000px) { .grid-entry, .grid-entry-2 { grid-template-columns: 1fr; } }
.konten-top { margin-bottom: 1.5rem; }
@media (max-width: 1000px) { .bilanz { grid-template-columns: 1fr; } }

/* Banking */
.banking .clickable { cursor: pointer; }
.banking-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 1.5rem; align-items: start; }
.banking-layout > .card { margin-bottom: 0; }
.banking-layout .grid-3 { grid-template-columns: 1fr 1fr; }
.booking-fields { min-width: 0; }
.grid-fw { display: grid; grid-template-columns: 1fr; }
.fw-inputs { display: grid; grid-template-columns: 90px 1fr; gap: .5rem; }
.fw-ccy { text-transform: uppercase; }
[data-fee-preview]:empty { display: none; }
@media (max-width: 1100px) { .banking-layout { grid-template-columns: 1fr; } }
.amount-in { color: #166534; }
.amount-out { color: #991b1b; }
.truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 520px; }
.small-dropzone { padding: .9rem 1rem; }
.candidates { margin-top: 1rem; }
.candidates h3 { font-size: .95rem; margin: 0 0 .25rem; }
.invoice-paid { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: .6rem .8rem; }
.flash-error-text { color: #991b1b; }
.ignore-actions { margin-top: 1rem; }
.ignore-actions form { margin: 0; }

/* User management */
.user-row-form { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin: 0; }
.user-row-form select { width: auto; min-width: 180px; }
.switch, .check { display: flex !important; flex-direction: row !important; align-items: center; gap: .5rem !important; font-weight: 400 !important; cursor: pointer; }
.check-grid { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin-bottom: .75rem; }
.project-picklist { border: 1px solid var(--border); border-radius: 8px; max-height: 420px; overflow-y: auto; }
.project-picklist .check { padding: .45rem .75rem; border-bottom: 1px solid var(--border); margin: 0; }
.project-picklist .check:last-child { border-bottom: 0; }
.project-picklist .check .badge { margin-left: auto; }
.project-picklist[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.picklist-tools { display: flex; gap: .75rem; align-items: center; padding: .5rem .75rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; }
.picklist-tools input { max-width: 280px; }
.role-form > .card { margin-bottom: 0; }

/* Flash */
.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }
.flash-info { background: #eff6ff; color: #1e40af; }

/* Auth */
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 2rem; box-shadow: 0 10px 30px rgba(0,0,0,.05); }
.auth-card h1 { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.25rem; }
.auth-card h2 { font-size: 1.25rem; }

@media print {
  body { background: #fff; }
  .sidebar, .flash, .no-print { display: none !important; }
  .layout-app .content { padding: 0; }
  .invoice-page { margin: 0; }
  .invoice-page .invoice-doc { border: 0; max-width: none; padding: 0; }
}

@media (max-width: 860px) {
  .menu-bottom-group { margin: 0; flex-direction: row; }
  .grid-smtp { grid-template-columns: 1fr; }
  .layout-app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { padding: 1rem; }
  .menu { flex-direction: row; padding: .5rem; }
  .sidebar-user { border-top: 0; margin-left: auto; }
  .layout-app .content { padding: 1.25rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Invoice line items editor */
.items-table td { vertical-align: middle; }
.items-table input { padding: .4rem .55rem; }
.items-table .num-input { text-align: right; max-width: 120px; margin-left: auto; display: block; }
.items-table .unit-input { max-width: 110px; }
.items-table .new-item td { background: #fafbfc; }

/* Optional extra attachments on the invoice email form */
.field-group { display: flex; flex-direction: column; gap: .35rem; }
.field-label { font-weight: 500; font-size: .9rem; }
.dropzone.dropzone-sm { padding: 1rem; }

/* EBICS */
.badge-pending { background: #fef3c7; color: #92400e; }
.ebics-cell { min-width: 260px; }
.ebics-times { display: flex; flex-direction: column; gap: .1rem; margin-top: .35rem; }
.text-error { color: #b91c1c; }
.ebics-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1rem; }
.ebics-steps > li { display: grid; grid-template-columns: 2rem 1fr; gap: .75rem; align-items: start; }
.ebics-steps .step-no { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: #e5e7eb; color: #374151; }
.ebics-steps .done .step-no { background: #dcfce7; color: #166534; }
.ebics-steps .current .step-no { background: var(--primary); color: #fff; }
.ebics-steps h3 { margin: .2rem 0 .35rem; font-size: 1rem; }
.ebics-steps p { margin: .25rem 0 .5rem; }
.hash { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; word-break: break-all; background: #f6f8fa; padding: .35rem .5rem; border-radius: 6px; display: block; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem 1.5rem; margin-bottom: 1rem; }
.status-grid .label { display: block; font-size: .8rem; color: var(--muted, #6b7280); }
.status-grid strong { font-size: 1rem; }
.table-scroll { overflow-x: auto; }
.ebics-cell { min-width: 230px; }
.row-actions .btn { white-space: nowrap; }

/* Duplicate hints in banking */
form.inline { display: inline-block; margin: .25rem 0 0; }
.duplicate-warning a { font-weight: 600; }

/* Banking: split booking */
.split-box { margin-top: 1.25rem; border: 1px solid #e5e7eb; border-radius: 10px; padding: .75rem 1rem; background: #fafbfc; }
.split-box summary { cursor: pointer; }
.split-box[open] summary { margin-bottom: .75rem; }
.split-table td { vertical-align: middle; padding: .35rem .4rem; }
.split-table select, .split-table input { width: 100%; }
.split-table .num-input { text-align: right; min-width: 90px; }
.split-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: .5rem 0; flex-wrap: wrap; }
.split-parts { margin: .4rem 0 0 1.1rem; padding: 0; }
.split-table th:nth-child(1) { width: 40%; }
.split-table th:nth-child(2) { width: 32%; }
.split-table th:nth-child(3) { width: 18%; }

/* Banking: account balances above the tabs */
.bank-saldi { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: .75rem; margin: 0 0 1rem; }
.bank-saldo { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: .75rem 1rem; }
.bank-saldo-head { font-weight: 600; margin-bottom: .4rem; }
.bank-saldo-values { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.bank-saldo-values .label { display: block; font-size: .78rem; color: var(--muted); }
.bank-saldo-values strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.bank-saldo-status { margin-top: .45rem; }

/* "Keine Buchung ohne Beleg" */
.beleg-note { display: flex; flex-wrap: wrap; gap: .25rem .5rem; align-items: baseline; padding: .6rem 1rem; margin-bottom: 1rem;
  border: 1px solid #bbf7d0; border-left: 4px solid #16a34a; background: #f0fdf4; border-radius: 8px; font-size: .9rem; }
.beleg-note-missing { border-color: #fde68a; border-left-color: #d97706; background: #fffbeb; }
.beleg-note a { font-weight: 600; margin-left: auto; }
.beleg-note span { margin-left: auto; color: #166534; }
.tab-count { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: #d97706; color: #fff; font-size: .75rem; font-weight: 700; text-align: center; }
.badge-missing { background: #fef3c7; color: #92400e; }
.beleg-years .num { white-space: nowrap; }
.beleg-years tr.selected td { background: #eff6ff; }
.beleg-bulk { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.beleg-bulk > * { flex: 1 1 14rem; }
.beleg-bulk .btn { flex: 0 0 auto; }
.file-button { position: relative; overflow: hidden; display: inline-block; cursor: pointer; }
.file-button input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.doc-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.doc-list li { display: flex; gap: .75rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.doc-list li form { margin-left: auto; }
.journal .beleg-links a { margin-right: .35rem; }
.table-wrap { overflow-x: auto; margin-top: 1rem; }
.beleg-section { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.beleg-section h3 { margin: 0 0 .5rem; }
.recurring-beleg { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; }
.recurring-beleg > label:not(.check) { flex: 1 1 18rem; }
.badge-recurring { background: #e0e7ff; color: #3730a3; }
.betrag-search { max-width: 11rem; }
#fehlend .search { margin-bottom: 1rem; }
#fehlend .search input { width: 320px; max-width: 100%; }

/* Mitarbeiter: general information and Lohnblatt */
.details-2col { grid-template-columns: 140px 1fr 140px 1fr; }
@media (max-width: 800px) { .details-2col { grid-template-columns: 120px 1fr; } }
.lohn-settings { border-bottom: 1px solid var(--border); }
.lohn-settings summary { cursor: pointer; }
.lohn-settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem 1rem; margin: 1rem 0 .5rem; }
.lohn-settings-grid label { font-size: .85rem; }
.lohn-errors { margin: 0 1.5rem 1rem; }
.lohn-errors ul { margin: .25rem 0 0 1.1rem; padding: 0; }
.lohnblatt { font-size: .85rem; }
.lohnblatt th, .lohnblatt td { padding: .3rem .4rem; vertical-align: middle; }
.lohnblatt thead th { font-size: .7rem; letter-spacing: 0; text-transform: none; line-height: 1.2; min-width: 70px; vertical-align: bottom; }
.lohnblatt thead th.col-input { color: var(--text); }
.lohnblatt .num-input { width: 86px; text-align: right; padding: .25rem .35rem; font-size: .85rem; }
.lohnblatt .date-input { width: 130px; padding: .2rem .3rem; font-size: .8rem; }
.lohnblatt .num-input::placeholder { color: #9ca3af; }
.lohnblatt input.invalid { border-color: #dc2626; background: #fef2f2; }
.lohnblatt .sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; text-align: left; white-space: nowrap; padding-left: 1rem; }
.lohnblatt thead .sticky-col { background: #fafbfc; }
.lohnblatt .strong { font-weight: 600; }
.lohnblatt tr.row-sep td, .lohnblatt tr.row-sep th { border-top: 2px solid var(--border); }
.lohnblatt tfoot td, .lohnblatt tfoot th { border-top: 2px solid #9ca3af; background: #fafbfc; }
.lohnblatt .diff-warn { color: #b91c1c; }
.lohnblatt.no-hourly .col-hourly { display: none; }
.lohnblatt th.has-rate { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.badge-lohn { background: #fef3c7; color: #92400e; margin-left: .25rem; }
.journal-search { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: flex-end; border-bottom: 1px solid var(--border); background: #fafbfc; }
.journal-search label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 500; }
.journal-search label.check { flex-direction: row; align-items: center; padding-bottom: .5rem; }
.journal-search input[type=search] { min-width: 260px; }
.journal-search .badge { align-self: center; }
.journal-search-error { margin: .75rem 1.5rem; }

/* MWST-Abrechnung (ESTV form layout) */
.estv-meta { display: flex; flex-wrap: wrap; gap: .5rem 2rem; }
.estv-meta .muted { margin-right: .35rem; }
.estv-form { border-top: 4px solid #d52b1e; }
.estv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .5rem; }
.estv-section { margin: 1.5rem 0 .25rem; padding-bottom: .35rem; border-bottom: 2px solid #111827; font-size: 1.05rem; }
.estv-sub { font-weight: 600; margin: .75rem 0 .15rem; font-size: .9rem; }
.estv-colhead, .estv-row { display: grid; grid-template-columns: 3.2rem 1fr 11rem 11rem; gap: .75rem; align-items: start; }
.estv-colhead > div { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); text-align: right; }
.estv-row { padding: .45rem 0; border-bottom: 1px solid var(--border); }
.estv-nr { font-weight: 700; font-variant-numeric: tabular-nums; background: #f3f4f6; border: 1px solid var(--border); border-radius: 4px; text-align: center; padding: .1rem 0; }
.estv-label { font-size: .9rem; }
.estv-col { display: flex; justify-content: flex-end; align-items: center; gap: .25rem; min-height: 1.6rem; }
.estv-val { font-variant-numeric: tabular-nums; font-weight: 600; border: 1px solid #9ca3af; border-radius: 3px; padding: .1rem .5rem; min-width: 8rem; text-align: right; background: #fff; }
.estv-zero { color: var(--muted); font-weight: 400; }
.estv-copy { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 .15rem; font-size: .9rem; }
.estv-copy:hover, .estv-copy.copied { color: var(--primary, #2563eb); }
.estv-total .estv-val { border-width: 2px; border-color: #111827; }
.estv-na .estv-label { color: var(--muted); }
.estv-details { margin-top: .25rem; font-size: .85rem; }
.estv-details summary { cursor: pointer; color: var(--muted); }
.mwst-override { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: 1rem 0; }
.mwst-override select { max-width: 26rem; }
@media (max-width: 760px) {
  .estv-colhead, .estv-row { grid-template-columns: 2.6rem 1fr; }
  .estv-colhead > div:nth-child(n+3) { display: none; }
  .estv-col { grid-column: 2; justify-content: flex-start; }
  .estv-col:empty { display: none; }
}
.table-compact th, .table-compact td { padding: .35rem .6rem; }

/* MWST: due return (tab blinks yellow), yearly reminder, submission status */
@keyframes mwst-blink { 0%, 100% { background: #fef08a; box-shadow: 0 0 0 2px #facc15; } 50% { background: transparent; box-shadow: none; } }
.tabs a.tab-blink { animation: mwst-blink 1.2s ease-in-out infinite; border-radius: 6px; }
.tab-count-warn { background: #ca8a04; }
.flash-warn { background: #fefce8; border: 1px solid #facc15; color: #713f12; }
.mwst-jahr-note { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.mwst-status { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.mwst-status form { display: inline-flex; align-items: center; gap: .5rem; margin: 0; }
.mwst-status input[type=date] { width: auto; }
@media (prefers-reduced-motion: reduce) { .tabs a.tab-blink { animation: none; background: #fef08a; } }

/* Sales: checklist */
.checklist { list-style: none; margin: 0 0 1rem; padding: 0; }
.checklist li { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist .check-text { flex: 1; white-space: pre-wrap; }
.checklist li.done .check-text { text-decoration: line-through; color: var(--muted); }
.check-toggle { flex: none; width: 2rem; height: 2rem; border: 2px solid #9ca3af; border-radius: 6px; background: #fff; cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.check-toggle:hover { border-color: #16a34a; background: #f0fdf4; }
.check-toggle.checked { border-color: #16a34a; background: #dcfce7; }
.check-toggle svg { width: 1.6rem; height: 1.6rem; fill: none; stroke: #16a34a; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.checklist-add { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; }
.checklist-add textarea { width: 100%; }
.user-picks { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; border: 0; padding: 0; margin: 0 0 .5rem; }
.user-picks legend { font-weight: 600; margin-bottom: .35rem; }

/* Ticketing: kanban board */
.kanban { display: grid; grid-template-columns: repeat(var(--lanes, 4), minmax(230px, 1fr)); gap: 1rem; overflow-x: auto; padding-bottom: .5rem; align-items: start; }
.kanban-lane { background: #e9edf3; border-radius: var(--radius); padding: .75rem; min-height: 300px; display: flex; flex-direction: column; gap: .6rem; }
.kanban-lane.drop-target { background: #dbeafe; outline: 2px dashed var(--primary); outline-offset: -2px; }
.kanban-lane-head { display: flex; justify-content: space-between; align-items: center; }
.kanban-lane-head h2 { margin: 0; font-size: .95rem; }
.kanban-count { background: #fff; border-radius: 999px; padding: 0 .55rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.kanban-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.kanban-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: .6rem .7rem; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.kanban-card[draggable=true] { cursor: grab; }
.kanban-card.dragging { opacity: .4; }
.kanban-card:hover { border-color: #b7c3d4; }
.kanban-card-link { display: block; color: var(--text); }
.kanban-card-link:hover { text-decoration: none; color: var(--primary); }
.kanban-card-no { color: var(--muted); font-size: .8rem; margin-right: .3rem; }
.kanban-card-title { font-weight: 500; overflow-wrap: anywhere; }
.kanban-card-meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .4rem; font-size: .75rem; color: var(--muted); }
.kanban-card-meta > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card-icons { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; }
.avatar-xs { width: 22px; height: 22px; font-size: .65rem; background: var(--primary); }
.kanban-empty { text-align: center; margin: 0; }
.kanban-new > summary { list-style: none; text-align: center; }
.kanban-new > summary::-webkit-details-marker { display: none; }
.kanban-new[open] > summary { margin-bottom: .6rem; }
.kanban-new form { background: #fff; border-radius: 8px; padding: .75rem; }
.btn-active { background: #eff6ff; border-color: var(--primary); color: var(--primary-dark); }

/* Ticketing: ticket detail */
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.5rem; align-items: start; }
.ticket-layout .card { margin-bottom: 1.5rem; }
.ticket-description { overflow-wrap: anywhere; }
.ticket-sub { font-size: .95rem; margin: 1.25rem 0 .5rem; }
.ticket-files { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem; }
.ticket-files li { display: flex; flex-direction: column; gap: .2rem; max-width: 200px; overflow-wrap: anywhere; }
.ticket-thumb img { display: block; width: 180px; height: 120px; object-fit: cover; border: 1px solid var(--border); border-radius: 6px; background: #f3f4f6; }
.ticket-thumb-sm img { width: 120px; height: 80px; }
.ticket-props { display: grid; grid-template-columns: 95px 1fr; gap: .6rem .75rem; margin: 0; align-items: center; }
.ticket-props dt { color: var(--muted); font-size: .85rem; }
.ticket-props dd { margin: 0; overflow-wrap: anywhere; }
.ticket-props form { margin: 0; }
.timeline { list-style: none; margin: 0 0 1.25rem; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.timeline-comment { border: 1px solid var(--border); border-radius: 8px; padding: .65rem .8rem; background: #fff; overflow-wrap: anywhere; }
.timeline-comment.team { border-left: 3px solid var(--primary); }
.timeline-comment.intern { background: #fffbeb; border-color: #fde68a; }
.timeline-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .25rem; }
.timeline-event { padding-left: .8rem; border-left: 2px solid var(--border); }
.timeline-files { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.timeline-files li { display: flex; flex-direction: column; gap: .2rem; }
@media (max-width: 900px) { .ticket-layout { grid-template-columns: 1fr; } }

/* Ticketing: board form */
.type-info { margin: -.5rem 0 0; padding-left: 1.1rem; }
.lane-fields { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.lane-fields legend { font-weight: 500; font-size: .9rem; margin-bottom: .3rem; padding: 0; }
.lane-row { display: flex; align-items: center; gap: .6rem; }
.lane-no { flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: #e5e7eb; display: grid; place-items: center; font-size: .8rem; font-weight: 600; }
.password-once { font-size: 1rem; background: #fff; padding: .1rem .4rem; border-radius: 4px; user-select: all; }

/* Ticketing: customer portal layout */
.layout-portal { min-height: 100vh; }
.portal-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; background: var(--sidebar); color: var(--sidebar-text); padding: 0 1.5rem; flex-wrap: wrap; }
.portal-bar .brand { padding: .9rem 0; }
.portal-user { display: flex; align-items: center; gap: 1rem; font-size: .9rem; }
.portal-user span { color: #fff; }
.portal-user a { color: var(--sidebar-text); }
.portal-user form { margin: 0; }
.portal-content { padding: 2rem 2.5rem; }
.portal-narrow { margin: 0 auto; }
.portal-login { display: flex; justify-content: center; align-items: flex-start; gap: 1.5rem; flex-wrap: wrap; margin-top: 2rem; }
.portal-login .auth-card { max-width: 380px; }
.report-link { overflow-wrap: anywhere; background: #f3f4f6; padding: .6rem .8rem; border-radius: 8px; }
.hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 860px) { .portal-content { padding: 1.25rem; } .kanban { grid-template-columns: repeat(var(--lanes, 4), minmax(220px, 80vw)); } }

/* Projects: contract documents */
.project-docs th { text-align: left; vertical-align: top; width: 1%; padding-top: .7rem; font-weight: 600; text-transform: none; letter-spacing: normal; font-size: .9rem; color: var(--text); background: none; }
.project-docs td { vertical-align: top; }
.project-docs .doc-list { margin: 0; }
.project-docs .doc-list li { flex-wrap: wrap; border-bottom: 0; padding: .2rem 0; }

/* Ticketing: documentation (wiki) */
.board-tabs { margin-bottom: 1rem; width: fit-content; }
.page-head .board-tabs { margin-bottom: 0; }
.wiki-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.wiki-nav { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
.wiki-nav h2 a { color: var(--text); }
.wiki-tree { list-style: none; margin: 0; padding: 0; }
.wiki-tree li { padding: .2rem .4rem .2rem calc(.4rem + var(--depth, 0) * 1rem); border-radius: 6px; font-size: .9rem; overflow-wrap: anywhere; }
.wiki-tree li.active { background: #eff6ff; font-weight: 600; }
.wiki-tree li.active a { color: var(--primary-dark); }
.wiki-lock { font-size: .75rem; }
.wiki-main .card { margin-bottom: 1.5rem; }
.wiki-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.wiki-title { margin-bottom: .35rem; }
.wiki-crumbs { margin: 0 0 .25rem; }
.wiki-content { line-height: 1.65; overflow-wrap: anywhere; }
.wiki-content h1 { font-size: 1.45rem; margin: 1.5rem 0 .5rem; }
.wiki-content h2 { font-size: 1.2rem; margin: 1.4rem 0 .5rem; padding-bottom: .25rem; border-bottom: 1px solid var(--border); }
.wiki-content h3 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
.wiki-content > :first-child { margin-top: 0; }
.wiki-content code { background: #f3f4f6; padding: .1rem .3rem; border-radius: 4px; font-size: .88em; }
.wiki-content pre { background: #111827; color: #e5e7eb; padding: .9rem 1rem; border-radius: 8px; overflow-x: auto; }
.wiki-content pre code { background: none; padding: 0; color: inherit; }
.wiki-content blockquote { margin: 1rem 0; padding: .25rem 1rem; border-left: 3px solid #cfd6e0; color: var(--muted); }
.wiki-content table { border-collapse: collapse; margin: 1rem 0; }
.wiki-content th, .wiki-content td { border: 1px solid var(--border); padding: .4rem .6rem; text-align: left; }
.wiki-content th { background: #f8fafc; }
.wiki-content img { max-width: 100%; }
.wiki-subpages { margin: 0; padding-left: 1.2rem; }
.wiki-editor { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; line-height: 1.5; }
.wiki-conflict { margin-bottom: 1rem; }
.wiki-conflict summary { cursor: pointer; font-weight: 500; margin-bottom: .5rem; }
.diff-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.diff { border-collapse: collapse; width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.diff td { padding: .1rem .5rem; vertical-align: top; }
.diff-no { width: 1%; color: var(--muted); text-align: right; user-select: none; white-space: nowrap; background: #f8fafc; }
.diff-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-sign { display: inline-block; width: 1.1rem; user-select: none; color: var(--muted); }
.diff-add td { background: #dcfce7; }
.diff-add .diff-no { background: #bbf7d0; }
.diff-del td { background: #fee2e2; }
.diff-del .diff-no { background: #fecaca; }
.diff-skip td { background: #eff6ff; color: #1e40af; text-align: center; font-family: inherit; }
.diff-add-inline { background: #dcfce7; text-decoration: none; padding: 0 .2rem; }
.diff-del-inline { background: #fee2e2; padding: 0 .2rem; }
.diff-stat-add { color: #15803d; font-weight: 600; }
.diff-stat-del { color: #b91c1c; font-weight: 600; }
@media (max-width: 900px) { .wiki-layout { grid-template-columns: 1fr; } .wiki-nav { position: static; max-height: none; } }
.wiki-history .row-actions { white-space: normal; }
.wiki-history .row-actions > * { margin: .1rem 0; }
.wiki-main .card { overflow-x: auto; }

/* Sales: Rapporte next to the checklist */
.sales-lists { margin-bottom: 1.5rem; align-items: start; }
.rapport-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.rapport-list li { padding: .55rem 0; border-bottom: 1px solid var(--border); }
.rapport-list li:last-child { border-bottom: 0; }
.rapport-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .2rem; }
.rapport-actions { margin-left: auto; display: inline-flex; gap: .35rem; align-items: center; }
.rapport-actions form { margin: 0; }
.rapport-date { width: auto !important; }
.rapport-search { margin-bottom: .5rem; }
.rapport-search input[type=search] { flex: 1; width: auto; }
.rapport-results td { vertical-align: top; }
.rapport-results mark { background: #fef08a; padding: 0 .1rem; border-radius: 2px; }

/* Contacts: further contact persons of a business contact */
.col-stack { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }
.col-stack > .card { margin-bottom: 0; }
.person-list { list-style: none; margin: 0; padding: 0; }
.person-list li { padding: .65rem 0; border-bottom: 1px solid var(--border); }
.person-list li:first-child { padding-top: 0; }
.person-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.person-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.person-actions { margin-left: auto; display: inline-flex; gap: .35rem; align-items: center; }
.person-actions form { margin: 0; }
.person-funktion { color: var(--muted); font-size: .9rem; margin-top: .15rem; }
.person-contact { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; font-size: .9rem; margin-top: .25rem; }
.person-contact a { overflow-wrap: anywhere; }
.person-form { margin-bottom: 1rem; }
.person-list li .person-form { margin-bottom: 0; }
.person-rows { border: 1px solid var(--border); border-radius: 10px; padding: .75rem 1rem 1rem; margin: 0; display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.person-rows legend { font-weight: 600; padding: 0 .35rem; }
.person-rows > p { margin: 0; }
.person-rows [data-person-rows] { display: flex; flex-direction: column; gap: .75rem; }
.person-row { display: flex; flex-direction: column; gap: .75rem; padding: .75rem; background: var(--bg, #f4f5f8); border-radius: 8px; }
.person-row .btn { align-self: flex-start; }
.rapport-fields { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; width: 100%; }
.rapport-person-select { width: auto !important; max-width: 100%; flex: 1 1 14rem; }
.rapport-person { font-size: .9rem; color: var(--muted); margin-bottom: .15rem; }
.rapport-person strong { color: var(--text, inherit); font-weight: 600; }

/* Dashboard: open Todos and last Rapporte of a salesperson */
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-project { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; padding: .75rem 0 .3rem; }
.todo-project:first-child { padding-top: 0; }
.todo-item { display: flex; align-items: center; gap: .6rem; padding: .35rem 0 .35rem .25rem; border-bottom: 1px solid var(--border); }
.todo-item form.inline { margin: 0; }
.todo-item .check-text { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
.dashboard-rapporte { margin-top: 1.5rem; }
.rapport-snippet { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 16rem; }

/* Meine Tickets (overview of assigned tickets in progress) */
.my-tickets td { vertical-align: top; }
.badge-lane-2 { background: #e0ecff; color: #1d4ed8; }
.badge-lane-3 { background: #fef3c7; color: #92400e; }
.badge-lane-4 { background: #ede9fe; color: #6d28d9; }
.dashboard-tickets { margin-bottom: 1.5rem; }

/* Beleg upload: what was read from the document */
.beleg-hint { display: flex; flex-direction: column; gap: .3rem; padding: .7rem .9rem; border: 1px solid #bfdbfe; background: #eff6ff; border-radius: 8px; font-size: .9rem; }
.beleg-hint.loading { color: var(--muted); border-color: var(--border); background: var(--bg); }
.beleg-hint-facts { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
