:root {
  --bg: #111214;
  --bg-2: #1a1b1e;
  --panel: #222327;
  --panel-2: #2b2d31;
  --border: #34363c;
  --text: #e6e7e9;
  --muted: #9a9ca3;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --green: #3ba55d;
  --red: #ed4245;
  --yellow: #f0b232;
  --orange: #faa61a;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 20px;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand img { width: 30px; height: 30px; border-radius: 50%; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip img { width: 28px; height: 28px; border-radius: 50%; }
.menu-toggle { display: none; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 56px); }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--border); padding: 16px 10px; }
.sidebar .guild-head { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; }
.sidebar .guild-head img, .guild-icon-fallback {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
}
.guild-icon-fallback {
  display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: var(--muted); margin-bottom: 2px;
}
.sidebar nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--panel-2); color: var(--text); }
.sidebar .back { display: block; padding: 9px 12px; color: var(--muted); font-size: .9rem; margin-top: 12px; }

.content { padding: 28px; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }

/* ---------- Komponenten ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
}
.card > h2:first-child { margin-bottom: 4px; }
.card > .muted:first-of-type { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.8rem; font-weight: 700; }
.stat .sub { color: var(--muted); font-size: .8rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 6px; padding: 8px 14px;
  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:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--border); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #c23336; }
.btn.success { background: var(--green); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn.lg { padding: 12px 22px; font-size: 1rem; }

input[type=text], input[type=number], input[type=search], select, textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; min-height: 80px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .02em; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row > .btn, .row > .shrink { flex: 0 0 auto; min-width: 0; }

/* Schalter */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; cursor: pointer; }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 12px; background: var(--border); position: relative; transition: background .15s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* Rollen-/Kanal-Auswahl */
.pick-list { max-height: 200px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); padding: 4px; }
.pick-list label { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 4px; cursor: pointer; }
.pick-list label:hover { background: var(--panel); }
.pick-list label.disabled { opacity: .45; cursor: not-allowed; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell img { width: 32px; height: 32px; border-radius: 50%; }
.user-cell .id { color: var(--muted); font-size: .8rem; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--panel-2); }
.badge.ban { background: rgba(237,66,69,.18); color: #ff7b7d; }
.badge.unban, .badge.untimeout { background: rgba(59,165,93,.18); color: #6fdc8c; }
.badge.kick { background: rgba(250,166,26,.18); color: #ffc260; }
.badge.timeout, .badge.warn { background: rgba(240,178,50,.15); color: #f6cf72; }
.role-chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; background: var(--panel-2); font-size: .78rem; margin: 2px 3px 2px 0; }

.empty { text-align: center; padding: 36px 12px; color: var(--muted); }
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 18px; border: 1px solid; }
.alert.warn { background: rgba(240,178,50,.1); border-color: rgba(240,178,50,.4); }

/* Server-Auswahl */
.guild-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.guild-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.guild-card img, .guild-card .guild-icon-fallback { width: 72px; height: 72px; border-radius: 22px; font-size: 1.6rem; }
.guild-card .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { max-width: 420px; text-align: center; padding: 40px 32px; }
.login .logo { font-size: 3rem; margin-bottom: 8px; }

/* Speichern-Leiste */
.save-bar {
  position: sticky; bottom: 16px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 460px; padding: 22px; }
.modal .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* Toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel-2); border-left: 4px solid var(--green); padding: 10px 14px; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.4); max-width: 360px; animation: slide .2s ease-out; }
.toast.error { border-left-color: var(--red); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }

.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 48px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

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

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; top: 56px; left: 0; bottom: 0; width: 260px; z-index: 20; overflow: auto; }
  .sidebar.open { display: block; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 18px 14px; }
  .user-chip .name { display: none; }
}

/* ---------- Ergänzungen Phase 1/2 ---------- */
.content.centered { margin: 0 auto; }
.nav-group { color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 14px 12px 4px; }
.field-label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .02em; }
.section-title { margin-top: 28px; }
.module-card { display: block; color: inherit; margin: 0; }
.module-card:hover { text-decoration: none; border-color: var(--accent); }
.module-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
a.stat { color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--accent); }
.badge.warn { background: rgba(240,178,50,.15); color: #f6cf72; }
tr.unread td { background: rgba(88,101,242,.06); }
.user-cell img.mini, .user-cell .guild-icon-fallback.mini { width: 32px; height: 32px; border-radius: 8px; font-size: .75rem; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--red); color: #fff; font-size: .72rem; line-height: 18px; text-align: center; }
.modal.wide { max-width: 720px; max-height: 90vh; overflow: auto; }
.modal small { display: block; margin-top: 4px; }
.report-list { display: flex; flex-direction: column; gap: 10px; max-height: 45vh; overflow: auto; }
.report-item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
input[type=file] { font: inherit; color: var(--muted); max-width: 100%; }

.profile-card { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
.profile-preview { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; padding-bottom: 16px; text-align: center; }
.profile-banner { height: 110px; background: var(--accent) center / cover no-repeat; }
.profile-preview img { width: 88px; height: 88px; border-radius: 50%; border: 6px solid var(--bg); margin-top: -44px; background: var(--bg); object-fit: cover; }
.profile-preview strong { display: block; font-size: 1.15rem; }

@media (max-width: 800px) {
  .profile-card { grid-template-columns: 1fr; }
  .hide-mobile { display: none; }
}
.btn.menu-toggle { display: none; }
@media (max-width: 800px) {
  .btn.menu-toggle { display: inline-flex; }
  .brand span { display: none; }
}

/* ---------- Phase 3: Community ---------- */
.alert.info { background: rgba(88,101,242,.1); border-color: rgba(88,101,242,.4); word-break: break-all; }
.xp-bar { height: 5px; width: 90px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 4px 0 2px; }
.xp-bar span { display: block; height: 100%; background: var(--accent); }
.rank-pos { font-weight: 700; font-size: 1.05rem; width: 40px; }
.danger-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.danger-row:first-of-type { border-top: 0; }
.reward-row .field { margin-bottom: 8px; }

/* ---------- Phase 4: Interaktion ---------- */
label.check { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; }
.poll-item { padding: 14px 0; border-top: 1px solid var(--border); }
.poll-item:first-child { border-top: 0; padding-top: 0; }
.poll-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 8px; flex-wrap: wrap; }
.poll-option { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr 90px; gap: 10px; align-items: center; padding: 3px 0; }
.poll-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.poll-bar span { display: block; height: 100%; background: var(--accent); }
.editor { border-color: var(--accent); }
.item-row .field { margin-bottom: 8px; }
@media (max-width: 800px) { .poll-option { grid-template-columns: 1fr 70px; } .poll-option .poll-bar { grid-column: 1 / -1; grid-row: 2; } }

/* ---------- Phase 5: Diagramme ---------- */
:root {
  --series-1: #3987e5; /* blau – geprüft auf dunkler Fläche (#222327) */
  --series-2: #d95926; /* orange */
}
.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .value-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart-tip { position: absolute; display: none; pointer-events: none; background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: .82rem; white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,.4); z-index: 2; }
.chart-tip .key, .chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.chart-legend.seq { gap: 2px; align-items: center; margin-top: 4px; }
.chart-legend.seq i { width: 16px; margin: 0; }
.chart-legend.seq span { margin: 0 6px; }
.chart-card h2 { margin: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.delta-good { color: #3fbf5f; }
.delta-bad { color: #ff7b7d; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; padding: 5px 0; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 14px; }
.hbar-track span { display: block; height: 100%; max-width: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.hbar-value { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.stat .sub span { font-weight: 600; }
input[type=password] { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font: inherit; }
.grid-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
@media (max-width: 900px) { .grid-charts { grid-template-columns: 1fr; } }

/* ---------- Phase 6: Nachrichten-Logging ---------- */
.alert.danger { background: rgba(237,66,69,.1); border-color: rgba(237,66,69,.45); }
pre.code { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; font-size: .82rem; overflow-x: auto; white-space: pre; margin: 0 0 14px; }
.notice { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 4px 16px; margin-bottom: 12px; }
.notice ol { padding-left: 20px; }
.notice li { margin-bottom: 6px; }
.checklist { list-style: none; padding: 0; margin: 12px 0 0; }
.checklist li { display: flex; gap: 10px; padding: 4px 0; }
.checklist li > span { font-weight: 700; width: 16px; }
.checklist li.ok > span { color: #3fbf5f; }
.checklist li.fail > span { color: #ff7b7d; }
#enable-btn:disabled { opacity: .45; }
