/* ====================================================
   Design Tokens
   ==================================================== */
:root {
  /* Brand */
  --lan-blue: #004e9f;
  --lan-blue-dark: #003773;
  --lan-accent: #e63946;

  /* Palette */
  --bg: #ffffff;
  --bg-muted: #f4f5f7;
  --bg-hover: #eef0f3;
  --border: #e1e4e8;
  --text: #1c1f23;
  --text-muted: #5b6472;
  --success: #2e8b3d;
  --warn: #d48806;
  --danger: #c0392b;
  --info: #0969da;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 28px;
  --sp-8: 32px;

  /* Radius */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
}

/* ====================================================
   Reset + Base
   ==================================================== */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--lan-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ====================================================
   Buttons
   ==================================================== */
button, .btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid var(--border);
  background: #fff; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; font-family: inherit;
  transition: background .12s, border-color .12s;
}
button:hover, .btn:hover { background: var(--bg-hover); }
button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }

/* Primary — filled LAN blue */
button.primary, .btn.primary {
  background: var(--lan-blue); color: #fff;
  border-color: var(--lan-blue);
}
button.primary:hover, .btn.primary:hover {
  background: var(--lan-blue-dark); border-color: var(--lan-blue-dark);
}
button.primary:disabled, .btn.primary:disabled {
  background: var(--lan-blue); border-color: var(--lan-blue);
}

/* Secondary — outlined */
button.secondary, .btn.secondary {
  background: #fff; color: var(--text);
  border-color: var(--border);
}
button.secondary:hover, .btn.secondary:hover { background: var(--bg-muted); }

/* Ghost — text only */
button.ghost, .btn.ghost {
  background: transparent; border-color: transparent; color: var(--text-muted);
}
button.ghost:hover, .btn.ghost:hover { background: var(--bg-muted); color: var(--text); }

/* Danger */
button.danger, .btn.danger {
  background: #fff; color: var(--danger); border-color: var(--danger);
}
button.danger:hover, .btn.danger:hover { background: #fff3f3; }

/* ====================================================
   Forms
   ==================================================== */
input:not([type=checkbox]):not([type=radio]):not([type=file]),
textarea, select {
  width: 100%; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font: inherit; background: #fff;
}
input[type=checkbox], input[type=radio] {
  width: auto; margin: 0; padding: 0; border: 0;
  accent-color: var(--lan-blue);
  flex-shrink: 0;
}
input[type=file] { border: 1px dashed var(--border); padding: 6px; background: #fff; border-radius: var(--radius-sm); }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--lan-blue); outline-offset: -1px;
}
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
/* Inline "row" labels (z.B. Checkbox + Text) nutzen .flex — übersteuert die muted Form-Label-Regel */
label.flex {
  display: flex; align-items: center; gap: 8px;
  color: var(--text); font-size: 14px;
  margin-bottom: 0; padding: 6px 0;
  cursor: pointer;
}
label.flex:hover { background: var(--bg-muted); border-radius: 4px; padding-left: 4px; padding-right: 4px; }

/* ====================================================
   Card Utility
   ==================================================== */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--sp-6);
}

/* ====================================================
   Chips
   ==================================================== */
.chip {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 10px;
  font-size: 11px; font-weight: 500;
  background: var(--bg-muted); color: var(--text-muted);
}
.chip.ok      { background: #e6f4ea; color: var(--success); }
.chip.warn, .chip.draft { background: #fff4d6; color: var(--warn); }
.chip.danger  { background: #fde8e8; color: var(--danger); }
.chip.info    { background: #dbeafe; color: var(--info); }

/* ====================================================
   Header
   ==================================================== */
.header {
  border-bottom: 1px solid var(--border);
  background: #fff;
  position: sticky; top: 0; z-index: 30;
}
.header-inner {
  display: flex; align-items: center;
  max-width: none;
  padding: 0 20px;
  height: 64px;
  gap: var(--sp-4);
  justify-content: space-between;
}
.header .brand {
  display: flex; align-items: center; gap: var(--sp-2);
  flex-shrink: 0; text-decoration: none; color: inherit;
}
.header .brand img { height: 32px; display: block; }

/* Nav tabs */
.header nav, .main-nav {
  display: flex; align-items: stretch; height: 64px; gap: 2px;
  flex-shrink: 0;
}
.header nav .tab, .main-nav .tab {
  display: inline-flex; align-items: center;
  padding: 0 var(--sp-3);
  color: var(--text-muted);
  font-size: 14px;
  border-bottom: 2px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.header nav .tab:hover, .main-nav .tab:hover { color: var(--text); text-decoration: none; }
.header nav .tab.active, .main-nav .tab.active { color: var(--lan-blue); border-bottom-color: var(--lan-blue); font-weight: 600; }

/* User menu */
.header .spacer { flex: 1; }
.header-inner .user-menu-wrap { margin-left: 0; }
.user-menu-wrap { position: relative; }
.user-menu-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: #fff;
  cursor: pointer; font-size: 13px; color: var(--text);
  font-family: inherit;
}
.user-menu-btn:hover { background: var(--bg-muted); }
.user-menu-btn .chevron {
  width: 10px; height: 10px; margin-left: 2px;
  opacity: .6; transition: transform .15s;
}
.user-menu-btn.open .chevron { transform: rotate(180deg); }

.user-menu-panel {
  display: none;
  position: absolute; top: calc(100% + 4px); right: 0;
  min-width: 160px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 100;
  padding: var(--sp-1) 0;
}
.user-menu-panel.open { display: block; }
.user-menu-panel a,
.user-menu-panel button {
  display: block; width: 100%;
  padding: 7px 14px;
  text-align: left; font-size: 13px;
  border: none; background: transparent;
  color: var(--text); cursor: pointer; border-radius: 0;
}
.user-menu-panel a:hover,
.user-menu-panel button:hover { background: var(--bg-muted); text-decoration: none; }
.user-menu-panel .menu-divider {
  height: 1px; background: var(--border);
  margin: var(--sp-1) 0;
}
.user-menu-panel .menu-item-muted { color: var(--text-muted); }

/* ====================================================
   Page
   ==================================================== */
.page { padding: var(--sp-5); max-width: 1400px; margin: 0 auto; }

/* ====================================================
   Login
   ==================================================== */
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 90vh; }
.login-card {
  width: 340px; padding: 28px;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-card img { height: 40px; margin-bottom: 16px; }
.login-card h2 { margin: 0 0 16px; font-size: 18px; }
.login-card .err { color: var(--danger); margin-top: 8px; font-size: 13px; min-height: 18px; }
.login-card .row { margin-bottom: 12px; }

/* ====================================================
   Customer List
   ==================================================== */
.customer-list { width: 100%; border-collapse: collapse; }
.customer-list th, .customer-list td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.customer-list th {
  font-size: 12px; color: var(--text-muted);
  font-weight: 500; background: var(--bg-muted);
  position: sticky; top: 52px;
}
.customer-list tbody tr { cursor: pointer; }
.customer-list tbody tr:hover { background: var(--bg-muted); }
.customer-list tbody tr:active { background: var(--bg-hover); }

/* Completion bar */
.completion { display: inline-flex; align-items: center; gap: var(--sp-2); }
.completion .bar {
  width: 64px; height: 5px;
  background: var(--bg-muted); border-radius: 3px; overflow: hidden;
}
.completion .fill { height: 100%; background: var(--lan-blue); }

.search-row { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }
.search-row input { max-width: 320px; }

/* ====================================================
   Customer Detail — 3-column layout
   ==================================================== */
.detail-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 300px;
  gap: var(--sp-5);
  align-items: start;
  min-height: 70vh;
}
@media (max-width: 1200px) {
  .detail-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .right-sidebar { grid-column: 1 / -1; max-width: 100%; }
}
@media (max-width: 899px) {
  .detail-layout { grid-template-columns: 1fr; gap: 16px; }
  .detail-sidebar {
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: var(--sp-3);
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
  }
  .detail-sidebar h3 {
    display: inline-block;
    margin: 0 8px 0 0;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .detail-sidebar .module-item {
    display: inline-flex;
    margin-right: 4px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .detail-sidebar > button { flex-shrink: 0; margin-top: 0 !important; width: auto !important; }
  .right-sidebar { position: static; border-left: none; padding-left: 0;
                   border-top: 1px solid var(--border); padding-top: var(--sp-4); }
}

/* Left sidebar */
.detail-sidebar {
  border-right: 1px solid var(--border);
  padding-right: var(--sp-4);
  position: sticky; top: 70px;
  align-self: flex-start;
}
.detail-sidebar h3 {
  font-size: 11px; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: .05em;
  margin: var(--sp-4) 0 var(--sp-2);
}
.module-item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 7px 10px; border-radius: var(--radius-sm);
  cursor: pointer; border: 1px solid transparent;
  font-size: 13px;
}
.module-item:hover { background: var(--bg-muted); }
.module-item.active { background: var(--bg-muted); border-color: var(--border); }
.module-item .icon { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.module-item .label { flex: 1; }
.module-item .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border); flex-shrink: 0;
}
.module-item .dot.draft { background: var(--warn); }
.module-item .dot.complete { background: var(--success); }

/* Middle panel wrapper + main tab bar */
.panel-wrap { display: flex; flex-direction: column; min-height: 300px; }
.main-tab-bar {
  display: flex; gap: 0; border-bottom: 2px solid var(--border);
  margin-bottom: var(--sp-4);
}
.main-tab-bar .tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: var(--sp-2) var(--sp-4); font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.main-tab-bar .tab:hover { color: var(--text); }
.main-tab-bar .tab.active { color: var(--lan-blue); border-bottom-color: var(--lan-blue); }

/* Middle panel */
.module-panel { padding: 0; min-height: 300px; }
.module-panel.card { padding: var(--sp-6); }

/* ====================================================
   Files Tab
   ==================================================== */
.files-tab { display: flex; flex-direction: column; gap: var(--sp-3); }
.files-topbar { display: flex; gap: var(--sp-2); align-items: center; }
.files-topbar input { flex: 1; }
.files-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.files-chips .chip {
  cursor: pointer; border: 1px solid var(--border);
  height: 26px; padding: 0 10px; font-size: 11px; font-weight: 500;
  display: inline-flex; align-items: center; border-radius: 10px;
  background: var(--bg-muted); color: var(--text-muted);
  transition: background .1s, color .1s;
}
.files-chips .chip:hover { background: var(--bg-hover); color: var(--text); }
.files-chips .chip.active { background: var(--lan-blue); color: #fff; border-color: var(--lan-blue); }
.files-list { display: flex; flex-direction: column; gap: 2px; }

/* Files tab: consistent grid rows */
.files-tab .file-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 140px 80px;
  gap: 12px;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  border-left: none; border-right: none; border-top: none;
}
.files-tab .file-row:hover { background: var(--bg-muted); }
.files-tab .file-row .file-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }

/* Non-files-tab file-row (attachments panel) */
.file-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm);
  border: 1px solid transparent; transition: background .1s;
}
.file-row:hover { background: var(--bg-muted); }
.file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-name { font-size: 13px; color: var(--lan-blue); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-name:hover { text-decoration: underline; }
.file-path { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; font-size: 12px; }
.cat-select { font-size: 11px; padding: 2px 4px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-muted); width: 100%; }

/* ====================================================
   Empty State
   ==================================================== */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
  padding: var(--sp-8) var(--sp-6);
  max-width: 400px; margin: 0 auto;
}
.empty-state .empty-icon {
  width: 48px; height: 48px;
  color: var(--border); margin-bottom: var(--sp-4);
}
.empty-state h3 { font-size: 18px; margin: 0 0 var(--sp-2); }
.empty-state p { color: var(--text-muted); margin: 0 0 var(--sp-5); font-size: 13px; }

/* ====================================================
   Customer Header
   ==================================================== */
.customer-header {
  margin-bottom: var(--sp-4);
  padding: 16px 20px;
}
.customer-header .ch-top {
  display: flex; align-items: flex-start;
  gap: var(--sp-4); justify-content: space-between;
}
.customer-header .ch-name-block { flex: 1; min-width: 0; }
.customer-header h1 {
  font-size: 22px; margin: 0 0 2px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.customer-header .ch-meta {
  font-size: 12px; color: var(--text-muted);
}
.customer-header .ch-actions {
  display: flex; align-items: center; gap: var(--sp-2);
  flex-shrink: 0;
}
.customer-header .ch-back-btn {
  font-size: 13px; color: var(--text-muted);
}
.stats-chips {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  margin-top: 10px;
}

/* ====================================================
   SelectLine Row (Block D)
   ==================================================== */
.sl-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2);
  margin-top: var(--sp-3); padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.sl-label { color: var(--text-muted); }
.sl-info  { display: flex; align-items: center; gap: var(--sp-1); }
.sl-name  { font-weight: 500; }
.sl-city  { font-size: 12px; }
.sl-nr    { font-family: monospace; font-size: 11px; }
.sl-unlink-btn {
  margin-left: auto; font-size: 16px; line-height: 1;
  padding: 0 6px; color: var(--text-muted);
}
.chip-ok      { background: #e6f4ea; color: var(--success); }
.chip-neutral { background: var(--bg-muted); color: var(--text-muted); }
.chip-error   { background: #fde8e8; color: var(--danger); }

/* SelectLine search results in modal */
.sl-search-results {
  max-height: 320px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.sl-result-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px var(--sp-3); cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.sl-result-row:last-child { border-bottom: none; }
.sl-result-row:hover { background: var(--bg-muted); }

/* ====================================================
   Right Sidebar
   ==================================================== */
.right-sidebar {
  position: sticky; top: 70px;
  align-self: flex-start;
  border-left: 1px solid var(--border);
  padding-left: var(--sp-4);
}
.right-sidebar .tab-bar {
  display: flex; border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-3);
}
.right-sidebar .tab-bar button {
  flex: 1; padding: 7px var(--sp-2);
  font-size: 12px; color: var(--text-muted);
  background: transparent; border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; cursor: pointer;
  border-radius: 0; font-family: inherit;
}
.right-sidebar .tab-bar button:hover { color: var(--text); background: transparent; }
.right-sidebar .tab-bar button.active {
  color: var(--lan-blue); border-bottom-color: var(--lan-blue);
  font-weight: 600;
}

.right-sidebar .rs-panel { display: none; }
.right-sidebar .rs-panel.active { display: block; }

/* Notes in right sidebar */
.rs-notes-section { margin-bottom: var(--sp-4); }
.rs-notes-section h4 {
  font-size: 11px; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: .05em;
  margin: 0 0 var(--sp-2);
}

/* Activity timeline */
.activity-item {
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.activity-item .act-main { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-item .when { color: var(--text-muted); font-size: 11px; margin-top: 1px; }

/* Attachments panel */
.rs-attachment-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) 0; border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.rs-attachment-row a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* File-type icon badge */
.file-icon { user-select: none; font-family: -apple-system, "Segoe UI", sans-serif; }

/* Attachment file-row: icon + column-meta + delete (overrides files-tab .file-meta) */
.file-row .file-meta.col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; flex-shrink: 1; }
.file-row .file-meta.col .filename { font-weight: 500; font-size: 13px; color: var(--lan-blue);
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row .file-meta.col .filename:hover { text-decoration: underline; }
.file-row .file-meta.col .sub { font-size: 11px; color: var(--text-muted); }
.file-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 4px;
              border: 1px solid var(--border); flex-shrink: 0; }

/* ====================================================
   Notes + Attachments (module panel, keep compat)
   ==================================================== */
.notes-panel { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 12px; }
.note { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.note .meta { font-size: 11px; color: var(--text-muted); }

/* ====================================================
   Fields
   ==================================================== */
.field-row { margin-bottom: 14px; }
.field-row .help { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.field-row .required::after { content: " *"; color: var(--danger); }
.table-field table { border-collapse: collapse; width: 100%; }
.table-field th, .table-field td { border: 1px solid var(--border); padding: 4px 8px; }
.table-field td input { border: none; padding: 4px; }
.table-field th { background: var(--bg-muted); font-weight: 500; font-size: 12px; }

/* ====================================================
   Utilities
   ==================================================== */
.muted { color: var(--text-muted); }
.flex { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }

/* ====================================================
   Toast
   ==================================================== */
.toast-wrap {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 200; display: flex; flex-direction: column; gap: 6px;
}
.toast {
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--text); color: #fff;
  box-shadow: var(--shadow-md); font-size: 13px;
}
.toast.err { background: var(--danger); }

/* ====================================================
   Modal
   ==================================================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 100; display: flex; align-items: center; justify-content: center;
}
/* Scrollbare Modals mit sticky Footer */
.modal {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  min-width: 400px;
  max-width: 80vw;
  overflow: hidden;
  padding: 0;
}
.modal > h2,
.modal > h3 {
  margin: 0;
  padding: 20px 24px 8px;
  flex-shrink: 0;
  font-size: 18px;
}
.modal-body {
  padding: 0 24px 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.modal-footer {
  flex-shrink: 0;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: #fff;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal-footer.left-split {
  justify-content: space-between;
}
/* Preview-Modal übersteuert mit eigenem Layout */

/* ====================================================
   Global Search
   ==================================================== */
.search-global {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 520px;
  margin: 0 24px;
}
.search-global input[type="search"] {
  width: 100%;
  padding: 5px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
}
.search-global input[type="search"]:focus {
  background: #fff;
  outline: 2px solid var(--lan-blue);
  outline-offset: -1px;
}
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 60vh;
  overflow-y: auto;
  z-index: 200;
}
.search-group {
  border-bottom: 1px solid var(--border);
}
.search-group:last-child { border-bottom: none; }
.search-group-header {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--lan-blue);
  cursor: pointer;
  background: var(--bg-muted);
}
.search-group-header:hover { background: var(--bg-hover); }
.search-hit {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.search-hit:hover { background: var(--bg-hover); }
.search-hit .chip.small {
  font-size: 10px;
  padding: 1px 6px;
  flex-shrink: 0;
  margin-top: 2px;
}
.search-hit .small { font-size: 12px; }
.search-hit mark {
  background: #fff3cd;
  border-radius: 2px;
  padding: 0 2px;
  font-style: normal;
}
.search-empty {
  padding: 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* ====================================================
   Responsive — Table fields (horizontal scroll)
   ==================================================== */
.table-field { overflow-x: auto; }
.table-field table { min-width: 100%; }
.table-field td input, .table-field td select { min-width: 100px; }
@media (max-width: 600px) {
  .table-field table { min-width: 640px; }
  .table-field td input, .table-field td select { min-width: 90px; font-size: 13px; }
}

/* ====================================================
   Responsive — Admin table wrap
   ==================================================== */
.admin-table-wrap { overflow-x: auto; max-width: 100%; }
.admin-table-wrap table { min-width: 600px; }

/* ====================================================
   Responsive — Header (≤720px: two-row wrap)
   ==================================================== */
@media (max-width: 720px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
    justify-content: flex-start;
  }
  .header .brand { flex-shrink: 0; }
  .header-inner .user-menu-wrap { margin-left: auto; }
  .main-nav {
    order: 3;
    flex-basis: 100%;
    height: auto;
    justify-content: flex-start;
  }
  .search-global {
    order: 4;
    flex-basis: 100%;
    max-width: none;
    margin: 0;
  }
}

/* ====================================================
   Responsive — Customer list (≤899px: hide cols;
                               ≤600px: card stack)
   ==================================================== */
@media (max-width: 899px) and (min-width: 601px) {
  .customer-list th:nth-child(2),
  .customer-list td:nth-child(2),
  .customer-list th:nth-child(5),
  .customer-list td:nth-child(5) {
    display: none;
  }
}
@media (max-width: 600px) {
  .customer-list thead { display: none; }
  .customer-list tbody,
  .customer-list tr,
  .customer-list td { display: block; width: 100%; }
  .customer-list tr {
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
  }
  .customer-list td {
    padding: 2px 0;
    border: 0;
  }
  .customer-list td[data-label]::before {
    content: attr(data-label) ": ";
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 6px;
    text-transform: uppercase;
  }
  .customer-list td[data-label="Name"]::before,
  .customer-list td[data-label="Aktionen"]::before { content: ""; }
  .customer-list td[data-label="Name"] { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
}

/* ====================================================
   Responsive — Customer header action buttons (≤720px)
   ==================================================== */
@media (max-width: 720px) {
  .customer-header { padding: 12px !important; }
  .customer-header h1 { font-size: 18px !important; }
  .customer-header .ch-actions { flex-wrap: wrap; gap: 6px; }
  .customer-header .btn { font-size: 12px; padding: 6px 10px; }
}

/* ====================================================
   Responsive — Files tab (≤700px: two-row grid)
   ==================================================== */
@media (max-width: 700px) {
  .files-tab .file-row {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    row-gap: 4px;
  }
  .files-tab .file-row .cat-select {
    grid-column: 2 / 4;
    grid-row: 2;
    font-size: 11px;
  }
  .files-tab .file-row .file-meta {
    grid-column: 2;
    grid-row: 2;
    font-size: 11px;
  }
}

/* ====================================================
   Responsive — Modal (≤500px: full-width)
   ==================================================== */
@media (max-width: 500px) {
  .modal {
    min-width: 0;
    width: calc(100vw - 24px);
    max-height: 85vh;
  }
  .modal > h2,
  .modal > h3 { padding: 14px 16px 6px; }
  .modal-body { padding: 0 16px 12px; }
  .modal-footer { padding: 10px 16px; }
}

/* ====================================================
   File Preview Modal
   ==================================================== */
.preview-backdrop { padding: 24px; }
.preview-modal {
  width: min(1100px, 96vw); height: 88vh;
  max-width: 96vw; max-height: 90vh;
  display: flex; flex-direction: column; padding: 0; min-width: 0;
}
.preview-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border); gap: 16px;
}
.preview-header .filename { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-body { flex: 1; overflow: auto; background: var(--bg-muted); display: flex; align-items: stretch; }
.preview-iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.preview-image { max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; background: #fff; padding: 16px; }
.preview-text { flex: 1; margin: 0; padding: 16px 20px; overflow: auto; background: #fff;
                font: 13px/1.5 "Consolas", "Courier New", monospace; white-space: pre-wrap; word-break: break-all; }
.preview-office { margin: auto; text-align: center; padding: 40px; background: #fff; border-radius: 8px; border: 1px solid var(--border); }
.preview-loading { margin: auto; color: var(--text-muted); }
.preview-error { margin: auto; color: var(--danger); }
@media (max-width: 700px) {
  .preview-backdrop { padding: 0; }
  .preview-modal { height: 100vh; width: 100vw; border-radius: 0; max-width: 100vw; max-height: 100vh; }
}

/* ====================================================
   Filename link (file list clickable spans)
   ==================================================== */
.filename.link { color: var(--lan-blue); cursor: pointer; text-decoration: none; }
.filename.link:hover { text-decoration: underline; }

/* ====================================================
   Knowledge-Book Design Tokens (Kundendetail only)
   ==================================================== */
:root {
  --kb-blue:        #2563eb;
  --kb-blue-soft:   #eff6ff;
  --kb-ink:         #0f172a;
  --kb-text:        #1e293b;
  --kb-muted:       #64748b;
  --kb-faint:       #94a3b8;
  --kb-border:      #e2e8f0;
  --kb-border-soft: #f1f5f9;
  --kb-bg:          #ffffff;
  --kb-bg-rail:     #f8fafc;
  --kb-accent:      #1e40af;
  --kb-ok:          #15803d;
  --kb-warn:        #b45309;
  --kb-danger:      #b91c1c;
}

/* ====================================================
   KB — root page override (break out of .page padding)
   ==================================================== */
#root.kb-root {
  padding: 0;
  max-width: none;
  margin: 0;
}

/* ====================================================
   KB — Context bar (above layout)
   ==================================================== */
.kb-contextbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--kb-border);
  background: var(--kb-bg);
  flex-wrap: wrap;
}
.kb-contextbar .kb-back {
  color: var(--kb-muted);
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.kb-contextbar .kb-back:hover { color: var(--kb-text); }
.kb-contextbar .kb-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--kb-ink);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kb-contextbar .kb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Mode toggle (Ansicht / Bearbeiten) */
.kb-mode-toggle {
  display: inline-flex;
  background: var(--kb-bg-rail);
  border: 1px solid var(--kb-border);
  border-radius: 8px;
  padding: 3px;
  font-size: 13px;
  font-weight: 500;
}
.kb-mode-toggle button {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--kb-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  font-size: 13px;
}
.kb-mode-toggle button.active {
  background: var(--kb-bg);
  color: var(--kb-ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

/* ====================================================
   KB — 3-column layout
   ==================================================== */
.kb-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 260px;
  min-height: calc(100vh - 57px - 49px); /* viewport minus header minus contextbar */
}
@media (max-width: 1100px) {
  .kb-layout { grid-template-columns: 260px 1fr; }
  .kb-onpage  { display: none; }
}
@media (max-width: 800px) {
  .kb-layout  { grid-template-columns: 1fr; }
  .kb-tree    { display: none; }
}

/* ====================================================
   KB — Left tree
   ==================================================== */
.kb-tree {
  border-right: 1px solid var(--kb-border);
  background: var(--kb-bg-rail);
  padding: 24px 16px 40px;
  font-size: 14px;
  position: sticky;
  top: 57px;          /* global header height */
  align-self: start;
  max-height: calc(100vh - 57px);
  overflow-y: auto;
}

.kb-tree-customer {
  padding: 10px 12px;
  background: var(--kb-bg);
  border: 1px solid var(--kb-border);
  border-radius: 8px;
  margin-bottom: 20px;
  cursor: pointer;
}
.kb-tree-customer:hover { border-color: var(--kb-blue); }
.kb-tree-customer h3 {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 600;
  color: var(--kb-ink);
}
.kb-tree-customer small { color: var(--kb-muted); font-size: 12px; }

.kb-tree-section { margin-bottom: 24px; }
.kb-tree-section h4 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--kb-muted);
  margin: 0 0 8px 8px;
}

.kb-tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--kb-text);
  font-size: 14px;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  position: relative;
}
.kb-tree-item:hover { background: #eef2f7; }
.kb-tree-item.active {
  background: var(--kb-blue-soft);
  color: var(--kb-accent);
  font-weight: 500;
}
.kb-tree-item.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--kb-blue);
}
.kb-tree-item .kb-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--kb-faint);
  margin-left: auto;
  flex-shrink: 0;
}
.kb-tree-item .kb-dot.draft { background: var(--kb-warn); }
.kb-tree-item .kb-dot.ok    { background: var(--kb-ok); }
.kb-tree-item .kb-count {
  margin-left: auto;
  color: var(--kb-muted);
  font-size: 12px;
  flex-shrink: 0;
}
.kb-tree-item svg { flex-shrink: 0; }

/* ====================================================
   KB — Middle article
   ==================================================== */
.kb-article {
  padding: 32px 48px 120px;
  max-width: none;        /* nutze die volle Grid-Cell */
  margin: 0;
  width: 100%;
  color: var(--kb-text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "ss01","cv11","tnum";
}

/* Typography */
.kb-article h1 {
  font-size: 36px;
  font-weight: 700;
  margin: 4px 0 6px;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--kb-ink);
}
.kb-article .kb-lede {
  font-size: 17px;
  color: var(--kb-muted);
  margin: 0 0 32px;
  line-height: 1.55;
}
.kb-article h2 {
  font-size: 22px;
  font-weight: 650;
  margin: 44px 0 14px;
  letter-spacing: -0.01em;
  scroll-margin-top: 80px;
  color: var(--kb-ink);
}
.kb-article h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 28px 0 10px;
  scroll-margin-top: 80px;
  color: var(--kb-ink);
}
.kb-article p { margin: 0 0 14px; }
.kb-article a { color: var(--kb-blue); text-decoration: none; }
.kb-article a:hover { text-decoration: underline; }

/* Breadcrumb */
.kb-crumb {
  font-size: 13px;
  color: var(--kb-muted);
  margin-bottom: 10px;
}
.kb-crumb a { color: var(--kb-muted); text-decoration: none; }
.kb-crumb a:hover { color: var(--kb-blue); }

/* Page actions row */
.kb-page-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.kb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--kb-border);
  background: var(--kb-bg);
  border-radius: 7px;
  font-size: 13px;
  color: var(--kb-text);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.kb-btn:hover { background: var(--kb-bg-rail); }
.kb-btn.primary { background: var(--kb-ink); color: #fff; border-color: var(--kb-ink); }
.kb-btn.primary:hover { background: #1e293b; }

/* Definition-list block */
.kb-dl {
  background: var(--kb-bg-rail);
  border: 1px solid var(--kb-border-soft);
  border-radius: 10px;
  padding: 4px 18px;
  margin: 14px 0 20px;
}
.kb-dl dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 24px;
}
.kb-dl dt {
  padding: 12px 0;
  border-bottom: 1px solid var(--kb-border-soft);
  color: var(--kb-muted);
  font-size: 14px;
  font-weight: 500;
}
.kb-dl dd {
  padding: 12px 0;
  border-bottom: 1px solid var(--kb-border-soft);
  margin: 0;
  font-size: 14px;
  color: var(--kb-text);
  word-break: break-word;
}
.kb-dl dt:last-of-type,
.kb-dl dt:last-of-type + dd { border-bottom: 0; }

/* Table — modernes Layout */
.kb-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 24px;
  font-size: 13px;
  background: var(--kb-bg);
  border: 1px solid var(--kb-border);
  border-radius: 10px;
  overflow: hidden;
}
.kb-table thead th {
  background: var(--kb-bg-rail);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--kb-muted);
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--kb-border);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.kb-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--kb-border-soft);
  color: var(--kb-text);
  vertical-align: middle;
  line-height: 1.45;
}
.kb-table tbody td.kb-mono {
  font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  color: var(--kb-text);
}
/* Zebra-Stripes — subtil */
.kb-table tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.014);
}
.kb-table tbody tr:last-child td { border-bottom: 0; }
.kb-table tbody tr:hover td { background: var(--kb-blue-soft); }
.kb-table-wrap {
  overflow-x: auto;
  margin: 0 0 8px;
  border-radius: 10px;
  -webkit-overflow-scrolling: touch;
}
/* Scrollbar dezenter machen */
.kb-table-wrap::-webkit-scrollbar { height: 8px; }
.kb-table-wrap::-webkit-scrollbar-thumb {
  background: var(--kb-border);
  border-radius: 4px;
}
.kb-table-wrap::-webkit-scrollbar-thumb:hover { background: var(--kb-faint); }

/* Dropdown (z.B. Multi-Collector-pro-Modul) */
.kb-dropdown {
  position: relative;
  display: inline-block;
}
.kb-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--kb-bg);
  border: 1px solid var(--kb-border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  min-width: 240px;
  max-width: 360px;
  z-index: 100;
  padding: 4px 0;
}
.kb-dropdown.open > .kb-dropdown-menu { display: block; }
.kb-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--kb-text);
  cursor: pointer;
  white-space: normal;
  line-height: 1.4;
}
.kb-dropdown-item:hover { background: var(--kb-blue-soft); color: var(--kb-blue); }

/* Code-Block in Modals (z.B. Master-Import-Modal) */
.kb-code-block {
  display: block;
  background: var(--kb-bg-rail);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-family: ui-monospace, Consolas, "SF Mono", monospace;
  margin: 8px 0;
  border: 1px solid var(--kb-border);
}

/* Module Status-Bar — universelle Top-Zeile pro Modul */
.kb-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 14px;
  background: var(--kb-bg-rail);
  border: 1px solid var(--kb-border);
  border-radius: 8px;
  margin: 0 0 16px 0;
  font-size: 12.5px;
}
.kb-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 14px;
  background: var(--kb-bg);
  border: 1px solid var(--kb-border);
  color: var(--kb-text);
  font-size: 12px;
}
.kb-status-pill.ok     { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.kb-status-pill.warn   { background: #fef9c3; border-color: #fcd34d; color: #854d0e; }
.kb-status-pill.muted  { background: var(--kb-bg-rail); color: var(--kb-muted); }
.kb-status-meta {
  color: var(--kb-muted);
  font-size: 12px;
}
.kb-status-meta strong { color: var(--kb-text); font-weight: 500; }

/* Module-Summary (Quick-Stats Cards am Anfang eines Moduls) */
.kb-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 0 0 24px 0;
}
.kb-summary-card {
  background: var(--kb-bg-rail);
  border: 1px solid var(--kb-border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kb-summary-card.warn  { background: #fef9c3; border-color: #fcd34d; }
.kb-summary-card.danger{ background: #fee2e2; border-color: #fca5a5; }
.kb-summary-card.ok    { background: #f0fdf4; border-color: #86efac; }
.kb-summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--kb-muted);
  font-weight: 600;
}
.kb-summary-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--kb-ink);
  line-height: 1.1;
  word-break: break-all;
}
.kb-summary-value.small { font-size: 14px; font-weight: 500; }
.kb-summary-detail {
  font-size: 12px;
  color: var(--kb-muted);
  margin-top: 2px;
}

/* Tabellen-Toolbar (Filter + Toggle) */
.kb-table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 8px;
  font-size: 13px;
}
.kb-table-toolbar input {
  flex: 0 0 220px;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--kb-border);
  border-radius: 6px;
  background: var(--kb-bg);
}
.kb-table-toolbar .kb-count {
  color: var(--kb-muted);
  font-size: 12px;
}
.kb-table-toolbar .kb-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--kb-blue);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
}
.kb-table-toolbar .kb-toggle:hover { background: var(--kb-blue-soft); }

.kb-table tbody tr.kb-row-hidden { display: none; }
.kb-table-empty-filter {
  text-align: center;
  color: var(--kb-muted);
  font-style: italic;
  padding: 16px !important;
}

/* Callout */
.kb-callout {
  background: var(--kb-blue-soft);
  border-left: 3px solid var(--kb-blue);
  padding: 14px 18px;
  border-radius: 6px;
  margin: 20px 0;
  font-size: 14px;
  color: var(--kb-text);
}
.kb-callout.warn { background: #fef9c3; border-color: var(--kb-warn); }
.kb-callout.tip  { background: #f0fdf4; border-color: var(--kb-ok); }
.kb-callout strong { display: block; margin-bottom: 4px; }

/* File reference pill */
.kb-fileref {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--kb-bg-rail);
  border: 1px solid var(--kb-border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--kb-text);
  text-decoration: none;
  cursor: pointer;
  margin: 2px 0;
}
.kb-fileref:hover { background: var(--kb-bg); }
.kb-fileref .kb-ft {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: .04em;
}
.kb-ft-pdf  { background: #dc2626; }
.kb-ft-docx { background: #2563eb; }
.kb-ft-xlsx { background: #16a34a; }
.kb-ft-vsdx { background: #7c3aed; }
.kb-ft-img  { background: #b45309; }
.kb-ft-default { background: #64748b; }

/* Status pill */
.kb-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.kb-pill.ok     { background: #dcfce7; color: var(--kb-ok); }
.kb-pill.warn   { background: #fef3c7; color: var(--kb-warn); }
.kb-pill.danger { background: #fee2e2; color: var(--kb-danger); }
.kb-pill.info   { background: var(--kb-blue-soft); color: var(--kb-accent); }
.kb-pill .kb-d  { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Mono */
.kb-mono { font-family: "SF Mono", Consolas, monospace; font-size: 13px; }

/* Prev/Next navigation */
.kb-pagenav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 56px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--kb-border);
}
.kb-pagenav-btn {
  text-decoration: none;
  color: var(--kb-text);
  padding: 14px 16px;
  border: 1px solid var(--kb-border);
  border-radius: 10px;
  background: var(--kb-bg);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.kb-pagenav-btn:hover { border-color: var(--kb-blue); background: var(--kb-blue-soft); }
.kb-pagenav-btn small {
  color: var(--kb-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  display: block;
}
.kb-pagenav-btn.next { text-align: right; }

/* Empty pagenav slot */
.kb-pagenav-empty {
  display: block;
}

/* ====================================================
   KB — Right on-this-page TOC
   ==================================================== */
.kb-onpage {
  border-left: 1px solid var(--kb-border);
  padding: 32px 20px 40px;
  position: sticky;
  top: 57px;
  align-self: start;
  max-height: calc(100vh - 57px);
  overflow-y: auto;
  font-size: 13px;
  background: var(--kb-bg);
}
.kb-onpage h5 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--kb-muted);
  margin: 0 0 10px;
  font-weight: 600;
}
.kb-onpage ul { list-style: none; padding: 0; margin: 0; }
.kb-onpage li { margin-bottom: 2px; }
.kb-onpage a {
  display: block;
  padding: 4px 10px;
  border-radius: 5px;
  color: var(--kb-muted);
  text-decoration: none;
  line-height: 1.4;
}
.kb-onpage a:hover { color: var(--kb-text); background: var(--kb-bg-rail); }
.kb-onpage a.active { color: var(--kb-blue); background: var(--kb-blue-soft); font-weight: 500; }
.kb-onpage a.lvl-3 { padding-left: 22px; font-size: 12px; }
.kb-onpage .kb-onpage-meta {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--kb-border);
  font-size: 12px;
  color: var(--kb-muted);
}
.kb-onpage .kb-onpage-meta div { margin-bottom: 6px; }

/* ====================================================
   KB — Edit mode
   ==================================================== */
body.kb-edit .kb-article  { background: #fffdf5; }
body.kb-edit .kb-dl       { background: #fff; border-color: #fbe8a3; }

.kb-edit-bar {
  display: none;
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: var(--kb-ink);
  color: #fff;
  padding: 8px 8px 8px 16px;
  border-radius: 10px;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
body.kb-edit .kb-edit-bar { display: flex; }
.kb-edit-bar button {
  background: var(--kb-blue);
  color: #fff;
  border: 0;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
}
.kb-edit-bar button.cancel { background: rgba(255,255,255,.1); }

/* ====================================================
   KB — Notes / Activity / Files page headings
   ==================================================== */
.kb-page-h1 {
  font-size: 36px;
  font-weight: 700;
  margin: 0 0 24px;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--kb-ink);
}
.kb-section-h2 {
  font-size: 22px;
  font-weight: 650;
  margin: 32px 0 12px;
  letter-spacing: -0.01em;
  color: var(--kb-ink);
  scroll-margin-top: 80px;
}

/* Note item in KB */
.kb-note-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--kb-border-soft);
  font-size: 14px;
}

/* ====================================================
   Dashboard Split Layout (.dash-)
   ==================================================== */

/* Reset root padding when dash layout is active */
#root.dash-root {
  padding: 0;
  max-width: none;
  margin: 0;
}

.dash-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* Left panel */
.dash-list {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--kb-bg-rail);
  border-right: 1px solid var(--kb-border);
}

.dash-list-header {
  flex-shrink: 0;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--kb-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-list-header .dash-actions {
  display: flex;
  gap: 6px;
}

.dash-list-header .dash-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: none;
  border-radius: 7px;
  background: var(--kb-bg-rail, #f4f5f7);
}

.dash-list-header .dash-search-wrap:focus-within {
  background: #fff;
  outline: 2px solid var(--kb-blue);
  outline-offset: 0;
}

.dash-list-header .dash-search-wrap svg {
  color: var(--kb-muted);
  flex-shrink: 0;
}

.dash-list-header .dash-search-wrap input {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--kb-text);
}

.dash-list-header .dash-search-kbd {
  flex-shrink: 0;
  background: var(--kb-bg-rail);
  border: 1px solid var(--kb-border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--kb-muted);
  font-family: "SF Mono", Consolas, monospace;
  pointer-events: none;
}

.dash-list-header .dash-archived-toggle {
  font-size: 11px;
  color: var(--kb-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
}

.dash-list-body {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 40px;
}

/* Group header */
.dash-group-header {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--kb-faint);
  padding: 12px 14px 4px;
}

/* List item */
.dash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s;
  position: relative;
}

.dash-item:hover { background: #eef2f7; }

.dash-item.active {
  background: var(--kb-blue-soft);
  border-left-color: var(--kb-blue);
}

.dash-item.active .dash-item-name {
  color: var(--kb-accent);
  font-weight: 600;
}

/* Avatar circle */
.dash-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.dash-av-0 { background: #dbeafe; color: #1d4ed8; }
.dash-av-1 { background: #dcfce7; color: #15803d; }
.dash-av-2 { background: #ede9fe; color: #6d28d9; }
.dash-av-3 { background: #ffedd5; color: #c2410c; }
.dash-av-4 { background: #ccfbf1; color: #0f766e; }

.dash-item-body {
  flex: 1;
  min-width: 0;
}

.dash-item-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--kb-text);
}

.dash-item-sub {
  font-size: 11px;
  color: var(--kb-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status dot */
.dash-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dash-dot-ok   { background: #22c55e; }
.dash-dot-warn { background: #f59e0b; }
.dash-dot-muted { background: var(--kb-faint); }

/* Keyboard hint bar */
.dash-kbd {
  flex-shrink: 0;
  padding: 7px 14px;
  background: var(--kb-bg-rail);
  border-top: 1px solid var(--kb-border);
  font-size: 11px;
  color: var(--kb-faint);
  text-align: center;
}

.dash-kbd kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--kb-border);
  border-radius: 3px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 10px;
  color: var(--kb-muted);
  background: #fff;
  margin: 0 2px;
}

/* Right preview pane */
.dash-preview {
  overflow-y: auto;
  background: var(--kb-bg);
}

.dash-preview-inner {
  padding: 36px 44px 80px;
  max-width: 760px;
  width: 100%;
}

/* Preview header */
.dash-preview-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.dash-preview-avatar {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dash-preview-header-text h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 4px;
  color: var(--kb-ink);
  line-height: 1.2;
}

.dash-preview-header-text .meta {
  font-size: 14px;
  color: var(--kb-muted);
}

/* Action buttons row */
.dash-preview-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* Stats grid */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.dash-stat-card {
  background: var(--kb-bg-rail);
  border: 1px solid var(--kb-border);
  border-radius: 9px;
  padding: 14px 16px;
}

.dash-stat-card .ds-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--kb-faint);
  margin-bottom: 4px;
}

.dash-stat-card .ds-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--kb-ink);
  line-height: 1.2;
}

.dash-stat-card .ds-sub {
  font-size: 12px;
  color: var(--kb-muted);
  margin-top: 2px;
}

/* Section title */
.dash-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--kb-muted);
  margin: 0 0 10px;
}

/* Quick-Facts DL */
.dash-quick-facts {
  margin-bottom: 24px;
}

/* Timeline */
.dash-timeline {
  margin: 0 0 28px;
}

.dash-timeline-item {
  display: flex;
  gap: 12px;
  padding: 7px 0;
  position: relative;
}

.dash-timeline-item::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 28px;
  bottom: -3px;
  width: 1px;
  background: var(--kb-border);
}

.dash-timeline-item:last-child::before { display: none; }

.dash-timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--kb-bg-rail);
  border: 1px solid var(--kb-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--kb-muted);
}

.dash-timeline-body {
  flex: 1;
  padding-top: 6px;
}

.dash-timeline-body .tl-text { font-size: 13px; }
.dash-timeline-body .tl-when { font-size: 12px; color: var(--kb-muted); margin-top: 1px; }

/* Notes block */
.dash-notes-block {
  margin-bottom: 28px;
}

.dash-note-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--kb-border-soft);
  font-size: 13px;
  color: var(--kb-text);
}

.dash-note-item .dn-meta { font-size: 11px; color: var(--kb-muted); margin-top: 2px; }

/* Divider */
.dash-divider {
  border: 0;
  border-top: 1px solid var(--kb-border);
  margin: 24px 0;
}

/* Empty + no-selection states */
.dash-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 40px;
  color: var(--kb-muted);
}

.dash-empty-state svg { margin-bottom: 16px; opacity: .4; }
.dash-empty-state h3 { font-size: 17px; margin: 0 0 8px; color: var(--kb-text); }
.dash-empty-state p { font-size: 13px; margin: 0; }

/* Responsive: <900px single column */
@media (max-width: 900px) {
  .dash-layout {
    grid-template-columns: 1fr;
  }
  .dash-preview { display: none; }
  .dash-layout.detail-open .dash-list { display: none; }
  .dash-layout.detail-open .dash-preview { display: block; }
}

/* ====================================================
   Admin Tree Layout (.adm-)
   ==================================================== */

#root.adm-root {
  padding: 0;
  max-width: none;
  margin: 0;
}

.adm-layout {
  display: grid;
  grid-template-columns: 270px 1fr 280px;
  height: calc(100vh - 64px);
  overflow: hidden;
}

@media (max-width: 1100px) {
  .adm-layout { grid-template-columns: 260px 1fr; }
  .adm-usage  { display: none; }
}

@media (max-width: 800px) {
  .adm-layout { grid-template-columns: 1fr; }
  .adm-tree   { display: none; }
}

/* Left tree pane */
.adm-tree {
  border-right: 1px solid var(--kb-border);
  background: var(--kb-bg-rail);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.adm-tree-toolbar {
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--kb-border);
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  align-items: center;
}

.adm-tree-toolbar .adm-search-wrap {
  position: relative;
  flex: 1;
}

.adm-tree-toolbar .adm-search-wrap svg {
  position: absolute;
  top: 8px;
  left: 8px;
  color: var(--kb-muted);
  pointer-events: none;
}

.adm-tree-toolbar input {
  width: 100%;
  padding: 6px 10px 6px 28px;
  border: 1px solid var(--kb-border);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--kb-text);
}

.adm-tree-toolbar input:focus { outline: 2px solid var(--kb-blue); }

.adm-btn-add {
  width: 28px;
  height: 28px;
  border: 1px solid var(--kb-border);
  background: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--kb-muted);
  flex-shrink: 0;
  padding: 0;
}

.adm-btn-add:hover {
  border-color: var(--kb-blue);
  color: var(--kb-blue);
  background: var(--kb-blue-soft);
}

/* Section switcher */
.adm-section-switcher {
  display: flex;
  flex-shrink: 0;
  padding: 8px 10px;
  gap: 4px;
  border-bottom: 1px solid var(--kb-border);
  background: var(--kb-bg-rail);
  flex-wrap: wrap;
}

.adm-section-btn {
  flex: 1;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  color: var(--kb-muted);
  font-family: inherit;
  text-align: center;
  white-space: nowrap;
}

.adm-section-btn:hover {
  background: #eef2f7;
  color: var(--kb-text);
}

.adm-section-btn.active {
  background: var(--kb-blue-soft);
  color: var(--kb-accent);
  border-color: var(--kb-border);
  font-weight: 600;
}

/* Tree body */
.adm-tree-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

/* Module row */
.adm-tree-module { font-size: 13px; }

.adm-tree-mod-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 4px;
  user-select: none;
}

.adm-tree-mod-header:hover { background: #eef2f7; }
.adm-tree-mod-header.active { background: var(--kb-blue-soft); color: var(--kb-accent); }

.adm-chevron {
  color: var(--kb-faint);
  flex-shrink: 0;
  transition: transform .15s;
  display: flex;
  align-items: center;
}

.adm-tree-mod-header.open .adm-chevron { transform: rotate(90deg); }

.adm-mod-icon { color: var(--kb-muted); flex-shrink: 0; }
.adm-tree-mod-header.active .adm-mod-icon { color: var(--kb-accent); }

.adm-mod-name { flex: 1; font-weight: 500; }
.adm-mod-count { font-size: 11px; color: var(--kb-faint); }

/* Field items under module */
.adm-tree-fields { padding-left: 18px; padding-bottom: 4px; }

.adm-tree-field {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 5px;
  margin: 1px 4px;
  color: var(--kb-muted);
  font-size: 12px;
}

.adm-tree-field:hover { background: #eef2f7; color: var(--kb-text); }
.adm-tree-field.active { background: var(--kb-blue-soft); color: var(--kb-accent); }

.adm-field-name { flex: 1; }

/* Field-type icon colors */
.adm-ti-text      { color: #6d28d9; }
.adm-ti-textarea  { color: #15803d; }
.adm-ti-select    { color: #c2410c; }
.adm-ti-multisel  { color: #92400e; }
.adm-ti-table     { color: #0f766e; }
.adm-ti-file      { color: #1d4ed8; }
.adm-ti-link      { color: #9d174d; }

/* Add-field row at bottom of field list */
.adm-tree-add-field {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 5px;
  margin: 1px 4px;
  color: var(--kb-faint);
  font-size: 11px;
  cursor: pointer;
}

.adm-tree-add-field:hover { color: var(--kb-blue); background: var(--kb-blue-soft); }

/* Add-module row at bottom of tree */
.adm-tree-add-module {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  color: var(--kb-faint);
  font-size: 12px;
  cursor: pointer;
  margin: 2px 4px;
  border-radius: 6px;
}

.adm-tree-add-module:hover { color: var(--kb-blue); background: var(--kb-blue-soft); }

/* Middle editor pane */
.adm-editor {
  overflow-y: auto;
  background: var(--kb-bg);
  border-right: 1px solid var(--kb-border);
  display: flex;
  flex-direction: column;
}

.adm-editor-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--kb-border);
  position: sticky;
  top: 0;
  background: var(--kb-bg);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.adm-editor-header .adm-breadcrumb {
  font-size: 12px;
  color: var(--kb-muted);
  margin-bottom: 2px;
}

.adm-editor-header h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--kb-ink);
}

.adm-type-badge {
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  background: var(--kb-bg-rail);
  color: var(--kb-muted);
  border: 1px solid var(--kb-border);
  flex-shrink: 0;
}

.adm-editor-header-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.adm-editor-body {
  padding: 24px;
  flex: 1;
}

/* Field group in form */
.adm-field-group {
  margin-bottom: 20px;
}

.adm-field-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--kb-ink);
  margin-bottom: 5px;
}

.adm-field-group .adm-hint {
  font-size: 12px;
  color: var(--kb-muted);
  margin-top: 3px;
}

.adm-field-group input[type="text"],
.adm-field-group select,
.adm-field-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--kb-border);
  border-radius: 7px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--kb-text);
}

.adm-field-group input:focus,
.adm-field-group select:focus,
.adm-field-group textarea:focus {
  outline: 2px solid var(--kb-blue);
}

.adm-field-group textarea { resize: vertical; min-height: 80px; }

/* Toggle row */
.adm-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--kb-border-soft);
}

.adm-toggle-row:last-child { border-bottom: 0; }

.adm-toggle-row .adm-toggle-info span {
  display: block;
  font-size: 14px;
  font-weight: 500;
}

.adm-toggle-row .adm-toggle-info small {
  font-size: 12px;
  color: var(--kb-muted);
}

.adm-toggle {
  width: 38px;
  height: 20px;
  border-radius: 10px;
  background: var(--kb-border);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s;
  border: none;
  padding: 0;
}

.adm-toggle.on { background: var(--kb-blue); }

.adm-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.adm-toggle.on::after { transform: translateX(18px); }

/* Select option list */
.adm-option-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }

.adm-option-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.adm-option-row input {
  flex: 1;
  padding: 5px 10px;
  border: 1px solid var(--kb-border);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
}

.adm-option-rm {
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--kb-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  padding: 0;
}

.adm-option-rm:hover { background: #fee2e2; color: var(--kb-danger); }

.adm-add-option {
  font-size: 12px;
  color: var(--kb-blue);
  border: 0;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  font: inherit;
}

.adm-type-config {
  background: var(--kb-bg-rail);
  border: 1px solid var(--kb-border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 8px;
}

.adm-type-config h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--kb-muted);
  margin: 0 0 12px;
}

/* Sticky save bar */
.adm-save-bar {
  padding: 12px 24px;
  border-top: 1px solid var(--kb-border);
  background: var(--kb-bg);
  display: flex;
  gap: 8px;
  align-items: center;
  position: sticky;
  bottom: 0;
  flex-shrink: 0;
}

.adm-save-bar .adm-save-hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--kb-muted);
}

/* Usage panel */
.adm-usage {
  overflow-y: auto;
  background: var(--kb-bg);
  padding: 20px 18px;
}

.adm-usage h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--kb-muted);
  margin: 0 0 12px;
}

.adm-usage-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px solid var(--kb-border-soft);
  font-size: 13px;
}

.adm-usage-item:last-child { border-bottom: 0; }

.adm-usage-av {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.adm-av-0 { background: #dbeafe; color: #1d4ed8; }
.adm-av-1 { background: #dcfce7; color: #15803d; }
.adm-av-2 { background: #ede9fe; color: #6d28d9; }
.adm-av-3 { background: #ffedd5; color: #c2410c; }
.adm-av-4 { background: #ccfbf1; color: #0f766e; }

.adm-usage-body .adm-ub-name { font-weight: 500; line-height: 1.3; }
.adm-usage-body .adm-ub-sub  { font-size: 11px; color: var(--kb-muted); }
.adm-usage-count { margin-left: auto; font-size: 11px; color: var(--kb-muted); }

.adm-usage-bar-row {
  margin-bottom: 8px;
}

.adm-usage-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 3px;
}

.adm-usage-bar-label span:last-child { color: var(--kb-muted); }

.adm-usage-bar {
  height: 4px;
  background: var(--kb-border);
  border-radius: 2px;
  overflow: hidden;
}

.adm-usage-bar-fill {
  height: 100%;
  background: var(--kb-blue);
  border-radius: 2px;
}

.adm-divider {
  border: 0;
  border-top: 1px solid var(--kb-border);
  margin: 16px 0;
}

/* Empty editor placeholder */
.adm-editor-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 40px;
  color: var(--kb-muted);
  flex: 1;
}

.adm-editor-empty svg { margin-bottom: 16px; opacity: .4; }
.adm-editor-empty p { font-size: 14px; margin: 0; }

/* Key field read-only mono */
.adm-key-input {
  font-family: "SF Mono", Consolas, monospace !important;
  font-size: 13px !important;
  color: #6d28d9 !important;
}

/* User list table in admin */
.adm-user-list {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.adm-user-list th, .adm-user-list td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--kb-border);
}

.adm-user-list th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--kb-muted);
  background: var(--kb-bg-rail);
}

.adm-user-list tbody tr:hover { background: var(--kb-bg-rail); }
.adm-user-list .adm-user-actions { display: flex; gap: 6px; }
.kb-note-item .meta { font-size: 12px; color: var(--kb-muted); margin-bottom: 4px; }
.kb-note-item .body { color: var(--kb-text); }

/* Activity item in KB */
.kb-act-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--kb-border-soft);
  font-size: 14px;
}
.kb-act-item .act-main { color: var(--kb-text); }
.kb-act-item .act-when { color: var(--kb-muted); font-size: 12px; margin-top: 2px; }

/* Empty state inside KB */
.kb-empty {
  color: var(--kb-muted);
  font-size: 14px;
  padding: 16px 0;
  font-style: italic;
}

/* Responsive KB article padding */
@media (max-width: 900px) {
  .kb-article { padding: 24px 24px 80px; }
}
@media (max-width: 600px) {
  .kb-article { padding: 16px 16px 60px; }
  .kb-article h1, .kb-page-h1 { font-size: 26px; }
  .kb-article h2, .kb-section-h2 { font-size: 18px; }
  .kb-pagenav { grid-template-columns: 1fr; }
}

/* ── Freitext-Blockeditor (Editor.js) ──────────────────────────────────── */
.freeform-editor-root { min-height: 220px; margin-bottom: 16px; }
.editorjs-holder { font-size: 15px; line-height: 1.6; color: var(--kb-text); }
.editorjs-holder .ce-block__content,
.editorjs-holder .ce-toolbar__content { max-width: 100%; }
.editorjs-holder.readonly .ce-toolbar,
.editorjs-holder.readonly .ce-inline-toolbar,
.editorjs-holder.readonly .ce-toolbox { display: none !important; }
.editorjs-holder img { max-width: 100%; height: auto; }
.editorjs-holder .image-tool__image-picture { border-radius: 4px; }
.editorjs-holder .cdx-block { padding: 0.4em 0; }

/* ── Inline-Editor (Notizen, Module-Textarea) ─────────────────────── */
.kb-editorjs-field {
  border: 1px solid var(--kb-border);
  border-radius: 6px;
  padding: 6px 12px;
  background: #fff;
  transition: border-color .12s;
}
.kb-editorjs-field:focus-within { border-color: var(--lan-blue); }
.kb-editorjs-field .editorjs-holder { padding: 0; }

/* ── Rich-Text-Read-View (Module-Field-Read, Notizen-Read) ────────── */
.kb-richtext { line-height: 1.55; color: var(--text); }
.kb-richtext > *:first-child { margin-top: 0; }
.kb-richtext > *:last-child { margin-bottom: 0; }
.kb-richtext h1, .kb-richtext h2, .kb-richtext h3 { margin: 12px 0 6px; font-weight: 600; }
.kb-richtext h1 { font-size: 18px; }
.kb-richtext h2 { font-size: 16px; }
.kb-richtext h3 { font-size: 14px; }
.kb-richtext p { margin: 4px 0 8px; }
.kb-richtext ul, .kb-richtext ol { margin: 4px 0 8px; padding-left: 22px; }
.kb-richtext li { margin: 2px 0; }
.kb-richtext code { font-family: ui-monospace, Menlo, Consolas, monospace;
  background: var(--bg-muted); padding: 1px 5px; border-radius: 3px; font-size: 92%; }
.kb-richtext pre {
  background: var(--bg-muted); padding: 8px 12px; border-radius: 4px;
  overflow-x: auto; font-size: 12px;
}
.kb-richtext pre code { background: transparent; padding: 0; }
.kb-richtext blockquote {
  border-left: 3px solid var(--border);
  padding: 4px 12px;
  color: var(--text-muted);
  margin: 6px 0;
}
.kb-richtext .ej-table {
  border-collapse: collapse; width: 100%; margin: 6px 0; font-size: 13px;
}
.kb-richtext .ej-table td, .kb-richtext .ej-table th {
  border: 1px solid var(--border); padding: 4px 8px;
}
.kb-richtext hr.ej-delimiter { border: 0; border-top: 1px dashed var(--border); margin: 12px 0; }
.kb-richtext figure { margin: 6px 0; }
.kb-richtext img { max-width: 100%; height: auto; border-radius: 4px; }
.kb-richtext .ej-checklist { list-style: none; padding-left: 4px; }
.kb-richtext .ej-checklist li { margin: 2px 0; }
.kb-richtext mark { background: #fff5b1; padding: 0 2px; }

/* ── IT-Profil (Customer-Preview-Pane) ───────────────────────────── */
.it-profile {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.it-profile-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}
.it-profile-mode {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  background: var(--bg-muted);
  padding: 2px 9px;
  border-radius: 12px;
}
.it-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
.it-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  gap: 12px;
  border-bottom: 1px dashed #eef0f3;
  font-size: 13px;
}
.it-row:last-child { border-bottom: 0; }
.it-row.dim .it-v { color: var(--text-muted); font-weight: 400; }
.it-k {
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.2px;
}
.it-v {
  color: var(--text);
  font-weight: 600;
  text-align: right;
  font-feature-settings: 'tnum';
}
.it-v-sub {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
  margin-left: 4px;
}
