:root {
  --bg: #0e0f1f;
  --sidebar: #11122a;
  --card: #191b38;
  --card2: #20234a;
  --text: #eef0ff;
  --muted: #9aa0c8;
  --border: #2c3066;
  --accent: #7c5cff;
  --accent2: #22d3ee;
  --pink: #ff5fa2;
  --green: #34d399;
  --orange: #fbbf24;
  --red: #f87171;
  --grad: linear-gradient(135deg, #7c5cff 0%, #2f80ff 100%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 15% 0%, #23266b 0%, var(--bg) 42%) fixed;
  min-height: 100vh;
}

a { color: var(--accent2); }
code { background: #0b0c1d; padding: 0.1rem 0.4rem; border-radius: 6px; color: var(--orange); font-size: 0.88em; }

/* ---------- Login (Vollbild) ---------- */
.login-screen {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  background: linear-gradient(120deg, #0e0f1f, #2a1a7a, #0a3a66, #3a1466, #0e0f1f);
  background-size: 400% 400%;
  animation: shift 16s ease infinite;
}
@keyframes shift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
.login-screen img { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 0 40px rgba(124, 92, 255, 0.6); margin-bottom: 1.2rem; }
.login-screen h1 { font-size: clamp(3rem, 9vw, 6.2rem); line-height: 1.05; font-weight: 800; margin: 0 0 0.4rem; background: linear-gradient(90deg, #fff, #9fd8ff, #c4b5fd); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-screen p { max-width: 560px; color: #cfd3ff; font-size: 1.15rem; margin: 0 0 2rem; }
.login-screen .btn { font-size: 1.15rem; padding: 0.9rem 2.4rem; border-radius: 14px; }
.login-error { color: var(--red); background: rgba(248, 113, 113, 0.12); padding: 0.6rem 1rem; border-radius: 10px; margin-bottom: 1.2rem; }

/* ---------- Kleine Zentrierbox (Einspruchsformular) ---------- */
.center-box {
  max-width: 440px;
  margin: 12vh auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2.2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* ---------- Serverübersicht ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 2.5rem 1.5rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; }
.topbar .brand { display: flex; align-items: center; gap: 0.8rem; font-size: 1.4rem; font-weight: 700; }
.topbar .brand img { width: 44px; height: 44px; border-radius: 12px; }
.topbar a { color: var(--muted); text-decoration: none; }
.topbar a:hover { color: var(--text); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.2rem; }
.server-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.server-card:hover { transform: translateY(-4px); box-shadow: 0 14px 40px rgba(124, 92, 255, 0.25); }
.server-card .icon { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 1rem; background: var(--grad); display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; overflow: hidden; }
.server-card .icon img { width: 100%; height: 100%; object-fit: cover; }
.server-card h3 { margin: 0 0 1rem; font-size: 1.05rem; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1.2rem; }

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

.sidebar {
  width: 270px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 1.3rem 0.9rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.7rem; font-size: 1.15rem; font-weight: 700; padding: 0 0.5rem; margin-bottom: 1rem; }
.sidebar-brand img { width: 36px; height: 36px; border-radius: 10px; }
.sidebar-server { display: flex; align-items: center; gap: 0.7rem; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 0.7rem; margin-bottom: 1.2rem; }
.sidebar-server .icon { width: 42px; height: 42px; border-radius: 50%; background: var(--grad); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.sidebar-server .icon img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-server .name { font-size: 0.92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-server .sub { font-size: 0.72rem; color: var(--muted); }

.nav-label { font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 0.9rem 0.7rem 0.3rem; }
.sidebar nav a { display: block; padding: 0.55rem 0.75rem; border-radius: 10px; color: #c3c8f5; text-decoration: none; font-size: 0.92rem; margin-bottom: 2px; }
.sidebar nav a:hover { background: var(--card2); color: #fff; }
.sidebar nav a.active { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 6px 20px rgba(124, 92, 255, 0.35); }
.sidebar-back { margin-top: auto; padding: 1rem 0.7rem 0; color: var(--muted); text-decoration: none; font-size: 0.85rem; }
.sidebar-back:hover { color: #fff; }

.main { flex: 1; padding: 2.2rem 2.5rem 4rem; max-width: 980px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.8rem; }
.page-head .emoji { width: 54px; height: 54px; border-radius: 16px; background: var(--grad); display: flex; align-items: center; justify-content: center; font-size: 1.7rem; box-shadow: 0 8px 24px rgba(124, 92, 255, 0.4); }
.page-head h1 { margin: 0; font-size: 1.7rem; }
.page-head p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.92rem; }
.main h1 { margin-top: 0; }

/* ---------- Sektionen & Formulare ---------- */
section {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: 14px;
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.4rem;
}
section:nth-of-type(4n+2) { border-left-color: var(--accent2); }
section:nth-of-type(4n+3) { border-left-color: var(--pink); }
section:nth-of-type(4n+4) { border-left-color: var(--orange); }
section h2 { margin: 0 0 0.9rem; font-size: 1.05rem; }
section h3 { font-size: 0.95rem; margin: 1.2rem 0 0.6rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: -0.4rem 0 1rem; }

label { display: block; margin-bottom: 1rem; font-size: 0.88rem; color: var(--muted); }
input[type=text], input[type=number], input[type=password], select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  background: #0d0e22;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25); }
textarea { resize: vertical; }

.btn {
  display: inline-block;
  background: var(--grad);
  color: #fff;
  border: none;
  padding: 0.62rem 1.3rem;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.93rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  transition: filter 0.15s, transform 0.1s;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn.secondary { background: var(--card2); border: 1px solid var(--border); margin-right: 0.4rem; }
.btn.green { background: linear-gradient(135deg, #10b981, #22d3ee); }
.btn.orange { background: linear-gradient(135deg, #f59e0b, #ef4444); }

button { font-family: inherit; }
td button, .card button, section form button:not(.btn):not(.emoji-btn) {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 8px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
}
td button:hover, .card button:hover { background: rgba(248, 113, 113, 0.3); }

table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
th, td { text-align: left; padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.92rem; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }

.inline-form { display: flex; gap: 0.6rem; align-items: flex-start; flex-wrap: wrap; }
.inline-form input, .inline-form select { margin-top: 0; }
.inline-form > * { flex: 1 1 140px; }
.inline-form .btn { flex: 0 0 auto; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 800px) { .row-2, .row-3 { grid-template-columns: 1fr; } .layout { flex-direction: column; } .sidebar { width: 100%; height: auto; position: static; } .main { padding: 1.5rem 1rem; } }

/* ---------- Schalter (Toggle) ---------- */
.switch-row { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1rem; color: var(--text); font-size: 0.95rem; }
.switch { position: relative; width: 48px; height: 26px; flex-shrink: 0; margin: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #3a3d6e; border-radius: 26px; cursor: pointer; transition: 0.2s; }
.slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ---------- Statistik-Karten ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1rem 1.2rem; border-top: 4px solid var(--accent); }
.stat:nth-child(2) { border-top-color: var(--orange); }
.stat:nth-child(3) { border-top-color: var(--green); }
.stat:nth-child(4) { border-top-color: var(--pink); }
.stat .num { font-size: 2rem; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 0.82rem; }
.bar { height: 12px; border-radius: 8px; background: #0d0e22; overflow: hidden; margin: 0.5rem 0 0.3rem; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--green), var(--accent2)); border-radius: 8px; }
.badge { display: inline-block; padding: 0.15rem 0.65rem; border-radius: 20px; font-size: 0.78rem; font-weight: 600; background: var(--card2); }
.badge.ok { background: rgba(52, 211, 153, 0.18); color: var(--green); }
.badge.warn { background: rgba(251, 191, 36, 0.18); color: var(--orange); }
.badge.bad { background: rgba(248, 113, 113, 0.18); color: var(--red); }

/* ---------- Emoji-Picker ---------- */
.emoji-field { display: flex; gap: 0.4rem; align-items: center; }
.emoji-field input { margin-top: 0; }
.emoji-btn { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--card2); font-size: 1.3rem; cursor: pointer; }
.emoji-btn:hover { border-color: var(--accent); }
.emoji-picker { position: absolute; z-index: 1000; width: 340px; background: #14153a; border: 1px solid var(--accent); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); padding: 0.6rem; }
.emoji-picker[hidden] { display: none; }
.emoji-tabs { display: flex; gap: 0.2rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.emoji-tabs button { background: transparent; border: 0; font-size: 1.2rem; padding: 0.25rem 0.45rem; border-radius: 8px; cursor: pointer; }
.emoji-tabs button.active, .emoji-tabs button:hover { background: var(--card2); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 220px; overflow-y: auto; }
.emoji-grid button { background: transparent; border: 0; font-size: 1.4rem; padding: 0.25rem; border-radius: 8px; cursor: pointer; }
.emoji-grid button:hover { background: var(--card2); }
.emoji-grid img { width: 26px; height: 26px; }

/* Hinweis-Boxen (Gespeichert / Fehler) */
.notice { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1.2rem; font-size: .92rem; border: 1px solid transparent; }
.notice.ok { background: rgba(52, 211, 153, .15); border-color: rgba(52, 211, 153, .5); color: #6ee7b7; }
.notice.err { background: rgba(239, 68, 68, .15); border-color: rgba(239, 68, 68, .5); color: #fca5a5; }
td .btn { margin-bottom: 0; padding: .4rem .8rem; }

.login-screen .welcome-sub { font-size: clamp(1.3rem, 3.2vw, 2.1rem); margin: 0 0 1.4rem; color: #e4e6ff; font-weight: 600; }

/* ---------- Rechtliches (Datenschutz / Nutzungsbedingungen) ---------- */
.legal-links { margin-top: 2.2rem; font-size: .85rem; color: var(--muted); }
.legal-links a { color: var(--muted); text-decoration: none; }
.legal-links a:hover { color: #fff; text-decoration: underline; }
.legal-page { max-width: 780px; margin: 0 auto; padding: 2.5rem 1.2rem 4rem; }
.legal-page .back { display: inline-block; margin-bottom: 1.5rem; text-decoration: none; }
.legal-page h1 { font-size: 2rem; margin: 0 0 .3rem; }
.legal-page h3 { margin: 1.8rem 0 .5rem; color: #c4b5fd; }
.legal-page li { margin: .3rem 0; line-height: 1.55; }
.legal-page p { line-height: 1.6; }
.sidebar .legal-links { margin: .6rem .5rem 0; font-size: .75rem; }

/* Rollen-Auswahl mit Häkchen */
.role-box { max-height: 160px; overflow-y: auto; background: #0b0c1d; border: 1px solid var(--line, #2a2c4a); border-radius: 10px; padding: .5rem .7rem; margin: .5rem 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .2rem .8rem; }
.role-box .check { display: flex; align-items: center; gap: .4rem; font-weight: 400; margin: 0; cursor: pointer; }
.role-box .check input { width: auto; margin: 0; }
details summary { cursor: pointer; }
