/* =========================================================
   SgtDev Panel
   Ein lautes Element (Rang-Abzeichen + Akzentbalken), sonst ruhig.
   ========================================================= */
:root {
  --night: #07090d;
  --surface: #0d121b;
  --surface-2: #131a27;
  --surface-3: #18212f;
  --line: #1d2635;
  --line-2: #273245;
  --text: #e2e8f0;
  --muted: #8392a7;
  --faint: #5b6779;
  --accent: #38bdf8;
  --accent-ink: #04121c;
  --signal: #f5b544;
  --ok: #34d399;
  --bad: #f87171;
  --r-s: 7px;
  --r-m: 10px;
  --r-l: 14px;
  --head: 'Chakra Petch', system-ui, sans-serif;
  --body: 'IBM Plex Sans', system-ui, sans-serif;
  --side: 252px;
}
* { box-sizing: border-box; }
html { background: var(--night); -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--text); background: var(--night); font: 15px/1.55 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--head); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: .005em; }
h1 { font-size: 27px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.num { font-family: var(--head); font-variant-numeric: tabular-nums; }
.ic { flex: none; display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------- Gerüst ---------------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: linear-gradient(180deg, var(--surface) 0%, var(--night) 70%); }
.brandmark { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; color: var(--text); }
.brandmark:hover { text-decoration: none; }
.brandmark svg { width: 36px; height: 36px; flex: none; }
.brandmark b { font-family: var(--head); font-size: 20px; font-weight: 700; display: block; line-height: 1.05; }
.brandmark span { font-size: 12px; color: var(--muted); }
.nav { padding: 4px 12px 16px; display: flex; flex-direction: column; }
.nav-label { font-size: 12px; color: var(--faint); padding: 16px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; color: var(--muted); padding: 8px 10px; border-radius: var(--r-s); font-size: 14.5px; position: relative; }
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.on { color: var(--text); background: var(--surface-2); }
.nav a.on::before { content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav a.on .ic { color: var(--accent); }
.nav .badge { margin-left: auto; font-size: 11px; font-weight: 600; background: var(--signal); color: #1a1200; border-radius: 999px; padding: 0 7px; line-height: 18px; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.me img { width: 34px; height: 34px; border-radius: 50%; }
.me div { min-width: 0; flex: 1; line-height: 1.25; }
.me b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me span { font-size: 12px; color: var(--muted); }
.me a { color: var(--muted); padding: 6px; border-radius: var(--r-s); }
.me a:hover { color: var(--text); background: var(--surface-2); }

.topbar { display: none; }
main { padding: 30px clamp(16px, 3.5vw, 44px) 64px; max-width: 1240px; width: 100%; }

/* Seitenkopf */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.page-head .actions-inline { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Bausteine ---------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 20px 22px; }
.card + .card, .stack > * + * { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head p { margin: 4px 0 0; }
.section { margin-bottom: 28px; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.g-form { grid-template-columns: minmax(0, 1.2fr) minmax(300px, 1fr); align-items: start; }

/* Kennzahlen: eine durchgehende Leiste */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); margin-bottom: 24px; overflow: hidden; }
.kpis > div { padding: 18px 20px; border-right: 1px solid var(--line); min-width: 0; }
.kpis > div:last-child { border-right: 0; }
.kpis strong { font-family: var(--head); font-size: 30px; font-weight: 600; display: block; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpis span { color: var(--muted); font-size: 13px; display: block; margin-top: 2px; }
.kpis em { font-style: normal; font-size: 12px; color: var(--faint); }
.kpis .hot strong { color: var(--signal); }

/* Tabellen */
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-l); overflow-x: auto; background: var(--surface); }
.card .table-wrap { border-radius: var(--r-m); background: transparent; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td.code, .code { font-family: var(--head); letter-spacing: .04em; white-space: nowrap; }
td.right, th.right { text-align: right; }
.empty { padding: 34px 20px; color: var(--muted); text-align: center; }

/* Liste (ohne Tabelle) */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; line-height: 18px; }
.pill.open, .pill.warn { color: var(--signal); border-color: color-mix(in srgb, var(--signal) 40%, transparent); }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.pill.acc { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--ok); flex: none; }
.dot.miss { background: var(--bad); }
.swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--surface-3); }
.avatar.lg { width: 60px; height: 60px; }
.person { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.person:hover { text-decoration: none; }
.person:hover b { color: var(--accent); }
.roles-inline { display: flex; flex-wrap: wrap; gap: 4px; }

/* Tabs */
.tabs { display: inline-flex; gap: 2px; background: var(--surface); padding: 3px; border-radius: var(--r-m); border: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { padding: 6px 13px; border-radius: var(--r-s); color: var(--muted); font-size: 14px; display: inline-flex; gap: 7px; align-items: center; }
.tabs a.on { background: var(--surface-3); color: var(--text); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs .count { font-size: 12px; color: var(--faint); }

/* Formulare */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--night); border: 1px solid var(--line-2); border-radius: var(--r-s); padding: 9px 11px; width: 100%; }
input[type=color] { padding: 3px; height: 40px; cursor: pointer; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.hint { font-size: 12.5px; color: var(--faint); margin-top: 6px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.row .field { margin-bottom: 0; }
.row:last-child { margin-bottom: 0; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--text); margin: 0 0 10px; cursor: pointer; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.lang-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.lang-pair label::before { margin-right: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 500 14px var(--body); padding: 9px 15px; border-radius: var(--r-s); border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-m); margin-bottom: 22px; border: 1px solid; background: var(--surface); }
.flash.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); color: var(--ok); }
.flash.error { border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); }
.notice { display: flex; gap: 12px; align-items: flex-start; border: 1px solid color-mix(in srgb, var(--signal) 35%, transparent); background: color-mix(in srgb, var(--signal) 7%, var(--surface)); padding: 13px 16px; border-radius: var(--r-m); margin-bottom: 20px; font-size: 14px; }
.notice .ic { color: var(--signal); margin-top: 2px; }
.notice.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.notice.bad .ic { color: var(--bad); }

/* Definitionen */
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px 24px; margin: 0; }
.meta dt { color: var(--muted); font-size: 12.5px; }
.meta dd { margin: 3px 0 0; }

/* Kanal-Auswahl */
.channel-pick { max-height: 300px; overflow: auto; border: 1px solid var(--line-2); border-radius: var(--r-s); padding: 8px 12px; background: var(--night); }
.channel-pick b { display: block; font-family: var(--head); font-weight: 500; font-size: 12.5px; color: var(--faint); margin: 10px 0 2px; }
.channel-pick b:first-child { margin-top: 2px; }
.channel-pick label { display: flex; gap: 9px; align-items: center; color: var(--text); font-size: 14px; margin: 0; padding: 4px 0; cursor: pointer; }

.role-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 16px; }
.role-list label { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 14px; margin: 0; padding: 6px 0; cursor: pointer; }
.role-list label.locked { color: var(--faint); cursor: not-allowed; }

/* Status-Raster (Server) */
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.status-grid > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 14px 16px; }
.status-grid h3 { font-size: 14px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.status-grid ul { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.status-grid li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 3px 0; color: var(--muted); }

/* Charts */
.chart-box { position: relative; height: 230px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Bewertungen */
.stars { color: var(--signal); letter-spacing: 2px; }
.bars div { display: grid; grid-template-columns: 34px 1fr 30px; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 7px; }
.bars i { display: block; height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bars i b { display: block; height: 100%; background: var(--signal); border-radius: 4px; }
.review { border-bottom: 1px solid var(--line); padding: 16px 0; }
.review:first-child { padding-top: 0; }
.review p { margin: 6px 0 0; max-width: 72ch; }

/* Umfrage-Balken */
.poll-opt { margin-bottom: 9px; }
.poll-opt div { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; gap: 10px; }
.poll-opt i { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.poll-opt i b { display: block; height: 100%; background: var(--accent); }

/* Ticket-Live-Chat */
.chat { display: flex; flex-direction: column; height: min(68vh, 720px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; margin-right: 6px; box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 88%; }
.msg img.avatar { width: 30px; height: 30px; }
.msg .bubble { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px 12px 12px 12px; padding: 9px 12px; min-width: 0; }
.msg.team { align-self: flex-end; flex-direction: row-reverse; }
.msg.team .bubble { background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); border-radius: 12px 4px 12px 12px; }
.msg .who { font-size: 12.5px; color: var(--muted); margin-bottom: 3px; display: flex; gap: 8px; }
.msg .who b { color: var(--text); font-weight: 600; }
.msg .text { white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; }
.msg .emb { border-left: 3px solid var(--accent); padding: 4px 10px; margin-top: 6px; font-size: 14px; }
.msg .emb b { display: block; }
.msg img.att { max-width: 260px; border-radius: 8px; margin-top: 6px; display: block; }
.chat-form { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-form textarea { min-height: 44px; max-height: 160px; height: 44px; flex: 1; }
.chat-closed { padding: 16px; color: var(--muted); border-top: 1px solid var(--line); text-align: center; }

/* Embed-Vorschau (Discord-ähnlich) */
.preview { background: #313338; border-radius: var(--r-m); padding: 16px; color: #dbdee1; font-family: 'gg sans', 'IBM Plex Sans', system-ui, sans-serif; }
.preview .pv-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.preview .pv-head img { width: 36px; height: 36px; border-radius: 50%; }
.preview .pv-head b { color: #f2f3f5; font-weight: 600; }
.preview .pv-head .bot { background: #5865f2; color: #fff; font-size: 10px; font-weight: 600; padding: 1px 5px; border-radius: 3px; }
.preview .pv-ping { color: #c9cdfb; background: rgba(88,101,242,.3); border-radius: 3px; padding: 0 3px; }
.preview .pv-embed { border-left: 4px solid var(--accent); background: #2b2d31; border-radius: 4px; padding: 10px 14px 12px; margin-top: 6px; max-width: 520px; }
.preview .pv-title { font-weight: 600; color: #f2f3f5; margin-bottom: 4px; }
.preview .pv-text { white-space: pre-wrap; font-size: 14px; line-height: 1.4; }
.preview .pv-img { max-width: 100%; border-radius: 4px; margin-top: 10px; display: block; }
.preview .pv-foot { font-size: 12px; color: #949ba4; margin-top: 8px; }
.preview .pv-btn { display: inline-block; margin-top: 8px; background: #4e5058; color: #fff; padding: 6px 14px; border-radius: 4px; font-size: 14px; }

.feed li { align-items: flex-start; }
.feed .when { font-size: 12px; color: var(--faint); white-space: nowrap; }

.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(600px 400px at 50% 30%, color-mix(in srgb, var(--accent) 10%, transparent), transparent); }
.login-box { width: min(380px, 100%); }
.login-box svg { width: 64px; height: 64px; display: block; margin-bottom: 28px; }
.login-box h1 { font-size: 34px; margin-bottom: 8px; }
.login-box p { color: var(--muted); margin: 0 0 28px; }
.login-box .btn { width: 100%; padding: 13px; font-size: 15px; }

/* ---------------- Mobil ---------------- */
@media (max-width: 960px) {
  .g-main, .g-form, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(290px, 85vw); z-index: 20; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.55); }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--night); z-index: 10; }
  .topbar .brandmark { padding: 0; }
  .topbar .brandmark svg { width: 28px; height: 28px; }
  .topbar button { background: none; border: 1px solid var(--line-2); color: var(--text); border-radius: var(--r-s); padding: 7px; cursor: pointer; }
  main { padding-top: 22px; }
  .g2, .lang-pair { grid-template-columns: 1fr; }
  .kpis > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .msg { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { transition: none !important; animation: none !important; } }

/* Textbausteine im Live-Chat */
.snippet-bar { padding: 10px 12px 0; border-top: 1px solid var(--line); background: var(--surface); }
.snippet-bar select { width: 100%; font-size: 14px; padding: 7px 10px; }
.snippet-bar + .chat-form { border-top: 0; }
.card h3 .ic { display: inline-block; vertical-align: -3px; margin-right: 4px; }
.day-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.day-pick label { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); border-radius: var(--r-s); padding: 6px 10px; margin: 0; color: var(--text); cursor: pointer; }
.device { display: flex; gap: 12px; align-items: center; }
.step-list { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.step-list li { counter-increment: s; position: relative; padding: 0 0 14px 38px; }
.step-list li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--line-2); display: grid; place-items: center; font-family: var(--head); font-size: 13px; }
