/* Klickhelfer Rechnungstool - NUR die eigenen Bausteine.
 *
 * Die gemeinsame Oberflaeche (Farbpalette, App-Huelle, Kopfleiste, Karten,
 * Schaltflaechen, Formulare, Dialoge ...) kommt 1:1 aus dem CRM: index.html
 * laedt zuerst base.css - eine WORTGLEICHE Kopie von
 * Klickforce/app/static/styles.css - und erst danach diese Datei.
 *
 * Regel: Was das CRM schon definiert, steht hier NICHT mehr. Ausnahmen sind
 * die wenigen Selektoren, die im Rechnungstool etwas anderes bedeuten; sie
 * sind unten einzeln begruendet. Alles rund um die Rechnungserstellung
 * (Positionszeilen, Summenleiste, Belegmasken ...) ist unveraendert geblieben.
 *
 * base.css NIE hier von Hand aendern - Aenderungen gehoeren ins CRM und
 * werden mit "oberflaeche-vergleichen.py" geprueft.
 *
 * Bewusst behaltene Doppelungen:
 *   .col      Wie .row - Spalte MIT Abstand; die CRM-Fassung haette gap 0.
 *   .field    Formularfeld der Rechnungserstellung: Flex-Spalte, position:relative fuer die Kunden-Vorschlagsliste. Im CRM nur ein Aussenabstand.
 *   .modal    PDF-/E-Mail-Vorschau: Flex-Spalte mit Kopf, Rahmen und Fuss. Das CRM meint damit einen kleinen mittigen Dialog.
 *   .row      Layout-Helfer in der Rechnungsmaske. Im CRM eine anklickbare Listenzeile mit Trennlinie und Zeigefinger.
 */


@media (prefers-reduced-motion: reduce){
}
@media (display-mode: standalone){
}
/* Alle injizierten SVGs einheitlich stylen – egal ob in .ic, .iconbtn, Toggle usw.
   (sonst rendern sie in Standardgröße/gefüllt und sprengen z. B. die Aktions-Buttons). */
.ic svg,.iconbtn svg,.theme-toggle svg,.confirm-ico svg,.tl-del svg,.search-clear svg,.btn svg{
  stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;display:block;
}
.iconbtn svg,.tl-del svg{width:17px;height:17px}
.search-clear svg{width:15px;height:15px}
@keyframes growline{}
.tab-badge{display:inline-flex;min-width:18px;height:18px;padding:0 5px;border-radius:10px;background:var(--red);color:#fff;font-size:11px;font-weight:800;align-items:center;justify-content:center;margin-left:2px;vertical-align:middle}
/* ---- Schmale Fenster: die Leiste braucht sonst 913 px bei 375 px Platz ----
   Die sechs Reiter passen nicht nebeneinander. Statt sie zu quetschen oder
   Beschriftungen abzuschneiden, wird die Reiter-Zeile seitlich wischbar; Logo
   und die Knoepfe rechts bleiben fest stehen. Die Rollbalken-Leiste wird
   ausgeblendet, damit es wie ein natives Wisch-Menue wirkt. */
@media(max-width:860px){
  .tabs::-webkit-scrollbar{display:none}
}
.statuschip{font-size:12px;color:var(--muted);transition:opacity .3s}
.wrap.wide{max-width:1240px}
/* Seitenueberschrift, die FREI im .wrap steht (ohne .page-head drumherum).
   Das CRM setzt .page-title{margin:0}, weil dort immer .page-head die Abstaende
   macht - im Rechnungstool stehen mehrere Ueberschriften frei (Kunden,
   Mahnungen, Nachricht, Einstellungen). Ohne diese Regel klebt der
   Beschreibungstext direkt an der Ueberschrift. Ueberschriften INNERHALB von
   .page-head sind nicht betroffen: sie sind keine direkten Kinder von .wrap. */
.wrap>.page-title{margin:4px 0 20px}
/* Beschreibungszeile direkt darunter rueckt bewusst naeher heran
   (20 px minus 12 px = 8 px Abstand, wie vor der Umstellung). */
.wrap>.page-title+.page-lead{margin:-12px 0 18px}
@keyframes pagein{}
.page-head-l{display:flex;align-items:center;gap:12px}
.lock-banner{display:flex;align-items:center;gap:10px;background:#fff6ec;border:1px solid #f6d9b8;color:#8a5a1c;border-radius:12px;padding:12px 16px;font-size:13.5px;margin-bottom:16px}
/* display:flex würde sonst das hidden-Attribut überschreiben -> Balken bliebe leer sichtbar */
.lock-banner[hidden]{display:none}
.lock-banner b{color:#7a4d13}
.lock-banner .grow{flex:1}
body.dark .lock-banner{background:#2a2113;border-color:#4a3a1c;color:#e6b566}
body.dark .lock-banner b{color:#f0c987}
.form-locked input,.form-locked select,.form-locked textarea{pointer-events:none;opacity:.7}
.form-locked .switch,.form-locked .del,.form-locked .btn-line,.form-locked .line-actions,.form-locked .drag-handle,.form-locked .tpl-save{pointer-events:none;opacity:.55}
@media(max-width:780px){.grid2{grid-template-columns:1fr;gap:16px}}
.col{display:flex;flex-direction:column;gap:12px}

/* ---------------- Felder ---------------- */
.field{position:relative;display:flex;flex-direction:column}
.field label{font-size:11px;color:var(--muted);font-weight:600;margin:0 0 4px 2px}
.field input,.field select,.field textarea{
  border:1px solid var(--line);border-radius:10px;padding:11px 12px;font-size:14px;
  font-family:inherit;color:var(--ink);background:#fff;width:100%;outline:none;
  transition:border-color .12s, box-shadow .12s;
}
.field textarea{resize:vertical;min-height:44px;line-height:1.4}
.field input:focus,.field select:focus,.field textarea:focus{
  border-color:var(--orange);box-shadow:0 0 0 3px rgba(240,131,48,.14);
}
.field input::placeholder,.field textarea::placeholder{color:#b3b3bd}
.field.readonly input{background:#f7f7f9;color:var(--muted)}
.row{display:flex;gap:10px}
.row>*{flex:1}
code{background:var(--bg);border:1px solid var(--line);border-radius:6px;padding:1px 6px;font-size:12px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--orange-dark)}

/* ---------------- Searchable Combo (Kunde) ---------------- */
.combo{position:relative}
.combo-list{
  position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:30;max-height:260px;overflow:auto;
  background:var(--card);border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow-lg);
  padding:5px;animation:pop .14s var(--ease);
}
@keyframes pop{}
.combo-item{padding:9px 11px;border-radius:8px;cursor:pointer;display:flex;flex-direction:column;gap:1px}
.combo-item small{color:var(--muted);font-size:12px}
.combo-item:hover,.combo-item.active{background:var(--bg)}
.combo-item.active{outline:1px solid rgba(240,131,48,.4)}
.combo-empty{padding:12px 11px;color:var(--muted);font-size:13px}

/* ---------------- Positionen ---------------- */
.lines{display:flex;flex-direction:column;gap:14px}
.line{border:1px solid var(--line);border-radius:12px;padding:14px;background:var(--card2);position:relative;animation:pagein .2s var(--ease)}
.line .lhead{display:grid;grid-template-columns:20px 26px 1fr 78px 106px 92px 66px 92px 30px 30px;gap:8px;align-items:start}
.einheit-field select{padding-left:10px;padding-right:6px}
/* display:flex würde das hidden-Attribut sonst überschreiben (Basis-Feld ausblenden) */
.field[hidden]{display:none}
.item-row2{display:flex;gap:14px;align-items:flex-start;margin-top:10px}
.item-row2 .desc{flex:1;margin-top:0}
.ak-toggle{display:flex;align-items:center;gap:7px;font-size:13px;color:var(--muted);white-space:nowrap;cursor:pointer;user-select:none;padding-top:7px}
.ak-toggle input{width:16px;height:16px;accent-color:var(--orange);cursor:pointer;margin:0;flex:none}
.disc-row2{display:flex;gap:12px;align-items:flex-end;flex-wrap:wrap;margin-top:10px}
.line .badge{width:24px;height:24px;border-radius:50%;background:#fff;border:1px solid var(--line);display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--muted);font-weight:700;margin-top:20px;position:relative}
.line .badge::after{content:"";position:absolute;right:-2px;top:-2px;width:7px;height:7px;border-radius:50%;background:var(--green)}
.line.text .badge::after,.line.discount .badge::after{display:none}
.line .amount{font-weight:800;text-align:right;margin-top:20px;white-space:nowrap}
.line .del{border:none;background:none;cursor:pointer;color:#b0b0ba;margin-top:18px;width:28px;height:28px;border-radius:8px;display:flex;align-items:center;justify-content:center;transition:background .15s,color .15s}
.line .del:hover{background:#fde8e8;color:var(--red)}
.line .tpl-save{border:none;background:none;cursor:pointer;color:#b0b0ba;margin-top:18px;width:28px;height:28px;border-radius:8px;display:flex;align-items:center;justify-content:center;transition:background .15s,color .15s}
.line .tpl-save:hover{background:#fdf3e4;color:var(--orange-dark,#c06a17)}
.tpl-save svg{width:16px;height:16px}
.line .desc{margin-top:10px}
.line.text .lhead,.line.discount .lhead{grid-template-columns:20px 26px 1fr 120px 30px}
.drag-handle{display:flex;align-items:center;justify-content:center;width:20px;height:24px;margin-top:20px;border-radius:6px;color:#c3c3cc;cursor:grab;transition:color .15s,background .15s}
.drag-handle:hover{color:var(--muted);background:rgba(0,0,0,.05)}
.drag-handle:active{cursor:grabbing}
.drag-handle .ic svg{fill:currentColor;stroke:none;width:15px;height:15px}
/* animation:none ist wichtig: beim Ziehen wird das Element per insertBefore neu
   eingehängt, was die pagein-Animation sonst bei jedem dragover neu abspielt -> Flackern. */
.line.dragging{opacity:.5;border-color:var(--orange);box-shadow:0 10px 26px rgba(0,0,0,.14);animation:none}
.einheit-custom{margin-top:6px}
body.dark .drag-handle{color:#55555f}
body.dark .drag-handle:hover{color:#9a9aa6;background:rgba(255,255,255,.06)}
.line-actions{display:flex;gap:8px;justify-content:center;margin-top:6px;flex-wrap:wrap}
/* Vorlagen-Menü (wiederkehrende Posten) */
.tpl-wrap{position:relative}
.tpl-menu{position:absolute;top:calc(100% + 8px);left:50%;transform:translateX(-50%);min-width:300px;max-width:380px;
  background:#fff;border:1px solid var(--line);border-radius:12px;box-shadow:0 10px 30px rgba(40,28,16,.14);
  padding:6px;z-index:60}
.tpl-menu[hidden]{display:none}
.tpl-empty{padding:12px 14px;font-size:13px;color:var(--muted);line-height:1.5}
.tpl-row{display:flex;align-items:center;gap:4px}
.tpl-pick{flex:1;display:flex;flex-direction:column;align-items:flex-start;gap:2px;border:none;background:none;
  cursor:pointer;text-align:left;padding:9px 10px;border-radius:9px;font-family:inherit;color:var(--ink)}
.tpl-pick b{font-size:13.5px}
.tpl-pick span{font-size:12px;color:var(--muted)}
.tpl-pick:hover{background:#fbeee1}
.tpl-del{border:none;background:none;cursor:pointer;color:#b0b0ba;width:28px;height:28px;border-radius:8px;
  display:flex;align-items:center;justify-content:center;flex:none}
.tpl-del:hover{background:#fde8e8;color:var(--red)}
.tpl-del svg{width:15px;height:15px}
/* Vorlagen-Editor (Einstellungen → Vorlagen) */
.tpl-edit{border:1px solid var(--line);border-radius:12px;padding:14px 16px;margin-bottom:12px;background:var(--card2)}
.tpl-edit-head{display:grid;grid-template-columns:1fr 110px 100px 90px auto 34px;gap:10px;align-items:end;margin-bottom:10px}
.tpl-edit-head .tpl-ak{white-space:nowrap;padding-bottom:10px}
.tpl-edit-head .iconbtn{margin-bottom:5px}
@media(max-width:820px){.tpl-edit-head{grid-template-columns:1fr 1fr;align-items:center}}
body.dark .tpl-edit{background:#2a2a2f;border-color:#3a3a41}
body.dark .tpl-menu{background:#242428;border-color:#3a3a41;box-shadow:0 10px 30px rgba(0,0,0,.5)}
body.dark .tpl-pick:hover{background:#313138}
body.dark .tpl-del:hover{background:#3a2020;color:#ff8a80}
body.dark .line .tpl-save:hover{background:#3a2c15;color:#f0b35e}
.btn-line{display:inline-flex;align-items:center;gap:7px;border:1px solid var(--line);background:#fff;border-radius:10px;padding:9px 14px;font-weight:600;font-size:13px;cursor:pointer;color:var(--ink);transition:border-color .15s,color .15s,transform .1s}
.btn-line:hover{border-color:var(--orange);color:var(--orange-dark)}
.btn-line:active{transform:scale(.97)}
.btn-line .ic{color:var(--green)}

/* ---------------- Total-Bar ---------------- */
.totalbar{position:sticky;bottom:0;z-index:40;background:var(--dark);color:#fff;border-radius:14px;margin-top:18px;padding:18px 26px;display:flex;align-items:center;justify-content:flex-end;gap:24px;box-shadow:var(--shadow-lg)}
.totalbar .lbl{color:#c9c9cf;font-size:13px;text-align:right}
.totalbar .val{font-size:26px;font-weight:800;font-variant-numeric:tabular-nums}
.totalbar .mini{font-size:12px;color:#b9b9c0;text-align:right;line-height:1.4}

/* ---------------- Buttons ---------------- */
.actions{display:flex;gap:10px;justify-content:flex-end;flex-wrap:wrap;margin-top:18px}
.btn.dark{background:var(--ink);color:#fff}
.btn.dark:hover{background:#000}
.btn.ghost{background:#fff;border:1px solid var(--line);color:var(--ink)}
.btn.ghost:hover{border-color:#c9c9d2}
.btn.full{width:100%;justify-content:center}
.btn.sm{padding:7px 12px;font-size:12.5px;border-radius:9px}

/* ---------------- Toggles (Zahlarten) ---------------- */
.pays{display:grid;grid-template-columns:1fr 1fr;gap:12px}
@media(max-width:600px){.pays{grid-template-columns:1fr}}
.pay{border:1px solid var(--line);border-radius:12px;padding:14px 16px;display:flex;align-items:center;gap:12px;background:var(--card2)}
.pay .ico{width:38px;height:38px;border-radius:50%;background:var(--ink);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700}
.pay .meta{flex:1}
.pay .meta b{display:block}
.pay .meta span{font-size:12px;color:var(--muted)}
/* "Bereits bezahlt": Kachel über die volle Breite, grüner Haken, Auswahl bar/Karte */
.pay.paid-row{grid-column:1/-1}
.pay .ico.ok{background:var(--green)}
.pay-select{border:1px solid var(--line);border-radius:10px;padding:9px 10px;font-size:14px;font-family:inherit;background:#fff;color:var(--ink);outline:none;cursor:pointer}
.pay-select:focus{border-color:var(--orange)}
body.dark .pay-select{background:#2a2a2f;border-color:#3a3a41;color:var(--ink)}
/* Ist "Bereits bezahlt" aktiv, sind PayPal/Überweisung ohne Wirkung -> ausgrauen */
.pays.already-paid .pay:not(.paid-row){opacity:.45;pointer-events:none}
.switch{position:relative;width:42px;height:24px;flex:none}
.switch input{display:none}
.switch span{position:absolute;inset:0;background:#cfcfd6;border-radius:20px;transition:.15s;cursor:pointer}
.switch span::after{content:"";position:absolute;left:3px;top:3px;width:18px;height:18px;background:#fff;border-radius:50%;transition:.15s}
.switch input:checked + span{background:var(--green)}
.switch input:checked + span::after{transform:translateX(18px)}
.search{position:relative;flex:1;min-width:200px;display:flex;align-items:center}
.search .ic{position:absolute;left:11px;color:var(--muted);pointer-events:none}
.search input{width:100%;border:1px solid var(--line);border-radius:10px;padding:10px 34px 10px 34px;font-size:14px;font-family:inherit;color:var(--ink);background:#fff;outline:none;transition:border-color .12s,box-shadow .12s}
.search input:focus{border-color:var(--orange);box-shadow:0 0 0 3px rgba(240,131,48,.14)}
.search-clear{position:absolute;right:6px;top:50%;transform:translateY(-50%);border:none;background:none;cursor:pointer;color:var(--muted);width:26px;height:26px;padding:0;border-radius:7px;display:flex;align-items:center;justify-content:center}
.search-clear[hidden]{display:none}
.search-clear:hover{background:var(--bg);color:var(--ink)}
body.dark .search-clear:hover{background:#2e2e34}
.toolbar select{border:1px solid var(--line);border-radius:10px;padding:10px 12px;font-size:14px;font-family:inherit;background:#fff;color:var(--ink);outline:none;cursor:pointer}
.toolbar select:focus{border-color:var(--orange)}

/* ---------------- Tabellen (Liste) ---------------- */
table.list{width:100%;border-collapse:collapse}
table.list th{text-align:left;font-size:12px;color:var(--muted);font-weight:600;padding:8px 10px;border-bottom:1px solid var(--line)}
table.list td{padding:11px 10px;border-bottom:1px solid var(--line);font-size:14px;vertical-align:middle}
table.list tr{transition:background .12s}
table.list tr:hover td{background:var(--card2)}
table.list td.num{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
.status{font-size:11px;font-weight:700;padding:3px 9px;border-radius:20px;white-space:nowrap}
.status.entwurf{background:#eee;color:#777}
.status.festgeschrieben{background:#e7efff;color:#3b6fd1}
/* Versendet = unterwegs, noch nicht bezahlt -> orange. Gruen ist NUR bezahlt. */
.status.versendet{background:#fdf3e4;color:#c07a1d}
.status.bezahlt{background:#e4f7ee;color:#159a5b}
.status.overdue{background:#fdeceb;color:var(--red)}
.status.storno{background:#e7efff;color:#3b6fd1}
body.dark .status.storno{background:#22304a;color:#8db4ff}
/* Kostenvoranschläge */
.status.angenommen{background:#e4f7ee;color:#159a5b}
.status.abgelehnt{background:#fdeceb;color:var(--red)}
.status.abgelaufen{background:#fdf3e4;color:#c07a1d}
.status.abgerechnet{background:#e7efff;color:#3b6fd1}
body.dark .status.angenommen{background:#173a29;color:#6fe0a2}
body.dark .status.abgelehnt{background:#3d1f1d;color:#ff9d94}
body.dark .status.abgelaufen{background:#3a2c15;color:#f0b35e}
body.dark .status.abgerechnet{background:#22304a;color:#8db4ff}
.iconbtn{border:none;background:none;cursor:pointer;color:var(--muted);padding:6px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;transition:background .12s,color .12s}
.iconbtn:hover{background:var(--bg);color:var(--ink)}
.iconbtn.ok:hover{background:#e6f6ec;color:var(--green)}
body.dark .iconbtn.ok:hover{background:#193a2a;color:#6fe0a2}
.rowacts{display:flex;gap:2px;justify-content:flex-end}

/* ---------------- Kunden-Seite ---------------- */
.cust-layout{display:grid;grid-template-columns:320px 1fr;gap:18px;align-items:start}
@media(max-width:820px){.cust-layout{grid-template-columns:1fr}}
.cust-list-card{position:sticky;top:80px}
.cust-list{margin-top:12px;max-height:60vh;overflow:auto;display:flex;flex-direction:column;gap:3px}
.cust-row{padding:10px 12px;border-radius:10px;cursor:pointer;display:flex;flex-direction:column;gap:1px;transition:background .12s}
.cust-row small{color:var(--muted);font-size:12px}
.cust-row:hover{background:var(--bg)}
.cust-row.active{background:rgba(240,131,48,.12);box-shadow:inset 3px 0 0 var(--orange)}
.cust-head{display:flex;align-items:flex-start;gap:12px;margin-bottom:6px}
.cust-avatar{width:52px;height:52px;border-radius:15px;background:linear-gradient(135deg,var(--orange),#f5a95f);color:#fff;display:flex;align-items:center;justify-content:center;font-size:22px;font-weight:800;flex:none;box-shadow:0 4px 14px rgba(240,131,48,.3)}
.cust-head h2{margin:0;font-size:22px;letter-spacing:-.3px}
.cust-head .sub{color:var(--muted);font-size:13px;margin-top:2px}
.cust-head .grow{flex:1}
.datagrid{display:grid;grid-template-columns:1fr 1fr;gap:14px 22px;margin:6px 0 6px}
@media(max-width:560px){.datagrid{grid-template-columns:1fr}}
.datagrid .dl{font-size:11px;color:var(--muted);font-weight:600;margin-bottom:2px}
.datagrid .dv{font-size:15px;word-break:break-word}
.stat-cards{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:6px 0 4px}
@media(max-width:560px){.stat-cards{grid-template-columns:1fr}}
.stat{border:1px solid var(--line);border-radius:12px;padding:14px 16px;background:var(--card2)}
.stat .k{font-size:12px;color:var(--muted)}
.stat .v{font-size:20px;font-weight:800;margin-top:3px;font-variant-numeric:tabular-nums}
.stat.accent{background:linear-gradient(135deg,rgba(240,131,48,.1),rgba(240,131,48,.03));border-color:rgba(240,131,48,.3)}
.stat.accent .v{color:var(--orange-dark)}

/* Notiz-Timeline */
.timeline{margin-top:6px;position:relative;padding-left:22px}
.timeline::before{content:"";position:absolute;left:6px;top:4px;bottom:4px;width:2px;background:var(--line);border-radius:2px}
.tl-item::before{content:"";position:absolute;left:-19px;top:4px;width:11px;height:11px;border-radius:50%;background:var(--card);border:2px solid var(--orange)}
.tl-item.event::before{border-color:var(--green)}
.note-input{display:flex;gap:8px;margin:4px 0 14px}
.note-input textarea{flex:1;border:1px solid var(--line);border-radius:10px;padding:10px 12px;font-family:inherit;font-size:14px;color:var(--ink);background:#fff;outline:none;resize:vertical;min-height:42px}
.note-input textarea:focus{border-color:var(--orange);box-shadow:0 0 0 3px rgba(240,131,48,.14)}

/* ---------------- Mahnungen ---------------- */
.mahn-item{display:flex;align-items:center;gap:16px;padding:16px 4px;border-bottom:1px solid var(--line);flex-wrap:wrap}
.mahn-item:last-child{border-bottom:none}
.mahn-main{flex:1;min-width:200px}
.mahn-main b{font-size:15px}
.mahn-main .sub{color:var(--muted);font-size:13px;margin-top:2px}
.mahn-days{font-weight:800;color:var(--red);white-space:nowrap}
.mahn-amount{font-weight:800;font-variant-numeric:tabular-nums;white-space:nowrap}
.mahn-tpl{border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:14px;background:var(--card2)}
.mahn-tpl .thead{display:flex;align-items:center;gap:10px;margin-bottom:10px}
.mahn-tpl .lvlname{font-weight:700;font-size:15px}
.send-grid{display:grid;grid-template-columns:1fr 1fr 150px;gap:12px;align-items:end}
@media(max-width:720px){.send-grid{grid-template-columns:1fr}}
body.dark .mahn-tpl{background:#2a2a2f;border-color:#3a3a41}
.lvl-pill{font-size:11px;font-weight:700;padding:3px 9px;border-radius:20px;background:#fdeceb;color:var(--red);white-space:nowrap}
.lvl-pill.l0{background:#eef0f3;color:var(--muted)}
.lvl-pill.l1{background:#fff3e2;color:#b5731a}
.lvl-pill.l2{background:#fde7e2;color:#c4562b}
.lvl-pill.l3{background:#fbe0e0;color:#c0392b}

/* ---------------- Subnav (Einstellungen) ---------------- */
.subnav{display:flex;gap:4px;flex-wrap:wrap;margin:-6px 0 20px;padding:5px;background:var(--card);border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow);position:sticky;top:76px;z-index:30}
.subtab{border:none;background:none;padding:9px 15px;border-radius:10px;font-weight:600;font-size:13.5px;color:var(--muted);cursor:pointer;transition:background .15s,color .15s}
.subtab:hover{background:var(--bg);color:var(--ink)}
.subtab.active{background:var(--ink);color:#fff}
.set-sec{animation:pagein .28s var(--ease)}

/* Design live preview */
/* Beide Spalten gleich hoch (stretch): die Vorschau-Spalte wird so hoch wie die
   Steuer-Spalte, die Vorschau füllt den Platz ÜBER dem Speichern-Button aus ->
   der Button endet bündig mit dem „Logo-Größe & Seitenränder"-Kästchen. */
.design-layout{display:grid;grid-template-columns:1fr 520px;gap:18px;align-items:stretch}
@media(max-width:1050px){.design-layout{grid-template-columns:1fr}}
.design-controls{display:flex;flex-direction:column}
/* letztes Steuer-Kästchen ohne unteren Abstand -> Spaltenhöhe endet genau an
   der Kasten-Unterkante, damit der Speichern-Button rechts bündig abschließt */
.design-controls>.card:last-child{margin-bottom:0}
.design-preview-col{display:flex;flex-direction:column;min-width:0}
.design-preview-card{padding:16px;flex:1;display:flex;flex-direction:column;min-height:0;margin-bottom:0}
.dpv-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}
.live-toggle{font-size:12px}
.dpv-frame{position:relative;flex:1;min-height:420px;border-radius:10px;overflow:hidden;border:1px solid var(--line);background:#e9e9ee}
/* iframe absolut füllen -> zuverlässig, unabhängig von der Prozenthöhen-Auflösung */
.dpv-frame iframe{position:absolute;inset:0;width:100%;height:100%;border:none;display:block;background:#fff}
.dpv-spin{position:absolute;top:10px;right:10px}
.spinner{width:18px;height:18px;border:2.5px solid rgba(240,131,48,.3);border-top-color:var(--orange);border-radius:50%;display:inline-block;animation:spin .7s linear infinite}
@keyframes spin{}

/* ---------------- Modal ---------------- */
.modal-back{position:fixed;inset:0;background:rgba(20,16,40,.5);display:none;z-index:100;align-items:center;justify-content:center;padding:24px;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px)}
.modal-back.open{display:flex;animation:fadein .18s var(--ease)}
@keyframes fadein{}
.modal{background:#fff;border-radius:16px;width:min(900px,96vw);max-height:92vh;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 20px 60px rgba(0,0,0,.3);animation:modalin .22s var(--ease)}
@keyframes modalin{}
.modal header{display:flex;align-items:center;gap:12px;padding:14px 18px;border-bottom:1px solid var(--line)}
.modal header b{flex:1}
.modal .body{flex:1;overflow:auto;background:#f0f0f3}
.modal iframe{width:100%;height:78vh;border:none;display:block;background:#fff}
/* Ersatz fuer den eingebetteten Rahmen, wenn der Browser PDFs nicht darin
   anzeigt (Safari) - besser ein klarer Hinweis als ein leeres Fenster. */
.modal-hint{height:78vh;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;text-align:center;padding:30px;color:var(--muted);font-size:14px}
.modal-hint b{color:var(--ink);font-size:15.5px}
.modal .foot{padding:12px 18px;border-top:1px solid var(--line);display:flex;gap:10px;justify-content:flex-end}

/* Confirm-Dialog */
.confirm-back{z-index:120}
.confirm-box{background:var(--card);border-radius:18px;width:min(420px,94vw);padding:28px 26px 22px;text-align:center;box-shadow:0 24px 70px rgba(0,0,0,.35);animation:modalin .22s var(--ease)}
.confirm-ico{width:58px;height:58px;border-radius:50%;margin:0 auto 14px;display:flex;align-items:center;justify-content:center;background:rgba(240,131,48,.14);color:var(--orange-dark)}
.confirm-ico svg{width:28px;height:28px;stroke-width:2}
.confirm-ico.warn{background:rgba(210,67,58,.13);color:var(--red)}
.confirm-ico.mail{background:rgba(58,110,209,.13);color:#3b6fd1}
.confirm-box h3{margin:0 0 6px;font-size:19px}
.confirm-box p{margin:0 0 20px;color:var(--muted);font-size:14px;line-height:1.55}
.confirm-box p b{color:var(--ink)}
.confirm-actions{display:flex;gap:10px;justify-content:center}
.confirm-actions .btn{min-width:120px;justify-content:center}

/* ---------------- Sonstiges ---------------- */
.section-title{font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.5px;margin:2px 0 12px}
.toast.ok{background:#2c8a52}
.logo-preview{display:flex;align-items:center;gap:16px;flex-wrap:wrap}
.logo-preview img{max-height:64px;max-width:240px;background:#fff;border:1px solid var(--line);border-radius:10px;padding:8px}
.fmt-help{font-size:12.5px;color:var(--muted);line-height:1.7;background:var(--card2);border:1px solid var(--line);border-radius:10px;padding:12px 14px}

/* Kunden-Import */
#custImportText{width:100%;font-family:inherit;font-size:14px;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:#fff;color:var(--ink);outline:none;resize:vertical}
#custImportText:focus{border-color:var(--orange);box-shadow:0 0 0 3px rgba(240,131,48,.14)}
.imp-table{width:100%;border-collapse:collapse;font-size:13px}
.imp-table th{text-align:left;color:var(--muted);font-weight:700;font-size:11px;text-transform:uppercase;letter-spacing:.3px;padding:6px 8px;border-bottom:1px solid var(--line);white-space:nowrap}
.imp-table td{padding:4px 6px;border-bottom:1px solid var(--line);vertical-align:middle}
.imp-table input.imp-f{width:100%;min-width:80px;padding:6px 8px;border:1px solid var(--line);border-radius:8px;background:#fff;color:var(--ink);font-family:inherit;font-size:13px;outline:none}
.imp-table input.imp-f:focus{border-color:var(--orange)}
.imp-badge{display:inline-block;padding:2px 9px;border-radius:20px;font-size:11px;font-weight:700;white-space:nowrap}
.imp-badge.neu{background:#e7f5ec;color:#1f7a45}
.imp-badge.upd{background:#fdeede;color:#a85b17}

/* Design-Einstellungen */
.dgrid{display:grid;grid-template-columns:1fr 76px 46px 62px;gap:10px 14px;align-items:center;max-width:520px}
.dgrid .h{font-size:11px;color:var(--muted);font-weight:700;text-transform:uppercase;letter-spacing:.4px}
.dgrid .name{font-size:14px}
.dgrid input[type=number]{width:100%;padding:8px 9px;border:1px solid var(--line);border-radius:9px;background:#fff;color:var(--ink);font-family:inherit;font-size:14px;outline:none}
.dgrid input[type=number]:focus{border-color:var(--orange);box-shadow:0 0 0 3px rgba(240,131,48,.14)}
.chk{display:inline-flex;align-items:center;gap:7px;font-size:13px;color:var(--ink);cursor:pointer}
.chk input{width:16px;height:16px;accent-color:var(--orange)}
.margins-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;max-width:440px}
.stepper{display:flex;align-items:center;gap:6px}
.stepper button{width:30px;height:34px;border:1px solid var(--line);background:var(--card);border-radius:8px;cursor:pointer;font-size:16px;color:var(--ink);transition:border-color .12s}
.stepper button:hover{border-color:var(--orange)}
body.dark .field input,body.dark .field select,body.dark .field textarea,
body.dark .search input,body.dark .toolbar select,body.dark .note-input textarea,
body.dark #custImportText,body.dark .imp-table input.imp-f,
body.dark .dgrid input[type=number],body.dark .margins-grid .field input{background:#2e2e34;border-color:#3a3a41;color:var(--ink)}
body.dark .field input::placeholder,body.dark .field textarea::placeholder,
body.dark .search input::placeholder,body.dark #custImportText::placeholder,body.dark .note-input textarea::placeholder{color:#7a7a86}
body.dark .field.readonly input{background:#202024;color:#8a8a95}
body.dark .line{background:#2a2a2f;border-color:#3a3a41}
body.dark .btn.ghost,body.dark .btn-line,body.dark .theme-toggle,body.dark .stepper button{background:#2e2e34;border-color:#43434b;color:var(--ink)}
body.dark .btn.ghost:hover,body.dark .btn-line:hover{border-color:var(--orange)}
body.dark .tab.active{color:#fff}
body.dark .subtab.active{background:#ececf1;color:#1a1a1e}
body.dark .btn.dark{background:#ececf1;color:#15151a}
body.dark .btn.dark:hover{background:#fff}
body.dark .btn.danger{background:#3a2020;color:#ff8a80}
body.dark .pay,body.dark .stat,body.dark .fmt-help{background:#2a2a2f;border-color:#3a3a41}
body.dark .badge{background:#2e2e34;border-color:#43434b}
body.dark .modal{background:#242428}
body.dark .modal .body{background:#1a1a1e}
body.dark table.list tr:hover td{background:#2e2e34}
body.dark .cust-row:hover,body.dark .combo-item:hover,body.dark .combo-item.active{background:#2e2e34}
body.dark .cust-row.active{background:rgba(240,131,48,.16)}
body.dark .line .del:hover{background:#3a2020;color:#ff8a80}
body.dark .logo-preview img{background:#fff}
body.dark .iconbtn:hover{background:#2e2e34}
body.dark .status.entwurf{background:#313138;color:#aaa}
body.dark .status.festgeschrieben{background:#22304a;color:#8db4ff}
body.dark .status.versendet{background:#3a2c15;color:#f0b35e}
body.dark .status.bezahlt{background:#193a2a;color:#6fe0a2}
body.dark .status.overdue,body.dark .lvl-pill{background:#3a2020;color:#ff9a90}
body.dark .lvl-pill.l0{background:#26262c;color:#9c9ca8}
body.dark .lvl-pill.l1{background:#3a2f1a;color:#e6b566}
body.dark .tl-item::before{background:var(--card)}
body.dark code{background:#2e2e34;border-color:#43434b}
body.dark .dpv-frame{background:#2f2f33}
/* In der Topbar steht das Kennzeichen neben dem Logo - genau wie das
   orange "KLICKFORCE" im CRM. Auf schmalen Fenstern weg, dort zaehlt Platz. */
.topbar .brand-sub{flex:0 0 auto;white-space:nowrap}
@media(max-width:860px){.topbar .brand-sub{display:none}}
.login-card .field{margin-bottom:10px}
.login-card input{width:100%}
.logout-btn{margin-left:6px}
/* display:flex wuerde sonst das hidden-Attribut aushebeln (CRM-Link in der Topbar) */
.theme-toggle[hidden]{display:none}
