/* ================================================================ Design-Tokens (Vercel-Stil: Schwarz/Weiß, Rot nur als Akzent) */

:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #030303;
  --line: rgba(255, 255, 255, .045);
  --dot: rgba(255, 255, 255, .07);
  --noise: .05;
  --glow: rgba(255, 255, 255, .065);
  --sidebar: rgba(0, 0, 0, .55);
  --card-shadow: none;
  --panel: #0a0a0a;
  --panel-solid: #0a0a0a;
  --panel-2: #111111;
  --hover: #161616;
  --input: #0a0a0a;
  --border: #1f1f1f;
  --border-strong: #333333;
  --text: #ededed;
  --muted: #a1a1a1;
  --faint: #6e6e6e;
  --mono-fill: #ededed;
  --track: #1a1a1a;
  --fill-soft: rgba(237, 237, 237, .08);
  --btn: #ededed;
  --btn-text: #0a0a0a;
  --btn-hover: #ffffff;
  --ring: rgba(255, 255, 255, .14);
  --accent: #e5484d;
  --accent-soft: rgba(229, 72, 77, .14);
  --accent-text: #ff6369;
  --green: #45c387;
  --green-soft: rgba(69, 195, 135, .12);
  --orange: #f1a10d;
  --orange-soft: rgba(241, 161, 13, .12);
  --red: #e5484d;
  --red-soft: rgba(229, 72, 77, .12);
  --shadow: rgba(0, 0, 0, .6);
  --sk1: #0f0f0f;
  --sk2: #1c1c1c;
  --log-bg: #050505;
  --log-text: #c7c7c7;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f2f3;
  --line: rgba(0, 0, 0, .05);
  --dot: rgba(0, 0, 0, .085);
  --noise: .045;
  --glow: rgba(255, 255, 255, .9);
  --sidebar: rgba(250, 250, 250, .7);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 18px rgba(0, 0, 0, .04);
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --panel-2: #f7f7f8;
  --hover: #ececee;
  --input: #ffffff;
  --border: #e2e2e5;
  --border-strong: #c4c4c9;
  --text: #171717;
  --muted: #666666;
  --faint: #8f8f8f;
  --mono-fill: #171717;
  --track: #f0f0f0;
  --fill-soft: rgba(23, 23, 23, .06);
  --btn: #171717;
  --btn-text: #ffffff;
  --btn-hover: #383838;
  --ring: rgba(0, 0, 0, .12);
  --accent: #d93036;
  --accent-soft: rgba(217, 48, 54, .08);
  --accent-text: #c4282e;
  --green: #18794e;
  --green-soft: rgba(24, 121, 78, .09);
  --orange: #a35200;
  --orange-soft: rgba(163, 82, 0, .09);
  --red: #c4282e;
  --red-soft: rgba(196, 40, 46, .08);
  --shadow: rgba(0, 0, 0, .08);
  --sk1: #f5f5f5;
  --sk2: #ebebeb;
  --log-bg: #0a0a0a;
  --log-text: #d4d4d4;
}

:root {
  --radius: 12px;
  --radius-sm: 8px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: "Geist", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Geist Mono", Consolas, "Cascadia Mono", monospace;
}

/* ================================================================ Basis */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background-color: var(--bg);
  /* feines Punktraster als Textur */
  background-image: radial-gradient(circle at 1px 1px, var(--dot) 1px, transparent 0);
  background-size: 24px 24px;
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}
/* weicher Lichtschein oben wie auf vercel.com */
body::before {
  content: ""; position: fixed; left: 50%; top: -340px; width: 1100px; height: 640px; transform: translateX(-30%);
  pointer-events: none; z-index: 0; border-radius: 50%;
  background: radial-gradient(ellipse at center, var(--glow), transparent 68%);
}
/* leichte Körnung über dem Hintergrund (SVG-Rauschen), liegt hinter allen Inhalten */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: var(--noise);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
.hidden { display: none !important; }
code, pre, .mono { font-family: var(--font-mono); font-size: .92em; }
code { background: var(--panel-2); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; }
.ti { font-size: 1.15em; line-height: 1; vertical-align: -.12em; }
::selection { background: var(--fill-soft); }

/* ================================================================ Login */

.login { position: relative; display: flex; align-items: center; justify-content: center; height: 100%; overflow: hidden; z-index: 1; }
.login-bg {
  position: absolute; inset: -50%;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  transform: perspective(700px) rotateX(58deg);
  animation: gridMove 20s linear infinite;
  mask-image: radial-gradient(ellipse at center, #000 15%, transparent 58%);
}
.login-glow {
  position: absolute; width: 560px; height: 560px; border-radius: 50%;
  background: radial-gradient(circle, var(--glow), transparent 62%);
  filter: blur(10px);
  animation: breathe 6s ease-in-out infinite alternate;
}
.login-box {
  position: relative; width: min(400px, calc(100% - 32px)); text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px 32px 30px; box-shadow: 0 40px 100px var(--shadow);
  animation: fadeUp .7s var(--ease) both;
}
.login-box h1 { margin: 18px 0 0; font-size: 28px; font-weight: 600; letter-spacing: -.04em; }
.login-box > p { margin: 2px 0 24px; }
.logo {
  width: 52px; height: 52px; margin: 0 auto; border-radius: 13px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 26px; box-shadow: 0 0 40px var(--accent-soft);
}
.terminal {
  text-align: left; font-family: var(--font-mono); font-size: 13px;
  background: var(--log-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 22px; min-height: 44px; color: var(--log-text);
}
.terminal .prompt { color: var(--faint); }
.caret { display: inline-block; width: 7px; height: 15px; background: var(--log-text); vertical-align: -2px; margin-left: 2px; animation: blink 1s step-end infinite; }

/* ================================================================ Layout */

.app { position: relative; z-index: 1; display: flex; height: 100%; }
.sidebar {
  width: 256px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; padding: 18px 12px;
  background: var(--sidebar); border-right: 1px solid var(--border);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 6px; }
.brand b { display: block; font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.brand .muted { display: block; font-size: 12px; }
.logo-sm {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--accent); color: #fff; font-size: 17px;
}
.guild-select { width: 100%; }
nav { position: relative; display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 12px; font-weight: 500; color: var(--faint); padding: 16px 10px 6px; }
nav a {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; text-decoration: none;
  color: var(--muted); padding: 7px 10px; border-radius: 6px; font-weight: 400;
  transition: color .15s, background .15s;
}
nav a .ti { font-size: 17px; }
nav a:hover { color: var(--text); background: var(--hover); text-decoration: none; }
nav a.active { color: var(--text); font-weight: 500; background: transparent; }
.nav-indicator {
  position: absolute; left: 0; right: 0; top: 0; height: 0; z-index: 0; border-radius: 6px;
  background: var(--hover);
  transition: top .35s var(--ease), height .35s var(--ease), opacity .2s;
}
.nav-indicator::before {
  content: ""; position: absolute; left: 0; top: 28%; bottom: 28%; width: 2px; border-radius: 0; background: var(--accent);
}
/* dezente Credits über dem Benutzerbereich */
.credits { padding: 0 10px 4px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.credits-label { color: var(--faint); font-size: 11px; margin-bottom: 2px; }
.credits a { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); text-decoration: none; width: fit-content; transition: color .15s; }
.credits a .ti { font-size: 14px; color: var(--faint); transition: color .15s; }
.credits a:hover, .credits a:hover .ti { color: var(--text); }
.user { display: flex; align-items: center; gap: 8px; padding: 8px; border-top: 1px solid var(--border); }
.user img { width: 28px; height: 28px; border-radius: 50%; }
.user span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.icon-btn {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 99px; border: 1px solid transparent; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 16px; transition: background .15s, color .15s, border-color .15s, transform .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); border-color: var(--border); text-decoration: none; }
.icon-btn:active { transform: scale(.92); }
main { flex: 1; overflow-y: auto; padding: 40px 48px 72px; }
main > * { max-width: 1200px; margin-left: auto; margin-right: auto; }

/* Seitenkopf: groß, eng gesetzt, ohne Icon-Kachel */
.page-head { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.page-icon { display: none; }
.page-head h1 { margin: 0; font-size: 32px; font-weight: 600; letter-spacing: -.045em; line-height: 1.2; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }

/* ================================================================ Bausteine */

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-bottom: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--card-shadow);
  transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: var(--border-strong); }
.grid .card { margin-bottom: 0; }
.card p { margin: 0 0 6px; }
.card h2 {
  display: flex; align-items: center; gap: 8px; margin: 0 0 16px;
  font-size: 14px; font-weight: 500; color: var(--text); letter-spacing: -.01em;
}
.card h2 .ti { color: var(--muted); font-size: 16px; }
h2.section { font-size: 18px; font-weight: 600; letter-spacing: -.03em; margin: 28px 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row + .row { margin-top: 12px; }
.spacer { flex: 1; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.stat-value { font-size: 34px; font-weight: 600; letter-spacing: -.045em; font-variant-numeric: tabular-nums; margin: 2px 0 0; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
input, select, textarea {
  background: var(--input); color: var(--text); border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 7px 11px; font: inherit; transition: border-color .15s, box-shadow .15s;
}
select option, select optgroup { background: var(--panel-solid); color: var(--text); }
input:hover, select:hover { border-color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px var(--ring); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--text); padding: 0; }
input[type=number] { width: 110px; font-family: var(--font-mono); }
input[type=date] { font-family: var(--font-mono); }

/* Buttons: Pillenform, primär schwarz/weiß invertiert */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px;
  border: 1px solid var(--border-strong); border-radius: 99px; padding: 0 16px; font: inherit; font-weight: 500; cursor: pointer;
  background: transparent; color: var(--text); text-decoration: none;
  transition: background .15s, border-color .15s, transform .15s, color .15s;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-primary { background: var(--btn); border-color: var(--btn); color: var(--btn-text); }
.btn-primary:hover { background: var(--btn-hover); border-color: var(--btn-hover); }
.btn-danger { border-color: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-small { height: 28px; padding: 0 11px; font-size: 12px; }
.btn-big { height: 44px; padding: 0 22px; font-size: 15px; width: 100%; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--panel-2); }
thead th:first-child { border-top-left-radius: 6px; }
thead th:last-child { border-top-right-radius: 6px; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }

.bar { height: 6px; background: var(--track); border-radius: 99px; overflow: hidden; margin: 7px 0 15px; }
.bar > div { height: 100%; border-radius: 99px; background: var(--mono-fill); animation: grow .9s var(--ease) both; transition: width .6s var(--ease); }
.bar > div.accent { background: var(--mono-fill); }
.bar > div.warn { background: var(--orange); }
.bar > div.crit { background: var(--red); }
.meter-label { display: flex; justify-content: space-between; font-size: 13px; }
.meter-label span:last-child { font-family: var(--font-mono); color: var(--muted); font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 99px; padding: 2px 6px 2px 11px;
  display: inline-flex; align-items: center; gap: 4px; font-size: 13px; animation: pop .25s var(--ease) both;
}
.chip a { text-decoration: none; }
.chip button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 4px; border-radius: 50%; }
.chip button:hover { color: var(--red); }
.chip-static { padding: 2px 11px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 0 9px; height: 22px; font-size: 12px; font-weight: 500;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge-red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge-orange { background: var(--orange-soft); color: var(--orange); border-color: transparent; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; position: relative; flex-shrink: 0; }
.pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: currentColor; animation: ping 1.8s var(--ease) infinite; }

/* ================================================================ Log-Einträge */

.entry {
  display: flex; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--card-shadow);
  margin-bottom: 8px; overflow: hidden; transition: border-color .15s;
  animation: fadeUp .35s var(--ease) both;
}
.entry:hover { border-color: var(--border-strong); }
.entry .stripe { width: 3px; flex-shrink: 0; }
.entry .body { padding: 12px 16px; flex: 1; min-width: 0; }
.entry .head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.entry .title { font-weight: 500; }
.entry .time { font-family: var(--font-mono); font-size: 12px; color: var(--faint); }
.entry .desc { margin-top: 3px; overflow-wrap: anywhere; color: var(--muted); }
.entry .fields { margin-top: 10px; display: grid; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--border); }
.entry .field-name { font-weight: 500; font-size: 12px; color: var(--faint); }
.entry .field-value { overflow-wrap: anywhere; }
.entry .who a { font-weight: 500; text-decoration: none; }
.entry .who a:hover { text-decoration: underline; }
.mention { background: var(--fill-soft); color: var(--text); border-radius: 4px; padding: 0 4px; text-decoration: none; }
a.mention:hover { background: var(--text); color: var(--bg); text-decoration: none; }

.events { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 7px 16px; margin: 12px 0 4px 2px; }
.events label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
details > summary { cursor: pointer; color: var(--muted); font-size: 13px; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
details > summary:hover { color: var(--text); }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; display: inline-block; transition: transform .2s; font-size: 16px; }
details[open] > summary::before { transform: rotate(90deg); }
details[open] > *:not(summary) { animation: fadeUp .3s var(--ease) both; }

pre.log {
  background: var(--log-bg); color: var(--log-text); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px;
  max-height: 440px; overflow: auto; font-size: 12px; line-height: 1.7; white-space: pre-wrap; word-break: break-all; margin: 0;
}
.chart-box { position: relative; height: 240px; }
.profile-head { display: flex; gap: 18px; align-items: center; }
.profile-head img { width: 72px; height: 72px; border-radius: 50%; border: 1px solid var(--border-strong); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 18px; font-family: var(--font-mono); font-size: 13px; }
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty .ti { display: block; font-size: 28px; margin: 0 auto 10px; color: var(--faint); }

/* Lade-Platzhalter */
.skeleton {
  border-radius: var(--radius); background: linear-gradient(90deg, var(--sk1) 25%, var(--sk2) 37%, var(--sk1) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
}

/* Benachrichtigungen */
.toasts { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.toast {
  display: flex; align-items: center; gap: 10px; background: var(--panel-solid); border: 1px solid var(--border);
  padding: 12px 16px; border-radius: 10px; box-shadow: 0 16px 40px var(--shadow); max-width: 400px;
  animation: toastIn .35s var(--ease) both;
}
.toast .ti { color: var(--green); font-size: 18px; }
.toast.error .ti { color: var(--red); }
.toast.out { animation: toastOut .3s var(--ease) both; }

/* Seitenwechsel: Inhalte gleiten zeitversetzt ein */
.page > * { animation: fadeUp .5s var(--ease) both; }
.page > *:nth-child(2) { animation-delay: .05s; }
.page > *:nth-child(3) { animation-delay: .1s; }
.page > *:nth-child(4) { animation-delay: .15s; }
.page > *:nth-child(5) { animation-delay: .2s; }
.page > *:nth-child(6) { animation-delay: .25s; }
.page > *:nth-child(n+7) { animation-delay: .3s; }
.page .grid > .card { animation: fadeUp .5s var(--ease) both; }
.page .grid > .card:nth-child(2) { animation-delay: .08s; }
.page .grid > .card:nth-child(3) { animation-delay: .16s; }

/* ================================================================ Animationen */

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes grow { from { width: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
@keyframes ping { 0% { transform: scale(1); opacity: .7; } 80%, 100% { transform: scale(2.6); opacity: 0; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes gridMove { from { background-position: 0 0; } to { background-position: 0 56px; } }
@keyframes breathe { from { transform: scale(.9); opacity: .7; } to { transform: scale(1.1); opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(16px) scale(.97); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    animation-delay: 0s !important; transition-duration: .01ms !important;
  }
}

@media (max-width: 860px) {
  .app { flex-direction: column; height: auto; min-height: 100%; }
  .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); }
  nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label, .nav-indicator { display: none; }
  nav a.active { background: var(--hover); }
  main { padding: 24px 16px 48px; }
  .page-head h1 { font-size: 26px; }
  .kv { grid-template-columns: 1fr; }
}
