/* ------------------------------------------------------------------
   pixelpublic Mahnwesen – Corporate Design
   Schwarz/Weiß mit Khaki-Akzent (#9A8E6B), Schrift Aptos.
   ------------------------------------------------------------------ */
:root {
  --khaki: #9A8E6B;
  --black: #111111;
  --dark-grey: #555555;
  --mid-grey: #666666;
  --grey: #888888;
  --light-grey: #AAAAAA;
  --rule: #DDDDDD;
  --bg-light: #F4F4F4;
  --bg-off: #FAFAFA;
  --white: #FFFFFF;
  --danger: #A6321F;      /* funktionaler Warnton nur für kritischen Verzug */
  --danger-bg: #F7ECEA;
  --font: "Aptos", "Segoe UI", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Das hidden-Attribut muss immer gewinnen. Sonst ueberstimmt jede Regel mit eigenem
   display (.btn, Overlays, Flex-Container) das Verstecken – die Elemente bleiben
   sichtbar, obwohl das JS sie ausgeblendet hat. Fuer .modal-overlay war das schon
   einzeln geflickt; diese Regel deckt alle 38 hidden-Umschaltungen im JS ab. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--black);
  background: var(--bg-off);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--khaki); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Kopfzeile ---------------------------------------------------- */
.site-header {
  background: var(--black);
  color: var(--white);
  padding: 0;
  border-bottom: 3px solid var(--khaki);
}
.site-header .bar {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand .name { font-weight: 700; font-size: 20px; letter-spacing: 0.5px; }
.brand .name .cube { color: var(--khaki); }
.brand .tagline { font-size: 11px; color: var(--light-grey); letter-spacing: 1px; margin-top: 2px; }
.brand .tagline b { color: var(--white); font-weight: 700; }

.site-header nav { display: flex; gap: 20px; margin-left: auto; align-items: center; }
.site-header nav a { color: var(--white); font-size: 14px; letter-spacing: 0.3px; }
.site-header nav a.active { color: var(--khaki); font-weight: 700; }
.site-header nav .user { color: var(--light-grey); font-size: 13px; }
.site-header nav a:has(.avatar) { display: inline-flex; align-items: center; gap: 7px; }
.avatar { border-radius: 50%; object-fit: cover; vertical-align: middle; display: inline-block; background: var(--bg-off); }
.avatar-lg { width: 64px; height: 64px; }
.avatar-xs { width: 18px; height: 18px; margin-right: 4px; vertical-align: -4px; }
.bulk-bar { display: flex; align-items: center; gap: 12px; margin: 8px 0 12px; }
.bulk-bar .btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Konfigurierbare Spalten der Vorgangsliste */
table.grid thead th { position: relative; }
.col-resize { position: absolute; top: 0; right: 0; width: 8px; height: 100%; cursor: col-resize; }
.col-resize:hover { background: var(--khaki); opacity: 0.4; }
.spalten-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: 270px;
  background: var(--white); border: 1px solid var(--rule); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.16); padding: 12px; }
.sp-head { font-weight: 700; margin-bottom: 4px; }
.sp-list { list-style: none; margin: 0 0 10px; padding: 0; max-height: 340px; overflow: auto; }
.sp-item { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 4px; }
.sp-item:hover { background: var(--bg-off); }
.sp-item.dragging { opacity: 0.5; }
.sp-grip { cursor: grab; color: var(--mid-grey); user-select: none; letter-spacing: -2px; }
.sp-item label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: normal; margin: 0; }
.sp-actions { display: flex; gap: 8px; justify-content: flex-end; }
.monat-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.monat-tab { border: 1px solid var(--mid-grey); background: var(--white); color: var(--black); padding: 5px 12px; font-size: 13px; cursor: pointer; border-radius: 3px; }
.monat-tab:hover { border-color: var(--khaki); }
.monat-tab.is-active { background: var(--khaki); color: var(--white); border-color: var(--khaki); }

/* --- Layout ------------------------------------------------------- */
main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }
/* Dashboard nutzt die volle Breite, damit alle Spalten passen. */
main.wide { max-width: none; }
.page-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0; font-weight: 700; }
.page-head .sub { color: var(--mid-grey); font-size: 14px; }
.eyebrow { color: var(--khaki); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; font-weight: 700; }

/* --- Buttons ------------------------------------------------------ */
.btn {
  display: inline-block;
  border: 1px solid var(--black);
  background: var(--black);
  color: var(--white);
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  border-radius: 2px;
}
.btn:hover { background: var(--khaki); border-color: var(--khaki); text-decoration: none; }
.btn.secondary { background: var(--white); color: var(--black); }
.btn.secondary:hover { background: var(--bg-light); color: var(--black); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: var(--white); color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: var(--white); }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover, .btn[disabled]:hover { background: var(--black); border-color: var(--black); color: var(--white); }

/* --- Flash -------------------------------------------------------- */
.flash { padding: 11px 16px; border-radius: 2px; margin-bottom: 10px; font-size: 14px; border-left: 4px solid var(--grey); background: var(--bg-light); }
.flash.success { border-left-color: var(--khaki); }
.flash.error { border-left-color: var(--danger); background: var(--danger-bg); }
.flash.info { border-left-color: var(--dark-grey); }

/* --- Toolbar / Filter --------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 18px; padding: 16px; background: var(--white); border: 1px solid var(--rule); border-radius: 3px; }
.toolbar .field { display: flex; flex-direction: column; gap: 4px; }
.toolbar label { font-size: 12px; color: var(--mid-grey); letter-spacing: 0.4px; }
.toolbar select, .toolbar input[type=text], .toolbar input[type=date], .toolbar input[type=search] { padding: 7px 9px; border: 1px solid var(--rule); border-radius: 2px; font-family: var(--font); font-size: 14px; }
.toolbar select[multiple] { padding: 4px 6px; min-width: 190px; }
.toolbar .field label .muted { font-size: 11px; }
.toolbar .spacer { margin-left: auto; }
.sync-status { font-size: 13px; color: var(--mid-grey); }
.sync-status b { color: var(--black); }

/* --- Tabelle ------------------------------------------------------ */
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--rule); border-radius: 3px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.grid thead th { background: var(--bg-light); font-size: 12px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--mid-grey); cursor: pointer; user-select: none; }
table.grid thead th.sortable::after { content: " \2195"; color: var(--light-grey); }
table.grid tbody tr:hover { background: var(--bg-off); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid .kunde { white-space: normal; max-width: 260px; }
table.grid td.verzug-cell { text-align: center; }
table.grid .muted { color: var(--grey); font-size: 12px; }

/* Verzugs-Kennzeichnung (Farbcodierung) */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.3px; }
.badge.is-ok { background: var(--bg-light); color: var(--mid-grey); }
.badge.is-warn { background: #F0ECE0; color: #6E6444; }
.badge.is-alert { background: var(--khaki); color: var(--white); }
.badge.is-critical { background: var(--danger); color: var(--white); }
tr.row-critical td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.row-alert td:first-child { box-shadow: inset 3px 0 0 var(--khaki); }
/* Bezahlte Belege: grüner Balken links, kein Verzug */
tr.row-paid td:first-child { box-shadow: inset 3px 0 0 #2E7D32; }
.badge.is-paid { background: #E6F4EA; color: #2E7D32; }

/* Historie: Versand-Kennzeichnung je Mahntext */
.tag-sent { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
    background: #E6F4EA; color: #2E7D32; margin-left: 6px; }
.tag-draft { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
    background: #FFF8E1; color: #8A6D00; margin-left: 6px; }
/* Wartet auf den geplanten Versand – blau, damit es sich klar von „verschickt" (gruen)
   und „nicht verschickt" (gelb) unterscheidet. */
.tag-geplant { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
    background: #E8F0FE; color: #1A4FA0; margin-left: 6px; }
.history-item.is-sent { border-left: 3px solid #2E7D32; padding-left: 9px; }

/* Geplanter Versand im Versanddialog */
.plan-box { border: 1px solid var(--rule); border-radius: 6px; padding: 10px 12px; margin: 0 0 14px; }
.plan-toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.plan-toggle input { width: auto; margin: 0; }
.plan-zeile { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.plan-zeile > span { display: flex; flex-direction: column; gap: 4px; }
.plan-zeile label { font-size: 12px; color: var(--dark-grey); }
.plan-zeile input[type="date"], .plan-zeile select { width: auto; min-width: 160px; }

.status-pill { font-size: 12px; padding: 2px 8px; border: 1px solid var(--rule); border-radius: 999px; color: var(--dark-grey); }
.tag-akonto { font-size: 11px; background: var(--black); color: var(--white); padding: 1px 6px; border-radius: 2px; margin-left: 6px; }
.tag-pruef { font-size: 11px; background: var(--danger-bg); color: var(--danger); padding: 1px 6px; border-radius: 2px; border: 1px solid var(--danger); }

/* --- Detail ------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: start; }
.card { background: var(--white); border: 1px solid var(--rule); border-radius: 3px; padding: 20px; margin-bottom: 20px; }
.card h2 { font-size: 16px; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 2px solid var(--khaki); }
dl.facts { display: grid; grid-template-columns: 190px 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--mid-grey); font-size: 13px; }
dl.facts dd { margin: 0; font-size: 14px; }
dl.facts dd.big { font-size: 18px; font-weight: 700; }

textarea, input[type=text], input[type=number], input[type=password], input[type=email], select {
  font-family: var(--font); font-size: 14px;
}
.form-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-row label { font-size: 13px; color: var(--mid-grey); }
.form-row input, .form-row select, .form-row textarea { padding: 8px 10px; border: 1px solid var(--rule); border-radius: 2px; width: 100%; }
.form-row textarea { min-height: 200px; resize: vertical; line-height: 1.55; }
.hint { font-size: 12px; color: var(--grey); }
.inline-form { display: inline; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.generated { border: 1px solid var(--khaki); border-radius: 3px; padding: 16px; background: var(--bg-off); }
.generated .subject { font-weight: 700; margin-bottom: 8px; }
.copy-area { width: 100%; min-height: 240px; font-family: "Consolas", "Courier New", monospace; font-size: 13px; padding: 12px; border: 1px solid var(--rule); border-radius: 2px; }

.history-item { border-left: 3px solid var(--khaki); padding: 8px 14px; margin-bottom: 12px; background: var(--bg-off); }
.history-item .meta { font-size: 12px; color: var(--mid-grey); margin-bottom: 4px; }
.history-item pre { white-space: pre-wrap; font-family: var(--font); font-size: 13px; margin: 6px 0 0; }

.placeholders { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.placeholders code { background: var(--bg-light); border: 1px solid var(--rule); padding: 2px 6px; border-radius: 2px; font-size: 12px; cursor: pointer; }

/* --- Login -------------------------------------------------------- */
.login-wrap { max-width: 380px; margin: 8vh auto; }
.login-wrap .card { padding: 28px; }
.empty { text-align: center; color: var(--grey); padding: 48px 16px; }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .site-header nav { gap: 12px; }
}

/* --- Finanzübersicht ---------------------------------------------- */
.bn-toggle { display: inline-flex; border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.bn-toggle .btn { border: none; border-radius: 0; }
.bn-toggle .btn.is-active { background: var(--khaki); color: var(--white); }

.finanz-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.finanz-card { margin-bottom: 0; }
.finanz-card .fc-label { font-size: 13px; color: var(--mid-grey); letter-spacing: 0.3px; }
.finanz-card .fc-sum { font-size: 28px; font-weight: 700; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.finanz-card .fc-meta { font-size: 12px; color: var(--grey); }
.finanz-card.fc-total { background: var(--black); color: var(--white); border-color: var(--black); }
.finanz-card.fc-total .fc-label { color: var(--khaki); }
.finanz-card.fc-total .fc-meta { color: var(--light-grey); }

/* Brutto/Netto-Umschaltung */
#finanz.mode-brutto .v-netto { display: none; }
#finanz.mode-netto .v-brutto { display: none; }

.chart-wrap { margin-top: 8px; }
.verlauf-chart { width: 100%; height: 240px; display: block; background: var(--bg-off); border: 1px solid var(--rule); border-radius: 3px; }
.verlauf-chart polyline { stroke-width: 2; vector-effect: non-scaling-stroke; }
.verlauf-chart .line-brutto { stroke: var(--khaki); }
.verlauf-chart .line-netto { stroke: var(--dark-grey); }
#finanz.mode-brutto .verlauf-chart .line-netto { display: none; }
#finanz.mode-netto .verlauf-chart .line-brutto { display: none; }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--mid-grey); margin-top: 6px; }

/* Manuelle Nachbearbeitung der Tageswerte (nur Admins) */
.manuell-badge {
  display: inline-block; margin-left: 5px; padding: 0 5px;
  border: 1px solid var(--khaki); background: #F0ECE0; color: #6E6444;
  border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 17px;
}
.fin-edit-toggle.is-active { background: var(--khaki); color: var(--white); border-color: var(--khaki); }
.fin-edit-row > td { background: var(--bg-off); }
.fin-edit-form { padding: 10px 4px; }
.fin-edit-head { font-weight: 700; margin-bottom: 8px; }
.fin-edit-grid { width: auto; border-collapse: collapse; }
.fin-edit-grid th, .fin-edit-grid td { padding: 4px 10px 4px 0; text-align: left; font-size: 13px; }
.fin-edit-grid th { color: var(--mid-grey); font-weight: 600; }
.fin-edit-grid input { width: 130px; padding: 5px 7px; border: 1px solid var(--rule); border-radius: 3px; text-align: right; font-variant-numeric: tabular-nums; }
.fin-edit-actions { margin-top: 10px; display: flex; gap: 8px; }
.fin-edit-hint { margin: 8px 0 0; font-size: 12px; }
.badge-comment.is-empty { border-color: var(--rule); background: transparent; color: var(--mid-grey); font-weight: 400; }
.badge-comment.is-empty:hover { border-color: var(--khaki); background: var(--khaki); color: var(--white); }
#finKommList .history-item { position: relative; }
#finKommList .history-item .inline-form { position: absolute; top: 8px; right: 8px; }

/* --- Jahresübersicht (Heatmap-Raster) --- */
.jahr-waehler { display: flex; flex-wrap: wrap; gap: 6px; }
.metrik-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.metrik-legende { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.heat-scale { display: inline-block; width: 90px; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, hsl(0,60%,82%), hsl(60,60%,82%), hsl(120,60%,82%)); }
.heat-scale.rev { background: linear-gradient(90deg, hsl(120,60%,82%), hsl(60,60%,82%), hsl(0,60%,82%)); }
table.heatmap-grid { border-collapse: collapse; font-variant-numeric: tabular-nums; width: 100%; table-layout: fixed; }
table.heatmap-grid col.hg-col-day { width: 46px; }
table.heatmap-grid th, table.heatmap-grid td { border: 1px solid var(--rule); text-align: right;
  padding: 5px 8px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.heatmap-grid thead th { background: var(--bg-off); text-align: center; position: sticky; top: 0; z-index: 1; }
table.heatmap-grid th.hg-day { text-align: center; color: var(--mid-grey); font-weight: 600; background: var(--bg-off);
  position: sticky; left: 0; z-index: 2; }
.heatmap-grid td.hg-cell { color: #333; cursor: pointer; }
.heatmap-grid td.hg-cell:hover { outline: 2px solid var(--black); outline-offset: -2px; }
.heatmap-grid td.hg-cell.is-manuell { font-weight: 700; box-shadow: inset 0 0 0 2px var(--khaki); }
.heatmap-grid td.hg-empty { background: repeating-linear-gradient(45deg, #fff, #fff 4px, #f4f4f4 4px, #f4f4f4 8px); cursor: pointer; }
.heatmap-grid td.hg-void { background: #fafafa; }
.heatmap-grid .hg-mark { font-size: 10px; margin-right: 2px; vertical-align: middle; }
.marker-legende { margin: 6px 0 2px; font-size: 11px; }

/* --- Detailseite: frei anordenbare Info-Boxen (Drag & Drop) --- */
.box-toolbar { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; flex-wrap: wrap; }
.box-grip-demo { color: #9A8E6B; }
.box-layout .box-col { min-height: 40px; }
.box-layout .card[data-box] > h2 { cursor: grab; user-select: none; }
.box-layout .card[data-box] > h2::before { content: "\2059"; color: #c3c3c3; margin-right: 8px; font-weight: 400; letter-spacing: -2px; }
.box-layout .card[data-box] > h2:active { cursor: grabbing; }
.box-layout .card.dragging { opacity: .45; outline: 2px dashed #9A8E6B; }
.box-col.box-drop-active { outline: 2px dashed rgba(154, 142, 107, .5); outline-offset: 4px; border-radius: 6px; }

/* --- Dashboard: Notiz-Spalte (inline, 2-zeilig gekürzt, aufklappbar) --- */
table.grid th[data-col="notizen"] { width: 190px; }
table.grid td[data-col="notizen"] { white-space: normal; }
.notiz-cell { display: flex; align-items: flex-start; gap: 6px; width: 100%; max-width: 260px; background: none; border: none; padding: 0; margin: 0; cursor: pointer; text-align: left; color: inherit; }
.notiz-cell .notiz-text {
    flex: 1 1 auto; min-width: 0;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
    overflow: hidden; white-space: normal; word-break: break-word;
    font-size: 12px; line-height: 1.3; max-height: 2.6em;
}
.notiz-cell .notiz-more { flex: 0 0 auto; color: #9A8E6B; font-size: 12px; margin-top: 1px; }
.notiz-cell:hover .notiz-text { text-decoration: underline; }

/* --- App-Footer + Versionslink --- */
.app-footer { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap;
    max-width: 1200px; margin: 28px auto 18px; padding: 12px 20px 0; border-top: 1px solid var(--rule);
    font-size: 12px; color: var(--mid-grey); }
.app-footer .af-name { color: var(--mid-grey); }
.app-footer .af-changelog { color: var(--khaki); text-decoration: none; font-weight: 600; }
.app-footer .af-changelog:hover { text-decoration: underline; }

/* --- Changelog-Seite --- */
.cl-current { font-size: 13px; color: var(--mid-grey); }
.changelog { position: relative; margin-left: 6px; }
.cl-release { position: relative; display: grid; grid-template-columns: 150px 1fr; gap: 18px;
    padding: 0 0 22px 18px; border-left: 2px solid var(--rule); }
.cl-release:last-child { border-left-color: transparent; }
.cl-release::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px;
    border-radius: 50%; background: #fff; border: 2px solid var(--mid-grey); }
.cl-release.is-latest::before { border-color: var(--khaki); background: var(--khaki); }
.cl-meta { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.cl-version { font-weight: 700; font-size: 16px; color: var(--black, #111); }
.cl-date { font-size: 12px; color: var(--mid-grey); }
.cl-latest-badge { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700;
    color: #2E7D32; background: #E6F4EA; border-radius: 4px; padding: 1px 6px; }
.cl-title { font-size: 15px; margin: 0 0 10px; }
.cl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.cl-item { display: flex; gap: 10px; align-items: baseline; }
.cl-text { font-size: 13.5px; line-height: 1.4; }
.cl-tag { flex: 0 0 auto; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    padding: 2px 8px; border-radius: 4px; min-width: 74px; text-align: center; }
.cl-neu { background: #E6F4EA; color: #2E7D32; }
.cl-verbessert { background: #EAF0FB; color: #2b5fb3; }
.cl-fix { background: #FFF8E1; color: #8A6D00; }
.cl-sicherheit { background: #FCE8E6; color: #B71C1C; }
@media (max-width: 640px) {
    .cl-release { grid-template-columns: 1fr; gap: 8px; }
    .cl-meta { flex-direction: row; align-items: center; gap: 10px; }
}

/* --- Jahres-Liniendiagramm mit Achsen + Hover --- */
.jc-titel { margin: 0; font-size: 15px; }

/* Cross-Jahr-Hover-Tooltip (Heatmap) */
.hg-tip { position: fixed; z-index: 60; background: var(--black); color: var(--white); padding: 8px 10px;
  border-radius: 5px; font-size: 12px; min-width: 150px; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  font-variant-numeric: tabular-nums; }
.hg-tip-head { font-weight: 700; margin-bottom: 5px; border-bottom: 1px solid rgba(255,255,255,.2); padding-bottom: 4px; }
.hg-tip-row { display: flex; justify-content: space-between; gap: 16px; line-height: 1.5; }
.hg-tip-row span { color: var(--light-grey); }
.hg-tip-row b.up { color: #4ADE80; }
.hg-tip-row b.down { color: #F87171; }

/* Forderungs-Split im Tagesdetail */
.tag-split { border-collapse: collapse; margin-top: 4px; }
.tag-split td { padding: 3px 10px 3px 0; font-size: 13px; }
.tag-split td.num { text-align: right; font-variant-numeric: tabular-nums; }
.jc { display: grid; grid-template-columns: 78px 1fr; grid-template-rows: 240px 20px; column-gap: 8px; }
.jc-yaxis { position: relative; grid-column: 1; grid-row: 1; }
.jc-ylabel { position: absolute; right: 4px; transform: translateY(-50%); font-size: 11px;
  color: var(--mid-grey); white-space: nowrap; font-variant-numeric: tabular-nums; }
.jc-plot { position: relative; grid-column: 2; grid-row: 1; background: var(--bg-off);
  border: 1px solid var(--rule); border-radius: 3px; }
.jc-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.jc-svg .jc-grid { stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }
.jc-svg .jc-grid-v { stroke: #ececec; }
.jc-svg .jc-line { stroke: var(--khaki); stroke-width: 2; vector-effect: non-scaling-stroke; }
.jc-svg .jc-line-n { stroke: var(--dark-grey); }
.jc-svg .jc-year { stroke-width: 1.5; opacity: 0.85; }
.jc-svg .jc-current { stroke-width: 2.6; opacity: 1; }
/* Legende + Titelzeile des Jahres-Diagramms */
.jc-titel-zeile { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin: 18px 0 8px; }
.jc-legend { display: flex; flex-wrap: wrap; gap: 12px; }
.jc-leg { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; cursor: pointer; user-select: none; }
.jc-swatch { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
/* Brutto/Netto-Umschaltung des Verlaufsdiagramms (Haupt-Finanzübersicht) */
#finanz.mode-brutto .jc-line-n { display: none; }
#finanz.mode-netto .jc-line-b { display: none; }
.jc-xaxis { position: relative; grid-column: 2; grid-row: 2; }
.jc-xlabel { position: absolute; transform: translateX(-50%); top: 3px; font-size: 11px; color: var(--mid-grey); }
.jc-guide { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--dark-grey); opacity: 0.5; pointer-events: none; }
.jc-dot { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%;
  background: var(--khaki); border: 2px solid var(--white); pointer-events: none; }
.jc-tip { position: absolute; transform: translate(-50%, -140%); background: var(--black); color: var(--white);
  padding: 5px 9px; border-radius: 4px; font-size: 12px; white-space: nowrap; pointer-events: none; z-index: 5;
  font-variant-numeric: tabular-nums; }

/* --- Tages-Detail-Modal --- */
.tag-abschnitt { padding: 10px 0; border-top: 1px solid var(--rule); }
.tag-abschnitt:first-child { border-top: none; }
.tag-abschnitt-titel { font-weight: 700; margin-bottom: 6px; }
.tag-form { margin-top: 8px; }
.tag-form label { display: block; font-size: 12px; color: var(--mid-grey); margin-bottom: 4px; }
.tag-form-row { display: flex; gap: 8px; }
.tag-form input[type="text"], .tag-form textarea { padding: 6px 8px; border: 1px solid var(--rule); border-radius: 3px; width: 100%; }
.tag-form input[type="text"] { max-width: 180px; text-align: right; }

/* --- Kommentar-Indikator + Modal ---------------------------------- */
.badge-comment {
  border: 1px solid var(--khaki); background: #F0ECE0; color: #6E6444;
  border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: var(--font);
}
.badge-comment:hover { background: var(--khaki); color: var(--white); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(17,17,17,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--white); border-radius: 4px; width: 100%; max-width: 640px;
  max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 2px solid var(--khaki);
}
.modal-close { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--mid-grey); line-height: 1; }
.modal-close:hover { color: var(--black); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-body:empty::after { content: "Keine Notizen."; color: var(--grey); }
.modal-body .history-item { border-left: 3px solid var(--khaki); padding: 8px 14px; margin-bottom: 12px; background: var(--bg-off); }
.modal-body .history-item .meta { font-size: 12px; color: var(--mid-grey); margin-bottom: 4px; }
.modal-body .history-item pre { white-space: pre-wrap; font-family: var(--font); font-size: 13px; margin: 4px 0 0; }

/* Zurückgezogene Historieneinträge (Audit bleibt sichtbar). */
.history-item.is-withdrawn { opacity: 0.6; border-left-color: var(--mid-grey); }
.history-item.is-withdrawn strong,
.history-item.is-withdrawn pre { text-decoration: line-through; text-decoration-color: var(--mid-grey); }

/* Aktionshistorie als Akkordeon (native details/summary). */
details.history-item { padding: 0; }
details.history-item > summary {
  cursor: pointer; padding: 8px 14px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; list-style: none;
}
details.history-item > summary::-webkit-details-marker { display: none; }
details.history-item > summary::before { content: "\25B8"; color: var(--khaki); font-size: 12px; }
details.history-item[open] > summary::before { content: "\25BE"; }
details.history-item > summary:hover { background: rgba(0,0,0,0.03); }
details.history-item .hist-title { font-weight: 600; }
details.history-item .hist-meta { font-size: 12px; color: var(--mid-grey); }
details.history-item .history-body { padding: 0 14px 12px; }

/* --- Rückwirkende Korrekturen (Finanzübersicht) --------------------------- */
.korr-box > summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.korr-box > summary::-webkit-details-marker { color: var(--grey); }
.korr-box > summary .sub { font-size: 12px; color: var(--grey); }
.korr-hinweis { margin: 10px 0 12px; max-width: 78ch; }
/* Bewusst ohne Ampelfarben: Eine Korrektur ist weder gut noch schlecht, und der
   Warnton bleibt dem kritischen Verzug vorbehalten. Nur das Vorzeichen zaehlt. */
.korr-tabelle td.korr-plus,
.korr-tabelle td.korr-minus { font-weight: 600; }
.korr-tabelle td.korr-minus { color: var(--dark-grey); }
.korr-leer { margin: 0; padding: 12px 14px; background: var(--bg-light); border: 1px solid var(--rule);
             border-radius: 3px; color: var(--dark-grey); font-size: 13px; max-width: 78ch; }

/* --- Sperr-Overlay fuer laufende Aktionen --------------------------------- */
.busy-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(250, 250, 250, 0.86);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.busy-box {
  background: var(--white); border: 1px solid var(--rule); border-radius: 3px;
  padding: 26px 30px; max-width: 46ch; text-align: center;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.09);
}
.busy-spinner {
  width: 30px; height: 30px; margin: 0 auto 16px;
  border: 3px solid var(--rule); border-top-color: var(--khaki); border-radius: 50%;
  animation: busy-spin 0.85s linear infinite;
}
@keyframes busy-spin { to { transform: rotate(360deg); } }
.busy-text { margin: 0; font-size: 14px; color: var(--black); }
.busy-zeit { margin: 8px 0 0; font-size: 12px; color: var(--grey); font-variant-numeric: tabular-nums; }
.busy-hinweis { margin: 14px 0 12px; font-size: 12px; color: var(--dark-grey); text-align: left; }
body.busy-aktiv { overflow: hidden; cursor: progress; }

/* Ohne Animation: statt Drehung ein ruhiges Pulsieren, damit trotzdem
   erkennbar ist, dass etwas laeuft. */
@media (prefers-reduced-motion: reduce) {
  .busy-spinner { animation: busy-puls 1.6s ease-in-out infinite; border-top-color: var(--rule); background: var(--khaki); }
  @keyframes busy-puls { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
}

/* --- Laufender Hintergrund-Abgleich (Dashboard) --------------------------- */
.sync-lauf { margin-top: 6px; font-size: 12px; color: var(--dark-grey); display: flex;
             gap: 7px; align-items: center; justify-content: flex-end; }
.sync-lauf-punkt { width: 8px; height: 8px; border-radius: 50%; background: var(--khaki);
                   animation: sync-puls 1.3s ease-in-out infinite; flex: 0 0 auto; }
@keyframes sync-puls { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sync-lauf-punkt { animation: none; } }

/* --- GMI-Duplettenerkennung ---------------------------------------------- */
.tag-receipt, .tag-invoice { display: inline-block; padding: 1px 7px; border-radius: 2px;
                             font-size: 11px; border: 1px solid var(--rule); white-space: nowrap; }
.tag-receipt { background: var(--bg-light); color: var(--black); font-weight: 600; }
.tag-invoice { background: var(--white); color: var(--dark-grey); }
/* Trennlinie zwischen den Belegpaaren – macht zusammengehoerige Zeilen erkennbar. */
table.grid tr.gmi-gruppe-start td { border-top: 2px solid var(--rule); }

/* Stapelversand: Empfaengeradresse direkt in der Vorschau bearbeitbar.
   Fehlende Adressen fallen rot auf, damit sie nicht uebersehen werden. */
.stapel-empfaenger { width: 100%; min-width: 220px; font-size: 13px; padding: 4px 6px; }
.stapel-empfaenger.ist-leer { border-color: var(--danger); background: var(--danger-bg); }

/* Stapelversand: Beispiel-Anschreiben. Bewusst wie ein Brief abgesetzt, damit der
   Text gelesen und nicht ueberblaettert wird. */
.beispiel-brief { border: 1px solid var(--rule); border-left: 3px solid var(--accent, #8A7B4F);
    border-radius: 4px; padding: 12px 14px; background: var(--white, #fff); }
.beispiel-betreff { font-weight: 700; margin-bottom: 8px; }
.beispiel-brief pre { margin: 0 0 8px; white-space: pre-wrap; font-family: var(--font); font-size: 13px; }
