:root {
  --bg: #0f1420; --bg2: #151c2b; --panel: #1a2234; --panel2: #212b40; --line: #2d3953; --text: #e8ecf4; --muted: #95a0b8;
  --paper: #f2b632; --paper-bg: #3a2e10; --live: #ff4d4f; --live-bg: #3a1214; --ok: #3fb950; --warn: #e0a526; --err: #e5484d; --info: #58a6ff;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --radius: 4px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--info); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.pos { color: var(--ok); } .neg { color: var(--err); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 17px; } h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* Buttons und Formulare */
.btn { background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 3px; padding: 7px 12px; border-radius: var(--radius); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #2a3550; } .btn:active { transform: translateY(1px); border-bottom-width: 2px; }
.btn.primary { background: #2b5fd9; border-color: #1d46a8; } .btn.primary:hover { background: #3a6ee6; }
.btn.danger { background: #5a1c20; border-color: #8a2a30; } .btn.danger:hover { background: #73242a; }
.btn.warn { background: #4d3a0e; border-color: #7a5c16; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }
textarea { font-family: var(--mono); font-size: 12px; min-height: 120px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 12px; }
.err-msg { color: var(--err); margin-top: 8px; min-height: 1em; } .ok-msg { color: var(--ok); margin-top: 8px; }

/* Auth-Karten */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background:
  repeating-linear-gradient(45deg, #121827 0 12px, #10151f 12px 24px); }
.auth-card { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 24px; box-shadow: 0 8px 0 #0a0e16; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 14px; }
.brand img { width: 28px; height: 28px; image-rendering: pixelated; }
.secret { font-family: var(--mono); font-size: 16px; letter-spacing: .08em; background: var(--bg2); padding: 10px; border-radius: 4px; word-break: break-all; user-select: all; }
.steps { display: flex; gap: 6px; margin-bottom: 12px; } .steps span { flex: 1; height: 4px; background: var(--line); border-radius: 2px; } .steps span.on { background: var(--info); }

/* App-Layout */
.topbar { position: sticky; top: 0; z-index: 20; background: #0c111b; border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 12px; padding: 8px 16px; flex-wrap: wrap; }
.mode-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 3px; font-weight: 700; font-size: 12px; letter-spacing: .04em; }
.mode-badge.paper { background: var(--paper-bg); color: var(--paper); border: 1px solid #6b5418; }
.mode-badge.live { background: var(--live-bg); color: var(--live); border: 1px solid #7a2224; }
.mode-badge.locked { background: #1d2333; color: var(--muted); border: 1px solid var(--line); }
.kpi-strip { display: flex; gap: 16px; flex-wrap: wrap; margin-left: auto; font-size: 12px; }
.kpi-strip div { display: flex; flex-direction: column; } .kpi-strip b { font-family: var(--mono); font-size: 14px; }
.emergency { display: flex; gap: 6px; flex-wrap: wrap; }
.halt-banner { background: #3a1214; color: #ffb3b5; padding: 6px 16px; font-size: 13px; border-top: 1px solid #7a2224; }
.nav { display: flex; gap: 2px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
.nav button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 10px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.nav button.on { color: var(--text); border-bottom-color: var(--info); }
main { padding: 16px; max-width: 1500px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px; margin-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.stat .l { font-size: 12px; color: var(--muted); } .stat .v { font-family: var(--mono); font-size: 20px; margin-top: 2px; } .stat .s { font-size: 11px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
.chip { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--panel2); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { color: var(--ok); border-color: #255d31; } .chip.warn { color: var(--warn); border-color: #6b5418; } .chip.err { color: var(--err); border-color: #7a2224; } .chip.info { color: var(--info); border-color: #24487a; }
.bar { height: 8px; background: var(--bg2); border-radius: 4px; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--ok); }
.bar.w > i { background: var(--warn); } .bar.e > i { background: var(--err); }
pre { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12px; background: var(--bg2); padding: 8px; border-radius: 4px; margin: 0; max-height: 360px; overflow: auto; }
.notice { border-left: 3px solid var(--paper); background: var(--paper-bg); padding: 8px 12px; border-radius: 0 4px 4px 0; margin-bottom: 14px; font-size: 13px; }
.notice.info { border-color: var(--info); background: #10213a; } .notice.err { border-color: var(--err); background: var(--live-bg); }

/* Office */
.office { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; }
.stage { position: relative; background: #0a0e16; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.stage canvas { display: block; width: 100%; height: auto; cursor: default; touch-action: manipulation; }
.stage .legend { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.stage .legend span { background: rgba(10, 14, 22, .8); padding: 2px 6px; border-radius: 3px; }
.side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.agent-head { display: flex; gap: 10px; align-items: center; }
.agent-head img.portrait { height: 72px; width: auto; padding: 4px 8px; background: var(--bg2); border-radius: 4px; }
.feed { max-height: 420px; overflow-y: auto; font-size: 12px; }
.feed .ev { display: grid; grid-template-columns: 46px 10px 1fr; gap: 6px; padding: 5px 0; border-bottom: 1px solid #222b3f; }
.feed .ev .dot { width: 8px; height: 8px; border-radius: 2px; margin-top: 5px; }
.feed .ev.warn { color: #f5d38a; } .feed .ev.error { color: #ffb3b5; }
.team { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.team .m { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 8px; cursor: pointer; text-align: left; }
.team .m.sel { border-color: var(--info); }
.team .m.need { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn) inset; }
.notice.warn { border-color: var(--warn); background: #2a2210; }
.meters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; align-items: stretch; }
.meters .meter { flex: 1 1 130px; min-width: 0; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.meters .meter b { font-size: 14px; }
.meters .bar { display: block; height: 4px; background: #222b3f; border-radius: 2px; overflow: hidden; margin-top: 2px; }
.meters .bar i { display: block; height: 100%; background: var(--ok); }
.meters .meter.warn .bar i { background: var(--warn); } .meters .meter.err .bar i { background: var(--err); }
.meters .meter.err b { color: var(--err); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.st-working { background: var(--info); } .st-idle { background: var(--muted); } .st-blocked { background: var(--warn); } .st-error { background: var(--err); }
.history li { margin-bottom: 6px; } .history { padding-left: 16px; margin: 0; font-size: 12px; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 18px; width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.chart { width: 100%; height: 180px; display: block; }

/* Bonusprogramm */
.bonus-line { font-size: 12px; margin-top: 3px; color: var(--paper); }
.bonus-line .rank { font-family: var(--mono); font-weight: 700; }
.eom { display: flex; gap: 14px; align-items: center; border-color: #6b5418; background: linear-gradient(90deg, #2a2210, var(--panel)); }
.eom .crown { font-size: 40px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-6deg); } }
.leader { display: flex; flex-direction: column; gap: 6px; }
.lrow { display: grid; grid-template-columns: 40px minmax(0, 1fr) 56px 96px; gap: 10px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.lrow:hover { border-color: var(--info); }
.lrow .rank { font-size: 18px; text-align: center; font-family: var(--mono); }
.lrow .bar { margin-top: 5px; } .lrow .bar > i { background: var(--paper); }
.lrow .badges { font-size: 15px; letter-spacing: 2px; text-align: right; }
@media (max-width: 760px) { .lrow { grid-template-columns: 34px minmax(0, 1fr) 48px; } .lrow .badges { grid-column: 2 / -1; text-align: left; } }
@media (prefers-reduced-motion: reduce) { .eom .crown { animation: none; } }

@media (max-width: 1050px) {
  .office { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  main { padding: 10px; }
  .topbar-inner { padding: 8px 10px; gap: 8px; }
  .kpi-strip { margin-left: 0; width: 100%; gap: 12px; }
  .emergency { width: 100%; } .emergency .btn { flex: 1; font-size: 12px; padding: 6px 6px; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; background: #0c111b; border-top: 1px solid var(--line); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
  body { padding-bottom: 56px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .stat .v { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 760px) {
  .stage { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .stage canvas { width: 170%; max-width: none; }
  .stage .legend { position: static; padding: 6px; }
}
