:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2330; --muted: #667085; --line: #e3e6eb;
  --brand: #1f5fbf; --brand-ink: #ffffff; --soft: #eef3fb; --ok: #1a7f4b; --warn: #b26b00; --err: #b42318;
  --radius: 10px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12151b; --panel: #1a1f27; --text: #e7eaf0; --muted: #98a2b3; --line: #2a313c;
          --brand: #5b8def; --soft: #1f2a3d; --ok: #4cc38a; --warn: #f0b354; --err: #f97066; }
}
* { box-sizing: border-box; }
#app { height: 100%; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.danger { color: var(--err); }
button:disabled { opacity: .55; cursor: default; }
input, select, textarea { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.center { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.login { width: 100%; max-width: 380px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.error { color: var(--err); font-size: 14px; min-height: 1.4em; margin-top: 8px; }

.shell { display: grid; grid-template-rows: 52px minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }
.top { display: flex; align-items: center; gap: 14px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 650; }
.top nav { display: flex; gap: 4px; margin-left: 12px; flex-wrap: wrap; }
.top nav button { border: none; background: transparent; padding: 6px 10px; }
.top nav button.active { background: var(--soft); color: var(--brand); font-weight: 600; }
.top .who { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 14px; }
.main { overflow: hidden; min-height: 0; height: calc(100vh - 52px); height: calc(100dvh - 52px); }

.chat { display: grid; grid-template-columns: 250px minmax(0, 1fr); height: 100%; min-height: 0; overflow: hidden; }
.agents { border-right: 1px solid var(--line); padding: 12px; overflow: auto; background: var(--panel); }
.agent { padding: 10px; border-radius: 8px; cursor: pointer; margin-bottom: 4px; }
.agent:hover { background: var(--soft); }
.agent.active { background: var(--soft); outline: 1px solid var(--brand); }
.agent .name { font-weight: 600; }
.agent .desc { font-size: 13px; color: var(--muted); }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--soft); color: var(--brand); margin-left: 6px; vertical-align: 1px; }
.conv { display: grid; grid-template-rows: minmax(0, 1fr) auto; height: 100%; min-width: 0; min-height: 0; }
.msgs { overflow-y: scroll; min-height: 0; height: 100%; padding: 20px max(16px, 6%); }
.msg { max-width: 820px; margin: 0 auto 16px; }
.msg .bubble { padding: 12px 14px; border-radius: var(--radius); white-space: pre-wrap; word-wrap: break-word; }
.msg.user .bubble { background: var(--soft); margin-left: 15%; }
.msg.assistant .bubble { background: var(--panel); border: 1px solid var(--line); }
.msg .sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg .sources a { font-size: 13px; text-decoration: none; padding: 3px 8px; border: 1px solid var(--line); border-radius: 99px; background: var(--panel); }
.composer { border-top: 1px solid var(--line); padding: 12px max(16px, 6%); background: var(--panel); }
.composer form { max-width: 820px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 200px; }
.notice { max-width: 820px; margin: 0 auto 6px; font-size: 12px; color: var(--muted); }

.page { padding: 20px max(16px, 4%); overflow: auto; height: 100%; }
.page h2 { font-size: 18px; margin: 0 0 12px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row > button { flex: 0 0 auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.status-done { color: var(--ok); } .status-failed { color: var(--err); } .status-queued, .status-processing { color: var(--warn); }
.tablewrap { overflow-x: auto; }
code { font-size: 12px; }

@media (max-width: 760px) {
  .chat { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .agents { border-right: none; border-bottom: 1px solid var(--line); display: flex; gap: 6px; overflow-x: auto; }
  .agent { min-width: 180px; }
  .grid2 { grid-template-columns: 1fr; }
  .top .who span { display: none; }
}
.top nav a.modlink { padding: 6px 10px; text-decoration: none; border-radius: 8px; }
.top nav a.modlink:hover { background: var(--soft); }

/* Rechteverwaltung */
.card.wide { grid-column: 1 / -1; }
.row.head { align-items: center; } .row.head h2 { margin: 0; }
.row.end { justify-content: flex-end; margin-top: 14px; } .row.end > * { flex: 0 0 auto; }
.small { font-size: 12px; }
.badge.role { background: #fff1e0; color: #8a4b00; }
.badge.mod { background: #e7f5e9; color: #0a6b1e; }
.dlg-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: grid; place-items: center; padding: 16px; }
.dlg { background: var(--panel); border-radius: 12px; padding: 20px 22px; width: min(720px, 100%); max-height: 92vh; overflow: auto; }
.dlg h2 { margin: 0 0 8px; font-size: 18px; }
.rechte h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 6px; }
.rechte label.chk, .dlg label.chk { display: flex; gap: 8px; align-items: baseline; margin: 6px 0; color: var(--text); font-size: 14px; }
.rechte input[type=checkbox], .rechte input[type=radio], .dlg input[type=checkbox] { width: auto; margin: 0; }
.modrow { display: flex; gap: 12px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.modname { width: 120px; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segopt { display: flex !important; gap: 6px; align-items: center; margin: 0 !important; padding: 5px 12px; color: var(--text) !important; cursor: pointer; border-right: 1px solid var(--line); font-size: 13px !important; }
.segopt:last-child { border-right: none; }
.segopt:has(input:checked) { background: var(--soft); color: var(--brand) !important; font-weight: 600; }
.segopt:has(input:disabled) { opacity: .45; cursor: default; }

/* 2FA */
.card.login.wide { max-width: 520px; }
button.full { width: 100%; margin-top: 16px; }
input.otp { font-size: 22px; letter-spacing: .3em; text-align: center; }
.qr { display: grid; place-items: center; margin: 10px 0; }
.qr img { width: 200px; height: 200px; border: 1px solid var(--line); border-radius: 8px; }
ol.steps { padding-left: 20px; } ol.steps li { margin: 8px 0; }
pre.codes { font: 600 18px/1.7 ui-monospace, Consolas, monospace; background: var(--soft); padding: 12px 16px; border-radius: 8px; columns: 2; }
@media print { body * { visibility: hidden; } pre.codes, pre.codes * { visibility: visible; } pre.codes { position: absolute; top: 20px; left: 20px; } }
