:root {
  --brand: #CC3433;
  --red: #CC3433; --red-d: #B32D2C; --pink: #EDB5B5; --red-soft: #FBEDED;
  --bg: #F7F3F3; --panel: #FFFFFF; --card: #FFFFFF; --line: #E7DEDE; --line-2: #D9CDCD;
  --ink: #1F1F1F; --text: #2b2b2b; --muted: #6a6464; --faint: #9a9090;
  --ok: #2F8A5B; --warn: #C98A1E; --err: #B32D2C;
  --shadow: 0 1px 2px rgba(60,20,20,.06), 0 4px 14px rgba(60,20,20,.06);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --red: #E0504F; --red-d: #CC3433; --pink: #6b2b2b; --red-soft: #2f1c1c;
    --bg: #141212; --panel: #1c1a1a; --card: #232020; --line: #322d2d; --line-2: #403939;
    --ink: #f3eeee; --text: #e3dcdc; --muted: #ab9f9f; --faint: #7d7272;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --red: #E0504F; --red-d: #CC3433; --pink: #6b2b2b; --red-soft: #2f1c1c;
  --bg: #141212; --panel: #1c1a1a; --card: #232020; --line: #322d2d; --line-2: #403939;
  --ink: #f3eeee; --text: #e3dcdc; --muted: #ab9f9f; --faint: #7d7272;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--red); }
.boot { height: 100vh; display: grid; place-items: center; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); display: inline-block; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Buttons & Felder ---------- */
.btn { white-space: nowrap; border: 1px solid var(--line-2); background: var(--panel); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-d); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 11px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 18%, transparent); }
label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 12px 0 5px; }
.err { color: var(--err); font-size: 13px; margin-top: 10px; min-height: 18px; }
.muted { color: var(--muted); }
.kicker { font-size: 11px; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-rows: 46vh auto; }
.auth-top { background: var(--brand); color: #fff; padding: 32px 16px; display: flex; align-items: flex-end; justify-content: center; position: relative; overflow: hidden; }
.auth-top::after { content: ""; position: absolute; width: 70vh; height: 70vh; border-radius: 50%; border: 18vh solid rgba(255,255,255,.07); right: -24vh; top: -26vh; }
.auth-top h1 { margin: 0; font-size: 34px; font-weight: 300; letter-spacing: .02em; text-transform: uppercase; max-width: 380px; width: 100%; }
.auth-top h1 b { display: block; font-weight: 900; }
.auth-card { max-width: 380px; width: calc(100% - 32px); margin: -28px auto 40px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; position: relative; z-index: 1; }
.auth-card .btn { width: 100%; margin-top: 16px; }

/* ---------- Grundgerüst ---------- */
.shell { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.top { display: flex; align-items: center; gap: 18px; padding: 0 16px; height: 56px; background: var(--brand); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; letter-spacing: .04em; white-space: nowrap; }
.brand svg { width: 34px; height: 20px; }
.brand span { font-weight: 300; opacity: .8; }
.nav { display: flex; gap: 2px; }
.nav button { background: transparent; border: 0; color: #fff; opacity: .78; padding: 8px 12px; border-radius: 7px; cursor: pointer; font-weight: 700; }
.nav button.on, .nav button:hover { opacity: 1; background: rgba(255,255,255,.14); }
.top .sp { flex: 1; }
.pill { background: rgba(255,255,255,.16); border-radius: 20px; padding: 4px 11px; font-size: 12.5px; white-space: nowrap; }
.pill.warn { background: #fff; color: var(--brand); font-weight: 800; }
.usermenu { position: relative; }
.usermenu > button { background: rgba(255,255,255,.16); border: 0; color: #fff; border-radius: 20px; padding: 5px 12px 5px 5px; display: flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 700; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: #fff; color: var(--brand); display: grid; place-items: center; font-size: 11px; font-weight: 900; }
.menu { position: absolute; right: 0; top: 42px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 190px; padding: 6px; z-index: 20; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--bg); }
.mockbar { background: #FFF4D6; color: #6b4d00; padding: 6px 16px; font-size: 12.5px; text-align: center; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mockbar { background: #3a2f12; color: #f1d78a; } }
.main { overflow: hidden; display: grid; }

/* ---------- Board ---------- */
.board { display: grid; grid-template-columns: 250px 1fr; height: 100%; overflow: hidden; }
.side { border-right: 1px solid var(--line); background: var(--panel); overflow-y: auto; overflow-x: hidden; padding: 14px 10px 30px; }
.dept { margin-bottom: 14px; }
.dept h4 { margin: 0 6px 4px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.agent { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: none; border: 0; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.agent:hover, .agent.on { background: var(--red-soft); }
.agent i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); flex: none; }
.agent.busy i { background: var(--warn); animation: pulse 1.2s infinite; }
.agent > span { min-width: 0; }
.agent b { font-size: 12.5px; letter-spacing: .03em; }
.agent small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.25; }
.agent .lead { font-size: 10px; color: var(--red); font-weight: 800; margin-left: 4px; }
.work { overflow-y: auto; padding: 18px 20px 40px; }
.taskbar { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.taskbar .row { display: flex; gap: 10px; align-items: flex-end; }
.taskbar select { width: 220px; flex: none; }
.taskbar textarea { resize: none; min-height: 42px; max-height: 200px; }
.taskbar .hint { font-size: 12px; color: var(--muted); margin-top: 7px; }
.cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; align-items: start; }
.col { background: color-mix(in srgb, var(--panel) 55%, var(--bg)); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.col h3 { margin: 2px 4px 10px; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--line-2); border-radius: 8px; padding: 9px 11px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); }
.card:hover { border-color: var(--line-2); }
.card.queued { border-left-color: var(--faint); }
.card.running { border-left-color: var(--warn); }
.card.done { border-left-color: var(--ok); }
.card.error { border-left-color: var(--err); }
.card .t { font-weight: 600; color: var(--ink); line-height: 1.35; }
.card .m { font-size: 11.5px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 10.5px; font-weight: 800; letter-spacing: .04em; border-radius: 4px; padding: 1px 6px; background: var(--bg); color: var(--muted); }
.tag.chat { background: var(--red-soft); color: var(--red); }
.empty { color: var(--faint); font-size: 12.5px; text-align: center; padding: 18px 6px; }

/* ---------- Seitenpanel (Chat / Details) ---------- */
.drawer { position: fixed; top: 56px; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); border-left: 1px solid var(--line); box-shadow: -8px 0 30px rgba(0,0,0,.12); display: grid; grid-template-rows: auto 1fr auto; z-index: 10; }
.drawer header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.drawer header h2 { margin: 0; font-size: 16px; color: var(--ink); }
.drawer header p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.drawer header .x { margin-left: auto; }
.thread { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 92%; border-radius: 12px; padding: 10px 13px; }
.bubble.me { align-self: flex-end; background: var(--red); color: #fff; white-space: pre-wrap; }
.bubble.ai { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); }
.bubble.ai.err { border-color: var(--err); color: var(--err); }
.bubble .meta { font-size: 11px; color: var(--muted); margin-top: 6px; }
.composer { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; min-height: 42px; max-height: 160px; }
.detail { overflow-y: auto; padding: 16px; }
.detail .q { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 12.5px; margin: 14px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------- Markdown ---------- */
.md { line-height: 1.55; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 { color: var(--ink); line-height: 1.25; margin: 1.1em 0 .45em; }
.md h1 { font-size: 1.35em; } .md h2 { font-size: 1.18em; } .md h3 { font-size: 1.05em; }
.md table { border-collapse: collapse; width: 100%; margin: .7em 0; font-size: .95em; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line-2); padding: 5px 8px; text-align: left; }
.md th { background: var(--bg); }
.md code { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: .92em; }
.md pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; }
.md pre code { border: 0; padding: 0; }
.md blockquote { margin: .6em 0; padding: .2em .9em; border-left: 3px solid var(--red); color: var(--muted); }
.md a.wiki { text-decoration: none; border-bottom: 1px dashed var(--red); cursor: pointer; }

/* ---------- Wissen ---------- */
.notes { display: grid; grid-template-columns: 300px 1fr; height: 100%; overflow: hidden; }
.notes .side input { margin-bottom: 10px; }
.notes .folder { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 12px 6px 4px; }
.notes .item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.notes .item:hover, .notes .item.on { background: var(--red-soft); }
.notes .view { overflow-y: auto; padding: 24px 32px 60px; }
.notes .view .path { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.notes .view .md { max-width: 820px; }
.notice { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; font-size: 13px; }

/* ---------- Verwaltung ---------- */
.admin { overflow-y: auto; padding: 20px; }
.admin .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; max-width: 1200px; }
.box { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--red); border-radius: 0 0 var(--radius) var(--radius); padding: 16px; box-shadow: var(--shadow); }
.box h3 { margin: 0 0 10px; font-size: 15px; color: var(--ink); }
.box.wide { grid-column: 1 / -1; }
.big { font-size: 26px; font-weight: 900; color: var(--red); }
.bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.bar > i { display: block; height: 100%; background: var(--red); }
table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th { text-align: left; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 6px; border-bottom: 1px solid var(--line); }
table.list td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { margin: 0; display: flex; align-items: center; gap: 5px; font-weight: 600; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 3px 10px; cursor: pointer; font-size: 12.5px; }
.form2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 30; padding: 16px; }
.modal { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); width: min(460px, 100%); padding: 20px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 4px; color: var(--ink); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- Handy ---------- */
@media (max-width: 860px) {
  .board, .notes { grid-template-columns: 1fr; }
  .board .side { display: none; }
  .board.agents-open .side { display: block; position: fixed; inset: 56px 0 0 0; z-index: 9; }
  .notes .side { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .cols { grid-template-columns: 1fr; }
  .taskbar .row { flex-direction: column; align-items: stretch; }
  .taskbar select { width: 100%; }
  .top { gap: 8px; padding: 0 10px; }
  .brand span, .pill.budget { display: none; }
  .nav button { padding: 8px 8px; }
  .work, .admin { padding: 14px 16px 40px; }
  .notes .view { padding: 16px; }
  .form2 { grid-template-columns: 1fr; }
}
.only-mobile { display: none; }
@media (max-width: 860px) { .only-mobile { display: inline-block; } }

/* ---------- Notiz bearbeiten ---------- */
.notebar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; max-width: 820px; flex-wrap: wrap; }
.notebar .path { margin: 0; }
.notebar .sp { flex: 1; }
.editor { width: 100%; max-width: 820px; min-height: 60vh; resize: vertical; font: 13.5px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 14px; }
.notes .view .notice { max-width: 820px; }
