/* ==========================================================================
   vRace Account Studio — Athletic Telemetry Console Design System
   Powered by UI/UX Pro Max:
   - Palette: vRace Blaze (#F97316) + Telemetry Cyan (#22D3EE) + Emerald (#10B981)
   - Tri-Stack Fonts: Plus Jakarta Sans (Display/KPI) + Be Vietnam Pro (UI) + JetBrains Mono (Data)
   - Surface Depth, Sticky Data Grid, Segmented Subtab Glider, Tactile Motion
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Layered Surfaces */
  --bg-canvas: #090c10;
  --bg-canvas-glow:
    radial-gradient(880px 360px at 14% -8%, rgba(249, 115, 22, 0.075), transparent 65%),
    radial-gradient(760px 320px at 88% -10%, rgba(34, 211, 238, 0.06), transparent 65%);
  --bg-surface: #11161f;
  --bg-surface-hover: #151c27;
  --bg-elevated: #18202d;
  --bg-inset: #0b0f16;
  --header-bg: rgba(17, 22, 31, 0.84);

  /* Borders & Highlights */
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-default: rgba(255, 255, 255, 0.085);
  --border-hover: rgba(255, 255, 255, 0.16);
  --surface-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.055);

  /* Brand & Semantic Tokens */
  --primary: #f97316;
  --primary-hover: #fb923c;
  --primary-dim: rgba(249, 115, 22, 0.14);
  --primary-border: rgba(249, 115, 22, 0.34);
  --on-primary: #ffffff;

  --accent: #22d3ee;
  --accent-dim: rgba(34, 211, 238, 0.12);
  --accent-border: rgba(34, 211, 238, 0.28);
  --on-accent: #06131a;

  --success: #10b981;
  --success-dim: rgba(16, 185, 129, 0.13);
  --success-border: rgba(16, 185, 129, 0.28);

  --warning: #f59e0b;
  --warning-dim: rgba(245, 158, 11, 0.13);
  --warning-border: rgba(245, 158, 11, 0.28);

  --danger: #f43f5e;
  --danger-dim: rgba(244, 63, 94, 0.13);
  --danger-border: rgba(244, 63, 94, 0.3);

  --violet: #38bdf8;
  --violet-dim: rgba(56, 189, 248, 0.12);

  /* Typography Colors */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Gradients & Elevation */
  --grad-brand: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
  --grad-telemetry: linear-gradient(90deg, #f97316 0%, #22d3ee 55%, #10b981 100%);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.38);
  --shadow-lg: 0 22px 54px rgba(0, 0, 0, 0.62);
  --shadow-primary: 0 4px 16px rgba(249, 115, 22, 0.3);
  --focus-ring: 0 0 0 3px rgba(34, 211, 238, 0.22);

  /* Tri-Stack Fonts */
  --font-display: "Plus Jakarta Sans", "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-ui: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

  /* 6-Step Modular Type Scale */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13.5px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-kpi: 26px;

  /* Radii & Spacing Rhythm */
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="light"] {
  color-scheme: light;

  --bg-canvas: #f3f6fb;
  --bg-canvas-glow:
    radial-gradient(880px 360px at 14% -8%, rgba(234, 88, 12, 0.055), transparent 65%),
    radial-gradient(760px 320px at 88% -10%, rgba(2, 132, 199, 0.055), transparent 65%);
  --bg-surface: #ffffff;
  --bg-surface-hover: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-inset: #edf2f8;
  --header-bg: rgba(255, 255, 255, 0.88);

  --border-subtle: rgba(15, 23, 42, 0.05);
  --border-default: rgba(15, 23, 42, 0.095);
  --border-hover: rgba(15, 23, 42, 0.18);
  --surface-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.9);

  --primary: #ea580c;
  --primary-hover: #f97316;
  --primary-dim: rgba(234, 88, 12, 0.1);
  --primary-border: rgba(234, 88, 12, 0.28);
  --on-primary: #ffffff;

  --accent: #0284c7;
  --accent-dim: rgba(2, 132, 199, 0.1);
  --accent-border: rgba(2, 132, 199, 0.26);
  --on-accent: #ffffff;

  --success: #059669;
  --success-dim: rgba(5, 150, 105, 0.1);
  --success-border: rgba(5, 150, 105, 0.26);

  --warning: #d97706;
  --warning-dim: rgba(217, 119, 6, 0.11);
  --warning-border: rgba(217, 119, 6, 0.28);

  --danger: #e11d48;
  --danger-dim: rgba(225, 29, 72, 0.1);
  --danger-border: rgba(225, 29, 72, 0.28);

  --violet: #0369a1;
  --violet-dim: rgba(3, 105, 161, 0.1);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --grad-brand: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
  --grad-telemetry: linear-gradient(90deg, #ea580c 0%, #0284c7 55%, #059669 100%);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 20px 44px rgba(15, 23, 42, 0.15);
  --shadow-primary: 0 4px 14px rgba(234, 88, 12, 0.24);
  --focus-ring: 0 0 0 3px rgba(2, 132, 199, 0.18);
}

/* ==========================================================================
   Reset, Base Typography & Custom Scrollbars
   ========================================================================== */

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

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-hover) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

*::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

body {
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-canvas);
  background-image: var(--bg-canvas-glow);
  background-attachment: fixed;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

code {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--accent);
}

kbd.kbd-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 19px;
  padding: 0 5px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  box-shadow: inset 0 -1px 0 var(--border-default);
  pointer-events: none;
  user-select: none;
}

/* Tabular Numbers for Telemetry Alignment */
.stat-value,
.nav-badge,
.filter-badge,
.page-label,
.pagination-info,
.log-console,
.col-num {
  font-variant-numeric: tabular-nums;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ==========================================================================
   Top Header & Live WebSocket Telemetry Pill
   ========================================================================== */

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  min-height: 58px;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-default);
  box-shadow: var(--surface-highlight);
  gap: 12px;
  z-index: 30;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 11px;
}

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

.sidebar-toggle-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: var(--bg-inset);
  flex-shrink: 0;
  transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease, transform 0.1s ease;
}

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

.sidebar-toggle-btn:active {
  transform: scale(0.95);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--grad-brand);
  color: var(--on-primary);
  font-family: var(--font-display);
  font-weight: 800;
  display: grid;
  place-items: center;
  font-size: 13.5px;
  letter-spacing: -0.03em;
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  flex-shrink: 0;
}

.brand-title {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-accent {
  color: var(--primary);
}

.brand-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ws-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  transition: border-color 0.2s ease, color 0.2s ease;
}

.ws-pill.connected {
  border-color: var(--success-border);
  color: var(--text-primary);
}

.ws-pill.disconnected {
  border-color: var(--danger-border);
  color: var(--danger);
}

.ws-dot {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
}

.ws-pill.connected .ws-dot {
  background: var(--success);
}

.ws-pill.connected .ws-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1.5px solid var(--success);
  opacity: 0;
  animation: vraceSonarPulse 2.4s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.ws-pill.disconnected .ws-dot {
  background: var(--danger);
}

@keyframes vraceSonarPulse {
  0% {
    transform: scale(0.75);
    opacity: 0.75;
  }
  75%, 100% {
    transform: scale(1.85);
    opacity: 0;
  }
}

/* ==========================================================================
   Main Workspace & Grouped Sidebar
   ========================================================================== */

.workspace-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: 226px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 10px 12px 4px;
  user-select: none;
  white-space: nowrap;
}

.nav-group-label:first-of-type {
  padding-top: 2px;
}

.sidebar.collapsed {
  width: 64px;
  padding: 14px 8px;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-tag,
.sidebar.collapsed .nav-group-label,
.sidebar.collapsed .sidebar-footer {
  display: none;
}

.sidebar-mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-default);
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.62);
  backdrop-filter: blur(4px);
  will-change: opacity;
  z-index: 45;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  font-weight: 500;
  text-align: left;
  transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.1s ease;
}

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

.nav-item:active {
  transform: scale(0.985);
}

.nav-item.active {
  background: var(--primary-dim);
  border-color: var(--primary-border);
  color: var(--primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--primary);
}

.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.nav-item:hover .nav-icon {
  transform: translateX(1px);
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  font-weight: 600;
}

.nav-item.active .nav-badge {
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
}

.nav-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-inset);
  color: var(--text-muted);
}

.sidebar-spacer {
  flex: 1;
  min-height: 12px;
}

.sidebar-footer {
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.sidebar-footer-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
}

.sidebar-footer-head i {
  color: var(--primary);
}

.mono-truncate {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-primary);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 28px;
  scroll-behavior: smooth;
}

.page-view {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.page-view.active {
  display: flex;
}

/* ==========================================================================
   KPI Bento Cards & Surface Panels
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.024) 0%, transparent 100%),
    var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--surface-highlight), var(--shadow-sm);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: var(--surface-highlight), var(--shadow-md);
}

.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.stat-icon-primary {
  background: var(--primary-dim);
  border-color: var(--primary-border);
  color: var(--primary);
}

.stat-icon-success {
  background: var(--success-dim);
  border-color: var(--success-border);
  color: var(--success);
}

.stat-icon-accent {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent);
}

.stat-icon-violet {
  background: var(--violet-dim);
  border-color: rgba(56, 189, 248, 0.26);
  color: var(--violet);
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--fs-kpi);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-top: 6px;
}

.stat-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-meter {
  height: 3px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--bg-inset);
  overflow: hidden;
}

.stat-meter-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--grad-brand);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.stat-meter-fill.fill-success { background: var(--success); }
.stat-meter-fill.fill-accent { background: var(--accent); }
.stat-meter-fill.fill-violet { background: var(--violet); }

.text-primary-brand { color: var(--primary); }
.text-success { color: var(--success); }
.text-accent { color: var(--accent); }
.text-violet { color: var(--violet); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.016) 0%, transparent 100%),
    var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--surface-highlight), var(--shadow-sm);
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-header h3 {
  font-size: var(--fs-md);
  font-weight: 650;
  color: var(--text-primary);
}

/* ==========================================================================
   Inputs, Custom Checkboxes, Search Wrapper & Tactile Buttons
   ========================================================================== */

.input {
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: var(--fs-base);
  font-family: inherit;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

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

.input:hover:not(:disabled):not(:focus) {
  border-color: var(--border-hover);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.input:not(textarea) {
  min-height: 36px;
  line-height: 1.35;
}

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

.input-sm:not(textarea) {
  min-height: 30px;
}

.search-input-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 256px;
}

.search-input-wrap > i {
  position: absolute;
  left: 11px;
  font-size: 12.5px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-wrap > .input-search {
  width: 100%;
  min-width: 0;
  padding-left: 32px;
  padding-right: 32px;
}

.search-input-wrap > kbd.kbd-hint {
  position: absolute;
  right: 8px;
}

.input-search {
  min-width: 240px;
}

.textarea {
  resize: vertical;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

/* Custom Accessible Checkbox */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 4.5px;
  border: 1.5px solid var(--border-hover);
  background: var(--bg-inset);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  flex-shrink: 0;
  vertical-align: middle;
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}

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

input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

input[type="checkbox"]::before {
  content: "";
  width: 9px;
  height: 9px;
  transform: scale(0);
  transition: transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1);
  background-color: var(--on-primary);
  clip-path: polygon(14% 44%, 0 62%, 44% 100%, 100% 20%, 82% 4%, 42% 68%);
}

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

input[type="checkbox"]:checked::before {
  transform: scale(1);
}

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

input[type="checkbox"]:indeterminate::before {
  background-color: var(--on-accent);
  clip-path: inset(38% 12% 38% 12% round 2px);
  transform: scale(1);
}

/* Tactile Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.09s ease,
    filter 0.15s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: var(--bg-surface-hover);
  filter: brightness(1.06);
}

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

.btn:focus-visible,
.btn-icon:focus-visible,
.nav-item:focus-visible,
.subtab-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

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

.btn.btn-loading {
  pointer-events: none;
  opacity: 0.8;
}

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

.btn-xs {
  padding: 3.5px 8px;
  font-size: var(--fs-xs);
  border-radius: 6px;
}

.btn-primary {
  background: var(--grad-brand);
  color: var(--on-primary);
  border-color: transparent;
  font-weight: 600;
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:hover:not(:disabled) {
  background: var(--grad-brand);
  border-color: transparent;
  filter: brightness(1.08);
}

/* Calm Tonal Row Action Buttons (avoids 50 glaring primary buttons per table page) */
.btn-tonal-primary {
  background: var(--primary-dim);
  color: var(--primary);
  border-color: var(--primary-border);
  font-weight: 600;
}

.btn-tonal-primary:hover:not(:disabled) {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

.btn-tonal-accent {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-border);
  font-weight: 600;
}

.btn-tonal-accent:hover:not(:disabled) {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: var(--danger-border);
  font-weight: 500;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.09s ease;
}

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

.btn-icon:active {
  transform: scale(0.93);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Dropdowns & Floating Menus
   ========================================================================== */

.dropdown-wrap {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  max-height: 310px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: var(--surface-highlight), var(--shadow-lg);
  z-index: 40;
  transform-origin: top right;
}

.dropdown-menu-left {
  left: 0;
  right: auto;
  transform-origin: top left;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.dropdown-item:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.dropdown-item i.fa-fw {
  color: var(--text-secondary);
  font-size: 12.5px;
  transition: color 0.12s ease;
}

.dropdown-item:hover i.fa-fw {
  color: var(--accent);
}

.dropdown-item-danger {
  color: var(--danger);
}

.dropdown-item-danger i.fa-fw {
  color: var(--danger);
}

.dropdown-item-danger:hover {
  background: var(--danger-dim);
  color: var(--danger);
}

.dropdown-item-danger:hover i.fa-fw {
  color: var(--danger);
}

.dropdown-filter-panel {
  min-width: 260px;
  max-height: none;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.dropdown-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 5px 9px 2px;
}

.dropdown-divider {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: 5px 0;
}

.filter-badge {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  font-weight: 600;
  background: var(--primary);
  color: var(--on-primary);
}

.btn-has-selection {
  border-color: var(--primary-border);
  color: var(--primary);
  background: var(--primary-dim);
}

.row-actions-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.floating-dropdown-menu {
  position: fixed;
  right: auto;
  top: 0;
  left: 0;
  min-width: 205px;
  z-index: 70;
}

/* ==========================================================================
   Global API Bar, Boot Loader & Skeletons
   ========================================================================== */

.global-api-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 95;
  pointer-events: none;
  opacity: 0;
  background: transparent;
}

.global-api-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--grad-telemetry);
  box-shadow: 0 0 10px var(--primary);
}

.app-boot-loader {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-canvas);
}

.boot-loader-card {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  box-shadow: var(--surface-highlight), var(--shadow-lg);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 600;
}

.boot-loader-card i {
  color: var(--primary);
  font-size: 16px;
}

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

.skeleton-line {
  display: block;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--bg-inset) 25%,
    var(--bg-elevated) 50%,
    var(--bg-inset) 75%
  );
  background-size: 200% 100%;
  animation: vraceShimmer 1.35s ease-in-out infinite;
}

.skeleton-line.sk-sm { width: 48px; }
.skeleton-line.sk-md { width: 96px; }
.skeleton-line.sk-lg { width: 150px; }

.skeleton-card {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-inset);
}

.skeleton-thumb {
  width: 60px;
  height: 46px;
  border-radius: 7px;
  flex-shrink: 0;
  background: linear-gradient(
    90deg,
    var(--bg-surface) 25%,
    var(--bg-elevated) 50%,
    var(--bg-surface) 75%
  );
  background-size: 200% 100%;
  animation: vraceShimmer 1.35s ease-in-out infinite;
}

.inline-loader {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

.inline-loader i {
  color: var(--primary);
}

/* ==========================================================================
   Data Tables, Sticky Columns & Empty States
   ========================================================================== */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.table-wrap-accounts {
  max-height: calc(100vh - 335px);
  max-height: calc(100dvh - 335px);
  min-height: 260px;
  overflow: auto;
}

.table-wrap.is-loading tbody {
  opacity: 0.45;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}

.data-table th,
.data-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

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

.data-table th {
  background: var(--bg-inset);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--fs-xs);
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border-default);
  user-select: none;
}

.table-wrap-scroll thead th,
.table-wrap-accounts thead th {
  position: sticky;
  top: 0;
  z-index: 4;
}

/* Sticky Checkbox (left) & Actions (right) on Accounts Table */
#accountsTable th.col-sticky-left,
#accountsTable td.col-sticky-left {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--bg-surface);
}

#accountsTable thead th.col-sticky-left {
  z-index: 6;
  background: var(--bg-inset);
}

#accountsTable th.col-sticky-right,
#accountsTable td.col-sticky-right {
  position: sticky;
  right: 0;
  z-index: 3;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -6px 0 14px rgba(0, 0, 0, 0.12);
}

#accountsTable thead th.col-sticky-right {
  z-index: 6;
  background: var(--bg-inset);
}

.data-table tbody tr {
  transition: background-color 0.12s ease;
}

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

#accountsTable tbody tr:hover td.col-sticky-left,
#accountsTable tbody tr:hover td.col-sticky-right {
  background: var(--bg-surface-hover);
}

.data-table tbody tr.row-selected td {
  background: var(--accent-dim);
}

#accountsTable tbody tr.row-selected td.col-sticky-left,
#accountsTable tbody tr.row-selected td.col-sticky-right {
  background: var(--bg-elevated);
}

.data-table tbody tr.row-selectable {
  cursor: pointer;
}

.avatar-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--primary);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 1px solid transparent;
  line-height: 1.35;
}

.pill-success {
  background: var(--success-dim);
  color: var(--success);
  border-color: var(--success-border);
}

.pill-warning {
  background: var(--warning-dim);
  color: var(--warning);
  border-color: var(--warning-border);
}

.pill-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: var(--danger-border);
}

.pill-accent {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-border);
}

.pill-primary {
  background: var(--primary-dim);
  color: var(--primary);
  border-color: var(--primary-border);
}

.pill-muted {
  background: var(--bg-inset);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.empty-state-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  max-width: 360px;
  white-space: normal;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  gap: 8px;
  flex-wrap: wrap;
}

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

/* ==========================================================================
   Forms & Responsive Multi-Column Grids
   ========================================================================== */

.split-grid {
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.stack-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.connections-grid-2,
.grid-2-equal {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-width: 0;
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field > .input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.field .btn-row .input {
  min-width: 0;
}

.field > span {
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-secondary);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: var(--fs-sm);
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: 4px 0;
}

/* ==========================================================================
   Progress Track (with Active Shimmer) & Live Console Log
   ========================================================================== */

.progress-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.progress-fill {
  position: relative;
  height: 100%;
  background: var(--grad-brand);
  border-radius: inherit;
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.32) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: vraceProgressSweep 1.8s ease-in-out infinite;
}

@keyframes vraceProgressSweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

.log-console {
  height: 250px;
  overflow-y: auto;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.55;
}

.log-line {
  padding: 2.5px 0;
  border-bottom: 1px dashed var(--border-subtle);
  word-break: break-word;
}

.log-info { color: var(--text-secondary); }
.log-success { color: var(--success); }
.log-warning { color: var(--warning); }
.log-error { color: var(--danger); }

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
  transition: border-color 0.15s ease;
}

.activity-item:hover {
  border-color: var(--border-hover);
}

/* ==========================================================================
   Modals, Profile Card & Rich Toasts
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal-card {
  width: 100%;
  max-width: 510px;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--surface-highlight), var(--shadow-lg);
}

.modal-card-lg {
  max-width: 690px;
}

.modal-card-avatar {
  max-width: 560px;
}

.avatar-compare-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 16px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.avatar-drop-zone.is-dragover {
  border-color: var(--primary);
  background: var(--primary-dim);
}

.avatar-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.avatar-slot-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.avatar-slot-meta {
  font-size: 11.5px;
  text-align: center;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-ring {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 2px solid var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.avatar-ring img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-ring-fallback {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-secondary);
}

.avatar-ring-preview {
  cursor: pointer;
  border-style: dashed;
  border-color: var(--border-hover);
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.avatar-ring-preview:hover {
  border-color: var(--primary);
  transform: scale(1.03);
}

.avatar-ring-preview.has-preview {
  border-style: solid;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim), var(--shadow-sm);
}

.avatar-ring-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.avatar-ring-placeholder i {
  font-size: 20px;
  color: var(--primary);
  opacity: 0.85;
}

.avatar-compare-arrow {
  color: var(--primary);
  font-size: 18px;
  opacity: 0.85;
}

.avatar-bulk-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.avatar-bulk-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.avatar-bulk-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.avatar-bulk-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.avatar-bulk-mini {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--border-hover);
  background: var(--bg-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.avatar-bulk-mini-more {
  background: var(--primary-dim);
  border-color: var(--primary-border);
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 11px;
}

.avatar-bulk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.avatar-bulk-empty {
  grid-column: 1 / -1;
  padding: 14px 10px;
  text-align: center;
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-sm);
}

.avatar-bulk-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 7px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  min-width: 0;
}

.avatar-bulk-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--primary-border);
}

.avatar-bulk-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-bulk-idx {
  position: absolute;
  bottom: 0;
  right: 0;
  padding: 0 5px;
  border-radius: 6px;
  background: rgba(9, 12, 16, 0.82);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
}

.avatar-bulk-name {
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vp-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.vp-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
}

.vp-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-dim);
  border: 2px solid var(--primary-border);
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
}

.vp-hero-meta {
  min-width: 0;
  flex: 1;
}

.vp-name {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.vp-sub {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  word-break: break-all;
  margin-top: 2px;
}

.vp-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.vp-alert {
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  background: var(--warning-dim);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.vp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

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

.vp-field {
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  min-width: 0;
}

.vp-field-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-bottom: 2px;
}

.vp-field-value {
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
}

.vp-section {
  border-top: 1px solid var(--border-default);
  padding-top: 10px;
}

.vp-section-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.vp-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}

.vp-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  font-size: var(--fs-sm);
}

.vp-raw-details {
  border-top: 1px solid var(--border-default);
  padding-top: 8px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.vp-raw-details summary {
  cursor: pointer;
  user-select: none;
}

.vp-raw-pre {
  margin-top: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.modal-header h3 {
  font-size: var(--fs-md);
  font-weight: 700;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.hint-text {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

/* Rich Toasts */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
  max-width: min(380px, calc(100vw - 32px));
}

.toast {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  box-shadow: var(--surface-highlight), var(--shadow-lg);
  font-size: var(--fs-sm);
  color: var(--text-primary);
}

.toast-icon {
  font-size: 14px;
  flex-shrink: 0;
  color: var(--accent);
}

.toast-msg {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
  word-break: break-word;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 4px;
}

.toast-close:hover {
  color: var(--text-primary);
  background: var(--bg-inset);
}

.toast-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2.5px;
  width: 100%;
  transform-origin: left center;
  background: var(--accent);
  opacity: 0.85;
}

.toast-success { border-color: var(--success-border); }
.toast-success .toast-icon { color: var(--success); }
.toast-success .toast-progress { background: var(--success); }

.toast-error { border-color: var(--danger-border); }
.toast-error .toast-icon { color: var(--danger); }
.toast-error .toast-progress { background: var(--danger); }

/* ==========================================================================
   Segmented Subtabs (with Sliding Glider) & Master-Detail Entity Cards
   ========================================================================== */

.master-detail-grid {
  display: grid;
  grid-template-columns: 365px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.subtabs {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  margin-bottom: 14px;
}

.subtabs.subtabs-inline {
  margin-bottom: 0;
}

.subtab-glider {
  position: absolute;
  top: 4px;
  left: 0;
  height: calc(100% - 8px);
  border-radius: 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
}

.subtab-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: color 0.16s ease, background-color 0.16s ease;
}

.subtab-btn:hover:not(.active) {
  color: var(--text-primary);
}

.subtab-btn.active {
  color: var(--primary);
  font-weight: 600;
}

/* Fallback if no glider or wrapped multi-line */
.subtabs:not(.has-glider) .subtab-btn.active {
  background: var(--bg-elevated);
  border-color: var(--primary-border);
  box-shadow: var(--shadow-sm);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 620px;
  overflow-y: auto;
  padding-right: 2px;
}

.entity-card {
  display: flex;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-inset);
  cursor: pointer;
  transition:
    transform 0.16s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.16s ease,
    background-color 0.16s ease,
    box-shadow 0.16s ease;
}

.entity-card:hover {
  transform: translateY(-1.5px);
  border-color: var(--border-hover);
  background: var(--bg-surface-hover);
}

.entity-card.active {
  border-color: var(--primary-border);
  background: var(--primary-dim);
  box-shadow: inset 3px 0 0 var(--primary);
}

.entity-thumb {
  width: 62px;
  height: 48px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 15px;
}

.entity-meta {
  flex: 1;
  min-width: 0;
}

.entity-title {
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 650;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entity-sub {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge-free {
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid var(--success-border);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
}

.badge-paid {
  background: var(--warning-dim);
  color: var(--warning);
  border: 1px solid var(--warning-border);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
}

.star-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  padding: 3px 5px;
  border-radius: 6px;
  align-self: flex-start;
  transition: color 0.15s ease, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.star-btn:hover {
  color: var(--warning);
  transform: scale(1.15);
}

.star-btn.starred {
  color: #f59e0b;
}

.inline-url-box {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--accent-border);
  background: var(--bg-inset);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  word-break: break-all;
}

.race-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.race-pill {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

.acc-garmin-job-panel {
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  margin-bottom: 12px;
}

.acc-garmin-job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.email-cell-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.mig-preview-box {
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: var(--fs-sm);
}

.mig-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}

.mig-preview-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-secondary);
}

.mig-preview-item strong {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.cron-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 13px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
}

.cron-status-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1 1 280px;
  min-width: 0;
}

.cron-cooldowns-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.cron-status-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Leaflet Map Dark/Light Polish */
.leaflet-container {
  font-family: var(--font-ui);
}

[data-theme="dark"] .leaflet-tile-pane {
  filter: invert(100%) hue-rotate(180deg) brightness(90%) contrast(92%) saturate(85%);
}

[data-theme="dark"] .leaflet-bar a {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}

[data-theme="dark"] .leaflet-bar a:hover {
  background-color: var(--bg-elevated);
  color: var(--primary);
}

[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(11, 15, 22, 0.78);
  color: var(--text-muted);
}

[data-theme="dark"] .leaflet-control-attribution a {
  color: var(--text-secondary);
}

.gps-marker-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.gps-marker-start {
  background: #10b981;
}

.gps-marker-end {
  background: #f97316;
}

/* Race Detail Hero, Telemetry Tiles, CMS Accordions & Leaderboard Medals */
.race-hero-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  margin-bottom: 4px;
}

.race-hero-top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.race-hero-banner {
  width: 132px;
  height: 82px;
  border-radius: 9px;
  object-fit: cover;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  flex-shrink: 0;
}

.race-hero-meta {
  flex: 1;
  min-width: 0;
}

.race-hero-title {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 6px;
}

.race-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.race-hero-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.race-hero-dates i {
  color: var(--text-muted);
  margin-right: 4px;
}

.race-telemetry-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.race-telemetry-tile {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.race-telemetry-label {
  font-size: 10.5px;
  color: var(--text-muted);
}

.race-telemetry-val {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.race-ranges-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.race-info-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.race-doc-accordion {
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  overflow: hidden;
}

.race-doc-accordion summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 13px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.14s ease;
}

.race-doc-accordion summary::-webkit-details-marker {
  display: none;
}

.race-doc-accordion summary:hover {
  background: var(--bg-surface-hover);
}

.race-doc-accordion summary .acc-chevron {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.race-doc-accordion[open] summary .acc-chevron {
  transform: rotate(180deg);
}

.race-doc-body {
  padding: 10px 14px 13px;
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 240px;
  overflow-y: auto;
  word-break: break-word;
}

.race-doc-body p {
  margin-bottom: 8px;
}

.race-doc-body p:last-child {
  margin-bottom: 0;
}

.race-doc-body ul,
.race-doc-body ol {
  padding-left: 18px;
  margin-bottom: 8px;
}

.race-doc-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 6px 0;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--bg-inset);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.rank-badge.rank-1 {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}

.rank-badge.rank-2 {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.38);
}

.rank-badge.rank-3 {
  background: rgba(249, 115, 22, 0.16);
  color: #fb923c;
  border-color: rgba(249, 115, 22, 0.38);
}

[data-theme="light"] .rank-badge.rank-1 { color: #b45309; }
[data-theme="light"] .rank-badge.rank-2 { color: #475569; }
[data-theme="light"] .rank-badge.rank-3 { color: #c2410c; }

.lb-runner-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lb-runner-clickable {
  cursor: pointer;
  border-radius: 7px;
  padding: 2px 6px 2px 2px;
  margin: -2px -6px -2px -2px;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.lb-runner-clickable:hover {
  background: var(--bg-surface-hover);
}

.lb-runner-clickable:hover .lb-runner-name {
  color: var(--primary);
}

/* ==========================================================================
   User Activity Viewer Modal (#modalUserActivities)
   ========================================================================== */
.modal-card.modal-card-xl {
  width: min(1220px, 95vw);
  max-width: 1220px;
  height: min(88vh, 840px);
  max-height: 92dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 22px;
}

.actv-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  margin-bottom: 0;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border-subtle);
}

.actv-modal-header > .btn-row {
  flex-shrink: 0;
}

.actv-user-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.actv-avatar {
  flex-shrink: 0;
}

.actv-avatar-img,
.actv-avatar-fallback {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-dim);
  color: var(--primary);
  border: 1.5px solid var(--primary-border);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
}

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

.actv-user-meta h3 {
  font-size: 16.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actv-user-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.actv-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.actv-race-filter {
  min-width: 220px;
  max-width: 360px;
  flex: 1 1 240px;
}

.actv-race-filter select {
  width: 100%;
}

.actv-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  flex-shrink: 0;
}

.actv-kpi-card {
  min-width: 0;
  padding: 9px 13px;
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
}

.actv-kpi-label {
  font-size: 11px;
  color: var(--text-muted);
}

.actv-kpi-val {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actv-split-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.92fr) minmax(0, 1.38fr);
  gap: 14px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.actv-list-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  overflow: hidden;
}

.actv-list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.actv-pager {
  flex-shrink: 0;
  margin-top: 0;
  padding: 8px 11px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.actv-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  min-width: 0;
  transition: border-color 0.14s ease, background-color 0.14s ease, transform 0.14s ease;
}

.actv-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-surface-hover);
}

.actv-item.active {
  border-color: var(--primary-border);
  background: var(--primary-dim);
  box-shadow: inset 3px 0 0 var(--primary);
}

.actv-item-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-inset);
  color: var(--primary);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
}

.actv-item.active .actv-item-icon {
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
}

.actv-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.actv-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.actv-item-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.actv-item-dist {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.actv-item-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.actv-item-metrics i {
  color: var(--text-muted);
  margin-right: 3px;
}

.actv-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.actv-item-pills {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.actv-src-pill {
  font-size: 10px;
  padding: 1px 6px;
}

.actv-detail-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 4px 4px 2px;
}

.actv-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.actv-detail-head-meta {
  flex: 1;
  min-width: 0;
}

.actv-detail-head h4 {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 2px;
  word-break: break-word;
}

.actv-map-shell {
  position: relative;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-default);
  background: var(--bg-inset);
}

.actv-leaflet-map {
  height: 250px;
  width: 100%;
  background: var(--bg-inset);
}

.actv-map-overlay {
  position: absolute;
  inset: 0;
  z-index: 450;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  background: rgba(11, 15, 25, 0.72);
  backdrop-filter: blur(3px);
}

[data-theme="light"] .actv-map-overlay {
  background: rgba(248, 250, 252, 0.84);
}

.actv-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  flex-shrink: 0;
}

.actv-metric-tile {
  min-width: 0;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
}

.actv-metric-label {
  font-size: 10.5px;
  color: var(--text-muted);
}

.actv-metric-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
  word-break: break-word;
}

.actv-detail-tabs {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 7px;
}

.actv-detail-tabs .btn.active {
  background: var(--primary-dim);
  color: var(--primary);
  border-color: var(--primary-border);
}

.actv-detail-tab-pane {
  min-height: 70px;
  min-width: 0;
}

.actv-race-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.actv-race-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  min-width: 0;
}

.actv-race-row > .pill {
  flex-shrink: 0;
}

.actv-race-row.actv-race-current {
  border-color: var(--accent-border);
  background: var(--accent-dim);
}

.actv-race-info {
  flex: 1;
  min-width: 0;
}

.actv-race-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
}

.actv-splits-wrap {
  max-height: 220px;
  overflow-y: auto;
  overflow-x: auto;
}

.data-table-compact th,
.data-table-compact td {
  padding: 6px 9px;
  font-size: 12px;
}

.actv-split-pace {
  display: flex;
  align-items: center;
  gap: 8px;
}

.actv-split-bar {
  flex: 1;
  min-width: 54px;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-inset);
  overflow: hidden;
}

.actv-split-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
}

@media (max-width: 960px) {
  .modal-card.modal-card-xl {
    width: 96vw;
    height: auto;
    max-height: 92dvh;
    overflow-y: auto;
    padding: 14px 16px;
  }
  .actv-split-grid {
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .actv-list-scroll {
    max-height: 300px;
  }
  .actv-detail-col {
    overflow: visible;
  }
  .actv-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .actv-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .race-hero-top {
    flex-direction: column;
  }
  .race-hero-banner {
    width: 100%;
    height: 140px;
  }
  .race-telemetry-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.hidden {
  display: none !important;
}

.perm-hidden {
  display: none !important;
}

/* ==========================================================================
   Authentication Pages (/login & /setup), User Menu & RBAC Pills
   ========================================================================== */
.auth-page-body {
  min-height: 100vh;
  margin: 0;
  background-color: var(--bg-canvas);
  background-image: var(--bg-canvas-glow);
  color: var(--text-primary);
  font-family: var(--font-ui);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-shell {
  width: 100%;
  max-width: 440px;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 26px 26px 22px;
  box-shadow: var(--surface-highlight), var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--grad-brand);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-primary);
  flex-shrink: 0;
}

.auth-brand-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-brand-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.auth-heading h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}

.auth-alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  line-height: 1.45;
  border: 1px solid var(--danger-border);
  background: var(--danger-dim);
  color: #fda4af;
}

.auth-alert-info {
  border-color: var(--accent-border);
  background: var(--accent-dim);
  color: var(--accent);
}

.auth-setup-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-dim);
  border: 1px solid var(--primary-border);
  font-size: var(--fs-sm);
}

.auth-setup-banner i {
  color: var(--primary);
  font-size: 16px;
  margin-top: 2px;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 11px;
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

.auth-input {
  width: 100%;
  padding-left: 34px;
  padding-right: 36px;
}

.auth-eye-btn {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}

.auth-eye-btn:hover {
  color: var(--text-primary);
}

.auth-submit-btn {
  width: 100%;
  justify-content: center;
  height: 40px;
  font-size: 14px;
  margin-top: 4px;
}

.auth-footer-note {
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 11.5px;
}

.header-user-wrap {
  position: relative;
}

.header-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.header-user-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#headerUserDropdown {
  right: 0;
  left: auto;
  top: calc(100% + 6px);
  min-width: 215px;
}

.header-user-info-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px 8px;
}

.role-pill-admin {
  background: var(--primary-dim);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  font-weight: 700;
  font-size: 10px;
}

.role-pill-operator {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  font-weight: 700;
  font-size: 10px;
}

.role-pill-viewer {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  font-weight: 700;
  font-size: 10px;
}

.rbac-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rbac-legend-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
}

.rbac-legend-row .pill {
  flex-shrink: 0;
  min-width: 78px;
  justify-content: center;
}

/* ==========================================================================
   Reduced Motion & Responsive Breakpoints
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 1160px) {
  .settings-grid,
  .connections-grid-2,
  .grid-2-equal,
  .split-grid,
  .master-detail-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .top-header {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: nowrap;
    min-height: 52px;
  }
  .brand-wrap {
    min-width: 0;
    flex: 1;
    gap: 8px;
  }
  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }
  .brand-title {
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .brand-sub {
    display: none;
  }
  .header-actions {
    gap: 6px;
    flex-wrap: nowrap;
    flex-shrink: 0;
  }
  .header-btn-label {
    display: none;
  }
  .ws-pill {
    padding: 7px;
    justify-content: center;
  }
  #wsStatusText {
    display: none;
  }
  #btnHeaderTestMail,
  #btnThemeToggle {
    width: 34px;
    height: 34px;
    padding: 0;
  }
  .main-content {
    padding: 12px;
  }
  .search-input-wrap {
    min-width: 0;
    flex: 1 1 170px;
  }
  .search-input-wrap > kbd.kbd-hint {
    display: none;
  }
  .input-search {
    min-width: 0;
    flex: 1 1 160px;
  }
  .table-wrap-accounts {
    max-height: none;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 246px;
    padding: 12px 10px;
    transform: translate3d(-100%, 0, 0);
    visibility: hidden;
    pointer-events: none;
    will-change: transform;
    backface-visibility: hidden;
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open {
    visibility: visible;
    pointer-events: auto;
  }
  html.no-gsap .sidebar.mobile-open {
    transform: translate3d(0, 0, 0);
  }
  .sidebar.collapsed {
    width: 246px;
    padding: 12px 10px;
  }
  .sidebar.collapsed .nav-item {
    justify-content: flex-start;
    padding: 9px 12px;
  }
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-badge,
  .sidebar.collapsed .nav-tag,
  .sidebar.collapsed .nav-group-label,
  .sidebar.collapsed .sidebar-footer {
    display: block;
  }
  .sidebar.collapsed .nav-badge {
    display: inline-block;
  }
  .sidebar-mobile-header {
    display: flex;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .brand-accent {
    display: none;
  }
}
