/* Kanzlei-Hub – gemeinsame Shell (Auftrag C): Seitenleiste, Navigation, Badges,
   Knöpfe und Dialoge. Beide Oberflächen binden diese Datei ein (nach der jeweiligen
   styles.css), damit Navigation und Knöpfe überall identisch aussehen. */

/* ── Seitenleiste (Container-Flächen über Variablen) ── */
.sidebar, .product-nav { background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border); }

/* ── Navigation: identische Größen/Abstände/Zustände in beiden Oberflächen ── */
.side-nav { display: flex; flex-direction: column; }
.nav-group { margin-bottom: 5px; display: block; }
.nav-group:last-child { margin-bottom: 2px; }
.nav-eyebrow { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase;
  color: #A39CBD; padding: 5px 9px 2px; font-weight: 700;
  display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0;
  cursor: pointer; border-radius: 7px; transition: color .12s; }
.nav-eyebrow span { flex: 1; text-align: left; }
.nav-eyebrow:hover { color: #6B6488; }
.nav-eyebrow:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }

.nav-item { display: flex; align-items: center; gap: 9px; padding: 6px 9px; border-radius: 8px;
  color: #56516E; background: none; border: 0; width: 100%; text-align: left;
  font-size: 13px; line-height: 1.15; font-weight: 600; position: relative;
  transition: background .12s, color .12s; cursor: pointer; }
.nav-item > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; flex: 1; }
.nav-item:hover { background: color-mix(in srgb, var(--violet) 8%, #fff); color: var(--violet); }
.nav-item.active { background: color-mix(in srgb, var(--violet) 13%, #fff); color: var(--violet); }
/* Aktiv wird allein über violetten Hintergrund + violette Schrift dargestellt – kein roter Balken. */
.nav-item:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }

/* Badges an Navigationseinträgen */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  margin-left: 6px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; }
.nav-badge[hidden] { display: none !important; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 20px; background: #EFEAF7; color: var(--violet); font-weight: 700; }
.badge.off { background: #F0EEEE; color: var(--muted); }

/* ── Knöpfe: ein einheitliches System für beide Oberflächen ──
   Sekundär (Standard): heller Rahmen; Primär: violett gefüllt; Ghost: rahmenlos;
   Gefahr (danger-text): roter Text; klein (small/sm): kompakter. Fokusring Pflicht. */
.btn, .ghost, .ghostbtn, .btn-secondary,
.panel-head button, .head-actions button, .settings-actions button, .upload-queue button,
.folder-row button, .export-box button, .btnrow button, .datev-actions button {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; line-height: 1.2;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s; }
.btn:hover, .ghost:hover, .ghostbtn:hover, .btn-secondary:hover,
.panel-head button:hover, .head-actions button:hover, .settings-actions button:hover, .upload-queue button:hover,
.folder-row button:hover, .export-box button:hover, .btnrow button:hover, .datev-actions button:hover {
  border-color: var(--violet-700); background: #F6F4FA; color: var(--violet); }

/* Ghost im Sinne des Hub: rahmenlos/transparent (subtile Aktion) */
.btn-ghost { border: 1px solid transparent; background: transparent; color: inherit;
  padding: 8px 14px; border-radius: 8px; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s; }
.btn-ghost:hover { background: color-mix(in srgb, var(--violet) 8%, #fff); color: var(--violet); }

.primary, .btn-primary, .settings-actions .primary, .panel-head .primary {
  border: 1px solid var(--violet); background: var(--violet); color: #fff;
  padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; line-height: 1.2;
  cursor: pointer; box-shadow: 0 6px 18px rgba(56,45,94,.14);
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s; }
.primary:hover, .btn-primary:hover, .settings-actions .primary:hover, .panel-head .primary:hover {
  background: var(--violet-deep); border-color: var(--violet-deep); color: #fff; }

.btn-accent { background: var(--red); color: #fff; border-color: var(--red); }
.btn-accent:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }

.danger-text, .btn-danger, .ghost.danger { color: var(--red); border-color: transparent; background: transparent; box-shadow: none; }
.danger-text:hover, .btn-danger:hover, .ghost.danger:hover { background: #FBE9EA; border-color: transparent; color: var(--red); }

.small, .btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }

/* ── Installierbare Handy-App (PWA) ── */
.pwa-hint {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 1260;
  display: flex; align-items: center; gap: 10px; width: min(430px, calc(100vw - 36px));
  padding: 12px; border: 1px solid color-mix(in srgb, var(--violet) 20%, var(--line));
  border-radius: 12px; background: var(--card); color: var(--ink); box-shadow: 0 16px 46px rgba(38,31,64,.22);
}
.pwa-hint[hidden] { display: none !important; }
.pwa-hint-icon {
  display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px;
  border-radius: 10px; background: var(--violet); color: #fff; font-size: 12px; font-weight: 800;
}
.pwa-hint-text { display: grid; gap: 2px; min-width: 0; flex: 1; }
.pwa-hint-text strong { color: var(--violet); font-size: 13.5px; }
.pwa-hint-text span { color: var(--muted); font-size: 12px; line-height: 1.35; }
.pwa-hint-close {
  align-self: flex-start; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 21px; line-height: 1; cursor: pointer;
}
.pwa-hint-close:hover { background: var(--paper-2); color: var(--violet); }
.pwa-update-hint .pwa-hint-icon { background: var(--red); font-size: 20px; }
.pwa-offline {
  width: min(520px, calc(100vw - 32px)); margin: 12vh auto 0; padding: 34px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--card); text-align: center;
  box-shadow: var(--shadow); color: var(--ink); font-family: var(--font);
}
.pwa-offline-mark {
  display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 18px;
  border-radius: 18px; background: var(--violet); color: #fff; font-weight: 800; letter-spacing: .04em;
}
.pwa-offline h1 { margin: 0 0 10px; color: var(--violet); }
.pwa-offline p { margin: 0 auto 22px; color: var(--muted); line-height: 1.55; }

@media (max-width: 768px) {
  .pwa-hint {
    left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: auto;
    align-items: center; padding: 11px;
  }
  .pwa-hint-icon { flex-basis: 34px; width: 34px; height: 34px; border-radius: 9px; }
  .pwa-hint .btn { padding: 7px 9px; white-space: nowrap; }
  .pwa-hint-close { position: absolute; top: -9px; right: -5px; background: var(--card); box-shadow: 0 2px 8px rgba(38,31,64,.18); }
  .pwa-offline { margin-top: 7vh; padding: 26px 22px; }
}

/* Auftrag O – Sicherheitsnetz: Auch ein Knopf ganz ohne Klasse (und außerhalb der oben
   genannten Container) bekommt im Arbeitsbereich und in nativen Dialogen den sekundären
   Hub-Stil, damit nirgends ein Browser-Standardknopf ("grauer Kasten") erscheint. Über
   :where() bleibt die Spezifität niedrig, sodass jede bewusste Klassen-/Container-Regel
   weiterhin gewinnt. Bewusst schlichte Elemente (Icon-, Link-, Navigations-, Werkzeug-
   Knöpfe) sind ausgenommen. Werte identisch zur .btn-Basis. */
.workspace button:where(:not(.primary):not(.btn-primary):not(.ghost):not(.ghostbtn):not(.btn-ghost):not(.btn):not(.btn-secondary):not(.danger-text):not(.btn-danger):not(.btn-accent):not(.linkbtn):not(.icon-btn):not(.iconbtn):not([class*="ico"]):not([class*="nav"]):not([class*="tab"]):not([class*="zoom"]):not([class*="doc-"]):not([class*="chip"])),
dialog button:where(:not(.primary):not(.btn-primary):not(.ghost):not(.ghostbtn):not(.btn-ghost):not(.btn):not(.btn-secondary):not(.danger-text):not(.btn-danger):not(.btn-accent):not(.linkbtn):not(.icon-btn):not(.iconbtn):not([class*="ico"]):not([class*="nav"])) {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; line-height: 1.2;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s; }
.workspace button:where(:not(.primary):not(.btn-primary):not(.ghost):not(.ghostbtn):not(.btn-ghost):not(.btn):not(.btn-secondary):not(.danger-text):not(.btn-danger):not(.btn-accent):not(.linkbtn):not(.icon-btn):not(.iconbtn):not([class*="ico"]):not([class*="nav"]):not([class*="tab"]):not([class*="zoom"]):not([class*="doc-"]):not([class*="chip"])):hover,
dialog button:where(:not(.primary):not(.btn-primary):not(.ghost):not(.ghostbtn):not(.btn-ghost):not(.btn):not(.btn-secondary):not(.danger-text):not(.btn-danger):not(.btn-accent):not(.linkbtn):not(.icon-btn):not(.iconbtn):not([class*="ico"]):not([class*="nav"])):hover {
  border-color: var(--violet-700); background: #F6F4FA; color: var(--violet); }

/* Fokusring für alle Knöpfe (Tastaturbedienung) */
.btn:focus-visible, .ghost:focus-visible, .ghostbtn:focus-visible, .btn-ghost:focus-visible, .btn-secondary:focus-visible,
.primary:focus-visible, .btn-primary:focus-visible, .btn-accent:focus-visible, .danger-text:focus-visible,
.btn-danger:focus-visible, .small:focus-visible, .btn-sm:focus-visible, .nav-bottom-actions button:focus-visible,
.panel-head button:focus-visible, .head-actions button:focus-visible, .settings-actions button:focus-visible {
  outline: none; box-shadow: var(--focus); }

/* ── Native Bedienelemente: zentral für beide Oberflächen ──
   Datei-Auswahl, Auswahllisten, Häkchen, Radios, Datum und Fortschritt dürfen
   nicht als graue Browser-Standardelemente erscheinen. */
select:not([multiple]) {
  -webkit-appearance: none; appearance: none;
  color: var(--ink); background-color: var(--card);
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select:not([multiple]):hover { border-color: var(--violet-700); }
select:not([multiple]):focus-visible { outline: none; box-shadow: var(--focus); }

input[type=checkbox]:not(.no-modern),
input[type=radio]:not(.no-modern) {
  -webkit-appearance: none; appearance: none; -moz-appearance: none;
  width: 19px; height: 19px; flex: none; margin: 0; padding: 0; position: relative;
  border: 2px solid color-mix(in srgb, var(--violet) 28%, var(--card));
  background: var(--card); cursor: pointer; vertical-align: -4px;
  transition: background .14s ease, border-color .14s ease, box-shadow .14s ease;
}
input[type=checkbox]:not(.no-modern) { border-radius: 6px; }
input[type=radio]:not(.no-modern) { border-radius: 50%; }
input[type=checkbox]:not(.no-modern):hover,
input[type=radio]:not(.no-modern):hover { border-color: var(--violet); }
input[type=checkbox]:not(.no-modern):focus-visible,
input[type=radio]:not(.no-modern):focus-visible { outline: none; box-shadow: var(--focus); }
input[type=checkbox]:not(.no-modern):checked { background: var(--violet); border-color: var(--violet); }
input[type=checkbox]:not(.no-modern):checked::after {
  content: ""; position: absolute; left: 5px; top: 1.5px; width: 5px; height: 10px;
  border: solid var(--card); border-width: 0 2.5px 2.5px 0; transform: rotate(43deg);
}
input[type=radio]:not(.no-modern):checked { border-color: var(--violet); }
input[type=radio]:not(.no-modern):checked::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--violet);
}
input[type=checkbox]:not(.no-modern):disabled,
input[type=radio]:not(.no-modern):disabled { opacity: .5; cursor: not-allowed; }

input[type=file] { font-size: 13px; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 700; color: var(--violet); background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 14px; margin-right: 11px; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
input[type=file]::file-selector-button:hover {
  background: color-mix(in srgb, var(--violet) 12%, var(--card));
  border-color: var(--violet-700);
}
input[type=file]:focus-visible { outline: none; box-shadow: var(--focus); }

.file-pick { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; flex-wrap: wrap; max-width: 100%; }
.file-pick input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-pick input:disabled + .fp-btn { cursor: not-allowed; opacity: .55; }
.fp-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  color: var(--violet); background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-weight: 700; font-size: 13px;
  text-transform: none; letter-spacing: 0;
  transition: background .12s, border-color .12s;
}
.file-pick:hover .fp-btn {
  background: color-mix(in srgb, var(--violet) 12%, var(--card));
  border-color: var(--violet-700);
}
.fp-btn svg { width: 16px; height: 16px; }
.fp-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-size: 12.5px; font-weight: 400;
  text-transform: none; letter-spacing: 0;
}
.file-pick input:focus-visible + .fp-btn { outline: none; box-shadow: var(--focus); }

input[type=date],
input[type=month] { color-scheme: light; accent-color: var(--violet); }
input[type=date]::-webkit-calendar-picker-indicator,
input[type=month]::-webkit-calendar-picker-indicator {
  margin: 0; padding: 4px; border-radius: var(--radius-sm);
  background-color: var(--paper-2); cursor: pointer; opacity: .9;
}
input[type=date]:hover::-webkit-calendar-picker-indicator,
input[type=month]:hover::-webkit-calendar-picker-indicator {
  background-color: color-mix(in srgb, var(--violet) 12%, var(--card));
}
/* Beschriftete Eingabezeile für persönliche Aufgaben. */
.ma-add #ma-title,
.ma-add input[type=date],
.ma-add select {
  width: 100%; min-width: 0; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
}
.ma-add input:focus-visible,
.ma-add select:focus-visible {
  outline: none; border-color: var(--violet); box-shadow: var(--focus);
}
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }

progress {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 8px; overflow: hidden; border: 0;
  border-radius: var(--radius-sm); background: var(--paper-2); color: var(--violet);
}
progress::-webkit-progress-bar { background: var(--paper-2); border-radius: var(--radius-sm); }
progress::-webkit-progress-value { background: var(--violet); border-radius: var(--radius-sm); }
progress::-moz-progress-bar { background: var(--violet); border-radius: var(--radius-sm); }

input[type=color] {
  width: 46px; min-height: 38px; padding: 3px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); cursor: pointer;
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 6px; }
/* Auftrag Q: native Felder der StBVV-Gebührenposition. */
.invoice-fee-fields input,
.invoice-fee-fields select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}

/* Gemeinsamer Rechnungslayout-Editor für Hub und Buchhaltungssoftware. */
.layout-editor-grid,
.hon-layout-grid {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
}
.hon-layout-grid { grid-template-columns: minmax(390px, 500px) minmax(0, 1fr); }
.layout-config,
.hon-layout-config { display: grid; gap: 12px; min-width: 0; }
.layout-config-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.layout-config-card > h3 {
  margin: 0;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0;
}
.layout-variants {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
}
.layout-variant {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  text-align: left;
}
.layout-variant:hover { border-color: var(--violet); background: var(--paper-2); }
.layout-variant.active {
  border-color: var(--violet);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--violet) 18%, transparent);
}
.layout-variant-mini { display: grid; place-items: center; color: var(--muted); }
.layout-variant-mini svg { width: 48px; height: 62px; fill: none; stroke: currentColor; stroke-width: 1.2; }
.layout-variant.active .layout-variant-mini { color: var(--violet); }
.layout-variant strong,
.layout-variant small { display: block; overflow-wrap: anywhere; }
.layout-variant strong { margin-top: 5px; font-size: 12px; }
.layout-variant small { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.layout-fields { display: grid; gap: 11px; padding: 13px 14px; }
.layout-fields.two { grid-template-columns: 1fr 1fr; }
.layout-fields label,
.faktura-settings-grid label,
.customer-form-grid label {
  display: grid;
  min-width: 0;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.layout-fields .span2,
.faktura-settings-grid .span2,
.customer-form-grid .span2 { grid-column: 1 / -1; }
.layout-fields input:not([type=checkbox]),
.layout-fields textarea,
.faktura-settings-grid input:not([type=checkbox]),
.faktura-settings-grid textarea,
.customer-form-grid input,
.customer-form-grid select,
.customer-note-field textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
}
.layout-fields textarea,
.faktura-settings-grid textarea { resize: vertical; }
.layout-fields input:focus,
.layout-fields textarea:focus,
.faktura-settings-grid input:focus,
.faktura-settings-grid textarea:focus,
.customer-form-grid input:focus,
.customer-form-grid select:focus,
.customer-note-field textarea:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: var(--focus);
}
.layout-color-control { display: flex; align-items: center; gap: 8px; }
.layout-color-control input[type=color] { width: 34px; min-width: 34px; height: 34px; min-height: 34px; padding: 2px; }
.layout-color-control input:last-child { flex: 1; min-width: 0; }
.layout-stepper {
  display: grid;
  grid-template-columns: 34px 52px 34px auto;
  align-items: center;
  width: max-content;
  max-width: 100%;
}
.layout-stepper button,
.layout-zoom button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--card);
  color: var(--violet);
}
.layout-stepper button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.layout-stepper input { height: 34px; padding: 5px; border-radius: 0; border-left: 0; border-right: 0; text-align: center; }
.layout-stepper span { padding-left: 8px; color: var(--muted); font-size: 12px; }
.layout-logo-drop {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 14px 10px;
  padding: 12px;
  border: 1px dashed color-mix(in srgb, var(--violet) 28%, var(--line));
  border-radius: 8px;
  background: var(--paper);
  transition: border-color .12s, background .12s;
}
.layout-logo-drop.dragging { border-color: var(--violet); background: var(--paper-2); }
.layout-logo-preview {
  display: grid;
  place-items: center;
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--violet);
}
.layout-logo-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.layout-logo-copy { display: block; flex: 1; min-width: 0; }
.layout-logo-copy strong,
.layout-logo-copy small { display: block; }
.layout-logo-copy strong { color: var(--ink); font-size: 13px; }
.layout-logo-copy small {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layout-logo-drop .file-pick { flex: 0 0 auto; }
.layout-config-card > .danger-text { margin: 0 14px 12px; padding: 0; border: 0; background: transparent; }
.layout-preview-wrap {
  position: sticky;
  top: 16px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.layout-preview-bar {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.layout-preview-bar > strong { font-size: 13px; }
.layout-zoom {
  display: grid;
  grid-template-columns: 30px 52px 30px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.layout-zoom button { width: 30px; height: 30px; min-height: 30px; border: 0; }
.layout-zoom output { color: var(--muted); font-size: 11px; text-align: center; font-variant-numeric: tabular-nums; }
.layout-preview-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 536px;
  overflow: hidden;
  padding: 18px 10px;
  background: var(--paper);
}
.layout-preview-scale { --layout-preview-zoom: .72; flex: 0 0 374px; width: 374px; height: 530px; }
.invoice-live-sheet {
  position: relative;
  width: 520px;
  height: 735px;
  box-sizing: border-box;
  overflow: hidden;
  padding: 34px 38px 28px;
  transform: scale(var(--layout-preview-zoom));
  transform-origin: top left;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 7px;
  line-height: 1.4;
}
.live-sheet-head { display: flex; justify-content: space-between; gap: 24px; min-height: 78px; }
.live-logo { display: flex; flex-direction: column; justify-content: flex-start; max-width: 225px; color: var(--invoice-brand); }
.live-logo strong { font-size: 18px; line-height: 1.1; }
.live-logo span { margin-top: 3px; font-size: 6px; letter-spacing: 0; }
.live-logo img { display: block; width: auto; max-width: 220px; height: var(--invoice-logo-height); object-fit: contain; object-position: left top; }
.live-provider { display: grid; align-content: start; justify-items: end; color: var(--muted); text-align: right; }
.live-provider strong { color: var(--ink); font-size: 9px; }
.live-sender { padding-bottom: 5px; border-bottom: 1px solid var(--invoice-brand); color: var(--invoice-brand); font-size: 5.5px; }
.live-address { display: grid; width: 220px; min-height: 76px; align-content: start; padding-top: 10px; font-size: 8px; }
.live-invoice-meta { display: grid; grid-template-columns: 1fr 190px; gap: 18px; margin-top: 10px; }
.live-invoice-meta h3 { margin: 0 0 4px; color: var(--invoice-brand); font-size: 17px; }
.live-invoice-meta dl { margin: 0; }
.live-invoice-meta dl div { display: grid; grid-template-columns: 90px 1fr; gap: 8px; padding: 1px 0; }
.live-invoice-meta dt { color: var(--muted); }
.live-invoice-meta dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.live-position-table { width: 100%; margin-top: 18px; border-collapse: collapse; font-size: 7px; }
.live-position-table th { padding: 5px 4px; border-bottom: 1px solid var(--invoice-brand); color: var(--invoice-brand); text-align: left; }
.live-position-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.live-position-table th:nth-child(n+3),
.live-position-table td:nth-child(n+3) { text-align: right; font-variant-numeric: tabular-nums; }
.live-position-table td strong,
.live-position-table td span { display: block; }
.live-position-table td span { color: var(--muted); font-size: 6px; }
.live-sums { width: 205px; margin: 13px 0 0 auto; }
.live-sums > div { display: flex; justify-content: space-between; gap: 12px; padding: 2px 4px; font-variant-numeric: tabular-nums; }
.live-sums span { color: var(--muted); }
.live-sums .live-grand-total { margin-top: 4px; padding: 6px 4px; background: var(--paper-2); color: var(--invoice-brand); font-size: 9px; }
.live-sums .live-grand-total span { color: inherit; }
.live-closing { margin-top: 17px; }
.live-closing p { margin: 4px 0; }
.live-footer {
  position: absolute;
  left: 38px;
  right: 38px;
  bottom: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
  padding-top: 7px;
  border-top: 1px solid var(--invoice-brand);
  color: var(--muted);
  font-size: 5.5px;
}
.invoice-live-sheet.variant-modern .live-sheet-head { margin: -34px -38px 0; padding: 24px 38px 14px; background: var(--invoice-brand); }
.invoice-live-sheet.variant-modern .live-logo,
.invoice-live-sheet.variant-modern .live-provider,
.invoice-live-sheet.variant-modern .live-provider strong { color: var(--card); }
.invoice-live-sheet.variant-modern .live-sender { margin-top: 11px; }
.invoice-live-sheet.variant-kompakt { padding-top: 25px; }
.invoice-live-sheet.variant-kompakt .live-sheet-head { min-height: 54px; }
.invoice-live-sheet.variant-kompakt .live-address { min-height: 58px; }
.invoice-live-sheet.variant-kompakt .live-position-table { margin-top: 10px; }

.hon-layout-settings { margin-bottom: 14px; }
.hon-layout-head { display: flex; justify-content: flex-end; margin: 0 0 12px; }
.hon-layout-head .field { width: min(360px, 100%); }
.hon-layout-preview { min-width: 0; }
.hon-layout-actions { margin-top: 14px; }
.hon-layout-empty {
  display: grid;
  justify-items: start;
  gap: 6px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}
.hon-layout-empty span { color: var(--muted); }
.hon-pflicht-hinweis {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-left: 3px solid var(--red);
  border-radius: 6px;
  background: color-mix(in srgb, var(--red) 8%, var(--card));
  color: var(--ink);
}
.hon-pflicht-hinweis[hidden] { display: none; }
.hon-pflicht-hinweis > div { display: grid; gap: 3px; min-width: 0; }
.hon-pflicht-hinweis strong { font-size: 12px; }
.hon-pflicht-hinweis span { color: var(--muted); font-size: 11px; line-height: 1.4; }
.hon-platzhalter-fehlt {
  display: inline;
  padding: 0 2px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--red) 14%, var(--card));
  color: var(--red);
  font-weight: 750;
}
.hon-absender-source {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.hon-absender-zeile {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.hon-absender-zeile span { color: var(--muted); }
.hon-absender-zeile strong { min-width: 0; overflow-wrap: anywhere; }
.hon-absender-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; }

@media (max-width: 999px) {
  .layout-editor-grid,
  .hon-layout-grid { grid-template-columns: 1fr; }
  .layout-editor-grid > .layout-preview-wrap { position: relative; top: auto; order: -1; }
  .layout-preview-stage { min-height: 486px; }
  .layout-preview-scale { flex-basis: 322px; width: 322px; height: 456px; }
  .invoice-live-sheet { transform: scale(.62); }
}

@media (max-width: 768px) {
  .layout-variants { grid-template-columns: repeat(3, minmax(96px, 1fr)); overflow-x: auto; }
  .layout-fields.two { grid-template-columns: 1fr; }
  .layout-fields .span2 { grid-column: auto; }
  .layout-logo-drop { align-items: flex-start; flex-wrap: wrap; }
  .layout-logo-copy { min-width: calc(100% - 70px); }
  .layout-logo-drop .file-pick { margin-left: 65px; }
  .layout-preview-stage { min-height: 390px; padding: 12px 6px; }
  .layout-preview-scale { flex-basis: 265px; width: 265px; height: 375px; }
  .invoice-live-sheet { transform: scale(.51); }
  .hon-layout-head { justify-content: stretch; }
  .hon-layout-head .field { width: 100%; }
  .hon-pflicht-hinweis { align-items: flex-start; flex-direction: column; }
  .hon-absender-zeile { grid-template-columns: 1fr; gap: 2px; }
}
