/* ===== MAHN — Mahnliste ===== */
.mahn-stichtag { display:flex; align-items:center; gap:8px; margin:0 0 16px; flex-wrap:wrap; }
.mahn-stichtag label { font-size:12.5px; color:var(--text-muted); font-weight:600; }
.mahn-stichtag input[type=date] { padding:6px 10px; border:1px solid var(--border); border-radius:8px; font-size:13px; }
.mahn-qbtn { padding:6px 12px; border:1px solid var(--border); background:var(--surface,#fff); border-radius:8px; font-size:12.5px; cursor:pointer; color:var(--text-muted); }
.mahn-qbtn:hover { border-color:var(--brand); }
.mahn-qbtn.active { background:var(--brand-soft); color:var(--brand-dark); border-color:var(--brand); font-weight:600; }

.mahn-hist { display:flex; align-items:center; gap:8px; background:#fef3c7; color:#92400e; padding:8px 12px; border-radius:8px; font-size:12.5px; margin-bottom:14px; }
.mahn-hist i { width:14px; height:14px; }

.mahn-cards { display:flex; gap:12px; flex-wrap:wrap; margin-bottom:18px; }
.mahn-card { background:var(--surface,#fff); border:1px solid var(--border); border-radius:10px; padding:12px 16px; min-width:150px; display:flex; flex-direction:column; gap:2px; }
.mahn-card-l { font-size:11.5px; color:var(--text-muted); text-transform:uppercase; letter-spacing:.3px; }
.mahn-card-v { font-size:19px; font-weight:700; color:var(--text); }
.mahn-card-sub { font-size:11px; color:var(--text-dim); }
.mahn-card.total { background:var(--brand-soft); border-color:var(--brand); }
.mahn-card.total .mahn-card-v { color:var(--brand-dark); }

.mahn-total-bar { display:flex; align-items:center; gap:14px; background:var(--brand-soft); border:1px solid var(--brand); border-radius:10px; padding:10px 16px; margin-bottom:16px; }
.mahn-total-l { font-size:11.5px; color:var(--brand-dark); text-transform:uppercase; letter-spacing:.3px; font-weight:600; }
.mahn-total-v { font-size:20px; font-weight:700; color:var(--brand-dark); }
.mahn-total-sub { font-size:12px; color:var(--text-muted); }
.mahn-total-cnt { margin-left:auto; font-size:12px; color:var(--text-muted); }

/* Baum */
.mahn-tree .mahn-grp { cursor:pointer; }
.mahn-tree .mahn-grp td { padding:8px 14px; }
.mahn-grp-s td { background:var(--bg-soft,#f2f4f7); font-weight:700; font-size:13px; color:var(--text); border-top:1px solid var(--border); }
.mahn-grp-v td { background:var(--surface,#fff); font-weight:600; font-size:12.5px; color:var(--text-muted); }
.mahn-grp:hover td { filter:brightness(.98); }
.mahn-caret { width:15px; height:15px; vertical-align:-3px; }
.mahn-caret.sm { width:13px; height:13px; }
.mahn-grp-sum { font-weight:700; color:var(--text); }
.mahn-grp-sum.sm { font-weight:600; color:var(--text-muted); }
.mahn-grp-cnt { display:inline-block; margin-left:6px; padding:0 7px; border-radius:20px; background:var(--border,#e5e7eb); color:var(--text-muted); font-size:11px; font-weight:600; }

.mahn-indent { display:inline-block; width:18px; }
.mahn-indent2 { display:inline-block; width:54px; }
.mahn-pen { width:14px; height:14px; color:var(--text-dim); }
.mahn-rowact { white-space:nowrap; }
.mahn-done { width:16px; height:16px; color:var(--text-dim); cursor:pointer; margin-right:10px; vertical-align:-3px; }
.mahn-done:hover { color:#16a34a; }
.mahn-make { width:16px; height:16px; color:var(--text-dim); cursor:pointer; margin-right:10px; vertical-align:-3px; }
.mahn-make:hover { color:var(--brand); }

/* ===== Dialog «Mahnung erstellen» ===== */
.mahn-dlg-ov { position:fixed; inset:0; background:rgba(15,23,42,.45); display:flex; align-items:center; justify-content:center; z-index:1200; padding:20px; }
.mahn-dlg { background:var(--surface,#fff); border:1px solid var(--border); border-radius:14px; box-shadow:0 20px 60px rgba(0,0,0,.28); width:560px; max-width:100%; max-height:calc(100vh - 40px); overflow:auto; }
.mahn-dlg-h { display:flex; align-items:center; gap:8px; padding:16px 20px; border-bottom:1px solid var(--border); font-size:15px; font-weight:700; color:var(--text); }
.mahn-dlg-h i { width:18px; height:18px; color:var(--brand); }
.mahn-dlg-x { margin-left:auto; border:none; background:transparent; cursor:pointer; color:var(--text-dim); padding:2px; border-radius:6px; }
.mahn-dlg-x:hover { background:var(--bg-soft,#f2f4f7); color:var(--text); }
.mahn-dlg-x i { width:18px; height:18px; }
.mahn-dlg-sub { padding:10px 20px 0; font-size:12.5px; color:var(--text-muted); }
.mahn-dlg-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px 16px; padding:14px 20px; }
.mahn-dlg-grid label { display:flex; flex-direction:column; gap:4px; font-size:12px; font-weight:600; color:var(--text-muted); }
.mahn-dlg-grid input, .mahn-dlg-grid select { padding:8px 10px; border:1px solid var(--border); border-radius:8px; font-size:13px; font-weight:400; color:var(--text); background:#fff; }
.mahn-dlg-hint { padding:0 20px 4px; font-size:11.5px; color:var(--text-dim); }
.mahn-dlg-btns { display:flex; justify-content:flex-end; gap:10px; padding:14px 20px; border-top:1px solid var(--border); flex-wrap:wrap; }
.mahn-dlg-adr { padding:12px 20px 4px; display:flex; flex-direction:column; gap:8px; }
.mahn-dlg-adr-h { font-size:12px; font-weight:600; color:var(--text-muted); display:flex; align-items:center; gap:8px; }
.mahn-adr-saved { font-weight:600; font-size:10.5px; background:#fef3c7; color:#92400e; padding:1px 7px; border-radius:20px; }
.mahn-dlg-adr input { padding:8px 10px; border:1px solid var(--border); border-radius:8px; font-size:13px; color:var(--text); background:#fff; }
.mahn-dlg-adr-row { display:flex; gap:10px; }
.mahn-dlg-adr-row input { flex:1; }
.mahn-dlg-chk { display:flex; align-items:center; gap:7px; font-size:11.5px; color:var(--text-muted); font-weight:500; cursor:pointer; }
.mahn-dlg-chk input { width:auto; }
.mahn-dlg-full { grid-column:1 / -1; }
.mahn-dlg-opt { font-weight:400; color:var(--text-dim); font-size:10.5px; }

/* Erledigt-Popup */
.mahn-pop { position:fixed; z-index:1100; background:#fff; border:1px solid var(--border); border-radius:10px; box-shadow:0 12px 40px rgba(0,0,0,.18); padding:12px; width:220px; }
.mahn-pop-t { font-size:12px; font-weight:600; color:var(--text-muted); margin-bottom:6px; }
.mahn-pop input[type=date] { width:100%; padding:7px 9px; border:1px solid var(--border); border-radius:8px; font-size:13px; }
.mahn-pop-btns { display:flex; justify-content:flex-end; gap:8px; margin-top:10px; }
.mahn-pop-btns .btn { padding:5px 12px; font-size:12.5px; }
.mahn-obj { max-width:420px; }

/* Inline-Editor */
.mahn-edit td { background:#f0f9ff; border-top:1px solid var(--brand); }
.mahn-edit-extra td { background:#f0f9ff; border-bottom:1px solid var(--brand); padding-top:0; }
.mahn-edit-extra label { font-size:11.5px; color:var(--text-muted); font-weight:600; margin-right:14px; display:inline-flex; align-items:center; gap:5px; }
.mahn-in { padding:5px 7px; border:1px solid var(--border); border-radius:6px; font-size:12.5px; }
.mahn-in.ktr { width:70px; }
.mahn-in.name { width:180px; }
.mahn-in.num { width:100px; text-align:right; }
.mahn-in.cur { width:64px; }
.mahn-in.wide { width:240px; }
.mahn-edit-obj { display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.mahn-edit-actions { white-space:nowrap; }
.mahn-icbtn { border:1px solid var(--border); background:#fff; border-radius:6px; padding:4px 7px; cursor:pointer; color:var(--text-muted); }
.mahn-icbtn.ok { border-color:var(--brand); color:var(--brand-dark); }
.mahn-icbtn i { width:14px; height:14px; vertical-align:-2px; }

.mahn-tablewrap { background:var(--surface,#fff); border:1px solid var(--border); border-radius:12px; overflow:auto; max-height:calc(100vh - 330px); }
.mahn-table { width:100%; border-collapse:collapse; font-size:13px; }
.mahn-table thead th { position:sticky; top:0; z-index:3; text-align:left; padding:10px 14px; background:var(--bg-soft,#f7f8fa); color:var(--text-muted); font-size:11.5px; text-transform:uppercase; letter-spacing:.3px; border-bottom:1px solid var(--border); box-shadow:0 1px 0 var(--border); }
.mahn-table th.num, .mahn-table td.num { text-align:right; white-space:nowrap; }
.mahn-table tbody td { padding:9px 14px; border-bottom:1px solid var(--border-soft,#eef0f3); }
.mahn-table tbody tr:last-child td { border-bottom:none; }
.mahn-row td { color:var(--text); }
.mahn-row td.mahn-tage { color:var(--text-muted); }
.mahn-row td.mahn-tage.over { color:#b91c1c; }
.mahn-note-cell { white-space:nowrap; }
.mahn-note-cell .mahn-notebtn { margin-left:0; }
.mahn-th-note { text-align:left; }
/* Positionszeile ohne Unterrand, wenn Notiz-Unterzeile/Panel folgt */
.mahn-row-nb td { border-bottom:none !important; }
.mahn-clk { cursor:pointer; }
.mahn-clk:hover { background:var(--brand-soft); }
.mahn-ktr { font-variant-numeric:tabular-nums; font-weight:600; color:var(--brand-dark); }
.mahn-bem { margin-left:6px; color:var(--text-dim); }
.mahn-bem i { width:13px; height:13px; vertical-align:-2px; }
.mahn-table td.empty { text-align:center; color:var(--text-dim); padding:20px; }
.mahn-foot { font-size:12px; color:var(--text-dim); margin-top:10px; }

.mahn-kat { display:inline-block; padding:2px 8px; border-radius:20px; font-size:11px; font-weight:600; background:#eef0f3; color:#475569; }
.mahn-kat.k-garantierueckbehalt { background:#fef3c7; color:#92400e; }
.mahn-kat.k-nachtrag { background:#dbeafe; color:#1d4ed8; }
.mahn-kat.k-ertragsabgrenzung { background:#e0e7ff; color:#4338ca; }
.mahn-kat.k-kreditor { background:#fce7f3; color:#9d174d; }

/* Modal */
.mahn-modal-bg { position:fixed; inset:0; background:rgba(15,23,42,.45); display:flex; align-items:center; justify-content:center; z-index:1000; padding:20px; }
.mahn-modal { background:#fff; border-radius:14px; width:min(560px,100%); max-height:90vh; overflow:auto; box-shadow:0 20px 60px rgba(0,0,0,.25); }
.mahn-modal-head { display:flex; align-items:center; padding:16px 20px; border-bottom:1px solid var(--border); }
.mahn-modal-head h3 { margin:0; font-size:16px; }
.mahn-x { margin-left:auto; background:none; border:none; cursor:pointer; color:var(--text-muted); }
.mahn-x i { width:18px; height:18px; }
.mahn-form { padding:16px 20px; display:flex; flex-direction:column; gap:12px; }
.mahn-form label { display:flex; flex-direction:column; gap:4px; font-size:12.5px; font-weight:600; color:var(--text-muted); }
.mahn-form input, .mahn-form select, .mahn-form textarea { padding:8px 10px; border:1px solid var(--border); border-radius:8px; font-size:13px; font-weight:400; color:var(--text); }
.mahn-form-row { display:flex; gap:12px; }
.mahn-form-row label { flex:1; }
.mahn-form hr { border:none; border-top:1px solid var(--border); margin:2px 0; }
.mahn-hint { font-size:11.5px; color:var(--text-dim); margin:0; }
.mahn-modal-foot { display:flex; justify-content:flex-end; gap:10px; padding:14px 20px; border-top:1px solid var(--border); }

/* ===== Mahnliste-spezifisch ===== */
/* Tage überfällig */
.mahn-tage { font-variant-numeric:tabular-nums; color:var(--text-muted); white-space:nowrap; }
.mahn-tage.over { color:#b91c1c; font-weight:600; }

/* Rechnungsnummer + Sachbearbeiter-Chip in der Zeile */
.mahn-rgnr { display:inline-block; margin-left:8px; font-size:11px; color:var(--text-dim); font-variant-numeric:tabular-nums; }
.mahn-sb { display:inline-block; margin-left:8px; padding:1px 7px; border-radius:20px; background:#eef0f3; color:#475569; font-size:10.5px; font-weight:600; }

/* Mahnstufen-Badge */
.mahn-stufe { display:inline-block; padding:2px 8px; border-radius:20px; font-size:11px; font-weight:600; background:#eef0f3; color:#475569; }
.mahn-stufe.st-0 { background:#e5e7eb; color:#4b5563; }
.mahn-stufe.st-1 { background:#fef9c3; color:#854d0e; }
.mahn-stufe.st-2 { background:#fed7aa; color:#9a3412; }
.mahn-stufe.st-3 { background:#fecaca; color:#991b1b; }

/* Gruppenkopf-Badge etwas kompakter im Baum */
.mahn-grp-s .mahn-stufe { font-size:12px; }

/* ===== Notiz-History (pro Rechnungsnummer) ===== */
.mahn-notebtn { display:inline-flex; align-items:center; gap:3px; margin-left:8px; padding:1px 7px; border-radius:20px; background:#eef0f3; color:var(--text-muted); cursor:pointer; font-size:11px; vertical-align:1px; }
.mahn-notebtn i { width:13px; height:13px; }
.mahn-notebtn:hover { background:var(--brand-soft); color:var(--brand-dark); }
.mahn-notebtn.has { background:#fef3c7; color:#92400e; }
.mahn-notebtn.on { background:var(--brand); color:#fff; }
.mahn-notebtn b { font-weight:700; }

.mahn-note-row > td { background:#f7fbfd !important; border-bottom:1px solid var(--brand) !important; padding:0 !important; }
.mahn-notes { padding:12px 18px 12px 68px; }

/* Letzte Notiz als Unterzeile (Vorschau, klickbar → voller Verlauf) */
.mahn-noteprev-row > td { padding:0 !important; background:transparent; }
.mahn-noteprev { display:flex; align-items:baseline; gap:6px; padding:2px 14px 8px 68px; cursor:pointer; }
.mahn-noteprev i { width:12px; height:12px; color:var(--brand); flex:none; align-self:center; }
.mahn-noteprev-txt { font-size:12px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:52ch; }
.mahn-noteprev-meta { font-size:10.5px; color:var(--text-dim); white-space:nowrap; }
.mahn-noteprev:hover .mahn-noteprev-txt { color:var(--brand-dark); }
.mahn-notes-h { display:flex; align-items:center; gap:6px; font-size:12px; font-weight:700; color:var(--brand-dark); margin-bottom:8px; }
.mahn-notes-h i { width:14px; height:14px; }
.mahn-note-list { display:flex; flex-direction:column; gap:8px; max-height:none; }
.mahn-note { border-left:3px solid var(--brand); background:#fff; border:1px solid var(--border); border-left:3px solid var(--brand); border-radius:8px; padding:7px 11px; }
.mahn-note-meta { font-size:11px; color:var(--text-dim); margin-bottom:3px; }
.mahn-note-txt { font-size:13px; color:var(--text); white-space:pre-wrap; word-break:break-word; }
.mahn-note-empty { font-size:12.5px; color:var(--text-dim); font-style:italic; padding:2px 0; }
.mahn-note-add { display:flex; gap:8px; margin-top:10px; }
.mahn-note-add input { flex:1; padding:7px 10px; border:1px solid var(--border); border-radius:8px; font-size:13px; }
.mahn-note-add .btn { white-space:nowrap; }

/* Dokumente aus der Ablage im Verlauf */
.mahn-doc { display:flex; align-items:center; gap:8px; background:#fff; border:1px solid var(--border); border-left:3px solid #64748b; border-radius:8px; padding:6px 11px; }
.mahn-doc-ico { width:15px; height:15px; flex:0 0 auto; }
.mahn-doc-ico.out { color:var(--brand-dark); } .mahn-doc-ico.in { color:#15803d; }
.mahn-doc-name { font-size:13px; color:var(--text); text-decoration:none; word-break:break-word; }
a.mahn-doc-name:hover { text-decoration:underline; color:var(--brand-dark); }
.mahn-doc-tag { font-size:10px; font-weight:600; padding:1px 7px; border-radius:20px; }
.mahn-doc-tag.out { background:var(--brand-soft); color:var(--brand-dark); }
.mahn-doc-tag.in { background:#dcfce7; color:#15803d; }
.mahn-doc-date { margin-left:auto; font-size:11px; color:var(--text-dim); white-space:nowrap; }

/* ===== Gelb-Markierung: Änderungen seit letztem Mittwoch ===== */
.mahn-row.mahn-chg > td { background:#fffbe6; }
.mahn-row.mahn-chg.mahn-clk:hover > td { background:#fdf4c8; }
.mahn-chg-legend { display:inline-block; background:#fffbe6; border:1px solid #f2e6a8; padding:0 6px; border-radius:4px; }
