@font-face { font-family: 'Bricolage'; src: url('/fonts/bricolage/bricolage-grotesque-latin-wght-normal.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }
@font-face { font-family: 'Instrument'; src: url('/fonts/instrument/instrument-sans-latin-wght-normal.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }

:root {
  --bg: #e9edf2; --surface: #fff; --ink: #14213d; --muted: #586579; --line: #c5ceda; --soft: #f3f5f8;
  --accent: #2449d8; --accent-soft: #e3e9fc; --amber: #9a6500; --amber-soft: #fdf1d6;
  --green: #1c7448; --green-soft: #dff3e8; --red: #b3261e; --red-soft: #fbe4e2;
  --head: 'Bricolage', 'Segoe UI', system-ui, sans-serif; --body: 'Instrument', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); }
h1, h2, h3 { font-family: var(--head); line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 30px; font-weight: 700; } h2 { font-size: 20px; font-weight: 650; } h3 { font-size: 16px; font-weight: 650; }
p { margin: 0 0 .6em; } a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: 13px; }

/* Grundaufbau */
#app { display: grid; grid-template-columns: 250px 1fr; min-height: 100%; }
.side { background: var(--ink); color: #fff; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .firm { font: 700 21px/1.1 var(--head); padding: 0 8px 16px; overflow-wrap: anywhere; }
.side a, .side button.link { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px; border-radius: 6px; color: #d6dcea; text-decoration: none; background: none; border: 0; text-align: left; cursor: pointer; width: 100%; }
.side a:hover, .side button.link:hover { background: #ffffff14; color: #fff; }
.side a.on { background: #fff; color: var(--ink); font-weight: 600; }
.side .grp { margin: 16px 8px 4px; font-size: 13px; color: #94a0b8; }
.side .spacer { flex: 1; }
.side .new { background: var(--accent); color: #fff; font-weight: 600; justify-content: center; margin-bottom: 4px; }
.side .new:hover { background: #3558e6; }
.count { background: var(--amber-soft); color: var(--amber); font-size: 12px; font-weight: 700; border-radius: 10px; padding: 0 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #94a0b8; flex: none; }
.dot.running, .dot.planning, .dot.in_progress { background: var(--accent); animation: pulse 1.4s infinite; }
.dot.waiting, .dot.blocked { background: #e0a100; } .dot.done { background: #2fa36b; } .dot.failed { background: #e0584f; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none !important; } }
main { padding: 30px 36px 60px; min-width: 0; max-width: 1180px; }

/* Bausteine */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 14px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: #1b3cc0; }
.btn.danger { color: var(--red); } .btn.sm { padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; margin-bottom: 16px; }
.banner { background: var(--amber-soft); color: #5c3d00; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.banner.err { background: var(--red-soft); color: var(--red); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 12px; background: var(--soft); white-space: nowrap; }
.badge.running, .badge.planning, .badge.in_progress { background: var(--accent-soft); color: var(--accent); }
.badge.waiting, .badge.blocked, .badge.open { background: var(--amber-soft); color: var(--amber); }
.badge.done, .badge.approved { background: var(--green-soft); color: var(--green); }
.badge.failed, .badge.denied { background: var(--red-soft); color: var(--red); }
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=url], input[type=number], select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: #fff; }
textarea { resize: vertical; min-height: 80px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row.end { justify-content: flex-end; } .grow { flex: 1; min-width: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 6px 0; } .check input { width: auto; }

/* Projektkopf und Reiter */
.phead { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 6px; }
.goal { color: var(--muted); max-width: 75ch; white-space: pre-wrap; margin: 6px 0 18px; }
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }

/* Organigramm – das Erkennungsmerkmal der Seite */
.org { overflow-x: auto; padding: 4px 0 8px; }
.org-in { display: inline-flex; flex-direction: column; align-items: center; min-width: 100%; }
.org-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: 100%; }
.org-top .staff { justify-self: start; display: flex; align-items: center; }
.org-top .staff::before { content: ''; width: 34px; border-top: 2px dashed var(--line); }
.stem { width: 2px; height: 22px; background: var(--line); }
.org-row { display: flex; }
.org-row .slot { padding: 22px 7px 0; position: relative; }
.org-row .slot::before { content: ''; position: absolute; top: 0; left: 50%; width: 2px; height: 22px; background: var(--line); margin-left: -1px; }
.org-row .slot::after { content: ''; position: absolute; top: 0; left: 0; right: 0; border-top: 2px solid var(--line); }
.org-row .slot:first-child::after { left: 50%; } .org-row .slot:last-child::after { right: 50%; }
.org-row .slot:only-child::after { display: none; }
.node { width: 168px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; text-align: left; cursor: pointer; display: block; }
.node:hover { border-color: var(--accent); }
.node .role { font: 650 15px/1.2 var(--head); display: flex; gap: 7px; align-items: center; overflow-wrap: anywhere; }
.node .what { font-size: 13px; color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.node.boss { background: var(--ink); color: #fff; border-color: var(--ink); } .node.boss .what { color: #b8c2d8; }
.node.staffnode { border-style: dashed; }

/* Aufgaben */
.task { border-top: 1px solid var(--line); padding: 10px 0; }
.task:first-of-type { border-top: 0; }
.task summary { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; cursor: pointer; list-style: none; }
.task summary::-webkit-details-marker { display: none; }
.task .t { font-weight: 600; } .task .who { font-size: 13px; color: var(--muted); }
.task .body { padding: 8px 0 4px; color: #2c3a55; max-width: 80ch; }
.task .body .res { background: var(--soft); border-radius: 6px; padding: 8px 12px; margin-top: 8px; white-space: pre-wrap; }

/* Chat */
.chat { display: grid; grid-template-columns: 210px 1fr; gap: 16px; align-items: start; }
.people { display: flex; flex-direction: column; gap: 2px; }
.people button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.people button.on { background: var(--surface); font-weight: 600; box-shadow: inset 3px 0 var(--accent); }
.chatbox { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; height: min(66vh, 640px); }
#chatlog { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 78%; padding: 8px 12px; border-radius: 10px; background: var(--soft); overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; } .msg.me a { color: #fff; }
.msg .from { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.msg :last-child { margin-bottom: 0; }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 42px; height: 42px; }
.typing { font-size: 13px; color: var(--muted); padding: 0 16px 8px; }

/* Dokumentation */
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.entry { display: grid; grid-template-columns: 86px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--soft); }
.entry:first-child { border-top: 0; }
.entry > div { min-width: 0; }
.entry time { font-size: 12px; color: var(--muted); padding-top: 2px; }
.entry .who { font-weight: 650; font-size: 13px; }
.entry.k-error .txt { color: var(--red); } .entry.k-request .txt { color: var(--amber); }
.doc { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--soft); padding: 9px 0; cursor: pointer; }
.doc:first-of-type { border-top: 0; } .doc:hover .dt { color: var(--accent); } .doc .dt { font-weight: 600; }
.md h1, .md h2, .md h3 { margin: .9em 0 .35em; } .md h1 { font-size: 22px; } .md h2 { font-size: 18px; } .md h3 { font-size: 15px; }
.md ul, .md ol { margin: 0 0 .6em; padding-left: 1.3em; } .md pre { background: var(--soft); padding: 10px; border-radius: 6px; overflow-x: auto; }
.md code { background: var(--soft); padding: 1px 4px; border-radius: 4px; font-size: .92em; } .md pre code { padding: 0; }
.md > :first-child { margin-top: 0; }
dialog { border: 0; border-radius: 10px; padding: 0; width: min(820px, 94vw); max-height: 88vh; color: var(--ink); }
dialog::backdrop { background: #14213d99; }
#reader-body { padding: 24px 28px; }

/* Anfragen */
.req .advice { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin: 10px 0; }

/* Verwaltung */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
thead th { border-top: 0; font-size: 13px; color: var(--muted); font-weight: 600; }
td.c, th.c { text-align: center; } td.c input { width: 18px; height: 18px; }
.matrix { overflow-x: auto; }

/* Anmeldung */
.login { grid-column: 1 / -1; display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login form { width: min(380px, 100%); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.show { opacity: 1; }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  main { padding: 20px 16px 50px; }
  .chat, .split, .cols { grid-template-columns: 1fr; }
  .people { flex-direction: row; overflow-x: auto; }
  .phead { flex-wrap: wrap; gap: 8px; } .phead .grow { flex-basis: 100%; }
}
td .row { flex-wrap: nowrap; }
