/* Theme Color Schemes */
    body.theme-purple {
      --primary: #a855f7;
      --on-primary: #ffffff;
      --primary-soft: #7c3aed;
      --primary-bright: #c084fc;
      --primary-dark: #6b21a8;
      --primary-shadow: rgba(168, 85, 247, 0.5);
      --bg: #020617;
      --bg-soft: #0f172a;
      --card: #1e293b;
      --muted: #94a3b8;
      --border: rgba(55, 65, 81, 0.8);
    }
    body.theme-blue {
      --primary: #3b82f6;
      --on-primary: #ffffff;
      --primary-soft: #2563eb;
      --primary-bright: #60a5fa;
      --primary-dark: #1e40af;
      --primary-shadow: rgba(59, 130, 246, 0.5);
      --bg: #020617;
      --bg-soft: #0f172a;
      --card: #1e293b;
      --muted: #94a3b8;
      --border: rgba(55, 65, 81, 0.8);
    }
    body.theme-pink {
      --primary: #ec4899;
      --on-primary: #ffffff;
      --primary-soft: #db2777;
      --primary-bright: #f472b6;
      --primary-dark: #be185d;
      --primary-shadow: rgba(236, 72, 153, 0.5);
      --bg: #020617;
      --bg-soft: #0f172a;
      --card: #1e293b;
      --muted: #94a3b8;
      --border: rgba(55, 65, 81, 0.8);
    }
    body.theme-teal {
      --primary: #14b8a6;
      --on-primary: #ffffff;
      --primary-soft: #0d9488;
      --primary-bright: #2dd4bf;
      --primary-dark: #0f766e;
      --primary-shadow: rgba(20, 184, 166, 0.5);
      --bg: #020617;
      --bg-soft: #0f172a;
      --card: #1e293b;
      --muted: #94a3b8;
      --border: rgba(55, 65, 81, 0.8);
    }
    body.theme-neutral {
      --primary: #64748b;
      --on-primary: #ffffff;
      --primary-soft: #475569;
      --primary-bright: #94a3b8;
      --primary-dark: #334155;
      --primary-shadow: rgba(100, 116, 139, 0.5);
      --bg: #020617;
      --bg-soft: #0f172a;
      --card: #1e293b;
      --muted: #94a3b8;
      --border: rgba(55, 65, 81, 0.8);
    }
    /* Removed color themes: green/red/orange/amber/indigo - only curated presets are supported
       Retained presets: purple, blue, pink, teal, neutral + neutral variants below */
    body.theme-neutral-warm {
      --primary: #6b7280; /* slightly warmer neutral */
      --on-primary: #ffffff;
      --primary-soft: #5b6674;
      --primary-bright: #98a2b3;
      --primary-dark: #444b58;
      --primary-shadow: rgba(107, 114, 128, 0.45);
      --bg: #020617;
      --bg-soft: #0f172a;
      --card: #1e293b;
      --muted: #94a3b8;
      --border: rgba(55, 65, 81, 0.8);
    }
    body.theme-neutral-cool {
      --primary: #55606e; /* slightly cooler neutral */
      --on-primary: #ffffff;
      --primary-soft: #455163;
      --primary-bright: #8696a7;
      --primary-dark: #343f4b;
      --primary-shadow: rgba(85, 96, 110, 0.45);
      --bg: #020617;
      --bg-soft: #0f172a;
      --card: #1e293b;
      --muted: #94a3b8;
      --border: rgba(55, 65, 81, 0.8);
    }
    body.theme-neutral-dark {
      --primary: #475569; /* darker neutral */
      --on-primary: #ffffff;
      --primary-soft: #32405a;
      --primary-bright: #7b8aa1;
      --primary-dark: #1f2b3a;
      --primary-shadow: rgba(71, 85, 105, 0.45);
      --bg: #020617;
      --bg-soft: #0f172a;
      --card: #1e293b;
      --muted: #94a3b8;
      --border: rgba(55, 65, 81, 0.8);
    }
      /* Light-mode field label color removed; base styling now applies */
      .field label {
        color: var(--muted);
        font-weight: 500;
      }

    * { box-sizing: border-box; }
    html, body { 
      min-height: 100%; 
      margin: 0;
    }
    body {
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background: radial-gradient(circle at top left, var(--primary-soft), var(--bg));
      color: #f9fafb;
    }
    .app-shell {
      max-width: 1600px;
      margin: 0 auto;
      padding: 0 12px 32px;
      min-height: 100vh;
    }
    
    /* Comfortable density - wider layout for desktop */
    body.density-comfortable .app-shell {
      max-width: 2000px;
      padding: 0 24px 40px;
    }
    body.density-comfortable .card {
      padding: 18px 20px;
    }
    body.density-comfortable table th,
    body.density-comfortable table td {
      padding: 10px 12px;
    }
    body.density-comfortable .field {
      margin-bottom: 14px;
    }
    
    header {
      position: sticky;
      top: 0;
      z-index: 100;
      width: 100%;
      background: linear-gradient(135deg, var(--primary), var(--primary-bright));
      padding: 12px 0;
      box-shadow: 0 18px 45px var(--primary-shadow);
    }
    
    body.density-comfortable header > div {
      max-width: 2000px;
    }
    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .brand img {
      height: 28px;
      width: auto;
      display: block;
    }
    header h1 {
      margin: 0;
      font-size: 1.2rem;
    }
    header p {
      margin: 2px 0 0;
      font-size: 0.8rem;
      opacity: 0.9;
    }
    .event-meta {
      text-align: right;
      font-size: 0.8rem;
    }
    .badge {
      display: inline-flex;
      align-items: center;
      padding: 3px 10px;
      border-radius: 999px;
      border: 1px solid rgba(248,250,252,0.2);
      background: rgba(15,23,42,0.3);
      font-size: 0.72rem;
      margin-bottom: 3px;
      transition: all 0.3s ease;
    }
    .badge.connected {
      background: rgba(34, 197, 94, 0.2);
      border-color: rgba(34, 197, 94, 0.4);
      color: #86efac;
    }
    .badge.offline {
      background: rgba(239, 68, 68, 0.2);
      border-color: rgba(239, 68, 68, 0.4);
      color: #fca5a5;
    }
    .badge.connecting {
      background: rgba(251, 191, 36, 0.2);
      border-color: rgba(251, 191, 36, 0.4);
      color: #fde047;
    }
    .sync-meta {
      font-size: 0.72rem;
      margin-bottom: 2px;
      opacity: 0.85;
    }

    nav {
      margin-top: 14px;
      display: inline-flex;
      gap: 4px;
      padding: 4px;
      border-radius: 12px;
      background: rgba(15,23,42,0.95);
      box-shadow: 0 12px 32px rgba(15,23,42,0.7);
    }
    nav button {
      border: none;
      background: transparent;
      color: rgba(249,250,251,0.9);
      padding: 7px 14px;
      border-radius: 999px;
      font-size: 0.9rem;
      cursor: pointer;
      white-space: nowrap;
      position: relative;
      z-index: 3; /* Place text above overlay */
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
      -webkit-text-fill-color: currentColor; /* prevent accidental transparent text due to background-clip usage */
      transition: color 0.12s ease, transform 0.12s ease;
    }
    nav button, nav button * { color: inherit !important; mix-blend-mode: normal; }
    nav button.active {
      background: radial-gradient(circle at top left, var(--primary-soft), var(--primary-bright));
      background-color: var(--primary); /* fallback for small gradients or older browsers */
      color: var(--on-primary) !important;
      -webkit-text-fill-color: var(--on-primary) !important;
      -webkit-text-fill-color: #ffffff !important;
      font-weight: 700;
      box-shadow: 0 8px 22px rgba(0,0,0,0.22), 0 0 var(--glow-nav-active), inset 0 1px 0 rgba(255,255,255,0.04);
      padding: 9px 16px;
      border: 1px solid rgba(255,255,255,0.12);
      transform: translateY(-1px);
      z-index: 4;
      text-shadow: 0 1px 2px rgba(0,0,0,0.45);
      -webkit-text-stroke: 0.35px rgba(0,0,0,0.32);
      -webkit-font-smoothing: antialiased;
    }
    /* removed small dot indicator for active tab to keep navbar cleaner */
    nav .nav-separator {
      width: 1px;
      background: rgba(249,250,251,0.2);
      margin: 0 16px;
      align-self: stretch;
    }
    nav .nav-group {
      display: flex;
      flex-direction: column;
      gap: 4px;
      align-items: center;
    }
    nav .nav-group-label {
      font-size: 0.65rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: rgba(249,250,251,0.5);
      font-weight: 600;
      user-select: none;
      text-align: center;
    }
    /* Removed 'body.light-mode' variant: nav group label color inherits from default theme */
    nav .nav-group-buttons {
      display: flex;
      gap: 8px;
      align-items: center;
    }

    main { margin-top: 18px; }
    section[data-tab] { display: none; }
    section[data-tab].active { display: block; }

    .card {
      background: radial-gradient(circle at top left, #111827, #020617);
      border-radius: 12px;
      padding: 14px 14px 16px;
      border: 1px solid var(--border);
      box-shadow: 0 18px 40px rgba(15,23,42,0.9);
      margin-bottom: 14px;
    }

    /* Theme-aware token wallet panel */
    .token-wallet-panel {
      background: linear-gradient(135deg, var(--primary-soft), var(--primary));
      color: var(--on-primary);
      padding: 20px;
      border-radius: 12px;
      display: flex;
      flex-direction: column;
      gap: 16px;
      border: 1px solid rgba(255,255,255,0.06);
      box-shadow: 0 10px 30px var(--primary-shadow);
    }
    .token-wallet-panel .token-title { font-size: 14px; opacity: 0.95; color: var(--on-primary); }
    .token-wallet-panel .token-count { font-size: 42px; font-weight: 800; letter-spacing: 0.02em; color: var(--on-primary); }
    .token-wallet-panel .token-sub { font-size: 13px; opacity: 0.9; color: var(--on-primary); }
    .token-wallet-panel .token-email { font-size: 12px; color: var(--on-primary); opacity: 0.85; }
    .token-wallet-panel .purchase-btn.primary-btn {
      box-shadow: 0 8px 20px rgba(0,0,0,0.18);
      background: var(--on-primary) !important; /* Use light color to contrast with wallet gradient */
      color: var(--primary-dark) !important; /* Text is primary-dark on light background */
      border: none;
    }
    .token-wallet-panel .purchase-btn.primary-btn:hover {
      filter: brightness(0.95);
      transform: translateY(-1px);
    }
    
    /* Compact styling for Live Event tab */
    section[data-tab]:nth-child(3) .card {
      padding: 10px 12px 12px;
      margin-bottom: 10px;
    }
    section[data-tab]:nth-child(3) .card-header {
      margin-bottom: 6px;
    }
    section[data-tab]:nth-child(3) .tag-label {
      margin-top: 8px;
      margin-bottom: 4px;
    }
    section[data-tab]:nth-child(3) .input-row {
      gap: 8px;
      margin-top: 8px;
      margin-bottom: 8px;
    }
    section[data-tab]:nth-child(3) .field {
      margin-bottom: 0;
    }

    /* Compact styling for Event tab (first section) */
    section[data-tab]:first-child .card {
      padding: 10px 12px 12px;
      margin-bottom: 10px;
    }
    section[data-tab]:first-child .card-header {
      margin-bottom: 6px;
      padding: 0.75rem 1rem !important;
    }
    section[data-tab]:first-child .card-body {
      padding: 0.75rem 1rem !important;
    }
    section[data-tab]:first-child .card-title {
      font-size: 0.95rem !important;
    }
    section[data-tab]:first-child .card-subtitle {
      font-size: 0.75rem !important;
    }
    section[data-tab]:first-child .token-count {
      font-size: 3rem !important;
    }
    section[data-tab]:first-child .token-title {
      font-size: 0.75rem !important;
    }
    section[data-tab]:first-child .token-sub {
      font-size: 0.75rem !important;
    }
    section[data-tab]:first-child ul,
    section[data-tab]:first-child li {
      font-size: 0.75rem !important;
      line-height: 1.4 !important;
    }
    section[data-tab]:first-child button {
      padding: 0.5rem 1rem !important;
      font-size: 0.85rem !important;
    }

    /* Event filter buttons styling */
    .event-filter-btn {
      background: transparent !important;
      border: 1px solid var(--border) !important;
      color: var(--text-secondary) !important;
      transition: all 0.2s ease;
    }
    .event-filter-btn:hover {
      background: var(--brand-surface-highlight) !important;
      color: var(--text-primary) !important;
    }
    .event-filter-btn.active {
      background: rgba(59, 130, 246, 0.15) !important;
      border-color: rgba(59, 130, 246, 0.4) !important;
      color: var(--accent-blue) !important;
    }

    .card-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 8px;
    }
    .card-title {
      font-size: 1rem;
      font-weight: 700;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--text-primary);
      line-height: 1.1;
    }
    .card-subtitle {
      font-size: 0.86rem;
      color: var(--text-secondary);
      margin-top: 4px;
    }
    .helper-text { font-size: 0.85rem; color: var(--muted); }

    .lineup-grid,
    .results-grid,
    .live-grid {
      display: grid;
      grid-template-columns: minmax(0,1fr) minmax(0,1fr);
      gap: 12px;
    }
    .live-grid {
      grid-template-columns: minmax(0,1.6fr) minmax(0,1.2fr);
    }

    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.8rem;
    }
    th, td {
      padding: 5px 6px;
      border-top: 1px solid rgba(31,41,55,0.9);
      text-align: left;
      white-space: nowrap;
    }
    thead th {
      border-top: none;
      color: var(--muted);
      font-size: 0.75rem;
    }
    
    tbody tr.dq {
      color: #f97373;
    }

    /* Allow wrapping inside Live Event leaderboard so text stays inside the card */
    .live-grid table th,
    .live-grid table td {
      white-space: normal;
    }

    .lineup-select {
      width: 100%;
      padding: 4px 6px;
      border-radius: 8px;
      border: 1px solid rgba(55,65,81,0.9);
      background: rgba(15,23,42,0.9);
      color: #e5e7eb;
      font-size: 0.8rem;
    }

    .tag-label {
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.12em;
      color: var(--muted);
      margin: 10px 0 4px;
    }

    .class-pill-row {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }
    .class-pill {
      padding: 3px 8px;
      border-radius: 999px;
      border: 1px solid rgba(55,65,81,0.9);
      background: rgba(15,23,42,0.95);
      font-size: 0.72rem;
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }
    .class-pill span.dot {
      width: 7px;
      height: 7px;
      border-radius: 999px;
      background: rgba(148,163,184,0.9);
    }
    .class-pill.completed {
      background: #16a34a;
      border-color: #16a34a;
      color: #ecfdf5;
    }
    .class-pill.completed span.dot { background: #bbf7d0; }
    .class-pill.active {
      background: linear-gradient(135deg, var(--primary), var(--primary-bright));
      border-color: rgba(219,234,254,0.9);
      animation: pillPulse 2s ease-in-out infinite;
    }
    
    /* When a completed class is also active, keep the green but add pulse */
    .class-pill.completed.active {
      background: #16a34a;
      border-color: #16a34a;
      color: #ecfdf5;
      animation: pillPulseGreen 2s ease-in-out infinite;
    }
    
    @keyframes pillPulse {
      0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.7); }
      50% { box-shadow: 0 0 0 4px rgba(168, 85, 247, 0); }
    }
    
    @keyframes pillPulseGreen {
      0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
      50% { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0); }
    }

    .status-row {
      display: grid;
      grid-template-columns: repeat(3,minmax(0,1fr));
      gap: 8px;
      margin-top: 8px;
      margin-bottom: 8px;
      font-size: 0.76rem;
    }
    .status-chip {
      border-radius: 10px;
      border: 1px solid rgba(55,65,81,0.9);
      padding: 4px 8px;
      background: rgba(15,23,42,0.95);
    }
    .status-main {
      font-weight: 600;
      font-size: 0.84rem;
    }
    .status-sub {
      color: var(--muted);
      font-size: 0.72rem;
    }

    .lineup-rail {
      display: flex;
      gap: 8px;
      margin-top: 6px;
      margin-bottom: 8px;
      overflow-x: auto;
      max-height: 120px;
      padding-bottom: 2px;
    }
    .chip-card {
      min-width: 150px;
      border-radius: 12px;
      border: 1px solid rgba(55,65,81,0.9);
      background: rgba(15,23,42,0.96);
      padding: 6px 8px;
      font-size: 0.76rem;
    }
    .chip-card .truck { font-weight: 600; }
    .chip-card .meta { color: var(--muted); font-size: 0.7rem; }
    
    /* Color-coded status: gray=upcoming, blue=current, green=complete */
    .chip-card { 
      background: rgba(55,65,81,0.5); /* Gray for upcoming */
      border: 1px solid rgba(75,85,99,0.7);
    }
    
    .chip-card.current { 
      /* background: rgba(59,130,246,0.2); REMOVED: Don't override background color */
      border: 2px solid #3b82f6 !important;
      box-shadow: 0 0 12px rgba(59,130,246,0.4) !important;
      animation: chipPulse 2s ease-in-out infinite;
    }
    
    @keyframes chipPulse {
      0%, 100% { box-shadow: 0 0 12px rgba(59,130,246,0.4); }
      50% { box-shadow: 0 0 20px rgba(59,130,246,0.7), 0 0 0 4px rgba(59,130,246,0.2); }
    }
    
    .chip-card.pulled { 
      background: rgba(34,197,94,0.2); /* Green for complete */
      border: 1px solid rgba(34,197,94,0.5);
      opacity: 0.5;
    }
    
    .chip-card.dq {
      background: rgba(239,68,68,0.2); /* Red for DQ */
      border: 1px solid rgba(239,68,68,0.5);
      opacity: 0.5;
    }
    
    /* DQ truck that is current - keep red but add pulse */
    .chip-card.dq.current {
      background: rgba(239,68,68,0.2);
      border: 2px solid #ef4444;
      opacity: 1;
      animation: chipPulseDQ 2s ease-in-out infinite;
    }
    
    @keyframes chipPulseDQ {
      0%, 100% { box-shadow: 0 0 12px rgba(239,68,68,0.4); }
      50% { box-shadow: 0 0 20px rgba(239,68,68,0.7), 0 0 0 4px rgba(239,68,68,0.2); }
    }

    .input-row {
      display: grid;
      grid-template-columns: minmax(0,1.5fr) repeat(2,minmax(0,1fr));
      gap: 8px;
      margin-top: 10px;
      font-size: 0.78rem;
    }
    .field { display: flex; flex-direction: column; gap: 3px; }
    .field label { color: var(--muted); font-size: 0.74rem; }
    .field input {
      padding: 6px 8px;
      border-radius: 9px;
      border: 1px solid rgba(55,65,81,0.9);
      background: rgba(15,23,42,0.96);
      color: #e5e7eb;
      font-size: 0.82rem;
    }
    .field input[readonly] { border-style: dashed; color: var(--muted); }
    
    select {
      background: rgba(15,23,42,0.96) !important;
      color: #e5e7eb !important;
    }
    select option {
      background: rgba(15,23,42,0.96) !important;
      color: #e5e7eb !important;
    }

    .flags-row {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin-top: 6px;
      margin-bottom: 8px;
      font-size: 0.76rem;
    }
    .flag-chip {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 3px 8px;
      border-radius: 999px;
      border: 1px solid rgba(55,65,81,0.9);
      background: rgba(15,23,42,0.96);
    }

    .primary-btn {
      margin-top: 12px;
      width: 100%;
      border-radius: 10px;
      border: none;
      padding: 8px 10px;
      font-size: 0.86rem;
      font-weight: 600;
      background: linear-gradient(135deg, #22c55e, #16a34a);
      color: #022c22;
      cursor: pointer;
      box-shadow: var(--glow-primary);
    }
    
    .secondary-btn {
      border-radius: 10px;
      border: 1px solid rgba(55, 65, 81, 0.9);
      padding: 8px 10px;
      font-size: 0.86rem;
      font-weight: 600;
      background: rgba(55, 65, 81, 0.5);
      color: #e5e7eb;
      cursor: pointer;
      transition: all 0.2s;
    }
    
    .secondary-btn:hover {
      background: rgba(55, 65, 81, 0.8);
      border-color: rgba(75, 85, 99, 1);
    }

    .timer-row {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      font-size: 0.76rem;
      color: var(--muted);
      margin-top: 2px;
      margin-bottom: 2px;
    }
    .timer-chip {
      padding: 3px 6px;
      border-radius: 999px;
      border: 1px dashed rgba(148,163,184,0.7);
      font-variant-numeric: tabular-nums;
    }

    .talk-list {
      margin: 6px 0 0;
      padding-left: 18px;
      font-size: 0.78rem;
      color: var(--muted);
      max-height: 100px;
      overflow-y: auto;
    }
    .talk-list strong { color: #e5e7eb; }

    .export-links {
      margin-top: 6px;
      font-size: 0.78rem;
      color: var(--muted);
    }
    .export-links a {
      color: var(--primary-bright);
      text-decoration: underline;
      cursor: pointer;
    }
    .export-links span { margin: 0 5px; }

    .settings-toggle {
      width: 100%;
      border-radius: 12px;
      padding: 8px 11px;
      background: linear-gradient(135deg, var(--primary-soft), var(--primary-bright));
      border: 1px solid rgba(248,250,252,0.16);
      display: flex;
      align-items: center;
      justify-content: space-between;
      cursor: pointer;
      font-size: 0.8rem;
      color: #f9fafb;
      box-shadow: var(--glow-accent);
    }
    .settings-toggle small {
      text-transform: uppercase;
      letter-spacing: 0.12em;
      color: rgba(249,250,251,0.85);
      font-size: 0.7rem;
    }
    .settings-panel { margin-top: 8px; }
    .settings-panel.collapsed { display: none; }

    .theme-row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 6px;
    }
    .theme-chip {
      padding: 5px 9px;
      border-radius: 999px;
      border: 1px solid rgba(55,65,81,0.9);
      font-size: 0.78rem;
      cursor: pointer;
      background: rgba(15,23,42,0.96);
      color: #e5e7eb;
      transition: box-shadow 0.15s ease, transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
    }
    .theme-chip:hover {
      transform: translateY(-1px);
      box-shadow: 0 8px 18px rgba(15,23,42,0.9);
    }

    /* Per-theme preview styling */
    .theme-chip[data-theme="theme-purple"] {
      background: linear-gradient(135deg, #3b0764, #a855f7);
      border-color: rgba(216,180,254,0.9);
      color: #fdf4ff;
    }
    .theme-chip[data-theme="theme-blue"] {
      background: linear-gradient(135deg, #1d4ed8, #60a5fa);
      border-color: rgba(191,219,254,0.95);
      color: #eff6ff;
    }
    /* Removed green/red/orange theme chips */
    .theme-chip[data-theme="theme-pink"] {
      background: linear-gradient(135deg, #be185d, #f472b6);
      border-color: rgba(251,207,232,0.9);
      color: #fdf2f8;
    }
    .theme-chip[data-theme="theme-teal"] {
      background: linear-gradient(135deg, #0f766e, #5eead4);
      border-color: rgba(153,246,228,0.9);
      color: #f0fdfa;
    }
    .theme-chip[data-theme="theme-neutral"] {
      background: linear-gradient(135deg, #111827, #4b5563);
      border-color: rgba(148,163,184,0.9);
      color: #e5e7eb;
    }
    .theme-chip[data-theme="theme-neutral-warm"] {
      background: linear-gradient(135deg, #0f172a, #414a55);
      border-color: rgba(148,160,178,0.9);
      color: #dce3ea;
    }
    .theme-chip[data-theme="theme-neutral-cool"] {
      background: linear-gradient(135deg, #0b1626, #2f3b4a);
      border-color: rgba(118,132,150,0.9);
      color: #d9e2ea;
    }
    .theme-chip[data-theme="theme-neutral-dark"] {
      background: linear-gradient(135deg, #070b12, #26313e);
      border-color: rgba(84,98,112,0.9);
      color: #cfd8df;
    }

    .theme-chip.active {
      box-shadow: 0 0 0 1px #f9fafb, 0 10px 24px var(--primary-shadow);
    }

    /* Edit Modal Styles */
    .modal-overlay {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.7);
      z-index: 99999;
      align-items: center;
      justify-content: center;
    }
    .modal-overlay.active {
      display: flex;
    }

    .modal {
      background: var(--card);
      border-radius: 16px;
      padding: 32px;
      max-width: 800px;
      width: 95%;
      max-height: 92vh;
      overflow-y: auto;
      box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
      border: 1px solid rgba(55, 65, 81, 0.9);
    }

    .modal-header {
      margin-bottom: 20px;
    }

    .modal-header h2 {
      margin: 0;
      font-size: 1.3rem;
      color: #f9fafb;
    }

    .modal-header p {
      margin: 4px 0 0;
      font-size: 0.85rem;
      color: var(--muted);
    }

    .modal-content {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .modal-footer {
      display: flex;
      gap: 10px;
      margin-top: 20px;
    }

    .modal-actions {
      display: flex;
      gap: 10px;
      margin-top: 20px;
    }

    .modal-btn {
      flex: 1;
      padding: 10px 12px;
      border: none;
      border-radius: 10px;
      font-size: 0.86rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.15s ease;
    }

    .modal-btn.save {
      background: linear-gradient(135deg, #3b82f6, #2563eb);
      color: #ffffff;
      box-shadow: var(--glow-primary);
    }

    .modal-btn.save:hover {
      transform: translateY(-2px);
      box-shadow: var(--glow-primary-hover);
    }

    .modal-btn.cancel {
      background: rgba(55, 65, 81, 0.9);
      color: #e5e7eb;
      border: 1px solid rgba(55, 65, 81, 0.9);
    }

    .modal-btn.cancel:hover {
      background: rgba(75, 85, 99, 0.9);
    }

    .modal-btn.cancel.active {
      background: var(--primary);
      color: #ffffff;
      border: 1px solid var(--primary);
      box-shadow: var(--glow-primary);
    }

    .modal-btn.save.active {
      box-shadow: var(--glow-primary-hover);
      transform: translateY(-2px);
    }

    .modal-btn.delete {
      background: linear-gradient(135deg, #dc2626, #991b1b);
      color: #ffffff;
      box-shadow: var(--glow-danger);
    }

    .modal-btn.delete:hover {
      transform: translateY(-2px);
      box-shadow: var(--glow-danger-hover);
    }

    /* Glow intensity classes */
    body.glow-off {
      --glow-primary: none;
      --glow-primary-hover: none;
      --glow-danger: none;
      --glow-danger-hover: none;
      --glow-accent: none;
      --glow-nav-active: none;
    }
    body.glow-mid {
      --glow-primary: 0 12px 30px rgba(22,163,74,0.7);
      --glow-primary-hover: 0 16px 40px rgba(22,163,74,0.8);
      --glow-danger: 0 12px 30px rgba(220, 38, 38, 0.7);
      --glow-danger-hover: 0 16px 40px rgba(220, 38, 38, 0.8);
      --glow-accent: 0 10px 26px var(--primary-shadow);
      --glow-nav-active: 0 10px 28px var(--primary-shadow);
    }
    body.glow-high {
      --glow-primary: 0 18px 46px rgba(22,163,74,0.95);
      --glow-primary-hover: 0 24px 60px rgba(22,163,74,1);
      --glow-danger: 0 18px 46px rgba(220, 38, 38, 0.95);
      --glow-danger-hover: 0 24px 60px rgba(220, 38, 38, 1);
      --glow-accent: 0 16px 42px var(--primary-shadow);
      --glow-nav-active: 0 16px 44px var(--primary-shadow);
    }

    /* Detail rows styling */
    .detail-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10px 0;
      border-bottom: 1px solid rgba(55, 65, 81, 0.6);
    }

    .detail-row:last-child {
      border-bottom: none;
    }

    .detail-row label {
      font-weight: 600;
      color: var(--muted);
      font-size: 0.85rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
    }

    .detail-value {
      color: #f9fafb;
      font-size: 0.9rem;
      text-align: right;
      flex: 1;
      margin-left: 12px;
    }

    /* Detail display mode - read-only fields */
    .detail-display {
      background: rgba(15, 23, 42, 0.6) !important;
      border: 1px dashed rgba(55, 65, 81, 0.7) !important;
      color: var(--muted) !important;
      cursor: not-allowed !important;
    }

    .detail-display:disabled {
      opacity: 0.8;
    }

    /* Detail edit mode - editable fields */
    .detail-edit {
      background: rgba(15, 23, 42, 0.96) !important;
      border: 1px solid rgba(55, 65, 81, 0.9) !important;
      color: #e5e7eb !important;
      cursor: text !important;
    }

    .detail-edit:disabled {
      opacity: 1;
    }

    /* Clickable row styling */
    table tbody tr {
      cursor: pointer;
      transition: background-color 0.15s ease;
    }

    table tbody tr:hover {
      background-color: rgba(168, 85, 247, 0.2);
    }

    @media (max-width: 900px) {
      header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
      }
      .event-meta { text-align: left; }
      .lineup-grid,
      .results-grid,
      .live-grid {
        grid-template-columns: minmax(0,1fr);
      }
    }

    /* Live Event Specific Styles */
    .tag-label {
      font-size: 0.75rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      color: rgba(249,250,251,0.6);
      margin: 16px 0 8px;
    }

    .class-pill-row {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-bottom: 20px;
    }

    .class-pill {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 8px 16px;
      background: rgba(15,23,42,0.7);
      border: 1px solid rgba(55,65,81,0.9);
      border-radius: 20px;
      font-size: 0.85rem;
      font-weight: 500;
      color: rgba(249,250,251,0.7);
    }

    .class-pill .dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: rgba(148,163,184,0.5);
    }

    .class-pill.completed {
      background: rgba(34,197,94,0.15);
      border-color: #22c55e;
      color: #22c55e;
    }

    .class-pill.completed .dot {
      background: #22c55e;
    }

    .class-pill.active {
      background: linear-gradient(135deg, var(--primary), var(--primary-dark));
      border-color: var(--primary);
      color: #fff;
      font-weight: 600;
      animation: pillPulse 2s ease-in-out infinite;
    }

    .class-pill.active .dot {
      background: #fff;
      box-shadow: 0 0 8px rgba(255,255,255,0.5);
    }
    
    /* When a completed class is also active, keep the green but add pulse */
    .class-pill.completed.active {
      background: rgba(34,197,94,0.15);
      border-color: #22c55e;
      color: #22c55e;
      animation: pillPulseGreen 2s ease-in-out infinite;
    }
    
    .class-pill.completed.active .dot {
      background: #22c55e;
    }
    
    @keyframes pillPulse {
      0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.7); }
      50% { box-shadow: 0 0 0 6px rgba(168, 85, 247, 0); }
    }
    
    @keyframes pillPulseGreen {
      0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
      50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    }

    .status-row {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 12px;
      margin: 20px 0;
    }

    .status-chip {
      background: rgba(15,23,42,0.5);
      border: 1px solid rgba(55,65,81,0.9);
      border-radius: 12px;
      padding: 16px;
      transition: all 0.2s ease;
    }

    .status-chip:hover {
      transform: translateY(-2px);
      border-color: var(--primary);
      box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }

    .status-chip .card-subtitle {
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      color: rgba(249,250,251,0.5);
      margin-bottom: 8px;
    }

    .status-chip .status-main {
      font-size: 1.1rem;
      font-weight: 700;
      color: rgba(249,250,251,0.95);
      margin-bottom: 4px;
    }

    .status-chip .status-sub {
      font-size: 0.8rem;
      color: rgba(249,250,251,0.6);
    }

    .status-chip:first-child {
      background: linear-gradient(135deg, var(--primary), var(--primary-dark));
      border-color: var(--primary);
    }

    .status-chip:first-child .card-subtitle,
    .status-chip:first-child .status-main,
    .status-chip:first-child .status-sub {
      color: #fff;
    }

    .lineup-rail {
      display: flex;
      gap: 12px;
      overflow-x: auto;
      padding: 12px 0;
      margin-bottom: 20px;
    }

    .chip-card {
      min-width: 200px;
      background: rgba(15,23,42,0.5);
      border: 1px solid rgba(55,65,81,0.9);
      border-radius: 12px;
      padding: 10px 14px;
      user-select: none;
    }

    .chip-card:hover {
      border-color: var(--primary);
      box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }

    .chip-card .meta {
      font-size: 0.7rem;
      color: rgba(249,250,251,0.5);
      margin-bottom: 4px;
    }

    .chip-card .truck {
      font-size: 0.95rem;
      font-weight: 700;
      color: rgba(249,250,251,0.95);
      margin-bottom: 4px;
    }

    .chip-card.pulled {
      background: rgba(34,197,94,0.2); /* Green for complete */
      border: 1px solid rgba(34,197,94,0.5);
      opacity: 0.5;
    }
    
    .chip-card.dq {
      background: rgba(239,68,68,0.2); /* Red for DQ */
      border: 1px solid rgba(239,68,68,0.5);
      opacity: 0.5;
    }
    
    .chip-card.dq .truck {
      color: #f87171;
    }
    
    /* DQ truck that is current - keep red but add pulse */
    .chip-card.dq.current {
      background: rgba(239,68,68,0.2);
      border: 2px solid #ef4444;
      opacity: 1;
      animation: chipPulseDQ 2s ease-in-out infinite;
    }
    
    .chip-card.dq.current .truck {
      color: #ef4444;
      font-weight: 700;
    }
    
    @keyframes chipPulseDQ {
      0%, 100% { box-shadow: 0 0 12px rgba(239,68,68,0.4); }
      50% { box-shadow: 0 0 20px rgba(239,68,68,0.7), 0 0 0 6px rgba(239,68,68,0.2); }
    }

    .chip-card.current {
      /* background: rgba(59,130,246,0.2); Blue for current - REMOVED */
      border: 2px solid #3b82f6;
      box-shadow: 0 0 12px rgba(59,130,246,0.4);
      animation: chipPulse 2s ease-in-out infinite;
    }

    .chip-card.current .truck {
      color: #60a5fa;
      font-weight: 700;
    }
    
    @keyframes chipPulse {
      0%, 100% { box-shadow: 0 0 12px rgba(59,130,246,0.4); }
      50% { box-shadow: 0 0 20px rgba(59,130,246,0.7), 0 0 0 6px rgba(59,130,246,0.2); }
    }

    .input-row {
      display: grid;
      grid-template-columns: 2fr 1fr 1fr;
      gap: 16px;
      margin-bottom: 16px;
    }

    .flags-row {
      display: flex;
      gap: 12px;
      flex-wrap: wrap;
      margin-bottom: 16px;
    }

    .flag-chip {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 8px 14px;
      background: rgba(15,23,42,0.5);
      border: 1px solid rgba(55,65,81,0.9);
      border-radius: 8px;
      font-size: 0.85rem;
      color: rgba(249,250,251,0.8);
      cursor: pointer;
      transition: all 0.2s;
    }

    .flag-chip:hover {
      background: rgba(15,23,42,0.8);
      border-color: var(--primary);
    }

    .flag-chip input[type="checkbox"] {
      margin: 0;
      cursor: pointer;
    }

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

    table tr.dq {
      opacity: 0.5;
      text-decoration: line-through;
    }

    @media (max-width: 768px) {
      .input-row {
        grid-template-columns: 1fr;
      }
      .status-row {
        grid-template-columns: 1fr;
      }
      .live-grid {
        grid-template-columns: 1fr;
      }
    }

    /* Footer */
    footer {
      background: rgba(15,23,42,0.95);
      border-top: 1px solid rgba(55,65,81,0.5);
      padding: 20px;
      text-align: center;
      font-size: 0.85rem;
      color: rgba(249,250,251,0.6);
      margin-top: auto;
    }

    footer .footer-brand {
      font-size: 1rem;
      font-weight: 700;
      color: rgba(249,250,251,0.95);
      margin-bottom: 8px;
      letter-spacing: 0.5px;
    }

    footer .footer-powered {
      font-size: 0.8rem;
      color: rgba(249,250,251,0.5);
      margin-top: 4px;
    }

    footer .footer-powered a {
      color: var(--primary-bright);
      text-decoration: none;
      font-weight: 600;
      transition: color 0.2s ease;
    }

    footer .footer-powered a:hover {
      color: var(--primary);
      text-decoration: underline;
    }

    footer .footer-links {
      margin-top: 12px;
      display: flex;
      justify-content: center;
      gap: 16px;
      flex-wrap: wrap;
      font-size: 0.75rem;
    }

    footer .footer-links a {
      color: rgba(249,250,251,0.5);
      text-decoration: none;
      transition: color 0.2s ease;
    }

    footer .footer-links a:hover {
      color: var(--primary-bright);
    }

    /* Loading Screen */
    #loading-screen {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(135deg, #020617 0%, #0f172a 50%, #1e293b 100%);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      z-index: 9999;
      opacity: 1;
      transition: opacity 1.5s ease-out;
    }

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

    .loading-logo {
      width: 300px;
      height: 300px;
      margin-bottom: 30px;
      animation: pulse 2s ease-in-out infinite;
    }

    .loading-logo img {
      width: 100%;
      height: 100%;
      object-fit: contain;
      filter: drop-shadow(0 0 20px rgba(103, 126, 234, 0.5));
    }

    .loading-title {
      font-size: 2rem;
      font-weight: 700;
      color: #f9fafb;
      margin-bottom: 10px;
      letter-spacing: 1px;
    }

    .loading-subtitle {
      font-size: 1rem;
      color: rgba(249, 250, 251, 0.6);
      margin-bottom: 40px;
    }

    .loading-spinner {
      width: 50px;
      height: 50px;
      border: 4px solid rgba(103, 126, 234, 0.2);
      border-top-color: #667eea;
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }

    .loading-status {
      margin-top: 20px;
      font-size: 0.9rem;
      color: rgba(249, 250, 251, 0.5);
      font-style: italic;
    }

    @keyframes pulse {
      0%, 100% {
        transform: scale(1);
        opacity: 1;
      }
      50% {
        transform: scale(1.05);
        opacity: 0.8;
      }
    }

    @keyframes spin {
      0% {
        transform: rotate(0deg);
      }
      100% {
        transform: rotate(360deg);
      }
    }

    /* DOS Mode Easter Egg Styles */
    body.dos-mode {
      background: #000000 !important;
      font-family: 'Courier New', monospace !important;
    }
    
    body.dos-mode * {
      font-family: 'Courier New', monospace !important;
      color: #00FF00 !important;
      background: #000000 !important;
      border-color: #00FF00 !important;
      text-shadow: 0 0 5px #00FF00 !important;
      box-shadow: none !important;
    }
    
    body.dos-mode .app-container {
      background: #000000 !important;
      border: 2px solid #00FF00 !important;
    }
    
    body.dos-mode button,
    body.dos-mode .primary-btn,
    body.dos-mode .modal-btn {
      background: #000000 !important;
      border: 1px solid #00FF00 !important;
      color: #00FF00 !important;
      box-shadow: none !important;
    }
    
    body.dos-mode button:hover,
    body.dos-mode .primary-btn:hover {
      background: #00FF00 !important;
      color: #000000 !important;
      box-shadow: none !important;
    }
    
    @keyframes blink {
      0%, 49% { opacity: 1; }
      50%, 100% { opacity: 0; }
    }
    
    .dos-cursor {
      animation: blink 1s infinite;
    }
    
    /* Full Pull Celebration Animations */
    @keyframes celebrationBounce {
      0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0;
      }
      50% {
        transform: translate(-50%, -50%) scale(1.1);
      }
      100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
      }
    }
    
    @keyframes celebrationFadeOut {
      from {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
      }
      to {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
      }
    }
    
    @keyframes confettiFall {
      0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
      }
      100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
      }
    }
    
    @keyframes fadeOut {
      from { opacity: 1; }
      to { opacity: 0; }
    }
    
    @keyframes todayPulse {
      0%, 100% {
        box-shadow: 0 0 24px rgba(34,197,94,0.4);
        border-color: #22c55e;
      }
      50% {
        box-shadow: 0 0 32px rgba(34,197,94,0.7), 0 0 48px rgba(34,197,94,0.3);
        border-color: #16a34a;
      }
    }
    
    /* Login Screen Overlay */
    #login-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 10000;
      opacity: 1;
      transition: opacity 0.5s ease;
    }
    
    #login-overlay.hidden {
      opacity: 0;
      pointer-events: none;
    }
    
    .login-container {
      text-align: center;
      padding: 48px;
      background: rgba(255,255,255,0.03);
      border-radius: 24px;
      border: 1px solid rgba(255,255,255,0.1);
      backdrop-filter: blur(10px);
      max-width: 500px;
    }
    
    .login-logo {
      width: 180px;
      height: 180px;
      margin: 0 auto 24px;
      animation: pulse 2s ease-in-out infinite;
    }
    
    .login-logo img {
      width: 100%;
      height: 100%;
      object-fit: contain;
      filter: drop-shadow(0 0 20px rgba(139,92,246,0.5));
    }
    
    .login-title {
      font-size: 32px;
      font-weight: 900;
      margin-bottom: 8px;
      background: linear-gradient(135deg, var(--primary-bright), var(--primary));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }
    
    .login-subtitle {
      font-size: 16px;
      color: rgba(249,250,251,0.6);
      margin-bottom: 40px;
    }
    
    .login-message {
      font-size: 14px;
      color: rgba(249,250,251,0.7);
      margin-bottom: 32px;
      line-height: 1.6;
    }
    
    #login-google-btn {
      background: white;
      color: #1f2937;
      padding: 14px 32px;
      border-radius: 12px;
      border: none;
      font-size: 16px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s;
      display: inline-flex;
      align-items: center;
      gap: 12px;
      box-shadow: 0 4px 16px rgba(255,255,255,0.2);
    }
    
    #login-google-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 24px rgba(255,255,255,0.3);
    }
    
    #login-google-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
      transform: none;
    }
    
    .login-footer {
      margin-top: 32px;
      font-size: 12px;
      color: rgba(249,250,251,0.4);
    }
    
    /* Header Auth Buttons */
    #authorize-google-btn:hover:not(:disabled) {
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(255,255,255,0.25);
    }
    
    #signout-google-btn:hover:not(:disabled) {
      background: rgba(239, 68, 68, 0.2);
      border-color: rgba(239, 68, 68, 0.5);
      transform: translateY(-1px);
    }
    
    #authorize-google-btn:disabled,
    #signout-google-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }
    
    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }
    
    @keyframes slideInRight {
      from {
        transform: translateX(400px);
        opacity: 0;
      }
      to {
        transform: translateX(0);
        opacity: 1;
      }
    }
    
    @keyframes slideOutRight {
      from {
        transform: translateX(0);
        opacity: 1;
      }
      to {
        transform: translateX(400px);
        opacity: 0;
      }
    }
    
    @keyframes spin {
      from {
        transform: rotate(0deg);
      }
      to {
        transform: rotate(360deg);
      }
    }

    /* ========================================
       🎨 MODERN DESIGN SYSTEM - v0.7.0
       Tier-1 Professional UI Enhancement
       ======================================== */

    /* Light mode support has been removed; all colors are now handled by preset themes */

    /* All 'body.light-mode' selectors removed; app enforces dark theme by default and theme presets handle color contrasts */

    /* Badge connected uses the default dark-mode .badge.connected styling above */

    /* Badges offline/connecting use default dark-mode .badge.offline/.badge.connecting styles */

    /* Light mode specific chip, select, and typography rules have been removed to enforce a dark-only default
       Base styles apply in the default theme, and contrast adjustments are handled per-theme variables. */

    .field label {
      color: var(--muted);
      font-weight: 500;
    }
    .field label.required { color: var(--text-primary); font-weight: 700; }

    /* Light mode footer overrides removed; default footer styling applies */

    /* ========================================
       🧭 Buttons, Inputs, Tables, Modals
       ======================================== */
    :root {
      --radius-sm: 8px;
      --radius-md: 12px;
      --btn-padding-y: 10px;
      --btn-padding-x: 14px;
      --input-padding: 10px 12px;
      --table-border: 1px solid var(--border);
    }

    /* Button base */
    .btn, .primary-btn, .modal-btn {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: var(--btn-padding-y) var(--btn-padding-x);
      border-radius: var(--radius-md);
      font-weight: 700;
      font-size: 0.95rem;
      line-height: 1;
      border: 1px solid transparent;
      cursor: pointer;
      transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
      user-select: none;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }

    /* Primary action */
    .primary-btn {
      background: linear-gradient(135deg, var(--primary), var(--primary-soft));
      color: #ffffff !important;
      border-color: rgba(0,0,0,0.06);
      box-shadow: 0 8px 22px rgba(16,24,40,0.18);
    }
    .primary-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(16,24,40,0.2); }
    .primary-btn:active { transform: translateY(0); box-shadow: 0 8px 20px rgba(16,24,40,0.16); }
    .primary-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

    /* Secondary / Raw action */
    .modal-btn, .modal-btn.cancel { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
    .modal-btn.save { background: linear-gradient(135deg, var(--primary), var(--primary-soft)); color: #fff; border: 1px solid rgba(0,0,0,0.06); }
    .modal-btn.delete { background: linear-gradient(135deg, rgba(220,38,38,0.95), rgba(185,28,28,0.95)); color: #fff; border: 1px solid rgba(0,0,0,0.06); }

    /* Inputs */
    input:not([type=color]), textarea, select {
      padding: var(--input-padding);
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: var(--card);
      color: var(--text-primary);
      transition: all 0.16s ease;
    }
    input:not([type=color]):focus, textarea:focus, select:focus {
      border-color: var(--primary);
      box-shadow: 0 6px 18px rgba(var(--primary-shadow), 0.12);
      outline: none;
    }
    ::placeholder { color: var(--muted); }

    /* Tables */
    table { width: 100%; border-collapse: collapse; border-spacing: 0; }
    table thead th {
      position: sticky; top: 0; z-index: 2;
      text-align: left; font-weight: 700; padding: 10px 12px; font-size: 0.9rem;
      background: linear-gradient(180deg, rgba(0,0,0,0.06), rgba(0,0,0,0.02));
      border-bottom: 1px solid rgba(0,0,0,0.06);
      color: var(--text-secondary);
    }
    table tbody td { padding: 10px 12px; border-top: 1px solid rgba(0,0,0,0.06); color: var(--text-primary); font-size: 0.92rem; }
    table tbody tr:hover { background: rgba(0,0,0,0.03); }
    table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }

    /* Modals */
    .modal { border-radius: 14px; padding: 20px; max-width: 940px; width: 96%; margin: 0 auto; box-shadow: var(--shadow-xl); }
    .modal-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
    .modal-header h2 { font-size: 1.15rem; font-weight: 800; margin: 0; color: var(--text-primary); }
    .modal-body { padding: 8px 0 16px; }
    .modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

    /* Accessibility helpers */
    .muted { color: var(--muted); }
    .link { color: var(--primary); cursor: pointer; text-decoration: underline; }

    /* Modal overlay utility */
    .modal-overlay { display: none; position: fixed; inset: 0; align-items: center; justify-content: center; padding: 20px; z-index: 10000; }
    .modal-overlay.active { display: flex; }

    /* Focus accessible states */
    /* Focus-visible improved: subtle accessible focus ring (reduced thickness & opacity) */
    .btn:focus-visible, .primary-btn:focus-visible, .modal-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
      outline: 2px solid rgba(99, 102, 241, 0.18);
      outline-offset: 2px;
      box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.06);
    }

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

    /* Placeholder colors per theme */
    ::placeholder { color: rgba(241,245,249,0.6); }


    /* Enhanced Dark Mode - Modern, Sleek, Premium */
    body:not(.light-mode) {
      --text-primary: #f1f5f9;
      --text-secondary: #94a3b8;
      --card-hover: rgba(30, 41, 59, 0.8);
      --on-primary: #ffffff;
    }

    body:not(.light-mode)::before {
      content: '';
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      height: 500px;
      background: radial-gradient(ellipse at top, var(--primary) 0%, transparent 60%);
      opacity: 0.15;
      pointer-events: none;
      z-index: 0;
    }

    body:not(.light-mode) .app-shell {
      position: relative;
      z-index: 1;
    }

    /* Dark mode: Buttons, tables, inputs */
    body:not(.light-mode) .primary-btn {
      background: linear-gradient(135deg, rgba(99,102,241,0.98), rgba(79,70,229,0.98));
      color: #ffffff !important;
      box-shadow: 0 10px 30px rgba(10, 15, 40, 0.6);
      border-color: rgba(255,255,255,0.04);
    }
    body:not(.light-mode) .modal-btn.cancel { background: transparent; color: var(--muted); border: 1px solid rgba(255,255,255,0.06); }
    body:not(.light-mode) table thead th { background: rgba(15,23,42,0.8); color: var(--text-secondary); border-bottom-color: rgba(255,255,255,0.04); }
    body:not(.light-mode) table tbody tr:hover { background: rgba(255,255,255,0.02); }

    body.light-mode .primary-btn { background: linear-gradient(135deg, var(--primary-bright), var(--primary)); color: #fff !important; box-shadow: 0 8px 20px rgba(15,23,42,0.08); }
    body.light-mode table thead th { background: #f8fafc; color: #475569; border-bottom-color: #e2e8f0; }
    body.light-mode table tbody tr:hover { background: #f1f5f9; }

    /* Modern Glassmorphism Effects */
    header {
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      position: relative;
      overflow: hidden;
      transition: all 0.3s ease;
      z-index: 999 !important; /* Keep header above in-page visuals */
    }

    header::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
      pointer-events: none;
      z-index: 0; /* keep header background behind content */
    }

    nav {
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      transition: all 0.3s ease;
      position: relative;
      z-index: 1000 !important; /* make sure nav sits above other content"bubbles" */
    }

    nav button {
      position: relative;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      z-index: 1001 !important; /* keep button text above overlays */
    }

    nav button::before {
      content: '';
      position: absolute;
      inset: 0;
      border-radius: 999px;
      background: linear-gradient(135deg, var(--primary), var(--primary-bright));
      opacity: 0;
      z-index: 2; /* keep overlay below button content */
      pointer-events: none; /* avoid blocking clicks */
      mix-blend-mode: normal;
      transition: opacity 0.2s ease;
    }

    nav button:hover::before {
      opacity: 0.1;
    }

    nav button.active::before {
      opacity: 1;
    }

    nav button:hover {
      transform: translateY(-1px);
    }

    /* Enhanced Cards */
    .card {
      position: relative;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      overflow: hidden;
    }

    .card::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 1px;
      background: linear-gradient(90deg, transparent 0%, var(--primary) 50%, transparent 100%);
      opacity: 0.3;
    }

    .card:hover {
      transform: translateY(-2px);
      box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    }

    /* Modern Input Styling */
    input:not([type=color]):not([type=checkbox]):not([type=radio]), 
    textarea, 
    select {
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    input:not([type=color]):not([type=checkbox]):not([type=radio]):focus, 
    textarea:focus, 
    select:focus {
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(var(--primary-shadow), 0.1);
      outline: none;
    }

    input:not([type=color]):not([type=checkbox]):not([type=radio]):hover:not(:focus), 
    textarea:hover:not(:focus), 
    select:hover:not(:focus) {
      border-color: var(--primary-bright);
    }

    /* Enhanced Buttons */
    .primary-btn,
    .modal-btn.save {
      position: relative;
      overflow: hidden;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Simplified, subtle hover overlay - removed expanding circular ripple */
    .primary-btn::before,
    .modal-btn.save::before {
      content: '';
      position: absolute;
      inset: 0; /* full-cover overlay */
      border-radius: inherit;
      background: rgba(255, 255, 255, 0.04);
      opacity: 0;
      pointer-events: none;
      transition: opacity 160ms ease;
    }

    .primary-btn:hover::before,
    .modal-btn.save:hover::before {
      opacity: 1;
    }

    .primary-btn:hover,
    .modal-btn.save:hover {
      transform: translateY(-3px) scale(1.02);
    }

    /* Remove native touch highlight and prevent browser-specific tap visual circles */
    button, .btn, .primary-btn, .modal-btn {
      -webkit-tap-highlight-color: transparent;
      -ms-touch-action: manipulation;
      touch-action: manipulation;
      appearance: none;
      -webkit-appearance: none;
    }

    .primary-btn:active,
    .modal-btn.save:active {
      transform: translateY(-1px) scale(0.99);
    }
    .primary-btn:active::before,
    .modal-btn.save:active::before {
      opacity: 0.06; /* slight overlay on active for feedback without a large circular ripple */
      transition: opacity 60ms ease;
    }

    .secondary-btn,
    .modal-btn.cancel {
      position: relative;
      overflow: hidden;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .secondary-btn:hover,
    .modal-btn.cancel:hover {
      transform: translateY(-2px);
      background: rgba(75, 85, 99, 0.9);
    }

    /* Enhanced Tables */
    table {
      border-collapse: separate;
      border-spacing: 0;
    }

    table thead th {
      position: sticky;
      top: 0;
      background: var(--card);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      z-index: 10;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      font-size: 0.7rem;
    }

    table tbody tr {
      transition: all 0.2s ease;
    }

    table tbody tr:hover {
      background: var(--card-hover);
      transform: scale(1.01);
    }

    table tbody tr:active {
      transform: scale(0.99);
    }

    /* Enhanced Modals */
    .modal-overlay {
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      animation: fadeIn 0.2s ease;
    }

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

    .modal {
      animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes modalSlideUp {
      from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
      }
      to {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }

    /* Enhanced Pills & Chips */
    .class-pill,
    .chip-card,
    .status-chip {
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      cursor: pointer;
    }

    .class-pill:hover,
    .chip-card:hover:not(.current):not(.pulled):not(.dq),
    .status-chip:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    }

    /* Enhanced Status Badges */
    .badge {
      animation: badgeFadeIn 0.3s ease;
      transition: all 0.2s ease;
    }

    .badge:hover {
      transform: scale(1.05);
    }

    @keyframes badgeFadeIn {
      from {
        opacity: 0;
        transform: translateY(-4px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    /* Scrollbar Styling - Modern & Theme-aware */
    :root {
      --scrollbar-track: rgba(15, 23, 42, 0.24);
      --scrollbar-thumb-color: #94a3b8; /* fallback for Firefox */
      --scrollbar-thumb: linear-gradient(135deg, var(--primary-soft), var(--primary-bright));
      --scrollbar-thumb-hover: linear-gradient(135deg, var(--primary), var(--primary-dark));
    }

    /* Theme-aware overrides - ensure proper thumb color & track contrast */
    body.theme-purple, body.theme-blue, body.theme-pink, body.theme-teal, body.theme-neutral, body.theme-neutral-warm, body.theme-neutral-cool, body.theme-neutral-dark {
      --scrollbar-track: rgba(15, 23, 42, 0.28);
      --scrollbar-thumb-color: var(--primary-dark);
      --scrollbar-thumb: linear-gradient(135deg, var(--primary-soft), var(--primary-bright));
      --scrollbar-thumb-hover: linear-gradient(135deg, var(--primary), var(--primary-dark));
    }

    /* WebKit-based scrollbars */
    ::-webkit-scrollbar {
      width: 10px;
      height: 10px;
    }

    ::-webkit-scrollbar-track {
      background: var(--scrollbar-track);
      border-radius: 8px;
    }

    ::-webkit-scrollbar-thumb {
      background: var(--scrollbar-thumb);
      border-radius: 8px;
      transition: all 0.2s ease;
      min-height: 24px;
      background-clip: padding-box;
    }

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

    /* Firefox - color and width */
    /* Scrollbars completely hidden */
    * { 
      scrollbar-width: none !important; 
      -ms-overflow-style: none !important;
    }
    *::-webkit-scrollbar { 
      display: none !important; 
      width: 0 !important;
      height: 0 !important;
    }
    
    body.hide-scrollbar, body.hide-scrollbar * { 
      scrollbar-width: none !important; 
      -ms-overflow-style: none !important;
      overflow: -moz-scrollbars-none !important;
    }
    body.hide-scrollbar *::-webkit-scrollbar { 
      display: none !important; 
      width: 0 !important;
      height: 0 !important;
    }

    /* Footer Enhancement */
    footer {
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      transition: all 0.3s ease;
    }

    footer .footer-links a {
      position: relative;
      transition: all 0.2s ease;
    }

    footer .footer-links a::after {
      content: '';
      position: absolute;
      bottom: -2px;
      left: 0;
      width: 0;
      height: 2px;
      background: var(--primary-bright);
      transition: width 0.3s ease;
    }

    footer .footer-links a:hover::after {
      width: 100%;
    }

    /* Loading Screen Enhancement */
    #loading-screen {
      background: linear-gradient(135deg, #020617 0%, #0f172a 50%, #1e293b 100%);
    }

    #loading-screen::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 100%;
      background: radial-gradient(ellipse at center, var(--primary) 0%, transparent 70%);
      opacity: 0.1;
      animation: pulse 4s ease-in-out infinite;
    }

    /* Theme toggle removed -- single dark theme enforced */

    body:not(.light-mode) .theme-toggle-btn {
      background: var(--card);
      color: var(--text-primary);
      border-color: rgba(255,255,255,0.04);
    }

    /* Smooth Transitions */
    body {
      transition: background 0.3s ease, color 0.3s ease;
    }

    * {
      transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
      transition-duration: 0.2s;
      transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Selection Styling */
    ::selection {
      background: var(--primary);
      color: white;
    }

    ::-moz-selection {
      background: var(--primary);
      color: white;
    }

    /* Focus Visible for Accessibility */
    *:focus-visible {
      outline: 2px solid var(--primary);
      outline-offset: 2px;
    }

    /* Reduced Motion Support */
    @media (prefers-reduced-motion: reduce) {
      *,
      *::before,
      *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
      }
    }

    /* Print Styles */
    @media print {
      body {
        background: white;
        color: black;
      }
      .theme-toggle-btn,
      nav,
      footer {
        display: none;
      }
      .card {
        break-inside: avoid;
        page-break-inside: avoid;
      }
    }

    /* Additional nav accessibility and dark-mode polish */
    body:not(.light-mode) nav button { color: rgba(248, 250, 252, 0.9); }
    body:not(.light-mode) nav button:hover { background: rgba(148, 163, 184, 0.08); color: #ffffff; }
    body:not(.light-mode) nav button.active { color: var(--on-primary) !important; -webkit-text-fill-color: var(--on-primary) !important; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.14); }
    body.light-mode nav button.active { color: #ffffff !important; -webkit-text-fill-color: #ffffff !important; font-weight: 700; text-shadow: 0 1px 1px rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.35); }
    nav button.active { color: #ffffff !important; }
    nav button:focus-visible { outline: 2px solid var(--primary-bright); outline-offset: 2px; box-shadow: 0 0 0 3px rgba(var(--primary-shadow), 0.06); }

    /* NAV TEXT VISIBILITY OVERRIDES - highest specificity to prevent text disappearing */
    nav, nav * { isolation: isolate; }
    nav button, nav button * {
      color: inherit !important;
      -webkit-text-fill-color: inherit !important;
      mix-blend-mode: normal !important;
      -webkit-font-smoothing: antialiased !important;
    }
    nav button::before {
      z-index: 1 !important; /* ensure pseudo overlay stays behind text */
      mix-blend-mode: normal !important;
      pointer-events: none !important;
      filter: none !important;
    }
    nav button:hover, nav button:active, nav button:focus {
      color: var(--on-primary) !important;
      -webkit-text-fill-color: var(--on-primary) !important;
      text-shadow: 0 1px 2px rgba(0,0,0,0.2) !important;
    }
    nav button.active, nav button.active * {
      color: var(--on-primary) !important;
      -webkit-text-fill-color: var(--on-primary) !important;
      text-shadow: 0 2px 8px rgba(0,0,0,0.6), 0 0 1px rgba(255,255,255,0.1) !important;
      -webkit-text-stroke: 0.4px rgba(0,0,0,0.6) !important;
    }
    nav button.active {
      -webkit-text-stroke: 0.55px rgba(0,0,0,0.55) !important;
    }
    /* Make overlay subtle so it doesn't hide text */
    nav .nav-group-buttons > button.active::before,
    nav .nav-group-buttons > button.active {
      background-image: none !important;
      background-color: var(--primary-dark) !important; /* use darker fallback for contrast */
      border: 1px solid rgba(0,0,0,0.12) !important;
      color: var(--on-primary) !important;
      padding: 10px 18px !important;
      font-size: 0.95rem !important;
      text-transform: none !important;
    }

    /* Sticky Header Wrapper */
    .sticky-top-container {
      position: sticky;
      top: 0;
      z-index: 1000;
      width: 100%;
    }

    /* Reset header sticky when inside wrapper */
    .sticky-top-container header {
      position: relative;
      top: auto;
      z-index: auto;
    }
