/* ══════════════════════════════════════════════════════════════════
   CoBa BIM-Generator — Design System
   Commerzbank-inspiriert: Schwarz / Weiß / #FFCC00
   Typografie: Atkinson Hyperlegible + Bricolage Grotesque
   ══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,500;12..96,600;12..96,700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Tokens ─────────────────────────────────────────────────────── */
:root {
  --yellow:     #FFCC00;
  --yellow-soft:#FFF4BD;
  --yellow-dim: #E8B800;
  --ink:        #0A0A0A;
  --ink2:       #1E1E1E;
  --ink3:       #525252;
  --ink4:       #8A8A8A;
  --paper:      #FFFFFF;
  --paper2:     #F8F8F6;
  --paper3:     #F0EFEB;
  --line:       #E4E2DC;
  --line2:      #CFCDC4;
  --danger:     #B23A2C;
  --danger-bg:  #FEF0EE;
  --good:       #2F7A3E;
  --good-bg:    #EEF7F0;
  --blue:       #1A4D8A;
  --orphan:     #FFE0DC;
  --font-body:  'Atkinson Hyperlegible', 'Arial', sans-serif;
  --font-display:'Bricolage Grotesque', 'Trebuchet MS', sans-serif;
  --font-mono:  'JetBrains Mono', 'Consolas', monospace;
  --radius:     0px;  /* Commerzbank: keine Rundungen */
  --shadow:     0 2px 8px rgba(0,0,0,0.08), 0 0 1px rgba(0,0,0,0.06);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.12), 0 0 1px rgba(0,0,0,0.08);
  --topbar-h:   56px;
  --sidebar-w:  260px;
  --transition: 0.15s ease;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  margin: 0; padding: 0;
  background: var(--paper2);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
}
h1,h2,h3,h4,h5,h6 { font-family: var(--font-display); font-weight: 600; margin: 0; line-height: 1.25; }
p { margin: 0 0 0.75em; }
p:last-child { margin-bottom: 0; }
a { color: var(--ink); }
input, textarea, select, button { font-family: inherit; font-size: inherit; }
textarea { resize: vertical; }
table { border-collapse: collapse; width: 100%; }
code, pre { font-family: var(--font-mono); }
img { max-width: 100%; display: block; }

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--paper3); }
::-webkit-scrollbar-thumb { background: var(--line2); }
::-webkit-scrollbar-thumb:hover { background: var(--ink4); }

/* ══ LAYOUT ═════════════════════════════════════════════════════ */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Topbar ─────────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  flex-shrink: 0;
  border-bottom: 4px solid var(--yellow);
  position: relative;
  z-index: 100;
}
.topbar-logo-area {
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.topbar-monogram {
  width: 34px; height: 34px;
  background: var(--yellow);
  position: relative;
  flex-shrink: 0;
}
.topbar-monogram::after {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 14px 14px 0;
  border-color: transparent var(--ink) transparent transparent;
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--paper);
  line-height: 1.2;
}
.topbar-subtitle {
  font-size: 11px; color: var(--ink4);
  font-weight: 400;
}
.topbar-divider { width: 1px; height: 28px; background: #333; flex-shrink: 0; }
.topbar-version {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--ink4);
}
.topbar-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--good);
  flex-shrink: 0;
}
.topbar-status-label { font-size: 11px; color: var(--ink4); }
.topbar-spacer { flex: 1; }
.topbar-ag-logo {
  height: 32px; max-width: 120px;
  object-fit: contain; object-position: right center;
  opacity: 0.9;
}
.topbar-st-logo {
  height: 26px; max-width: 110px;
  object-fit: contain; object-position: right center;
  filter: none !important;
  opacity: 0.9;
}

/* ── Main layout ────────────────────────────────────────────────── */
#main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar / Tab nav ──────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--ink2);
  color: var(--paper);
  display: flex; flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-section-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink4);
  padding: 20px 18px 6px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 13px; font-weight: 500;
  color: var(--ink4);
  border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  text-decoration: none;
  user-select: none;
}
.sidebar-item:hover { background: rgba(255,255,255,0.05); color: var(--paper); }
.sidebar-item.active {
  background: rgba(255,204,0,0.1);
  color: var(--yellow);
  border-left-color: var(--yellow);
}
.sidebar-item .icon {
  font-size: 16px; width: 20px; text-align: center; flex-shrink: 0;
}
.sidebar-item .badge {
  margin-left: auto;
  background: rgba(255,255,255,0.1);
  color: var(--ink4);
  font-size: 10px; font-weight: 600;
  padding: 1px 6px;
  min-width: 20px; text-align: center;
}
.sidebar-item.active .badge { background: var(--yellow); color: var(--ink); }
.sidebar-bottom {
  margin-top: auto;
  padding: 16px 18px;
  border-top: 1px solid #2a2a2a;
}
.sidebar-st-wordmark {
  font-family: var(--font-display);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink4);
  text-transform: uppercase;
  line-height: 1.4;
}

/* ── Content area ───────────────────────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  background: var(--paper2);
}
.panel {
  display: none;
  padding: 32px;
  max-width: 1400px;
}
.panel.active { display: block; }
.panel-wide { max-width: 100%; padding: 0; }

/* ── Page header ─────────────────────────────────────────────────  */
.page-header {
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 26px; font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.page-header .subtitle {
  font-size: 13px; color: var(--ink3);
}
.page-header-bar {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

/* ══ COMPONENTS ═════════════════════════════════════════════════ */

/* ── Card ───────────────────────────────────────────────────────── */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.card-header h2 { font-size: 14px; font-weight: 600; color: var(--ink); }
.card-header .subtitle { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.card-header-actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 20px; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn-primary {
  background: var(--yellow);
  color: var(--ink);
  border-color: var(--yellow);
}
.btn-primary:hover { background: var(--yellow-dim); border-color: var(--yellow-dim); }
.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line2);
}
.btn-secondary:hover { border-color: var(--ink); background: var(--paper3); }
.btn-ghost {
  background: transparent;
  color: var(--ink3);
  border-color: transparent;
  padding: 7px 10px;
}
.btn-ghost:hover { background: var(--paper3); color: var(--ink); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Toolbar row ─────────────────────────────────────────────────  */
.toolbar-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper3);
}

/* ── Form inputs ─────────────────────────────────────────────────  */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 5px;
}
.input, .select, .textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--line2);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--yellow-soft);
}
.input.mono { font-family: var(--font-mono); font-size: 13px; }
.textarea { min-height: 100px; }
.input-row { display: flex; gap: 12px; }
.input-row .field { flex: 1; }

/* ── Tables ─────────────────────────────────────────────────────── */
.coba-table {
  width: 100%;
  font-size: 13px;
  margin-bottom: 12px;
}
.coba-table thead {
  background: var(--ink);
  color: var(--paper);
}
.coba-table thead th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.coba-table tbody tr { border-bottom: 1px solid var(--line); }
.coba-table tbody tr:last-child { border-bottom: none; }
.coba-table tbody tr:hover { background: var(--paper2); }
.coba-table tbody td {
  padding: 7px 12px;
  vertical-align: middle;
}
.coba-table.striped tbody tr:nth-child(even) { background: var(--paper3); }

/* ── MEM table (special) ─────────────────────────────────────────  */
#mem-scroll-container {
  overflow: auto;
  max-height: calc(100vh - 180px);
}
.mem-table {
  font-size: 12px;
  white-space: nowrap;
}
.mem-table thead { position: sticky; top: 0; z-index: 10; }
.mem-table thead tr:first-child th {
  background: var(--ink);
  color: var(--paper);
  padding: 6px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.mem-table thead tr:first-child th.awf-header {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  height: 120px;
  min-width: 36px;
  max-width: 36px;
  vertical-align: bottom;
  padding: 8px 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
  border-left: 1px solid #333;
}
.mem-table thead tr:first-child th.awf-header.active-col {
  background: var(--ink2);
  color: var(--yellow);
}
.mem-table tbody tr { border-bottom: 1px solid var(--line); }
.mem-table tbody tr.gruppe-header td {
  background: var(--ink);
  color: var(--yellow);
  font-family: var(--font-display);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 6px 10px;
}
.mem-table tbody tr:hover { background: var(--paper2); }
.mem-table tbody td { padding: 5px 8px; vertical-align: middle; }
.mem-table tbody td.bauteil-cell { color: var(--ink3); font-size: 11px; }
.mem-table tbody td.attr-cell { font-weight: 500; }
.mem-table tbody td.awf-cell {
  text-align: center;
  cursor: pointer;
  border-left: 1px solid var(--line);
  min-width: 36px;
}
.mem-table tbody td.awf-cell:hover { background: var(--yellow-soft); }
.mem-cell-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: var(--ink);
  color: var(--yellow);
  font-size: 13px; font-weight: 700;
}
.mem-table tr.orphan { opacity: 0.5; background: var(--orphan) !important; }
.mem-table tr.orphan td.attr-cell { text-decoration: line-through; }

/* Sticky first columns in MEM */
.mem-table thead th.sticky-col,
.mem-table tbody td.sticky-col {
  position: sticky;
  background: inherit;
  z-index: 5;
}
.mem-table thead th.sticky-col { background: var(--ink); }
.mem-table thead th.col-nr   { left: 0; min-width: 36px; }
.mem-table thead th.col-bt   { left: 36px; min-width: 120px; }
.mem-table thead th.col-attr { left: 156px; min-width: 220px; }
.mem-table tbody td.col-nr   { left: 0; min-width: 36px; }
.mem-table tbody td.col-bt   { left: 36px; min-width: 120px; }
.mem-table tbody td.col-attr { left: 156px; min-width: 220px; font-weight: 500; }

/* ── Toast ───────────────────────────────────────────────────────  */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  font-size: 13px;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--yellow);
  animation: toast-in 0.2s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--good); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Toggle switch ───────────────────────────────────────────────  */
.toggle {
  position: relative; display: inline-flex;
  width: 40px; height: 22px; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--line2);
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: white;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--yellow); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Priority badges ─────────────────────────────────────────────  */
.badge-obligatorisch { background: var(--yellow); color: var(--ink); font-size: 10px; font-weight: 700; padding: 2px 7px; }
.badge-empfohlen { background: var(--paper3); color: var(--ink3); font-size: 10px; font-weight: 600; padding: 2px 7px; border: 1px solid var(--line2); }
.badge-optional { background: transparent; color: var(--ink4); font-size: 10px; padding: 2px 7px; border: 1px solid var(--line); }

/* ── AWF card ────────────────────────────────────────────────────  */
.awf-card {
  border: 1px solid var(--line);
  margin-bottom: 12px;
  background: var(--paper);
}
.awf-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  background: var(--paper3);
}
.awf-card-header:hover { background: var(--yellow-soft); }
.awf-card-nr {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  color: var(--ink3);
  min-width: 60px;
}
.awf-card-title { font-weight: 600; font-size: 14px; flex: 1; }
.awf-card-body { padding: 16px; }
.awf-verantwortung-box {
  background: var(--yellow-soft);
  border-left: 3px solid var(--yellow);
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 12px;
}
.awf-verantwortung-box strong { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink3); margin-bottom: 2px; }

/* ── Chapter editor ──────────────────────────────────────────────  */
.chapter-list { }
.chapter-item {
  background: var(--paper);
  border: 1px solid var(--line);
  margin-bottom: 8px;
}
.chapter-item-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
}
.chapter-item-header:hover { background: var(--paper2); }
.chapter-item.open .chapter-item-header { border-bottom-color: var(--line); }
.chapter-drag-handle { cursor: grab; color: var(--ink4); font-size: 16px; }
.chapter-nr { font-family: var(--font-mono); font-size: 12px; color: var(--ink3); min-width: 28px; }
.chapter-title-display { font-weight: 600; font-size: 14px; flex: 1; }
.chapter-item-body { padding: 16px; }

/* ── Rich text display (chapter content rendered) ────────────────  */
.rich-content { font-size: 14px; line-height: 1.7; }
.rich-content h1,h2,h3 { margin: 1em 0 0.5em; }
.rich-content ul, .rich-content ol { margin: 0.5em 0 0.5em 1.5em; }
.rich-content li { margin-bottom: 4px; }
.rich-content table { margin: 12px 0; }
.rich-content strong { font-weight: 700; }
.rich-content em { font-style: italic; }
.rich-content code { font-family: var(--font-mono); font-size: 0.9em; background: var(--paper3); padding: 1px 5px; }
.rich-content .coba-table th { background: var(--ink); color: var(--paper); padding: 8px 12px; font-size: 12px; }
.rich-content .coba-table td { padding: 7px 12px; border-bottom: 1px solid var(--line); }

/* ── Inline content editor ────────────────────────────────────────  */
.content-editor-toolbar {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--paper3);
}
.content-editor-toolbar button {
  padding: 3px 8px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line2); background: var(--paper); cursor: pointer;
  color: var(--ink);
}
.content-editor-toolbar button:hover { background: var(--yellow-soft); }
.content-editor-area {
  min-height: 120px;
  padding: 12px;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
  outline: none;
  border: none;
}
.content-editor-area:focus { background: var(--paper2); }
[contenteditable] [data-color] { }

/* ── Image block ─────────────────────────────────────────────────  */
.img-block {
  margin: 16px 0;
  border: 1px solid var(--line);
}
.img-block figcaption {
  padding: 6px 12px;
  font-size: 12px; color: var(--ink3);
  background: var(--paper3);
  border-top: 1px solid var(--line);
}
.img-block figcaption strong { color: var(--ink); }
.img-drop-zone {
  border: 2px dashed var(--line2);
  padding: 32px;
  text-align: center;
  color: var(--ink4);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}
.img-drop-zone:hover, .img-drop-zone.drag-over {
  border-color: var(--yellow);
  background: var(--yellow-soft);
  color: var(--ink);
}

/* ── Deckblatt ───────────────────────────────────────────────────  */
#deckblatt {
  position: relative;
  background: var(--ink);
  min-height: 100vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.deckblatt-img {
  position: absolute; inset: 0;
  object-fit: cover; object-position: center;
  width: 100%; height: 100%;
  opacity: 0.35;
  mix-blend-mode: luminosity;
}
.deckblatt-overlay {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  height: 100%;
}
.deckblatt-band {
  height: 8px; background: var(--yellow); flex-shrink: 0;
}
.deckblatt-content {
  flex: 1;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 60px 72px;
}
.deckblatt-kuerzel {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 700; letter-spacing: 0.15em;
  color: var(--yellow); text-transform: uppercase;
  margin-bottom: 16px;
}
.deckblatt-title {
  font-family: var(--font-display);
  font-size: 48px; font-weight: 700; line-height: 1.1;
  color: white; margin-bottom: 8px;
}
.deckblatt-subtitle {
  font-size: 20px; font-weight: 400; color: rgba(255,255,255,0.6);
  margin-bottom: 40px;
}
.deckblatt-meta {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 24px;
}
.deckblatt-meta-item label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--yellow); display: block; margin-bottom: 3px;
}
.deckblatt-meta-item span { font-size: 14px; color: white; }
.deckblatt-logos {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 72px;
  border-top: 4px solid var(--yellow);
  background: rgba(0,0,0,0.4);
}

/* ── Diagram / Organigramm canvas ────────────────────────────────  */
#org-canvas { border: 1px solid var(--line); background: var(--paper); display: block; }
.org-node {
  font-family: var(--font-display);
  font-size: 11px;
}

/* ── Kommunikationsplan Gantt-style ─────────────────────────────  */
.komm-table { font-size: 12px; }
.komm-color-swatch {
  width: 14px; height: 14px; display: inline-block; flex-shrink: 0;
  border: 1px solid var(--line2);
}

/* ── Clash matrix ────────────────────────────────────────────────  */
.clash-matrix-wrap { overflow: auto; }
.clash-table th, .clash-table td {
  padding: 6px 8px; border: 1px solid var(--line);
  font-size: 11px; text-align: center;
}
.clash-table thead th { background: var(--ink); color: var(--paper); }
.clash-table td.clash-cell {
  cursor: pointer; min-width: 44px;
  background: var(--yellow-soft);
}
.clash-table td.clash-cell:hover { background: var(--yellow); }
.clash-table td.diag { background: var(--paper3); cursor: default; }
.clash-table td.lower { background: var(--paper2); cursor: default; }

/* ── Datei-Mapping table ─────────────────────────────────────────  */
.mapping-table td, .mapping-table th { padding: 6px 10px; font-size: 12px; border: 1px solid var(--line); }
.mapping-table thead th { background: var(--ink); color: var(--paper); }
.mapping-preview { font-family: var(--font-mono); font-size: 11px; background: var(--paper3); padding: 8px 12px; color: var(--ink3); }

/* ── Signaturtabelle ─────────────────────────────────────────────  */
.sig-table td, .sig-table th { padding: 10px 14px; border: 1px solid var(--line); font-size: 13px; }
.sig-table thead th { background: var(--ink); color: var(--paper); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.sig-field { height: 48px; border: 1px dashed var(--line2); margin-top: 6px; }
.sig-signed { background: var(--good-bg); border-color: var(--good); }

/* ── Revision list ───────────────────────────────────────────────  */
.revision-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.revision-row:last-child { border-bottom: none; }
.revision-version { font-family: var(--font-mono); font-size: 12px; min-width: 40px; }
.revision-status { font-size: 11px; padding: 2px 8px; font-weight: 600; }
.revision-status.entwurf { background: var(--paper3); color: var(--ink3); }
.revision-status.freigegeben { background: var(--good-bg); color: var(--good); }

/* ── LOI/LOG doc panel ───────────────────────────────────────────  */
.loi-gruppe { margin-bottom: 32px; }
.loi-gruppe-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; padding: 8px 0; border-bottom: 3px solid var(--yellow); margin-bottom: 16px; }
.lod-badge {
  display: inline-block;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  padding: 2px 8px;
  background: var(--ink); color: var(--yellow);
}

/* ── AI assistant sidebar ────────────────────────────────────────  */
#ai-sidebar {
  width: 340px; flex-shrink: 0;
  background: var(--paper);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  transition: width var(--transition);
}
#ai-sidebar.collapsed { width: 0; overflow: hidden; }
.ai-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
  background: var(--paper3);
}
.ai-header .ai-dot {
  width: 8px; height: 8px; background: var(--yellow);
  flex-shrink: 0;
}
.ai-messages {
  flex: 1; overflow-y: auto;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.ai-msg { font-size: 13px; line-height: 1.5; padding: 8px 10px; }
.ai-msg.user { background: var(--paper3); align-self: flex-end; max-width: 90%; }
.ai-msg.assistant { background: var(--yellow-soft); max-width: 90%; }
.ai-msg.system { color: var(--ink4); font-size: 11px; text-align: center; }
.ai-input-area {
  border-top: 1px solid var(--line);
  padding: 10px;
  display: flex; gap: 6px;
}
.ai-input-area textarea {
  flex: 1; min-height: 60px; max-height: 120px;
  font-size: 13px;
}
.ai-loading { text-align: center; color: var(--ink4); font-size: 12px; padding: 8px; }

/* ── Versionen panel ─────────────────────────────────────────────  */
.version-card {
  border: 1px solid var(--line);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px;
  background: var(--paper);
}
.version-card:hover { background: var(--paper2); }

/* ── Preview modal ───────────────────────────────────────────────  */
#preview-modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  align-items: center; justify-content: center;
}
#preview-modal.open { display: flex; }
.preview-modal-inner {
  background: white;
  width: 900px; max-width: 96vw;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.preview-modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  background: var(--ink); color: var(--paper);
}
.preview-modal-body { overflow-y: auto; padding: 40px 60px; font-size: 14px; line-height: 1.7; }
.preview-modal-body .coba-table th { background: var(--ink); color: var(--paper); padding: 8px 12px; }
.preview-modal-body .coba-table td { padding: 7px 12px; border-bottom: 1px solid var(--line); }

/* ── Drag & drop ──────────────────────────────────────────────────  */
.dragging { opacity: 0.4; }
.drag-over { outline: 2px solid var(--yellow); outline-offset: -2px; }

/* ── Utility ─────────────────────────────────────────────────────  */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--ink3); }
.text-danger { color: var(--danger); }
.text-good { color: var(--good); }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

@media (max-width: 900px) {
  #sidebar { width: 200px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
}
