/* Einheitliche Oberfläche: Platzausnutzung bei Browser-Zoom, Knöpfe, Storno-Kennzeichnung.
   Wird als letzte Stildatei geladen und gleicht die über die Jahre gewachsenen Einzelregeln an. */

/* ---------- Inhaltsbreite: wächst bei verkleinerter Ansicht (Zoom 75–90 %, große Monitore) mit ---------- */
.content {
  max-width: clamp(1480px, 92vw, 2240px);
}
/* Kein waagerechtes Scrollen durch zu breite Einzelelemente */
.content img,
.content video,
.content canvas {
  max-width: 100%;
}

/* ---------- Knöpfe ---------- */
/* Text und Symbol immer mittig – auch bei festen Breiten, Vollbreite und Zeilenumbruch */
.btn {
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  vertical-align: middle;
}
.btn > svg,
.btn > .ic {
  flex: none;
}
/* Leere Zähler-Platzhalter (z. B. „Kundenlink“ ohne neue Anfragen) dürfen den Text nicht aus der Mitte schieben */
.btn > span:empty {
  display: none;
}
/* Mehrzeilige Knöpfe (schmale Spalten): Höhe wächst mit, Text bleibt mittig */
.btn.wrap,
.btn[style*='white-space:normal'],
.btn[style*='white-space: normal'] {
  height: auto;
  min-height: 34px;
  padding-top: 6px;
  padding-bottom: 6px;
}
/* Knöpfe ohne Text (nur Symbol): quadratisch, Symbol mittig */
.btn.icon-only {
  padding: 0;
  width: 34px;
}
.btn.sm.icon-only {
  width: 28px;
}
/* Gefahr: rot umrandet; als Hauptaktion eines Bestätigungsdialogs rot gefüllt */
.btn.danger {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, var(--line-2));
}
.btn.danger:hover {
  background: var(--bad-soft);
}
.btn.ghost.danger {
  border-color: transparent;
}
.modal footer .btn.danger:last-child:not([style*='margin-right']) {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}
.modal footer .btn.danger:last-child:not([style*='margin-right']):hover {
  background: color-mix(in srgb, var(--bad) 85%, #000);
}
/* Deaktiviert: deutlich als nicht anklickbar erkennbar (auch bei gefüllten Knöpfen) */
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
/* Sichtbarer Tastaturfokus für alle Knöpfe, auch gefüllte */
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.primary:focus-visible {
  outline-color: color-mix(in srgb, var(--accent) 70%, var(--text));
}
/* Dialoge: einheitliche Reihenfolge – Nebenaktionen links, Abbrechen davor, Hauptaktion ganz rechts */
.modal footer {
  flex-wrap: wrap;
  align-items: center;
}
.modal footer .btn[style*='margin-right'] {
  order: -1;
}
.modal footer .btn.primary {
  order: 1;
}
/* Knopfreihen: gleichmäßige Abstände */
.btn-row {
  gap: 8px;
}
/* Handy/App: Tippflächen mindestens 44 px */
.appmode #view .btn,
.appmode .modal footer .btn {
  min-height: 44px;
}
.appmode #view .btn.sm {
  min-height: 44px;
  min-width: 44px;
}

/* ---------- Projekt schnell anlegen (unter der Projekt-Auswahl) ---------- */
.proj-new {
  margin-top: 2px;
  padding: 2px 0;
  align-self: flex-start;
  font-weight: 500;
  justify-content: flex-start;
}

/* ---------- Storno: in Listen und Belegansicht eindeutig ---------- */
tr.doc-storniert td {
  color: var(--muted);
}
tr.doc-storniert td.num,
tr.doc-storniert td.num *,
.st-x {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  color: var(--muted);
}
tr.doc-storniert td:first-child,
tr.doc-storniert .c-no {
  color: var(--text);
}
.st-ref {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--bad);
  white-space: nowrap;
  margin-top: 2px;
}
.st-ref a {
  color: inherit;
  text-decoration: underline;
}
.st-ref .st-chip {
  background: var(--bad-soft);
  color: var(--bad);
}
.storno-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 15px;
}
.storno-banner > svg {
  width: 22px;
  height: 22px;
  flex: none;
  margin-top: 1px;
}
.storno-banner a {
  color: inherit;
  text-decoration: underline;
}
.storno-banner .small {
  color: var(--text);
  margin-top: 2px;
  font-size: 13px;
}
.storno-banner.info {
  border-color: color-mix(in srgb, var(--info) 40%, transparent);
  background: var(--info-soft);
  color: var(--info);
}
.badge.storno-big {
  font-size: 13px;
  padding: 3px 10px;
}

/* Anzeigegröße (public/anzeige.js): Oberfläche kompakter bei 100 % Browser-Zoom */
html[data-anzeige] .app,
html[data-anzeige] .login-wrap,
html[data-anzeige] .modal-bg > .modal,
html[data-anzeige] .toasts,
html[data-anzeige] .update-bar {
  zoom: var(--anzeige, 1);
}
html[data-anzeige] .app {
  min-height: calc(100vh / var(--anzeige, 1));
}
html[data-anzeige] .side {
  height: calc(100vh / var(--anzeige, 1));
}
html[data-anzeige] .content {
  max-width: clamp(1480px, calc(92vw / var(--anzeige, 1)), 2240px);
}

/* =====================================================================================================
   Einheitliches Raster für die ganze Software (3.124): gleiche Höhen, gleiche Abstände, ruhige Gruppen.
   Abstände nur aus der Skala 4 · 8 · 12 · 16 · 24 · 32 px; Bedienelemente 36 px (klein 30 px) hoch.
   ===================================================================================================== */
:root {
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --ctl-h: 36px;
  --ctl-h-sm: 30px;
}

/* ---------- Knöpfe: gleiche Höhe, gleiche Innenabstände, gleiche Abstände untereinander ---------- */
.btn {
  height: var(--ctl-h);
  min-height: var(--ctl-h);
  padding: 0 var(--sp-4);
  gap: var(--sp-2);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s, color 0.12s;
}
.btn.sm {
  height: var(--ctl-h-sm);
  min-height: var(--ctl-h-sm);
  padding: 0 var(--sp-3);
  gap: 6px;
  font-size: 13px;
}
.btn:not(.primary):not(.ghost):not(.danger):hover {
  border-color: var(--faint);
  background: var(--panel-2);
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Gruppen von Knöpfen: immer 8 px Abstand, umbrechen statt quetschen */
.btn-row,
.modal footer,
.page-head,
.sb-knoepfe,
.actions,
.toolbar {
  gap: var(--sp-2);
}
.btn-row {
  row-gap: var(--sp-2);
}
.page-head .btn-row,
.page-head > .btn + .btn {
  margin-left: 0;
}
/* Knöpfe direkt nebeneinander ohne Gruppe (ältere Seiten) bekommen denselben Abstand */
.card > .btn + .btn,
.page-head > .btn + .btn,
.modal .body > .btn + .btn {
  margin-left: var(--sp-2);
}

/* ---------- Segment-Schalter (Reiter-Gruppen, Filter, Ansicht): eine ruhige, zusammenhängende Leiste ---------- */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius-sm) + 3px);
  max-width: 100%;
}
.seg > .btn {
  height: var(--ctl-h-sm);
  min-height: var(--ctl-h-sm);
  padding: 0 var(--sp-3);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-size: 13px;
  font-weight: 550;
}
.seg > .btn:hover {
  color: var(--text);
  background: var(--panel);
  border-color: transparent;
}
.seg > .btn.primary,
.seg > .btn[aria-pressed='true'],
.seg > .btn[aria-current='page'] {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line-2);
  box-shadow: 0 1px 2px rgba(16, 16, 24, 0.08);
}
.seg > .btn.primary .sb-n,
.seg > .btn .sb-n {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Reiter-Leisten ---------- */
.tabs {
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
}
.tabs button,
.tabs a {
  padding: 10px var(--sp-3);
}

/* ---------- Seitenkopf: Titel, Untertitel, Aktionen ---------- */
.page-head {
  margin-bottom: var(--sp-5);
  row-gap: var(--sp-3);
}
.page-head h1 {
  margin: 0;
  line-height: 1.2;
}
.page-head .muted.small,
.page-head h1 + .muted {
  margin-top: var(--sp-1);
}

/* ---------- Karten: gleiche Innenabstände, gleicher Abstand untereinander ---------- */
.card {
  padding: 20px;
  border-radius: var(--radius);
}
.card + .card {
  margin-top: var(--sp-4);
}
.grid > .card + .card,
.grid > .card,
/* Kennzahl- und Kachelraster (eigene Grid-Klassen): Abstand kommt vom gap – sonst sitzt die erste Karte höher */
[class$='kpis'] > .card,
[class*='kpis '] > .card,
[class$='-grid'] > .card,
[class*='-grid '] > .card,
[class$='-tiles'] > .card {
  margin-top: 0;
}
.grid {
  gap: var(--sp-4);
}
.card > h2:first-child,
.card > h3:first-child,
.card > header:first-child h2 {
  margin-top: 0;
}
.card h2 {
  font-size: 17px;
  line-height: 1.3;
  margin-bottom: var(--sp-3);
}
.card h3 {
  font-size: 14px;
  margin: var(--sp-4) 0 var(--sp-2);
}

/* ---------- Eingabefelder: gleiche Höhe wie Knöpfe, ruhiger Fokus ---------- */
input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='color']):not([type='file']),
select {
  min-height: var(--ctl-h);
  border-radius: var(--radius-sm);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.f {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--sp-3);
}
.flbl {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--muted);
}
.grid2,
.form-grid {
  gap: var(--sp-3) var(--sp-4);
}

/* ---------- Kennzeichen (Badges): gleiche Höhe und Form ---------- */
.badge {
  min-height: 22px;
  padding: 0 var(--sp-2);
  gap: var(--sp-1);
  line-height: 1;
  font-size: 12px;
}
.badge svg {
  width: 12px;
  height: 12px;
}

/* ---------- Tabellen: einheitliche Zeilenhöhe, ruhige Kopfzeile ---------- */
.t th {
  padding: 10px var(--sp-3);
  font-size: 12px;
  letter-spacing: 0.01em;
}
.t td {
  padding: 11px var(--sp-3);
}
.t tbody tr:hover td {
  background: var(--panel-2);
}

/* ---------- Fenster (Dialoge) ---------- */
.modal header {
  padding: var(--sp-4) var(--sp-5);
}
.modal .body {
  padding: var(--sp-5);
}
.modal footer {
  padding: var(--sp-3) var(--sp-5) var(--sp-4);
  flex-wrap: wrap;
}
.modal header h2 {
  font-size: 18px;
  line-height: 1.3;
}

/* ---------- Kleine Bildschirme: Gruppen dürfen umbrechen, Knöpfe bleiben gleich hoch ---------- */
@media (max-width: 700px) {
  .card {
    padding: var(--sp-4);
  }
  .modal .body {
    padding: var(--sp-4);
  }
  .page-head {
    margin-bottom: var(--sp-4);
  }
}

/* ---------- Schlicht: keine Zusatzsymbole in Text-Knöpfen, keine Erklärzeilen unter Seitentiteln ---------- */
.btn[data-btxt='1'] > .ic,
.btn[data-btxt='1'] > svg {
  display: none;
}
/* „+ Neuer Kontakt“ / „+ Neues Projekt“ unter einer Auswahl: als Link erkennbar (Akzentfarbe, Plus bleibt) */
.btn.contact-new {
  color: var(--accent);
}
.btn.contact-new[data-btxt='1'] > .ic {
  display: inline-block;
}
.btn.contact-new:hover {
  text-decoration: underline;
}
.page-head h1 + .muted.small:not([id]):not(:has(b)),
.page-head h1 + .ak-sub {
  display: none;
}

/* Shop-Schnittstelle: Schnell verbinden (Anschlussdatei) */
.sh-schnell {
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--panel));
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 4px 0 18px;
}
.sh-schnell-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.sh-schnell-form .f { margin: 0; }
@media (max-width: 860px) { .sh-schnell-form { grid-template-columns: 1fr; } }

/* Zwei-Faktor-Hinweis: kurz am Handy, sonst ausführlich */
.tf-bar .tf-kurz { display: none; }
.tf-bar[hidden] { display: none !important; }
@media (max-width: 720px) {
  .tf-bar { flex-wrap: nowrap; gap: 8px; padding: 8px 10px 8px 12px; }
  .tf-bar .tf-lang { display: none; }
  .tf-bar .tf-kurz { display: inline; flex: 1; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
