@font-face { font-family: "Archivo"; font-weight: 600; font-display: swap; src: url("/static/fonts/archivo-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 700; font-display: swap; src: url("/static/fonts/archivo-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 400; font-display: swap; src: url("/static/fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible Next"; font-weight: 600; font-display: swap; src: url("/static/fonts/atkinson-hyperlegible-next-latin-600-normal.woff2") format("woff2"); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 17px; line-height: 1.5;
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 17px; font-weight: 600; }
a { color: var(--focus); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.mono, code { font-family: var(--font-mono); font-size: .92em; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Aufbau: Handy = Inhalt + untere Leiste; Desktop = linke Leiste + Inhalt */
.shell { min-height: 100vh; }
.main { padding: 12px 16px calc(150px + env(safe-area-inset-bottom, 0px)); margin: 0 auto; width: 100%; }
.topbar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  border-bottom: 1px solid var(--line);
}
.top-logo { max-height: 30px; max-width: 120px; width: auto; height: auto; flex: none; object-fit: contain; }
.nav-logo { display: none; }
.doc-logo { max-height: 60px; max-width: 220px; width: auto; height: auto; object-fit: contain; }
.logo-preview { max-height: 128px; max-width: 100%; background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.topbar h1 { flex: 1; min-width: 0; font-size: 20px; overflow-wrap: anywhere; }
.nav {
  position: fixed; left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 6; display: flex; gap: 2px; padding: 6px;
  background: var(--nav); border-radius: 999px; box-shadow: 0 10px 24px rgba(0, 0, 0, .25);
}
.nav .brand { display: none; }
/* Handy: Symbol über Beschriftung. Sieben Punkte bei 360 px: 360 - 2*8 (Rand) - 2*4 (Innenabstand) = 336 px, gap 0, 336 / 7 = 48 px je Fläche (>= 44 px);
   ab 420 px: 420 - 2*16 - 2*6 - 6*2 = 364 px / 7 = 52 px. Unter 480 px bleiben nur Symbole sichtbar (siehe unten). */
.nav a, .nav .navbtn {
  flex: 1; min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border-radius: 999px;
  color: var(--navfg); text-decoration: none; font-family: var(--font-display); font-weight: 600; font-size: 12px;
}
.nav .navtoggle { display: none; }
.icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.nav a[aria-current="page"] { color: var(--tape); }
.nav .label { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav a:focus-visible, .nav .navbtn:focus-visible { outline: 3px solid var(--nav-focus); outline-offset: -3px; }
/* Grundregeln stehen vor dem Desktop-Block (min-width: 1100px): gleiche Spezifität, spätere Regel gewinnt. */
.nav form { flex: 1; min-width: 0; display: flex; margin: 0; }
.nav .navbtn { border: 0; background: none; padding: 0; }
.topbar .tb-tools, .topbar .tb-lbl { display: none; }
.topbar .tb-icon { min-width: 44px; min-height: 44px; padding: 0; flex: none; }
.topbar .tb-user { display: inline-flex; align-items: center; gap: 6px; }

/* Suchoverlay (JS baut es auf); über dem Vollbild-Editor (200) und dessen Dialogen (300) */
.so-backdrop { position: fixed; inset: 0; z-index: 400; background: rgba(27, 36, 48, .55); display: flex; align-items: flex-start; justify-content: center; padding: calc(8vh + env(safe-area-inset-top, 0px)) 12px 12px; }
.so-backdrop[hidden] { display: none; }
.so-dialog { width: 100%; max-width: 640px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.so-dialog input[type="search"] { width: 100%; min-height: 52px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); font: inherit; padding: 0 16px; }
.so-results { overflow-y: auto; overflow-x: hidden; padding: 6px; }
.so-hit { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.so-hit:hover, .so-hit:focus-visible { background: var(--bg); }
.so-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.so-title { font-weight: 600; overflow-wrap: anywhere; }
.so-snip { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.so-label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.so-all { font-weight: 600; color: var(--focus); }
.so-empty { margin: 0; padding: 14px 12px; color: var(--muted); }

/* Einsatzband: einziges auffälliges Element */
.tape {
  position: fixed; left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 7;
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 22px;
  background: var(--tape); color: var(--ink-on-tape);
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 10px 100%, 0 50%);
  animation: tape-in .25s ease-out;
}
.tape .who { flex: 1; min-width: 0; font-family: var(--font-display); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tape .time { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; }
.tape button { background: var(--ink-on-tape); color: var(--tape); border-color: transparent; min-height: 40px; }
@keyframes tape-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Zeilen (eine Höheneinheit) */
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 14px;
  border-top: 1px solid var(--line); color: inherit; text-decoration: none;
}
.row:first-child { border-top: 0; }
a.row:hover { background: var(--bg); }
.row .main-col { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.row .value { font-family: var(--font-mono); font-size: 15px; text-align: right; overflow-wrap: anywhere; }

/* Bedienelemente */
button, .btn {
  min-height: 44px; padding: 0 16px; font: inherit; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none;
}
button.primary, .btn.primary { background: var(--tape); color: var(--ink-on-tape); border-color: var(--tape); }
button.danger { color: var(--bad); }
button[aria-pressed="true"] { background: var(--tape); color: var(--ink-on-tape); border-color: var(--ink-on-tape); box-shadow: inset 0 0 0 2px var(--ink-on-tape); }
.plainlist { list-style: none; margin: 0; padding: 0; }
.plainlist a { display: flex; align-items: center; min-height: 44px; }
button:disabled { opacity: .5; cursor: default; }
label { display: block; margin: 14px 0; font-weight: 600; font-size: 15px; }
label > input, label > select, label > textarea { margin-top: 6px; font-weight: 400; }
input, select, textarea {
  display: block; width: 100%; min-height: 46px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
textarea { min-height: 140px; resize: vertical; }
.hint { color: var(--muted); font-size: 15px; margin-top: 4px; font-weight: 400; }
.error { background: var(--surface); border: 1px solid var(--bad); border-left-width: 6px; border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.empty { text-align: center; padding: 40px 12px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.empty .btn { margin-top: 12px; }
.stack > * + * { margin-top: 16px; }
.login { max-width: 420px; margin: 0 auto; padding: 32px 16px; }

/* Hilfeblatt: unten am Handy, Seitenfeld am PC */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; max-height: 70vh; overflow: auto; background: var(--surface); border-top: 1px solid var(--line); padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
.sheet[hidden] { display: none; }

@media (min-width: 1100px) {
  /* Titelzeile (Zeile 1) läuft über Liste und Akte; die Menüleiste belegt beide Zeilen. */
  .shell { --titlebar-h: 57px; display: grid; grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .shell.has-list { grid-template-columns: 220px 300px minmax(0, 1fr); }
  .shell.nav-collapsed { grid-template-columns: 64px minmax(0, 1fr); }
  .shell.nav-collapsed.has-list { grid-template-columns: 64px 300px minmax(0, 1fr); }
  .nav {
    position: sticky; top: 0; left: auto; right: auto; bottom: auto; height: 100vh; flex-direction: column; gap: 2px;
    border-radius: 0; box-shadow: none; padding: 16px 10px; grid-column: 1; grid-row: 1 / -1;
  }
  .top-logo { display: none; }
  .nav .nav-logo { display: block; max-height: 32px; max-width: 160px; width: auto; margin: 0 12px 10px; object-fit: contain; align-self: flex-start; }
  .shell.nav-collapsed .nav .nav-logo { display: none; }
  .nav .brand { display: block; padding: 0 12px 14px; color: var(--tape); font-family: var(--font-display); font-weight: 700; font-size: 18px; }
  .nav .navtoggle { display: flex; align-items: center; justify-content: center; align-self: flex-end; width: 44px; min-height: 44px; padding: 0; margin-bottom: 6px; border: 0; background: none; color: var(--navfg); border-radius: 10px; }
  .nav .navtoggle:focus-visible { outline: 3px solid var(--nav-focus); outline-offset: -3px; }
  .shell.nav-collapsed .nav .navtoggle .icon { transform: scaleX(-1); }
  .nav a, .nav .navbtn { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; min-height: 44px; border-radius: 10px; font-size: 14px; width: 100%; }
  .nav a[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-focus); }
  .nav .nav-end { margin-top: auto; }
  .nav form { flex: none; }
  .shell.nav-collapsed .nav { padding: 16px 10px; }
  .shell.nav-collapsed .nav .brand { display: none; }
  .shell.nav-collapsed .nav .navtoggle { align-self: center; }
  .shell.nav-collapsed .nav a, .shell.nav-collapsed .nav .navbtn { justify-content: center; padding: 0; }
  .shell.nav-collapsed .nav .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar { grid-column: 2 / -1; grid-row: 1; height: var(--titlebar-h); padding-top: 10px; }
  .topbar .tb-tools { display: flex; align-items: center; gap: 4px; }
  .topbar .tb-tools form { margin: 0; }
  .topbar .tb-user { margin-left: 8px; color: var(--ink); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
  .topbar .tb-user:hover { text-decoration: underline; }
  .topbar .tb-lbl { display: inline; margin-left: 6px; }
  .topbar .tb-icon { min-width: 36px; min-height: 36px; }
  .content { grid-column: 2; grid-row: 2; }
  .shell.has-list .content { grid-column: 3; }
  .main { padding-bottom: 32px; }
  .tape { left: 240px; right: 24px; bottom: 24px; }
  .shell.has-list ~ .tape { left: 540px; }
  .shell.nav-collapsed ~ .tape { left: 84px; }
  .shell.nav-collapsed.has-list ~ .tape { left: 384px; }
  .sheet { left: auto; top: 0; width: 360px; max-height: none; border-left: 1px solid var(--line); border-top: 0; }
  body { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none; animation: none; scroll-behavior: auto; }
}

@media (max-width: 479px) {
  .nav .label, .shell.nav-collapsed .nav .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav a, .nav .navbtn { min-height: 44px; }
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.searchbar { display: flex; gap: 8px; margin-bottom: 14px; }
.searchbar input { flex: 1; }
.checks label { display: flex; align-items: center; gap: 10px; font-weight: 400; margin: 6px 0; }
.checks input { width: 24px; min-height: 24px; margin: 0; }
.details { display: grid; gap: 4px; margin: 0 0 16px; }
.details dt { color: var(--muted); font-size: 15px; }
.details dd { margin: 0 0 8px; overflow-wrap: anywhere; white-space: pre-wrap; }
.startvisit { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 8px 0 16px; }
.startvisit label { margin: 0; flex: 1; min-width: 180px; }
.row .sub { white-space: pre-line; }
.tabs { display: flex; gap: 4px; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; border-bottom: 1px solid var(--line); margin: 8px 0 16px; }
.tabs a { flex: none; min-height: 44px; display: flex; align-items: center; padding: 0 14px; color: var(--muted); text-decoration: none; font-family: var(--font-display); font-weight: 600; }
.tabs a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -3px 0 var(--tape); }
.device { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 14px; }
.device h3 { font-size: 18px; }
.person { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 14px; }
.person h3 { font-size: 18px; display: flex; align-items: center; gap: 10px; }
.initials { width: 40px; height: 40px; font-size: 14px; }
.copy { min-height: 36px; padding: 0 10px; font-size: 14px; }
.cred { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 14px; }
.reveal { margin-top: 10px; }
.reveal .pw { font-family: var(--font-mono); font-size: 18px; overflow-wrap: anywhere; user-select: all; }
.reveal .bar { height: 4px; background: var(--tape); width: 100%; transform-origin: left; margin-top: 8px; }
.reveal .bar.run { animation: drain 30s linear forwards; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.reveal .msg { color: var(--bad); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.photos figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.photos img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photos figcaption { padding: 8px 10px; font-size: 15px; overflow-wrap: anywhere; }
.photos figcaption form { margin-top: 6px; }
.row form { margin: 0; }
mark { background: var(--tape); color: var(--ink-on-tape); padding: 0 2px; border-radius: 2px; }
.steps { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 16px; }
.steps ul { list-style: none; margin: 8px 0; padding: 0; }
.step { display: flex; justify-content: space-between; gap: 12px; min-height: 44px; align-items: center; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; }
.step.done span { color: var(--muted); text-decoration: line-through; }
.readable { max-width: 80ch; }
.article { max-width: 70ch; }
.actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0; }
.actions-row .sep { width: 1px; align-self: stretch; min-height: 24px; background: var(--line); margin: 0 4px; }
.details a, .people a { color: inherit; text-decoration: underline; }
.article h2 { margin-top: 24px; font-size: 20px; }
.tablewrap { overflow-x: auto; }
.auditlog { width: 100%; border-collapse: collapse; font-size: 15px; }
.auditlog th, .auditlog td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }

/* Kundenakte V2: Avatare, Firmenkopf, Kennzahlen, Zeitleiste, Firmenspalte */
.avatar { flex: none; display: inline-grid; place-items: center; border-radius: 50%; font-family: var(--font-display); font-weight: 700; line-height: 1; }
.av-1 { background: var(--av1-bg); color: var(--av1-fg); }
.av-2 { background: var(--av2-bg); color: var(--av2-fg); }
.av-3 { background: var(--av3-bg); color: var(--av3-fg); }
.av-4 { background: var(--av4-bg); color: var(--av4-fg); }
.content { min-width: 0; }
.firmhead { display: flex; align-items: center; gap: 12px; margin: 8px 0 12px; }
.head-av { width: 48px; height: 48px; font-size: 17px; background: var(--tape); color: var(--ink-on-tape); }
.firmhead small { display: block; font-size: 14px; }
.firmname { font-size: 24px; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 12px; padding: 10px 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.stats > div { text-align: center; border-left: 1px solid var(--line); min-width: 0; }
.stats > div:first-child { border-left: 0; }
.stats b { display: block; font-family: var(--font-display); font-size: 20px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 14px; color: var(--muted); }
.people { display: grid; grid-template-columns: 1fr; gap: 12px; }
.person h3 { align-items: center; }
.tl { list-style: none; margin: 12px 0 0; padding: 0 0 0 22px; position: relative; }
.tl::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.ev { position: relative; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.ev::before { content: ""; position: absolute; left: -22px; top: 18px; width: 14px; height: 14px; border-radius: 50%; background: var(--tape); border: 2px solid var(--bg); }
.evbody { display: block; min-height: 56px; padding: 10px 14px; color: inherit; text-decoration: none; border-radius: 16px; }
.evbody strong { display: block; font-family: var(--font-display); overflow-wrap: anywhere; }
.evbody small { display: block; color: var(--muted); font-size: 15px; white-space: pre-line; overflow-wrap: anywhere; }
.evdur { display: block; font-family: var(--font-mono); font-size: 15px; margin-top: 2px; }
a.evbody:hover { background: var(--bg); }
.listcol { display: none; background: var(--bg); }
.listsearch { margin-bottom: 10px; }
.firmlist { list-style: none; margin: 0; padding: 0; }
.firmlist .it { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px; border-radius: 14px; border: 1px solid transparent; color: inherit; text-decoration: none; }
.firmlist .it:hover { background: var(--surface); }
.firmlist .it.on { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }
.firmlist .avatar { width: 36px; height: 36px; font-size: 13px; }
.firmlist .it-main { min-width: 0; }
.firmlist b { display: block; font-family: var(--font-display); overflow-wrap: anywhere; }
.firmlist small { display: block; color: var(--muted); font-size: 14px; }
@media (min-width: 1100px) {
  .listcol { display: block; grid-column: 2; grid-row: 2; position: sticky; top: var(--titlebar-h); height: calc(100vh - var(--titlebar-h)); overflow-y: auto; padding: 16px 10px; border-right: 1px solid var(--line); }
  .people { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 419px) {
  .nav { gap: 0; padding: 4px; left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); }
  .nav a, .nav .navbtn { padding: 0 1px; }
}

/* Doku-Text */
.doc-body { overflow-wrap: anywhere; }
.doc-body img.doc-photo { display: block; max-width: 100%; height: auto; border-radius: var(--radius); margin: 8px 0; }
.doc-body table { border-collapse: collapse; display: block; overflow-x: auto; }
.doc-body th, .doc-body td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.doc-body pre { overflow-x: auto; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
/* Formate im Doku-Text: Ausrichtung, unterstrichen, markiert, Aufgabenkästchen */
.doc-body .al-links, .editor-preview .al-links { text-align: left; }
.doc-body .al-zentriert, .editor-preview .al-zentriert { text-align: center; }
.doc-body .al-rechts, .editor-preview .al-rechts { text-align: right; }
.doc-body .al-blocksatz, .editor-preview .al-blocksatz { text-align: justify; hyphens: auto; }
/* Textfarbe und -größe aus der Blockmarke (::: zentriert rot gross): nur feste Klassen, Farben aus den Tokens */
.doc-body .tc-rot, .editor-preview .tc-rot { color: var(--tc-rot); }
.doc-body .tc-orange, .editor-preview .tc-orange { color: var(--tc-orange); }
.doc-body .tc-gruen, .editor-preview .tc-gruen { color: var(--tc-gruen); }
.doc-body .tc-blau, .editor-preview .tc-blau { color: var(--tc-blau); }
.doc-body .tc-grau, .editor-preview .tc-grau { color: var(--tc-grau); }
.doc-body .tc-rot :is(h1, h2, h3), .editor-preview .tc-rot :is(h1, h2, h3) { color: var(--tc-rot); }
.doc-body .tc-orange :is(h1, h2, h3), .editor-preview .tc-orange :is(h1, h2, h3) { color: var(--tc-orange); }
.doc-body .tc-gruen :is(h1, h2, h3), .editor-preview .tc-gruen :is(h1, h2, h3) { color: var(--tc-gruen); }
.doc-body .tc-blau :is(h1, h2, h3), .editor-preview .tc-blau :is(h1, h2, h3) { color: var(--tc-blau); }
.doc-body .tc-grau :is(h1, h2, h3), .editor-preview .tc-grau :is(h1, h2, h3) { color: var(--tc-grau); }
.doc-body .ts-klein, .editor-preview .ts-klein { font-size: 0.875em; --ts-k: 0.875; }
.doc-body .ts-gross, .editor-preview .ts-gross { font-size: 1.25em; --ts-k: 1.25; }
.doc-body .ts-sehr-gross, .editor-preview .ts-sehr-gross { font-size: 1.6em; --ts-k: 1.6; }
.doc-body [class*="ts-"] h1, .editor-preview [class*="ts-"] h1 { font-size: calc(26px * var(--ts-k, 1)); }
.doc-body [class*="ts-"] h2, .editor-preview [class*="ts-"] h2 { font-size: calc(20px * var(--ts-k, 1)); }
.doc-body [class*="ts-"] h3, .editor-preview [class*="ts-"] h3 { font-size: calc(17px * var(--ts-k, 1)); }
.doc-body u, .editor-preview u { text-decoration: underline; text-underline-offset: 2px; }
.doc-body mark, .editor-preview mark { background: var(--mark-bg, #ffe680); color: var(--mark-ink, #1a1a1a); padding: 0 2px; }
.doc-body input[type="checkbox"], .editor-preview input[type="checkbox"] { margin-right: 6px; }
.doc-body li:has(> input[type="checkbox"]), .editor-preview li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.2em; }
.doc-gone { color: var(--muted); font-style: italic; }
.doc-conflict { margin-bottom: 16px; }

/* Doku-Editor: ab 1100 px Textfeld links, Vorschau rechts */
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.editor-toolbar button { min-height: 44px; padding: 0 12px; }
.editor-toolbar button.editor-link { border-color: var(--focus); }
.editor-panes { display: block; }
.editor-preview { display: none; }
.editor-note { background: var(--surface); border: 1px solid var(--line); border-left-width: 6px; border-radius: var(--radius); padding: 10px 14px; margin: 8px 0; }
.editor-note .actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.editor-status { color: var(--muted); font-size: 15px; margin: 4px 0; }
.editor-dialog { position: fixed; inset: 0; z-index: 40; background: rgba(27, 36, 48, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.editor-dialog[hidden] { display: none; }
.editor-dialog-box { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; width: min(520px, 100%); max-height: 80vh; display: flex; flex-direction: column; padding: 16px; gap: 10px; }
.editor-dialog-box h3 { font-size: 18px; }
.editor-dialog-list { overflow: auto; flex: 1; }
.editor-dialog-list h4 { margin: 10px 0 4px; font-family: var(--font-display); font-size: 15px; color: var(--muted); }
.editor-dialog-list button { display: block; width: 100%; text-align: left; margin: 0 0 4px; }
@media (min-width: 1100px) {
  .editor-panes.is-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .editor-panes.is-split .editor-preview { display: block; }
  .editor-panes.is-split textarea { min-height: 60vh; }
  .editor-preview { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; min-height: 60vh; max-height: 75vh; overflow: auto; max-width: none; }
}
.editor-preview h1, .editor-preview h2, .editor-preview h3, .doc-body h1, .doc-body h2, .doc-body h3 { margin: 16px 0 8px; }
.editor-preview ul, .editor-preview ol { padding-left: 1.4em; }
.editor-preview img { max-width: 100%; height: auto; }
.editor-preview code { background: var(--bg); padding: 0 4px; border-radius: 4px; }
.editor-preview pre code { background: none; padding: 0; }
.editor-ai-btn { border-color: var(--focus); }
.editor-ai .editor-note label { display: block; margin-bottom: 4px; }
.editor-ai .editor-note input { width: 100%; max-width: 640px; }
.editor-ai-text { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; white-space: pre-wrap; max-height: 40vh; overflow: auto; }

/* Farbprobe auf der Seite Einstellungen > Farben (Farben kommen aus /theme.css) */
.sample { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.sample-tape { background: var(--tape); color: var(--ink-on-tape); padding: 10px 16px; border-radius: var(--radius); font-family: var(--font-display); font-weight: 700; }
.sample-nav { background: var(--nav); color: var(--navfg); padding: 10px 16px; border-radius: var(--radius); }
.sample-nav strong { color: var(--nav-focus); }
.choice-list { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.choice-list label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.devtable { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.devtable th, .devtable td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; vertical-align: top; }
.devtable th { color: var(--muted); font-size: 15px; font-weight: 600; }
.devtable td a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
@media (max-width: 719px) {
  .devtable, .devtable tbody, .devtable tr, .devtable td { display: block; width: 100%; }
  .devtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .devtable tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .devtable td { border: 0; padding: 4px 12px; }
  .devtable td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 14px; }
}

/* Doku mit Unterseiten: Inhaltsverzeichnis, Pfad, Seitenverwaltung */
.doc-toc { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 10px 16px; margin: 0 0 16px; }
.doc-toc h3 { margin: 0 0 6px; font-size: 1rem; }
.doc-toc ol, .doc-toc ul { margin: 4px 0; padding-left: 1.4em; }
.doc-toc ul { list-style: disc; }
.crumbs { margin: 4px 0 8px; font-size: 0.95rem; }
.crumbs a { text-decoration: underline; }
.doc-prevnext { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; margin: 20px 0; }
.doc-manage { margin-top: 24px; }
.doc-manage .inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.doc-manage .inline-form label { flex-basis: 100%; }
.doc-manage .inline-form input[type="text"] { flex: 1 1 220px; min-width: 0; }
.doc-pages { list-style: none; margin: 0; padding: 0; }
.doc-pages .doc-page-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.doc-page-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.doc-page-actions form { margin: 0; }

/* Doku und Editor, modernere Darstellung */
.doc-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin: 4px 0 16px; }
.doc-head h2 { margin: 0; }
.doc-crumb { margin: 0 0 4px; font-size: 15px; }
.doc-crumb a { color: var(--muted); text-decoration: none; }
.doc-crumb a:hover { color: var(--ink); text-decoration: underline; }
.doc-paper { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 20px 18px; margin: 0 0 20px; }
.doc-paper .doc-body { max-width: 72ch; margin: 0 auto; line-height: 1.65; }
.doc-paper .doc-body > :first-child { margin-top: 0; }
.doc-paper .doc-body h1, .doc-paper .doc-body h2, .doc-paper .doc-body h3 { font-family: var(--font-display); line-height: 1.25; }
.doc-paper .doc-body h2 { padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.doc-paper .doc-body blockquote { margin: 12px 0; padding: 4px 14px; border-left: 4px solid var(--tape); color: var(--muted); }
.doc-paper .doc-body a { text-underline-offset: 3px; }
.doc-paper .doc-body th { background: var(--bg); }
.doc-toc { border-radius: 16px; }
.doc-toc a { text-underline-offset: 3px; }
.doc-manage { border-top: 1px solid var(--line); padding-top: 16px; }
.doc-pages { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin: 0 0 16px; }
.doc-pages li { padding: 8px 14px; }
.doc-pages li:last-child { border-bottom: 0; }
.doc-page-title { font-weight: 600; text-decoration: none; }
.doc-page-title:hover { text-decoration: underline; }
.doc-page-actions button, .doc-page-actions .btn { min-height: 40px; padding: 0 12px; font-weight: 500; }

.editor-help { margin: 12px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; }
.editor-help summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; font-size: 15px; }
.editor-help[open] { padding-bottom: 8px; }
.editor-actions { position: sticky; bottom: 0; z-index: 5; background: var(--bg); padding: 10px 0; }
@media (min-width: 1100px) {
  .editor { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: clip; }
  .editor-toolbar { position: sticky; top: 0; z-index: 4; margin: 0; padding: 8px 12px; gap: 6px 14px; align-items: center; background: var(--surface); border-bottom: 1px solid var(--line); }
  .editor-group { display: inline-flex; flex-wrap: wrap; gap: 2px; padding-right: 14px; border-right: 1px solid var(--line); }
  .editor-group:last-of-type { border-right: 0; padding-right: 0; }
  .editor-toolbar button { min-height: 36px; padding: 0 10px; font-size: 14px; font-weight: 500; background: transparent; border-color: transparent; }
  .editor-toolbar button:hover { background: var(--bg); border-color: var(--line); }
  .editor-toolbar button.editor-link { color: var(--ink); border-color: transparent; background: var(--bg); }
  .editor-toolbar button.editor-ai-btn { margin-left: auto; background: var(--tape); color: var(--ink-on-tape); border-color: var(--tape); }
  .editor-panes.is-split { gap: 0; align-items: stretch; }
  .editor-panes.is-split textarea { min-height: 62vh; border: 0; border-radius: 0; padding: 18px 20px; line-height: 1.6; font-size: 15px; resize: vertical; background: var(--surface); }
  .editor-panes.is-split textarea:focus-visible { outline-offset: -3px; }
  .editor-panes.is-split .editor-preview { border: 0; border-left: 1px solid var(--line); border-radius: 0; background: var(--bg); padding: 18px 24px; min-height: 62vh; max-height: 78vh; line-height: 1.65; }
  .editor-status { padding: 6px 14px; margin: 0; border-top: 1px solid var(--line); min-height: 0; }
  .editor-status:empty { display: none; }
  .editor-note { margin: 8px 12px; }
}

/* Auswahlfelder Farbe und Größe in der Werkzeugleiste */
.editor-toolbar select.editor-select { min-height: 36px; max-width: 9em; padding: 0 6px; font-size: 14px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }

/* Editor wie im Intranet: eine Leiste mit Trennern, Live/Vollbild, Statuszeile */
.editor-toolbar .editor-group { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.editor-toolbar button.fx-b { font-weight: 800; }
.editor-toolbar button.fx-i { font-style: italic; font-family: Georgia, serif; }
.editor-toolbar button.fx-s { text-decoration: line-through; }
.editor-toolbar button.fx-u { text-decoration: underline; }
.editor-toolbar button.editor-toggle[aria-pressed="true"] { background: var(--tape); color: var(--ink-on-tape); border-color: var(--tape); box-shadow: none; }
.editor-meta { padding: 5px 14px; font-size: 13px; color: var(--muted); background: var(--bg); border-top: 1px solid var(--line); }
.editor-dialog { z-index: 300; }
body.editor-full-open { overflow: hidden; }
@media (min-width: 1100px) {
  .editor-toolbar { gap: 6px 0; }
  .editor-toolbar .editor-group { padding: 0 8px; border-right: 1px solid var(--line); }
  .editor-toolbar .editor-group:first-child { padding-left: 0; }
  .editor-toolbar .editor-view { order: 9; margin-left: auto; border-right: 0; padding-right: 0; }
  .editor-toolbar button.editor-ai-btn { order: 8; margin-left: 8px; }
  .editor.editor-full { position: fixed; inset: 0; z-index: 200; border-radius: 0; border: 0; display: flex; flex-direction: column; box-shadow: none; }
  .editor.editor-full .editor-panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; }
  .editor.editor-full .editor-panes.is-split { grid-template-columns: 1fr 1fr; }
  .editor.editor-full .editor-panes textarea, .editor.editor-full .editor-panes.is-split .editor-preview { height: 100%; min-height: 0; max-height: none; overflow: auto; resize: none; }
}
.editor-toolbar button.editor-save { background: var(--tape); color: var(--ink-on-tape); border-color: var(--tape); }

/* Aufgabenlisten (- [ ]) im Doku-Text: das Kästchen bleibt klein und links in der Zeile (die globale Regel für Eingaben macht sonst jedes Feld volle Breite) */
.doc-body input[type="checkbox"], .editor-preview input[type="checkbox"] { display: inline-block; width: 1.1em; height: 1.1em; min-height: 0; padding: 0; margin: 0 8px 0 0; vertical-align: -0.15em; accent-color: var(--tape); }
.doc-body li:has(> input[type="checkbox"]), .editor-preview li:has(> input[type="checkbox"]) { text-align: left; }

/* Startseite */
.dash { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.dash > section { min-width: 0; }
.dash h2 { font-size: 18px; margin: 0 0 8px; }
.dash h3 { font-size: 15px; color: var(--muted); margin: 12px 0 6px; }
.dash .stats { margin-bottom: 0; }
.dash .stats span { overflow-wrap: anywhere; padding: 0 4px; }
.dash .actions { margin: 0; }
.dash-running { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--tape); border-radius: 18px; box-shadow: var(--shadow); }
.dash-running-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dash-running .who { font-family: var(--font-display); font-weight: 700; overflow-wrap: anywhere; }
.dash-running .sub { color: var(--muted); font-size: 15px; }
.dash .row .title a { color: inherit; }
@media (min-width: 720px) {
  .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-wide { grid-column: 1 / -1; }
}
@media (min-width: 1100px) {
  .dash { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-visits { grid-column: span 2; }
}

/* Doku-Baum: untergeordnete Seiten sind eingerückt */
.doc-pages ul.doc-pages { margin-left: 20px; padding-left: 12px; border-left: 2px solid var(--line); }
.doc-pages li { display: block; }
.doc-page-row select { max-width: 16em; }
.doc-toc ol ol { list-style: lower-alpha; }

/* Anmeldung und zweiter Faktor */
.login { max-width: none; margin: 0; padding: max(24px, env(safe-area-inset-top, 0px)) 16px 24px; min-height: 100dvh; display: grid; place-items: center; align-content: center; background: var(--bg); position: relative; }
.login::before { content: ""; position: fixed; inset: 0 0 auto 0; height: 6px; background: var(--tape); }
.login > .error { width: min(420px, 100%); margin: 0 0 12px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 28px 24px 24px; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin: 0 0 22px; }
.auth-brand img { border-radius: 14px; flex: none; }
.auth-brand strong { display: block; font-family: var(--font-display); font-size: 22px; line-height: 1.15; }
.auth-brand span { display: block; color: var(--muted); font-size: 15px; }
.auth-card h1 { font-size: 24px; margin: 0 0 6px; }
.auth-lead { color: var(--muted); margin: 0 0 8px; }
.auth-card label { margin: 16px 0 0; }
.auth-card form button[type="submit"] { width: 100%; min-height: 48px; margin-top: 22px; font-size: 16px; }
.auth-card .auth-qr { display: block; margin: 16px auto; max-width: 100%; height: auto; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.auth-card code { overflow-wrap: anywhere; }
.auth-card .codes { list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auth-card .codes li { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; font-family: var(--font-mono); }
.auth-card .btn { width: 100%; }
.login::after { content: ""; position: fixed; inset: 16px; border: 2px solid var(--line); border-radius: 24px; pointer-events: none; }
@media (max-width: 480px) { .login::after { inset: 8px; border-radius: 18px; } }

/* Politur: weichere Flächen, Verlauf in Kopf- und Menüleiste, Akzent als feine Zierlinie (Vorbild: Intranet LH) */
.topbar { background: linear-gradient(120deg, var(--nav) 0%, color-mix(in srgb, var(--nav) 70%, #3b82d6) 100%); color: #fff; border-bottom: 0; box-shadow: 0 2px 14px rgba(10, 30, 60, .22); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 3px; background: var(--tape); opacity: .9; }
.topbar h1, .topbar .tb-user { color: #fff; }
.topbar button, .topbar .btn { color: #fff; background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .3); border-radius: 999px; transition: background .15s; }
.topbar button:hover, .topbar .btn:hover { background: rgba(255, 255, 255, .28); }
.topbar :focus-visible { outline-color: #fff; }
.nav { background: linear-gradient(180deg, var(--nav), color-mix(in srgb, var(--nav) 82%, #000)); }
.nav a, .nav .navbtn { transition: background .15s, color .15s; }
.nav a:hover, .nav .navbtn:hover { background: rgba(255, 255, 255, .08); color: var(--nav-focus); }
.rows, .device, .person, .cred, .steps, .stats, .ev, .so-dialog { border-radius: var(--radius-lg); }
a.row, a.evbody, .firmlist .it { transition: background .15s; }
.ev, .device, .person, .cred { transition: box-shadow .15s, transform .15s; }
.ev:hover, .device:hover, .person:hover, .cred:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
button, .btn { border-radius: var(--radius); transition: background .15s, box-shadow .15s, transform .12s; }
button:hover:not(:disabled), .btn:hover { background: color-mix(in srgb, var(--surface) 90%, var(--focus)); }
button.primary, .btn.primary { box-shadow: 0 2px 6px rgba(0, 0, 0, .18); }
button.primary:hover:not(:disabled), .btn.primary:hover { background: var(--tape); filter: brightness(.95); transform: translateY(-1px); }
input, select, textarea { border-radius: var(--radius); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--ring); }
.firmname::after { content: ""; display: block; width: 44px; height: 4px; border-radius: 4px; background: var(--tape); margin-top: 6px; }
.tabs a { border-radius: 10px 10px 0 0; transition: background .15s; }
.tabs a:hover { background: var(--surface); }
.login { background: radial-gradient(ellipse at 50% -10%, color-mix(in srgb, var(--nav) 22%, var(--bg)) 0%, var(--bg) 65%); }
.auth-card { border-radius: 24px; border-top: 5px solid var(--tape); box-shadow: var(--shadow-hover); }
.auth-brand img { box-shadow: var(--shadow); }
@media (prefers-reduced-motion: reduce) { .ev:hover, .device:hover, .person:hover, .cred:hover, button.primary:hover:not(:disabled), .btn.primary:hover { transform: none; } }
