@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-card: #1a1a1a;
  --bg-hover: #222222;
  --border: #2a2a2a;
  --text-primary: #f0f0f0;
  --text-secondary: #888888;
  --accent-red: #cc2200;
  --accent-orange: #ff6600;
  --accent-gold: #ffd700;
  --accent-silver: #c0c0c0;
  --accent-bronze: #cd7f32;
  --rank-1: rgba(255, 215, 0, 0.08);
  --rank-2: rgba(192, 192, 192, 0.06);
  --rank-3: rgba(205, 127, 50, 0.06);
  --accent-blue: #3b82f6;
  --accent-green: #22c55e;
  --accent-purple: #a855f7;
  --accent-gray: #6b7280;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --navbar-height: 60px;
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --focus-ring: 0 0 0 3px rgba(255, 102, 0, 0.35);
}

/* ---------- Light theme ----------
   Toggled via a `data-theme="light"` attribute on <html>, set as early as
   possible in <head> (before first paint) to avoid a flash of the wrong theme.
   Everything not overridden here (borders, shadows, rank-row tints, etc.)
   already reads fine unchanged against a white background. */
:root[data-theme="light"] {
  --bg-primary: #f7f7f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #eef0f3;
  --border: #e3e5e9;
  --text-primary: #16181d;
  --text-secondary: #6b7280;
  --accent-orange: #dd5900;
  --accent-gold: #b8860b;
  --accent-silver: #78716c;
  --accent-bronze: #9a5b30;
  --focus-ring: 0 0 0 3px rgba(221, 89, 0, 0.25);
}

:root[data-theme="light"] button.primary:hover { background: #c24e00; }
:root[data-theme="light"] button.danger:hover { background: #a51c00; }

:root[data-theme="light"] .skeleton-bar {
  background: linear-gradient(90deg, var(--bg-hover) 25%, #ffffff 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
}

/* Badges/status pills use their own literal colors (not the vars above) so
   they read as soft-tinted pills rather than translucent overlays on white. */
:root[data-theme="light"] .badge-red { background: #fee2e2; color: #b91c1c; }
:root[data-theme="light"] .badge-orange { background: #ffedd5; color: #c2410c; }
:root[data-theme="light"] .badge-darkred { background: #fecaca; color: #991b1b; }
:root[data-theme="light"] .badge-purple { background: #f3e8ff; color: #7e22ce; }
:root[data-theme="light"] .badge-gray { background: #e5e7eb; color: #4b5563; }
:root[data-theme="light"] .badge-dimgray { background: #f1f2f4; color: #6b7280; }
:root[data-theme="light"] .badge-green { background: #dcfce7; color: #15803d; }
:root[data-theme="light"] .badge-success { background: #dcfce7; color: #15803d; }
:root[data-theme="light"] .badge-blue { background: #dbeafe; color: #1d4ed8; }
:root[data-theme="light"] .status-active { background: linear-gradient(135deg, #dcfce7, #bbf7d0); color: #15803d; border-color: #86efac; box-shadow: 0 1px 6px rgba(21,128,61,0.12); }
:root[data-theme="light"] .status-banned { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #b91c1c; border-color: #fca5a5; box-shadow: 0 1px 6px rgba(185,28,28,0.12); }
:root[data-theme="light"] .status-staff { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #1d4ed8; border-color: #93c5fd; box-shadow: 0 1px 6px rgba(29,78,216,0.12); }
:root[data-theme="light"] .status-stale { background: linear-gradient(135deg, #ffedd5, #fed7aa); color: #c2410c; border-color: #fdba74; box-shadow: 0 1px 6px rgba(194,65,12,0.12); }
:root[data-theme="light"] .status-redhalo { background: linear-gradient(135deg, #f3e8ff, #e9d5ff); color: #7e22ce; border-color: #d8b4fe; box-shadow: 0 1px 6px rgba(126,34,206,0.12); }

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Custom scrollbar everywhere (page body, dropdown panels, the modal, etc.)
   instead of the browser's default bar. Elements that intentionally scroll
   sideways without showing a bar at all (.tabs, .navbar-links) already set
   their own ::-webkit-scrollbar{display:none}, which — being a more specific
   selector — wins over this regardless of order. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
  border: 2px solid var(--bg-primary);
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
  background-clip: padding-box;
}

/* Visible keyboard focus everywhere — mouse users never see it (:focus-visible),
   keyboard users always do. Removing this without a replacement fails WCAG. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-orange);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* ---------- Navbar ---------- */

.navbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--navbar-height);
}

.navbar-brand {
  font-weight: 800;
  font-size: 1.05rem;
  white-space: nowrap;
}

.navbar-brand span {
  color: var(--accent-orange);
}

.navbar-links {
  display: flex;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.navbar-links a {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.navbar-links a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.navbar-links a.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.navbar-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

/* Discord's own brand color — deliberately identical in both themes, like
   any brand mark, rather than following the site's light/dark palette. */
.discord-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #5865f2;
  border-color: #5865f2;
  color: #fff;
  white-space: nowrap;
}

.discord-btn:hover {
  background: #4752c4;
  border-color: #4752c4;
}

.discord-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  font-size: 1rem;
}

.navbar-search {
  position: relative;
  width: 220px;
}

.navbar-search input {
  width: 100%;
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' height='16' fill='none' stroke='%23888888' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  display: none;
  z-index: 200;
}

.search-dropdown.open {
  display: block;
}

.search-dropdown-group {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.search-dropdown-group:last-child {
  border-bottom: none;
}

.search-dropdown-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 6px 14px 2px;
}

.search-dropdown-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.88rem;
}

.search-dropdown-item:hover {
  background: var(--bg-hover);
}

.search-dropdown-empty {
  padding: 16px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Layout ---------- */

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
  width: 100%;
  flex: 1;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 800;
}

.page-note {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-orange);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 20px;
}

/* ---------- Inputs ---------- */

input, select, button, textarea {
  font-family: inherit;
  font-size: 0.9rem;
}

input[type="text"], input[type="search"], input[type="number"], input[type="password"], select, textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent-orange);
}

/* Native number-input spin buttons render as an unstyleable OS widget that
   looks nothing like the rest of the UI — hidden here in favor of the
   custom up/down stepper initNumberSteppers() (utils.js) builds around
   every <input type="number">, which still calls the input's own
   stepUp()/stepDown() so typing a value directly still works too. */
input[type="number"] {
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.number-stepper {
  position: relative;
  display: inline-flex;
}

.number-stepper input[type="number"] {
  width: 100%;
  padding-right: 28px;
}

.number-stepper-buttons {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 22px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  border-radius: 0 7px 7px 0;
  overflow: hidden;
}

.number-stepper-buttons button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 0;
  background: var(--bg-card);
  color: var(--text-secondary);
  line-height: 0;
}

.number-stepper-buttons button:first-child {
  border-bottom: 1px solid var(--border);
}

.number-stepper-buttons button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Custom checkbox — the native box is another unstyleable OS widget.
   `appearance: none` drops its default rendering entirely; everything
   below (box, checkmark) is drawn from scratch, while the element is
   still a real <input type="checkbox"> for click/keyboard/label behavior. */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-card);
  display: inline-block;
  position: relative;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.15s, border-color 0.15s;
}

input[type="checkbox"]:hover {
  border-color: var(--accent-orange);
}

input[type="checkbox"]:checked {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
}

input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #0a0a0a;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

button:hover {
  background: var(--bg-hover);
}

button:active {
  transform: scale(0.98);
}

button.primary {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
  color: #0a0a0a;
}

button.primary:hover {
  background: #ff7a1f;
}

button.danger {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #fff;
}

button.danger:hover {
  background: #e0290a;
}

button.ghost {
  background: transparent;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.icon-btn {
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button svg, .username-link svg, .device-icon svg {
  vertical-align: middle;
  flex-shrink: 0;
}

/* ---------- Filter bar ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}

.filter-bar input, .filter-bar select {
  min-width: 140px;
}

.filter-spacer {
  flex: 1;
}

.jump-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.jump-controls input {
  width: 170px;
}

/* ---------- Table ---------- */

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  overflow-x: auto;
}

table {
  width: 100%;
  /* border-collapse breaks position: sticky on <th> in Chromium; separate +
     zero spacing keeps the same visual look without that bug. */
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

thead th {
  /* Not sticky: position:sticky on <th> is notoriously inconsistent across
     browsers in table layout, and with pagination capped at 25 rows a
     sticky header isn't worth that risk — the header is always one short
     scroll away. */
  background: var(--bg-secondary);
  text-align: left;
  padding: 10px 14px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

thead th.sortable {
  cursor: pointer;
}

thead th.sortable:hover {
  color: var(--text-primary);
}

thead th .sort-arrow {
  margin-left: 4px;
  opacity: 0.6;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

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

tbody tr.rank-1 { background: var(--rank-1); }
tbody tr.rank-2 { background: var(--rank-2); }
tbody tr.rank-3 { background: var(--rank-3); }
tbody tr.rank-1:hover, tbody tr.rank-2:hover, tbody tr.rank-3:hover { background: var(--bg-hover); }

tbody tr.highlighted {
  outline: 2px solid var(--accent-orange);
  outline-offset: -2px;
}

.username-link {
  font-weight: 600;
  cursor: pointer;
}

.username-link:hover {
  color: var(--accent-orange);
  text-decoration: underline;
}

.rank-cell {
  font-weight: 700;
}

.rank-1 .rank-cell { color: var(--accent-gold); }
.rank-2 .rank-cell { color: var(--accent-silver); }
.rank-3 .rank-cell { color: var(--accent-bronze); }

.muted {
  color: var(--text-secondary);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-red { background: rgba(204,34,0,0.18); color: #ff6644; }
.badge-orange { background: rgba(255,102,0,0.18); color: #ff9955; }
.badge-darkred { background: rgba(120,0,0,0.28); color: #ff4444; }
.badge-purple { background: rgba(168,85,247,0.18); color: #c084fc; }
.badge-gray { background: rgba(107,114,128,0.22); color: #9ca3af; }
.badge-dimgray { background: rgba(107,114,128,0.12); color: #6b7280; }
.badge-green { background: rgba(34,197,94,0.18); color: #4ade80; text-decoration: line-through; }
.badge-success { background: rgba(34,197,94,0.18); color: #4ade80; }
.badge-blue { background: rgba(59,130,246,0.18); color: #60a5fa; }

.board-row-link {
  display: inline-flex;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.board-row-link:hover {
  color: var(--accent-orange);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.status-active { background: linear-gradient(135deg, rgba(34,197,94,0.24), rgba(34,197,94,0.08)); color: #4ade80; border-color: rgba(74,222,128,0.3); box-shadow: 0 1px 6px rgba(34,197,94,0.18); }
.status-banned { background: linear-gradient(135deg, rgba(255,68,34,0.24), rgba(255,68,34,0.08)); color: #ff6644; border-color: rgba(255,102,68,0.3); box-shadow: 0 1px 6px rgba(255,68,34,0.18); }
.status-staff { background: linear-gradient(135deg, rgba(59,130,246,0.24), rgba(59,130,246,0.08)); color: #60a5fa; border-color: rgba(96,165,250,0.3); box-shadow: 0 1px 6px rgba(59,130,246,0.18); }
.status-stale { background: linear-gradient(135deg, rgba(255,102,0,0.24), rgba(255,102,0,0.08)); color: #ff9955; border-color: rgba(255,153,85,0.3); box-shadow: 0 1px 6px rgba(255,102,0,0.18); }
.status-redhalo { background: linear-gradient(135deg, rgba(168,85,247,0.24), rgba(168,85,247,0.08)); color: #c084fc; border-color: rgba(192,132,252,0.3); box-shadow: 0 1px 6px rgba(168,85,247,0.18); }

/* Deliberately louder than the other status badges (gradient + glow instead of
   a flat tint) — it's meant to read as a highlight/honor, not just a status. */
.status-influencer {
  background: linear-gradient(135deg, #ec4899, #f97316);
  color: #fff;
  box-shadow: 0 2px 10px rgba(236,72,153,0.45);
}

.status-badge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.note-banner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-orange);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.note-banner.danger { border-left-color: var(--accent-red); }
.note-banner .icon { flex-shrink: 0; margin-top: 1px; }

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.pagination-count {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.pagination-buttons {
  display: flex;
  gap: 6px;
}

.pagination-buttons button.active {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
  color: #0a0a0a;
}

/* ---------- Cards ---------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.stat-card .value {
  font-size: 1.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-card .label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 4px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.chart-card h3 {
  margin: 0 0 14px;
  font-size: 0.95rem;
}

.chart-card canvas {
  max-height: 280px;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chart-card-header h3 {
  margin: 0;
}

.chip-toggle {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.chip-toggle button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
}

.chip-toggle button.active {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
  color: #0a0a0a;
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs button {
  border: none;
  background: transparent;
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.tabs button.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-orange);
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
}

.modal h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

.modal-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* ---------- Toast ---------- */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-blue);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 240px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toast-in 0.2s ease;
  font-size: 0.88rem;
}

.toast.success { border-left-color: var(--accent-green); }
.toast.error { border-left-color: var(--accent-red); }
.toast.info { border-left-color: var(--accent-blue); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Skeleton / Empty ---------- */

.skeleton-row td {
  padding: 14px 16px;
}

.skeleton-bar {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-hover) 25%, #2c2c2c 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Country select (searchable, flag icons) ---------- */

.country-flag, .fi.country-flag {
  vertical-align: middle;
  flex-shrink: 0;
}

.fi.country-flag {
  width: 18px;
  height: 13px;
  border-radius: 2px;
  background-size: cover;
  background-position: center;
}

.country-select {
  position: relative;
  min-width: 170px;
}

.country-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.country-select-trigger svg {
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.country-select-trigger[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.country-select-label {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.country-select-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 260px;
  max-height: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.country-select-panel.open {
  display: flex;
}

.country-select-search {
  margin: 8px;
  width: calc(100% - 16px);
}

.country-select-options {
  overflow-y: auto;
  padding: 4px;
}

.country-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
}

.country-select-option:hover {
  background: var(--bg-hover);
}

.country-select-option.selected {
  color: var(--accent-orange);
}

.country-select-check {
  width: 14px;
  flex-shrink: 0;
  color: var(--accent-orange);
}

.country-select-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ---------- Device select (icon dropdown) — same look as country-select ---------- */

.device-select {
  position: relative;
  min-width: 150px;
}

.device-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.device-select-trigger svg {
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.device-select-trigger[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.device-select-label {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-select-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.device-select-panel.open {
  display: flex;
}

.device-select-options {
  padding: 4px;
}

.device-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
}

.device-select-option:hover {
  background: var(--bg-hover);
}

.device-select-option.selected {
  color: var(--accent-orange);
}

.device-select-check {
  width: 14px;
  flex-shrink: 0;
  color: var(--accent-orange);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state .icon {
  font-size: 2.4rem;
  margin-bottom: 10px;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.site-footer a {
  color: var(--accent-orange);
}

.site-footer a:hover {
  text-decoration: underline;
}

/* ---------- Misc ---------- */

.hidden { display: none !important; }

.flag-emoji {
  margin-right: 4px;
}

.device-icon {
  margin-right: 4px;
}

[title] {
  cursor: help;
}

.loading-spinner {
  border: 3px solid var(--border);
  border-top-color: var(--accent-orange);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  animation: spin 0.7s linear infinite;
  margin: 30px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
  .navbar { padding: 0 12px; }
  .navbar-inner { flex-wrap: wrap; height: auto; padding: 10px 0; gap: 10px; justify-content: space-between; }
  .navbar-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .navbar-links::-webkit-scrollbar { display: none; }
  .navbar-links a { flex-shrink: 0; }
  .navbar-search { width: 100%; order: 2; }
  .search-dropdown { width: 100%; max-width: 100%; }

  .page { padding: 20px 14px; }
  .page-title { font-size: 1.35rem; }

  .modal-form-grid { grid-template-columns: 1fr; }
  .modal { padding: 18px; }

  .chart-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }

  .filter-bar { padding: 12px; }
  .filter-bar > input,
  .filter-bar > .country-select,
  .filter-bar > .device-select {
    width: 100%;
  }
  .filter-spacer { display: none; }
  .jump-controls { width: 100%; }
  .jump-controls input { flex: 1; width: auto; min-width: 0; }
  #reset-filters { width: 100%; }

  .country-select-panel, .device-select-panel {
    max-width: calc(100vw - 56px);
  }

  .toast-container { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; width: 100%; }
}

/* Below phone width, the table keeps its real <thead> (so tapping a header
   sorts exactly like the desktop click-to-sort does — same elements, same
   listeners, nothing mobile-specific to break) and stays horizontally
   scrollable, but its first two columns (whichever a given page considers
   the "identity" columns — Rank+Username, or Username+Level for the Stats
   recent-activity table) are frozen in place with position: sticky, so you
   always know whose row you're looking at while swiping to see the rest. */
@media (max-width: 640px) {
  .rtable th:nth-child(1), .rtable td:nth-child(1),
  .rtable th:nth-child(2), .rtable td:nth-child(2) {
    position: sticky;
    z-index: 2;
  }
  .rtable th:nth-child(1), .rtable td:nth-child(1) {
    left: 0;
    width: 58px;
    min-width: 58px;
    max-width: 58px;
  }
  .rtable th:nth-child(2), .rtable td:nth-child(2) {
    left: 58px;
    width: 118px;
    min-width: 118px;
    max-width: 118px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .rtable thead th:nth-child(1), .rtable thead th:nth-child(2) {
    background: var(--bg-secondary);
  }
  .rtable tbody td:nth-child(1), .rtable tbody td:nth-child(2) {
    background: var(--bg-card);
  }
  .rtable tbody tr:hover td:nth-child(1), .rtable tbody tr:hover td:nth-child(2) {
    background: var(--bg-hover);
  }
  /* A sticky cell needs its own fully OPAQUE background, or the columns
     scrolled behind it show through — the rank-1/2/3 tint colors are
     semi-transparent (blended against the row elsewhere), so applied
     directly as a sticky cell's only background they'd let exactly that
     scrolled content bleed through. Layering the tint as a background-image
     over an opaque background-color composites it to a flat, opaque result
     first, within this cell, before the cell is stacked over anything else. */
  .rtable tbody tr.rank-1 td:nth-child(1), .rtable tbody tr.rank-1 td:nth-child(2) {
    background-color: var(--bg-card);
    background-image: linear-gradient(var(--rank-1), var(--rank-1));
  }
  .rtable tbody tr.rank-2 td:nth-child(1), .rtable tbody tr.rank-2 td:nth-child(2) {
    background-color: var(--bg-card);
    background-image: linear-gradient(var(--rank-2), var(--rank-2));
  }
  .rtable tbody tr.rank-3 td:nth-child(1), .rtable tbody tr.rank-3 td:nth-child(2) {
    background-color: var(--bg-card);
    background-image: linear-gradient(var(--rank-3), var(--rank-3));
  }
}
