:root {
  --accent: #3b9cff;
  --accent2: #e63946;
  --text: #eef3fb;
  --muted: #9fb0c8;
  --glass: rgba(255, 255, 255, 0.07);
  --glass-strong: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.14);
  --ok: #2ecc71;
  --bad: #e74c3c;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background: #0a0f1a;
}
.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(circle at 15% 20%, rgba(59, 156, 255, .35), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(230, 57, 70, .28), transparent 40%),
    radial-gradient(circle at 60% 10%, rgba(120, 80, 255, .18), transparent 35%),
    linear-gradient(160deg, #0a0f1a, #111a2c);
}
.hidden { display: none !important; }
.glass {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}
.muted { color: var(--muted); }
.error { color: #ff8a8a; min-height: 1.2em; margin: 8px 0 0; }
h1, h2, h3 { margin: 0 0 6px; font-weight: 600; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.05rem; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { width: 100%; max-width: 360px; padding: 32px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.logo {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 18px; display: grid; place-items: center; font-size: 30px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.logo.small { width: 38px; height: 38px; font-size: 18px; border-radius: 11px; margin: 0; }

/* Layout */
.app { display: flex; gap: 18px; padding: 18px; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 18px; height: calc(100vh - 36px); }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; }
.brand small { display: block; color: var(--muted); font-size: .78rem; }
nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
nav a { padding: 10px 12px; border-radius: 10px; cursor: pointer; color: var(--muted); transition: .15s; user-select: none; }
nav a:hover { background: var(--glass); color: var(--text); }
nav a.active { background: var(--glass-strong); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.logout { margin-top: 10px; }
main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 18px; }

.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.card { padding: 20px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.stat { padding: 18px; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 600; margin-top: 4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot.off { background: var(--bad); box-shadow: 0 0 10px var(--bad); }

/* Formulare */
.form { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: .85rem; color: var(--muted); }
.field .hint { font-size: .75rem; color: var(--muted); opacity: .8; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; font: inherit; color: var(--text);
  background: rgba(0, 0, 0, .25); border: 1px solid var(--border); outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: rgba(0, 0, 0, .35); }
textarea { min-height: 90px; resize: vertical; }
select option { background: #151d2e; }
input[type=color] { padding: 3px; height: 42px; }

.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle .sw { width: 44px; height: 24px; border-radius: 12px; background: rgba(255, 255, 255, .15); position: relative; transition: .2s; flex-shrink: 0; }
.toggle .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle input:checked + .sw { background: var(--accent); }
.toggle input:checked + .sw::after { left: 23px; }

.roles { max-height: 190px; overflow-y: auto; background: rgba(0, 0, 0, .25); border: 1px solid var(--border); border-radius: 10px; padding: 6px; }
.roles label { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: .9rem; }
.roles label:hover { background: var(--glass); }
.roles input { width: auto; }
.roles .warn { color: #ffb36b; font-size: .72rem; margin-left: auto; }

.btn {
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border); font: inherit; cursor: pointer;
  color: var(--text); background: var(--glass-strong); transition: .15s;
}
.btn:hover { background: rgba(255, 255, 255, .2); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #2f6fe0); border-color: transparent; }
.btn.success { background: rgba(46, 204, 113, .25); border-color: rgba(46, 204, 113, .5); }
.btn.danger { background: rgba(231, 76, 60, .25); border-color: rgba(231, 76, 60, .5); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.list-item { padding: 14px; border-radius: 12px; background: rgba(0, 0, 0, .2); border: 1px solid var(--border); display: grid; gap: 10px; }
.list-item .row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: end; }
.stack { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
.badge { padding: 3px 9px; border-radius: 20px; font-size: .78rem; background: var(--glass-strong); white-space: nowrap; }
.badge.offen { background: rgba(255, 179, 107, .2); color: #ffc58a; }
.badge.angenommen { background: rgba(46, 204, 113, .2); color: #7deaa6; }
.badge.abgelehnt { background: rgba(231, 76, 60, .2); color: #ff9a8f; }
.log { font-family: Consolas, monospace; font-size: .8rem; max-height: 320px; overflow-y: auto; }
.log div { padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.log .t { color: var(--muted); margin-right: 8px; }
.log .ty { color: var(--accent); margin-right: 8px; }
.app-answers { display: grid; gap: 8px; margin-top: 8px; }
.app-answers b { display: block; font-size: .8rem; color: var(--muted); font-weight: 500; }
.app-answers p { margin: 2px 0 0; white-space: pre-wrap; }
details summary { cursor: pointer; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(120px);
  padding: 12px 20px; border-radius: 12px; background: rgba(20, 28, 45, .9); border: 1px solid var(--border);
  backdrop-filter: blur(12px); transition: .3s; z-index: 50; max-width: 90vw; opacity: 0; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.err { border-color: var(--bad); }

.btn.discord { background: #5865f2; border-color: transparent; text-decoration: none; display: block; font-weight: 600; }
.btn.discord:hover { background: #4752c4; }
a.btn { text-decoration: none; display: inline-block; text-align: center; }
.small-sep { margin: 14px 0 10px; font-size: .85rem; }
#loginForm { display: flex; flex-direction: column; gap: 12px; }
#loginForm.hidden { display: none; }
.guild-pick { display: flex; gap: 6px; margin: 0 4px 14px; }
.guild-pick select { flex: 1; min-width: 0; }
.me { display: flex; align-items: center; gap: 8px; padding: 10px 8px 0; font-size: .85rem; color: var(--muted); }
.me img { width: 26px; height: 26px; border-radius: 50%; }
.avatar { width: 28px; height: 28px; border-radius: 50%; vertical-align: middle; margin-right: 8px; background: var(--glass-strong); }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs .btn.active { background: linear-gradient(135deg, var(--accent), #2f6fe0); border-color: transparent; }
.search-results { display: grid; gap: 6px; margin-top: 8px; }
.search-results button { text-align: left; }
.badge.wartet { background: rgba(243, 156, 18, .25); color: #ffc66b; }
.badge.auto { background: rgba(155, 89, 182, .25); color: #d6a8ff; }
.badge.gelöst, .badge.erledigt { background: rgba(46, 204, 113, .2); color: #7deaa6; }
.badge.verlassen { background: rgba(127, 140, 141, .25); }
.table-wrap { overflow-x: auto; }
.invite-list { display: grid; gap: 10px; }
.invite-list .list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* Handy */
@media (max-width: 820px) {
  .app { flex-direction: column; padding: 10px; gap: 10px; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 8px; }
  .brand, .me { display: none; }
  .sidebar { flex-wrap: wrap; }
  .guild-pick { flex: 0 0 100%; margin: 0 0 8px; }
  nav { min-width: 0; flex: 1 1 200px; }
  nav { flex-direction: row; overflow-x: auto; }
  nav a { white-space: nowrap; }
  nav a span { display: none; }
  nav a.active span { display: inline; }
  .logout { margin: 0 0 0 6px; padding: 8px 10px; }
  .card { padding: 16px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 1.3rem; }
}
