:root {
  --color-bg-deep: #05070a;
  --color-bg-page: #0a0c12;
  --color-glass: rgba(16, 18, 28, 0.72);
  --color-glass-heavy: rgba(18, 20, 30, 0.9);
  --color-glass-modal: rgba(12, 14, 22, 0.94);
  --color-glass-border: rgba(59, 130, 246, 0.12);
  --color-glass-border-hover: rgba(220, 38, 38, 0.28);
  --color-accent-crimson: #dc2626;
  --color-accent-crimson-light: #ef4444;
  --color-accent-crimson-dim: rgba(220, 38, 38, 0.12);
  --color-accent-navy: #1e40af;
  --color-accent-blue: #3b82f6;
  --color-accent-cyan: #06b6d4;
  --color-danger: #ef4444;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-text-primary: #e8eaf0;
  --color-text-secondary: #8b95a7;
  --color-text-muted: #5c6578;
  --color-surface-elevated: #12151f;
  --color-surface-input: #090c14;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 9999px;
  --shadow-glass: 0 4px 24px rgba(0,0,0,0.35);
  --shadow-glass-hover: 0 8px 32px rgba(220,38,38,0.08);
  --shadow-modal: 0 24px 72px rgba(0,0,0,0.65);
  --color-primary: var(--color-accent-crimson);
  --color-primary-hover: var(--color-accent-crimson-light);
  --color-destructive: var(--color-danger);
  --color-destructive-foreground: #ffffff;
  --color-border: var(--color-glass-border);
  --color-border-hover: var(--color-glass-border-hover);
  --color-input: var(--color-surface-input);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background-color: var(--color-bg-deep);
  color: var(--color-text-primary);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(ellipse 1000px 500px at 50% -100px, rgba(220,38,38,0.09) 0%, transparent 60%),
    radial-gradient(ellipse 800px 400px at 0% 50%, rgba(30,64,175,0.05) 0%, transparent 50%),
    radial-gradient(ellipse 600px 300px at 100% 80%, rgba(59,130,246,0.04) 0%, transparent 50%);
}

a { color: var(--color-accent-blue); text-decoration: none; }
a:hover { color: var(--color-accent-crimson-light); }

.glass-card {
  background: var(--color-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
}
.glass-card-hover { transition: transform 0.1s ease, box-shadow 0.15s ease, border-color 0.15s ease; }
.glass-card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-glass-hover); border-color: var(--color-glass-border-hover); }

.glass-card-accent {
  background: var(--color-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  position: relative;
  overflow: hidden;
}
.glass-card-accent::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(135deg, #dc2626 0%, #1e40af 100%);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: rgba(10,12,18,0.9);
  border-right: 1px solid var(--color-glass-border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--color-glass-border);
}

.sidebar-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  background: linear-gradient(135deg, #ef4444 0%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-subtitle { font-size: 0.75rem; color: var(--color-text-secondary); margin-top: 4px; }

.sidebar-nav { padding: 16px 12px; flex: 1; }

.nav-section { margin-bottom: 24px; }
.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding: 8px 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  margin-bottom: 4px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.04); color: var(--color-text-primary); }
.nav-link.active {
  background: var(--color-accent-crimson-dim);
  color: var(--color-text-primary);
  border: 1px solid rgba(220,38,38,0.28);
}

.main-content { min-width: 0; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--color-glass-border);
  background: rgba(10,12,18,0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title { font-size: 1.125rem; font-weight: 700; margin: 0; }
.page-subtitle { font-size: 0.8rem; color: var(--color-text-secondary); }

.user-menu { display: flex; align-items: center; gap: 12px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--color-glass-border);
}

.page-body { padding: 28px 32px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card { padding: 20px; }
.stat-label { font-size: 0.75rem; color: var(--color-text-secondary); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 1.75rem; font-weight: 800; margin-top: 6px; }

.form-card { padding: 24px; margin-bottom: 24px; }
.form-title { font-size: 1rem; font-weight: 700; margin: 0 0 16px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-label { font-size: 0.8rem; color: var(--color-text-secondary); font-weight: 600; }
.form-hint { font-size: 0.75rem; color: var(--color-text-muted); }

input[type="text"],
input[type="url"],
input[type="number"],
input[type="email"],
input[type="password"],
textarea,
select {
  background: var(--color-surface-input);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--color-text-primary);
  font-size: 0.875rem;
  outline: none;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--color-accent-blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

textarea { min-height: 100px; resize: vertical; }

input[type="checkbox"] {
  accent-color: var(--color-accent-crimson);
  width: 18px; height: 18px; cursor: pointer;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius-md);
  padding: 10px 16px; font-size: 0.875rem; font-weight: 600;
  cursor: pointer; transition: transform 0.1s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--color-accent-crimson); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: rgba(255,255,255,0.06); color: var(--color-text-primary); border: 1px solid var(--color-glass-border); }
.btn-secondary:hover { background: rgba(255,255,255,0.10); }
.btn-danger { background: var(--color-destructive); color: var(--color-destructive-foreground); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--color-glass-border); }
th { color: var(--color-text-secondary); font-weight: 600; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.05em; }
td { color: var(--color-text-primary); }

.flash {
  padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 20px;
  border: 1px solid; font-size: 0.875rem;
}
.flash-success { background: rgba(34,197,94,0.08); color: #86efac; border-color: rgba(34,197,94,0.28); }
.flash-error { background: rgba(239,68,68,0.08); color: #fca5a5; border-color: rgba(239,68,68,0.28); }
.flash-info { background: rgba(59,130,246,0.08); color: #93c5fd; border-color: rgba(59,130,246,0.28); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--color-text-secondary); }
.badge { display:inline-flex;align-items:center;justify-content:center;padding:4px 10px;border-radius:var(--radius-pill);font-size:.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.03em; }
.badge-warn, .badge-warn { background:rgba(245,158,11,0.12);color:#fbbf24; }
.badge-kick, .badge-ban, .badge-timeout { background:rgba(239,68,68,0.12);color:#fca5a5; }
.badge-unban, .badge-untimeout { background:rgba(34,197,94,0.12);color:#86efac; }
.badge-purge { background:rgba(59,130,246,0.12);color:#93c5fd; }
.badge-muted { background:rgba(255,255,255,0.06);color:var(--color-text-secondary); }

/* Searchable select
   glass-card backdrop-filter creates stacking contexts, so a panel inside one
   card paints under the next sibling. Elevate the open card while the menu is open. */
.glass-card.has-open-select,
.form-card.has-open-select,
.glass-card:has(.search-select.is-open),
.form-card:has(.search-select.is-open) {
  position: relative;
  z-index: 40;
}
.search-select { position: relative; width: 100%; z-index: 0; }
.search-select.is-open { z-index: 50; }
.search-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--color-surface-input);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--color-text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  text-align: left;
}
.search-select-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  color: var(--color-text-muted);
}
.search-select.is-open .search-select-trigger,
.search-select-trigger:focus {
  border-color: var(--color-accent-blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
  outline: none;
}
.search-select-caret { color: var(--color-text-muted); font-size: 0.75rem; }
.search-select-panel {
  position: absolute;
  z-index: 80;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--color-glass-modal);
  border: 1px solid var(--color-glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}
.search-select-filter {
  width: 100%;
  border: none !important;
  border-bottom: 1px solid var(--color-glass-border) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}
.search-select-options {
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
}
.search-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--color-text-primary);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}
.search-select-option:hover,
.search-select-option.is-selected {
  background: rgba(59,130,246,0.12);
}
.search-select-check { cursor: pointer; }
.search-select-empty {
  padding: 12px;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}
.role-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}
.type-card-body { display: none; margin-top: 16px; border-top: 1px solid var(--color-glass-border); padding-top: 16px; }
.type-card.is-expanded .type-card-body { display: block; }
.type-card-header { display:flex; justify-content:space-between; align-items:center; gap:12px; width:100%; background:transparent; border:none; color:inherit; cursor:pointer; text-align:left; padding:0; }

.guild-switcher { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.guild-icon { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }

.recordings-table { width: 100%; }
.track-list { padding: 12px; background: rgba(0,0,0,0.15); border-radius: var(--radius-md); }
.track-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--color-glass-border); }
.track-item:last-child { border-bottom: none; }
.track-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.track-actions audio { height: 34px; max-width: 260px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill); font-size: .75rem; background: var(--color-surface-elevated); color: var(--color-text-secondary); text-transform: uppercase; }
.badge-low { background: rgba(46,204,113,0.15); color: #2ecc71; }
.badge-medium { background: rgba(241,196,15,0.15); color: #f1c40f; }
.badge-high { background: rgba(230,126,34,0.15); color: #e67e22; }
.badge-critical { background: rgba(231,76,60,0.15); color: #e74c3c; }
.json-pre { background: var(--color-surface-input); padding: 12px; border-radius: var(--radius-md); font-size: .8rem; overflow: auto; max-height: 300px; }

.ticket-field-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 0.7fr 0.6fr 0.7fr 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-glass-border);
}
.ticket-field-row:last-child { border-bottom: none; }
.ticket-field-row input, .ticket-field-row select { width: 100%; }
.field-check { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; white-space: nowrap; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 72px 1fr; }
  .sidebar-header { padding: 16px 8px; text-align: center; }
  .sidebar-title { font-size: 0.75rem; }
  .sidebar-subtitle { display: none; }
  .nav-section-title { display: none; }
  .nav-link span { display: none; }
  .nav-link { justify-content: center; padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(220,38,38,0.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(220,38,38,0.4); }
::selection { background: rgba(220,38,38,0.25); color: var(--color-text-primary); }
