/* ─────────────────────────────────────────────────────────────────────────────
   StaffTracker Dashboard — main.css
   Minimal, modern, dark design system — soft violet accent, fluid type,
   smooth motion, fully responsive.
   ───────────────────────────────────────────────────────────────────────────── */

/* Smooth same-origin page transitions (progressive enhancement; no-op where
   unsupported). Removes the hard flash when navigating between routes. */
@view-transition { navigation: auto; }

/* Self-hosted Inter (variable, latin). One file covers weights 100–900. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-variable.woff2') format('woff2-variations');
}

/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  color-scheme: dark;

  /* Backgrounds — neutral charcoal with a whisper of violet */
  --bg-base:     #0a0a0f;
  --bg-surface:  #111118;
  --bg-elevated: #181821;
  --bg-hover:    #1e1e2a;
  --bg-input:    #14141c;

  /* Brand */
  --primary:        #8b5cf6;
  --primary-hover:  #7c3aed;
  --primary-soft:   #a78bfa;
  --primary-light:  rgba(139, 92, 246, 0.12);
  --primary-border: rgba(139, 92, 246, 0.28);
  --primary-glow:   rgba(139, 92, 246, 0.22);

  /* Accent */
  --accent:       #22d3ee;
  --accent-light: rgba(34, 211, 238, 0.1);

  /* Semantic */
  --success:       #34d399;
  --success-light: rgba(52, 211, 153, 0.1);
  --warning:       #fbbf24;
  --warning-light: rgba(251, 191, 36, 0.1);
  --danger:        #f87171;
  --danger-light:  rgba(248, 113, 113, 0.1);

  /* Text */
  --text-primary:   #f4f4f5;
  --text-secondary: #9b9ba7;
  --text-muted:     #5b5b66;

  /* Borders */
  --border:        rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(139, 92, 246, 0.22);

  /* Layout */
  --sidebar-w:  256px;
  --topbar-h:   60px;
  --radius:     16px;
  --radius-sm:  10px;
  --radius-xs:  7px;
  --shadow:     0 8px 40px rgba(0, 0, 0, 0.4);
  --shadow-sm:  0 2px 16px rgba(0, 0, 0, 0.25);

  /* Motion */
  --ease:        cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.3, 0.64, 1);
  --transition:  0.2s var(--ease);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
img, svg { display: block; }

::selection { background: rgba(139, 92, 246, 0.35); color: #fff; }

/* Keyboard focus — visible, consistent, never on mouse click */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Slim, quiet scrollbars everywhere */
* { scrollbar-width: thin; scrollbar-color: rgba(139, 92, 246, 0.25) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.25); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.45); }

/* ── Shared keyframes ──────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* Content entrance — every direct child of .content drifts up softly, lightly
   staggered. Runs on initial load and after every htmx shell swap (new DOM). */
.content > * {
  animation: fadeUp 0.45s var(--ease) both;
}
.content > *:nth-child(2) { animation-delay: 0.04s; }
.content > *:nth-child(3) { animation-delay: 0.08s; }
.content > *:nth-child(4) { animation-delay: 0.12s; }
.content > *:nth-child(5) { animation-delay: 0.16s; }
.content > *:nth-child(n+6) { animation-delay: 0.2s; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s var(--ease);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), #6d28d9);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.sidebar-icon svg { width: 20px; height: 20px; }

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-subtitle {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 18px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section { margin-bottom: 26px; }

.nav-section-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 12px 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition), transform var(--transition);
  position: relative;
  cursor: pointer;
}

.nav-link svg {
  width: 17px; height: 17px;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity var(--transition);
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-link:hover svg { opacity: 1; }

.nav-link:active { transform: scale(0.98); }

.nav-link.active {
  background: var(--primary-light);
  color: var(--primary-soft);
  font-weight: 600;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: -12px; top: 50%;
  transform: translateY(-50%);
  height: 18px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-link.active svg { opacity: 1; color: var(--primary-soft); }

/* Sidebar footer */
.sidebar-footer {
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-sm {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--primary-border);
}

.avatar-placeholder {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-user { flex: 1; min-width: 0; }

.sidebar-username {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-role {
  font-size: 0.66rem;
  color: var(--text-muted);
}

.logout-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.logout-btn:hover { background: var(--danger-light); color: var(--danger); }
.logout-btn svg { width: 16px; height: 16px; }

/* ── Main layout ───────────────────────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ───────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: rgba(10, 10, 15, 0.7);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  z-index: 50;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-spacer { flex: 1; }

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-dot 2.4s var(--ease) infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4); }
  50%       { opacity: 0.6; box-shadow: 0 0 0 4px rgba(52, 211, 153, 0); }
}

.sidebar-toggle {
  display: none;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.sidebar-toggle:hover { background: var(--bg-elevated); color: var(--text-primary); }
.sidebar-toggle:active { transform: scale(0.94); }
.sidebar-toggle svg { width: 20px; height: 20px; }

/* ── Content area ──────────────────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: clamp(16px, 3vw, 32px);
  max-width: 1320px;
  width: 100%;
}

.page-header {
  margin-bottom: clamp(20px, 3vw, 30px);
}

.page-header h1 {
  font-size: clamp(1.3rem, 1.1rem + 1vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.25;
}

.page-header p {
  font-size: 0.86rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-admin   { background: var(--primary-light); color: var(--primary-soft); border: 1px solid var(--primary-border); }
.badge-staff   { background: var(--accent-light);  color: var(--accent); }
.badge-owner   { background: var(--warning-light); color: var(--warning); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger);  }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}

.card:hover { border-color: var(--border-strong); }

.card-glass {
  background: rgba(17, 17, 24, 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}

.card-header-title {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header-title svg { width: 16px; height: 16px; opacity: 0.6; }

.card-body { padding: 22px; }

/* ── Stat cards ────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s var(--ease-spring), border-color var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow-sm);
}

.stat-card.purple  { --stat-color: var(--primary); --stat-bg: var(--primary-light); }
.stat-card.cyan    { --stat-color: var(--accent);  --stat-bg: var(--accent-light); }
.stat-card.green   { --stat-color: var(--success); --stat-bg: var(--success-light); }
.stat-card.amber   { --stat-color: var(--warning); --stat-bg: var(--warning-light); }
.stat-card.red     { --stat-color: var(--danger);  --stat-bg: var(--danger-light); }

.stat-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
  background: var(--stat-bg, var(--primary-light));
  color: var(--stat-color, var(--primary-soft));
}

.stat-card.purple .stat-icon { color: var(--primary-soft); }

.stat-icon svg { width: 18px; height: 18px; }

.stat-value {
  font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.7rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.74rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 5px;
}

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s var(--ease);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--bg-elevated); }

tbody td {
  padding: 12px 14px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.td-primary { color: var(--text-primary); font-weight: 600; }
.td-points  { color: var(--primary-soft); font-weight: 700; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.td-rank    { color: var(--text-muted); font-size: 0.84rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.td-rank.gold   { color: #fbbf24; }
.td-rank.silver { color: #c0c4cc; }
.td-rank.bronze { color: #d08750; }

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: white;
  overflow: hidden;
}

img.user-avatar {
  object-fit: cover;
  display: block;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              transform 0.15s var(--ease-spring);
  cursor: pointer;
  border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-accent); }

.btn-discord {
  background: #5865f2;
  color: white;
  font-size: 0.95rem;
  padding: 13px 28px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(88, 101, 242, 0.3);
}

.btn-discord:hover { background: #4752c4; box-shadow: 0 6px 28px rgba(88, 101, 242, 0.4); transform: translateY(-2px); }
.btn-discord:active { transform: scale(0.98); }

.btn-sm { padding: 6px 12px; font-size: 0.76rem; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
  min-height: 42px; /* comfortable touch target */
}

.form-control:hover { border-color: var(--border-accent); }

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--bg-surface);
}

.form-control::placeholder { color: var(--text-muted); }

.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* ── Tabs ──────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: var(--radius-sm);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  padding: 7px 16px;
  border-radius: var(--radius-xs);
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn:active { transform: scale(0.97); }

.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 10px var(--primary-glow);
}

/* ── Section grid ──────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* ── Flash messages ────────────────────────────────────────────────────────── */
.flash-container { margin-bottom: 20px; }

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 500;
  margin-bottom: 10px;
  animation: fadeUp 0.3s var(--ease) both;
}

.flash-success { background: var(--success-light); border: 1px solid rgba(52, 211, 153, 0.2); color: var(--success); }
.flash-error   { background: var(--danger-light);  border: 1px solid rgba(248, 113, 113, 0.2); color: var(--danger); }
.flash-info    { background: var(--accent-light);  border: 1px solid rgba(34, 211, 238, 0.2);  color: var(--accent); }

.flash svg { width: 16px; height: 16px; flex-shrink: 0; }

.flash-close {
  margin-left: auto;
  opacity: 0.6;
  cursor: pointer;
  padding: 2px;
  transition: opacity var(--transition);
}

.flash-close:hover { opacity: 1; }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.section { margin-bottom: clamp(22px, 3vw, 30px); }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 24px;
  color: var(--text-muted);
  text-align: center;
  gap: 10px;
}

.empty-state svg { width: 40px; height: 40px; opacity: 0.35; }
.empty-state p { font-size: 0.875rem; }

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
  padding: 24px;
}

/* Two soft, slowly drifting aurora blobs — quiet, not flashy */
.login-bg::before {
  content: '';
  position: absolute;
  top: -220px; left: 50%;
  width: 720px; height: 560px;
  background: radial-gradient(ellipse, rgba(139, 92, 246, 0.14) 0%, transparent 65%);
  pointer-events: none;
  animation: aurora-a 14s ease-in-out infinite alternate;
}

.login-bg::after {
  content: '';
  position: absolute;
  bottom: -180px; right: -120px;
  width: 520px; height: 520px;
  background: radial-gradient(ellipse, rgba(34, 211, 238, 0.08) 0%, transparent 70%);
  pointer-events: none;
  animation: aurora-b 18s ease-in-out infinite alternate;
}

@keyframes aurora-a {
  from { transform: translateX(-60%) translateY(0); }
  to   { transform: translateX(-40%) translateY(30px); }
}

@keyframes aurora-b {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-40px, -30px) scale(1.1); }
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: clamp(32px, 6vw, 46px) clamp(24px, 5vw, 42px);
  width: 100%;
  max-width: 420px;
  text-align: center;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow), 0 0 90px rgba(139, 92, 246, 0.06);
  animation: fadeUp 0.5s var(--ease) both;
}

.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), #6d28d9);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 32px rgba(139, 92, 246, 0.3);
  animation: scaleIn 0.5s var(--ease-spring) 0.1s both;
}

.login-logo svg { width: 32px; height: 32px; }

.login-card h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 6px; }
.login-card p  { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 28px; }

.login-error {
  background: var(--danger-light);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.85rem;
  margin-bottom: 18px;
  text-align: left;
}

/* ── Error pages ───────────────────────────────────────────────────────────── */
.error-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  text-align: center;
  padding: 24px;
}

.error-page-inner { max-width: 480px; animation: fadeUp 0.45s var(--ease) both; }

.error-code {
  font-size: clamp(4.5rem, 14vw, 6.5rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 8px;
}

.error-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 10px; }

.error-msg { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 28px; }

/* ── Streak display ────────────────────────────────────────────────────────── */
.streak-flame {
  font-size: 1.8rem;
  line-height: 1;
}

/* ── Progress bar ──────────────────────────────────────────────────────────── */
.progress-bar {
  height: 5px;
  background: var(--bg-elevated);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 99px;
  transition: width 0.7s var(--ease);
}

/* ── Data refresh animation ────────────────────────────────────────────────── */
.refreshing tbody { opacity: 0.55; transition: opacity 0.2s var(--ease); }

@keyframes shimmer {
  0%   { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200px 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius-xs);
}

/* ── Contribution donut chart ──────────────────────────────────────────────── */
.contrib-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.contrib-layout {
  display: grid;
  grid-template-columns: minmax(260px, 380px) 1fr;
  gap: clamp(20px, 4vw, 44px);
  align-items: center;
  padding: clamp(20px, 3vw, 32px);
}

.contrib-donut-wrap {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin-inline: auto;
}

.contrib-donut {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible; /* glow must not clip at the svg's square edge */
  animation: donut-in 0.8s var(--ease) both;
}

@keyframes donut-in {
  from { opacity: 0; transform: rotate(-16deg) scale(0.92); }
  to   { opacity: 1; transform: rotate(0) scale(1); }
}

.contrib-seg {
  cursor: pointer;
  transition: opacity 0.25s var(--ease), stroke-width 0.25s var(--ease);
}

/* Hover focus: gently fade the rest, let the active slice breathe with a soft
   halo in its own color (low-alpha, small radius — no neon, easy on the eyes) */
.contrib-layout.focusing .contrib-seg {
  opacity: 0.32;
  filter: saturate(0.6);
}
.contrib-layout.focusing .contrib-seg.active {
  opacity: 1;
  stroke-width: 30;
  filter: saturate(1) drop-shadow(0 0 3px currentColor);
}
@supports (color: color-mix(in srgb, red 50%, transparent)) {
  .contrib-layout.focusing .contrib-seg.active {
    filter: saturate(1)
            drop-shadow(0 0 5px color-mix(in srgb, currentColor 30%, transparent));
  }
}

/* Donut center readout */
.contrib-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  padding: 18%;
}

.contrib-center-pct {
  font-size: clamp(1.3rem, 1rem + 1.4vw, 1.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  transition: color 0.2s var(--ease);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contrib-center-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contrib-center-sub {
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-top: 2px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Legend */
.contrib-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 4px;
}

.contrib-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), opacity 0.25s var(--ease), transform var(--transition);
}

.contrib-row:hover,
.contrib-row.active {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  transform: translateX(3px);
}

.contrib-layout.focusing .contrib-row:not(.active) { opacity: 0.35; }

.contrib-rank {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  width: 18px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.contrib-dot {
  width: 11px; height: 11px;
  border-radius: 4px;
  flex-shrink: 0;
}

.contrib-row-main { flex: 1; min-width: 0; }

.contrib-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.contrib-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
}

.contrib-val {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.contrib-bar {
  height: 4px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
  margin: 5px 0 4px;
}

.contrib-bar span {
  display: block;
  height: 100%;
  border-radius: 99px;
  transition: width 0.7s var(--ease);
}

.contrib-row-sub {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.contrib-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 16px;
  min-width: 0;
}

.contrib-stat { white-space: nowrap; }

.contrib-stat b {
  font-weight: 600;
  color: var(--text-secondary);
}

.contrib-pct {
  font-weight: 700;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

@media (max-width: 880px) {
  .contrib-layout { grid-template-columns: 1fr; }
  .contrib-donut-wrap { max-width: 280px; }
  .contrib-legend { max-height: none; overflow: visible; }
}

/* ── Back link (profile pages) ─────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 9px;
  margin-bottom: 10px;
  border-radius: 99px;
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  color: var(--primary-soft);
  font-size: 0.76rem;
  font-weight: 600;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.back-link:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--primary);
}

.back-link:hover svg { transform: translateX(-2px); }
.back-link svg { transition: transform var(--transition); }
.back-link:active { transform: scale(0.97); }

/* ── Staff profiles directory ──────────────────────────────────────────────── */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.profile-card {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: transform 0.25s var(--ease-spring), border-color var(--transition), box-shadow var(--transition);
}

.profile-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow-sm);
}

.profile-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.profile-roles {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.profile-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition), color var(--transition);
}

.profile-card:hover .profile-arrow {
  transform: translateX(3px);
  color: var(--primary-soft);
}

.profile-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.68rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* ── Sidebar overlay (mobile) ──────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 99;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 0.25s var(--ease) both;
}

.sidebar-overlay.active { display: block; }

/* ── Tooltip ───────────────────────────────────────────────────────────────── */
[data-tip] {
  position: relative;
  cursor: help;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: 5px 9px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition), transform var(--transition);
  box-shadow: var(--shadow-sm);
}

[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ────────────────────────────────────────────────────────────── */

/* Large desktop — keep content comfortably centered */
@media (min-width: 1700px) {
  .content { margin-inline: auto; }
}

/* Small desktop / tablet landscape */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* Tablet portrait & below — sidebar becomes a drawer */
@media (max-width: 880px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(var(--sidebar-w), 84vw);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 48px rgba(0, 0, 0, 0.6);
  }

  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .topbar { padding: 0 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card-body { padding: 18px; }
  .card-header { padding: 14px 18px; }

  /* Touch targets */
  .nav-link { padding: 12px; }
  .tab-btn { padding: 9px 16px; }
}

/* Phones */
@media (max-width: 480px) {
  html { font-size: 14.5px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 16px; }
  .topbar-title { font-size: 0.92rem; }
  .topbar-meta .badge { display: none; } /* role badge — redundant with sidebar on tiny screens */
  .login-card { padding: 32px 22px; }
  tbody td, thead th { padding-inline: 10px; }
}

@media (max-width: 360px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Reduced motion — kill all decorative animation, keep things usable ───── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
