:root {
  /* Surfaces — premium flat dark (mechanic design system) */
  --bg-0: #09090b;            /* page base */
  --bg-1: #141418;            /* inputs / sidebar wells */
  --bg-2: #141417;            /* cards */
  --bg-3: #1b1b1f;            /* zinc-800 — elevated / secondary */
  --bg-hover: #1b1b1f;        /* row / item hover */
  --border: rgba(255, 255, 255, 0.07);
  --border-bright: rgba(255, 255, 255, 0.13);
  /* Text */
  --text: #fafafa;
  --text-2: #a1a1aa;          /* zinc-400 */
  --text-3: #71717a;          /* zinc-500 */
  /* Brand accent — blue */
  --accent: #3b82f6;          /* blue-500 */
  --accent-hover: #2563eb;    /* blue-600 */
  --accent-soft: rgba(59, 130, 246, 0.15);
  /* Status — Tailwind palette (badges use the -400 text tone) */
  --success: #22c55e;
  --success-text: #4ade80;
  --success-soft: rgba(34, 197, 94, 0.18);
  --warning: #eab308;
  --warning-text: #facc15;
  --warning-soft: rgba(234, 179, 8, 0.18);
  --danger: #ef4444;
  --danger-text: #f87171;
  --danger-soft: rgba(239, 68, 68, 0.18);
  --info: #0ea5e9;
  --info-text: #38bdf8;
  --info-soft: rgba(14, 165, 233, 0.18);
  /* Radii */
  --radius: 12px;             /* cards — rounded-xl */
  --radius-md: 6px;           /* buttons / inputs — rounded-md */
  --radius-lg: 8px;           /* nav items — rounded-lg */
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
  font-family: 'Geist', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-0);
  background-image: radial-gradient(900px 380px at 50% -140px, rgba(255, 255, 255, 0.035), transparent 70%);
  color: var(--text); min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }

/* Custom scrollbar (mechanic) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #18181b; }
::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #52525b; }

/* ─── Login ─────────────────────────────────────── */
#login-overlay {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg-0);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(59,130,246,0.12) 0%, transparent 60%);
}
.login-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.5rem 2.25rem; width: 100%; max-width: 380px;
  text-align: center;
}
.login-logo {
  width: 64px; height: 64px; margin: 0 auto 1.25rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #fff; font-size: 2.2rem; font-weight: 700; line-height: 1;
  box-shadow: 0 10px 30px rgba(59, 130, 246, 0.35);
}
.login-card h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.3rem; }
.login-card .subtitle { color: var(--text-2); font-size: 0.85rem; margin-bottom: 1.1rem; }
.login-hint { color: var(--text-3); font-size: 0.85rem; line-height: 1.55; margin-bottom: 1.75rem; }
.btn-discord { display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  width: 100%; padding: 0.85rem; border-radius: var(--radius-md); border: none; text-decoration: none;
  background: #5865f2; color: #fff; font-weight: 600; font-size: 0.95rem;
  cursor: pointer; transition: background 0.2s; font-family: inherit; box-sizing: border-box; }
.btn-discord:hover { background: #4752c4; color: #fff; }
.login-error { color: var(--danger); font-size: 0.85rem; margin-bottom: 0.75rem; }

/* ─── Layout ────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }
#main-wrap { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ─── Sidebar ───────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w); background: transparent; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0;
  z-index: 100; overflow: hidden; transition: width 0.2s;
}
.nav-items::-webkit-scrollbar { width: 4px; }
.nav-items::-webkit-scrollbar-track { background: transparent; }
.nav-items::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 4px; }
.nav-items::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
.sidebar-header {
  display: flex; align-items: center; gap: 0.65rem; flex-shrink: 0;
  height: var(--topbar-h); padding: 0 1rem; border-bottom: 1px solid var(--border);
}
.sidebar-header .logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-lg); flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #fff; font-size: 1.15rem; font-weight: 700; line-height: 1;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}
.brand-meta { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; color: var(--text); line-height: 1.2; }
.sidebar-header .bot-tag {
  font-size: 0.7rem; color: var(--text-3); font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3;
}
.nav-items {
  list-style: none; padding: 0.5rem; flex: 1; min-height: 0; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--border-bright) transparent;
}
.nav-items li { margin-bottom: 2px; }
.nav-standalone { padding-bottom: 0.4rem; margin-bottom: 0.4rem; border-bottom: 1px solid var(--border); }
.nav-group { margin-top: 0.25rem; }
.nav-category {
  padding: 0.5rem 0.75rem 0.35rem; margin-top: 0.25rem;
  font-size: 0.6875rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.05em; color: #52525b; user-select: none;
}
.nav-group-items { list-style: none; padding: 0; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.75rem; border-radius: var(--radius-lg);
  color: var(--text-2); font-size: 0.875rem; font-weight: 500;
  transition: background 0.15s, color 0.15s; cursor: pointer;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-item .icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-item .icon svg { width: 16px; height: 16px; }
.nav-badge {
  margin-left: auto; min-width: 1.15rem; height: 1.15rem; padding: 0 0.35rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9999px; background: var(--accent-soft); color: var(--accent);
  font-size: 0.7rem; font-weight: 600; flex-shrink: 0;
}
.nav-badge:empty { display: none; }
.nav-item.active .nav-badge { background: rgba(59, 130, 246, 0.25); }
/* ─── Topbar ─────────────────────────────────────── */
#topbar {
  position: sticky; top: 0; z-index: 90;
  height: var(--topbar-h); background: rgba(9, 9, 11, 0.7);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; gap: 1rem; flex-shrink: 0;
}
#topbar-left { display: flex; align-items: center; }
#topbar-right { display: flex; align-items: center; gap: 0.75rem; }
#current-guild {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.35rem 0.75rem 0.35rem 0.45rem; border-radius: 9999px;
  border: 1px solid var(--border); background: var(--bg-2);
  max-width: 280px;
}
#current-guild-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.75rem; font-weight: 700;
}
#current-guild-icon img { width: 100%; height: 100%; object-fit: cover; }
#current-guild-icon svg { width: 15px; height: 15px; }
#current-guild-name {
  font-size: 0.875rem; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* ─── User menu (top-right dropdown) ─────────────── */
#user-menu { position: relative; }
#user-menu-trigger {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.5rem 0.3rem 0.35rem; border-radius: var(--radius-lg);
  background: transparent; border: none; cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
#user-menu-trigger:hover,
#user-menu-trigger[aria-expanded="true"] { background: rgba(255, 255, 255, 0.05); }
#topbar-avatar {
  width: 30px; height: 30px; border-radius: 50%; overflow: hidden;
  background: var(--accent-soft); display: flex; align-items: center;
  justify-content: center; font-size: 0.8rem; font-weight: 700;
  color: var(--accent); flex-shrink: 0;
}
#topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
#topbar-username { font-size: 0.85rem; font-weight: 500; color: var(--text); white-space: nowrap; }
#topbar-role { font-size: 0.6875rem; color: var(--text-3); margin-top: 1px; white-space: nowrap; }
.user-caret { display: inline-flex; color: var(--text-3); }
.user-caret svg { width: 16px; height: 16px; }

#user-menu-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 200;
  min-width: 200px; padding: 0.3rem;
  background: var(--bg-2); border: 1px solid var(--border-bright);
  border-radius: var(--radius-md); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.user-menu-label {
  padding: 0.4rem 0.6rem; font-size: 0.78rem; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-menu-sep { height: 1px; background: var(--border); margin: 0.3rem 0; }
.user-menu-item {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  padding: 0.5rem 0.6rem; border: none; background: transparent;
  border-radius: var(--radius-md); cursor: pointer; font-family: inherit;
  font-size: 0.875rem; color: var(--text-2); text-align: left;
  transition: background 0.12s, color 0.12s;
}
.user-menu-item svg { width: 16px; height: 16px; }
.user-menu-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.user-menu-danger { color: var(--danger-text); }
.user-menu-danger:hover { background: var(--danger-soft); color: var(--danger-text); }

/* ─── Main Content ──────────────────────────────── */
#content {
  flex: 1; padding: 1.75rem 2rem;
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.015em; }

/* ─── Cards ─────────────────────────────────────── */
.card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem;
}
.card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--text); }

/* ─── Stats Grid ────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; display: flex; align-items: center; gap: 1rem;
}
.stat-icon {
  font-size: 1.35rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; border-radius: var(--radius-lg);
  background: var(--bg-3);
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-info { min-width: 0; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-label { font-size: 0.8rem; color: var(--text-2); }
/* Accent tints kept subtle and flat (no gradient) — icon well only */
.stat-purple .stat-icon { background: var(--accent-soft); color: var(--accent); }
.stat-blue .stat-icon { background: var(--info-soft); color: var(--info); }
.stat-green .stat-icon { background: var(--success-soft); color: var(--success); }
.stat-orange .stat-icon { background: var(--warning-soft); color: var(--warning); }

/* ─── Dashboard ─────────────────────────────────── */
.dash-header-card { display: flex; align-items: center; gap: 1rem; }
.dash-server-icon { width: 56px; height: 56px; border-radius: var(--radius-lg); object-fit: cover; flex-shrink: 0; }
.dash-server-icon.fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 1.5rem;
}
.dash-header-info { min-width: 0; }
.dash-greeting { font-size: 0.8rem; color: var(--text-3); }
.dash-server-name { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.dash-insights { display: flex; flex-wrap: wrap; gap: 1.75rem; align-items: center; }
.insight-value { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; }
.insight-label { font-size: 0.72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.dash-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.dash-trend-toggle { display: flex; gap: 0.25rem; }
.dash-trend-btn.active { background: var(--accent); color: #fff; }
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 1.25rem; }
.dash-cols .card { margin-bottom: 0; }
@media (max-width: 900px) { .dash-cols { grid-template-columns: 1fr; } }
.ss-trend-btn.active { background: var(--accent); color: #fff; }
.ml-filter-btn.active { background: var(--accent); color: #fff; }
.ml-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 0.6rem; margin-top: 0.85rem; font-size: 0.85rem; color: var(--text-3); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.al-table { table-layout: fixed; width: 100%; }
.al-table th, .al-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Server stats — human/bot donut */
.ss-donut-wrap { height: 190px; position: relative; }
.ss-donut-legend { display: flex; justify-content: center; gap: 1.5rem; margin-top: 0.75rem; font-size: 0.85rem; color: var(--text-2); }
.ss-donut-legend .role-dot { width: 10px; height: 10px; }
.ss-donut-legend strong { color: var(--text); margin-left: 0.25rem; }

/* Server stats — role distribution bars */
.role-bars { display: flex; flex-direction: column; gap: 0.6rem; }
.role-bar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: 0.6rem; font-size: 0.85rem; }
.role-bar-label { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.role-bar-track { height: 8px; border-radius: 9999px; background: var(--bg-3); overflow: hidden; }
.role-bar-fill { height: 100%; border-radius: 9999px; min-width: 4px; }
.role-bar-count { color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Server stats — facts grid */
.ss-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem 2rem; }
.ss-fact { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; font-size: 0.875rem; }
.ss-fact .k { color: var(--text-3); }
.ss-fact .v { color: var(--text); font-weight: 500; text-align: right; }
@media (max-width: 600px) { .ss-facts { grid-template-columns: 1fr; } }

/* ─── Content Grid ──────────────────────────────── */
.content-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem; margin-bottom: 1.25rem;
}
.grid-2 {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

/* ─── Server cards ──────────────────────────────── */
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.85rem; }
.server-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 0.9rem;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
}
.server-card.is-active { border-color: var(--accent); }
.server-card.clickable { cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.server-card.clickable:hover { border-color: var(--border-bright); background: var(--bg-3); }
.server-card-head { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.server-card-icon { width: 44px; height: 44px; border-radius: var(--radius-lg); object-fit: cover; flex-shrink: 0; }
.server-card-icon.fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 1.15rem;
}
.server-card-info { min-width: 0; }
.server-card-name { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; min-width: 0; }
.server-card-name .scn-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.server-card-name .badge { flex-shrink: 0; }
.server-card-meta { font-size: 0.8rem; color: var(--text-3); margin-top: 1px; }
.owner-grid.owner-collapsed .server-card:nth-child(n+31) { display: none; }
.server-card-actions { display: flex; gap: 0.4rem; }
.server-card-actions .btn { width: auto; }
.server-card-actions > .btn:first-child { flex: 1; }
.server-card-actions .btn-ghost { padding: 0.35rem 0.55rem; }
.btn svg { width: 15px; height: 15px; }
.server-card-danger { color: var(--text-3); }
.server-card-danger:hover { color: var(--danger-text); background: var(--danger-soft); }

/* ─── Notice banner ─────────────────────────────── */
.notice {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 0.9rem; border-radius: var(--radius-md);
  font-size: 0.875rem; margin-bottom: 1rem;
}
.notice svg { width: 18px; height: 18px; flex-shrink: 0; }
.notice-warn { background: var(--warning-soft); color: var(--warning-text); border: 1px solid rgba(234, 179, 8, 0.3); }

/* ─── Lists ─────────────────────────────────────── */
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }

/* ─── Tables ────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th {
  text-align: left; padding: 0.6rem 0.75rem; color: var(--text-2);
  font-weight: 600; font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.03em; border-bottom: 1px solid var(--border);
}
td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--bg-hover); }
.table-group-row td {
  background: var(--bg-1); font-weight: 600; font-size: 0.85rem;
  padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border);
}
.table-group-row:hover td { background: var(--bg-1); }

/* ─── Badges ────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 0.125rem 0.625rem;
  border-radius: var(--radius-md); border: 1px solid var(--accent-soft);
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
  background: var(--accent-soft); color: var(--accent);
}
.badge-active, .badge-success { background: var(--success-soft); color: var(--success-text); border-color: rgba(34, 197, 94, 0.3); }
.badge-ended, .badge-danger { background: var(--danger-soft); color: var(--danger-text); border-color: rgba(239, 68, 68, 0.3); }
.badge-pending, .badge-warning { background: var(--warning-soft); color: var(--warning-text); border-color: rgba(234, 179, 8, 0.3); }
.badge-info { background: var(--info-soft); color: var(--info-text); border-color: rgba(14, 165, 233, 0.3); }
.badge-secondary { background: var(--bg-3); color: var(--text-2); border-color: var(--border-bright); }

/* ─── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.5rem 1rem; border-radius: var(--radius-md); border: none;
  font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit; white-space: nowrap;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bg-0), 0 0 0 4px var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; border-radius: var(--radius-md); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover:not(:disabled) { filter: brightness(0.92); }
.btn-secondary { background: var(--bg-3); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #3f3f46; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover:not(:disabled) { background: #0284c7; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border-bright); }
.btn-outline:hover:not(:disabled) { background: var(--bg-3); }

/* ─── Forms ─────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; margin-bottom: 0.35rem; font-size: 0.85rem; font-weight: 500; color: var(--text-2); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 0.55rem 0.75rem; border-radius: var(--radius-md);
  border: 1px solid var(--border-bright); background: var(--bg-1);
  color: var(--text); font-size: 0.875rem; font-family: inherit;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: transparent; box-shadow: 0 0 0 2px #71717a;
}
.form-select { cursor: pointer; }
.form-select option { background: var(--bg-1); color: var(--text); }
.form-textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; }
.form-hint { font-size: 0.8rem; color: var(--text-3); margin-top: 0.25rem; }
.form-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.25rem; }
.form-input[type="color"] { padding: 0.3rem; height: 40px; cursor: pointer; }

/* ─── Modal ─────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}
#modal-overlay > div {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 500px;
  max-height: 85vh; overflow-y: auto;
  animation: slideUp 0.2s ease;
}
#modal-overlay > div.modal-wide {
  max-width: 780px;
}
#modal-overlay > div.modal-confirm {
  max-width: 420px;
}

/* ─── Ticket Chat ────────────────────────────────── */
.tc-msg { display: flex; gap: 12px; padding: 2px 8px; border-radius: 4px; }
.tc-msg:hover { background: var(--bg-3); }
.tc-msg.tc-grouped { padding-left: 52px; }
.tc-av { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; margin-top: 2px; object-fit: cover; }
.tc-body { flex: 1; min-width: 0; }
.tc-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.tc-name { font-weight: 700; font-size: .9rem; }
.tc-name.tc-bot { color: var(--accent); }
.tc-bot-badge { background: var(--accent); color: #fff; font-size: .6rem; padding: 1px 5px; border-radius: 3px; vertical-align: middle; }
.tc-ts { font-size: .72rem; color: var(--text-3); }
.tc-content { font-size: .875rem; white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.tc-att { margin-top: 4px; }
.tc-att a { font-size: .82rem; color: var(--accent); }
.tc-att img { max-width: 320px; max-height: 220px; border-radius: 6px; margin-top: 4px; display: block; }
.tc-embed { border-left: 4px solid var(--border); background: var(--bg-3);
  padding: 8px 12px; border-radius: 0 4px 4px 0; margin-top: 6px; max-width: 480px; }
.tc-embed-author { font-size: .78rem; color: var(--text-2); margin-bottom: 3px; }
.tc-embed-title { font-weight: 700; font-size: .9rem; margin-bottom: 4px; }
.tc-embed-desc { font-size: .82rem; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.tc-embed-fields { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.tc-embed-field-name { font-size: .78rem; font-weight: 700; color: var(--text-2); }
.tc-embed-field-val { font-size: .82rem; white-space: pre-wrap; word-break: break-word; }
.tc-embed-footer { font-size: .72rem; color: var(--text-3); margin-top: 6px; }
.mention { background: rgba(88,101,242,.3); color: #dee0fc; border-radius: 3px; padding: 0 2px; font-weight: 500; }

/* ─── Member Picker ──────────────────────────────── */
.mp-wrap { position: relative; }
.mp-dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 3px); z-index: 200;
  background: var(--bg-2); border: 1px solid var(--border-bright);
  border-radius: 8px; max-height: 220px; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.mp-dropdown.hidden { display: none; }
.mp-item {
  padding: .5rem .75rem; cursor: pointer; font-size: .88rem;
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .5rem;
}
.mp-item:last-child { border-bottom: none; }
.mp-item:hover { background: var(--bg-hover); }
.mp-item-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.mp-item-tag { color: var(--text-3); font-size: .8rem; margin-left: auto; flex-shrink: 0; }
.mp-selected {
  display: flex; align-items: center; gap: .5rem; margin-top: .35rem;
  padding: .35rem .6rem; background: var(--accent-soft); border-radius: 6px;
  font-size: .88rem; width: fit-content;
}
.mp-selected button {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  padding: 0 .2rem; font-size: .9rem; line-height: 1; width: auto;
}
.mp-selected button:hover { color: var(--danger); }

/* ─── Role multi-picker (chips) ─────────────────── */
.rp-wrap { position: relative; }
.rp-control {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem;
  min-height: 42px; padding: .3rem .45rem;
  background: var(--bg-1); border: 1px solid var(--border-bright); border-radius: 8px;
  transition: border-color .15s;
}
.rp-control:focus-within { border-color: var(--accent); }
.rp-chips { display: contents; }
.rp-chip {
  display: inline-flex; align-items: center; gap: .35rem; max-width: 220px;
  padding: .2rem .25rem .2rem .5rem; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 6px; font-size: .82rem;
}
.rp-chip-x {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  padding: 0 .15rem; font-size: .8rem; line-height: 1; width: auto;
}
.rp-chip-x:hover { color: var(--danger); }
.rp-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.rp-search {
  flex: 1; min-width: 120px; border: none; background: transparent; outline: none;
  color: var(--text); font-size: .88rem; padding: .25rem;
}
.rp-dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 3px); z-index: 200;
  background: var(--bg-2); border: 1px solid var(--border-bright);
  border-radius: 8px; max-height: 220px; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.rp-dropdown.hidden { display: none; }
.rp-item {
  padding: .5rem .75rem; cursor: pointer; font-size: .88rem;
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .5rem;
}
.rp-item:last-child { border-bottom: none; }
.rp-item:hover { background: var(--bg-hover); }

/* ─── Role manager bulk bar ─────────────────────── */
.rm-bulk-bar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin-top: .75rem; padding: .5rem .75rem;
  background: var(--accent-soft); border: 1px solid var(--accent-soft); border-radius: 8px;
}

/* ─── Components V2 builder ─────────────────────── */
.v2-block {
  border: 1px solid var(--border); border-radius: 8px;
  padding: .6rem .75rem; margin-bottom: .6rem; background: var(--bg-1);
}
.v2-block.v2-container { background: var(--bg-2); border-style: dashed; }
.v2-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.v2-block-type { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); }
.v2-inline { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text-2); }
.v2-children { margin-top: .6rem; padding-left: .6rem; border-left: 2px solid var(--border); }
.v2-children:empty { display: none; }

.v2-preview {
  display: flex; flex-direction: column; gap: .35rem;
  background: var(--bg-1); border-radius: 8px; padding: 1rem; min-height: 120px;
}
.v2p-text { font-size: .92rem; line-height: 1.5; color: var(--text); white-space: normal; word-break: break-word; }
.v2p-text code { background: var(--bg-2); padding: .05rem .3rem; border-radius: 4px; font-size: .85em; }
.v2p-sep hr { border: none; border-top: 1px solid var(--border-bright); margin: 0; }
.v2p-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .35rem; }
.v2p-gallery img { width: 100%; height: 100px; object-fit: cover; border-radius: 8px; }
.v2p-btnrow { display: flex; flex-wrap: wrap; gap: .4rem; }
.v2p-btn {
  display: inline-flex; align-items: center; padding: .35rem .8rem;
  background: var(--bg-3, #2b2d31); border: 1px solid var(--border-bright);
  border-radius: 6px; font-size: .85rem; font-weight: 500; color: var(--text); text-decoration: none;
}
.v2p-btn:hover { background: var(--bg-hover); }
.v2p-section { display: flex; align-items: flex-start; gap: .75rem; }
.v2p-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.v2p-container {
  border-left: 4px solid var(--accent); border-radius: 6px;
  background: var(--bg-2); padding: .65rem .8rem;
  display: flex; flex-direction: column; gap: .35rem;
}

/* ─── Embed Builder preview ─────────────────────── */
.embed-preview-card {
  border-left: 4px solid var(--accent); background: var(--bg-2);
  border-radius: 6px; padding: .8rem 1rem; max-width: 520px;
}
.ebp-top { display: flex; gap: .75rem; align-items: flex-start; }
.ebp-main { flex: 1; min-width: 0; }
.ebp-author { font-size: .8rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }
.ebp-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: .4rem; word-break: break-word; }
.ebp-title a { color: #00a8fc; text-decoration: none; }
.ebp-title a:hover { text-decoration: underline; }
.ebp-desc { font-size: .9rem; line-height: 1.45; color: var(--text-2); word-break: break-word; }
.ebp-desc code, .ebp-field-val code { background: var(--bg-1); padding: .05rem .3rem; border-radius: 4px; font-size: .85em; }
.ebp-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.ebp-fields { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.ebp-field { flex: 1 1 100%; min-width: 0; }
.ebp-field.ebp-inline { flex: 1 1 30%; }
.ebp-field-name { font-size: .8rem; font-weight: 700; color: var(--text); margin-bottom: .1rem; }
.ebp-field-val { font-size: .85rem; color: var(--text-2); word-break: break-word; }
.ebp-image { max-width: 100%; border-radius: 8px; margin-top: .6rem; display: block; }
.ebp-footer { font-size: .75rem; color: var(--text-3); margin-top: .6rem; }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

/* ─── Toast ─────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 2000;
  display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none;
}
.toast {
  padding: 0.7rem 1.1rem; border-radius: 10px;
  font-size: 0.875rem; font-weight: 500; pointer-events: auto;
  animation: toastIn 0.25s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 360px; box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--info); color: white; }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0 } to { transform: translateX(0); opacity: 1 } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px) } }

/* ─── Loading / Empty ───────────────────────────── */
.loading { text-align: center; padding: 3rem; color: var(--text-3); }
.spinner {
  display: inline-block; width: 28px; height: 28px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }
.empty-state { color: var(--text-3); padding: 1rem 0; font-size: 0.9rem; font-style: italic; }

/* ─── Chart ─────────────────────────────────────── */
.chart-container { position: relative; height: 300px; }

/* ─── Utility ───────────────────────────────────── */
.text-muted { color: var(--text-3); }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.flex { display: flex; }
.gap-sm { gap: 0.5rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; display: inline-block; vertical-align: bottom; }
/* On table cells, inline-block breaks the cell out of the table layout and shifts
   every following column. Keep them as real table-cells. */
td.truncate, th.truncate { display: table-cell; }
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ─── Responsive ────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { width: 60px; overflow: hidden; }
  #sidebar:hover { width: var(--sidebar-w); }
  .nav-item span:not(.icon),
  .sidebar-footer { display: none; }
  .sidebar-header .brand-meta { display: none; }
  #sidebar:hover .nav-item span,
  #sidebar:hover .sidebar-footer { display: block; }
  #sidebar:hover .sidebar-header .brand-meta { display: flex; }
  .nav-category span { display: none; }
  #sidebar:hover .nav-category span { display: block; }
  #content { margin-left: 60px; padding: 1rem; }
}

/* ─── Embed Preview ─────────────────────────────── */
#embed-preview-box { min-height: 80px; }
.eb-field-row { margin-bottom: 0.5rem; }
.eb-field-row .form-group { margin-bottom: 0; }
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.content-grid .card { margin-bottom: 0; }
@media (max-width: 900px) { .content-grid { grid-template-columns: 1fr; } }

/* ─── Inline Code ───────────────────────────────── */
code { font-family: monospace; font-size: 0.85em; background: var(--bg-3); padding: 1px 5px; border-radius: 4px; }

/* ─── Audit Filter ──────────────────────────────── */
.audit-filter.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ─── Rollen-Manager ────────────────────────────── */
.role-badge {
  display: inline-block; font-size: 0.75rem; padding: 1px 8px;
  border: 1px solid; border-radius: 999px; margin: 1px 2px;
  white-space: nowrap;
}
.role-cell { max-width: 480px; }
.role-checkbox-label {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.4rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem;
}
.role-checkbox-label:hover { background: var(--bg-1); }
.role-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* ─── Kanal-Viewer ──────────────────────────────── */
.cv-feed { display: flex; flex-direction: column; gap: 0.25rem; }
.cv-msg {
  display: flex; gap: 0.75rem; padding: 0.5rem 0.6rem;
  border-radius: 6px; transition: background 0.1s;
}
.cv-msg:hover { background: var(--bg-1); }
.cv-msg-bot { opacity: 0.85; }
.cv-avatar { border-radius: 50%; flex-shrink: 0; align-self: flex-start; margin-top: 2px; }
.cv-body { min-width: 0; flex: 1; }
.cv-meta { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.15rem; flex-wrap: wrap; }
.cv-author { font-weight: 600; font-size: 0.9rem; }
.cv-time { font-size: 0.75rem; }
.cv-content { font-size: 0.9rem; white-space: pre-wrap; word-break: break-word; }
.cv-embed {
  margin-top: 0.4rem; padding: 0.5rem 0.75rem;
  background: var(--bg-1); border-radius: 0 4px 4px 0; max-width: 420px;
}
.cv-embed-title { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.25rem; }
.cv-embed-desc { font-size: 0.82rem; }
