:root {
  --bg: #111214;
  --surface: #1a1b1e;
  --surface-2: #232428;
  --border: #2e3035;
  --text: #e8e9eb;
  --muted: #9a9ca3;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #3ba55d;
  --danger: #ed4245;
  --warning: #f0b232;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f4f6;
    --surface: #ffffff;
    --surface-2: #f0f1f4;
    --border: #dfe1e6;
    --text: #1d1f23;
    --muted: #62656d;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 17px; margin-bottom: 12px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: Consolas, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--surface-2); color: var(--text); }
.account { display: flex; align-items: center; gap: 10px; }
.account form { margin: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; }
.bot-status { width: 9px; height: 9px; border-radius: 50%; }
.bot-status.online { background: var(--success); }
.bot-status.offline { background: var(--danger); }

.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px 60px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #c03537; }
.btn-discord { background: #5865f2; padding: 12px 16px; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* Layout */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 6px; font-size: 14px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.grid-2 > .card, .stack > .card, .grid-2 > form > .card:last-child { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.empty { text-align: center; padding: 40px; }

.center-card { min-height: 80vh; display: grid; place-items: center; }
.center-card .card { width: min(400px, 100%); text-align: center; padding: 32px; }
.center-card h1 { justify-content: center; }
.center-card .btn { margin-top: 20px; }
.brand-large .brand-mark { width: 56px; height: 56px; font-size: 26px; border-radius: 14px; margin-bottom: 12px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: rgb(59 165 93 / 0.12); border-color: rgb(59 165 93 / 0.4); }
.alert-error { background: rgb(237 66 69 / 0.12); border-color: rgb(237 66 69 / 0.4); }
.alert-warning { background: rgb(240 178 50 / 0.12); border-color: rgb(240 178 50 / 0.4); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value-sm { font-size: 20px; padding-top: 8px; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bar-label { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; vertical-align: middle; }
.badge-open { background: rgb(59 165 93 / 0.18); color: var(--success); }
.badge-closed { background: var(--surface-2); color: var(--muted); }

.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 16px; }

/* Formulare */
.form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.field { display: grid; gap: 6px; margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.form-grid .field { margin-bottom: 0; }
.field > span { font-size: 13px; font-weight: 600; }
input[type="text"], input[type="search"], input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type="color"] { width: 64px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input, .role input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.filters { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 12px; align-items: end; }
.filters .field { margin: 0; }
.filter-actions { display: flex; gap: 8px; }

.role-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; margin-top: 12px; }
.role { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.role:has(input:checked) { border-color: var(--accent); background: rgb(88 101 242 / 0.1); }
.role-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.questions { display: grid; gap: 10px; margin-top: 12px; }
.question { display: grid; grid-template-columns: 28px 2fr 2fr 110px 80px; gap: 12px; align-items: end; padding: 12px; background: var(--surface-2); border-radius: 8px; }
.question .field { margin: 0; }
.question .check { padding-bottom: 10px; }
.question-no { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--border); font-weight: 700; font-size: 13px; margin-bottom: 5px; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: fit-content; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 8px 18px; }
.segmented input:checked + span { background: var(--accent); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }

/* Details */
.details, .answers { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; margin: 0; }
.details dt, .answers dt { color: var(--muted); font-size: 14px; }
.details dd, .answers dd { margin: 0; overflow-wrap: anywhere; }
.answers { grid-template-columns: 1fr; gap: 4px; }
.answers dd { margin-bottom: 10px; }

/* Kategorien */
.category { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.category.inactive { opacity: 0.6; }
.category-main { display: flex; gap: 16px; align-items: flex-start; min-width: 0; }
.category-main h2 { margin-bottom: 2px; display: flex; gap: 8px; align-items: center; }
.category-emoji { font-size: 28px; line-height: 1; }
.meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 6px; }

/* Panel-Vorschau */
.discord-preview { background: #313338; color: #dbdee1; border-radius: 8px; padding: 16px; }
.embed-preview { border-left: 4px solid; background: #2b2d31; border-radius: 4px; padding: 10px 14px; font-size: 14px; }
.embed-preview-title { font-weight: 700; color: #f2f3f5; margin-bottom: 4px; }
.embed-preview-field { margin-top: 8px; }
.button-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.discord-button { background: #5865f2; color: #fff; padding: 6px 14px; border-radius: 4px; font-size: 14px; font-weight: 500; }
.select-preview { margin-top: 8px; background: #1e1f22; padding: 10px 12px; border-radius: 4px; color: #949ba4; }

/* Mobil */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .nav { order: 3; width: 100%; flex: none; }
  .account { margin-left: auto; }
  .account-name { display: none; }
  .container { padding: 20px 16px 48px; }
  .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr; }
  .question { grid-template-columns: 1fr 1fr; }
  .question-no { display: none; }
  .category { flex-direction: column; align-items: stretch; }
  .details { grid-template-columns: 1fr; gap: 2px; }
  .details dd { margin-bottom: 8px; }
}
