:root {
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1d212a;
  --surface-3: #262b36;
  --border: #272c37;
  --border-strong: #363c4a;
  --text: #e9ebf0;
  --muted: #8d95a5;
  --accent: #e8ac3e;
  --accent-soft: rgba(232, 172, 62, .14);
  --accent-text: #1b1405;
  --ok: #3fb56b;
  --ok-soft: rgba(63, 181, 107, .15);
  --danger: #ef5358;
  --danger-soft: rgba(239, 83, 88, .15);
  --info: #6b9bf5;
  --info-soft: rgba(107, 155, 245, .16);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .18);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; margin: 0; display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
h2 { font-size: 1rem; font-weight: 650; margin: 0 0 1rem; display: flex; align-items: center; gap: .6rem; }
code { background: var(--surface-3); padding: .1rem .4rem; border-radius: 5px; font: .88em ui-monospace, "Cascadia Code", Consolas, monospace; word-break: break-all; }
small { font-size: .55em; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.bad { color: var(--danger); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 252px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 1.25rem;
  padding: 1.25rem .9rem; background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .75rem; padding: .25rem .4rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 1.25rem; flex-shrink: 0;
  background: linear-gradient(135deg, #f2c35e, #d18f23); box-shadow: 0 4px 14px rgba(232, 172, 62, .28);
}
.brand-logo-lg { width: 56px; height: 56px; font-size: 1.75rem; border-radius: 15px; margin-bottom: 1rem; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text small { font-size: .78rem; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-title { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: .9rem .7rem .35rem; }
.nav-title:first-child { padding-top: 0; }
.sidebar nav a, .nav-button {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 550; border: 0; background: none; font: inherit; font-weight: 550; cursor: pointer; width: 100%;
}
.sidebar nav a:hover, .nav-button:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; }
.bot-state {
  display: flex; align-items: center; gap: .55rem; padding: .5rem .7rem; border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 550; background: var(--surface-2);
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.is-on .dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.is-off .dot { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.is-off { color: var(--danger); }

.content { flex: 1; min-width: 0; padding: 2rem 2.25rem 3rem; max-width: 1280px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.subtitle { margin: .3rem 0 0; color: var(--muted); }
.subtitle:empty { display: none; }
.page-actions { display: flex; gap: .5rem; }

/* ---------- Karten & Raster ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.35rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.card-danger { border-color: rgba(239, 83, 88, .35); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1.25rem; align-items: start; }
.split aside { position: sticky; top: 1.5rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { display: flex; align-items: center; gap: 1rem; margin: 0; color: var(--text); transition: border-color .15s, transform .15s; }
a.stat:hover { border-color: var(--border-strong); transform: translateY(-2px); text-decoration: none; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.stat-icon .icon { width: 22px; height: 22px; }
.tone-accent { background: var(--accent-soft); color: var(--accent); }
.tone-ok { background: var(--ok-soft); color: var(--ok); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-info { background: var(--info-soft); color: var(--info); }
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: .85rem; }

.empty { color: var(--muted); margin: 0; padding: .75rem 0; }
.count {
  font-size: .78rem; font-weight: 650; color: var(--muted); background: var(--surface-3);
  padding: .1rem .55rem; border-radius: 999px;
}
a.count { color: var(--text); }
a.count:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.rows li:last-child { border-bottom: 0; padding-bottom: 0; }
.rows li:first-child { padding-top: 0; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; margin: 0 -1.35rem -1.35rem; }
h2 + .table-wrap { margin-top: -.25rem; }
.card > .table-wrap:first-child { margin-top: -1.35rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem 1.35rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.ticket-id { font-weight: 650; font-variant-numeric: tabular-nums; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }
dl.stacked { display: block; }
dl.stacked dt { margin-top: .85rem; font-size: .82rem; }
dl.stacked dt:first-child { margin-top: 0; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 650;
  background: var(--surface-3); color: var(--muted); white-space: nowrap; vertical-align: middle;
}
.badge-open, .badge-untimeout, .badge-unban, .badge-unwarn, .badge-unlock { background: var(--ok-soft); color: #6bd892; }
.badge-closed, .badge-ban, .badge-kick, .badge-tempban { background: var(--danger-soft); color: #ff8b8f; }
.badge-warn, .badge-timeout, .badge-automod, .badge-lock { background: var(--accent-soft); color: var(--accent); }
.badge-team { background: var(--info-soft); color: #9fbdff; }

/* ---------- Formulare ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
input[type=text], input[type=password], select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: .6rem .75rem; font: inherit; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #5d6575; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 5rem; }
.field { margin-bottom: 1.15rem; }
.field:last-child { margin-bottom: 0; }
.field-wide { max-width: 760px; }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-grow { flex: 1; min-width: 200px; }
.field-emoji { width: 92px; }
.field-emoji input { text-align: center; font-size: 1.1rem; }
.field-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .4rem; }
.field-head label { margin: 0; }
.hint { color: var(--muted); font-size: .85rem; margin: .4rem 0 0; }
h2 + .hint { margin: -.5rem 0 1.1rem; }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 6px; }

.switch { display: inline-flex; align-items: center; gap: .65rem; cursor: pointer; margin: 0; font-weight: 550; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3); position: relative; flex-shrink: 0; transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  padding: .55rem 1rem; border-radius: var(--radius-sm); font: inherit; font-weight: 600; cursor: pointer;
  transition: filter .15s, background .15s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled, .icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-primary { background: linear-gradient(135deg, #f0bd55, #dc9a2b); border-color: transparent; color: var(--accent-text); }
.btn-primary:hover { background: linear-gradient(135deg, #f0bd55, #dc9a2b); filter: brightness(1.08); }
.btn-danger { background: var(--danger-soft); border-color: rgba(239, 83, 88, .4); color: #ff8b8f; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.icon-btn {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
}
.icon-btn:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }
.icon-btn-danger:hover:not(:disabled) { color: #fff; background: var(--danger); border-color: var(--danger); }

.form-actions { margin-top: .9rem; }
.btn-block { width: 100%; }
.nav-button.active { background: var(--accent-soft); color: var(--accent); }
.narrow { max-width: 560px; }
.card-highlight { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.warn { color: var(--accent); }
.login-card label { margin-top: .2rem; }
.login-foot { text-align: center; margin-top: 1rem; }
/* Rechte-Auswahl: Raster statt Tabelle, passt auch in schmale Spalten */
.perm-grid { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.perm-head, .perm-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 74px 86px; align-items: center; gap: .5rem;
  padding: .55rem .8rem;
}
.perm-head {
  background: var(--surface-2); color: var(--muted); font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
}
.perm-head span:not(:first-child), .perm-row > :not(:first-child) { justify-self: center; }
.perm-row { border-top: 1px solid var(--border); }
.perm-row:hover { background: var(--surface-2); }
.perm-label { font-weight: 600; font-size: .9rem; min-width: 0; }
.perm-label small { display: block; color: var(--muted); font-weight: 500; font-size: .76rem; line-height: 1.3; }
.perm-none { color: var(--muted); }
.switch input:disabled + .switch-track { opacity: .35; cursor: not-allowed; }
/* Benutzer-Seite: breitere rechte Spalte für das Einladungsformular */
.split-users { grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); }
.flash-action { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
#invite-link { font: .85rem ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--muted); }
.inline-form { display: flex; gap: .6rem; flex-wrap: wrap; }
.inline-form > input, .inline-form > select { flex: 1; min-width: 180px; width: auto; }
.inline-form-top { margin-top: 1.1rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }

.save-bar {
  position: sticky; bottom: 1rem; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: rgba(29, 33, 42, .92); backdrop-filter: blur(8px); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: .75rem .9rem .75rem 1.2rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); font-size: .88rem;
}

.filters { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.25rem; }
.filters select, .filters input[type=text] { width: auto; min-width: 210px; }
.tabs { display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.tabs a { padding: .4rem .95rem; color: var(--muted); border-radius: 7px; font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { background: var(--surface-3); color: var(--text); }

.toc { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.toc a { padding: .3rem .75rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: .85rem; font-weight: 600; }
.toc a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
section[id^=group-] { scroll-margin-top: 1rem; }

.flash { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem; border: 1px solid; font-weight: 550; }
.flash-ok { background: var(--ok-soft); border-color: rgba(63, 181, 107, .45); color: #8be3ac; }
.flash-error { background: var(--danger-soft); border-color: rgba(239, 83, 88, .45); color: #ff9a9d; }

/* ---------- Kategorien ---------- */
.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.cat-item { display: flex; align-items: center; gap: .9rem; padding: .75rem .9rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.cat-emoji { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-3); display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0; }
.cat-body { flex: 1; min-width: 0; }
.cat-body .muted { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-name { font-weight: 650; color: var(--text); }
.cat-actions { display: flex; gap: .35rem; align-items: center; }

.question { display: flex; gap: .9rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: .7rem; }
.question:last-child { margin-bottom: 0; }
.question-number { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem; display: grid; place-items: center; flex-shrink: 0; margin-top: 1.7rem; }
.question-body { flex: 1; min-width: 0; }
.question-body .field { margin-bottom: .8rem; }
.question-flags { display: flex; gap: 1.5rem; flex-wrap: wrap; font-size: .9rem; }

.style-picker { display: flex; gap: .5rem; flex-wrap: wrap; }
.style-option { margin: 0; cursor: pointer; }
.style-option input { position: absolute; opacity: 0; }
.style-option .dc-btn { opacity: .45; outline: 2px solid transparent; outline-offset: 2px; transition: opacity .15s; }
.style-option input:checked + .dc-btn { opacity: 1; outline-color: var(--text); }
.style-option input:focus-visible + .dc-btn { outline-color: var(--accent); }

.panel-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.panel-head h2 { margin: 0; }
.panel-head + .hint { margin: -.5rem 0 1.1rem; }

/* ---------- Discord-Vorschau ---------- */
.dc { background: #313338; border-radius: var(--radius-sm); padding: 1rem; color: #dbdee1; font-size: .9rem; }
.dc-embed { background: #2b2d31; border-left: 4px solid var(--accent); border-radius: 4px; padding: .75rem .9rem; }
.dc-title { font-weight: 700; color: #f2f3f5; margin-bottom: .35rem; }
.dc-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: .7rem; }
.dc-text:last-child { margin-bottom: 0; }
.dc-buttons { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .6rem; }
.dc-buttons:first-child { margin-top: 0; }
.dc-btn { display: inline-block; padding: .4rem .9rem; border-radius: 8px; color: #fff; font-weight: 600; font-size: .85rem; }
.dc-primary { background: #5865f2; }
.dc-secondary { background: #4e5058; }
.dc-success { background: #248046; }
.dc-danger { background: #da373c; }
.dc-modal { background: #2b2d31; border-radius: 8px; padding: 1rem; margin-top: .9rem; }
.dc-modal-title { font-size: 1.1rem; font-weight: 700; color: #f2f3f5; margin-bottom: .9rem; }
.dc-field { margin-bottom: .8rem; }
.dc-field-label { font-size: .78rem; font-weight: 700; color: #b5bac1; margin-bottom: .3rem; }
.dc-input { background: #1e1f22; border-radius: 6px; min-height: 2.3rem; padding: .5rem .65rem; color: #6d6f78; overflow-wrap: anywhere; }
.dc-input-long { min-height: 4.6rem; }
.dc-modal-foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* ---------- Ticket-Verlauf ---------- */
.messages { display: flex; flex-direction: column; gap: .7rem; }
.message { background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: var(--radius-sm); padding: .7rem .95rem; }
.message-staff { border-left-color: var(--info); }
.message-head { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .25rem; font-size: .9rem; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(900px 500px at 50% -10%, rgba(232, 172, 62, .16), transparent 70%);
}
.login-card { width: 100%; max-width: 380px; padding: 2rem; margin: 0; }
.login-card h1 { margin-bottom: .25rem; }
.login-card .muted { margin: 0 0 1.5rem; }
.login-card input { margin-bottom: 1.1rem; }
.login-card .btn { width: 100%; padding: .7rem; }

/* ---------- Schmale Bildschirme ---------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split aside { position: static; }
}
@media (max-width: 800px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--border); gap: .75rem; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: .25rem; }
  .sidebar nav a { width: auto; padding: .45rem .65rem; font-size: .9rem; }
  .sidebar-footer { flex-wrap: wrap; }
  .nav-title { display: none; }
  .sidebar-footer { flex-direction: row; align-items: center; margin-top: 0; }
  .sidebar-footer form { margin-left: auto; }
  .nav-button { width: auto; }
  .content { padding: 1.25rem 1rem 2.5rem; }
  .cat-item { flex-wrap: wrap; }
  .question-number { display: none; }
}
