:root {
  --bg: #05070d;
  --bg-2: #080c16;
  --panel: #0c1220;
  --panel-2: #111a2c;
  --line: #1b2740;
  --line-2: #26365a;
  --text: #eaf1fb;
  --text-2: #9fb0c9;
  --muted: #6b7994;
  --blue: #3b82f6;
  --blue-2: #2563eb;
  --cyan: #22d3ee;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  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; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- Grundlayout ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--blue), var(--cyan)); display: grid; place-items: center; font-weight: 800; letter-spacing: -.5px; color: #05070d; font-size: 13px; }
.brand b { display: block; font-size: 14px; letter-spacing: .2px; }
.brand span { display: block; font-size: 11px; color: var(--muted); }
.nav { padding: 4px 10px 16px; display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active { background: rgba(59, 130, 246, .14); color: var(--text); box-shadow: inset 2px 0 0 var(--blue); }
.nav a .badge { margin-left: auto; }
.side-foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.side-foot img, .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--panel-2); object-fit: cover; flex: none; }
.side-foot .who { min-width: 0; flex: 1; }
.side-foot .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who span { font-size: 11px; color: var(--muted); }

.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 14px; padding: 18px 28px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(5, 7, 13, .86); backdrop-filter: blur(10px); z-index: 5; }
.top h1 { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: -.2px; }
.top .sub { color: var(--muted); font-size: 12.5px; }
.top .grow { flex: 1; }
.menu-btn { display: none; }
.content { padding: 24px 28px 80px; max-width: 1280px; }

/* ---------- Bausteine ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2 { font-size: 14.5px; margin: 0 0 4px; font-weight: 650; }
.card h3 { font-size: 13px; margin: 18px 0 8px; color: var(--text-2); font-weight: 600; }
.card .desc { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head > div:first-child { flex: 1; min-width: 0; }
.card-head .desc { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--text-2); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { border-color: #33476f; background: #152038; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-2); }
.btn.success { background: rgba(16, 185, 129, .14); border-color: rgba(16, 185, 129, .45); color: #6ee7b7; }
.btn.danger { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .45); color: #fca5a5; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 34px; padding: 0; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.on { color: #6ee7b7; border-color: rgba(16, 185, 129, .4); }
.pill.on::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill.warn { color: #fcd34d; border-color: rgba(245, 158, 11, .4); }
.pill.warn::before { background: var(--amber); }
.pill.off { color: #fca5a5; border-color: rgba(239, 68, 68, .4); }
.pill.off::before { background: var(--red); }
.pill.plain::before { display: none; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--blue); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; color: var(--text-2); }
.tag .dot { width: 8px; height: 8px; border-radius: 50%; }

/* Formulare */
label.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label.field > span { font-size: 12.5px; color: var(--text-2); font-weight: 550; }
label.field > small { color: var(--muted); font-size: 11.5px; }
.input, select.input, textarea.input { width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 11px; color: var(--text); outline: none; min-width: 0; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59, 130, 246, .18); }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.5; }
input[type="color"].input { padding: 3px; height: 38px; cursor: pointer; }
.input-row { display: flex; gap: 8px; }
.input-row > * { flex: 1; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 11px; background: var(--line-2); transition: .15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #c7d2e5; transition: .15s; }
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px rgba(59, 130, 246, .35); }
.toggle-line { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.toggle-line:last-child { border-bottom: 0; }
.toggle-line > div { flex: 1; min-width: 0; }
.toggle-line b { display: block; font-weight: 550; font-size: 13.5px; }
.toggle-line small { color: var(--muted); font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; min-height: 40px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 9px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line-2); font-size: 12.5px; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 3px; line-height: 1; font-size: 15px; }
.chip button:hover { color: var(--red); }
.chips select { border: 0; background: transparent; color: var(--text-2); outline: none; flex: 1; min-width: 120px; padding: 4px; }
.chips select option { background: var(--panel); }

/* Tabellen & Listen */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; padding: 10px 12px; background: var(--bg-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: rgba(59, 130, 246, .05); }
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.item:last-child { border-bottom: 0; }
.item .body { flex: 1; min-width: 0; }
.item .body b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .body span { color: var(--muted); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 13px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; color: var(--text-2); cursor: pointer; font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--blue); }

/* Konsole */
.console { background: #03050a; border: 1px solid var(--line); border-radius: 8px; font: 12px/1.6 var(--mono); padding: 10px 12px; height: 320px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.console .l-warn { color: #fcd34d; }
.console .l-error { color: #fca5a5; }
.console .t { color: #3f4d68; margin-right: 8px; }
.console.tall { height: calc(100vh - 230px); min-height: 360px; }

/* Ticket-Chat */
.split { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 460px; }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 2px 10px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; }
.msg .avatar { width: 34px; height: 34px; }
.msg .b { min-width: 0; flex: 1; }
.msg .b .h { font-size: 12.5px; }
.msg .b .h b { color: var(--text); margin-right: 6px; }
.msg .b .h .bot { font-size: 10px; background: var(--blue); color: #fff; padding: 1px 5px; border-radius: 4px; margin-right: 6px; }
.msg .b .t { white-space: pre-wrap; word-break: break-word; color: #d8e1ef; }
.chat-input { display: flex; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.chat-input textarea { min-height: 44px; height: 44px; }

/* Discord-Vorschau */
.dc { background: #313338; border-radius: 8px; padding: 14px 16px; color: #dbdee1; font-family: "gg sans", "Noto Sans", var(--font); }
.dc .head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 14px; }
.dc .head b { color: #f2f3f5; }
.dc .head .app { font-size: 10px; background: #5865f2; color: #fff; padding: 1px 5px; border-radius: 3px; font-weight: 600; }
.dc .embed { display: grid; grid-template-columns: 1fr auto; gap: 8px; background: #2b2d31; border-left: 4px solid var(--blue); border-radius: 4px; padding: 10px 14px 12px 12px; max-width: 520px; margin-top: 4px; }
.dc .embed .et { font-weight: 700; color: #f2f3f5; margin-bottom: 4px; }
.dc .embed .ed { font-size: 14px; white-space: pre-wrap; line-height: 1.4; }
.dc .embed .ed strong { color: #f2f3f5; }
.dc .embed .thumb { width: 64px; height: 64px; border-radius: 4px; object-fit: cover; }
.dc .embed .eimg { grid-column: 1 / -1; max-width: 100%; border-radius: 4px; margin-top: 6px; }
.dc .embed .ef { grid-column: 1 / -1; font-size: 12px; color: #b5bac1; margin-top: 6px; }
.dc .mention { background: rgba(88, 101, 242, .3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; }

/* Rechte-Matrix */
.matrix th.rot { height: 130px; vertical-align: bottom; padding: 8px 4px; text-transform: none; letter-spacing: 0; }
.matrix th.rot div { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-size: 12px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.matrix th.rot .dot { width: 8px; height: 8px; border-radius: 50%; }
.matrix td.c { text-align: center; padding: 6px 4px; }
.matrix tr.group td { background: var(--bg-2); color: var(--cyan); font-weight: 650; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.matrix input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.matrix td.k { white-space: nowrap; }
.matrix td.k code { font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.matrix td.k small { display: block; color: var(--muted); font-size: 11.5px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; }

/* Template-Baum */
.tree .cat { margin-bottom: 12px; }
.tree .cat > b { font-size: 11.5px; letter-spacing: 1px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.tree .ch { display: flex; align-items: center; gap: 8px; padding: 3px 0 3px 14px; color: var(--text-2); font-size: 13px; }
.tree .ch .lvl { margin-left: auto; font-size: 11px; color: var(--muted); }

/* Toast & Dialog */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--blue); padding: 11px 14px; border-radius: 8px; max-width: 380px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); animation: tin .18s ease-out; }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }
.modal-bg { position: fixed; inset: 0; background: rgba(2, 4, 8, .72); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; padding: 22px; width: 100%; max-width: 480px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.modal h2 { margin: 0 0 6px; font-size: 16px; }
.modal p { color: var(--text-2); margin: 0 0 16px; }

.savebar { position: sticky; bottom: 16px; margin-top: 18px; display: flex; justify-content: flex-end; gap: 10px; z-index: 3; }
.savebar .inner { display: flex; gap: 10px; align-items: center; background: var(--panel-2); border: 1px solid var(--line-2); padding: 8px 8px 8px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; min-width: 0; }
.bars .bar i { display: block; width: 100%; max-width: 30px; background: linear-gradient(180deg, var(--cyan), var(--blue)); border-radius: 4px 4px 2px 2px; min-height: 2px; }
.bars .bar span { font-size: 10.5px; color: var(--muted); }
.bars .bar em { font-style: normal; font-size: 10.5px; color: var(--text-2); }

.bot-card { display: flex; align-items: center; gap: 16px; }
.bot-card .avatar { width: 64px; height: 64px; border: 2px solid var(--line-2); }
.bot-card h2 { font-size: 18px; margin: 0; }
.feed .item { padding: 8px 0; }
.feed .ic { width: 28px; height: 28px; border-radius: 7px; background: var(--panel-2); display: grid; place-items: center; color: var(--cyan); flex: none; }
.feed .ic svg { width: 15px; height: 15px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(900px 500px at 50% -10%, rgba(59, 130, 246, .18), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 32px; text-align: center; }
.login-card .brand-mark { width: 52px; height: 52px; font-size: 18px; border-radius: 13px; margin: 0 auto 16px; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card p { color: var(--text-2); margin: 0 0 24px; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; width: 100%; height: 44px; font-size: 15px; }
.btn.discord:hover { background: #4752c4; }
.login-card .note { margin-top: 18px; font-size: 12px; color: var(--muted); }
.login-card .err { margin-top: 16px; color: #fca5a5; font-size: 13px; }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .chat { height: 70vh; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, .6); }
  .menu-btn { display: inline-flex; }
  .top { padding: 14px 16px; }
  .content { padding: 18px 16px 80px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .top .sub { display: none; }
}
