:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --line: #d7dee8;
  --ink: #1f2933;
  --muted: #5b6b7c;
  --accent: #2d6a9f;
  --accent-soft: #e8f0f8;
  --warn: #8a5a00;
  --warnbg: #fff6e0;
  --error: #9b1c1c;
  --errorbg: #fdecec;
  --mark: #ffe58a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

/* --- Kopfzeile --- */
.topbar {
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
}
.topbar .wrap { display: flex; align-items: center; gap: 18px; }
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 600; font-size: 16px; }
.topbar nav { display: flex; gap: 14px; font-size: 14px; }
.topbar nav a { opacity: .85; }
.topbar nav a:hover, .topbar nav a[aria-current="page"] { opacity: 1; text-decoration: underline; }

.wrap { max-width: 1100px; margin: 0 auto; }
main.wrap { padding: 28px 20px 60px; }

h1 { font-size: 22px; margin: 0 0 4px; color: var(--accent); }
h2 { font-size: 17px; margin: 28px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

/* --- Main: Auswahl der Operationen --- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.tile {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px 20px;
  color: var(--ink);
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
a.tile:hover { border-color: var(--accent); box-shadow: 0 3px 12px rgba(45, 106, 159, .15); }
.tile-title { font-weight: 600; font-size: 17px; color: var(--accent); margin-bottom: 6px; }
.tile-text { color: var(--muted); font-size: 14px; }
.tile.disabled { opacity: .55; cursor: not-allowed; }
.tile.disabled .tile-title { color: var(--muted); }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--line);
  color: var(--muted);
  margin-left: 6px;
  vertical-align: middle;
}

/* --- Formular --- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
input[type="text"], input[type="date"], select {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
}
input[type="text"]:focus, input[type="date"]:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.search-row { display: flex; gap: 10px; }
.search-row input { flex: 1; font-size: 16px; }

fieldset { border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px 10px; margin: 0; }
legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 4px; }
.keys { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.keys label { font-size: 14px; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; margin-top: 22px; cursor: pointer; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 7px 18px;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .6; cursor: not-allowed; }
button.busy:disabled { cursor: wait; }
button.secondary { background: #fff; color: var(--accent); padding: 3px 10px; font-size: 13px; }
button.link { background: none; border: none; color: var(--accent); padding: 0; font-size: 13px; text-decoration: underline; }

/* --- Ergebnis --- */
.summary { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 14px; color: var(--muted); }
.summary b { color: var(--accent); }
.warn { background: var(--warnbg); border: 1px solid #e8c77a; border-left: 4px solid #d99b1c; border-radius: 4px; padding: 10px 14px; margin-bottom: 10px; color: var(--warn); }
.error { background: var(--errorbg); border: 1px solid #efb4b4; border-left: 4px solid var(--error); border-radius: 4px; padding: 10px 14px; margin-bottom: 10px; color: var(--error); white-space: pre-wrap; }
.empty { color: var(--muted); font-style: italic; }
.loading { color: var(--muted); }

.doc { background: var(--card); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 14px; overflow: hidden; }
.doc-head { padding: 12px 18px; border-bottom: 1px solid var(--line); background: #fbfcfe; display: flex; gap: 12px; align-items: flex-start; }
.doc-head .grow { flex: 1; min-width: 0; }
.doc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.doc-title { font-weight: 600; font-size: 16px; margin: 0 0 3px; }
.doc-path { font-family: Consolas, "Courier New", monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.tokens { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.token { font-size: 11px; background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 1px 8px; }
.doc-body { padding: 6px 18px 12px; }
.hit { padding: 8px 0; border-bottom: 1px dotted var(--line); }
.hit:last-child { border-bottom: none; }
.hit-key { font-weight: 600; color: var(--accent); font-size: 13px; }
.hit-src { color: var(--muted); font-weight: 400; font-size: 12px; }
.hit-val { margin-top: 2px; word-break: break-word; }
mark { background: var(--mark); padding: 0 2px; border-radius: 2px; }

/* --- NewTraining --- */
.note { background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 4px; padding: 10px 14px; margin-bottom: 18px; font-size: 14px; }
.note a { color: var(--accent); }
.note.missing a { color: var(--muted); pointer-events: none; }
.note.missing::after { content: " (Datei nicht gefunden)"; color: var(--error); }
.card-title { font-size: 16px; margin: 0 0 4px; padding: 0; border: none; color: var(--accent); }
.group-text { margin: 0 0 12px; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.full { grid-column: 1 / -1; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
code.ph { font-size: 11px; font-weight: 400; color: var(--muted); }
.req { color: var(--error); }
.badge.web { background: var(--accent-soft); color: var(--accent); margin-left: 2px; }
textarea {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  resize: vertical;
  color: var(--ink);
}
textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.invalid, input.invalid, select.invalid, textarea.invalid { border-color: var(--error); background: var(--errorbg); }
.system-value { font-family: Consolas, "Courier New", monospace; font-size: 13px; padding: 7px 10px; background: #f0f3f7; border: 1px dashed var(--line); border-radius: 4px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 6px 0 20px; }
.actions .hint { margin: 0; }
button.secondary-lg { background: #fff; color: var(--accent); }
.md-preview { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 14px; font-size: 12px; line-height: 1.45; overflow-x: auto; white-space: pre; max-height: 70vh; }
.success { background: #eaf6ec; border: 1px solid #a9d8b1; border-left: 4px solid #2f8a42; border-radius: 4px; padding: 10px 14px; color: #1e5a2b; }
.success p { margin: 4px 0; }
.success-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px !important; }
.success a { color: var(--accent); margin-left: 8px; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .doc-head { flex-direction: column; }
}

/* Pflichtfelder (Seite "NewTraining") */
.form-field.required, label.field.required { border-left: 3px solid var(--accent); padding-left: 10px; }
.form-field.required .field-label, label.field.required { color: var(--ink); }
.form-field.required input[type="text"], .form-field.required textarea, label.field.required select, label.field.required input[type="text"] { border-color: var(--accent); background: var(--accent-soft); }
.form-field.required input[type="text"]:focus, .form-field.required textarea:focus, label.field.required input[type="text"]:focus { background: var(--card); }

/* DropDown-Listen fuer MultiValue-Felder (Seite "NewTraining") */
.multi { position: relative; }
.multi-row { display: flex; gap: 6px; }
.multi-row input[type="text"] { flex: 1; min-width: 0; }
.multi-toggle { padding: 0 10px; }
.multi-panel { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); max-height: 260px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .12); padding: 4px 0; }
.multi-item { display: flex; align-items: center; gap: 8px; padding: 5px 12px; font-size: 13px; color: var(--ink); cursor: pointer; }
.multi-item:hover { background: var(--accent-soft); }

/* Seite "ExportPackage" */
.export-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.export-table th, .export-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.export-table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.export-table .num { text-align: right; white-space: nowrap; }
.export-table tr.total td { font-weight: 600; border-bottom: none; }
.export-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 16px; }
.export-cols h3 { font-size: 14px; margin: 0 0 4px; color: var(--ink); }
.export-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.export-list li { margin: 2px 0; }
@media (max-width: 700px) { .export-cols { grid-template-columns: 1fr; } }

/* Seite "GetEconContent" */
.device-code { font-size: 16px; font-weight: 600; letter-spacing: 1px; background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 1px 8px; }
.md-preview.failed { border-color: #efb4b4; background: var(--errorbg); }
.export-table tbody th { width: 170px; vertical-align: top; }

/* Seite "Contacts": bearbeitbare Tabelle (Vorbild NDIM-MUP) */
main.wrap.wide { max-width: 1600px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 6px; }
.toolbar h1 { margin: 0; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
button.tool, .filter-bar button, .multi-select-actions button { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px 12px; font-size: 14px; }
button.tool:hover:not([disabled]), .filter-bar button:hover { border-color: var(--accent); color: var(--accent); filter: none; }
button.tool[disabled] { cursor: default; color: var(--muted); }
#delete:not([disabled]) { border-color: var(--error); color: var(--error); }
.select-all { display: flex; align-items: center; gap: 6px; padding: 4px 10px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card); }

.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-bottom: 12px; padding: 8px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.filter { display: flex; align-items: center; gap: 6px; }
.filter-label { font-size: 12px; color: var(--muted); }
.filter input[type="search"] { font: inherit; padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; width: 18ch; }
.filter-columns { display: inline-flex; flex-wrap: wrap; }
.filter-bar .filter-column { padding: 3px 8px; font-size: 12px; border-radius: 0; margin-left: -1px; color: var(--muted); }
.filter-bar .filter-column:first-child { border-radius: 4px 0 0 4px; margin-left: 0; }
.filter-bar .filter-column:last-child { border-radius: 0 4px 4px 0; }
.filter-bar .filter-column[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); position: relative; }
.multi-select { position: relative; }
.filter-bar .multi-select-button { padding: 3px 8px; font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-bar .multi-select-button.active, .filter-bar #filter-reset:not([disabled]) { border-color: var(--accent); color: var(--accent); }
.filter-bar #filter-reset[disabled] { color: var(--muted); cursor: default; }
.multi-select-list { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 220px; max-height: 320px; overflow: auto; padding: 4px 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 14px rgba(20, 25, 35, .15); }
.multi-select-list[hidden] { display: none; }
.multi-select-actions { display: flex; gap: 6px; padding: 4px 10px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.filter-bar .multi-select-actions button { padding: 1px 8px; font-size: 12px; }
.multi-select-option { display: flex; align-items: center; gap: 6px; padding: 3px 10px; cursor: pointer; white-space: nowrap; font-size: 13px; }
.multi-select-option:hover { background: var(--accent-soft); }
.multi-select-option .count { margin-left: auto; padding-left: 12px; font-size: 11px; color: var(--muted); }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: calc(100vh - 230px); }
.edit-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.edit-table th, .edit-table td { text-align: left; padding: 2px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.edit-table th { position: sticky; top: 0; z-index: 1; background: var(--card); padding: 7px 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.edit-table .check-cell { width: 28px; text-align: center; }
.edit-table td.empty { padding: 14px 10px; white-space: normal; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover, th.sorted { color: var(--accent); }
.sort-indicator { font-size: 10px; }
.col-resize { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; touch-action: none; z-index: 2; }
.col-resize::after { content: ""; position: absolute; top: 25%; bottom: 25%; right: 2px; width: 1px; background: var(--line); }
.col-resize:hover::after, .col-resize.active::after { top: 0; bottom: 0; width: 3px; right: 1px; background: var(--accent); }
.edit-table.fixed-columns { table-layout: fixed; }
.edit-table.fixed-columns th, .edit-table.fixed-columns td { overflow: hidden; text-overflow: ellipsis; }
.edit-table.fixed-columns input.fill { width: 100%; min-width: 0; }

tr.markable { cursor: pointer; }
tr.markable:hover td { background: var(--bg); }
tr.marked td, tr.marked:hover td { background: #d3e1fa; }
tr.marked td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.edit-table input[type="text"] { font: inherit; font-size: 13px; padding: 2px 4px; border: 1px solid transparent; border-radius: 4px; background: transparent; }
.edit-table input[type="text"]:hover { border-color: var(--line); }
.edit-table input[type="text"]:focus { border-color: var(--accent); background: var(--card); outline: none; }
.edit-table input.saved { background: #e3f4ea; }
.edit-table input.fill { width: 100%; min-width: 6ch; box-sizing: border-box; text-overflow: ellipsis; }
.edit-table:not(.fixed-columns) input.fill { field-sizing: content; width: auto; min-width: 100%; }
.edit-table td.fill-cell { width: 100%; }
.edit-table:not(.fixed-columns) td.fill-cell input.fill { field-sizing: fixed; width: 100%; min-width: 22ch; }

.combo { display: flex; align-items: center; width: 100%; min-width: 0; }
.edit-table .combo input.fill { flex: 1 1 auto; min-width: 0; }
.edit-table:not(.fixed-columns) .combo input.fill { min-width: 9ch; }
.edit-table .combo-toggle { flex: none; padding: 0 3px; border: 1px solid transparent; border-radius: 4px; background: transparent;
  color: var(--muted); font-size: 11px; line-height: 16px; }
.edit-table .combo-toggle:hover { color: var(--accent); border-color: var(--line); filter: none; }
.edit-table .cell-link { flex: none; padding: 0 3px; color: var(--muted); font-size: 12px; text-decoration: none; }
.edit-table .cell-link:hover { color: var(--accent); }
.edit-table [hidden] { display: none !important; }
.edit-table .image-cell { display: block; text-align: center; }
.edit-table .image-cell .cell-link { font-size: 14px; }
.edit-table .mail-link { flex: 1 1 auto; min-width: 0; padding: 3px 5px; overflow: hidden; text-overflow: ellipsis; color: var(--accent); text-decoration: none; }
.edit-table .mail-link:hover { text-decoration: underline; }
.edit-table .cell-edit { flex: none; padding: 0 4px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--muted); font-size: 12px; line-height: 16px; visibility: hidden; }
.edit-table tr:hover .cell-edit { visibility: visible; }
.edit-table .cell-edit:hover { color: var(--accent); border-color: var(--line); filter: none; }
.edit-table .cell-link.missing { opacity: .45; filter: grayscale(1); }
.combo-list { position: fixed; z-index: 1000; max-height: 240px; overflow: auto; margin: 0; padding: 4px 0; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 14px rgba(20, 25, 35, .15); font-size: 12px; }
.combo-list[hidden] { display: none; }
.combo-list li { padding: 3px 10px; cursor: pointer; white-space: nowrap; }
.combo-list li.active, .combo-list li[role="option"]:hover { background: var(--accent-soft); }
.combo-list li.empty { cursor: default; white-space: normal; max-width: 260px; }

.context-menu { position: fixed; z-index: 1000; min-width: 220px; margin: 0; padding: 4px 0; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 14px rgba(20, 25, 35, .18); font-size: 14px; }
.context-menu[hidden] { display: none; }
.context-menu button { display: block; width: 100%; padding: 6px 14px; border: 0; border-radius: 0; background: none; color: var(--ink); text-align: left; white-space: nowrap; }
.context-menu button:hover:not([disabled]), .context-menu button:focus-visible { background: var(--accent-soft); outline: none; filter: none; }
.context-menu button[disabled] { color: var(--muted); cursor: default; opacity: 1; }

#toast { position: fixed; bottom: 16px; right: 16px; z-index: 1100; max-width: 480px; padding: 10px 14px; border-radius: 8px; background: var(--ink); color: #fff; white-space: pre-line; }
#toast[hidden] { display: none; }

/* Popup "Kontakt aus Clipboard" */
#clip-dialog { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 18px 22px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(20, 25, 35, .25); }
#clip-dialog::backdrop { background: rgba(20, 25, 35, .35); }
#clip-dialog h2 { margin: 0 0 4px; font-size: 18px; }
#clip-info { margin: 0 0 12px; font-size: 13px; }
.clip-fields { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; align-items: center; }
.clip-fields label { font-size: 13px; color: var(--muted); }
.clip-fields input { font: inherit; font-size: 14px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 4px; min-width: 0; }
.clip-fields input:focus { border-color: var(--accent); outline: none; }
.clip-fields input.extracted { background: #e3f4ea; border-color: #9fd3b4; }
#clip-source { margin-top: 12px; font-size: 13px; }
#clip-source summary { cursor: pointer; color: var(--muted); }
#clip-text { display: block; width: 100%; box-sizing: border-box; margin: 6px 0; font: 12px/1.4 Consolas, monospace; padding: 6px; border: 1px solid var(--line); border-radius: 4px; resize: vertical; }
.clip-warning { margin: 10px 0 0; padding: 6px 10px; border-radius: 6px; background: var(--warnbg); color: var(--warn); font-size: 13px; }
.clip-warning[hidden] { display: none; }
.clip-actions { display: flex; gap: 10px; margin-top: 16px; }
@media (max-width: 520px) { .clip-fields { grid-template-columns: 1fr; } }

/* Popup "Add Photo" */
#photo-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 18px 22px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(20, 25, 35, .25); }
#photo-dialog::backdrop { background: rgba(20, 25, 35, .35); }
#photo-dialog h2 { margin: 0 0 4px; font-size: 18px; }
#photo-info { margin: 0 0 8px; font-size: 13px; }
.photo-section { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.photo-section h3 { margin: 0 0 8px; font-size: 14px; }
.photo-section .clip-actions { margin-top: 10px; }
.photo-section p { margin: 0 0 8px; font-size: 13px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; max-height: 300px; overflow: auto; }
.photo-grid:empty { display: none; }
.photo-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 2px solid var(--line); border-radius: 6px;
  background: var(--card); cursor: pointer; font: inherit; font-size: 11px; color: var(--ink); }
.photo-item img { width: 96px; height: 96px; object-fit: cover; border-radius: 4px; background: #f2f3f5; }
.photo-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-item.current { border-color: #9fd3b4; }

/* Popup "History" */
#history-dialog { width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 18px 22px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(20, 25, 35, .25);
  resize: both; overflow: hidden; min-width: 520px; min-height: 340px; box-sizing: border-box; }
/* Groesse per Ziehen an der rechten unteren Ecke; die Tabelle der Eintraege nimmt die restliche Hoehe */
#history-dialog[open] { display: flex; flex-direction: column; }
#history-form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
#history-dialog::backdrop { background: rgba(20, 25, 35, .35); }
#history-dialog h2 { margin: 0 0 4px; font-size: 18px; }
#history-info { margin: 0 0 12px; font-size: 13px; }
.history-add { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 12px; }
.history-add input, .history-add textarea { font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; }
.history-add textarea { flex: 1; resize: vertical; }
.history-wrap { flex: 1 1 auto; min-height: 80px; max-height: none; }
.history-table td { vertical-align: top; }
.history-table td.history-id { padding: 5px 8px; color: var(--muted); font-size: 12px; }
.history-table input[type="datetime-local"], .history-table textarea { font: inherit; font-size: 13px; padding: 2px 4px; border: 1px solid transparent; border-radius: 4px; background: transparent; }
.history-table textarea { width: 100%; box-sizing: border-box; min-width: 30ch; resize: vertical; white-space: pre-wrap; }
.history-table input:hover, .history-table textarea:hover { border-color: var(--line); }
.history-table input:focus, .history-table textarea:focus { border-color: var(--accent); background: var(--card); outline: none; }
.history-table .saved { background: #e3f4ea; }
.history-table tr.dirty td.history-id { color: var(--warn); font-weight: 600; }
.history-table .history-delete { visibility: visible; }
.history-table .history-delete:hover { color: var(--error); border-color: var(--error); }
.history-file { margin: 10px 0 0; font-size: 12px; }
.photo-item[aria-selected="true"] { border-color: var(--accent); background: #eef3fb; }
.photo-clip { display: flex; align-items: center; justify-content: center; min-height: 120px; padding: 8px; border: 2px dashed var(--line); border-radius: 6px; }
.photo-clip:focus { border-color: var(--accent); outline: none; }
.photo-clip img { max-width: 100%; max-height: 240px; }

/* Popup "Add Outlook Folder" */
#outlook-dialog { width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 18px 22px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(20, 25, 35, .25); }
#outlook-dialog::backdrop { background: rgba(20, 25, 35, .35); }
#outlook-dialog h2 { margin: 0 0 4px; font-size: 18px; }
#outlook-info { margin: 0 0 12px; font-size: 13px; }
.outlook-wrap { max-height: calc(100vh - 260px); }
.outlook-table td { padding: 5px 8px; vertical-align: top; }
.outlook-table td.note { white-space: normal; min-width: 240px; color: var(--warn); font-size: 12px; }
.outlook-table .status { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 9px; font-size: 11px; line-height: 17px; }
.status.exists, .status.skipped { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.status.create { background: var(--accent-soft); color: var(--accent); }
.status.created { background: #e3f4ea; color: #1d6b3d; }
.status.error { background: var(--errorbg); color: var(--error); }

/* Aktionsprotokoll im Popup "Add Outlook Folder" */
#outlook-log-box { margin-top: 12px; font-size: 13px; }
#outlook-log-box summary { cursor: pointer; font-weight: 600; }
.action-log { list-style: none; margin: 6px 0; padding: 6px 8px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); font: 12px/1.45 Consolas, monospace; }
.action-log li { padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
.action-log .time { color: var(--muted); margin-right: 6px; }
.action-log .level { display: inline-block; min-width: 44px; font-weight: 600; text-transform: uppercase; font-size: 10px; }
.action-log .info .level { color: var(--muted); }
.action-log .ok .level { color: #1d6b3d; }
.action-log .warn .level, .action-log .warn .text { color: var(--warn); }
.action-log .error .level, .action-log .error .text { color: var(--error); }
.action-log .detail { display: block; margin: 1px 0 3px 106px; color: var(--error); }

/* --- n-dimensions-workspace: Anmeldung, Benutzer in der Kopfzeile, Links als Buttons --- */
.userbox { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; }
button.link-light { background: none; border: 1px solid rgba(255, 255, 255, .6); color: #fff; padding: 2px 10px; font-size: 13px; }
.login-wrap { max-width: 420px; }
.login-card { margin-top: 40px; }
.login-card .field { margin-bottom: 14px; }
.login-card input { width: 100%; }
a.button, label.button { display: inline-block; text-decoration: none; border-radius: 4px; border: 1px solid var(--accent); }
a.button.secondary { background: #fff; color: var(--accent); padding: 3px 10px; font-size: 13px; }
a.button.tool, label.button.tool { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px 12px; font-size: 14px; }
a.button:hover { filter: brightness(1.08); }
a.button.tool:hover, label.button.tool:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.resource-table td { vertical-align: middle; }
.resource-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0; }
input[type="password"] { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); color: var(--ink); }
label.file-pick { cursor: pointer; margin: 0; }

/* --- Arbeitsbereiche: Unter-Navigation --- */
.subnav { background: var(--accent-soft); border-bottom: 1px solid var(--line); padding: 7px 20px; }
.subnav .wrap { display: flex; gap: 18px; font-size: 14px; }
.subnav a { color: var(--accent); text-decoration: none; }
.subnav a:hover, .subnav a[aria-current="page"] { text-decoration: underline; font-weight: 600; }

/* --- Benutzerverwaltung und CLASSROOM --- */
[hidden] { display: none !important; }
main.wrap.narrow { max-width: 760px; }
dialog.form-dialog { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 18px 22px; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 40px rgba(20, 25, 35, .25); }
dialog.form-dialog.wide-dialog { width: min(980px, calc(100vw - 32px)); }
dialog.form-dialog::backdrop { background: rgba(20, 25, 35, .35); }
dialog.form-dialog h2 { margin: 0 0 8px; font-size: 18px; border: none; }
dialog.form-dialog .field { margin-bottom: 10px; }
.form-dialog input[type="text"], .form-dialog input[type="password"], .form-dialog input[type="number"], .form-dialog input[type="search"], .form-dialog textarea, .form-dialog select { width: 100%; box-sizing: border-box; }
input[type="number"], input[type="time"], input[type="search"], textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); }
.card textarea, .card input[type="text"] { box-sizing: border-box; }
.card .field textarea { width: 100%; }
.status { display: inline-block; padding: 0 7px; border-radius: 9px; font-size: 11px; line-height: 18px; }
.data-table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--card); }
.data-table th, .data-table td { text-align: left; vertical-align: middle; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.data-table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.data-table td.num, .data-table th.num { text-align: right; }
.data-table td.center { text-align: center; color: #1d6b3d; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * { margin-left: 4px; }
.inline-input { font: inherit; padding: 3px 6px; border: 1px solid transparent; border-radius: 4px; background: transparent; width: 100%; box-sizing: border-box; }
.inline-input:hover { border-color: var(--line); }
.inline-input:focus { border-color: var(--accent); background: #fff; outline: none; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 2px solid var(--line); margin: 10px 0 16px; }
.tabs button { background: none; color: var(--muted); border: none; border-bottom: 3px solid transparent; border-radius: 0; padding: 8px 14px; margin-bottom: -2px; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel fieldset { margin: 14px 0; }
button.danger { color: var(--error) !important; }
.secret { font-size: 15px; padding: 2px 8px; background: var(--accent-soft); border-radius: 4px; letter-spacing: .05em; }
.pre-line { white-space: pre-line; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; }
.tile.archived { opacity: .6; }
.course-card h3 { font-size: 14px; margin: 16px 0 6px; color: var(--muted); }
.question { margin: 12px 0; }
.question-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.question-head select { width: auto; }
.question-head input[type="number"] { width: 70px; }
.question textarea { width: 100%; box-sizing: border-box; margin-bottom: 8px; }
.option-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.option-row .inline-check { margin: 0; white-space: nowrap; }
.option-row input[type="text"] { flex: 1; }
fieldset.question legend { font-size: 14px; color: var(--ink); }
.answer { display: flex; gap: 8px; align-items: flex-start; padding: 6px 4px; border-radius: 4px; cursor: pointer; }
.answer:hover { background: var(--accent-soft); }
fieldset.question.correct { border-color: #2f8a42; background: #f1faf3; }
fieldset.question.wrong { border-color: var(--error); background: #fdf3f3; }
.feedback { font-weight: 600; font-size: 13px; margin-top: 4px; }
.correct .feedback { color: #1d6b3d; }
.wrong .feedback { color: var(--error); }
#user-select { width: 100%; margin: 6px 0; font: inherit; }
.roles-box { margin: 10px 0; }
.role-grid th.center-head, .role-grid td.center { text-align: center; }
.role-grid td.center input { width: 18px; height: 18px; }
.roles-overview td { vertical-align: top; font-size: 13px; }
.role-checks { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.role-checks .inline-check { margin: 0; }

.contact-box { margin: 0 0 12px; }
.contact-modes { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 8px; }
.contact-modes .inline-check { margin: 0; }
#contact-select { width: 100%; margin: 6px 0 0; font: inherit; }

/* --- Passwortfelder: Generate / Show / Copy --- */
.pw-wrap { display: flex; gap: 6px; align-items: center; }
.pw-wrap input { flex: 1; min-width: 0; font-family: Consolas, "Courier New", monospace; }
.pw-wrap button.pw-button { flex: none; padding: 4px 9px; font-size: 13px; font-weight: 400; }

/* --- Abgleich Benutzer <-> Kontakte --- */
.sync-wrap { max-height: 55vh; overflow: auto; }
.sync-table td { vertical-align: top; font-size: 13px; }
.sync-table select { width: auto; min-width: 170px; }
.sync-user { background: var(--accent-soft); padding: 0 3px; border-radius: 3px; }
.sync-contact { background: var(--warnbg); padding: 0 3px; border-radius: 3px; }
.sync-direction { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin: 4px 0 10px; padding: 8px 12px; background: var(--accent-soft); border-radius: 6px; }
.sync-direction .inline-check { margin: 0; }

/* --- sortierbare Spaltenkoepfe --- */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--accent); }
th.sortable::after { content: attr(data-arrow); margin-left: 4px; font-size: 11px; color: var(--accent); }
th.sortable[aria-sort="none"]::after { color: var(--muted); opacity: .45; }
th.sortable:hover { text-decoration: underline; }

/* --- DocStatus --- */
.doc-title .status { vertical-align: middle; margin-left: 6px; font-weight: 400; }
.personal-hint { display: block; color: var(--accent); }
