/* ─────────────────────────────────────────────
   Telemetry Dashboard — Organic Futuristic
   ───────────────────────────────────────────── */

/* Theme toggle button in nav */
.nav-theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-primary);
    line-height: 1;
    flex-shrink: 0;
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Language picker in nav */
.nav-lang-picker {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.2rem 0.3rem;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--text-primary);
    flex-shrink: 0;
    min-height: var(--touch-min);
}

/* ── Z-INDEX SCALE ──────────────────────────
   10000 – Skip link (accessibility)
    9999 – Toast notifications
    1000 – Tooltips, context menus, dropdowns
     200 – Tabs
     100 – Top nav, sticky headers
      50 – Scroll-to-top button
      10 – Overlays, legends
       5 – Loading states
       2 – Sticky section headers
       1 – Elevated cards
   ──────────────────────────────────────────── */

/* ── Smooth scroll ──────────────────────── */
html {
    scroll-behavior: smooth;
    color-scheme: dark;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* ── Selection colors ──────────────────── */
::selection {
    background: rgba(255, 107, 53, 0.3);
    color: var(--text-primary);
}

/* ── Skip links ──────────────────────────── */

.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-skip);
    background: var(--accent);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 0 0 var(--radius) var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: top 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.skip-link:focus {
    top: 0;
    outline: none;
}

/* ── Reset & Base ─────────────────────────── */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: clamp(0.85rem, 0.8rem + 0.25vw, 1rem);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    letter-spacing: -0.005em;
    transition: background-color var(--duration-slow) var(--ease-in-out),
                color var(--duration-slow) var(--ease-in-out);
}

h1, .h1 { font-size: clamp(1.25rem, 1rem + 1.5vw, 2rem); }
h2, .h2 { font-size: clamp(1.1rem, 0.9rem + 1vw, 1.5rem); }
h3, .h3 { font-size: clamp(1rem, 0.85rem + 0.7vw, 1.25rem); }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--duration-normal) var(--ease-out);
}

a:hover {
    color: var(--text-primary);
}

/* ── Navigation ───────────────────────────── */

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--glass-border);
    padding: 0 2rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    transition: background-color var(--duration-slow) var(--ease-in-out),
                border-color var(--duration-slow) var(--ease-in-out);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
}

.nav-brand a {
    color: var(--text-primary);
    transition: color var(--duration-normal) var(--ease-out);
}

.nav-brand a:hover {
    color: var(--accent);
}

.nav-icon {
    font-size: 1.4rem;
}

.nav-links {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: clamp(0.25rem, 1vw, 1rem);
    overflow: hidden;
    min-width: 0;
}

/* Items hidden by priority nav JS */
.nav-links > .nav-overflow-hidden {
    display: none !important;
}

/* "More" overflow dropdown trigger — hidden when all items fit */
.nav-overflow-wrap {
    display: none;
    position: relative;
    flex-shrink: 0;
}
.nav-overflow-wrap.nav-overflow-visible {
    display: flex;
    align-items: center;
}
.nav-overflow-trigger {
    color: var(--text-secondary);
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: clamp(0.75rem, 0.7rem + 0.3vw, 0.95rem);
    font-weight: 600;
    cursor: pointer;
    background: none;
    border: 1px solid transparent;
    transition: all var(--duration-normal) var(--ease-out);
    white-space: nowrap;
}
.nav-overflow-trigger:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.nav-overflow-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 180px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.25rem;
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
}
.nav-overflow-menu.open {
    display: block;
}
.nav-overflow-menu a,
.nav-overflow-menu .nav-dropdown-trigger {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.nav-overflow-menu a:hover,
.nav-overflow-menu .nav-dropdown-trigger:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-links a {
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: clamp(0.75rem, 0.7rem + 0.3vw, 0.95rem);
    font-weight: 500;
    transition: all var(--duration-normal) var(--ease-out);
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-links a:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-links a.active {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    position: relative;
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

.nav-links .nav-cta {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.nav-links .nav-cta:hover {
    background: var(--accent-dim);
}

/* ── Main content ─────────────────────────── */

.main-content {
    width: 100%;
    margin: 0;
    padding: 1rem 1.25rem;
    flex: 1;
}

/* ── Page header ──────────────────────────── */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    position: relative;
}

.page-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 80px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent);
    border-radius: 1px;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin-bottom: 0.3rem;
    padding: 0.2rem 0.6rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    transition: all var(--duration-normal) var(--ease-out);
}

.breadcrumb:hover {
    color: var(--accent);
    background: var(--bg-hover);
}

.count-badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-pill);
    font-weight: 500;
    vertical-align: middle;
}

/* ── Buttons ──────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.15rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.01em;
    min-height: var(--touch-min);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #e0601a 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(240, 112, 48, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ff8040 0%, var(--accent) 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(240, 112, 48, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(240, 112, 48, 0.2);
}

.btn-ghost {
    background: var(--glass-bg);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--border);
    background: var(--bg-hover);
}

.btn-lg {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

.btn-danger {
    background: linear-gradient(135deg, var(--red) 0%, #b91c1c 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(248, 113, 113, 0.25);
}

.btn-danger:hover {
    box-shadow: 0 4px 16px rgba(248, 113, 113, 0.35);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    min-height: 36px;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-icon {
    padding: 0.5rem;
    aspect-ratio: 1;
    justify-content: center;
}

/* ── Stats grid ───────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(100px, 14vw, 180px), 1fr));
    gap: var(--space-3);
    margin-bottom: 2rem;
}

/* ── KPI Cards — Mission Control ──────────── */

.kpi-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-3);
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: background-color var(--duration-slow) var(--ease-in-out),
                border-color var(--duration-normal) var(--ease-out),
                transform var(--duration-normal) var(--ease-out),
                box-shadow var(--duration-normal) var(--ease-out);
    box-shadow: var(--shadow-sm);
}

/* Instrument glow line at top */
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.5;
    transition: opacity var(--duration-normal) var(--ease-out);
}

/* Hover: lift + glow */
.kpi-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-dim);
    box-shadow: var(--shadow), var(--shadow-glow);
}

.kpi-card:hover::before {
    opacity: 1;
}

/* Accent variant */
.kpi-card--accent {
    border-color: var(--accent-dim);
    background: linear-gradient(135deg, var(--accent-dim) 0%, var(--glass-bg) 100%);
}

/* ── KPI Value ── */
.kpi-card__value {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    line-height: var(--line-height-tight);
    color: var(--text-primary);
}

/* ── KPI Label ── */
.kpi-card__label {
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: var(--space-1);
}

/* ── Delta indicator ── */
.kpi-card__delta {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    font-family: var(--font-mono);
    margin-top: var(--space-1);
}

.kpi-card__delta--up {
    color: var(--success);
}

.kpi-card__delta--down {
    color: var(--danger);
}

.kpi-card__delta--neutral {
    color: var(--text-muted);
}

/* Legacy aliases (existing templates use .stat-card) */
.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-3);
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: border-color var(--duration-normal) var(--ease-out),
                transform var(--duration-normal) var(--ease-out),
                box-shadow var(--duration-normal) var(--ease-out);
    box-shadow: var(--shadow-sm);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.5;
    transition: opacity var(--duration-normal) var(--ease-out);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-dim);
    box-shadow: var(--shadow), var(--shadow-glow);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card.accent {
    border-color: var(--accent-dim);
    background: linear-gradient(135deg, var(--accent-dim) 0%, var(--glass-bg) 100%);
}

.stat-value {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    line-height: var(--line-height-tight);
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: var(--space-1);
}

/* ── Sections ─────────────────────────────── */

.section {
    margin-bottom: 2.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    gap: 0.75rem;
}

.section-header h2 {
    margin-bottom: 0;
}

.section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    position: relative;
    padding-left: 0.85rem;
}

.section h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 3px;
    height: 1em;
    background: linear-gradient(180deg, var(--accent), rgba(240, 112, 48, 0.3));
    border-radius: 2px;
}

/* Section divider line (opt-in) */
.section-divider {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, var(--border), transparent 80%);
    margin: 2rem 0;
}

/* Subsection inside section */
.subsection {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

.subsection h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

/* Section with accent indicator */
.section-accent h2::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 1.1em;
    background: var(--accent);
    border-radius: var(--radius-xs);
    margin-right: 0.6rem;
    vertical-align: middle;
}

/* Content card pattern */
.content-card {
    background: rgba(14, 17, 24, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    overflow: hidden;
    transition: border-color 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.content-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    pointer-events: none;
}

.content-card:hover {
    border-color: rgba(240, 112, 48, 0.2);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2), 0 0 40px rgba(240, 112, 48, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.content-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.content-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Page subtitle */
.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
    font-weight: 400;
}

/* Info banner */
.info-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.06) 0%, rgba(96, 165, 250, 0.02) 100%);
    border: 1px solid rgba(96, 165, 250, 0.15);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1.15rem;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.info-banner-icon {
    flex-shrink: 0;
    font-size: 1.1rem;
}

.info-banner a {
    color: var(--blue);
}

/* Warning banner */
.warning-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.06) 0%, rgba(251, 191, 36, 0.02) 100%);
    border: 1px solid rgba(251, 191, 36, 0.15);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1.15rem;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* ── Tables ───────────────────────────────── */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    box-shadow: var(--shadow-sm);
}

/* Scroll shadow indicators for horizontal scroll */
.table-wrap {
    background:
        linear-gradient(to right, var(--glass-bg) 30%, transparent),
        linear-gradient(to left, var(--glass-bg) 30%, transparent),
        linear-gradient(to right, rgba(0,0,0,0.2), transparent 15px),
        linear-gradient(to left, rgba(0,0,0,0.2), transparent 15px);
    background-position: left center, right center, left center, right center;
    background-size: 20px 100%, 20px 100%, 15px 100%, 15px 100%;
    background-repeat: no-repeat;
    background-attachment: local, local, scroll, scroll;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    transition: background-color var(--duration-slow) var(--ease-in-out);
}

.data-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    user-select: none;
}

/* Sortable column headers */
.data-table th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 1.5rem;
}

.data-table th.sortable::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 0.4rem;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-muted);
    opacity: 0.4;
}

.data-table th.sortable:hover::after {
    opacity: 0.8;
}

.data-table th.sortable.sort-asc::after {
    border-top: none;
    border-bottom: 5px solid var(--accent);
    opacity: 1;
}

.data-table th.sortable.sort-desc::after {
    border-top: 5px solid var(--accent);
    opacity: 1;
}

.data-table th.sortable:hover,
.data-table th.sortable:focus-visible {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.data-table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.data-table.compact td {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Zebra striping (opt-in) */
.data-table.striped tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

/* Column alignment utilities */
.data-table .col-right {
    text-align: right;
}

.data-table .col-center {
    text-align: center;
}

/* Numeric column formatting */
.data-table .col-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Highlight on hover entire row */
.data-table tbody tr {
    transition: background var(--duration-normal) var(--ease-out);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

.clickable-row {
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.clickable-row:hover {
    background: rgba(240, 112, 48, 0.04);
    box-shadow: inset 3px 0 0 var(--accent);
}

.best-lap {
    background: var(--accent-glow);
}

.best-lap:hover {
    background: rgba(255, 107, 53, 0.25) !important;
}

/* Table row highlight states */
.row-success {
    background: rgba(63, 185, 80, 0.06);
}

.row-warning {
    background: rgba(210, 153, 34, 0.06);
}

.row-danger {
    background: rgba(248, 81, 73, 0.06);
}

/* Table cell with trend indicator */
.cell-trend-up::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 5px solid var(--green);
    margin-right: 0.3rem;
    vertical-align: middle;
}

.cell-trend-down::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--red);
    margin-right: 0.3rem;
    vertical-align: middle;
}

/* Row state classes */
.data-table .row-success td:first-child {
    box-shadow: inset 3px 0 0 var(--green);
}

.data-table .row-warning td:first-child {
    box-shadow: inset 3px 0 0 var(--yellow);
}

.data-table .row-danger td:first-child {
    box-shadow: inset 3px 0 0 var(--red);
}

.data-table .row-highlight {
    background: rgba(255, 107, 53, 0.04);
}

/* Table skeleton loading */
.data-table--skeleton {
    pointer-events: none;
}

.data-table--skeleton td {
    color: transparent;
    position: relative;
}

.data-table--skeleton td::after {
    content: '';
    position: absolute;
    top: 25%;
    left: 0.5rem;
    right: 0.5rem;
    height: 50%;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Numeric helper: monospace + tabular */
.data-table td.num {
    font-variant-numeric: tabular-nums;
    text-align: right;
    letter-spacing: -0.01em;
}

/* Compact time display */
.time-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    letter-spacing: -0.02em;
}

/* Data freshness indicator */
.data-fresh::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    margin-left: 0.4rem;
    vertical-align: middle;
}

.data-stale::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    margin-left: 0.4rem;
    vertical-align: middle;
}

/* Table caption */
.data-table caption {
    caption-side: bottom;
    text-align: left;
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 0.5rem 0;
    font-style: italic;
}

/* Rank badge styling in tables */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
}

.rank-badge.rank-1 { font-size: 1.2rem; }
.rank-badge.rank-2 { font-size: 1.1rem; }
.rank-badge.rank-3 { font-size: 1.0rem; }

/* Podium row highlights */
.data-table .podium-1 {
    background: rgba(255, 215, 0, 0.04);
}

.data-table .podium-2 {
    background: rgba(192, 192, 192, 0.04);
}

.data-table .podium-3 {
    background: rgba(205, 127, 50, 0.04);
}

/* Table empty row */
.data-table .empty-row td {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-style: italic;
}

/* ── Table scroll wrapper for responsive tables ── */
.table-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
}
.table-scroll-wrapper table {
    min-width: 600px;
    width: 100%;
}

/* ── Badges ───────────────────────────────── */

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-sans);
    text-transform: capitalize;
    vertical-align: middle;
    line-height: 1.2;
}

.badge-practice { background: rgba(52, 211, 153, 0.12); color: var(--green); }
.badge-qualifying { background: rgba(251, 191, 36, 0.12); color: var(--yellow); }
.badge-race { background: rgba(248, 113, 113, 0.12); color: var(--red); }
.badge-test { background: rgba(96, 165, 250, 0.12); color: var(--blue); }

.badge-dry { background: rgba(52, 211, 153, 0.1); color: var(--green); }
.badge-wet { background: rgba(96, 165, 250, 0.1); color: var(--blue); }
.badge-damp { background: rgba(251, 191, 36, 0.08); color: var(--yellow); }
.badge-mixed { background: rgba(167, 139, 250, 0.1); color: var(--purple); }

.badge-best { background: var(--accent); color: #fff; font-size: 0.7rem; }

.badge-success { background: rgba(52, 211, 153, 0.12); color: var(--green); }
.badge-warning { background: rgba(251, 191, 36, 0.12); color: var(--yellow); }
.badge-danger { background: rgba(248, 113, 113, 0.12); color: var(--red); }
.badge-info { background: rgba(96, 165, 250, 0.12); color: var(--blue); }
.badge-neutral { background: var(--glass-bg); color: var(--text-secondary); }

/* ── Grades ───────────────────────────────── */

.grade {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.grade-A { background: rgba(52, 211, 153, 0.12); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.25); }
.grade-B { background: rgba(163, 217, 119, 0.1); color: #a3d977; border: 1px solid rgba(163, 217, 119, 0.2); }
.grade-C { background: rgba(251, 191, 36, 0.1); color: var(--yellow); border: 1px solid rgba(251, 191, 36, 0.2); }
.grade-D { background: rgba(248, 113, 113, 0.1); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.2); }
.grade-F { background: rgba(255, 107, 107, 0.1); color: #ff6b6b; border: 1px solid rgba(255, 107, 107, 0.2); }

/* ── Card component ─────────────────────────── */

.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: background-color var(--duration-slow) var(--ease-in-out),
                border-color var(--duration-slow) var(--ease-in-out),
                box-shadow var(--duration-slow) var(--ease-in-out);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    pointer-events: none;
}

.card--glass {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
}

.card--elevated {
    box-shadow: var(--shadow-md);
    border-color: var(--border);
}

.card--interactive {
    cursor: pointer;
    transition: border-color var(--duration-normal) var(--ease-out),
                box-shadow var(--duration-normal) var(--ease-out),
                transform var(--duration-normal) var(--ease-out);
}

.card--interactive:hover {
    border-color: rgba(240, 112, 48, 0.2);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(240, 112, 48, 0.04);
    transform: translateY(-2px);
}

.card__header {
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.card__title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
}

.card__body {
    /* content container — no special styling needed */
}

.card__footer {
    padding-top: var(--space-3);
    margin-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

/* ── Meta grid (session detail) ───────────── */

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 18vw, 200px), 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.meta-item {
    background: rgba(14, 17, 24, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1.1rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    overflow: visible;
    transition: border-color 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.meta-item select,
.meta-item .form-select,
.meta-item .form-select-sm {
    max-width: 100%;
    width: 100%;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.meta-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
    pointer-events: none;
}

.meta-item:hover {
    border-color: rgba(240, 112, 48, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15), 0 0 30px rgba(240, 112, 48, 0.03);
}

.meta-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
}

.meta-value {
    font-size: 1.05rem;
    font-weight: 600;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.meta-value.highlight {
    color: var(--accent);
}

.meta-value a {
    color: var(--accent);
}

/* ── Score bars ───────────────────────────── */

.score-bars {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-bottom: 1.5rem;
    padding: 1.15rem;
    background: rgba(14, 17, 24, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.score-bar-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.score-bar-label {
    min-width: 7em;
    width: auto;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.score-bar-track {
    flex: 1;
    height: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-pill);
    overflow: hidden;
    position: relative;
}

.score-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-dim), var(--accent));
    border-radius: var(--radius-pill);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.score-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-pill);
}

.score-bar-fill.accent {
    background: linear-gradient(90deg, var(--blue), var(--purple));
}

/* Color-coded score bars based on percentage */
.score-bar-fill.score-excellent { background: linear-gradient(90deg, var(--success-dim), var(--green)); }
.score-bar-fill.score-good { background: linear-gradient(90deg, #538d36, #7ec850); }
.score-bar-fill.score-average { background: linear-gradient(90deg, #8a6d1a, var(--yellow)); }
.score-bar-fill.score-poor { background: linear-gradient(90deg, #8a2a1a, var(--red)); }

.score-bar-value {
    min-width: 5.5em;
    width: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-align: right;
    color: var(--text-primary);
    font-weight: 600;
}

/* ── Insight boxes ────────────────────────── */

.insight-box {
    background: rgba(14, 17, 24, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.35rem;
    margin-bottom: 1rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    overflow: hidden;
    transition: border-color 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.insight-box:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.insight-box h3 {
    font-size: 0.9rem;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.insight-box.good {
    border-left: 4px solid var(--green);
    background: linear-gradient(90deg, rgba(63, 185, 80, 0.04), transparent 30%);
}

.insight-box.good h3 { color: var(--green); }
.insight-box.good h3::before { content: '\2714 '; font-size: 0.85rem; }

.insight-box.warn {
    border-left: 4px solid var(--yellow);
    background: linear-gradient(90deg, rgba(210, 153, 34, 0.04), transparent 30%);
}

.insight-box.warn h3 { color: var(--yellow); }
.insight-box.warn h3::before { content: '\26A0 '; font-size: 0.85rem; }

.insight-box ul {
    list-style: none;
    padding: 0;
}

.insight-box li {
    padding: 0.3rem 0;
    padding-left: 1.2rem;
    position: relative;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.insight-box.good li::before {
    content: '\2713';
    position: absolute;
    left: 0;
    color: var(--green);
    font-size: 0.8rem;
}

.insight-box.warn li::before {
    content: '\203A';
    position: absolute;
    left: 0.15rem;
    color: var(--yellow);
    font-weight: 700;
}

.insight-box li:last-child {
    border-bottom: none;
}

/* ── GPS Map ──────────────────────────────── */

.gps-container {
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12);
}

.gps-map {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.15);
}

.gps-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.gps-controls label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.gps-controls select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

/* ── Chart container ──────────────────────── */

.chart-container {
    position: relative;
    background: rgba(14, 17, 24, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    margin-bottom: 1rem;
    width: 100%;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.03);
    overflow: visible;
}

.chart-container canvas {
    display: block;
    width: 100%;
}

/* Chart aspect-ratio modifiers */
.chart-container--wide    { aspect-ratio: 5 / 2; }
.chart-container--tall    { aspect-ratio: 3 / 2; }
.chart-container--square  { aspect-ratio: 1 / 1; max-width: clamp(240px, 40vw, 420px); }
.chart-container--short   { aspect-ratio: 3 / 1; }

/* Chart header/title inside container */
.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.chart-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chart-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.chart-legend-swatch {
    display: inline-block;
    width: 12px;
    height: 3px;
    border-radius: var(--radius-xs);
}

/* Chart loading state */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.chart-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.5rem;
}

/* Chart empty state */
.chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 2rem;
}

.chart-empty-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Chart tooltip overlay */
.chart-tooltip {
    position: absolute;
    background: rgba(14, 17, 24, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.85rem;
    font-size: 0.78rem;
    pointer-events: none;
    z-index: var(--z-elevated);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-tooltip-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-bottom: 0.15rem;
}

.chart-tooltip-value {
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--font-mono);
}

.chart-crosshair {
    position: absolute;
    width: 1px;
    background: var(--accent);
    top: 1rem;
    bottom: 1rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
}

.chart-crosshair.visible {
    opacity: 0.7;
}

/* ── Condition phases timeline ────────────── */

.phases-timeline {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.phase-block {
    background: rgba(14, 17, 24, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1.1rem;
    min-width: 140px;
    flex: 1;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.03);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.phase-block:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.phase-block.phase-dry { border-top: 3px solid var(--green); }
.phase-block.phase-wet { border-top: 3px solid var(--blue); }
.phase-block.phase-damp { border-top: 3px solid var(--yellow); }
.phase-block.phase-mixed { border-top: 3px solid var(--purple); }

.phase-label {
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: capitalize;
    margin-bottom: 0.25rem;
}

.phase-laps, .phase-pace, .phase-conf {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ── Card grid (tracks) ───────────────────── */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(240px, 30vw, 320px), 1fr));
    gap: 1rem;
}

.track-card {
    display: block;
    background: rgba(14, 17, 24, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.track-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    pointer-events: none;
}

.track-card:hover {
    border-color: rgba(240, 112, 48, 0.25);
    background: rgba(240, 112, 48, 0.04);
    color: var(--text-primary);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2), 0 0 40px rgba(240, 112, 48, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
}

.track-card-header h3 {
    font-size: 1.05rem;
    margin-bottom: 0.75rem;
}

.track-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.track-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.track-stat-label {
    color: var(--text-secondary);
}

.track-stat-value {
    font-family: var(--font-mono);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ── Forms ─────────────────────────────────── */

.analysis-form {
    max-width: 700px;
}

.form-section {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.03);
    transition: border-color 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    pointer-events: none;
}

.form-section:hover {
    border-color: rgba(240, 112, 48, 0.15);
}

.form-section legend {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0 0.5rem;
    letter-spacing: -0.01em;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    transition: color var(--duration-normal) var(--ease-out);
}

.form-group:focus-within label {
    color: var(--accent);
}

.form-input,
.form-select {
    width: 100%;
    min-height: var(--touch-min);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    font-family: var(--font-sans);
    transition: border-color var(--duration-normal) var(--ease-out), box-shadow var(--duration-normal) var(--ease-out), background var(--duration-normal) var(--ease-out);
}

.form-input:hover:not(:focus):not(:disabled),
.form-select:hover:not(:focus):not(:disabled) {
    border-color: var(--text-muted);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: rgba(240, 112, 48, 0.5);
    box-shadow: 0 0 0 3px rgba(240, 112, 48, 0.1), 0 0 20px rgba(240, 112, 48, 0.06);
    background: rgba(0, 0, 0, 0.35);
}

.form-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.form-input:disabled,
.form-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-tertiary);
}

.form-input.valid,
.form-select.valid {
    border-color: var(--green);
    box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.12);
}

/* Custom select arrow */
.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

/* Select option items — force dark background so text is readable on Windows */
select option,
.form-select option {
    background: #1c2128;
    color: #e6edf3;
}

/* Textarea specific */
textarea.form-input {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

/* Number input spinner hide on Webkit */
.form-input[type="number"]::-webkit-inner-spin-button,
.form-input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
    height: 24px;
}

/* Required field indicator — works with both .required class and HTML required attribute */
.form-group.required label::after,
.form-group:has([required]) > label::after {
    content: ' *';
    color: var(--red);
    font-weight: 400;
}

.file-input {
    width: 100%;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-input::file-selector-button {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    margin-right: 0.75rem;
    font-size: 0.85rem;
    transition: all var(--duration-normal) var(--ease-out);
}

.file-input::file-selector-button:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

/* Input group: input with inline button or icon */
.input-group {
    display: flex;
    gap: 0;
}

.input-group .form-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    white-space: nowrap;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(140px, 18vw, 200px), 1fr));
    gap: 1rem;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* ── Progress indicator ───────────────────── */

.progress-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.progress-indicator.hidden {
    display: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ── Pagination ───────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.page-info {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ── Empty state ──────────────────────────── */

.empty-state {
    text-align: center;
    padding: var(--space-6) var(--space-4);
    color: var(--text-secondary);
}

.empty-state p {
    margin-bottom: var(--space-3);
    font-size: 1rem;
}

/* ── Rich empty state ────────────────────── */

.empty-hero {
    text-align: center;
    padding: var(--space-6) var(--space-5);
    max-width: 640px;
    margin: 0 auto;
    background: linear-gradient(180deg, var(--glass-bg) 0%, var(--accent-dim) 100%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-border);
}

.empty-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-dim), transparent);
    opacity: 0.5;
}

.empty-hero-icon {
    font-size: 3.5rem;
    line-height: 1;
    margin-bottom: var(--space-3);
    opacity: 0.7;
    filter: grayscale(30%);
}

.empty-hero-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.empty-hero-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-4);
}

.empty-hero .btn {
    margin: var(--space-1);
}

.empty-hero .btn:first-of-type {
    margin-top: var(--space-2);
}

.empty-hero-compact {
    padding: var(--space-4) var(--space-3);
}

.empty-hero-compact .empty-hero-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-2);
}

.empty-hero-compact .empty-hero-title {
    font-size: 1.1rem;
}

.empty-hero-compact .empty-hero-desc {
    font-size: 0.88rem;
    margin-bottom: var(--space-3);
}

/* ── Error state ──────────────────────────── */

.error-state {
    text-align: center;
    padding: var(--space-6) var(--space-5);
    max-width: 480px;
    margin: 0 auto;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    box-shadow: var(--shadow-sm);
}

.error-state-icon {
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: var(--space-3);
    color: var(--red);
    opacity: 0.8;
}

.error-state-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.error-state-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-4);
}

.error-state .btn {
    margin-top: var(--space-2);
}

/* Steps guide within empty state */
.empty-steps {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin: 2rem auto 0;
    max-width: 720px;
    text-align: left;
}

.empty-step {
    flex: 1;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.2rem;
    position: relative;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    box-shadow: var(--shadow-sm);
}

.empty-step-num {
    position: absolute;
    top: -0.7rem;
    left: 1rem;
    background: var(--accent);
    color: #fff;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.empty-step-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    margin-top: 0.2rem;
}

.empty-step-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Welcome hero (dashboard first-visit) */
.welcome-hero {
    background: linear-gradient(135deg, var(--glass-bg) 0%, rgba(240, 112, 48, 0.06) 50%, rgba(96, 165, 250, 0.04) 100%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 3rem 2.5rem;
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.welcome-hero::before {
    content: '';
    position: absolute;
    top: -120px;
    right: -80px;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(240, 112, 48, 0.1) 0%, rgba(96, 165, 250, 0.04) 40%, transparent 70%);
    pointer-events: none;
    animation: heroGlow 8s ease-in-out infinite alternate;
}

@keyframes heroGlow {
    0% { opacity: 0.7; transform: translate(0, 0); }
    100% { opacity: 1; transform: translate(-20px, 20px); }
}

.welcome-hero-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.welcome-hero h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.welcome-hero .welcome-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Feature hints row */
.feature-hints {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(160px, 22vw, 240px), 1fr));
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.feature-hint {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    text-align: left;
    transition: all var(--duration-slow) cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.feature-hint::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    pointer-events: none;
}

.feature-hint:hover {
    border-color: var(--accent-dim);
    background: var(--accent-dim);
    transform: translateY(-2px);
    box-shadow: var(--shadow), var(--shadow-glow);
}

.feature-hint-icon {
    font-size: 1.5rem;
    margin-bottom: 0.4rem;
}

.feature-hint-title {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.feature-hint-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Responsive empty steps */
@media (max-width: 640px) {
    .empty-steps {
        flex-direction: column;
        gap: 1rem;
    }

    .welcome-hero {
        padding: 2rem 1.5rem;
    }

    .feature-hints {
        grid-template-columns: 1fr;
    }
}

/* ── Flash messages ───────────────────────── */

.flash-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1rem 2rem 0;
}

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.flash-success {
    background: rgba(52, 211, 153, 0.08);
    border: 1px solid rgba(52, 211, 153, 0.2);
    color: var(--green);
}

.flash-error {
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.2);
    color: var(--red);
}

.flash-warning {
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
    color: var(--yellow);
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    min-width: 2rem;
    min-height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}

.flash-close:hover {
    opacity: 1;
}

.flash-close:focus-visible {
    opacity: 1;
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* ── Footer ───────────────────────────────── */

.site-footer {
    text-align: center;
    padding: 2rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    border-top: 1px solid var(--border-subtle);
    margin-top: 3rem;
    letter-spacing: 0.02em;
}

/* ── Leaflet dark theme overrides ─────────── */

.leaflet-container {
    background: var(--bg-tertiary) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

.leaflet-control-attribution {
    background: rgba(13, 17, 23, 0.85) !important;
    color: var(--text-muted) !important;
    font-size: 0.7rem !important;
}

.leaflet-control-attribution a {
    color: var(--text-secondary) !important;
}

/* ── Speed legend (map) ───────────────────── */

.speed-legend {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.speed-legend .legend-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.speed-legend .legend-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.speed-legend .legend-swatch {
    width: 18px;
    height: 4px;
    border-radius: var(--radius-xs);
    display: inline-block;
}

/* ── Responsive ───────────────────────────── */

@media (max-width: 768px) {
    .top-nav {
        padding: 0 1rem;
        height: auto;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    /* nav-links handled by hamburger mobile section below */

    .nav-overflow-wrap {
        display: none !important;
    }

    .main-content {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .meta-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ─────────────────────────────────────────────
   Phase 2 — Additional utility classes
   ───────────────────────────────────────────── */

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.inline-form .form-row {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    align-items: end;
}

.inline-create-form {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 1rem;
}

.inline-create-form .form-row {
    gap: 8px;
}

.inline-create-form .form-input.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.2);
}

.add-record-form summary {
    cursor: pointer;
    color: var(--text-secondary);
}

.add-record-form summary:hover {
    color: var(--accent);
}

.meta-value.good {
    color: var(--green);
}

.meta-value.warn {
    color: var(--yellow);
}

/* Overlay legend checkboxes */
.overlay-legend input[type="checkbox"] {
    accent-color: var(--accent);
}

.overlay-legend label:hover {
    color: var(--accent);
}

/* ── Phase 3: Driving style ──────────────── */

.badge-style {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: capitalize;
}
.badge-style.smooth       { background: rgba(88,166,255,0.18); color: #79b8ff; }
.badge-style.aggressive   { background: rgba(248,81,73,0.18);  color: #ff8a82; }
.badge-style.conservative { background: rgba(210,153,34,0.18); color: #e5a73a; }
.badge-style.adaptive     { background: rgba(188,140,255,0.18);color: #c89cff; }

.style-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(280px, 40vw, 500px), 1fr));
    gap: 1.2rem;
}
@media (max-width: 700px) {
    .style-section { grid-template-columns: 1fr; }
}

.style-radar-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(160px, 25vh, 300px);
}

.style-features-list {
    list-style: none;
    padding: 0;
}
.style-features-list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.85rem;
}
.style-features-list li:last-child { border-bottom: none; }

.style-feature-name {
    flex: 1;
    color: var(--text-secondary);
    text-transform: capitalize;
}
.style-feature-bar {
    flex: 2;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: var(--radius-xs);
    overflow: hidden;
}
.style-feature-bar .fill {
    height: 100%;
    border-radius: var(--radius-xs);
    background: var(--accent);
    transition: width 0.4s ease;
}
.style-feature-value {
    width: 3rem;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
}

.driver-link {
    color: var(--accent);
    text-decoration: none;
}
.driver-link:hover {
    text-decoration: underline;
}

/* ── Phase 4: Comparison ─────────────────── */

.compare-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(280px, 40vw, 500px), 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
@media (max-width: 768px) {
    .compare-panels { grid-template-columns: 1fr; }
}

.compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(280px, 40vw, 500px), 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
@media (max-width: 768px) {
    .compare-grid { grid-template-columns: 1fr; }
}

.compare-column {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.compare-a { border-top: 3px solid var(--accent); }
.compare-b { border-top: 3px solid var(--blue); }

.compare-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.compare-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
}
.compare-a .compare-badge { background: var(--accent); color: #fff; }
.compare-b .compare-badge { background: var(--blue); color: #fff; }

.compare-column .score-bars {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

.compare-winner-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-pill);
    background: rgba(63, 185, 80, 0.12);
    color: var(--green);
    margin-top: 0.5rem;
}

.compare-advantage {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-sm);
    margin-left: 0.3rem;
    vertical-align: middle;
}
.compare-advantage.better {
    background: rgba(63, 185, 80, 0.12);
    color: var(--green);
}
.compare-advantage.worse {
    background: rgba(248, 81, 73, 0.1);
    color: var(--red);
}

.compare-delta-box {
    text-align: center;
    padding: 2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
}
.compare-delta-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.delta-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}
.delta-value {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    letter-spacing: -0.02em;
}
.delta-faster { color: var(--green); }
.delta-slower { color: var(--red); }
.delta-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}
.delta-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ── Style comparison wrap ──────────── */

.style-radar-wrap {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.style-radar-label {
    position: absolute;
    top: 0.5rem;
    left: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* ── Compare stat highlight ─────────── */

.stat-winner {
    position: relative;
}
.stat-winner::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--green);
    border-radius: var(--radius-xs);
}

/* ── Search dropdown ────────────────── */

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 280px;
    overflow-y: auto;
    z-index: var(--z-sticky);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.search-result-item {
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s ease;
}

.search-result-item:hover {
    background: var(--bg-hover);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item strong {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.search-result-meta {
    color: var(--text-secondary);
    font-size: 0.72rem;
    margin-top: 0.15rem;
}

/* ── Weekend notes box ──────────────── */

.weekend-notes {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.06), transparent);
    border: 1px solid var(--border);
    border-left: 3px solid var(--blue);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.weekend-notes h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--blue);
    margin-bottom: 0.25rem;
}

.weekend-notes p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.5;
}

/* ── Compare sessions toolbar ───────── */

.compare-toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.compare-toolbar .form-hint {
    margin-left: auto;
}

.compare-form {
    max-width: 100%;
}

/* ── Phase 4: Leaderboard ────────────────── */

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.rank-badge.rank-1 { background: #3a3000; color: #ffd700; }
.rank-badge.rank-2 { background: #2a2a2a; color: #c0c0c0; }
.rank-badge.rank-3 { background: #2a1a0a; color: #e09040; }

.podium-1 { background: rgba(255, 215, 0, 0.05); }
.podium-2 { background: rgba(192, 192, 192, 0.04); }
.podium-3 { background: rgba(205, 127, 50, 0.04); }

.highlight {
    color: var(--accent);
}

.trend-up { color: var(--green); font-size: 0.85rem; }
.trend-down { color: var(--red); font-size: 0.85rem; }
.trend-stable { color: var(--text-secondary); font-size: 0.85rem; }

/* ── Phase 4: Error pages ────────────────── */

.error-page {
    text-align: center;
    padding: 5rem 1.5rem;
    max-width: 520px;
    margin: 0 auto;
    animation: error-fade-in 0.4s ease-out;
}

@keyframes error-fade-in {
    from { opacity: 0; transform: translateY(15px); }
    to   { opacity: 1; transform: translateY(0); }
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.6;
    animation: error-float 3s ease-in-out infinite;
}

@keyframes error-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

.error-code {
    font-size: 7rem;
    font-weight: 800;
    font-family: var(--font-mono);
    background: linear-gradient(135deg, var(--accent), var(--yellow));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
}

.error-page h1 {
    font-size: 1.6rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.error-page .error-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.error-page .error-hint {
    margin-top: 2rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

@media (max-width: 400px) {
    .error-code {
        font-size: 5rem;
    }
    .error-page h1 {
        font-size: 1.3rem;
    }
}

/* ── Details/Summary transitions ──────── */

details {
    transition: background 0.2s ease;
}

details > summary {
    list-style: none;
    user-select: none;
}

details > summary::-webkit-details-marker {
    display: none;
}

details > summary::before {
    content: '\\25B6';
    display: inline-block;
    font-size: 0.65em;
    margin-right: 0.5em;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

details[open] > summary::before {
    transform: rotate(90deg);
}

details > summary:hover {
    opacity: 0.85;
}

/* ── Context menu animation ──────────── */

.context-menu {
    animation: ctx-appear 0.12s ease-out;
}

@keyframes ctx-appear {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* ── Dropdown menu animation ─────────── */

.nav-dropdown-menu.open,
.nav-dropdown.open {
    animation: dropdown-appear 0.15s ease-out;
}

@keyframes dropdown-appear {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Phase 5: Chart tooltip ─────────────── */

.chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(22, 27, 34, 0.92);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.1s;
    z-index: var(--z-elevated);
}

.chart-tooltip.visible {
    opacity: 1;
}

/* More prominent crosshair */
.chart-crosshair {
    width: 2px;
    background: var(--accent);
}

.chart-crosshair.visible {
    opacity: 0.85;
}

/* ── Phase 5: Invalid lap styling ───────── */

.invalid-lap {
    opacity: 0.45;
}

.badge-invalid {
    background: #2a1a2a;
    color: var(--purple);
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    margin-left: 0.3rem;
}

.badge-pit {
    background: #2a2210;
    color: #ff9800;
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    margin-left: 0.3rem;
}

/* ── Phase 5: New session type badges ───── */

.badge-warmup { background: #2a2a1a; color: #e0c070; }
.badge-sprint { background: #2a1a1a; color: #ff7070; }
.badge-endurance { background: #1a2a2a; color: #70c0e0; }

/* ── Phase 5: New track state badges ────── */

.badge-drying  { background: #1a2a2a; color: #80b0d0; }
.badge-greasy  { background: #2a2a1a; color: #c0b080; }
.badge-flooded { background: #1a1a3a; color: #6080c0; }
.badge-dusty   { background: #2a2a1a; color: #b0a080; }
.badge-cold    { background: #1a2030; color: #80a0e0; }
.badge-hot     { background: #301a1a; color: #e08070; }

/* ── Phase 5: GPS marker tooltip ────────── */

.gps-marker-tooltip {
    background: rgba(22, 27, 34, 0.92) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    font-family: var(--font-mono) !important;
    font-size: 0.8rem !important;
    padding: 3px 8px !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow) !important;
}

.gps-marker-tooltip::before {
    border-top-color: var(--border) !important;
}

/* ── Phase 5: Lap overlay controls ─────── */

.lap-overlay-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0;
    padding: 0.5rem;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

.lap-overlay-label {
    display: inline-flex;
    align-items: center;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0.15rem 0.25rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.lap-overlay-label:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-xs {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.btn-xs:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.overlay-legend-box {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    background: rgba(22, 27, 34, 0.85);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    pointer-events: none;
}

/* ── Phase 5: Checkbox grid (multi-conditions) ── */

.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.75rem;
    padding: 0.4rem 0;
}

.cb-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
}

.cb-label:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border);
}

.cb-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.cb-label input[type="checkbox"]:checked + span,
.cb-label:has(input:checked) {
    color: var(--text-primary);
    font-weight: 500;
}

/* ── Phase 5: Driver rows ───────────────── */

.driver-row {
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

.driver-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* ══════════════════════════════════════════
   Phase 6: Context menu
   ══════════════════════════════════════════ */

.ctx-menu {
    position: fixed;
    z-index: var(--z-overlay);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    min-width: 190px;
    padding: 4px 0;
    font-size: 0.82rem;
}

.ctx-menu-item {
    padding: 7px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    transition: background 0.1s;
}

.ctx-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.ctx-menu-item.danger {
    color: var(--red);
}

.ctx-menu-icon {
    font-size: 0.9rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.ctx-menu-separator {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ══════════════════════════════════════════
   Phase 6: Visualization layout
   ══════════════════════════════════════════ */

.viz-layout {
    display: flex;
    height: calc(100vh - 56px - 40px);
    overflow: visible;
}

.viz-sidebar {
    width: 300px;
    min-width: 260px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    padding: 1rem;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.viz-main {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.viz-map-container {
    width: 100%;
    aspect-ratio: 2 / 1;
    border-radius: var(--radius, 8px);
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 0;              /* contain Leaflet's internal z-indexes */
    isolation: isolate;       /* create stacking context so map can't overlap navbar */
}

.viz-chart-container {
    width: 100%;
    aspect-ratio: 2 / 1;
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius, 8px);
    border: 1px solid var(--border);
    padding: 8px;
    flex-shrink: 0;
}

.viz-chart-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.viz-chart-container:last-child {
    /* G-G diagram — square aspect ratio */
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: clamp(300px, 50vw, 500px);
}

.viz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.viz-header h1 {
    font-size: 1.1rem;
    margin: 0;
}

/* Sidebar sections */
.viz-section {
    margin-bottom: 1.25rem;
}

.viz-section h3 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
}

.viz-session-info {
    font-size: 0.82rem;
    line-height: 1.6;
}

.viz-session-info .meta-label {
    color: var(--text-secondary);
    min-width: 60px;
    display: inline-block;
}

/* Lap list */
.viz-lap-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 3px 4px;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: background 0.1s;
}

.viz-lap-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.viz-lap-swatch {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-xs);
    flex-shrink: 0;
}

.viz-lap-time {
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: monospace;
}

.viz-lap-item.best .viz-lap-time {
    color: var(--green);
    font-weight: 600;
}

.viz-quick-btns {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
}

/* Sector times table */
.viz-sector-table {
    width: 100%;
    font-size: 0.78rem;
    border-collapse: collapse;
}

.viz-sector-table th,
.viz-sector-table td {
    text-align: right;
    padding: 3px 6px;
}

.viz-sector-table th {
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}

.viz-sector-table td.best-sector {
    color: var(--green);
    font-weight: 600;
}

/* Stat rows */
.viz-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    padding: 2px 0;
}

.viz-stat-row .stat-label {
    color: var(--text-secondary);
}

.viz-stat-row .stat-value {
    font-weight: 500;
    font-family: monospace;
}

/* Sector marker on map */
.sector-marker-label {
    background: var(--accent, #ff6b35);
    color: white;
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    font-size: 0.733rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid rgba(0, 0, 0, 0.3);
}

/* Click hint on reference line */
.viz-ref-hint {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 4px;
}

/* ══════════════════════════════════════════
   Phase 6: In-app file browser
   ══════════════════════════════════════════ */

.file-browser {
    border: 1px solid var(--border);
    border-radius: var(--radius, 8px);
    overflow: hidden;
}

.file-browser-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.file-browser-title {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.file-browser-list {
    max-height: 280px;
    overflow-y: auto;
}

.file-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    transition: background 0.1s;
}

.file-row:last-child {
    border-bottom: none;
}

.file-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.file-row.selected {
    background: rgba(255, 107, 53, 0.08);
    border-left: 3px solid var(--accent);
}

.file-row-name {
    font-weight: 500;
}

.file-row-meta {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: right;
}

.file-browser-drop {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    border-top: 2px dashed var(--border);
    font-size: 0.82rem;
    transition: all 0.2s;
}

.file-browser-drop.drag-over {
    background: rgba(255, 107, 53, 0.06);
    border-color: var(--accent);
    color: var(--accent);
}

.file-browser-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

/* ══════════════════════════════════════════
   Phase 6: Nav dropdown
   ══════════════════════════════════════════ */

.nav-dropdown-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 340px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: var(--z-dropdown);
    margin-top: 4px;
}

.nav-dropdown.open {
    display: block;
}

.nav-dropdown-search {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.nav-dropdown-search input {
    width: 100%;
    padding: 0.4rem 0.6rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 4px);
    color: var(--text-primary);
    font-size: 0.82rem;
    outline: none;
}

.nav-dropdown-search input:focus {
    border-color: var(--accent);
}

.nav-dropdown-list {
    max-height: 320px;
    overflow-y: auto;
}

.nav-dropdown-item {
    display: block;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
    color: var(--text-primary);
    text-decoration: none;
}

.nav-dropdown-item:last-child {
    border-bottom: none;
}

.nav-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.nav-dropdown-item .session-meta {
    color: var(--text-secondary);
    font-size: 0.72rem;
    margin-top: 2px;
}

.nav-dropdown-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

/* ══════════════════════════════════════════
   Batch 5: Annotations
   ══════════════════════════════════════════ */

.annotation-card { background: var(--bg-secondary); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; border-left: 4px solid var(--border); }
.annotation-note { border-left-color: var(--blue); }
.annotation-issue { border-left-color: var(--red); }
.annotation-insight { border-left-color: var(--accent); }
.annotation-todo { border-left-color: var(--green); }
.annotation-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.annotation-date { color: var(--text-secondary); font-size: 0.85em; }
.annotation-tags { margin-top: 6px; }

/* ── Tags ────────────────────────────────── */

.tag { display: inline-block; background: var(--border); color: var(--text-secondary); padding: 2px 8px; border-radius: var(--radius-lg); font-size: 0.8em; margin: 2px; }

/* ── Template cards ──────────────────────── */

.template-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; min-width: 200px; max-width: 280px; transition: border-color 0.2s; }
.template-card:hover { border-color: var(--accent); }
.template-card h3 { margin: 0 0 6px; font-size: 1em; color: var(--accent); }
.template-card p { font-size: 0.85em; color: var(--text-secondary); margin: 0 0 8px; }

/* ── Plan cards ──────────────────────────── */

.plan-card { background: var(--bg-secondary); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; }
.plan-card h3 { margin: 0 0 8px; }

/* ── Progress bar ────────────────────────── */

.progress-bar { background: var(--border); border-radius: var(--radius-sm); height: 8px; overflow: hidden; }
.progress-fill { background: var(--green); height: 100%; transition: width 0.3s; }

/* ── Drill items ─────────────────────────── */

.drill-list { display: flex; flex-direction: column; gap: 8px; }
.drill-item { background: var(--bg-secondary); border-radius: var(--radius); padding: 12px 16px; }
.drill-item label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.drill-done { opacity: 0.6; }
.drill-item p { margin: 6px 0 4px 28px; font-size: 0.9em; color: var(--text-secondary); }

/* ══════════════════════════════════════════
   Batch 5: Dashboard grid
   ══════════════════════════════════════════ */

.dashboard-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.dashboard-widget { background: var(--bg-secondary); border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); }
.widget-header { background: var(--bg-secondary); padding: 8px 12px; font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-secondary); }
.widget-body { padding: 12px; color: var(--text-primary); min-height: 60px; }
.widget-body .data-table { margin: 0; font-size: 0.8rem; }
.widget-data-list { display: flex; flex-direction: column; gap: 6px; }
.widget-data-row { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0; border-bottom: 1px solid var(--border); }
.widget-data-row:last-child { border-bottom: none; }
.widget-data-key { font-size: 0.78rem; color: var(--text-muted); text-transform: capitalize; }
.widget-data-val { font-family: var(--font-mono); font-size: 0.82rem; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ── Dashboard/Widget cards ──────────────── */

.dashboard-card { background: var(--bg-secondary); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.dashboard-card h3 { margin: 0; flex: 1; }
.widget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(180px, 22vw, 260px), 1fr)); gap: 12px; }
.widget-card { background: var(--bg-secondary); border-radius: var(--radius); padding: 12px; }
.widget-card h3 { margin: 0 0 4px; font-size: 0.95em; }
.widget-card p { font-size: 0.85em; color: var(--text-secondary); margin: 0 0 6px; }

/* ══════════════════════════════════════════
   Batch 5: Export builder
   ══════════════════════════════════════════ */

.export-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(160px, 22vw, 240px), 1fr)); gap: 8px; }
.export-section-item { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--bg-secondary); border-radius: 6px; cursor: pointer; }

/* ══════════════════════════════════════════
   Batch 5: Button styles
   ══════════════════════════════════════════ */

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #c62828; }
.btn-secondary { background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { color: var(--text-primary); border-color: var(--text-muted); background: var(--bg-hover); }

/* ══════════════════════════════════════════
   Phase 7: Navigation improvements
   ══════════════════════════════════════════ */

/* ── Hamburger button (mobile) ─────────── */

.nav-hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    flex-direction: column;
    gap: 4px;
    z-index: var(--z-sticky);
}

.nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: var(--radius-xs);
    transition: all 0.3s ease;
}

.nav-hamburger.open span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}
.nav-hamburger.open span:nth-child(2) {
    opacity: 0;
}
.nav-hamburger.open span:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}

/* ── Dropdown trigger styling ──────────── */

.nav-dropdown-trigger {
    position: relative;
}

/* ── Dropdown menu improvements ────────── */

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    z-index: var(--z-dropdown);
    padding: 6px 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
}

.nav-dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0s;
}

/* Hover-open on desktop (pointer devices only, preserves click for touch) */
@media (min-width: 769px) and (hover: hover) {
    /* Invisible bridge between trigger and dropdown to prevent flicker */
    .nav-dropdown-wrap > .nav-dropdown-trigger::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: -8px;
        height: 8px;
    }

    .nav-dropdown-wrap:hover > .nav-dropdown-menu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateX(-50%) translateY(0);
        transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0s;
    }

    /* Also hover-open the Visualize session-search dropdown */
    .nav-dropdown-wrap:hover > .nav-dropdown {
        display: block;
    }
}

/* ── Dropdown item styling ─────────────── */

.nav-dropdown-menu .nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.85rem;
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: none;
    border-radius: var(--radius-sm);
    margin: 0 4px;
    transition: background 0.1s ease;
}

.nav-dropdown-menu .nav-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--accent);
}

.nav-dropdown-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-dropdown-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 10px;
}

/* ── Session detail tab navigation ─────── */

.session-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.session-tab {
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.15s ease;
    position: relative;
}

.session-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.session-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
    background: rgba(255, 107, 53, 0.04);
}

.session-tab .tab-count {
    display: inline-block;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 1px 5px;
    border-radius: var(--radius-pill);
    margin-left: 4px;
    font-weight: 500;
}

.session-tab.active .tab-count {
    background: var(--accent-glow);
    color: var(--accent);
}

.tab-panel {
    display: none;
    animation: tabFadeIn 0.25s ease both;
}

.tab-panel.active {
    display: block;
}

@keyframes tabFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .tab-panel {
        animation: none;
    }
}

/* ── Loading overlay ───────────────────── */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: var(--z-overlay);
    gap: 1.5rem;
    backdrop-filter: blur(4px);
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner-lg {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 1rem;
}

.loading-progress {
    width: 240px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
    overflow: hidden;
}

.loading-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-xs);
    transition: width 0.3s ease;
    width: 0%;
}

/* ── Toast notifications ───────────────── */

.toast-container {
    position: fixed;
    bottom: var(--space-5);
    right: var(--space-5);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    font-size: 0.88rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    animation: toastSlideIn var(--duration-normal) var(--ease-out);
    max-width: 380px;
    min-width: 260px;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
}

.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error { border-left: 3px solid var(--red); }
.toast.toast-info { border-left: 3px solid var(--blue); }
.toast.toast-warning { border-left: 3px solid var(--yellow); }

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 0.1rem;
}

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.toast-message {
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    min-width: 2rem;
    min-height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color var(--duration-normal) var(--ease-out);
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-primary);
}

.toast-close:focus-visible {
    color: var(--text-primary);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* Auto-dismiss progress bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--accent);
    transition: width linear;
    border-radius: 0 0 0 var(--radius);
}

.toast.toast-success .toast-progress { background: var(--green); }
.toast.toast-error .toast-progress { background: var(--red); }
.toast.toast-info .toast-progress { background: var(--blue); }
.toast.toast-warning .toast-progress { background: var(--yellow); }

/* Toast exit animation */
.toast.toast-exit {
    animation: toastSlideOut var(--duration-normal) var(--ease-out) forwards;
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .toast {
        animation-duration: 0.01ms;
    }
    .toast.toast-exit {
        animation-duration: 0.01ms;
    }
}

/* ── Modal ────────────────────────────────── */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal) var(--ease-out),
                visibility var(--duration-normal) var(--ease-out);
}

.modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(12px) scale(0.97);
    transition: transform var(--duration-normal) var(--ease-out);
}

.modal-backdrop.open .modal {
    transform: translateY(0) scale(1);
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
}

.modal__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast) var(--ease-out),
                background var(--duration-fast) var(--ease-out);
}

.modal__close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal__close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.modal__body {
    padding: var(--space-5);
    overflow-y: auto;
    flex: 1;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.6;
}

.modal__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border);
}

.modal--wide {
    max-width: 780px;
}

.modal--narrow {
    max-width: 400px;
}

@media (prefers-reduced-motion: reduce) {
    .modal-backdrop {
        transition-duration: 0.01ms;
    }
    .modal {
        transition-duration: 0.01ms;
    }
}

@media (max-width: 640px) {
    .modal {
        max-width: 100%;
        max-height: 92vh;
        border-radius: var(--radius) var(--radius) 0 0;
    }

    .modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }
}

/* ── Mobile responsive nav ─────────────── */

@media (max-width: 768px) {
    .nav-hamburger {
        display: flex;
    }

    .nav-links {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-secondary);
        flex-direction: column;
        padding: 1rem;
        gap: 0.25rem;
        overflow-y: auto;
        z-index: var(--z-sticky);
        border-top: 1px solid var(--border);
    }

    .nav-links.nav-open {
        display: flex;
    }

    .nav-links a,
    .nav-links .nav-dropdown-trigger {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        border-radius: var(--radius-sm);
        width: 100%;
    }

    .nav-dropdown-wrap {
        width: 100%;
    }

    .nav-dropdown-menu {
        position: static;
        transform: none;
        width: 100%;
        box-shadow: none;
        border: 1px solid var(--border);
        margin-top: 0.25rem;
        border-radius: var(--radius-sm);
        /* Reset desktop visibility-based hiding; use display for mobile */
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        display: none;
        transition: none;
    }

    .nav-dropdown-menu.open {
        display: block;
        transform: none;
    }

    .nav-cta {
        margin-top: 0.5rem;
        text-align: center;
        justify-content: center;
    }
}

/* ── Scroll-to-top button ──────────────── */

.scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s ease;
    z-index: var(--z-elevated);
    pointer-events: none;
}

.scroll-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.scroll-top:hover {
    background: var(--accent-dim);
    transform: translateY(-2px);
}

.scroll-top:focus-visible {
    background: var(--accent-dim);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── Skeleton loading ──────────────────── */

.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: var(--space-2);
}

.skeleton-text.skeleton-sm {
    height: 0.75rem;
}

.skeleton-text.skeleton-lg {
    height: 1.5rem;
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-card {
    aspect-ratio: 3 / 1;
    border-radius: var(--radius);
}

/* Skeleton stat grid */
.skeleton-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(120px, 15vw, 180px), 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.skeleton-stat {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
}

.skeleton-stat-label {
    height: 0.7rem;
    width: 60%;
    margin-bottom: var(--space-2);
}

.skeleton-stat-value {
    height: 1.5rem;
    width: 80%;
}

/* Skeleton table rows */
.skeleton-table-row {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.skeleton-table-cell {
    height: 0.85rem;
    flex: 1;
}

.skeleton-table-cell:first-child {
    flex: 0.5;
}

.skeleton-table-cell:last-child {
    flex: 0.7;
}

/* Skeleton chart */
.skeleton-chart {
    aspect-ratio: 2 / 1;
    border-radius: var(--radius);
    margin-bottom: var(--space-3);
}

/* Skeleton circle (avatar, badge) */
.skeleton-circle {
    border-radius: 50%;
}

.skeleton-circle-sm {
    width: 28px;
    height: 28px;
}

.skeleton-circle-md {
    width: 48px;
    height: 48px;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Loading overlay for async sections */
.section-loading {
    position: relative;
    min-height: 100px;
}

.section-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Pulse loading dot pattern */
.loading-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: dotPulse 1.4s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Grade badge S tier ──────────────── */

.grade-S { background: linear-gradient(135deg, #1a2a3a, #0a2a3a); color: #70d0ff; border: 1px solid #2a5a7a; }

/* ══════════════════════════════════════════
   Wizard Steps & Upload Progress
   ══════════════════════════════════════════ */

/* ── Wizard step indicator ───────────── */

.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 2rem;
    padding: 0 1rem;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

.wizard-step.active {
    opacity: 1;
}

.wizard-step.completed {
    opacity: 0.7;
}

.wizard-step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.wizard-step.active .wizard-step-num {
    background: linear-gradient(135deg, var(--accent) 0%, #e0601a 100%);
    border-color: var(--accent);
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(240, 112, 48, 0.15), 0 2px 12px rgba(240, 112, 48, 0.2);
}

.wizard-step.completed .wizard-step-num {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.wizard-step.completed .wizard-step-num::after {
    content: none;
}

.wizard-step-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.wizard-step.active .wizard-step-label {
    color: var(--text-primary);
}

.wizard-step-line {
    width: 60px;
    height: 2px;
    background: var(--border);
    margin: 0 0.5rem;
    transition: background 0.3s ease;
}

.wizard-step-line.completed {
    background: var(--green);
}

/* ── Wizard navigation ───────────────── */

.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── Upload progress ─────────────────── */

.upload-progress-wrap {
    margin-top: 0.75rem;
    padding: 0 0.75rem;
}

.upload-progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
    overflow: hidden;
    margin-bottom: 0.3rem;
}

.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: var(--radius-xs);
    width: 0%;
    transition: width 0.3s ease;
}

.upload-progress-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ── Corner picker (mid-analysis) ────── */

.corner-picker-panel {
    max-width: 680px;
    margin: 0 auto var(--sp-lg);
    padding: var(--sp-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    animation: fadeSlideIn 0.4s ease-out;
}
.corner-picker-panel.submitted {
    border-color: var(--green);
    opacity: 0.7;
    pointer-events: none;
}
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.corner-picker-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--sp-xs);
    text-align: center;
}
.corner-picker-hint {
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: var(--sp-md);
}
.corner-picker-map-wrap {
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: var(--sp-md);
}
.corner-picker-map-wrap canvas {
    display: block;
    max-width: 100%;
}
.corner-picker-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-sm);
}
.corner-picker-status {
    font-size: 0.82rem;
    font-weight: 600;
}
.corner-picker-status.status-ok   { color: var(--green); }
.corner-picker-status.status-warn { color: var(--yellow); }

/* ── Joker lap confirmation panel ────── */

.joker-confirm-panel {
    max-width: 720px;
    margin: 0 auto var(--sp-lg);
    padding: var(--sp-lg);
    background: var(--bg-secondary);
    border: 2px solid var(--orange, #e67e22);
    border-radius: var(--radius-md);
    animation: fadeSlideIn 0.4s ease-out;
}
.joker-confirm-panel.confirmed {
    border-color: var(--green);
    opacity: 0.7;
    pointer-events: none;
}
.joker-confirm-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--sp-xs);
    text-align: center;
}
.joker-confirm-hint {
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: var(--sp-md);
}
.joker-confirm-hint strong {
    color: var(--orange, #e67e22);
}
.joker-confirm-table-wrap {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: var(--sp-md);
    border-radius: var(--radius-sm);
}
.joker-confirm-table-wrap .table {
    font-size: 0.82rem;
}
.joker-candidate-highlight {
    background: rgba(230, 126, 34, 0.12);
}
.joker-candidate-highlight td {
    font-weight: 600;
}
.joker-confirm-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-sm);
}
.joker-confirm-status {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.joker-confirm-actions {
    display: flex;
    gap: var(--sp-sm);
}
.badge-joker {
    display: inline-block;
    padding: 0.1em 0.45em;
    border-radius: var(--radius-sm);
    background: var(--orange, #e67e22);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    vertical-align: middle;
}
.joker-lap {
    border-left: 3px solid var(--orange, #e67e22);
}

/* ── Analysis progress panel ─────────── */

.analysis-progress-panel {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 500px;
    margin: 0 auto;
}

.analysis-progress-icon {
    font-size: 3rem;
    animation: spin 2s linear infinite;
    margin-bottom: 1rem;
}

.analysis-progress-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.analysis-progress-subtitle {
    font-size: 0.95rem;
    color: var(--accent);
    margin-bottom: 1.5rem;
}

/* Pipeline stages */
.pipeline-stages {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    text-align: left;
    margin: 0 auto;
    max-width: 300px;
    margin-bottom: 1.5rem;
}

.pipeline-stage {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.pipeline-stage.active {
    color: var(--accent);
    font-weight: 600;
}

.pipeline-stage.completed {
    color: var(--green);
}

.pipeline-stage-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.pipeline-stage-dot.active {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(255, 107, 53, 0.4);
}

.pipeline-stage.completed .pipeline-stage-dot,
.pipeline-stage-dot.completed {
    background: var(--green);
    border-color: var(--green);
    box-shadow: none;
}

/* Overall progress bar */
.analysis-overall-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.analysis-overall-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: var(--radius-sm);
    transition: width 0.5s ease;
}

.analysis-elapsed {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ── Form validation feedback ────────── */

.form-input.invalid,
.form-select.invalid {
    border-color: var(--red);
    box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.15);
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

.form-error {
    font-size: 0.78rem;
    color: var(--red);
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.form-error::before {
    content: '!';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
}

.form-success {
    font-size: 0.78rem;
    color: var(--green);
    margin-top: 0.25rem;
}

/* ── Form loading spinner ──────────── */

.form-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 0.75rem;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ── Character counter ────────────── */

.char-counter {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 0.15rem;
}

.char-counter.warn {
    color: var(--yellow);
}

.char-counter.over {
    color: var(--red);
    font-weight: 600;
}

@media (max-width: 640px) {
    .wizard-steps {
        gap: 0;
    }
    .wizard-step-label {
        display: none;
    }
    .wizard-step-line {
        width: 30px;
    }
}

/* ══════════════════════════════════════════
   Comprehensive Mobile Responsiveness
   ══════════════════════════════════════════ */

@media (max-width: 768px) {
    /* ── Layout & spacing ────────────── */
    .main-content {
        padding: 0.75rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding-bottom: 0.75rem;
    }

    .page-header h1 {
        font-size: 1.3rem;
    }

    /* ── Stats grid: 2 columns on mobile ─── */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-label {
        font-size: 0.72rem;
    }

    /* ── Meta grid: 2 columns ───────────── */
    .meta-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    /* ── Tables: horizontal scroll ───────── */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }

    .data-table {
        font-size: 0.78rem;
        min-width: 600px;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem 0.4rem;
        white-space: nowrap;
    }

    /* ── Card grid: single column ────────── */
    .card-grid {
        grid-template-columns: 1fr;
    }

    /* ── Session tabs: scrollable ─────────── */
    .session-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 0;
        padding-bottom: 2px;
    }

    .session-tab {
        flex-shrink: 0;
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* ── Form sections ───────────────────── */
    .form-section {
        padding: 1rem;
    }

    .form-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .driver-row.form-row {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .driver-row .form-group {
        flex: 1 1 45% !important;
        min-width: 120px;
    }

    .checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* ── File browser ────────────────────── */
    .file-browser-toolbar {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .file-row {
        flex-direction: column;
        gap: 0.3rem;
    }

    .file-row-meta {
        font-size: 0.72rem;
    }

    /* ── Sections ────────────────────────── */
    .section {
        margin-bottom: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    /* ── Buttons ─────────────────────────── */
    .btn-lg {
        padding: 0.65rem 1.5rem;
        font-size: 0.9rem;
    }

    /* ── Compare page ────────────────────── */
    .compare-panels {
        grid-template-columns: 1fr;
    }

    .compare-grid {
        grid-template-columns: 1fr;
    }

    /* ── Leaderboard ─────────────────────── */
    .leaderboard-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .leaderboard-filters form {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* ── Development plans ────────────────── */
    .template-card {
        min-width: 100%;
        max-width: 100%;
    }

    /* ── Drill items ─────────────────────── */
    .drill-item {
        padding: 0.8rem;
    }

    /* ── Welcome hero ────────────────────── */
    .welcome-hero {
        padding: 2rem 1rem;
    }

    .welcome-hero h1 {
        font-size: 1.4rem;
    }

    .welcome-hero .welcome-subtitle {
        font-size: 0.9rem;
    }

    /* ── Empty hero ──────────────────────── */
    .empty-hero {
        padding: 2rem 1rem;
    }

    .empty-hero-icon {
        font-size: 2.5rem;
    }

    /* ── Feature hints ───────────────────── */
    .feature-hints {
        grid-template-columns: 1fr 1fr;
    }

    /* ── Pipeline progress ───────────────── */
    .analysis-progress-panel {
        padding: 2rem 1rem;
    }

    /* ── Score detail rows ───────────────── */
    .score-row {
        flex-direction: column;
        gap: 0.3rem;
    }

    /* ── Compact badges ──────────────────── */
    .badge {
        font-size: 0.68rem;
        padding: 0.1rem 0.35rem;
    }

    /* ── Visualization sidebar: stack on mobile ── */
    .viz-layout {
        flex-direction: column;
        height: auto;
    }

    .viz-sidebar {
        width: 100%;
        min-width: 0;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    /* ── Session picker dropdown: cap width ── */
    .nav-dropdown {
        width: min(340px, calc(100vw - 2rem));
    }

    /* Touch target minimum sizes */
    .tab-close-btn {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    input[type="checkbox"],
    input[type="radio"] {
        width: 22px;
        height: 22px;
    }
    .btn-xs {
        min-height: 36px;
        padding-inline: 12px;
    }
}

/* ── Small phones (< 480px) — compact KPI cards ── */
@media (max-width: 479px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .kpi-card, .stat-card {
        padding: var(--space-2) var(--space-2);
    }
    .kpi-card__value, .stat-value {
        font-size: var(--font-size-md);
    }
}

/* ── Extra small (phones < 400px) ─────── */
@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .feature-hints {
        grid-template-columns: 1fr;
    }

    .meta-grid {
        grid-template-columns: 1fr;
    }

    .session-tab {
        padding: 0.5rem 0.6rem;
        font-size: 0.75rem;
    }

    .data-table {
        font-size: 0.72rem;
    }

    .page-header h1 {
        font-size: 1.1rem;
    }

    .wizard-step-num {
        width: 26px;
        height: 26px;
        font-size: 0.75rem;
    }

    .wizard-step-line {
        width: 20px;
    }
}

/* ── Touch-friendly interactive targets ── */
@media (hover: none) {
    .clickable-row {
        cursor: default;
    }

    .clickable-row:active {
        background: var(--bg-hover);
    }

    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .cb-label {
        padding: 0.4rem 0;
    }

    input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    .form-select,
    .form-input {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
}

/* ══════════════════════════════════════════
   Visual Polish & Micro-interactions
   ══════════════════════════════════════════ */

/* ── Focus indicators (accessibility) ──── */

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn:focus-visible,
.card--interactive:focus-visible,
.chart-frame:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--accent-dim);
}

.form-input:focus-visible,
.form-select:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.nav-dropdown-item:focus-visible {
    outline: none;
    background: var(--bg-hover);
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-dropdown-trigger:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: var(--radius-sm);
}

/* Clickable table rows - keyboard accessible */
.clickable-row:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--accent);
}

/* Tab buttons focus */
.session-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Grade badges focus */
.grade:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* File row keyboard focus */
.file-row:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

/* Link focus inside cards */
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Analytics tool cards focus */
.analytics-tool-link:focus-visible .analytics-tool-card {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.analytics-tool-link:focus-visible {
    outline: none;
}

/* Compare column focus (for keyboard navigation) */
.compare-column:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-dim);
    border-color: var(--accent);
}

/* Badge focus (when used as interactive elements) */
.badge:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.badge-style:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Insight box focus */
.insight-box:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Stat card focus */
.stat-card:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-dim);
    border-color: var(--accent);
}

/* Template card focus (dev plan) */
.template-card:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-dim);
    border-color: var(--accent);
}

/* Annotation card focus */
.annotation-card:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Wizard step button focus */
.wizard-step:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius);
}

/* Canvas elements in charts - parent focus */
.chart-container:focus-within {
    border-color: var(--accent);
}

/* Score bar row focus (keyboard-navigable score breakdowns) */
.score-bar-row:focus-visible {
    outline: none;
    background: rgba(255, 107, 53, 0.08);
    box-shadow: inset 3px 0 0 var(--accent);
}

/* Textarea focus */
textarea:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Select (non-form-select) focus */
select:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Range slider focus */
input[type="range"]:focus-visible {
    outline: none;
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px var(--accent-dim);
}

/* ── Button press effect ─────────────── */

.btn:active {
    transform: scale(0.97);
}

.btn-primary:active {
    background: var(--accent-dim);
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(240, 112, 48, 0.2);
}

.btn-ghost:active {
    background: var(--bg-tertiary);
}

/* ── Card lift effect ────────────────── */

.track-card {
    transform: translateY(0);
}

.track-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.stat-card {
    transform: translateY(0);
    transition: all var(--duration-normal) ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* ── Clickable row glow ──────────────── */

.clickable-row {
    transition: background var(--duration-normal) var(--ease-out), box-shadow var(--duration-normal) var(--ease-out);
}

.clickable-row:hover {
    box-shadow: inset 3px 0 0 var(--accent);
}

/* ── Grade badges: enhanced ──────────── */

.grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.82rem;
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
    transition: transform var(--duration-normal) var(--ease-out);
}

.grade:hover {
    transform: scale(1.1);
}

.grade-S {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.15), rgba(112, 208, 255, 0.1));
    color: #70d0ff;
    border: 1px solid rgba(112, 208, 255, 0.25);
    text-shadow: 0 0 8px rgba(112, 208, 255, 0.3);
}

.grade-A {
    background: rgba(52, 211, 153, 0.12);
    color: var(--green);
    border: 1px solid rgba(52, 211, 153, 0.25);
}

.grade-B {
    background: rgba(163, 217, 119, 0.1);
    color: #a3d977;
    border: 1px solid rgba(163, 217, 119, 0.2);
}

.grade-C {
    background: rgba(251, 191, 36, 0.1);
    color: var(--yellow);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.grade-D {
    background: rgba(248, 113, 113, 0.1);
    color: var(--red);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.grade-F {
    background: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
    border: 1px solid rgba(255, 107, 107, 0.2);
}

/* ── Animated score bar ──────────────── */

.score-bar-fill {
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Smooth page transitions ─────────── */

.section {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Tab panel transition ────────────── */

.tab-panel {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Count badge pulse on hover ──────── */

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    margin-left: 0.4rem;
    vertical-align: middle;
    transition: background var(--duration-normal) var(--ease-out), color var(--duration-normal) var(--ease-out);
}

h1:hover .count-badge {
    background: var(--accent);
    color: #fff;
}

/* ── Session type badges: better colors ── */

.badge-qualifying { background: rgba(255, 107, 53, 0.15); color: var(--accent); }
.badge-race       { background: rgba(248, 81, 73, 0.15); color: var(--red); }
.badge-practice   { background: rgba(88, 166, 255, 0.15); color: var(--blue); }
.badge-warmup     { background: rgba(210, 153, 34, 0.15); color: var(--yellow); }
.badge-sprint     { background: rgba(188, 140, 255, 0.15); color: var(--purple); }
.badge-endurance  { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.badge-test       { background: rgba(139, 148, 158, 0.15); color: var(--text-secondary); }

/* ── Track condition badges ──────────── */

.badge-dry     { background: rgba(63, 185, 80, 0.12); color: var(--green); }
.badge-wet     { background: rgba(88, 166, 255, 0.12); color: var(--blue); }
.badge-damp    { background: rgba(88, 166, 255, 0.08); color: #7cb8e8; }
.badge-mixed   { background: rgba(210, 153, 34, 0.12); color: var(--yellow); }

/* ── Table header sticky (only inside sticky wrapper) ── */

.table-wrap-sticky .data-table thead th {
    position: sticky;
    top: 0;
    z-index: var(--z-elevated);
    background: var(--bg-secondary);
    box-shadow: 0 1px 0 var(--border);
}

/* ── Podium rows in leaderboard ──────── */

.podium-1 {
    border-left: 3px solid #ffd700;
}

.podium-2 {
    border-left: 3px solid #c0c0c0;
}

.podium-3 {
    border-left: 3px solid #cd7f32;
}

/* ── Rank badges ─────────────────────── */

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.rank-1 { background: rgba(255, 215, 0, 0.15); color: #ffd700; }
.rank-2 { background: rgba(192, 192, 192, 0.15); color: #c0c0c0; }
.rank-3 { background: rgba(205, 127, 50, 0.15); color: #cd7f32; }

/* ── Trend indicators ────────────────── */

.trend-up {
    color: var(--green);
    font-weight: 600;
    font-size: 0.82rem;
}

.trend-down {
    color: var(--red);
    font-weight: 600;
    font-size: 0.82rem;
}

.trend-stable {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

/* ── Scrollbar styling ───────────────── */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ── Selection color ─────────────────── */

::selection {
    background: rgba(255, 107, 53, 0.3);
    color: var(--text-primary);
}

/* ── Link underline on hover ─────────── */

a:hover {
    text-decoration-color: var(--accent);
}

/* ── Smooth scroll behavior ──────────── */

html {
    scroll-behavior: smooth;
}

/* ── Form section collapsible legend ──── */

.form-section legend {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    padding: 0 0.3rem;
}

/* ── Transition for interactive elements ── */

.track-card,
.stat-card,
.clickable-row,
.btn,
.badge,
.grade,
.file-row,
.template-card,
.plan-card,
.dashboard-card,
.widget-card,
.feature-hint {
    transition: all 0.2s ease;
}

/* ── File row hover ──────────────────── */

.file-row:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.file-row.selected {
    border-color: var(--accent);
    background: rgba(255, 107, 53, 0.06);
}

/* ── Nav brand hover animation ───────── */

.nav-brand:hover .nav-icon {
    animation: wobble 0.6s ease;
}

@keyframes wobble {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

/* ── Print styles ────────────────────── */

@media print {
    .top-nav,
    .site-footer,
    .scroll-top,
    .toast-container,
    .btn,
    .nav-hamburger {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }

    body {
        background: #fff;
        color: #000;
    }

    .data-table th,
    .data-table td {
        border: 1px solid #ccc;
    }
}

/* ── Driver profile editor ───────────── */

.profile-editor {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.profile-editor .form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.editable-field {
    width: 100%;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    font-family: var(--font-sans);
    transition: border-color var(--duration-normal) var(--ease-out), box-shadow var(--duration-normal) var(--ease-out);
}

.editable-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
}

textarea.editable-field {
    resize: vertical;
    min-height: 60px;
}

/* ── Add record form ─────────────────── */

.add-record-form summary {
    cursor: pointer;
    user-select: none;
}

.add-record-form[open] summary {
    margin-bottom: 0.5rem;
}

.add-record-form .form-row {
    flex-wrap: wrap;
}

.add-record-form .form-group {
    min-width: 120px;
}

.add-record-form input {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    width: 100%;
}

.add-record-form input:focus {
    outline: none;
    border-color: var(--accent);
}

@media (max-width: 768px) {
    .profile-editor .form-row {
        flex-direction: column;
    }

    .add-record-form .form-row {
        flex-direction: column;
    }

    .style-section {
        grid-template-columns: 1fr;
    }
}

/* ══════════════════════════════════════════
   CSS Utility Classes
   ══════════════════════════════════════════ */

/* ── Spacing utilities ────────────────── */

.mt-0  { margin-top: 0 !important; }
.mt-xs { margin-top: 0.25rem !important; }
.mt-sm { margin-top: 0.5rem !important; }
.mt-md { margin-top: 1rem !important; }
.mt-lg { margin-top: 1.5rem !important; }
.mt-xl { margin-top: 2rem !important; }

.mb-0  { margin-bottom: 0 !important; }
.mb-xs { margin-bottom: 0.25rem !important; }
.mb-sm { margin-bottom: 0.5rem !important; }
.mb-md { margin-bottom: 1rem !important; }
.mb-lg { margin-bottom: 1.5rem !important; }
.mb-xl { margin-bottom: 2rem !important; }

.ml-0  { margin-left: 0 !important; }
.ml-sm { margin-left: 0.5rem !important; }
.ml-md { margin-left: 1rem !important; }
.ml-lg { margin-left: 1.5rem !important; }

.mr-0  { margin-right: 0 !important; }
.mr-sm { margin-right: 0.5rem !important; }
.mr-md { margin-right: 1rem !important; }

.p-0  { padding: 0 !important; }
.p-sm { padding: 0.5rem !important; }
.p-md { padding: 1rem !important; }
.p-lg { padding: 1.5rem !important; }

.py-sm { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-md { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.px-sm { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
.px-md { padding-left: 1rem !important; padding-right: 1rem !important; }

.gap-0  { gap: 0 !important; }
.gap-xs { gap: 0.25rem !important; }
.gap-sm { gap: 0.5rem !important; }
.gap-md { gap: 1rem !important; }
.gap-lg { gap: 1.5rem !important; }

/* ── Display utilities ────────────────── */

.hidden     { display: none !important; }
.invisible  { visibility: hidden !important; }
.block      { display: block !important; }
.inline     { display: inline !important; }
.inline-blk { display: inline-block !important; }
.flex        { display: flex !important; }
.inline-flex { display: inline-flex !important; }
.grid        { display: grid !important; }

/* ── Flexbox utilities ────────────────── */

.flex-row     { flex-direction: row !important; }
.flex-col     { flex-direction: column !important; }
.flex-wrap    { flex-wrap: wrap !important; }
.flex-nowrap  { flex-wrap: nowrap !important; }
.flex-1       { flex: 1 1 0% !important; }
.flex-2       { flex: 2 1 0% !important; }
.flex-auto    { flex: 1 1 auto !important; }
.flex-none    { flex: none !important; }

.items-start   { align-items: flex-start !important; }
.items-center  { align-items: center !important; }
.items-end     { align-items: flex-end !important; }
.items-stretch { align-items: stretch !important; }

.justify-start   { justify-content: flex-start !important; }
.justify-center  { justify-content: center !important; }
.justify-end     { justify-content: flex-end !important; }
.justify-between { justify-content: space-between !important; }

.flex-center-gap {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

/* ── Text utilities ───────────────────── */

.text-xs   { font-size: 0.72rem !important; }
.text-sm   { font-size: 0.85rem !important; }
.text-base { font-size: 1rem !important; }
.text-lg   { font-size: 1.15rem !important; }
.text-xl   { font-size: 1.35rem !important; }

.text-left   { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right  { text-align: right !important; }

.font-normal { font-weight: 400 !important; }
.font-medium { font-weight: 500 !important; }
.font-semi   { font-weight: 600 !important; }
.font-bold   { font-weight: 700 !important; }
.font-mono   { font-family: var(--font-mono) !important; }

.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-accent    { color: var(--accent) !important; }
.good-text      { color: var(--green) !important; }
.warn-text      { color: var(--yellow) !important; }
.error-text     { color: var(--red) !important; }
.info-text      { color: var(--blue) !important; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.whitespace-nowrap { white-space: nowrap !important; }

/* ── Width / max-width utilities ──────── */

.w-full     { width: 100% !important; }
.w-auto     { width: auto !important; }
.max-w-xs   { max-width: 12.5rem !important; }
.max-w-sm   { max-width: 18.75rem !important; }
.max-w-md   { max-width: 31.25rem !important; }
.max-w-lg   { max-width: 43.75rem !important; }

/* ── Border & radius utilities ────────── */

.rounded     { border-radius: var(--radius) !important; }
.rounded-sm  { border-radius: var(--radius-sm) !important; }
.rounded-lg  { border-radius: 12px !important; }
.rounded-full { border-radius: 9999px !important; }
.border      { border: 1px solid var(--border) !important; }
.border-0    { border: 0 !important; }

/* ── Background utilities ─────────────── */

.bg-card     { background: var(--bg-secondary) !important; }
.bg-surface  { background: var(--bg-tertiary) !important; }
.bg-hover    { background: var(--bg-hover) !important; }
.bg-tertiary { background: var(--bg-tertiary) !important; }

/* ── Opacity / cursor utilities ───────── */

.opacity-50  { opacity: 0.5 !important; }
.opacity-75  { opacity: 0.75 !important; }
.cursor-ptr  { cursor: pointer !important; }
.cursor-def  { cursor: default !important; }
.pointer-events-none { pointer-events: none !important; }

/* ── Overflow ─────────────────────────── */

.overflow-hidden  { overflow: hidden !important; }
.overflow-x-auto  { overflow-x: auto !important; }
.overflow-y-auto  { overflow-y: auto !important; }

/* ── Position ─────────────────────────── */

.relative { position: relative !important; }
.absolute { position: absolute !important; }
.sticky   { position: sticky !important; }

/* ── Layout compound patterns ─────────── */

.flex-wrap-start {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-start;
}

.grid-2col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(280px, 40vw, 500px), 1fr));
    gap: 1rem;
}

@media (max-width: 640px) {
    .grid-2col {
        grid-template-columns: 1fr;
    }
}

.chart-canvas {
    max-width: 100%;
}

.chart-sidebar {
    flex: 1;
    min-width: 200px;
}

.coaching-below {
    margin-top: 0.8rem;
}

.chart-container-rel {
    position: relative;
}

/* ── Loading state containers ──────────── */

.loading-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem;
}

.loading-center .spinner-inline {
    width: 20px;
    height: 20px;
}

/* ══════════════════════════════════════════
   Development Plan Detail Styles
   ══════════════════════════════════════════ */

/* ── Overall progress bar ─────────────── */

.plan-progress {
    margin-bottom: 1.5rem;
    height: 12px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    overflow: hidden;
}

.plan-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--green));
    border-radius: 6px;
    transition: width 0.4s ease;
}

/* ── Plan info banner ─────────────────── */

.plan-about {
    background: rgba(54, 162, 235, 0.06);
    border-left: 3px solid var(--blue);
    padding: 0.8rem 1.2rem;
    border-radius: 6px;
    margin-bottom: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.plan-about strong {
    color: var(--blue);
}

/* ── Week card ────────────────────────── */

.plan-week {
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
}

.plan-week-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.plan-week-num {
    background: linear-gradient(135deg, var(--blue), #1a73c7);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.plan-week-title {
    margin: 0;
    font-size: 1.3rem;
    color: #e0e0e0;
}

.plan-week-focus {
    margin: 0.3rem 0 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ── Callout boxes (coaching, warmup) ─── */

.plan-callout {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.plan-callout-coaching {
    background: rgba(255, 215, 0, 0.05);
    border-left: 3px solid #ffd700;
}

.plan-callout-coaching strong {
    color: #ffd700;
}

.plan-callout-warmup {
    background: rgba(76, 175, 80, 0.05);
    border-left: 3px solid var(--green);
    margin-bottom: 1.2rem;
}

.plan-callout-warmup strong {
    color: var(--green);
}

/* ── Drill list ───────────────────────── */

.plan-drill-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ── Drill item ───────────────────────── */

.plan-drill {
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 1.2rem;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.03);
}

.plan-drill.done {
    background: rgba(76, 175, 80, 0.06);
    border-color: rgba(76, 175, 80, 0.2);
}

.plan-drill-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.plan-drill-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    flex: 1;
}

.plan-drill-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--green);
    cursor: pointer;
}

.plan-drill-name {
    font-size: 1rem;
    color: var(--text-primary);
}

.plan-drill.done .plan-drill-name {
    color: var(--green);
}

.plan-drill-badges {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.plan-badge-difficulty {
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    background: rgba(255, 152, 0, 0.15);
    color: var(--accent);
}

.plan-badge-duration {
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    background: rgba(54, 162, 235, 0.15);
    color: var(--blue);
}

.plan-drill-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0 0 0.6rem 0;
}

/* ── Target badge ─────────────────────── */

.plan-target {
    margin-bottom: 0.8rem;
}

.plan-target-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius);
    background: rgba(76, 175, 80, 0.12);
    color: var(--green);
    font-weight: 600;
}

.plan-metric-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    margin-left: 0.3rem;
}

/* ── Expandable sections ──────────────── */

.plan-details {
    margin-bottom: 0.6rem;
}

.plan-details summary {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.3rem 0;
}

.plan-details-instructions summary {
    color: var(--blue);
}

.plan-details-tips summary {
    color: var(--green);
}

.plan-details-mistakes summary {
    color: var(--red);
}

.plan-details-body {
    padding: 0.6rem 0 0.6rem 1rem;
    margin-top: 0.4rem;
}

.plan-details-instructions .plan-details-body {
    border-left: 2px solid rgba(54, 162, 235, 0.3);
}

.plan-details-tips .plan-details-body {
    border-left: 2px solid rgba(76, 175, 80, 0.3);
}

.plan-details-mistakes .plan-details-body {
    border-left: 2px solid rgba(231, 76, 60, 0.3);
}

.plan-details-text {
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.5;
    margin: 0 0 0.6rem 0;
}

.plan-steps-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.4rem;
    font-weight: 600;
    margin-top: 0.6rem;
}

.plan-steps-list {
    margin: 0;
    padding-left: 1.4rem;
    color: #c0c0c0;
    font-size: 0.8rem;
    line-height: 1.6;
}

.plan-steps-list li {
    margin-bottom: 0.3rem;
}

.plan-tips-list {
    margin: 0;
    padding-left: 1.2rem;
    color: #b8d8b8;
    font-size: 0.8rem;
    line-height: 1.6;
}

.plan-tips-list li {
    margin-bottom: 0.25rem;
}

.plan-mistakes-list {
    margin: 0;
    padding-left: 1.2rem;
    color: #e8b0a8;
    font-size: 0.8rem;
    line-height: 1.6;
}

.plan-mistakes-list li {
    margin-bottom: 0.25rem;
}

/* ── Success criteria ─────────────────── */

.plan-success {
    background: rgba(76, 175, 80, 0.06);
    border-radius: 6px;
    padding: 0.5rem 0.8rem;
    margin-top: 0.4rem;
}

.plan-success-label {
    font-size: 0.7rem;
    color: var(--green);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.plan-success-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ══════════════════════════════════════════
   Filter Bar & Leaderboard Styles
   ══════════════════════════════════════════ */

.filter-bar {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.filter-label + .filter-label {
    margin-left: 1rem;
}

.form-select.w-auto {
    width: auto;
}

.driver-name-cell {
    font-family: var(--font-sans);
    font-weight: 600;
}

.page-header .subtitle {
    font-weight: normal;
    margin-left: 0.5rem;
}

@media (max-width: 768px) {
    .plan-week {
        padding: 1rem;
    }

    .plan-week-num {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .plan-week-title {
        font-size: 1.1rem;
    }

    .plan-drill {
        padding: 0.8rem;
    }

    .plan-drill-badges {
        display: none;
    }
}

/* ── Narrow viewport (< 400px) ──────────────────── */
@media (max-width: 400px) {
    .nav-dropdown {
        width: calc(100vw - 2rem);
        max-width: 340px;
    }
    .template-card {
        min-width: 0;
        max-width: none;
    }
}

/* ══════════════════════════════════════════
   Quality Badge System (Data Health)
   ══════════════════════════════════════════ */

.quality-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    min-width: 2rem;
}

.quality-badge.quality-lg {
    padding: 0.2rem 0.6rem;
    font-size: 0.85rem;
    min-width: 3rem;
}

.quality-good {
    background: rgba(63, 185, 80, 0.15);
    color: var(--green);
}

.quality-ok {
    background: rgba(210, 153, 34, 0.15);
    color: var(--yellow);
}

.quality-poor {
    background: rgba(248, 81, 73, 0.15);
    color: var(--red);
}

/* ══════════════════════════════════════════
   Button Loading & Disabled States
   ══════════════════════════════════════════ */

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.75;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

.btn-ghost.btn-loading::after {
    border-color: rgba(139, 148, 158, 0.3);
    border-top-color: var(--text-secondary);
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

.btn[disabled],
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Button with icon ────────────────── */

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-icon .icon {
    font-size: 1.1em;
    line-height: 1;
}

/* ══════════════════════════════════════════
   Fetch Error & Retry Component
   ══════════════════════════════════════════ */

.fetch-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--text-secondary);
}

.fetch-error-icon {
    font-size: 2rem;
    opacity: 0.5;
}

.fetch-error-message {
    font-size: 0.85rem;
    max-width: 300px;
    line-height: 1.5;
}

.fetch-error .btn-retry {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
}

.fetch-error .btn-retry:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.fetch-error .btn-retry:active {
    transform: scale(0.97);
}

/* ── No data (different from error) ──── */

.no-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.no-data-icon {
    font-size: 1.5rem;
    opacity: 0.4;
}

.no-data-text {
    font-size: 0.82rem;
    line-height: 1.4;
}

/* ── Inline loading spinner ────────── */

.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(139, 148, 158, 0.3);
    border-top-color: var(--text-secondary);
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    vertical-align: middle;
}

.spinner-inline.spinner-accent {
    border-color: rgba(255, 107, 53, 0.2);
    border-top-color: var(--accent);
}

/* ══════════════════════════════════════════
   Enhanced Tablet Breakpoint (481–768px)
   ══════════════════════════════════════════ */

@media (min-width: 481px) and (max-width: 768px) {
    /* ── Card grids: 2 columns on tablet ──── */
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* ── Checkboxes: 3 columns on tablet ──── */
    .checkbox-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* ── Dev plan template cards ──────────── */
    .template-card {
        min-width: calc(50% - 0.5rem);
    }

    /* ── Weekend/compare toolbars inline ──── */
    .compare-toolbar {
        flex-direction: row;
        align-items: center;
    }
}

/* ══════════════════════════════════════════
   Landscape Phone Orientation
   ══════════════════════════════════════════ */

@media (max-height: 500px) and (orientation: landscape) {
    .top-nav {
        padding: 0.3rem 1rem;
    }

    .main-content {
        padding: 0.5rem 1rem;
    }

    .page-header {
        margin-bottom: 0.5rem;
    }

    .page-header h1 {
        font-size: 1.2rem;
    }

    .empty-hero {
        padding: 1.5rem 1rem;
    }

    .empty-hero-icon {
        font-size: 2rem;
    }

    /* Reduce vertical gaps */
    .section {
        margin-bottom: 0.75rem;
    }

    .stats-grid,
    .meta-grid {
        gap: 0.4rem;
    }
}

/* ══════════════════════════════════════════
   High-Resolution / 4K Screens
   ══════════════════════════════════════════ */

@media (min-width: 1600px) {
    .main-content {
        padding: 1rem 2rem;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(clamp(160px, 22vw, 240px), 1fr));
    }

    .meta-grid {
        grid-template-columns: repeat(auto-fill, minmax(clamp(180px, 22vw, 260px), 1fr));
    }

    .page-header h1 {
        font-size: 2rem;
    }

    .data-table {
        font-size: 0.92rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 1rem;
    }
}

/* ══════════════════════════════════════════
   Reduced Motion Preference
   ══════════════════════════════════════════ */

@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;
    }

    .skeleton,
    .skeleton::after {
        animation: none !important;
    }

    .toast {
        animation: none !important;
    }

    .btn:active {
        transform: none;
    }

    .track-card:hover,
    .stat-card:hover {
        transform: none;
    }
}

/* ══════════════════════════════════════════
   Custom Scrollbar (Dark Theme)
   ══════════════════════════════════════════ */

/* Webkit browsers (Chrome, Edge, Safari) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
    border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

::-webkit-scrollbar-corner {
    background: var(--bg-primary);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-primary);
}

/* Table wrap: narrower scrollbar */
.table-wrap::-webkit-scrollbar {
    height: 6px;
}

.table-wrap::-webkit-scrollbar-thumb {
    border-radius: var(--radius-xs);
    border: 1px solid var(--bg-primary);
}

/* ══════════════════════════════════════════
   Page Entrance Animation
   ══════════════════════════════════════════ */

.main-content {
    animation: page-enter 0.3s ease-out;
}

@keyframes page-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ══════════════════════════════════════════
   Enhanced Link & Anchor Styles
   ══════════════════════════════════════════ */

.main-content a:not(.btn):not(.nav-dropdown-item):not(.clickable-row):not(.breadcrumb):not([class*="badge"]) {
    color: var(--blue);
    text-decoration: none;
    transition: color var(--duration-normal) var(--ease-out);
}

.main-content a:not(.btn):not(.nav-dropdown-item):not(.clickable-row):not(.breadcrumb):not([class*="badge"]):hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ── Breadcrumb link style ────────────── */

.breadcrumb {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color var(--duration-normal) var(--ease-out);
}

.breadcrumb:hover {
    color: var(--accent);
}

/* ══════════════════════════════════════════
   Selection Highlight
   ══════════════════════════════════════════ */

::selection {
    background: rgba(255, 107, 53, 0.3);
    color: var(--text-primary);
}

::-moz-selection {
    background: rgba(255, 107, 53, 0.3);
    color: var(--text-primary);
}

/* ══════════════════════════════════════════
   CSS-Only Tooltip System
   Usage: <span class="tip" data-tip="Tooltip text">Hover me</span>
   Positions: .tip-top (default), .tip-bottom, .tip-left, .tip-right
   ══════════════════════════════════════════ */

.tip {
    position: relative;
    cursor: help;
}

.tip::after {
    content: attr(data-tip);
    position: absolute;
    z-index: var(--z-overlay);
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--bg-elevated, #23272e);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 4px);
    padding: 0.4rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.4;
    white-space: nowrap;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tip::before {
    content: '';
    position: absolute;
    z-index: var(--z-overlay);
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.tip:hover::after,
.tip:focus::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.tip:hover::before,
.tip:focus::before {
    opacity: 1;
}

/* Bottom tooltip */
.tip-bottom::after {
    bottom: auto;
    top: calc(100% + 8px);
    transform: translateX(-50%) translateY(-4px);
}

.tip-bottom::before {
    bottom: auto;
    top: calc(100% + 3px);
    border-top-color: transparent;
    border-bottom-color: var(--border);
}

.tip-bottom:hover::after,
.tip-bottom:focus::after {
    transform: translateX(-50%) translateY(0);
}

/* Left tooltip */
.tip-left::after {
    bottom: auto;
    top: 50%;
    left: auto;
    right: calc(100% + 8px);
    transform: translateY(-50%) translateX(4px);
}

.tip-left::before {
    bottom: auto;
    top: 50%;
    left: auto;
    right: calc(100% + 3px);
    transform: translateY(-50%);
    border-top-color: transparent;
    border-left-color: var(--border);
}

.tip-left:hover::after,
.tip-left:focus::after {
    transform: translateY(-50%) translateX(0);
}

/* Right tooltip */
.tip-right::after {
    bottom: auto;
    top: 50%;
    left: calc(100% + 8px);
    transform: translateY(-50%) translateX(-4px);
}

.tip-right::before {
    bottom: auto;
    top: 50%;
    left: calc(100% + 3px);
    transform: translateY(-50%);
    border-top-color: transparent;
    border-right-color: var(--border);
}

.tip-right:hover::after,
.tip-right:focus::after {
    transform: translateY(-50%) translateX(0);
}

/* Multiline tooltip */
.tip-wrap::after {
    white-space: normal;
    text-align: left;
    width: max-content;
}

/* Wider tooltip for section info tips */
h2 .tip-wrap::after {
    max-width: 360px;
}

/* ══════════════════════════════════════════
   Enhanced Stat Cards with Trend Indicators
   ══════════════════════════════════════════ */

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.35rem;
}

.stat-trend-up {
    color: var(--green);
}

.stat-trend-down {
    color: var(--red);
}

.stat-trend-flat {
    color: var(--text-muted);
}

.stat-trend-arrow {
    font-size: 0.85rem;
    line-height: 1;
}

.stat-trend-up .stat-trend-arrow::before {
    content: '\25B2';
}

.stat-trend-down .stat-trend-arrow::before {
    content: '\25BC';
}

.stat-trend-flat .stat-trend-arrow::before {
    content: '\2014';
}

/* Stat card icon (optional) */
.stat-icon {
    font-size: 1.4rem;
    margin-bottom: 0.3rem;
    opacity: 0.6;
}

/* Stat card with mini sparkline area */
.stat-sparkline {
    margin-top: 0.5rem;
    height: 24px;
    width: 100%;
}

/* Stat value colour variants */
.stat-value-good { color: var(--green); }
.stat-value-ok { color: var(--yellow); }
.stat-value-bad { color: var(--red); }
.stat-value-accent { color: var(--accent); }

/* Stat card mini-badge (e.g. "+5%") */
.stat-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-pill);
    margin-left: 0.3rem;
    vertical-align: middle;
}

.stat-badge-positive {
    background: rgba(76, 175, 80, 0.15);
    color: var(--green);
}

.stat-badge-negative {
    background: rgba(239, 83, 80, 0.15);
    color: var(--red);
}

.stat-badge-neutral {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

/* ══════════════════════════════════════════
   Enhanced Wizard Steps
   ══════════════════════════════════════════ */

.wizard-step {
    transition: opacity 0.2s ease;
    position: relative;
}

.wizard-step-num {
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
}

.wizard-step.active .wizard-step-num {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.2);
}

.wizard-step.completed .wizard-step-num::after {
    content: '\2713';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
}

.wizard-step-line {
    transition: background 0.3s ease;
    position: relative;
    overflow: hidden;
}

.wizard-step-line.completed::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--green);
    animation: wizard-line-fill 0.4s ease forwards;
}

@keyframes wizard-line-fill {
    from { transform: scaleX(0); transform-origin: left; }
    to { transform: scaleX(1); transform-origin: left; }
}

/* Pipeline stage checkmark animation */
.pipeline-stage.completed::before {
    content: '\2713';
    font-size: 0.7rem;
    color: var(--green);
    margin-right: 0.25rem;
    animation: stage-check 0.2s ease;
}

@keyframes stage-check {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Pipeline active stage pulse */
.pipeline-stage-dot.active {
    animation: dot-pulse 1.2s ease-in-out infinite;
}

@keyframes dot-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(255, 107, 53, 0); }
}

/* Analysis overall bar shimmer */
.analysis-overall-fill {
    position: relative;
    overflow: hidden;
}

.analysis-overall-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    animation: bar-shimmer 1.5s ease-in-out infinite;
    will-change: transform;
}

@keyframes bar-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(300%); }
}

/* ══════════════════════════════════════════
   Form Section Divider (replaces inline border-top)
   ══════════════════════════════════════════ */

.form-divider {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

.form-divider-label {
    font-weight: 600;
    color: var(--text-primary);
    display: block;
    margin-bottom: 0.5rem;
}

/* Driver row flex proportions */
.driver-col-name { flex: 2; }
.driver-col-lap { flex: 1; }
.driver-col-action { flex: 0.5; align-self: flex-end; }

/* Selected file info display */
.selected-file-info {
    padding: 0.4rem 0.75rem;
    color: var(--accent);
}

/* ══════════════════════════════════════════
   Action Button Groups & Inline Forms
   ══════════════════════════════════════════ */

.action-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.inline-delete-form {
    display: inline;
}

.btn-danger-text {
    color: var(--red);
}

.btn-compact { /* alias for .btn-xs – use .btn-xs in new code */
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

.compare-btn-compact { /* alias for .btn-sm – use .btn-sm in new code */
    font-size: 0.82rem;
    padding: 0.4rem 1rem;
}

/* Checkbox column width */
.col-checkbox { width: 40px; }

/* Form layout variants */
.form-add-session {
    max-width: 700px;
    align-items: flex-end;
}

.form-col-wide { flex: 3; position: relative; }
.form-col-narrow { flex: 0.5; }

/* Rename form hidden by default */
.rename-form-wrap {
    display: none;
    margin-top: 0.5rem;
}

.rename-form-wrap.visible {
    display: block;
}

.rename-input { max-width: clamp(200px, 50vw, 350px); }
.rename-trigger { margin-top: 0.25rem; }

/* ── Podium Graphic ──────────────────────── */
.podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem 1rem 0;
    max-width: 600px;
    margin: 0 auto;
}
.podium-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
    max-width: 180px;
}
.podium-rank {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
}
.podium-1st .podium-rank { color: #ffd700; }
.podium-2nd .podium-rank { color: #c0c0c0; }
.podium-3rd .podium-rank { color: #cd7f32; }

.podium-time {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary, #e6edf3);
    margin-bottom: 0.15rem;
}
.podium-1st .podium-time { font-size: 1.5rem; }

.podium-name {
    font-size: 0.85rem;
    color: var(--text-secondary, #8b949e);
    margin-bottom: 0.15rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.podium-date {
    font-size: 0.7rem;
    color: var(--text-muted, #484f58);
    margin-bottom: 0.35rem;
}

.podium-bar {
    width: 100%;
    border-radius: 6px 6px 0 0;
}
.podium-bar-1st {
    height: 100px;
    background: linear-gradient(180deg, rgba(255,215,0,0.35) 0%, rgba(255,215,0,0.10) 100%);
    border: 1px solid rgba(255,215,0,0.4);
    border-bottom: none;
}
.podium-bar-2nd {
    height: 70px;
    background: linear-gradient(180deg, rgba(192,192,192,0.25) 0%, rgba(192,192,192,0.08) 100%);
    border: 1px solid rgba(192,192,192,0.3);
    border-bottom: none;
}
.podium-bar-3rd {
    height: 50px;
    background: linear-gradient(180deg, rgba(205,127,50,0.25) 0%, rgba(205,127,50,0.08) 100%);
    border: 1px solid rgba(205,127,50,0.3);
    border-bottom: none;
}

@media (max-width: 480px) {
    .podium { gap: 0.4rem; padding: 1rem 0.5rem 0; }
    .podium-time { font-size: 1rem; }
    .podium-1st .podium-time { font-size: 1.15rem; }
    .podium-bar-1st { height: 70px; }
    .podium-bar-2nd { height: 50px; }
    .podium-bar-3rd { height: 35px; }
}

/* ── Key Corner Picker ───────────────────── */
.key-corner-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.key-corner-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}
.key-corner-chip:hover {
    border-color: var(--accent);
}
.key-corner-chip.active {
    border-color: var(--accent);
    background: rgba(255, 107, 53, 0.12);
}
.key-corner-chip input[type="checkbox"] {
    accent-color: var(--accent);
    margin: 0;
}
.chip-label {
    font-weight: 600;
    font-size: 0.9rem;
}
.chip-stat {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Add record spacing */
.add-record-wrap { margin-top: 1rem; }
.add-record-body { margin-top: 0.75rem; }
.form-col-end { align-self: end; }

/* Search dropdown text variant */
.search-no-results { color: var(--text-secondary); }

/* Chart relative positioning */
.chart-container-rel { position: relative; }

/* Track map height */
.gps-map-tall { aspect-ratio: 4 / 3; }

/* Order input width */
.input-narrow { width: 80px; }

/* ══════════════════════════════════════════
   Badge Hover & Interaction States
   ══════════════════════════════════════════ */

.badge {
    transition: filter 0.15s ease, transform 0.15s ease;
}

.badge:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

/* Session type badge enhanced saturation */
.badge-practice  { border: 1px solid rgba(63, 185, 80, 0.2); }
.badge-qualifying { border: 1px solid rgba(210, 153, 34, 0.2); }
.badge-race      { border: 1px solid rgba(248, 81, 73, 0.2); }
.badge-test      { border: 1px solid rgba(88, 166, 255, 0.2); }

/* Weather/condition badge borders */
.badge-dry   { border: 1px solid rgba(124, 201, 124, 0.15); }
.badge-wet   { border: 1px solid rgba(124, 156, 201, 0.15); }
.badge-damp  { border: 1px solid rgba(201, 201, 124, 0.15); }
.badge-mixed { border: 1px solid rgba(201, 124, 201, 0.15); }

/* Additional session type badge variants */
.badge-warmup     { background: rgba(251, 191, 36, 0.1); color: var(--yellow); border: 1px solid rgba(251, 191, 36, 0.2); }
.badge-sprint     { background: rgba(167, 139, 250, 0.1); color: var(--purple); border: 1px solid rgba(167, 139, 250, 0.2); }
.badge-endurance  { background: rgba(52, 211, 153, 0.1); color: #7cc9c9; border: 1px solid rgba(124, 201, 201, 0.2); }
.badge-heat       { background: rgba(248, 113, 113, 0.1); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.2); }
.badge-final      { background: rgba(251, 191, 36, 0.1); color: var(--yellow); border: 1px solid rgba(251, 191, 36, 0.2); }

/* Badge best enhanced */
.badge-best {
    box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.15);
}

/* Grade hover state */
.grade {
    transition: filter 0.15s ease, box-shadow 0.15s ease;
}

.grade:hover {
    filter: brightness(1.15);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Driving style badge enhancement */
.badge-style {
    transition: filter 0.15s ease, box-shadow 0.15s ease;
}

.badge-style.smooth       { border: 1px solid rgba(88,166,255,0.25); }
.badge-style.aggressive   { border: 1px solid rgba(248,81,73,0.25); }
.badge-style.conservative { border: 1px solid rgba(210,153,34,0.25); }
.badge-style.adaptive     { border: 1px solid rgba(188,140,255,0.25); }

.badge-style:hover {
    filter: brightness(1.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ══════════════════════════════════════════
   Card Hover Consistency
   ══════════════════════════════════════════ */

/* Compare cards */
.compare-column {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.compare-column:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    border-color: var(--text-muted);
}

/* Insight box enhanced hover */
.insight-box {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.insight-box:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
}

.insight-box.good:hover {
    border-color: var(--green);
}

.insight-box.warn:hover {
    border-color: var(--yellow);
}

/* Meta item enhanced hover */
.meta-item {
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.meta-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Score bar row hover highlight */
.score-bar-row {
    transition: background 0.15s ease;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    margin: 0 -0.4rem;
}

.score-bar-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Compare badge ring effect */
.compare-badge {
    transition: box-shadow 0.2s ease;
}

.compare-a .compare-badge:hover,
.compare-a:hover .compare-badge {
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.25);
}

.compare-b .compare-badge:hover,
.compare-b:hover .compare-badge {
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.25);
}

/* Badge brightens on parent clickable-row hover */
.clickable-row:hover .badge {
    filter: brightness(1.15);
}

.clickable-row:hover .grade {
    filter: brightness(1.1);
}

/* ══════════════════════════════════════════
   Session List Batch Actions
   ══════════════════════════════════════════ */

.batch-actions {
    margin-bottom: 0.75rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.batch-status {
    color: var(--accent);
}

/* ══════════════════════════════════════════
   Tab Panel Transition Enhancement
   ══════════════════════════════════════════ */

.session-tab {
    transition: background var(--duration-normal) var(--ease-out), color var(--duration-normal) var(--ease-out), transform 0.15s ease;
}

.session-tab:hover {
    transform: translateY(-1px);
}

/* Tab count badge brightens on tab hover */
.session-tab:hover .tab-count {
    filter: brightness(1.2);
}

/* ══════════════════════════════════════════
   Grid Column Utilities
   ══════════════════════════════════════════ */

.grid-cols-2 { grid-template-columns: repeat(2, 1fr) !important; }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr) !important; }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr) !important; }

/* ══════════════════════════════════════════
   Custom Checkbox Styling
   ══════════════════════════════════════════ */

input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    vertical-align: middle;
    position: relative;
    flex-shrink: 0;
}

input[type="checkbox"]:hover {
    border-color: var(--text-muted);
}

input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Checkbox label alignment in form contexts */
.cb-label input[type="checkbox"] {
    margin-right: 0.3rem;
}

/* ══════════════════════════════════════════
   Custom Radio Button Styling
   ══════════════════════════════════════════ */

input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    vertical-align: middle;
    position: relative;
    flex-shrink: 0;
}

input[type="radio"]:hover {
    border-color: var(--text-muted);
}

input[type="radio"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

input[type="radio"]:checked {
    border-color: var(--accent);
}

input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

/* ══════════════════════════════════════════
   Enhanced Number Input Spinner
   ══════════════════════════════════════════ */

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 0;
    transition: opacity 0.15s ease;
}

input[type="number"]:hover::-webkit-inner-spin-button,
input[type="number"]:hover::-webkit-outer-spin-button,
input[type="number"]:focus::-webkit-inner-spin-button,
input[type="number"]:focus::-webkit-outer-spin-button {
    opacity: 1;
}

/* ══════════════════════════════════════════
   Print Stylesheet
   ══════════════════════════════════════════ */

@media print {
    /* Reset page background */
    body {
        background: #fff !important;
        color: #111 !important;
        font-size: 11pt;
    }

    /* Hide navigation, footer, interactive elements */
    .topbar,
    .nav-dropdown-menu,
    .skip-link,
    .wizard-steps,
    .wizard-nav,
    .context-menu,
    .toast-container,
    .btn,
    .file-browser,
    .upload-progress-wrap,
    .compare-toolbar,
    .batch-actions,
    form:not(.inline-form),
    .session-tab-bar,
    .pipeline-stages,
    .analysis-progress-panel,
    [id="add-driver-btn"],
    .empty-hero a.btn,
    .error-actions {
        display: none !important;
    }

    /* White backgrounds for cards */
    .stat-card,
    .meta-item,
    .insight-box,
    .compare-column,
    .content-card,
    .form-section,
    .weekend-notes,
    .plan-drill,
    .plan-callout {
        background: #fff !important;
        border-color: #ddd !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    /* Ensure text is dark */
    .stat-value,
    .stat-label,
    .meta-label,
    .meta-value,
    .score-bar-label,
    .score-bar-value,
    h1, h2, h3,
    .page-header h1 {
        color: #111 !important;
    }

    /* Links show URL */
    a[href]::after {
        content: ' (' attr(href) ')';
        font-size: 0.8em;
        color: #666;
    }

    a.breadcrumb::after,
    a.btn::after,
    a.nav-dropdown-item::after,
    a.clickable-row::after {
        content: none !important;
    }

    /* Score bars print-friendly */
    .score-bar-track {
        background: #eee !important;
    }

    .score-bar-fill {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    /* Tables print well */
    .data-table {
        border-collapse: collapse;
    }

    .data-table th,
    .data-table td {
        border: 1px solid #ccc !important;
        background: #fff !important;
        color: #111 !important;
        padding: 0.3rem 0.5rem;
    }

    .data-table thead th {
        background: #f5f5f5 !important;
        font-weight: 700;
    }

    .data-table.striped tbody tr:nth-child(even) {
        background: #fafafa !important;
    }

    .col-numeric {
        text-align: right;
    }

    /* Hide elevation/shadow decorations */
    .elevation-1, .elevation-2, .elevation-3, .elevation-4 {
        box-shadow: none !important;
    }

    /* Empty hero: clean for print */
    .empty-hero {
        border: 1px solid #ddd !important;
        background: #fff !important;
    }

    .empty-hero::before {
        display: none !important;
    }

    /* Page header border */
    .page-header {
        border-bottom-color: #ddd !important;
    }

    /* Badge colors for print */
    .badge,
    .grade,
    .badge-style {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
        border: 1px solid #999 !important;
    }

    /* Disable animations */
    * {
        animation: none !important;
        transition: none !important;
    }

    /* Charts: hide for print, show placeholder */
    canvas {
        display: none !important;
    }

    .chart-container {
        break-inside: avoid;
    }

    .chart-container::after {
        content: '[Chart – view on screen]';
        display: block;
        padding: 1rem;
        text-align: center;
        color: #666;
        border: 1px dashed #999;
        font-style: italic;
    }

    .data-table tr {
        page-break-inside: avoid;
    }

    /* Page breaks */
    .section {
        page-break-inside: avoid;
    }

    h2 {
        break-after: avoid;
    }

    /* Layout adjustments */
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Hide tooltips */
    .tip::after,
    .tip::before {
        display: none !important;
    }
}

/* ══════════════════════════════════════════
   Inline Style Reducers - Misc Utilities
   ══════════════════════════════════════════ */

/* Text accent color utility */
.text-accent { color: var(--accent); }

/* Font-family override */
.font-sans { font-family: var(--font-sans) !important; }

/* Large delta display */
.delta-display { font-size: 2rem; }

/* Min-height for chart areas */
.min-h-200 { min-height: 200px; }

/* Full-width grid column span */
.grid-col-full { grid-column: 1 / -1; }

/* ══════════════════════════════════════════
   Analytics Tool Cards
   ══════════════════════════════════════════ */

.analytics-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
}

.analytics-tool-link {
    text-decoration: none;
    flex: 1;
    min-width: 260px;
    max-width: 400px;
}

.analytics-tool-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    border: 1px solid var(--border);
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.analytics-tool-card:hover {
    border-color: var(--blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.analytics-tool-name {
    margin: 0 0 0.3rem 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.analytics-tool-desc {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ══════════════════════════════════════════
   Rival Comparison Form Layout
   ══════════════════════════════════════════ */

.rival-form-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.rival-checks {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.rival-check-label {
    font-size: 0.85rem;
}

/* ══════════════════════════════════════════
   Data Health Detail Tweaks
   ══════════════════════════════════════════ */

.dh-missing-badge {
    margin-right: 0.3rem;
}

/* ══════════════════════════════════════════
   Inline-Style Replacement: Flex Utilities
   ══════════════════════════════════════════ */

/* Flex row utility for filter/form bars used in analytics pages */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* Flex-1 utility */
.flex-1 { flex: 1; }

/* ══════════════════════════════════════════
   Visualize Page Header Utilities
   ══════════════════════════════════════════ */

.viz-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.viz-header-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.viz-header-meta-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ══════════════════════════════════════════
   Dev Plan Template Cards Layout
   ══════════════════════════════════════════ */

.template-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.driver-select-bar {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ══════════════════════════════════════════
   Export Builder Utilities
   ══════════════════════════════════════════ */

.export-preview-pre {
    background: #1a1a1a;
    padding: 15px;
    border-radius: var(--radius);
    overflow-x: auto;
    max-height: 600px;
}

/* ══════════════════════════════════════════
   What-If Simulator Utilities
   ══════════════════════════════════════════ */

.wf-corner-grid {
    display: grid;
    gap: 0.5rem;
}

.wf-corner-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.wf-corner-label {
    min-width: 80px;
}

.wf-slider-track {
    flex: 1;
}

/* ══════════════════════════════════════════
   Data Health Insight Variants
   ══════════════════════════════════════════ */

.insight-box.border-red {
    border-left-color: var(--red);
}

.insight-box.border-blue {
    border-left-color: var(--blue);
}

/* ══════════════════════════════════════════
   Session Detail: Lap-time tooltip (canvas)
   ══════════════════════════════════════════ */

.lap-time-tooltip {
    display: none;
    position: absolute;
    background: rgba(0, 0, 0, 0.85);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.867rem;
    pointer-events: none;
    z-index: var(--z-elevated);
    white-space: nowrap;
}

/* Session detail: coaching hint cell */
.coaching-hint-cell {
    max-width: 300px;
    font-size: 0.85rem;
}

/* Overlay legend spacing */
.overlay-legend {
    margin-left: 1rem;
}

.lap-overlay-label {
    margin-right: 0.5rem;
}

/* Score display center (data health) */
.score-display {
    text-align: center;
    padding: 1.5rem;
}

.score-big {
    font-size: 3rem;
    font-weight: 700;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--accent);
}

/* Performance summary grid — auto-fit for KPIs */
.meta-grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(100px, 14vw, 160px), 1fr));
    gap: 0.75rem;
}

/* ══════════════════════════════════════════
   Annotation Form Utilities
   ══════════════════════════════════════════ */

.ann-search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ann-lap-input {
    width: 80px;
}

.ann-body-textarea {
    width: 100%;
}

/* ══════════════════════════════════════════
   Loading Skeleton Patterns
   ══════════════════════════════════════════ */

@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        var(--bg-hover) 50%,
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-line {
    height: 0.85rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-sm);
}

.skeleton-line:last-child {
    width: 60%;
}

.skeleton-heading {
    height: 1.5rem;
    width: 40%;
    margin-bottom: 1rem;
}

.skeleton-card {
    aspect-ratio: 3 / 1;
    border-radius: var(--radius);
}

.skeleton-stat {
    height: 3rem;
    border-radius: var(--radius-sm);
}

.skeleton-chart {
    aspect-ratio: 2 / 1;
    border-radius: var(--radius);
}

.skeleton-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.skeleton-row > .skeleton {
    flex: 1;
}

/* ══════════════════════════════════════════
   Table Enhancements
   ══════════════════════════════════════════ */

/* Sortable table headers */
.data-table th[data-sort] {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.2rem;
}

.data-table th[data-sort]:hover {
    color: var(--accent);
}

.data-table th[data-sort]::after {
    content: '\25B4\25BE';
    position: absolute;
    right: 0.3rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6rem;
    color: var(--text-muted);
    letter-spacing: -2px;
}

.data-table th[data-sort].sort-asc::after {
    content: '\25B2';
    color: var(--accent);
    letter-spacing: normal;
}

.data-table th[data-sort].sort-desc::after {
    content: '\25BC';
    color: var(--accent);
    letter-spacing: normal;
}

/* Sticky table header — consolidated (see also line ~4876) */
.table-wrap-sticky {
    max-height: 500px;
    overflow-y: auto;
}

/* Table row highlight on hover */
.data-table.compact tbody tr {
    transition: background 0.1s ease;
}

/* Striped rows variant */
.data-table.striped tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* Numeric column alignment */
.col-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
}

/* Ensure numeric headers also right-align (overrides .data-table th text-align:left) */
.data-table th.col-numeric {
    text-align: right;
}

/* Match th padding with compact td padding so columns align */
.data-table.compact th {
    padding: 0.55rem 0.75rem;
}

/* ══════════════════════════════════════════
   Smooth Page Transitions
   ══════════════════════════════════════════ */

/* Section reveal animation */
@keyframes section-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: section-fade-in 0.3s ease both;
}

.section:nth-child(2) { animation-delay: 0.05s; }
.section:nth-child(3) { animation-delay: 0.1s; }
.section:nth-child(4) { animation-delay: 0.15s; }
.section:nth-child(5) { animation-delay: 0.2s; }

/* Tab panel transition */
.tab-panel {
    transition: opacity 0.2s ease;
}

.tab-panel:not(.active) {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    left: -9999px;
}

.tab-panel.active {
    opacity: 1;
    pointer-events: auto;
    position: static;
}

/* Flash message auto-dismiss animation */
@keyframes flash-slide-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flash {
    animation: flash-slide-in 0.3s ease both;
}

/* Reduced motion: disable animations */
@media (prefers-reduced-motion: reduce) {
    .section,
    .flash,
    .tab-panel {
        animation: none !important;
        transition: none !important;
    }
}

/* ══════════════════════════════════════════
   Empty State Improvements
   ══════════════════════════════════════════ */

.empty-hero {
    transition: background var(--duration-normal) var(--ease-out);
}

.empty-hero:hover {
    background: var(--bg-hover);
}

/* Subtle pulse on the empty hero icon */
@keyframes empty-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.empty-hero-icon {
    animation: empty-pulse 3s var(--ease-out) infinite;
}

@media (prefers-reduced-motion: reduce) {
    .empty-hero-icon {
        animation: none;
    }
}

/* ══════════════════════════════════════════
   Scroll Indicator (for wide tables)
   ══════════════════════════════════════════ */

.table-wrap {
    position: relative;
}

.table-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, rgba(13, 17, 23, 0.6));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.table-wrap.has-scroll::after {
    opacity: 1;
}

/* ══════════════════════════════════════════
   Button Group Patterns
   ══════════════════════════════════════════ */

.btn-group {
    display: inline-flex;
    border-radius: var(--radius);
    overflow: hidden;
}

.btn-group .btn {
    border-radius: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-group .btn:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}

.btn-group .btn:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
    border-right: none;
}

.btn-group .btn.active {
    background: var(--accent);
    color: #fff;
}

/* Icon button (square aspect) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
}

/* ══════════════════════════════════════════
   Form UX Refinements
   ══════════════════════════════════════════ */

/* Form field character counter */
.form-counter {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.form-counter.limit-near {
    color: var(--yellow);
}

.form-counter.limit-reached {
    color: var(--red);
}

/* Inline form layout */
.form-inline {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.form-inline .form-group {
    margin-bottom: 0;
}

/* Form help text */
.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Required indicator */
.form-required::after {
    content: '*';
    color: var(--red);
    margin-left: 0.2rem;
}

/* Textarea auto-resize styling */
textarea {
    resize: vertical;
    min-height: 4rem;
}

/* ══════════════════════════════════════════
   Responsive: Extra Small (< 400px)
   ══════════════════════════════════════════ */

@media (max-width: 599px) {
    /* Stack filter bars on smaller screens */
    .filter-bar,
    .rival-form-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar .btn,
    .rival-form-bar .btn {
        width: 100%;
    }

    .filter-bar .form-select,
    .rival-form-bar .form-select {
        width: 100%;
    }
}

@media (max-width: 399px) {

    /* Full-width meta grid items */
    .meta-grid {
        grid-template-columns: 1fr !important;
    }

    /* Compact stat cards */
    .stat-card {
        padding: 0.75rem;
    }

    /* Smaller page header */
    .page-header h1 {
        font-size: 1.3rem;
    }

    /* Stack compare columns */
    .compare-grid {
        grid-template-columns: 1fr;
    }

    /* Single-column card grid */
    .card-grid {
        grid-template-columns: 1fr;
    }
}

/* ══════════════════════════════════════════
   Responsive: Tablet (481-768px)
   ══════════════════════════════════════════ */

@media (min-width: 481px) and (max-width: 768px) {
    /* Ensure filter bars wrap gracefully */
    .filter-bar {
        gap: 0.5rem;
    }

    /* 2-column meta grid */
    .meta-grid-auto {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ══════════════════════════════════════════
   Responsive: Large (> 1200px)
   ══════════════════════════════════════════ */

@media (min-width: 1200px) {
    /* Wider meta grid on large screens */
    .meta-grid-auto {
        grid-template-columns: repeat(auto-fit, minmax(clamp(140px, 18vw, 200px), 1fr));
    }

    /* Wider compare columns */
    .compare-grid {
        gap: 2rem;
    }
}

/* ══════════════════════════════════════════
   Micro-interaction: Ripple effect on buttons
   ══════════════════════════════════════════ */

.btn {
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease;
    opacity: 0;
}

.btn:active::before {
    width: 200%;
    height: 200%;
    opacity: 1;
    transition: width 0s, height 0s, opacity 0s;
}

/* ══════════════════════════════════════════
   Notification Dot (for nav items)
   ══════════════════════════════════════════ */

.has-notification::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    border: 1px solid var(--bg-primary);
}

/* ══════════════════════════════════════════
   Progress Bar Component
   ══════════════════════════════════════════ */

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-xs);
    transition: width 0.3s ease;
}

.progress-fill.green { background: var(--green); }
.progress-fill.yellow { background: var(--yellow); }
.progress-fill.red { background: var(--red); }
.progress-fill.blue { background: var(--blue); }

/* Thicker progress bar variant */
.progress-bar.thick {
    height: 10px;
    border-radius: 5px;
}

.progress-bar.thick .progress-fill {
    border-radius: 5px;
}

/* ══════════════════════════════════════════
   Chip/Tag Component (refined)
   ══════════════════════════════════════════ */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    color: var(--text-secondary);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.chip-dismiss {
    cursor: pointer;
    font-size: 0.7rem;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.chip-dismiss:hover {
    opacity: 1;
    color: var(--red);
}

/* ══════════════════════════════════════════
   Color-Coded Severity / Status Indicators
   ══════════════════════════════════════════ */

/* Status dot (small colored circle) */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.4rem;
    vertical-align: middle;
}

.status-dot.excellent { background: var(--green); box-shadow: 0 0 4px rgba(63, 185, 80, 0.4); }
.status-dot.average { background: var(--yellow); box-shadow: 0 0 4px rgba(210, 153, 34, 0.4); }
.status-dot.poor { background: var(--red); box-shadow: 0 0 4px rgba(248, 81, 73, 0.4); }

/* Severity bar (colored left border on cards) */
.severity-excellent { border-left: 3px solid var(--green); }
.severity-good { border-left: 3px solid var(--blue); }
.severity-average { border-left: 3px solid var(--yellow); }
.severity-poor { border-left: 3px solid var(--red); }
.severity-neutral { border-left: 3px solid var(--text-muted); }

/* Colored text utility helpers */
.text-green { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }
.text-purple { color: var(--purple); }

/* ══════════════════════════════════════════
   Card Elevation System
   ══════════════════════════════════════════ */

.elevation-0 {
    box-shadow: none;
}

.elevation-1 {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.elevation-2 {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.elevation-3 {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.elevation-4 {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

/* Interactive card that lifts on hover */
.card-interactive {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card-interactive:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    border-color: var(--accent);
}

.card-interactive:active {
    transform: translateY(0);
}

/* Highlighted card variant (featured/important) */
.card-featured {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(255, 107, 53, 0.1), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.card-featured::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: var(--radius) var(--radius) 0 0;
}

/* ══════════════════════════════════════════
   Typography Scale Refinements
   ══════════════════════════════════════════ */

/* Heading hierarchy */
.heading-xl {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.heading-lg {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.heading-md {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
}

.heading-sm {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Body text variants */
.body-lg {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.body-sm {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.body-xs {
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-muted);
}

/* Monospace data display */
.data-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* Large display number */
.display-number {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: var(--text-primary);
}

.display-number.accent {
    color: var(--accent);
}

/* Truncate long text with ellipsis */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Multi-line truncate (2 lines) */
.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ══════════════════════════════════════════
   Divider Component
   ══════════════════════════════════════════ */

.divider {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}

.divider-light {
    background: var(--border-subtle);
}

.divider-accent {
    height: 2px;
    background: linear-gradient(to right, var(--accent), transparent);
}

/* ══════════════════════════════════════════
   Scrollbar Styling (dark theme)
   ══════════════════════════════════════════ */

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-sm);
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ══════════════════════════════════════════
   Aspect Ratio Containers
   ══════════════════════════════════════════ */

.aspect-square {
    aspect-ratio: 1;
}

.aspect-video {
    aspect-ratio: 16 / 9;
}

.aspect-chart {
    aspect-ratio: 2 / 1;
}

/* ══════════════════════════════════════════
   Keyboard Shortcut Indicator (kbd)
   ══════════════════════════════════════════ */

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4em;
    padding: 0.1em 0.4em;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 0 var(--border);
    vertical-align: baseline;
}

/* ══════════════════════════════════════════
   Row Selection Indicator
   ══════════════════════════════════════════ */

.clickable-row.selected,
tr.row-selected {
    background: rgba(255, 107, 53, 0.08);
    box-shadow: inset 3px 0 0 var(--accent);
}

/* ══════════════════════════════════════════
   Active Filter Indicator
   ══════════════════════════════════════════ */

.filter-active {
    position: relative;
}

.filter-active::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

/* ══════════════════════════════════════════
   Inline Form Validation
   ══════════════════════════════════════════ */

.form-select.is-invalid,
.form-input.is-invalid {
    border-color: var(--red);
    box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.15);
}

.form-select.is-invalid:focus,
.form-input.is-invalid:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.2);
}

.form-error {
    display: block;
    color: var(--red);
    font-size: 0.78rem;
    margin-top: 0.25rem;
    animation: section-fade-in 0.2s ease both;
}

.btn.btn-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════
   Enhanced Toast Positioning
   ══════════════════════════════════════════ */

.toast-container {
    position: fixed;
    top: 4.5rem;
    right: 1rem;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow);
    color: var(--text-primary);
    font-size: 0.85rem;
    max-width: 360px;
    animation: toast-slide-in var(--duration-normal) var(--ease-out) both;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error { border-left: 3px solid var(--red); }
.toast.toast-warning { border-left: 3px solid var(--yellow); }
.toast.toast-info { border-left: 3px solid var(--blue); }

.toast-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 0.25rem;
    font-size: 1.1rem;
    margin-left: auto;
}

.toast-dismiss:hover {
    color: var(--text-primary);
}

@keyframes toast-slide-in {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.toast-exit {
    animation: toast-slide-out var(--duration-normal) var(--ease-out) both;
}

@keyframes toast-slide-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* ══════════════════════════════════════════
   Content Load Transition
   ══════════════════════════════════════════ */

.content-loaded {
    animation: content-reveal 0.3s ease both;
}

@keyframes content-reveal {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .content-loaded {
        animation: none;
    }
}

/* ══════════════════════════════════════════
   Action Feedback — Confirm Pulse
   ══════════════════════════════════════════ */

.pulse-success {
    animation: pulse-green 0.5s ease;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(63, 185, 80, 0); }
    100% { box-shadow: none; }
}

.pulse-error {
    animation: pulse-red 0.5s ease;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(248, 81, 73, 0); }
    100% { box-shadow: none; }
}

/* ══════════════════════════════════════════
   Grade Badge — Enhanced Visual Weight
   ══════════════════════════════════════════ */

.grade-S {
    font-weight: 700;
    text-shadow: 0 0 8px rgba(112, 208, 255, 0.4);
}

.grade-A {
    font-weight: 600;
}

/* ══════════════════════════════════════════
   Table Sort Indicator (visual cue)
   ══════════════════════════════════════════ */

.data-table th[data-sort] {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.4em;
}

.data-table th[data-sort]::after {
    content: '\2195';
    position: absolute;
    right: 0.4em;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7em;
    opacity: 0.3;
    transition: opacity 0.15s ease;
}

.data-table th[data-sort]:hover::after {
    opacity: 0.7;
}

.data-table th[data-sort].sort-asc::after {
    content: '\2191';
    opacity: 0.8;
}

.data-table th[data-sort].sort-desc::after {
    content: '\2193';
    opacity: 0.8;
}

/* (Responsive 399px rules consolidated above.
   Utilities .input-narrow, .font-normal, .mb-sm, .ml-sm defined above.) */

/* ══════════════════════════════════════════
   Section Hints — subtle guidance text below h2
   ══════════════════════════════════════════ */

.section-hint {
    margin: -0.3rem 0 1rem;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-secondary);
    opacity: 0.7;
    letter-spacing: 0.01em;
}

/* ── Driving Style: color-coded fill bars ── */

.style-fill-good { background: var(--green) !important; }
.style-fill-avg  { background: #ff9800 !important; }
.style-fill-warn { background: var(--red) !important; }

/* ══════════════════════════════════════════
   Driving Style — JS-rendered (driving_style.js)
   ══════════════════════════════════════════ */

.dstyle-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.4rem;
}

.dstyle-label-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: capitalize;
    border: 1px solid;
}

.dstyle-confidence {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.dstyle-description {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0 0 1rem;
    line-height: 1.5;
}

.dstyle-layout {
    display: grid;
    grid-template-columns: 1fr clamp(220px, 30vw, 450px);
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 768px) {
    .dstyle-layout { grid-template-columns: 1fr; }
}

.dstyle-gauge-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.dstyle-gauge-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border-subtle);
}
.dstyle-gauge-row:last-child { border-bottom: none; }

.dstyle-gauge-name {
    flex: 0 0 120px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: help;
}

.dstyle-gauge-track {
    flex: 1;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.dstyle-gauge-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.dstyle-gauge-qual {
    flex: 0 0 80px;
    text-align: right;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: help;
}

.dstyle-radar-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
}

.dstyle-radar-canvas {
    display: block;
    max-width: 100%;
}

.dstyle-insights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(280px, 40vw, 500px), 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
@media (max-width: 600px) {
    .dstyle-insights { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════
   Session Debrief — summary_report.js
   ══════════════════════════════════════════ */

/* Hero card: grade ring + stats */
.debrief-hero {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.2rem 1.4rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 1.2rem;
}

.debrief-grade-ring {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--grade-color, var(--accent));
    box-shadow: 0 0 18px var(--grade-glow, transparent), inset 0 0 12px var(--grade-glow, transparent);
    background: rgba(0, 0, 0, 0.25);
}

.debrief-grade-letter {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    color: var(--grade-color, var(--accent));
    letter-spacing: -0.02em;
}

.debrief-grade-label {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: 2px;
}

.debrief-hero-stats {
    flex: 1;
    min-width: 0;
}

.debrief-hero-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
}

.debrief-hero-numbers {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.debrief-stat-pill {
    display: flex;
    flex-direction: column;
    padding: 0.4rem 0.8rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    min-width: 80px;
}

.debrief-stat-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.debrief-stat-value {
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

/* Executive summary */
.debrief-executive {
    padding: 0.8rem 1rem;
    border-left: 3px solid var(--accent);
    background: rgba(255, 107, 53, 0.04);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 1.2rem;
}

/* Section labels inside debrief */
.debrief-section-label {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin: 1.2rem 0 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border-subtle);
}

/* Highlight cards */
.debrief-highlights {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(220px, 28vw, 300px), 1fr));
    gap: 0.8rem;
    margin-bottom: 0.6rem;
}

.debrief-highlight-card {
    display: flex;
    gap: 0.7rem;
    padding: 0.8rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    animation: fadeSlideUp 0.35s ease both;
}

.debrief-highlight-icon {
    flex-shrink: 0;
    font-size: 1.3rem;
    line-height: 1;
    margin-top: 0.1rem;
}

.debrief-highlight-body {
    flex: 1;
    min-width: 0;
}

.debrief-highlight-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.debrief-highlight-detail {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.debrief-highlight-metric {
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-mono);
    margin-top: 0.3rem;
}

/* Key metrics table overrides */
.debrief-metrics-table { margin-bottom: 0.6rem; }

.debrief-metric-name {
    font-weight: 500;
    color: var(--text-primary);
}

.debrief-rating-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
}

.debrief-metric-context {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* Improvement cards */
.debrief-improvements {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.debrief-improvement-card {
    padding: 0.8rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid var(--red);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.debrief-improvement-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.debrief-improvement-area {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.debrief-improvement-priority {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: rgba(231, 76, 60, 0.15);
    color: var(--red);
}

.debrief-improvement-explain {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.4rem;
}

.debrief-improvement-drill {
    font-size: 0.8rem;
    color: var(--text-primary);
    padding: 0.4rem 0.6rem;
    background: rgba(255, 107, 53, 0.06);
    border-radius: var(--radius-sm);
}

.debrief-drill-tag {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--accent);
    color: #fff;
    vertical-align: middle;
}

/* ── Next Session Actions — Hero wrapper ── */

.debrief-actions-hero {
    margin-top: 2rem;
    padding: 1.2rem;
    background: linear-gradient(135deg, rgba(255,107,53,0.04), rgba(255,107,53,0.08));
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.debrief-actions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 0.8rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--accent);
}

.debrief-actions-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.debrief-actions-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 0.4rem;
    cursor: help;
}

.debrief-actions-count {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255, 107, 53, 0.15);
    color: var(--accent);
}

.debrief-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(240px, 30vw, 320px), 1fr));
    gap: 0.8rem;
}

.debrief-action-card {
    display: flex;
    gap: 0.9rem;
    padding: 1rem 1.1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    animation: fadeSlideUp 0.35s ease both;
}
.debrief-action-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(255, 107, 53, 0.1);
}

.debrief-action-number {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 800;
}

.debrief-action-body {
    flex: 1;
    min-width: 0;
}

.debrief-action-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.45;
    margin-bottom: 0.4rem;
}

.debrief-action-meta {
    display: flex;
    gap: 0.6rem;
    font-size: 0.75rem;
}

.debrief-action-difficulty {
    font-weight: 600;
}

.debrief-action-category {
    color: var(--text-secondary);
    text-transform: capitalize;
}

.debrief-section-tip {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-left: 0.2rem;
    cursor: help;
    vertical-align: middle;
}

/* ══════════════════════════════════════════
   Achievements & Badges — Premium Motorsport
   ══════════════════════════════════════════ */

/* Star rating hero */
.badges-star-hero {
    text-align: center;
    padding: 1.2rem 0 0.8rem;
}

.badges-star-row {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.badges-star {
    font-size: 2.4rem;
    line-height: 1;
    transition: transform 0.2s ease;
}
.badges-star.filled {
    background: linear-gradient(135deg, #ffd700, #ffaa00, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.4));
    animation: starPulse 0.6s ease-out;
}
.badges-star.half {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    opacity: 0.7;
}
.badges-star.empty {
    color: var(--text-secondary);
    opacity: 0.2;
}

@keyframes starPulse {
    0%   { transform: scale(0.6); opacity: 0; }
    50%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.badges-star-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

/* Tier counters — metallic */
.badges-tier-row {
    display: flex;
    justify-content: center;
    gap: 1.2rem;
    margin: 0.8rem 0 1.2rem;
}

.badges-tier-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.7rem 1.4rem;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    min-width: 78px;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
    cursor: default;
}
.badges-tier-box[data-tier="gold"] {
    border-image: linear-gradient(135deg, #ffd700, #b8860b) 1;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.15);
}
.badges-tier-box[data-tier="silver"] {
    border-image: linear-gradient(135deg, #e0e0e0, #808080) 1;
    box-shadow: 0 0 12px rgba(192, 192, 192, 0.12);
}
.badges-tier-box[data-tier="bronze"] {
    border-image: linear-gradient(135deg, #cd7f32, #8b4513) 1;
    box-shadow: 0 0 12px rgba(205, 127, 50, 0.12);
}
.badges-tier-box:hover {
    transform: scale(1.03);
}
.badges-tier-box[data-tier="gold"]:hover {
    box-shadow: 0 0 24px rgba(255, 215, 0, 0.3);
}
.badges-tier-box[data-tier="silver"]:hover {
    box-shadow: 0 0 24px rgba(192, 192, 192, 0.25);
}
.badges-tier-box[data-tier="bronze"]:hover {
    box-shadow: 0 0 24px rgba(205, 127, 50, 0.25);
}

.badges-tier-num {
    font-size: 1.6rem;
    font-weight: 800;
    font-family: var(--font-mono);
    line-height: 1;
}
.badges-tier-num[data-tier="gold"] {
    background: linear-gradient(135deg, #ffd700, #ffaa00, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.badges-tier-num[data-tier="silver"] {
    background: linear-gradient(135deg, #e0e0e0, #a0a0a0, #e0e0e0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.badges-tier-num[data-tier="bronze"] {
    background: linear-gradient(135deg, #cd7f32, #a0622a, #cd7f32);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.badges-tier-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Badge cards grid — premium */
.badges-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(200px, 26vw, 280px), 1fr));
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

.badges-card {
    padding: 0.9rem 1.1rem;
    padding-top: calc(0.9rem + 2px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-top: 2px solid var(--badge-tier-color, var(--text-secondary));
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15), 0 0 8px var(--badge-tier-glow, transparent);
    animation: fadeSlideUp 0.3s ease both;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
}
.badges-card:hover {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15), 0 0 20px var(--badge-tier-glow, transparent);
    transform: translateY(-1px);
}

.badges-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.badges-card-name {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-primary);
}

.badges-card-tier {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: var(--radius-sm);
}

.badges-card-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 0.4rem;
}

.badges-card-category {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.badges-cat-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Progress to next tier — with glow */
.badges-progress-track {
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.badges-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    box-shadow: 0 0 6px var(--badge-tier-glow, transparent);
}

.badges-progress-label {
    font-size: 0.68rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

/* Radar section */
.badges-radar-section {
    margin-top: 1.2rem;
    text-align: center;
}

.badges-radar-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.badges-radar-canvas {
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

/* Coaching insight — pit crew note */
.badges-coaching {
    margin-top: 1.2rem;
    padding: 0.8rem 1.1rem;
    background: rgba(255, 255, 255, 0.02);
    border-left: 3px solid;
    border-image: linear-gradient(to bottom, var(--accent), rgba(255,107,53,0.3)) 1;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.badges-coaching-label {
    color: var(--accent);
    font-size: 0.78rem;
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
}

/* ── Shared animation for card entrance ── */

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Debrief / Badges responsive ── */

@media (max-width: 600px) {
    .debrief-hero {
        flex-direction: column;
        text-align: center;
    }
    .debrief-hero-numbers {
        justify-content: center;
    }
    .debrief-actions-grid,
    .debrief-highlights,
    .badges-card-grid {
        grid-template-columns: 1fr;
    }
    .badges-tier-row {
        gap: 0.6rem;
    }
    .badges-tier-box {
        min-width: 56px;
        padding: 0.5rem 0.8rem;
    }
}

/* ══════════════════════════════════════════
   Race Pace Simulator Form
   ══════════════════════════════════════════ */

.sim-form-grid {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.sim-form-group {
    flex: 1;
    min-width: 240px;
}

.sim-group-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

.sim-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.sim-field label {
    font-size: 0.82rem;
    color: var(--text-primary);
}

.sim-input {
    width: 90px;
    padding: 0.3rem 0.5rem;
    background: var(--bg-elevated, #23272e);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 4px);
    color: var(--text-primary);
    font-size: 0.85rem;
    text-align: right;
}

.sim-input:focus {
    outline: none;
    border-color: var(--blue, #36a2eb);
    box-shadow: 0 0 0 2px rgba(54, 162, 235, 0.15);
}

.sim-btn-icon {
    margin-right: 0.3rem;
}

/* ── Phase 16: Data management styles ────────────────────────── */

/* Danger zone for delete actions */
.danger-zone {
    border-top: 2px solid var(--red, #f85149);
    margin-top: 2rem;
    padding-top: 1rem;
}
.danger-zone summary {
    cursor: pointer;
    user-select: none;
}

/* Start/finish save bar */
.sf-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-secondary, #1a1f2e);
    border-radius: var(--radius-md, 8px);
}

/* Sector controls */
.sector-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Reorder buttons */
.col-order {
    width: 60px;
    text-align: center;
}
.reorder-btn {
    background: none;
    border: 1px solid var(--border, #30363d);
    padding: 0.15rem 0.3rem;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    color: var(--text-secondary, #8b949e);
    font-size: 0.7rem;
    line-height: 1;
}
.reorder-btn:hover:not([disabled]) {
    color: var(--accent, #ff6b35);
    border-color: var(--accent, #ff6b35);
}
.reorder-btn[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Heatmap */
.heatmap-wrap {
    overflow-x: auto;
}

/* Records held */
.records-held-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.record-held-item {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border, #30363d);
}
.record-held-item:last-child {
    border-bottom: none;
}

/* Kart card grid */
.kart-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(220px, 28vw, 300px), 1fr));
    gap: 1rem;
}
.kart-card {
    background: var(--bg-secondary, #1a1f2e);
    border: 1px solid var(--border, #30363d);
    border-radius: var(--radius-md, 8px);
    padding: 1rem;
    transition: border-color 0.15s;
}
.kart-card:hover {
    border-color: var(--accent, #ff6b35);
}
.kart-card-title {
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.kart-card-specs {
    font-size: 0.82rem;
    color: var(--text-secondary, #8b949e);
}

/* Dragging indicator */
tr[draggable="true"] {
    cursor: grab;
}
tr[draggable="true"]:active {
    cursor: grabbing;
}

/* ── Inline metadata editors ────────────────────────────────── */
.form-input-inline,
.form-select-inline {
    background: var(--bg-secondary, #161b22);
    color: var(--text-primary, #e6edf3);
    border: 1px solid transparent;
    border-radius: var(--radius-sm, 4px);
    padding: 0.2rem 0.4rem;
    font-size: inherit;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color 0.15s;
    max-width: 100%;
}
.form-input-inline:hover,
.form-select-inline:hover {
    border-color: var(--border, #30363d);
}
.form-input-inline:focus,
.form-select-inline:focus {
    border-color: var(--accent, #ff6b35);
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.15);
}
.form-select-inline {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    padding-right: 1.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b949e'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.3rem center;
}
input[type="date"].form-input-inline {
    width: 140px;
}
input[type="date"].form-input-inline::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

/* ── Head-to-Head Comparison Scorecard ──────────────────────── */
.h2h-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    background: var(--bg-secondary, #1a1f2e);
    border-radius: var(--radius, 8px);
    margin-bottom: 1.5rem;
}
.h2h-driver {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.h2h-driver-b { text-align: right; }
.h2h-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #e6edf3);
    text-decoration: none;
}
.h2h-name:hover { text-decoration: underline; }
.h2h-sessions {
    font-size: 0.82rem;
    color: var(--text-secondary, #8b949e);
}
.h2h-score-center {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.h2h-tally {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 2ch;
    text-align: center;
}
.h2h-tally-a { color: var(--accent, #ff6b35); }
.h2h-tally-b { color: var(--blue, #58a6ff); }
.h2h-winner { text-shadow: 0 0 12px currentColor; }
.h2h-vs {
    font-size: 0.85rem;
    color: var(--text-secondary, #8b949e);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Scorecard rows */
.h2h-scorecard {
    background: var(--bg-secondary, #1a1f2e);
    border-radius: var(--radius, 8px);
    overflow: hidden;
}
.h2h-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    border-bottom: 1px solid var(--border, #30363d);
    transition: background 0.15s;
}
.h2h-row:last-child { border-bottom: none; }
.h2h-row:hover { background: rgba(255, 255, 255, 0.02); }

.h2h-cell { padding: 1rem 1.5rem; }
.h2h-cell-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 180px;
    gap: 0.2rem;
}
.h2h-metric-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary, #e6edf3);
}
.h2h-metric-note {
    font-size: 0.75rem;
    color: var(--text-secondary, #8b949e);
}
.h2h-cell-val {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.h2h-cell-a { justify-content: flex-end; }
.h2h-cell-b { justify-content: flex-start; }
.h2h-val {
    font-size: 1.1rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary, #8b949e);
}
.h2h-cell-winner .h2h-val {
    color: var(--text-primary, #e6edf3);
    font-weight: 700;
}
.h2h-cell-a.h2h-cell-winner .h2h-val { color: var(--accent, #ff6b35); }
.h2h-cell-b.h2h-cell-winner .h2h-val { color: var(--blue, #58a6ff); }
.h2h-crown {
    font-size: 0.85rem;
    font-weight: 700;
}
.h2h-cell-a .h2h-crown { color: var(--accent, #ff6b35); }
.h2h-cell-b .h2h-crown { color: var(--blue, #58a6ff); }

/* Win indicator bar on left/right edge */
.h2h-row-win-a { box-shadow: inset 3px 0 0 var(--accent, #ff6b35); }
.h2h-row-win-b { box-shadow: inset -3px 0 0 var(--blue, #58a6ff); }

/* Verdict box */
.h2h-verdict {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.25rem 2rem;
    background: var(--bg-secondary, #1a1f2e);
    border-radius: var(--radius, 8px);
    text-align: center;
}
.h2h-verdict-icon { font-size: 1.5rem; }
.h2h-verdict-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #e6edf3);
}

/* Responsive */
@media (max-width: 640px) {
    .h2h-header {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 0.75rem;
    }
    .h2h-driver-b { text-align: center; }
    .h2h-row {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }
    .h2h-cell-label {
        grid-column: 1 / -1;
        order: -1;
        padding: 0.75rem 1rem 0;
    }
    .h2h-cell-a { justify-content: center; }
    .h2h-cell-b { justify-content: center; }
    .h2h-cell { padding: 0.5rem 1rem; }
}

/* Drill session linking */
.drill-sessions { margin-top: 0.5rem; }
.linked-session-card {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: var(--bg-secondary, #1e1e2e); padding: 0.3rem 0.6rem;
    border-radius: 6px; font-size: 0.8rem; margin: 0.2rem 0;
}
.linked-session-date { color: var(--text-muted, #888); }
.linked-session-score { color: var(--accent, #f59e0b); font-weight: 600; }
.drill-link-action {
    display: flex; gap: 0.4rem; align-items: center; margin-top: 0.4rem;
}
.drill-session-select { max-width: clamp(180px, 45vw, 300px); font-size: 0.8rem; }

/* Driver badges */
.badges-grid {
    display: flex; flex-wrap: wrap; gap: 0.75rem;
}
.badge-card {
    display: flex; align-items: center; gap: 0.6rem;
    background: var(--bg-secondary, #1e1e2e); padding: 0.6rem 1rem;
    border-radius: 10px; border: 1px solid var(--border, #333);
}
.badge-icon { font-size: 1.8rem; }
.badge-name { font-weight: 600; font-size: 0.95rem; }
.badge-level { font-size: 0.75rem; color: var(--text-muted, #888); }
