/* Basic page layout and print styles for Tiptap editor */
.tiptap-page-container {
  display: flex;
  justify-content: center;
  padding: 24px;
  overflow-x: auto;
  overflow-y: auto;
}

/* Outer scrollable container */
.tiptap-outer-container {
  width: 100%;
  height: 100%;
  overflow-x: auto !important;
  overflow-y: auto !important;
  display: flex;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  background: #e5e7eb;
}

/* Fixed DIN A4 wrapper */
.main-panel > .content { flex: 1; min-height: 0; height: auto; }
.project-editor-layout { flex: 1; min-height: 0; }
.project-editor-layout > .row, .project-editor-layout > .row > .col-md-6 { min-height: 0; }
.project-editor-shell { flex-basis: 0; min-height: 0; }
.invoice-editor-container .editor-pane { min-height: 0; }
.invoice-editor-container #document-editor-container { min-height: 0; height: auto; overflow: hidden; }
.tiptap-editor { min-height: 0; }
.document-editor { display:flex; flex-direction:column; overflow:hidden; }
.document-editor > .editor-ribbon { flex:0 0 auto; width:100% !important; min-width:0 !important; max-width:100%; border-radius:0; }
.document-editor > .tiptap-outer-container { flex:1 1 0; min-height:0; height:auto !important; }
.document-editor.tiptap-disabled > .editor-ribbon { opacity:.45; }
.tiptap-ruler-strip { position:relative; flex:0 0 32px; height:32px; width:100%; overflow:hidden; background:linear-gradient(180deg,#f8f9fa,#e9ecef); border-bottom:1px solid #d3d9df; }
.tiptap-ruler-strip > div:not(.tiptap-ruler) { z-index:21; }
.tiptap-ruler-strip > .tiptap-ruler { position:relative !important; top:auto; border-bottom:0; }
.document-editor.tiptap-disabled > .tiptap-ruler-strip { visibility:hidden; }
.tiptap-editor.tiptap-disabled { position: relative; background: #e5e7eb; }
.tiptap-disabled .tiptap-wrapper { visibility: hidden; }
.tiptap-empty-selection { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 32px; text-align: center; color: #64748b; font-size: var(--ef-font-body); }
.tiptap-empty-selection[hidden] { display: none; }
.template-kind-icon { margin-right: 8px; color: #64748b; }
.fa-folder.template-kind-icon { color: #d29a2e; }
.template-create-location { padding: 10px 12px; border-radius: 8px; background: #eff6ff; color: #475569; font-size: var(--ef-font-body); }
.project-template-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 14px 16px; border-top: 1px solid #e2e8f0; background: #f8fafc; font-size: var(--ef-font-body); }
.project-template-summary .modal-button { margin-left: auto; }
.project-template-summary p { flex-basis: 100%; margin: 0; }
.tiptap-wrapper {
  width: 210mm !important;
  min-width: 210mm !important;
  max-width: 210mm !important;
}

.tiptap-page {
  width: 210mm !important; /* A4 width - FIXED */
  min-width: 210mm !important;
  min-height: 297mm; /* A4 height */
  background: white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  margin: 12px 0;
  box-sizing: border-box;
  padding: 20mm; /* default page margin */
  overflow: hidden;
}
.tiptap-page .ProseMirror {
  min-height: calc(297mm - 40mm);
  outline: none;
}


/* Ruler styles - modernized */
.tiptap-ruler { 
  position: sticky !important;
  top: 0;
  flex: 0 0 32px;
  min-height: 32px;
  z-index: 20;
  box-sizing: border-box; 
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 1px solid #d3d9df;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  user-select: none;
}

.tiptap-ruler-ticks {
  position: relative;
  height: 100%;
  flex: 1;
}

.tiptap-ruler-handle { 
  border-radius: 3px;
  background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: all 0.15s ease;
  border: 1px solid rgba(0,0,0,0.1);
}

.tiptap-ruler-handle:hover {
  background: linear-gradient(135deg, #5a9ff2 0%, #4585cd 100%) !important;
  box-shadow: 0 3px 6px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.3);
  transform: scale(1.05);
}

.tiptap-ruler-handle:active {
  box-shadow: 0 1px 2px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
  transform: scale(0.98);
}

.tiptap-tabstop-marker {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 10px solid #e67e22;
  cursor: pointer;
  top: 18px;
  transform: translateX(-6px);
  transition: all 0.12s ease;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.15));
}

.tiptap-tabstop-marker:hover {
  border-top-color: #d35400;
  transform: translateX(-6px) scale(1.15);
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.25));
}

.tiptap-tabstop-marker:active {
  transform: translateX(-6px) scale(1.05);
}

.tiptap-ruler-tick {
  position: absolute;
  width: 1px;
  background: #adb5bd;
}

.tiptap-ruler-tick.major {
  height: 14px;
  background: #6c757d;
}

.tiptap-ruler-tick.minor {
  height: 7px;
}

.tiptap-ruler-number {
  position: absolute;
  font-size: 9px;
  color: #495057;
  top: 2px;
  transform: translateX(-50%);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-weight: 500;
}

.page-break { display: block; height: 24px; margin: 8px 0; border-top: 2px dashed #bbb; }
@media print {
  .page-break { display: block; page-break-after: always; break-after: page; }
}

.tiptap-host .ProseMirror .placeholder-chip { border: 1px dashed #2563eb; border-radius: 4px; background: #dbeafe; color: #1e40af; cursor: pointer; padding: 1mm; }
.tiptap-host .ProseMirror .placeholder-chip[data-category="customer"] { border-color: #2563eb; background: #dbeafe; color: #1e40af; }
.tiptap-host .ProseMirror .placeholder-chip[data-category="company"] { border-color: #0f766e; background: #ccfbf1; color: #115e59; }
.tree-item-wrapper[data-placeholder-category="customer"] .tree-item-title { color: #1e40af; }
.tree-item-wrapper[data-placeholder-category="company"] .tree-item-title { color: #115e59; }
.tree-item-wrapper[data-placeholder-category="customer"] .tree-item-title::before,
.tree-item-wrapper[data-placeholder-category="company"] .tree-item-title::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; background: #2563eb; }
.tree-item-wrapper[data-placeholder-category="company"] .tree-item-title::before { background: #0f766e; }
.tiptap-editor.hide-formatting-marks .tiptap-tab-space { border-bottom-color: transparent !important; }
.tiptap-editor.hide-formatting-marks .tiptap-tab-space::after { visibility: hidden; }
.placeholder-settings { border: 1px solid #cbd5e1; border-radius: 12px; padding: 24px; max-width: 440px; }
.placeholder-settings::backdrop { background: #0f172a66; }
.placeholder-settings label { display: block; margin: 12px 0; }
.placeholder-settings input { width: 90px; float: right; }
.placeholder-settings select { width: 140px; float: right; }
.invoice-positions { border: 2px dashed #7c3aed; padding: 12px; background: #f5f3ff; margin: 16px 0; }
.invoice-positions table { width: 100%; border-collapse: collapse; font-size: 12px; }
.invoice-positions td, .invoice-positions th { border: 1px solid #c4b5fd; padding: 6px; overflow-wrap: anywhere; }
.tiptap-host img { max-width: 100%; height: auto; }

.position-gear { border: 1px solid #cbd5e1; border-radius: 12px; padding: 24px; max-width: 850px; width: 90vw; }
.position-gear::backdrop { background: #0f172a66; }
.position-column-row { display: grid; grid-template-columns: 130px minmax(100px,1fr) 75px 90px 32px 32px 32px; gap: 8px; align-items: center; margin: 8px 0; }
.position-column-row input { width: 100%; min-width: 0; }
.position-gear footer { display: flex; gap: 12px; margin-top: 20px; }
.invoice-positions { cursor: text; }
.invoice-positions td .placeholder-chip { max-width:100%; }
.invoice-positions { position: relative; }
.position-add-field { position:absolute; right:0; top:-22px; height:22px; width:26px; padding:0; border:1px solid #cbd5e1; border-radius:5px 5px 0 0; background:white; color:#2563eb; font-size:18px; cursor:pointer; }
.position-gear { position:absolute; right:-25px; top:0; width:25px; height:25px; padding:0; max-width:none; z-index:20; border:0; background:white; color:#2563eb; cursor:pointer; }
.position-add-field,.position-gear,.totals-edit { opacity:0; pointer-events:none; transition:opacity .12s; }
.invoice-positions:hover>.position-add-field,.invoice-positions:focus-within>.position-add-field,.invoice-positions:hover>.position-gear,.invoice-positions:focus-within>.position-gear,.invoice-totals:hover>.totals-edit,.invoice-totals:focus-within>.totals-edit,.tableWrapper:hover>.position-gear,.tableWrapper:hover>.totals-edit,.tableWrapper:focus-within>.position-gear,.tableWrapper:focus-within>.totals-edit { opacity:1; pointer-events:auto; }
.invoice-positions+.invoice-totals,.tableWrapper[data-invoice-kind="positions"]+.tableWrapper[data-invoice-kind="totals"],table[data-invoice-kind="positions"]+table[data-invoice-kind="totals"] { margin-top:calc(-1 * var(--invoice-border-width,1px)); }
.invoice-field-chip { max-width:100%; padding:3px 6px; border-radius:5px; box-sizing:border-box; }
.placeholder-chip[data-category="positions"] { background:#ede9fe; border-color:#a78bfa; color:#6d28d9; }
.placeholder-chip[data-category="totals"] { background:#fff7ed; border-color:#fdba74; color:#9a3412; }
.invoice-style-settings { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin:18px 0; }
.invoice-style-settings label { margin:0; }
.invoice-style-settings input,.invoice-style-settings select { display:block; width:100%; }
.invoice-delete-table { color:#b91c1c!important; margin-right:auto; }
.invoice-layout-engine { position:absolute; width:210mm; height:0; overflow:hidden; visibility:hidden; }
.editor-side-settings .position-column-row { grid-template-columns:minmax(100px,1fr) 55px 80px 32px 32px 24px 24px 24px; }
.editor-side-settings .position-column-row input[type="color"] { width:32px; height:30px; padding:2px; }
@media print { .position-gear,.totals-edit,.position-add-field { display:none!important; } }
.position-resize-handle { position:absolute; top:0; bottom:0; right:-5px; width:10px; z-index:2; cursor:col-resize; touch-action:none; }
.position-resize-handle:hover { background:#2563eb44; }
.position-field-menu { position:fixed; z-index:11000; width:260px; padding:12px; background:white; box-shadow:0 8px 30px #0f172a33; border:1px solid #cbd5e1; border-radius:8px; }
.position-field-menu[hidden] { display:none; }
.position-field-menu select,.position-field-menu button { display:block; width:100%; margin:6px 0; padding:6px; }
.invoice-totals { position:relative; cursor:pointer; }
.invoice-totals, table[data-invoice-kind="totals"], .tableWrapper:has(> table[data-invoice-kind="totals"]) { break-inside:avoid; page-break-inside:avoid; }
table thead { display:table-header-group; }
.editor-settings-overlay.placeholder-mode { pointer-events:none; background:transparent; }
.editor-settings-overlay.placeholder-mode > aside { pointer-events:auto; }
.placeholder-picker-list details { margin:6px 0; }
.placeholder-picker-list summary { font-weight:600; padding:7px 0; cursor:pointer; }
.placeholder-picker-list details details { margin-left:10px; }
.placeholder-picker-list .text-field-item { display:block; width:100%; padding:5px 9px; margin-top:3px; border:1px solid #e2e8f0; border-radius:7px; background:#f8fafc; text-align:left; font-size:var(--ef-font-compact); cursor:grab; }
.placeholder-picker-list [data-placeholder-category="customer"] { color:#1e40af; background:#dbeafe; border-color:#93c5fd; }
.placeholder-picker-list [data-placeholder-category="company"] { color:#115e59; background:#ccfbf1; border-color:#5eead4; }
.placeholder-picker-list [data-placeholder-category="positions"] { color:#6d28d9; background:#ede9fe; border-color:#a78bfa; }
.placeholder-picker-list [data-placeholder-category="totals"] { color:#9a3412; background:#fff7ed; border-color:#fdba74; }
.placeholder-picker-list .text-field-item:hover { filter:brightness(.96); }
.tiptap-toolbar .editor-margin-input { width:76px; min-width:76px; }
.totals-edit { position:absolute; right:-25px; top:0; border:0; background:white; color:#2563eb; cursor:pointer; }
.totals-row-settings { display:grid; grid-template-columns:1fr 1fr 28px 28px 28px; gap:5px; margin:8px 0; }
.totals-row-settings input { min-width:0; width:100%; }
.invoice-positions th,.invoice-positions td,.invoice-totals td,.tiptap-editor .tiptap-host table[data-position-table] td,.tiptap-editor .tiptap-host table[data-position-table] th { box-sizing:border-box; }
@media print { .totals-edit,.position-add-field,.position-resize-handle,.position-field-menu { display:none!important; } }
.invoice-positions th { cursor:grab; }
.print-preview-overlay { position:fixed; inset:0; z-index:12000; background:#e2e8f0; display:flex; flex-direction:column; }
.print-preview-toolbar { padding:12px 20px; background:white; border-bottom:1px solid #cbd5e1; display:flex; gap:12px; align-items:center; }
.print-preview-frame { flex:1; border:0; width:100%; }

/* The document owns the page size and margins; the host must add no extra padding. */
.tiptap-editor .tiptap-wrapper { height: auto; min-height: 0; overflow: visible; background: transparent; border: 0; box-shadow: none; }
.tiptap-editor .tiptap-host { padding: 0 !important; background: transparent; height: auto !important; }
.tiptap-editor .tiptap-host .ProseMirror { padding: 0; max-height: none; min-height: 0; overflow: visible; border: 0; background: transparent; border-radius: 0; box-shadow: none; font-size: 11pt; line-height: 1; }
.tiptap-editor .tiptap-host .ProseMirror:focus { border: 0; box-shadow: none; }
.document-page { display: block; position: relative; width: 210mm; min-width: 210mm; max-width: 210mm; height: 297mm; min-height: 297mm; box-sizing: border-box; margin: 0 0 20px; background: white; box-shadow: 0 2px 12px #0f172a22; flex: none; }
.document-page-content { height: 100%; display: flow-root; }
.tiptap-editor .tiptap-host .ProseMirror p { margin: 0; }
.tiptap-editor .tiptap-host .ProseMirror h1,
.tiptap-editor .tiptap-host .ProseMirror h2,
.tiptap-editor .tiptap-host .ProseMirror h3 { margin: 0; }
.tiptap-editor .tiptap-host .invoice-positions { border: 0; padding: 0; margin: 0; background: transparent; }
.tiptap-editor .tiptap-host table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.tiptap-editor .tiptap-host td, .tiptap-editor .tiptap-host th { border: 1px solid #b9c4d2; padding: 2mm; vertical-align: top; position: relative; overflow-wrap: anywhere; }
.tiptap-editor .tiptap-host th { background: #f1f5f9; }
.tiptap-editor .tiptap-host table[data-position-table="true"] { font-size: 12px; }
.tiptap-editor .tiptap-host .selectedCell::after { content: ''; position: absolute; inset: 0; background: #2563eb22; pointer-events: none; }
.tiptap-editor .tableWrapper { overflow: visible; }
.tiptap-editor .column-resize-handle { position: absolute; right: -2px; top: 0; bottom: 0; width: 4px; background: #2563eb; pointer-events: none; }
.tiptap-editor .resize-cursor { cursor: col-resize; }
.position-drop-marker { position: fixed; width: 5px; background: #2563eb; box-shadow: 0 0 0 2px white; z-index: 10000; pointer-events: none; }
.position-drop-marker[hidden] { display: none; }
.column-drop-target { border-top: 4px solid #2563eb; }
.position-column-row small { cursor: grab; }
[data-placeholder-token][draggable="true"] { cursor: grab; }
.page-settings { border: 1px solid #cbd5e1; border-radius: 12px; padding: 24px; }
.page-settings label { display: flex; justify-content: space-between; gap: 20px; margin: 12px 0; }
.page-settings input { width: 90px; }
.document-page[data-oversized="true"] { outline: 2px solid #e67e22; }
.editor-settings-host { padding: 16px; }
.editor-side-settings { width: 100%; max-width: none; box-sizing: border-box; border: 0; border-radius: 0; padding: 8px; background: white; }
.editor-side-settings[hidden], .editor-settings-overlay[hidden] { display: none; }
.editor-side-settings .position-column-row { grid-template-columns: 95px minmax(65px,1fr) 52px 70px 26px 26px 26px; gap: 5px; font-size: var(--ef-font-compact); }
.editor-side-settings .position-column-row small { overflow-wrap: anywhere; }
.editor-side-settings label { display: block; margin: 12px 0; }
.field-settings input, .custom-position-field input { display: block; width: 100%; box-sizing: border-box; margin: 8px 0; }
.editor-settings-overlay { position: fixed; inset: 0; z-index: 10000; background: #0f172a66; display: flex; justify-content: flex-end; }
.editor-settings-drawer { width: min(580px,100vw); height: 100%; overflow: auto; background: white; padding: 20px; box-sizing: border-box; }
@media print {
  @page { size: A4; margin: 0; }
  .tiptap-toolbar, .tiptap-ruler-strip, .tiptap-ruler, .tiptap-section-ruler, .right-pane { display: none !important; }
  .tiptap-editor .tiptap-outer-container { display: block; padding: 0; overflow: visible !important; background: white; }
  .document-page { box-shadow: none; margin: 0; break-after: page; }
  .document-page:last-child { break-after: auto; }
}

.tiptap-editor .editor-ribbon { display: block; padding: 0; gap: 0; background: #f8fafc; border: 1px solid #dbe3ed; border-radius: 10px 10px 0 0; box-shadow: 0 2px 8px #0f172a08; }
.editor-ribbon-navigation { display:flex; justify-content:space-between; align-items:center; padding:6px 10px 0; background:white; border-bottom:1px solid #dbe3ed; }
.editor-ribbon-tabs { display:flex; gap:4px; }
.editor-ribbon-tab { border:0; border-bottom:3px solid transparent; background:transparent; color:#64748b; padding:10px 16px; font-size: var(--ef-font-body); font-weight: var(--ef-font-weight-semibold); cursor:pointer; }
.editor-ribbon-tab[aria-selected="true"] { color:#2563eb; border-bottom-color:#2563eb; }
.editor-ribbon-tab:hover { color:#1d4ed8; background:#eff6ff; }
.editor-ribbon-tab[hidden], .editor-ribbon-panel[hidden] { display:none; }
.editor-ribbon-quick { display:flex; gap:4px; padding-bottom:5px; }
.tiptap-editor .editor-ribbon-quick .tiptap-btn { border:0; box-shadow:none; background:transparent; font-size: var(--ef-font-section-title); padding:4px 9px; }
.editor-ribbon-panel { display:flex; align-items:stretch; flex-wrap:wrap; padding:12px 10px 8px; gap:0; min-height:106px; box-sizing:border-box; }
.editor-ribbon-group { display:flex; flex-direction:column; justify-content:space-between; padding:0 12px; border-right:1px solid #dbe3ed; gap:10px; }
.editor-ribbon-group:last-child { border-right:0; }
.editor-ribbon-group-controls { display:flex; flex-wrap:wrap; align-items:center; gap:6px; max-width:300px; }
.editor-ribbon-group-caption { font-size: var(--ef-font-caption); color:#94a3b8; letter-spacing:.04em; text-align:center; }
.editor-ribbon-control { display:flex; flex-direction:column; gap:4px; font-size: var(--ef-font-caption); color:#64748b; margin:0; }
.tiptap-editor .editor-ribbon .tiptap-btn { font-size: var(--ef-font-compact); padding:7px 9px; border-radius:5px; box-shadow:none; transform:none; }
.tiptap-editor .editor-ribbon .tiptap-btn:disabled { opacity:.35; cursor:default; transform:none; box-shadow:none; }
.tiptap-editor .editor-ribbon .tiptap-select { font-size: var(--ef-font-compact); max-width:160px; padding:6px 8px; border-radius:5px; box-shadow:none; }
.editor-ribbon-tab:focus-visible, .editor-ribbon .tiptap-btn:focus-visible { outline:2px solid #2563eb; outline-offset:2px; }
.editor-ribbon-group[aria-label="Schrift"] .editor-ribbon-group-controls { max-width: 205px; }
.editor-ribbon-group[aria-label="Format"] .editor-ribbon-group-controls { display:grid; grid-template-columns:repeat(2,max-content); }
.editor-ribbon-group[aria-label="Absatz"] .editor-ribbon-group-controls { display:grid; grid-template-columns:repeat(2,max-content); max-width:none; }
.editor-ribbon-group[aria-label="Schrift"] select[aria-label="Schriftart"] { width:130px; }
.editor-ribbon-group[aria-label="Schrift"] select[aria-label="Größe"] { width:64px; }
.editor-ribbon-group[aria-label="Absatz"] select { max-width:140px; }
.tiptap-editor .editor-ribbon .editor-ribbon-quick .tiptap-btn { font-size: var(--ef-font-section-title); }

/* Gemeinsames Menüband für Vorlagen, Dokumente und Textbausteine. */
.tiptap-editor .editor-ribbon { min-width:0 !important; max-width:100%; box-sizing:border-box; background:#fff; border:1px solid #d8d8d8; border-radius:3px 3px 0 0; box-shadow:none; }
.editor-ribbon-navigation { padding:0 10px; min-height:34px; background:#f4f2ef; border-bottom:1px solid #dedbd7; }
.editor-ribbon-tabs { gap:4px; }
.editor-ribbon-tabs { min-width:0; overflow-x:auto; }
.editor-ribbon-quick { flex-shrink:0; }
.editor-ribbon-tab { padding:8px 12px 6px; font-size: var(--ef-font-compact); font-weight: var(--ef-font-weight-normal); color:#303030; border-bottom-width:2px; }
.editor-ribbon-tab[aria-selected="true"] { color:#1f2937; border-bottom-color:#2167aa; font-weight: var(--ef-font-weight-semibold); }
.editor-ribbon-tab:hover { background:#e8e6e3; color:#111; }
.editor-ribbon-quick { padding:0; }
.editor-ribbon-panel { flex-wrap:nowrap; overflow-x:auto; min-height:105px; padding:8px 4px 4px; align-items:stretch; }
.editor-ribbon-group { flex:none; padding:0 12px; gap:4px; border-right-color:#d6d6d6; }
.editor-ribbon-group-caption { font-size: var(--ef-font-caption); color:#717171; letter-spacing:0; padding-top:4px; }
.tiptap-editor .editor-ribbon .editor-ribbon-group-controls { display:flex; flex-wrap:nowrap; max-width:none; height:70px; gap:5px; align-items:center; }
.editor-ribbon-row { display:flex; align-items:center; gap:4px; min-height:30px; }
.editor-ribbon-group:has(.editor-ribbon-row) .editor-ribbon-group-controls { flex-direction:column; justify-content:center; align-items:flex-start; gap:4px; }
.tiptap-editor .editor-ribbon .editor-ribbon-table-panel .editor-ribbon-group-controls { flex-direction:column; justify-content:center; align-items:stretch; gap:4px; }
.editor-ribbon-control { font-size: var(--ef-font-caption); color:#535353; gap:2px; }
.editor-ribbon-row .editor-ribbon-control > span { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
.tiptap-editor .editor-ribbon .tiptap-select { border:1px solid #bcbcbc; background:#fff; border-radius:2px; height:27px; padding:3px 24px 3px 6px; min-width:65px; max-width:145px; font-size: var(--ef-font-compact); }
.tiptap-editor .editor-ribbon select[aria-label="Schriftart"] { width:145px; }
.tiptap-editor .editor-ribbon select[aria-label="Schriftgröße"] { width:67px; }
.tiptap-editor .editor-ribbon select[aria-label="Zeilenabstand"] { width:95px; }
.tiptap-editor .editor-ribbon .editor-command { display:inline-flex; justify-content:center; align-items:center; gap:5px; background:transparent; border:1px solid transparent; border-radius:3px; color:#333; min-width:28px; min-height:28px; padding:4px; }
.tiptap-editor .editor-ribbon .editor-command:hover { background:#edf3fa; border-color:#a9c6e4; }
.tiptap-editor .editor-ribbon .editor-command.is-active { background:#e3eaf3; border-color:#aab7c8; }
.editor-command-icon { display:flex; align-items:center; justify-content:center; font-size:17px; line-height:1; min-width:19px; }
.tiptap-editor .editor-ribbon .editor-command-icon svg { width:20px; height:20px; fill:none; }
.editor-ribbon-row .editor-command-label,.editor-ribbon-quick .editor-command-label { display:none; }
.editor-command[data-command="bold"] .editor-command-icon { font-weight:700; font-size:14px; }
.editor-command[data-command="italic"] .editor-command-icon { font-style:italic; font-size:14px; }
.editor-command[data-command="underline"] .editor-command-icon { text-decoration:underline; font-size:14px; }
.editor-command[data-command="strike"] .editor-command-icon { text-decoration:line-through; font-size:12px; }
.tiptap-editor .editor-ribbon .editor-command-large { flex-direction:column; align-self:stretch; min-width:59px; max-width:96px; padding:6px 8px; gap:7px; }
.editor-command-large .editor-command-label { display:block; font-size:11px; line-height:1.2; text-align:center; white-space:normal; }
.tiptap-editor .editor-ribbon .editor-command-large .editor-command-icon svg { width:30px; height:30px; }
.editor-command-large .editor-command-icon { font-size:29px; min-height:31px; color:#365b7d; }
.tiptap-editor .editor-ribbon .editor-ribbon-quick .editor-command { font-size: var(--ef-font-section-title); padding:2px 5px; }
@media (max-width:700px) {
  .editor-ribbon-tab { padding:8px; }
  .editor-ribbon-group { padding:0 8px; }
  .editor-ribbon-quick { gap:0; }
}
.modal-panel-shell { position: relative; display: flex; flex-direction: column; height: 100%; background: #fff; color: #263449; }
.modal-panel-header { padding: 28px 28px 20px; border-bottom: 1px solid #e5eaf1; background: #f8fafc; }
.modal-panel-header h3 { margin: 0; font-size: 21px; font-weight: 650; color: #17283e; }
.modal-panel-header p { margin: 8px 0 0; color: #64748b; font-size: 14px; }
.modal-panel-close { position: absolute; top: 14px; right: 14px; z-index: 2; }
.modal-close-button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: #64748b; font-size: 24px; cursor: pointer; }
.modal-close-button:hover { background: #e9eef5; }
.modal-panel-body { flex: 1; min-height: 0; overflow: auto; padding: 24px 28px; }
.modal-panel-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 28px; border-top: 1px solid #e5eaf1; background: #f8fafc; flex-shrink: 0; }
.modal-button { min-width: 90px; padding: 10px 18px; border: 1px solid #d5deea; border-radius: 8px; background: white; color: #34445b; font: inherit; font-weight: 600; cursor: pointer; }
.modal-button-primary { border-color: #2563eb; background: #2563eb; color: white; }
.modal-button-primary:hover { background: #1d4ed8; }
.modal-button:focus-visible, .modal-close-button:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.template-modal-content:not([hidden]) { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.template-modal-content form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.modal-panel-shell .editor-settings-host { padding: 0; flex: 1; min-height: 0; }
.modal-panel-shell [hidden] { display: none !important; }
.editor-side-settings { padding: 0; height: 100%; color: #263449; }
.editor-side-settings .modal-panel-form { display: flex; flex-direction: column; height: 100%; margin: 0; }
.editor-side-settings .modal-panel-body > p { color: #64748b; font-size: var(--ef-font-body); line-height: 1.6; }
.editor-side-settings label { font-size: var(--ef-font-body); font-weight: var(--ef-font-weight-semibold); margin: 0 0 20px; }
.editor-side-settings input, .editor-side-settings select, .modal-panel-body .form-control { box-sizing: border-box; border: 1px solid #d5deea; border-radius: 7px; padding: 9px 11px; background: #fff; color: #263449; }
.editor-side-settings label > input { display: block; width: 100%; margin-top: 8px; }
.editor-side-settings input:focus, .editor-side-settings select:focus { outline: 2px solid #bfdbfe; border-color: #3b82f6; }
.editor-side-settings .placeholder-source { padding: 10px 12px; background: #eff6ff; border-radius: 7px; color: #1d4ed8; overflow-wrap: anywhere; }
.editor-side-settings .position-column-row { grid-template-columns: minmax(90px,1fr) 62px 94px 28px 28px 28px; gap: 7px; padding: 12px; margin: 0 0 12px; border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; }
.editor-side-settings .position-column-row small { grid-column: 1 / -1; color: #64748b; font-size: var(--ef-font-compact); }
.editor-side-settings .position-column-row button { padding: 4px; border: 1px solid #d5deea; border-radius: 6px; background: white; cursor: pointer; }
.editor-side-settings .modal-panel-actions .modal-button { padding: 10px 18px; }
.editor-side-settings .add-column, .editor-side-settings .modal-panel-body > button { margin-top: 10px; padding: 9px 12px; border: 1px solid #d5deea; border-radius: 7px; background: white; color: #2563eb; cursor: pointer; }
.tiptap-editor .tiptap-host .placeholder-chip[data-category="positions"] { background:#ede9fe; border-color:#a78bfa; color:#6d28d9; }
.tiptap-editor .tiptap-host .placeholder-chip[data-category="totals"] { background:#fff7ed; border-color:#fdba74; color:#9a3412; }
.editor-side-settings .position-column-row { grid-template-columns:minmax(100px,1fr) 55px 80px 32px 32px 24px 24px 24px; }
.modal-panel-actions[hidden] { display:none!important; }
.project-table-settings-body { padding:0!important; overflow:hidden!important; }
#project-table-settings { height:100%; min-height:0; }
#project-table-settings > .editor-side-settings { height:100%; box-sizing:border-box; }

/* Text blocks retain their natural footprint; guides never affect printing. */
.tiptap-editor:not(.hide-formatting-marks) .text-block { outline:1px solid #c4b5fd; outline-offset:2px; background:#faf8ff; position:relative; }
.tiptap-editor:not(.hide-formatting-marks) .text-block::before { content:attr(data-text-block-name); display:block; font-size:10px; line-height:14px; color:#7c3aed; height:0; transform:translateY(-14px); pointer-events:none; }
@media print { .text-block { outline:none!important; background:transparent!important; } .text-block::before { display:none!important; } }
.einvoice-form label{display:block;font-size:13px;margin-bottom:12px}.einvoice-form label .form-control,.einvoice-form label .form-select{margin-top:4px}.einvoice-form .form-select{padding-right:36px;background-position:right 12px center}.einvoice-pair{display:grid;grid-template-columns:1fr 1fr;gap:12px}.einvoice-form details{border:1px solid #dce2ec;border-radius:6px;padding:12px;margin:16px 0}.einvoice-form summary{font-weight:600;cursor:pointer;margin-bottom:12px}.einvoice-form .alert{font-size:13px;overflow-wrap:anywhere}.einvoice-form .alert ul{padding-left:18px;margin:0}
.einvoice-read-only .editor-ribbon-panels { opacity:.55; pointer-events:none; }
.document-recovery-notice { padding:14px 16px; background:#fff8e8; border-bottom:1px solid #ead7ac; font-size:13px; }
.document-recovery-notice p { margin:6px 0 10px; }
.document-recovery-notice button { margin-right:8px; }
.toolbar .document-command-bar { display:flex; align-items:center; gap:6px; min-width:0; margin-left:8px; }
.document-command-group { display:flex; align-items:center; gap:3px; padding-right:7px; border-right:1px solid #e3dfed; }
.document-command-group:last-child { border-right:0; padding-right:0; }
.document-icon-button { display:inline-flex; align-items:center; justify-content:center; width:34px; height:34px; padding:0; border:1px solid transparent; border-radius:7px; color:#655e80; background:transparent; font-size:15px; flex-shrink:0; }
.document-icon-button:hover:not(:disabled) { color:#6c5ce7; background:#eee9fc; border-color:#ded6f5; }
.document-icon-button:focus-visible { outline:2px solid #6c5ce7; outline-offset:2px; }
.document-icon-button:disabled { opacity:.35; cursor:default; }
@media (max-width:700px) { .toolbar .document-command-bar { gap:3px; overflow-x:auto; margin-left:0; } .document-command-group { padding-right:4px; } .document-icon-button { width:30px; height:32px; } }

/* Wiederholende Seitenbereiche bleiben außerhalb des fließenden Dokumenttextes. */
.document-page > [data-page-band] { position:absolute; left:var(--page-left,20mm); right:var(--page-right,20mm); display:flow-root; overflow:visible; font-size:12px; line-height:1.2; }
.document-page > .document-page-header { top:var(--page-top,20mm); height:var(--page-header,15mm); }
.document-page > .document-page-footer { bottom:var(--page-bottom,20mm); height:var(--page-footer,15mm); }
.document-page > [data-page-band] p { margin:0; }
.document-page:first-child[data-header-first="false"] { padding-top:var(--page-top,20mm)!important; }
.document-page:first-child[data-footer-first="false"] { padding-bottom:var(--page-bottom,20mm)!important; }
.document-page:first-child[data-header-first="false"] > .document-page-header,
.document-page:first-child[data-footer-first="false"] > .document-page-footer { display:none; }
.page-band-settings { margin:14px 0; padding:12px; border:1px solid var(--ef-border,#e0e2ec); border-radius:8px; }
.page-band-settings > label { display:flex; align-items:center; gap:8px; margin:9px 0; }
.page-band-tools { display:flex; gap:4px; flex-wrap:wrap; margin:8px 0; }
.page-band-tools select { max-width:100%; }
.page-band-editor { border:1px solid var(--ef-border,#e0e2ec); border-radius:5px; padding:10px; background:white; }
.page-band-editor .ProseMirror { min-height:70px; outline:none; display:block!important; padding:0!important; }
.page-band-editor p { margin:0; }
.document-page-header img { max-width:100%; max-height:var(--page-header,15mm); }
.document-page-footer img { max-width:100%; max-height:var(--page-footer,15mm); }
