/* ============================================================
   APPROACH HOLTMANN FONT FAMILY
   ============================================================ */
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-Lt.otf') format('opentype');
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-LtIt.otf') format('opentype');
  font-weight: 300; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-Rg.otf') format('opentype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-RgIt.otf') format('opentype');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-Md.otf') format('opentype');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-MdIt.otf') format('opentype');
  font-weight: 500; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-SmBd.otf') format('opentype');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-SmBdIt.otf') format('opentype');
  font-weight: 600; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-Bd.otf') format('opentype');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-BdIt.otf') format('opentype');
  font-weight: 700; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-Blk.otf') format('opentype');
  font-weight: 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-BlkIt.otf') format('opentype');
  font-weight: 800; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-XBlk.otf') format('opentype');
  font-weight: 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann';
  src: url('../assets/fonts/ApproachHoltmann-XBlkIt.otf') format('opentype');
  font-weight: 900; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann Ultra';
  src: url('../assets/fonts/ApproachHoltmann-UltBlk.otf') format('opentype');
  font-weight: 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Approach Holtmann Ultra';
  src: url('../assets/fonts/ApproachHoltmann-UltBlkIt.otf') format('opentype');
  font-weight: 900; font-style: italic; font-display: swap;
}

/* ============================================================
   GLOBALS
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel-2: #fafafa;
  --border: #e5e7eb;
  --border-dark: #d1d5db;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #1f2937;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --radius: 6px;
  --font-ui: 'Approach Holtmann', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-doc: 'Approach Holtmann', Arial, Helvetica, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "header header" "sidebar main";
  height: 100vh;
}

.app-header {
  grid-area: header;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.app-header h1 {
  font-size: 15px; font-weight: 600; margin: 0; letter-spacing: 0.01em;
}
.app-header .meta { font-size: 12px; color: #9ca3af; margin-left: auto; }
.app-header .header-actions { display: flex; gap: 8px; }
.app-header button {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 6px 12px; border-radius: var(--radius);
  cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 500;
  transition: background 0.15s;
}
.app-header button:hover { background: rgba(255,255,255,0.2); }
.app-header button.primary { background: var(--primary); border-color: var(--primary); }
.app-header button.primary:hover { background: var(--primary-hover); }

.sidebar {
  grid-area: sidebar;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
}

.main {
  grid-area: main;
  overflow-y: auto;
  padding: 30px 20px;
  background: var(--bg);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin: 0 0 10px 0; font-weight: 600;
}
.sidebar .section {
  margin-bottom: 24px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar .section:last-child { border-bottom: none; }

.field { margin-bottom: 12px; }
.field label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text-muted); margin-bottom: 4px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border-dark); border-radius: var(--radius);
  font-size: 13px; font-family: inherit; font-weight: 400;
  color: var(--text); background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.field textarea {
  resize: vertical; min-height: 70px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; line-height: 1.5;
}
.field-row { display: flex; gap: 8px; }
.field-row > * { flex: 1; }

.small-btn {
  background: var(--panel-2); border: 1px solid var(--border-dark);
  color: var(--text); padding: 4px 10px;
  font-size: 12px; font-family: inherit; font-weight: 500;
  border-radius: var(--radius); cursor: pointer;
  transition: background 0.15s;
}
.small-btn:hover { background: var(--border); }

.save-badge {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--success); font-size: 11px; font-weight: 500;
  opacity: 0; transition: opacity 0.3s;
}
.save-badge.visible { opacity: 1; }

/* Sidebar: prominent button to open leistungen modal */
.big-action-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}
.big-action-btn:hover { background: var(--primary-hover); }
.big-action-btn .arrow { font-size: 16px; }

/* Sidebar: leistungen summary (Tags) */
.leistungen-summary {
  margin-top: 10px;
}
.leistungen-summary .empty {
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  padding: 4px 0;
}
.leistungen-summary .count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.leistungen-summary .tags {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.leistungen-summary .tag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 4px 6px 4px 8px;
  font-size: 12px;
  line-height: 1.3;
}
.leistungen-summary .tag .tag-text { flex: 1; }
.leistungen-summary .tag .tag-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: inherit;
}
.leistungen-summary .tag .tag-remove:hover { background: rgba(0,0,0,0.06); color: var(--danger); }

/* ============================================================
   DOCUMENT (DIN A4)
   ============================================================ */
.document-stack {
  display: flex; flex-direction: column;
  align-items: center; gap: 20px;
}

.a4-page {
  background: white;
  width: 210mm;
  min-height: 297mm;
  padding: 20mm 22mm 18mm 22mm;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  font-family: var(--font-doc); font-weight: 400;
  color: #000; font-size: 10.5pt; line-height: 1.4;
  position: relative;
  page-break-after: always;
}

/* Logo: max 30% page width (= 63mm). We use 60mm. */
.holtmann-logo {
  margin-bottom: 8mm;
  display: block;
}
.holtmann-logo img {
  width: 60mm;
  height: auto;
  display: block;
}
.holtmann-logo .logo-fallback {
  display: none;
  font-family: var(--font-doc); font-weight: 900;
  font-size: 22pt; letter-spacing: -0.5pt; line-height: 1;
  color: #c8932e;
}
.holtmann-logo.no-image img { display: none; }
.holtmann-logo.no-image .logo-fallback { display: block; }

.doc-title {
  font-family: var(--font-doc);
  font-size: 13pt; font-weight: 700;
  color: #000; margin-bottom: 10mm;
}

.parties { margin-bottom: 6mm; }
.parties .row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8mm;
  margin-bottom: 4mm;
}
.parties .label-right {
  text-align: right; align-self: end;
}
.parties .label-right strong { font-weight: 700; }

.doc-section {
  margin-top: 5mm;
  page-break-inside: avoid;
}
.doc-section h3 {
  font-family: var(--font-doc);
  font-size: 11pt; font-weight: 700;
  margin: 0 0 3mm 0; color: #000;
}
.doc-section .para {
  display: grid;
  grid-template-columns: 12mm 1fr;
  column-gap: 2mm;
  margin-bottom: 2mm;
  text-align: justify;
}
.doc-section .para-num { flex-shrink: 0; }
.doc-section .para-flat { margin-bottom: 2mm; text-align: justify; }
.doc-section ul.bullets {
  margin: 2mm 0 2mm 12mm; padding-left: 5mm;
}
.doc-section ul.bullets li { margin-bottom: 1mm; }
.doc-section .leistungs-list-doc {
  margin: 2mm 0; padding: 0; list-style: none;
}
.doc-section .leistungs-list-doc li { font-weight: 700; }
.doc-section .leistungs-label {
  font-weight: 700; margin-top: 3mm; margin-bottom: 2mm;
}
.doc-section .sub-letters {
  display: grid;
  grid-template-columns: 8mm 1fr;
  margin-left: 12mm;
  margin-bottom: 1mm;
  text-align: justify;
}
.doc-section .sub-plain {
  margin-left: 12mm;
  margin-bottom: 1mm;
}
.doc-section .small-text {
  font-size: 9pt;
}

/* Footer */
.doc-footer {
  margin-top: 14mm;
  padding-top: 4mm;
  border-top: 1px solid #ddd;
  font-size: 8pt; color: #000;
}
.doc-footer-line2 {
  display: flex;
  justify-content: space-between;
  gap: 8mm;
}
.doc-footer-page { text-align: center; margin-top: 1mm; }

/* Signature */
.signature-area { margin-top: 12mm; page-break-inside: avoid; }
.signature-area .sig-place { margin-bottom: 14mm; }
.signature-area .sig-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20mm;
}
.signature-area .sig-col .sig-img { height: 14mm; margin-bottom: 1mm; }
.signature-area .sig-col .sig-label { font-weight: 400; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(17,24,39,0.55);
  z-index: 100;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: white;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 880px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
}
.modal-wide { max-width: 1100px; }
.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none;
  font-size: 24px; line-height: 1; cursor: pointer;
  color: var(--text-muted); padding: 0;
  width: 32px; height: 32px;
  border-radius: var(--radius); font-family: inherit;
}
.modal-close:hover { background: var(--panel-2); color: var(--text); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.modal-intro { color: var(--text-muted); font-size: 13px; margin: 0 0 16px 0; }

.btn {
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; border: 1px solid transparent;
  transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: white; color: var(--text); border-color: var(--border-dark); }
.btn-secondary:hover { background: var(--panel-2); }
.btn-danger { background: white; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }

/* Data tables */
.data-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.data-table th, .data-table td {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table th {
  font-weight: 600; color: var(--text-muted);
  background: var(--panel-2); font-size: 12px;
}
.data-table tr:hover td { background: var(--panel-2); }
.data-table td button {
  background: none; border: none;
  color: var(--primary); cursor: pointer;
  font-size: 13px; font-family: inherit; padding: 0 6px;
}
.data-table td button.del { color: var(--danger); }
.data-table td button:hover { text-decoration: underline; }

.form-block {
  padding: 16px; background: var(--panel-2);
  border-radius: var(--radius); margin-bottom: 8px;
}
.form-block h3 { margin: 0 0 12px 0; font-size: 14px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.form-actions { display: flex; gap: 8px; }

/* ============================================================
   TABS BAR
   ============================================================ */
.tabs-bar {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding: 6px 12px 0 12px;
  background: var(--panel-2);
  flex-shrink: 0;
  row-gap: 4px;
}
.tab {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  user-select: none;
  font-family: inherit;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.12s, background 0.12s;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); background: white; }
.tab.active {
  border-bottom-color: var(--primary);
  color: var(--text);
  font-weight: 600;
}
.tab.add-new {
  color: var(--primary);
  font-weight: 600;
}
.tab .tab-actions {
  opacity: 0;
  display: flex;
  gap: 2px;
  margin-left: 4px;
  transition: opacity 0.12s;
}
.tab:hover .tab-actions { opacity: 1; }
.tab.active .tab-actions { opacity: 1; }
.tab .tab-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
  line-height: 1;
}
.tab .tab-action-btn:hover { background: var(--border); color: var(--text); }
.tab .tab-action-btn.del:hover { background: #fee2e2; color: var(--danger); }

/* ============================================================
   CARDS (Leistungen Modal)
   ============================================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.l-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 14px 14px 14px 16px;
  cursor: pointer;
  background: white;
  transition: all 0.12s;
  font-size: 13px;
  line-height: 1.4;
  min-height: 64px;
  display: flex;
  align-items: center;
}
.l-card:hover { border-color: var(--border-dark); background: var(--panel-2); }
.l-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.l-card.active::before {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 8px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}
.l-card-text {
  flex: 1;
  padding-right: 22px;
}
.l-card-actions {
  position: absolute;
  bottom: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.12s;
}
.l-card:hover .l-card-actions { opacity: 1; }
.l-card-action {
  width: 24px; height: 24px;
  border-radius: 4px;
  background: white;
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-family: inherit;
  padding: 0;
  color: var(--text-muted);
}
.l-card-action:hover { background: var(--panel-2); color: var(--text); }
.l-card-action.del:hover { background: #fee2e2; border-color: #fecaca; color: var(--danger); }

.cards-empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
  font-style: italic;
  border: 1px dashed var(--border-dark);
  border-radius: 8px;
  margin-bottom: 18px;
}

.add-item-row {
  display: flex;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.add-item-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
}
.add-item-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ============================================================
   TEXTBAUSTEINE EDITOR
   ============================================================ */
.tb-editor-section {
  padding: 4px 0;
}
.tb-section-title-row {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--panel-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.tb-section-title-row .roman-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 0 8px;
  background: var(--accent);
  color: white;
  border-radius: 4px;
  font-weight: 700;
  font-size: 12px;
}
.tb-section-title-row .title-input {
  flex: 1;
}
.tb-section-title-row label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.tb-section-title-row input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
}
.tb-section-title-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* Points */
.tb-points-list { display: flex; flex-direction: column; gap: 10px; }

.tb-point {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: white;
}
.tb-point-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.tb-point-num {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 13px;
  min-width: 24px;
}
.tb-point-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.tb-action-btn {
  background: white;
  border: 1px solid var(--border);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-family: inherit;
  padding: 0;
  color: var(--text-muted);
  transition: background 0.12s;
}
.tb-action-btn:hover { background: var(--panel-2); color: var(--text); }
.tb-action-btn.add-sub { width: auto; padding: 0 8px; font-size: 11px; gap: 4px; }
.tb-action-btn.del:hover { background: #fee2e2; border-color: #fecaca; color: var(--danger); }
.tb-action-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.tb-point textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: white;
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}
.tb-point textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* Subpoints */
.tb-subpoints {
  margin-top: 10px;
  margin-left: 32px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}
.tb-substyle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.tb-substyle-row select {
  padding: 4px 8px;
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  text-transform: none;
  font-weight: 400;
  letter-spacing: normal;
  background: white;
}
.tb-subpoint {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  align-items: flex-start;
}
.tb-subpoint-marker {
  min-width: 22px;
  padding: 7px 0;
  text-align: center;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
}
.tb-subpoint textarea {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: white;
  resize: vertical;
  min-height: 40px;
  line-height: 1.5;
}
.tb-subpoint-actions {
  display: flex;
  gap: 4px;
  align-items: flex-start;
  padding-top: 4px;
}
.tb-subpoint-flags {
  display: flex;
  gap: 8px;
  margin-left: 28px;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.tb-subpoint-flags label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.tb-add-point-row {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}

/* Meta tab (Allgemein) */
.tb-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.tb-meta-grid .field-wide { grid-column: 1 / -1; }
.tb-meta-grid label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.tb-meta-grid input, .tb-meta-grid textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: white;
  resize: vertical;
}
.tb-meta-grid input:focus, .tb-meta-grid textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.tb-meta-section-title {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 10px 0 -6px 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.tb-meta-section-title:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }

.tb-help-note {
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  margin-bottom: 14px;
}
.tb-help-note code {
  background: white;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  border: 1px solid #bfdbfe;
}

/* ============================================================
   INFO BAR & DRAFTS
   ============================================================ */
.info-bar {
  background: var(--warn-bg);
  color: var(--warn-text);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 12px;
}

.draft-save-row { display: flex; gap: 8px; margin-bottom: 16px; }
.draft-save-row input {
  flex: 1; padding: 8px 12px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 13px; font-family: inherit;
}
.section-label {
  margin: 16px 0 8px 0;
  font-size: 13px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 600;
}
.drafts-list { list-style: none; padding: 0; margin: 0 0 16px 0; }
.drafts-list li {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center;
}
.drafts-list li .meta { font-size: 12px; color: var(--text-muted); }

/* ============================================================
   PRINT
   ============================================================ */
/* margins gelten pro physische Druckseite — dadurch hat jede Folgeseite
   automatisch denselben oberen/unteren Abstand wie die erste */
@page { size: A4; margin: 20mm 22mm 18mm 22mm; }

@media print {
  .app-header, .sidebar, .modal-backdrop { display: none !important; }
  .app { display: block; height: auto; }
  .main { padding: 0; background: white; overflow: visible; }
  .document-stack { gap: 0; }
  .a4-page {
    box-shadow: none;
    margin: 0;
    padding: 0;          /* margins kommen jetzt aus @page */
    width: auto;
    min-height: 0;
  }
}