/* =========================================================
   CLUBHOUSE V1 — Global Styles
   Maple Ranch Private-Side Guest Management
   Design language: Facebook UI / Events CRM family
   Token names aligned with Events CRM css/styles.css
   ========================================================= */

/* ---------------------------------------------------------
   Design Tokens
   --------------------------------------------------------- */
:root {
  /* Brand */
  --fb-blue: #1877f2;
  --fb-blue-hover: #166fe5;
  --fb-blue-active: #1464cc;
  --fb-blue-soft: #e7f0fe;

  /* Neutrals */
  --color-bg: #f0f2f5;
  --color-surface: #ffffff;
  --color-surface-2: #f7f8fa;
  --color-hover: #e4e6eb;
  --color-pressed: #d8dadf;
  --color-divider: #ced0d4;
  --color-divider-soft: #e4e6eb;

  --color-text: #050505;
  --color-text-secondary: #65676b;
  --color-text-tertiary: #8a8d91;
  --color-text-on-blue: #ffffff;

  /* Status */
  --color-success: #31a24c;
  --color-success-soft: #e6f4ea;
  --color-warning: #f7b928;
  --color-warning-soft: #fff5d6;
  --color-danger: #e41e3f;
  --color-danger-soft: #fde7eb;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    Helvetica, Roboto, Arial, sans-serif;
  --font-display: var(--font-sans);
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: 28px;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --lh-tight: 1.2;
  --lh-snug: 1.33;
  --lh-normal: 1.45;

  /* Spacing — 4px base */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 8px;
  --radius-card: 8px;
  --radius-xl: 12px;
  --radius-pill-tight: 20px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
  --shadow-md: 0 1px 2px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 28px rgba(0,0,0,0.18), 0 2px 4px rgba(0,0,0,0.08);

  /* Layout */
  --sidebar-w: 240px;
  --sidebar-collapsed: 64px;
  --content-max-width: 1200px;
}

/* ---------------------------------------------------------
   Reset / Base
   --------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  /* Disable iOS pull-to-refresh on body — main scroll lives in main-content */
  overscroll-behavior-y: contain;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-2) 0;
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  font-family: var(--font-display);
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p { margin: 0 0 var(--space-2) 0; }

a {
  color: var(--fb-blue);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

ul { margin: 0; padding: 0; list-style: none; }

/* ---------------------------------------------------------
   SVG Icon Sprite
   --------------------------------------------------------- */
.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }
.icon--xl { width: 32px; height: 32px; }

/* ---------------------------------------------------------
   Splash Screen
   --------------------------------------------------------- */
#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 500ms ease-out;
}

#splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#splash-video {
  width: 300px;
  max-width: 80vw;
  height: auto;
  display: block;
}

@media (max-width: 768px) {
  #splash-video {
    width: 200px;
  }
}

/* ---------------------------------------------------------
   Sign-in Screen
   Same card, logo, title and digit boxes the PIN screen used —
   only the steps inside it changed (email, then a six-digit code).
   --------------------------------------------------------- */
#signin-screen {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: #ffffff;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.pin-screen__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.pin-screen__logo {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-divider-soft), var(--shadow-sm);
  padding: 4px;
  display: grid;
  place-items: center;
  margin-bottom: var(--space-4);
  overflow: hidden;
}

.pin-screen__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-pill);
  display: block;
}

.pin-screen__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--color-text);
  margin: 0 0 var(--space-2);
}

.pin-screen__subtitle {
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-5);
}

.pin-input {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-bottom: var(--space-3);
}

.pin-digit {
  width: 52px;
  height: 64px;
  font-size: 28px;
  font-weight: var(--fw-bold);
  text-align: center;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  font-family: var(--font-sans);
  -webkit-appearance: none;
  appearance: none;
}

.pin-digit:focus {
  border-color: var(--fb-blue);
  box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.20);
}

.pin-screen__error {
  min-height: 20px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-danger);
}

@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

#signin-screen.shake .pin-input {
  animation: pinShake 0.35s ease;
}

/* Six boxes instead of four, so each one is narrower — the row still
   has to fit the 360px card without wrapping. */
.pin-digit--code {
  width: 44px;
  height: 58px;
  font-size: 24px;
}

.signin-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.signin-input {
  text-align: center;
  font-size: var(--fs-md);
}

.signin-submit {
  width: 100%;
  justify-content: center;
}

#signin-code-form .signin-submit {
  margin-top: var(--space-3);
}

.signin-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--space-3);
}

@media (max-width: 420px) {
  .pin-digit {
    width: 48px;
    height: 60px;
    font-size: 24px;
  }
  .pin-digit--code {
    width: 40px;
    height: 52px;
    font-size: 20px;
  }
  .pin-input { gap: var(--space-2); }
}

/* ---------------------------------------------------------
   App Container — sidebar + main layout
   --------------------------------------------------------- */
.app-container {
  display: flex;
  height: 100vh;
  height: 100dvh;       /* iOS dynamic viewport */
  width: 100%;
  overflow: hidden;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--color-bg);
  -webkit-overflow-scrolling: touch;
}

#view-root {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-6);
  min-width: 0;
  overflow-x: hidden;
}

@media (max-width: 768px) {
  #view-root {
    padding: var(--space-4) var(--space-3);
  }
}

/* ---------------------------------------------------------
   Sidebar
   --------------------------------------------------------- */
#sidebar {
  width: var(--sidebar-w);
  background: var(--color-surface);
  border-right: 1px solid var(--color-divider-soft);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 200ms ease;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-divider-soft);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.brand-mark-logo {
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-divider-soft);
  padding: 2px;
}

.brand-mark-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-pill);
  display: block;
}

.brand-text {
  min-width: 0;
}

.brand-name {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--color-text);
  line-height: var(--lh-tight);
}

.brand-sub {
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
  font-weight: var(--fw-regular);
  margin-top: 2px;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-secondary);
  padding: var(--space-2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: var(--space-2);
}

.sidebar-toggle:hover {
  background: var(--color-hover);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  overflow-y: auto;
}

.sidebar-nav li {
  margin: 2px 0;
}

.sidebar-item,
.nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-weight: var(--fw-medium);
  font-size: var(--fs-md);
  transition: background 120ms ease, color 120ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
}

.sidebar-item:hover,
.nav__item:hover {
  background: var(--color-hover);
  text-decoration: none;
}

.sidebar-item.active,
.nav__item.is-active {
  background: var(--fb-blue-soft);
  color: var(--fb-blue);
}

.sidebar-item.active .sidebar-icon,
.sidebar-item.active .icon,
.nav__item.is-active .icon {
  color: var(--fb-blue);
}

.sidebar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--color-text-secondary);
}

.sidebar-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  border-top: 1px solid var(--color-divider-soft);
  padding: var(--space-3);
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

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

.sidebar-lock-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  padding: var(--space-2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
  flex-shrink: 0;
}

.sidebar-lock-btn:hover {
  background: var(--color-hover);
  color: var(--color-text);
}

.sidebar-lock-btn .icon {
  width: 18px;
  height: 18px;
}

.user-name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--fb-blue);
  color: var(--color-text-on-blue);
  display: grid;
  place-items: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  flex-shrink: 0;
}

/* Mobile sidebar — collapse to icons-only rail */
@media (max-width: 768px) {
  #sidebar {
    width: var(--sidebar-collapsed);
  }

  #sidebar .sidebar-label,
  #sidebar .brand-text,
  #sidebar .sidebar-user,
  #sidebar .sidebar-lock-btn {
    display: none;
  }

  #sidebar.expanded .sidebar-label,
  #sidebar.expanded .brand-text,
  #sidebar.expanded .sidebar-user,
  #sidebar.expanded .sidebar-lock-btn {
    display: initial;
  }

  #sidebar.expanded .sidebar-user {
    display: block;
  }

  #sidebar.expanded .sidebar-lock-btn {
    display: inline-flex;
  }

  .sidebar-brand {
    justify-content: center;
    padding: var(--space-3) var(--space-2);
  }

  .sidebar-item,
  .nav__item {
    justify-content: center;
    padding: var(--space-3) var(--space-2);
  }

  .sidebar-footer {
    justify-content: center;
    padding: var(--space-3) var(--space-2);
  }
}

/* ---------------------------------------------------------
   Card
   --------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-divider-soft);
}

.card-header h2,
.card-header h3 {
  margin: 0;
}

/* ---------------------------------------------------------
   Buttons
   --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--color-hover);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  text-decoration: none;
  line-height: var(--lh-tight);
}

.btn:hover {
  background: var(--color-pressed);
  text-decoration: none;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--fb-blue);
  color: var(--color-text-on-blue);
}

.btn-primary:hover {
  background: var(--fb-blue-hover);
  color: var(--color-text-on-blue);
}

.btn-outline {
  background: transparent;
  border-color: var(--color-divider);
  color: var(--color-text);
}

.btn-outline:hover {
  background: var(--color-hover);
}

.btn-danger {
  background: var(--color-danger);
  color: #ffffff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: var(--fs-sm);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: 16px;
}

/* ---------------------------------------------------------
   Form Inputs
   --------------------------------------------------------- */
.input,
.select,
.textarea {
  width: 100%;
  padding: 10px var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  transition: border-color 120ms ease, box-shadow 120ms ease;
  -webkit-appearance: none;
  appearance: none;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--fb-blue);
  box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.20);
}

.textarea {
  min-height: 88px;
  resize: vertical;
}

/* The arrow sits var(--space-3) in from the right edge and is 12px wide, so
   padding-right: var(--space-7) keeps the text 8px clear of it. A rule that
   gives a .select its own padding must keep that right side (write the
   shorthand as `padding: <y> var(--space-7) <y> <x>`), or the text runs
   under the arrow. */
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2365676B' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-7);
}

@media (max-width: 768px) {
  /* iOS auto-zooms a focused input below 16px and never zooms back out.
     Anything a finger can put a caret into stays at 16px on a phone.
     input[type="text"] excludes .pin-digit — the sign-in code boxes are
     already above the threshold and must keep their smaller size. */
  .input,
  .select,
  .textarea,
  .signin-input,
  input[type="text"]:not(.pin-digit),
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="search"],
  input[type="date"],
  input[type="time"],
  input[type="password"] {
    font-size: 16px;
  }
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

/* ---------------------------------------------------------
   Filter Pills (legacy .pill kept for back-compat; new .filter-pill preferred)
   --------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  color: var(--color-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  margin-right: var(--space-2);
  margin-bottom: var(--space-2);
}

.pill:hover {
  background: var(--color-hover);
}

.pill.active {
  background: var(--fb-blue);
  border-color: var(--fb-blue);
  color: var(--color-text-on-blue);
}

/* ---------------------------------------------------------
   Modal
   --------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.50);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-4);
}

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

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
}

.modal-body {
  padding: var(--space-5);
}

.modal-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-divider-soft);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ---------------------------------------------------------
   Toast Notifications
   --------------------------------------------------------- */
#toast-container {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: var(--color-surface);
  color: var(--color-text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--fb-blue);
  min-width: 240px;
  max-width: 360px;
  font-size: 14px;
  font-weight: var(--fw-medium);
  animation: toastIn 200ms ease-out;
  pointer-events: auto;
}

.toast.toast-success { border-left-color: var(--color-success); }
.toast.toast-error   { border-left-color: var(--color-danger); }
.toast.toast-warning { border-left-color: var(--color-warning); }
.toast.toast-info    { border-left-color: var(--fb-blue); }

@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@media (max-width: 768px) {
  #toast-container {
    top: var(--space-3);
    right: var(--space-3);
    left: var(--space-3);
  }
  .toast { max-width: 100%; }

  /* Any bare .data-table (staff, custom blinds, processing centers, season
     limits, stay history, entry-flow queue, backfill error log, ...) scrolls
     horizontally in place instead of forcing the page to overflow sideways.
     Excludes .hunt-table: its card (.hunt-table-card, css/views.css) is the
     scroller, with the row's actions cell stuck to its right edge — a
     second scroll container here would take that edge away. */
  .data-table:not(.hunt-table) {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------------------------------------------------------
   Data Table
   --------------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider-soft);
  font-size: 14px;
}

.data-table th {
  background: var(--color-surface-2);
  font-weight: var(--fw-semibold);
  color: var(--color-text-secondary);
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.data-table tbody tr:hover {
  background: var(--color-surface-2);
}

/* ---------------------------------------------------------
   Loading Spinner
   --------------------------------------------------------- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-divider-soft);
  border-top-color: var(--fb-blue);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

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

.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-5);
  color: var(--color-text-secondary);
}

/* ---------------------------------------------------------
   Status badges
   --------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  background: var(--color-hover);
  color: var(--color-text);
}

.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: #946e10; }
.badge-danger  { background: var(--color-danger-soft);  color: var(--color-danger); }
.badge-info    { background: var(--fb-blue-soft);       color: var(--fb-blue); }

/* ---------------------------------------------------------
   Utilities
   --------------------------------------------------------- */
.text-primary    { color: var(--color-text); }
.text-secondary  { color: var(--color-text-secondary); }
.text-tertiary   { color: var(--color-text-tertiary); }
.text-success    { color: var(--color-success); }
.text-danger     { color: var(--color-danger); }
.text-center     { text-align: center; }
.text-right      { text-align: right; }
.text-bold       { font-weight: var(--fw-semibold); }
.text-sm         { font-size: var(--fs-sm); }
.text-lg         { font-size: var(--fs-lg); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-6); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-6); }

.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.hidden { display: none !important; }
.w-full { width: 100%; }

/* ---------------------------------------------------------
   Back-to-Top Button (global, floating)
   --------------------------------------------------------- */
#back-to-top-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-primary, #1877F2);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#back-to-top-btn:hover {
  filter: brightness(1.05);
}

#back-to-top-btn.back-to-top-visible {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 768px) {
  #back-to-top-btn {
    bottom: 32px;
  }
}

/* ---------------------------------------------------------
   TV mode — #/leaderboard-tv fills the window with no app chrome
   --------------------------------------------------------- */
body.tv-mode #sidebar,
body.tv-mode #back-to-top-btn,
body.tv-mode #toast-container {
  display: none !important;
}

body.tv-mode .app-container {
  padding: 0;
}

body.tv-mode #main-content {
  overflow: hidden;
  /* Bone, like .tv-screen, so no brown shows around the screen or flashes while it loads. */
  background: #EAE3D5;
}

body.tv-mode #view-root {
  max-width: none;
  padding: 0;
  margin: 0;
  height: 100%;
  overflow: hidden;
}
