:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --nav: #ffffff;
  --nav-soft: #edf6f2;
  --panel: #ffffff;
  --panel-2: #f4faf7;
  --ink: #25312e;
  --muted: #66736f;
  --line: #d8e5df;
  --accent: #c94f64;
  --accent-2: #0f766e;
  --ok: #25734c;
  --warn: #996b16;
  --danger: #b23b4d;
  --shadow: 0 14px 34px rgba(24, 48, 42, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button, .download { min-height: 46px; border: 0; border-radius: 8px; padding: 0 15px; background: #e7f0ec; color: var(--ink); cursor: pointer; font-weight: 750; touch-action: manipulation; text-decoration: none; }
button:hover { filter: brightness(.97); }
button:active { transform: translateY(1px); }

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  background: #080a0f;
}
.login-screen.hidden { display: none; }
.login-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}
.login-screen:not(.login-revealed) .login-panel { display: none; }
.login-screen.login-revealed {
  padding: 20px;
  background: #eaf3ef;
}
.login-screen.login-revealed .login-cover { display: none; }
.login-panel {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  display: grid;
  gap: 14px;
  padding: 28px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(18, 52, 44, .18);
}
.login-brand { margin-bottom: 4px; }
.login-panel h1 { font-size: 28px; }
.login-panel label { display: grid; gap: 6px; color: var(--muted); font-weight: 800; }
.login-submit { width: 100%; }
.login-setup { display: grid; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #f7fbfa; }
.login-setup.hidden { display: none; }
.login-setup p { color: var(--ink); font-weight: 800; }
.login-error { min-height: 20px; color: var(--danger); font-weight: 800; }
.login-error.success { color: var(--ok); }

aside {
  width: 252px;
  padding: 20px 14px;
  background: var(--nav);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid var(--line);
}
.brandblock { display: flex; align-items: center; gap: 12px; padding: 6px 6px 22px; }
.brandblock strong { display: block; font-size: 16px; line-height: 1.1; }
.brandblock small { color: var(--muted); }
.brand { width: 46px; height: 46px; display: grid; place-items: center; background: #dff4ee; color: var(--accent-2); border-radius: 8px; font-weight: 900; letter-spacing: .04em; border: 1px solid #bfe6dc; }
.nav { width: 100%; min-height: 48px; text-align: left; background: transparent; color: var(--muted); }
.nav.active { background: var(--nav-soft); color: var(--accent-2); }
.nav span { float: right; background: var(--accent); color: white; border-radius: 999px; min-width: 22px; text-align: center; padding: 1px 7px; }
.leitung-only { display: none; }
body.is-leitung .leitung-only { display: block; }
.role { margin-top: auto; display: grid; gap: 8px; font-size: 12px; color: var(--muted); padding: 12px 6px 4px; }
.role select { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
.role strong { padding: 10px 12px; border-radius: 8px; background: var(--nav-soft); color: var(--accent-2); }

main { flex: 1; min-width: 0; }
header { min-height: 82px; padding: 16px 30px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; background: rgba(255, 255, 255, .92); }
h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: 0; }
h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: 0; }
h3 { margin: 0 0 10px; font-size: 14px; }
p { margin: 0; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 10px; }
#syncState { min-width: 88px; padding: 7px 10px; border: 1px solid #cfded8; border-radius: 999px; background: #edf6f1; color: var(--ok); font-size: 12px; font-weight: 800; text-align: center; }
#syncState.busy { background: #fff5d8; color: var(--warn); }

.view { padding: 24px 30px; }
.hidden { display: none; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stats article { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; box-shadow: var(--shadow); }
.stats span { display: block; color: var(--muted); font-size: 12px; font-weight: 750; }
.stats strong { display: block; margin-top: 5px; font-size: 24px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
input, textarea, select { border: 1px solid var(--line); background: white; border-radius: 8px; padding: 13px 13px; outline: none; min-height: 48px; font-size: 16px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px #d8f0e9; }
#search { flex: 1; }
.search-field {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.search-field span {
  text-transform: uppercase;
  letter-spacing: .04em;
}
.search-field input {
  width: 100%;
}
.customer-mode { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 5px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 10px; background: #eaf3ef; }
.mode-option { min-height: 50px; background: transparent; }
.mode-option.active { background: var(--panel); box-shadow: var(--shadow); color: var(--accent); }
.entry-layout { display: grid; grid-template-columns: minmax(520px, 1.2fr) minmax(340px, .8fr); gap: 16px; align-items: start; }
.entry-main, .article-picker { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.entry-main { padding: 22px; }
.article-picker {
  width: auto;
  min-width: 0;
  padding: 18px;
  color: var(--ink);
  display: grid;
  gap: 12px;
  background: var(--panel);
}
.article-results { display: grid; gap: 8px; max-height: calc(100vh - 260px); overflow: auto; padding-right: 2px; }
.article-hit {
  min-height: 82px;
  display: grid;
  gap: 3px;
  align-content: center;
  text-align: left;
  background: white;
  border: 1px solid var(--line);
}
.article-hit span, .article-hit small { color: var(--muted); }
.selected-box { margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: #f7fbfa; }
.selected-articles { display: grid; gap: 8px; }
.selected-article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 120px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.selected-article span { display: block; color: var(--muted); font-size: 12px; }

.split { display: grid; grid-template-columns: minmax(300px, .78fr) minmax(520px, 1.35fr); gap: 16px; align-items: start; }
.list, .detail, .cards article, .helpgrid article { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.list { overflow: hidden; }
.row { width: 100%; min-height: 84px; padding: 15px 16px; background: white; border-bottom: 1px solid var(--line); text-align: left; border-radius: 0; display: grid; gap: 4px; }
.row:last-child { border-bottom: 0; }
.row.active { background: #eef8f4; box-shadow: inset 4px 0 0 var(--accent-2); }
.row strong { font-size: 14px; }
.row small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emptyblock { padding: 18px; color: var(--muted); }

.detail { padding: 22px; min-height: 470px; }
.record-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.eyebrow { display: block; margin-bottom: 5px; color: var(--accent-2); font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.pill { display: inline-flex; padding: 6px 10px; border-radius: 999px; background: #edf4f1; color: var(--muted); font-size: 12px; font-weight: 800; white-space: nowrap; }
.pill.open { background: #fff5d8; color: var(--warn); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.field { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--panel-2); min-height: 62px; overflow-wrap: anywhere; }
.field label { display: block; color: var(--muted); font-size: 11px; font-weight: 800; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.field span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.question-note textarea { width: 100%; min-height: 160px; margin-top: 6px; }
.full { grid-column: 1 / -1; }

.artifact-viewer {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}
.artifact-toolbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f7fbfa;
}
.artifact-toolbar .download {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
.artifact-viewer iframe {
  display: block;
  width: 100%;
  height: min(64vh, 720px);
  min-height: 420px;
  border: 0;
  background: white;
}

.timeline { margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 13px; background: #f7fbfa; }
.timeline ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.timeline li { display: grid; gap: 2px; padding-left: 10px; border-left: 3px solid #b8ded4; }
.timeline li span { color: var(--ink); }
.timeline li small { color: var(--muted); }

.approval-box { display: grid; gap: 10px; margin: 16px 0; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; align-items: start; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.kv span { color: var(--muted); font-size: 12px; font-weight: 800; }
.kv strong { font-weight: 650; overflow-wrap: anywhere; }
.empty { color: var(--muted); padding: 10px 0; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.action-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.decision-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.action-tiles button, .decision-tiles button {
  min-height: 76px;
  padding: 12px 14px;
  display: grid;
  align-content: center;
  gap: 3px;
  text-align: left;
}
.decision-tiles .download {
  min-height: 76px;
  padding: 12px 14px;
  display: grid;
  place-items: center;
  font-size: 16px;
}
.action-tiles span, .decision-tiles span { font-size: 15px; font-weight: 850; }
.action-tiles small, .decision-tiles small { color: inherit; opacity: .72; font-size: 12px; font-weight: 650; }
.primary { background: var(--accent); color: white; }
.danger { background: #fde8ec; color: var(--danger); }
.ok { background: #def1e6; color: var(--ok); }
.warn { background: #fff5d8; color: var(--warn); }

.cards { display: grid; gap: 10px; }
.cards article { padding: 16px; }
.cards article strong { display: block; font-size: 16px; margin-bottom: 4px; }
.audit-detail { margin-top: 10px; display: grid; gap: 7px; }
.audit-detail .kv { grid-template-columns: 130px minmax(0, 1fr); padding: 8px 10px; }

.helpgrid, .exportgrid, .permissions-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.helpgrid article, .exportgrid article, .permissions-grid article { padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.helpgrid ol { margin: 14px 0 0; padding-left: 19px; color: var(--muted); }
.helpgrid li { margin: 7px 0; }
.permissions-grid ul { margin: 14px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.45; }
.permissions-grid li { margin: 9px 0; }
.user-management-head { margin-bottom: 16px; }
.user-list { display: grid; gap: 12px; }
.user-create-form { display: grid; gap: 14px; margin-bottom: 20px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.user-create-form h3 { margin: 0; }
.user-search { display: grid; gap: 6px; margin-bottom: 12px; color: var(--muted); font-weight: 800; }
.user-search input { width: 100%; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.user-table { width: 100%; min-width: 720px; border-collapse: collapse; background: var(--panel); }
.user-table th, .user-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.user-table th { background: var(--nav-soft); color: var(--muted); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.user-table tr:last-child td { border-bottom: 0; }
.user-table button { margin: 2px 6px 2px 0; }
.user-card { display: grid; grid-template-columns: minmax(180px, 1.5fr) minmax(180px, 1fr) auto; gap: 14px; align-items: center; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.user-card.pending { border-color: #e7c675; background: #fffdf5; }
.user-identity { display: grid; gap: 4px; }
.user-identity small { color: var(--muted); }
.user-status { display: inline-block; width: max-content; padding: 4px 9px; border-radius: 999px; background: #fff2cf; color: var(--warn); font-size: 12px; font-weight: 800; }
.user-status.approved { background: #e6f5ec; color: var(--ok); }
.user-role { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 800; }
.user-card button { min-width: 140px; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 28px));
  padding: 14px 16px;
  border-radius: 10px;
  background: #25312e;
  color: white;
  box-shadow: 0 20px 50px rgba(0,0,0,.24);
  font-weight: 750;
}

.manual-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 45;
  min-height: 54px;
  padding: 0 18px;
  border: 2px solid #0f5f2f;
  border-radius: 8px;
  background: #39ff14;
  color: #102514;
  box-shadow: 0 18px 45px rgba(14, 74, 32, .28);
  font-size: 16px;
  font-weight: 900;
}

.manual-bubble {
  position: fixed;
  right: 18px;
  bottom: 86px;
  z-index: 50;
  width: min(760px, calc(100vw - 36px));
  max-height: min(720px, calc(100dvh - 112px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border: 2px solid #e7d064;
  border-radius: 8px;
  background: #fffdf2;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(30, 27, 24, .28);
}
.manual-bubble.dragging {
  box-shadow: 0 28px 90px rgba(30, 27, 24, .34);
}

.manual-bubble::after {
  content: "";
  position: absolute;
  right: 42px;
  bottom: -14px;
  width: 26px;
  height: 26px;
  background: #fffdf2;
  border-right: 2px solid #e7d064;
  border-bottom: 2px solid #e7d064;
  transform: rotate(45deg);
}

.manual-head {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 42px;
  gap: 12px;
  align-items: center;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #eadf9f;
  cursor: move;
  user-select: none;
}

.manual-head h2 { font-size: 20px; margin: 0 0 3px; }
.manual-head p { font-size: 14px; }
.manual-lamp {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ffe873;
  border: 1px solid #e1bd24;
  font-size: 28px;
}

.manual-close {
  min-height: 42px;
  width: 42px;
  padding: 0;
  border-radius: 8px;
  background: #f1e7aa;
  font-size: 24px;
  line-height: 1;
}

.manual-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #eadf9f;
}

.manual-choice button {
  min-height: 58px;
  text-align: left;
  background: #f4edc5;
  border: 1px solid #eadf9f;
}

.manual-choice button.active {
  background: #25312e;
  color: white;
}

.manual-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(220px, .9fr) minmax(300px, 1.25fr);
}

.manual-topics {
  display: grid;
  align-content: start;
  gap: 4px;
  max-height: 100%;
  overflow: auto;
  padding: 12px;
  border-right: 1px solid #eadf9f;
}

.manual-topic {
  min-height: 46px;
  padding: 8px 10px;
  background: transparent;
  color: #39514a;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
  border-radius: 8px;
}

.manual-topic:hover {
  background: #fff4b8;
  color: #0f5f2f;
}

.manual-topic.active {
  background: #e4f8da;
  color: #164b27;
  box-shadow: inset 4px 0 0 #39a846;
}

.manual-content {
  min-height: 0;
  overflow: auto;
  padding: 18px 20px 22px;
  font-size: 16px;
  line-height: 1.5;
}

.manual-content h3 {
  margin: 0 0 12px;
  font-size: 22px;
}

.manual-content p {
  color: var(--ink);
  max-width: 62ch;
}

.manual-content ol {
  margin: 0;
  padding-left: 24px;
}

.manual-content li {
  margin: 0 0 10px;
  padding-left: 3px;
}

.manual-button.hidden,
.manual-bubble.hidden {
  display: none;
}

dialog { border: 0; border-radius: 10px; padding: 0; width: min(780px, calc(100vw - 30px)); max-height: calc(100vh - 30px); overflow: auto; box-shadow: 0 25px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(30, 27, 24, .36); }
dialog form { padding: 24px; }
.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.formgrid label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
textarea { min-height: 90px; resize: vertical; }
menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 18px 0 0; }

@media (max-width: 900px) {
  body { display: block; }
  aside { position: sticky; top: 0; z-index: 10; width: auto; display: grid; grid-template-columns: auto repeat(8, minmax(max-content, 1fr)) auto; align-items: center; overflow-x: auto; padding: 10px; gap: 6px; }
  .brandblock { padding: 4px 10px 4px 4px; }
  .brand { width: 40px; height: 40px; }
  .nav { width: auto; min-width: max-content; padding: 0 14px; background: var(--nav-soft); text-align: center; }
  .role { margin: 0 0 0 auto; min-width: 220px; padding: 0; }
  .role label { display: none; }
  .split, .entry-layout, .helpgrid, .exportgrid, .permissions-grid, .stats { grid-template-columns: 1fr; }
  .article-results { max-height: none; }
  header { align-items: flex-start; gap: 12px; flex-direction: column; }
  .view { padding: 18px; }
  .kv { grid-template-columns: 1fr; gap: 3px; }
}

@media (max-width: 640px) {
  aside { grid-template-columns: 1fr 1fr; align-items: stretch; overflow: visible; }
  .brandblock { grid-column: 1 / -1; min-width: 0; padding: 2px 4px 8px; }
  .brandblock strong { font-size: 14px; }
  .brandblock small { display: block; }
  .nav { min-width: 0; min-height: 48px; }
  .role { grid-column: 1 / -1; min-width: 0; }
  .user-card { grid-template-columns: 1fr; align-items: stretch; }
  header { padding: 14px 16px; }
  h1 { font-size: 23px; }
  h2 { font-size: 20px; }
  .header-actions { width: 100%; justify-content: space-between; }
  .view { padding: 14px; }
  .stats { gap: 8px; }
  .stats article { padding: 11px 12px; }
  .stats strong { font-size: 20px; }
  .toolbar { flex-direction: column; }
  .search-field { width: 100%; }
  .customer-mode { grid-template-columns: 1fr; }
  .toolbar button, .actions button, menu button { width: 100%; }
  .detail { padding: 16px; min-height: 0; }
  .record-head { display: grid; gap: 10px; }
  .grid, .formgrid { grid-template-columns: 1fr; }
  .new-form { grid-template-columns: 1fr; }
  .selected-article { grid-template-columns: 1fr; }
  .actions, .action-tiles, .decision-tiles { display: grid; grid-template-columns: 1fr; }
  .action-tiles button, .decision-tiles button { min-height: 70px; text-align: center; }
  .artifact-toolbar { align-items: stretch; flex-direction: column; }
  .artifact-toolbar .download { justify-content: center; }
  .artifact-viewer iframe { min-height: 360px; height: 56vh; }
  dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 8px; }
  dialog form { padding: 18px; }
  menu { display: grid; grid-template-columns: 1fr; }
  .toast { left: 14px; right: 14px; bottom: 14px; }
  .manual-button { left: 14px; right: 14px; bottom: 14px; width: auto; }
  .manual-bubble { left: 10px; right: 10px; bottom: 82px; width: auto; max-height: calc(100dvh - 94px); }
  .manual-head { grid-template-columns: 46px minmax(0, 1fr) 40px; }
  .manual-lamp { width: 46px; height: 46px; font-size: 24px; }
  .manual-choice, .manual-body { grid-template-columns: 1fr; }
  .manual-topics { max-height: 220px; border-right: 0; border-bottom: 1px solid #eadf9f; }
}
