/* VoltTrack - Grafana-Style Professional Theme */

:root {
    /* Grafana-inspired color palette - Gray neutrals */
    --bg-primary: #0b0c0e;
    --bg-secondary: #111217;
    --bg-tertiary: #181b1f;
    --bg-card: #1f2229;
    --bg-card-hover: #262931;
    --bg-hover: #2a2e38;
    --bg-input: #0d0e11;
    --bg-panel-header: #262931;

    /* Text colors - softer than pure white */
    --text-primary: #d8dce2;
    --text-secondary: #8e939a;
    --text-tertiary: #6b7280;
    --text-muted: #5a6068;
    --text-dim: #3d424a;

    /* Accent colors - Bleu doux comme couleur principale */
    --accent-primary: #6b9cce;
    --accent-secondary: #5a8bb8;
    --accent-gradient: linear-gradient(135deg, #6b9cce, #5a8bb8);
    --primary: #6b9cce;

    /* Status colors - Grafana palette */
    --success: #73bf69;
    --success-color: #73bf69;
    --success-bg: rgba(115, 191, 105, 0.12);
    --warning: #ff9830;
    --warning-color: #ff9830;
    --warning-bg: rgba(255, 152, 48, 0.12);
    --danger: #f2495c;
    --danger-color: #f2495c;
    --danger-bg: rgba(242, 73, 92, 0.12);
    --info: #5794f2;
    --info-bg: rgba(87, 148, 242, 0.12);

    /* Additional Grafana colors */
    --accent-blue: #5794f2;
    --accent-green: #73bf69;
    --accent-purple: #b877d9;
    --accent-cyan: #6ccfdf;
    --accent-red: #f2495c;
    --accent-yellow: #fade2a;

    /* Borders - subtle */
    --border-color: #2c3039;
    --border-light: #262931;
    --border-medium: #3d424a;

    /* Fonts */
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Sizing - Compact but readable */
    --sidebar-width: 200px;
    --sidebar-collapsed: 56px;
    --topbar-height: 40px;
    --radius-sm: 3px;
    --radius-md: 4px;
    --radius-lg: 6px;
    --radius-xl: 8px;

    /* Panel sizing */
    --panel-header-height: 28px;
    --panel-padding: 10px;

    /* Shadows - minimal for flat design */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 12px rgba(107, 156, 206, 0.2);

    /* Transitions */
    --transition-fast: 0.12s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: none;  /* Hidden by default, shown via JS when authenticated */
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--transition-normal);
    z-index: 100;
}

/* Show sidebar and topbar only when authenticated */
body.authenticated .sidebar {
    display: flex;
}

body.authenticated .top-bar {
    display: flex;
}

.sidebar-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
}

.logo-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Vehicle Selector */
.vehicle-selector {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.current-vehicle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.current-vehicle:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-medium);
}

.vehicle-icon {
    width: 28px;
    height: 28px;
    background: var(--success);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.vehicle-icon svg {
    width: 16px;
    height: 16px;
    color: white;
}

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

.vehicle-name {
    display: block;
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vehicle-model {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0;
}

.vehicle-status {
    display: block;
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-top: 1px;
}

.dropdown-arrow {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.vehicle-dropdown {
    position: absolute;
    top: 100%;
    left: 1rem;
    right: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 50;
}

.vehicle-dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.vehicle-dropdown-item.active {
    background: var(--accent-primary);
    color: white;
}

.vehicle-dropdown-item.active .vehicle-dropdown-model {
    color: rgba(255, 255, 255, 0.8);
}

.vehicle-dropdown-item:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.vehicle-dropdown-item:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.vehicle-dropdown-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.vehicle-dropdown-model {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 0.5rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    font-size: 0.8rem;
}

.nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-item span {
    font-weight: 500;
}

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

.nav-item.active {
    color: #000;
    background: var(--accent-primary);
}

.nav-item.active svg {
    stroke: #000;
    opacity: 1;
}

/* Navigation Groups with Submenus */
.nav-group {
    margin-bottom: 4px;
}

.nav-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    font-size: 0.8rem;
    user-select: none;
}

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

.nav-group-header svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-group-header .nav-group-title {
    flex: 1;
    font-weight: 500;
}

.nav-group-header .nav-group-arrow {
    width: 12px;
    height: 12px;
    transition: transform var(--transition-fast);
    opacity: 0.5;
}

.nav-group.expanded .nav-group-arrow {
    transform: rotate(180deg);
}

.nav-group.has-active .nav-group-header {
    color: var(--accent-primary);
}

.nav-group.has-active .nav-group-header svg:first-child {
    opacity: 1;
}

.nav-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal);
}

.nav-group.expanded .nav-group-items {
    max-height: 500px;
}

.nav-group-items .nav-item {
    padding-left: 2rem;
    font-size: 0.75rem;
    margin-left: 0.5rem;
    border-left: 1px solid var(--border-color);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.nav-group-items .nav-item svg {
    width: 14px;
    height: 14px;
}

.nav-group-items .nav-item.active {
    border-left-color: var(--accent-primary);
}

/* Nav separator */
.nav-separator {
    height: 1px;
    background: var(--border-light);
    margin: 0.5rem 0.75rem;
}

/* Page Tabs (for combined pages) */
.page-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.tab-btn.active {
    color: var(--accent-primary);
    background: var(--bg-tertiary);
}

.tab-btn svg {
    width: 16px;
    height: 16px;
}

.tab-content {
    flex: 1;
    overflow-y: auto;
}

.tab-content.hidden {
    display: none;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border-light);
}

.collector-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.collector-status .status-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.last-sync {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* Sidebar Logout Button */
.sidebar-logout {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border-light);
    margin-top: auto;
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-logout:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-logout svg {
    width: 14px;
    height: 14px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

/* Top Bar */
.top-bar {
    height: var(--topbar-height);
    padding: 0 1rem;
    display: none;  /* Hidden by default, shown via CSS when body.authenticated */
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
}

.menu-toggle svg {
    width: 20px;
    height: 20px;
}

.page-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-range-selector select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.btn-icon svg {
    width: 16px;
    height: 16px;
}

.btn-icon.loading svg {
    animation: spin 1s linear infinite;
}

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

/* Pages */
.page {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
}

.hidden {
    display: none !important;
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    text-align: center;
    max-width: 420px;
    width: 100%;
}

.login-logo {
    width: 72px;
    height: 72px;
    color: var(--accent-primary);
    margin-bottom: 1rem;
}

.login-card h2 {
    font-size: 1.35rem;
    margin-bottom: 0.5rem;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.login-form {
    text-align: left;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.login-form input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: border-color var(--transition-fast);
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

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

.login-error {
    color: var(--danger);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    min-height: 1.25rem;
}

.login-form .btn {
    width: 100%;
    margin-top: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn svg {
    width: 14px;
    height: 14px;
}

.btn-primary {
    background: var(--accent-primary);
    color: #000;
}

.btn-primary:hover {
    background: var(--accent-secondary);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-medium);
}

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

.btn-large {
    padding: 0.6rem 1.25rem;
    font-size: 0.85rem;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
}

/* Live Status Row */
.live-status-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.live-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    transition: all var(--transition-fast);
}

.live-card:hover {
    border-color: var(--border-medium);
}

.live-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.live-card-title {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--success);
}

.live-indicator .pulse {
    width: 5px;
    height: 5px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

/* Vehicle State Card */
.vehicle-state-content {
    display: flex;
    align-items: center;
}

.state-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.state-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
}

.state-icon svg {
    width: 18px;
    height: 18px;
}

.state-icon.online { background: var(--success-bg); color: var(--success); }
.state-icon.driving { background: var(--info-bg); color: var(--info); }
.state-icon.charging { background: var(--warning-bg); color: var(--warning); }
.state-icon.asleep { background: var(--bg-tertiary); color: var(--text-muted); }

.state-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
}

.state-since {
    display: block;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

/* Battery Card */
.battery-content {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.battery-gauge {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.battery-ring {
    transform: rotate(-90deg);
}

.battery-bg {
    fill: none;
    stroke: var(--bg-tertiary);
    stroke-width: 6;
}

.battery-progress {
    fill: none;
    stroke: var(--success);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 226.2;
    stroke-dashoffset: 226.2;
    transition: stroke-dashoffset 0.5s ease;
}

.battery-progress.low { stroke: var(--warning); }
.battery-progress.critical { stroke: var(--danger); }

.battery-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.battery-percent {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.battery-unit {
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.battery-info {
    flex: 1;
    min-width: 140px;
    display: flex;
    flex-direction: column;
}

.battery-details {
    width: 100%;
}

.battery-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-light);
    gap: 0.5rem;
}

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

.detail-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
}

.detail-value {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
}

/* Location Card */
.location-address {
    font-size: 0.75rem;
    color: var(--text-muted);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-map-container {
    height: 120px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.live-map {
    height: 100%;
    width: 100%;
    background: var(--bg-tertiary);
}

/* Climate Card */
.temp-display {
    display: flex;
    justify-content: space-around;
}

.temp-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.temp-item svg {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
}

.temp-data {
    text-align: center;
}

.temp-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.temp-value::after {
    content: '°C';
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.temp-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Charging Row */
.charging-row {
    margin-bottom: 1rem;
}

.charging-panel {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.05));
    border: 1px solid var(--warning);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.charging-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    color: var(--warning);
    font-weight: 600;
    font-size: 1rem;
}

.charging-header svg {
    width: 24px;
    height: 24px;
}

.charging-stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
}

.charging-stat {
    text-align: center;
}

.charging-stat-value {
    display: block;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--warning);
    font-family: 'JetBrains Mono', monospace;
}

.charging-stat-unit {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.charging-stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--accent-primary);
}

.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 16px;
    height: 16px;
}

.stat-icon.drives { background: var(--info-bg); color: var(--accent-blue); }
.stat-icon.charges { background: var(--warning-bg); color: var(--accent-primary); }
.stat-icon.efficiency { background: var(--success-bg); color: var(--accent-green); }
.stat-icon.cost { background: rgba(184, 119, 217, 0.12); color: var(--accent-purple); }
.stat-icon.trips { background: rgba(107, 156, 206, 0.12); color: var(--accent-primary); }
.stat-icon.time { background: var(--danger-bg); color: var(--accent-red); }

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.stat-trend {
    text-align: right;
}

.trend-value {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-trend.positive .trend-value {
    color: var(--success);
}

.stat-trend.negative .trend-value {
    color: var(--danger);
}

.stat-trend.neutral .trend-value {
    color: var(--text-muted);
}

/* Charts Row */
.charts-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.chart-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0;
    overflow: hidden;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-panel-header);
    border-bottom: 1px solid var(--border-color);
}

.chart-header h3 {
    font-size: 0.75rem;
    font-weight: 500;
}

.chart-container {
    height: 180px;
    position: relative;
    padding: 0.5rem;
}

.chart-container.large {
    height: 220px;
}

/* Activity Row */
.activity-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.activity-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0;
    min-width: 0;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-panel-header);
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    font-size: 0.75rem;
    font-weight: 500;
}

.view-all {
    font-size: 0.65rem;
    color: var(--accent-primary);
    text-decoration: none;
}

.view-all:hover {
    text-decoration: underline;
}

.activity-list {
    max-height: 220px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.25rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    min-width: 0;
}

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

.activity-icon {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon.drive {
    background: var(--info-bg);
    color: var(--accent-blue);
}

.activity-icon.charge {
    background: var(--warning-bg);
    color: var(--accent-primary);
}

.activity-icon svg {
    width: 14px;
    height: 14px;
}

.activity-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.activity-title {
    display: block;
    font-weight: 500;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.activity-subtitle {
    display: block;
    font-size: 0.6rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-value {
    text-align: right;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Drives Page */
.page-header {
    margin-bottom: 0.75rem;
}

.page-stats {
    display: flex;
    gap: 1rem;
}

.page-stat {
    text-align: center;
}

.page-stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.page-stat-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.drives-content, .charges-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    height: calc(100vh - var(--topbar-height) - 150px);
}

/* Show 2 columns when detail panel is open (class added via JS) */
.drives-content.has-detail-panel,
.charges-content.has-detail-panel {
    grid-template-columns: 1fr 400px;
}

/* Charges visuals (map + brand chart) */
.charges-visuals {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1rem;
    margin-bottom: 1rem;
}

.charges-map-container {
    width: 100%;
    height: 300px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.charges-map-container .map-full {
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
}

.charges-brand-chart {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 1rem;
}

.charges-brand-chart h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

@media (max-width: 992px) {
    .charges-visuals {
        grid-template-columns: 1fr;
    }

    .charges-brand-chart {
        order: -1;
    }
}

/* Charges à vérifier */
.data-table tr.needs-review {
    background: rgba(245, 158, 11, 0.05);
}

.data-table tr.needs-review:hover {
    background: rgba(245, 158, 11, 0.1);
}

.data-table td.cost-estimated {
    color: var(--warning);
    font-weight: 600;
}

.cost-warning {
    margin-right: 0.25rem;
    font-size: 0.9em;
    animation: pulse-warning 2s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Charge en cours (active) */
.data-table tr.charge-active {
    background: rgba(249, 115, 22, 0.1);
    border-left: 3px solid var(--warning);
}

.data-table tr.charge-active:hover {
    background: rgba(249, 115, 22, 0.15);
}

.data-table tr.charge-active td:first-child {
    position: relative;
    padding-left: 1.5rem;
}

.charge-active-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--warning);
    font-weight: 600;
}

.charge-active-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--warning);
    border-radius: 50%;
    animation: pulse-active 1.5s ease-in-out infinite;
}

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

/* Séparateurs de mois et semaine dans les tableaux */
.month-separator,
.week-separator {
    cursor: default !important;
}

.month-separator:hover,
.week-separator:hover {
    background: inherit !important;
}

.month-separator {
    background: var(--bg-secondary) !important;
}

.month-separator td {
    padding: 0.75rem 1rem !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.week-separator {
    background: rgba(107, 156, 206, 0.05) !important;
}

.week-separator td {
    padding: 0.5rem 1rem !important;
    padding-left: 2rem !important;
    border-bottom: 1px solid var(--border-light) !important;
}

/* Separator content layout */
.separator-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.separator-title {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.month-separator .separator-title {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.week-separator .separator-title {
    font-size: 0.75rem;
    color: var(--accent-primary);
}

.separator-stats {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: normal;
}

.drives-list-panel, .charges-list-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-toolbar {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.search-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.filter-select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.drives-table-container, .charges-table-container {
    flex: 1;
    overflow: auto;
}

/* Price per kWh indicator */
.price-per-kwh {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.data-table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 650px;
    font-size: 0.75rem;
}

.data-table th {
    position: sticky;
    top: 0;
    background: var(--bg-panel-header);
    padding: 0.4rem 0.6rem;
    text-align: left;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.75rem;
}

.data-table tbody tr {
    cursor: pointer;
    transition: background var(--transition-fast);
}

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

.data-table tbody tr.selected {
    background: rgba(107, 156, 206, 0.1);
}

.loading-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem !important;
}

/* Admin Page - User Management */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* User table styles */
.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.user-display-name {
    font-weight: 500;
    color: var(--text-primary);
}

.user-username {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.role-badge, .status-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.role-badge.admin {
    background: rgba(107, 156, 206, 0.15);
    color: var(--accent-primary);
}

.role-badge.user {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.status-badge.active {
    background: var(--success-bg);
    color: var(--success);
}

.status-badge.inactive {
    background: var(--danger-bg);
    color: var(--danger);
}

.primary-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    margin-left: 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--warning-bg);
    color: var(--warning);
}

/* Vehicle Access in User Modal */
.form-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.form-section h4 {
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.vehicles-access-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.vehicle-access-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.vehicle-access-item .vehicle-name {
    flex: 1;
    font-weight: 500;
}

.vehicle-access-item select {
    width: 140px;
}

.vehicle-access-item .primary-checkbox {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.vehicle-access-item .primary-checkbox input {
    margin: 0;
}

.vehicle-cell {
    font-weight: 500;
    vertical-align: middle;
    background: var(--bg-tertiary);
}

.actions-cell {
    display: flex;
    gap: 0.5rem;
}

.actions-cell .btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.actions-cell .btn-icon.delete-user:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.actions-cell .btn-icon svg {
    width: 16px;
    height: 16px;
}

.current-user {
    background: rgba(107, 156, 206, 0.05);
}

/* Admin page responsive */
@media (max-width: 768px) {
    #admin-page .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    #admin-page .page-header h2 {
        font-size: 1.25rem;
    }

    #admin-page .page-header .btn {
        width: 100%;
        justify-content: center;
    }

    #admin-page .data-table-container {
        margin: 0 -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    #admin-page .data-table {
        min-width: 550px;
    }

    #admin-page .data-table th,
    #admin-page .data-table td {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    #admin-page .user-display-name {
        font-size: 0.85rem;
    }

    #admin-page .user-username {
        font-size: 0.7rem;
    }

    #admin-page .role-badge,
    #admin-page .status-badge {
        padding: 0.2rem 0.5rem;
        font-size: 0.65rem;
    }

    #admin-page .actions-cell {
        gap: 0.25rem;
    }

    #admin-page .actions-cell .btn-icon {
        width: 28px;
        height: 28px;
    }

    #admin-page .actions-cell .btn-icon svg {
        width: 14px;
        height: 14px;
    }
}

/* Checkbox group in modals */
.checkbox-group {
    display: flex;
    align-items: center;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

/* Modal small variant */
.modal-content.small {
    max-width: 400px;
}

/* Map Panel */
.drives-map-panel, .locations-map-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.full-map {
    height: 100%;
    width: 100%;
    background: var(--bg-tertiary);
}

/* Charge Detail Panel */
.charge-detail-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    max-width: 500px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.detail-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.btn-close {
    background: transparent;
    border: none;
}

.detail-content {
    margin-bottom: 1.5rem;
}

/* Charge Detail Header */
.charge-detail-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.charge-type-info {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.charge-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.charge-type-badge.dc {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.charge-type-badge.ac {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success);
}

.charge-brand-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.charge-location {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Charge Detail Grid */
.charge-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.charge-detail-section {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 0.875rem;
}

.charge-detail-section h4 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.charge-detail-section .info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
}

.charge-detail-section .info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.charge-detail-section .info-value {
    font-size: 0.8rem;
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.charge-detail-section .info-value.highlight {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Charge Heating Info */
.charge-heating-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--warning-bg);
    border: 1px solid rgba(255, 152, 48, 0.3);
    border-radius: var(--radius-md);
    color: var(--warning);
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.charge-heating-info svg {
    flex-shrink: 0;
}

.detail-chart {
    height: 200px;
}

.detail-chart h4 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.detail-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.charge-electrical-info {
    display: flex;
    justify-content: space-around;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-top: 1rem;
}

.electrical-badge {
    text-align: center;
}

.electrical-badge .badge-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.electrical-badge .badge-value {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-primary);
}

/* Charge Brand Stats Panel */
.charge-brand-stats-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    max-width: 500px;
}

.brand-stats-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.brand-stat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.brand-stat-item .brand-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-stat-item .brand-logo {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card-hover);
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
}

.brand-stat-item .brand-name {
    font-weight: 600;
}

.brand-stat-item .brand-stats {
    display: flex;
    gap: 1.5rem;
}

.brand-stat-item .stat {
    text-align: right;
}

.brand-stat-item .stat-value {
    display: block;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.brand-stat-item .stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.charges-actions {
    padding: 1rem;
    display: flex;
    justify-content: flex-end;
}

/* Efficiency Page - Extended */
.efficiency-grid-extended {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
}

.efficiency-main-chart {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.efficiency-stats-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.efficiency-stats-panel h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.efficiency-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.eff-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.eff-stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.eff-stat-value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

.eff-stat-value.positive { color: var(--success); }
.eff-stat-value.negative { color: var(--danger); }

.eff-drives-count {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Goal Panel */
.efficiency-goal-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.efficiency-goal-panel .chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.efficiency-goal-panel select {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.goal-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.goal-progress-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.goal-progress-bar {
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.goal-progress-fill {
    height: 100%;
    border-radius: var(--radius-md);
    transition: width 0.5s ease;
}

.goal-progress-fill.excellent { background: var(--success); }
.goal-progress-fill.good { background: var(--warning); }
.goal-progress-fill.needs-work { background: var(--danger); }

.goal-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.goal-percent {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--text-primary);
}

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

.goal-target {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

/* Top Drives */
.efficiency-top-drives {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.top-drives-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.top-drives-column h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.top-drives-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.top-drive-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.2s;
}

.top-drive-item:hover {
    background: var(--bg-hover);
}

.top-drive-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    flex: 1;
}

.top-drive-route {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-drive-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.top-drive-efficiency {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    margin-left: 0.5rem;
}

/* Chart panels */
.efficiency-by-temp, .efficiency-by-speed, .efficiency-by-elevation,
.efficiency-by-month, .efficiency-by-hour {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.efficiency-by-elevation {
    grid-column: 1 / -1;
}

.efficiency-by-elevation .chart-container {
    height: 250px;
}

/* Regen Panel */
.efficiency-regen-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.efficiency-regen-panel h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.regen-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.regen-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

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

.regen-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

.regen-value.positive { color: var(--success); }

/* Routes Panel */
.efficiency-routes-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.efficiency-routes-panel h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.routes-comparison {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.route-comparison-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 0.75rem;
}

.route-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.route-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.route-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
}

.route-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.route-stat {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.route-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.route-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
}

.route-stat-value.positive { color: var(--success); }
.route-stat-value.negative { color: var(--danger); }

.route-drives {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.route-drive {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    padding: 0.25rem 0;
    cursor: pointer;
}

.route-drive:hover {
    background: var(--bg-hover);
    margin: 0 -0.25rem;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.route-drive span {
    flex: 1;
}

.route-drive .positive { color: var(--success); }
.route-drive .negative { color: var(--danger); }

.no-data {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 1rem;
}

/* Battery Page */
.battery-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    grid-template-rows: auto auto;
    gap: 1rem;
}

.battery-health-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.battery-health-content {
    text-align: center;
}

.health-gauge {
    position: relative;
    margin: 1rem 0;
}

.health-gauge svg {
    width: 100%;
    max-width: 200px;
}

.gauge-bg {
    fill: none;
    stroke: var(--bg-tertiary);
    stroke-width: 12;
    stroke-linecap: round;
}

.gauge-fill {
    fill: none;
    stroke: var(--success);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 251.3;
    stroke-dashoffset: 25;
    transition: stroke-dashoffset 0.5s ease;
}

.health-value {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.health-value span:first-child {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.health-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.health-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.health-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
}

.health-stat:last-child {
    border-bottom: none;
}

.health-stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.health-stat-value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.battery-level-chart {
    grid-column: 2;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.vampire-drain-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.vampire-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 1.5rem;
}

.vampire-stat {
    text-align: center;
}

.vampire-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--danger);
}

.vampire-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.charging-history-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

/* SOH History Panel */
.soh-history-panel {
    grid-column: 1 / -1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.soh-history-panel .chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.soh-prediction {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.soh-prediction .prediction-label {
    color: var(--text-secondary);
}

.soh-prediction .prediction-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--accent-primary);
}

.soh-info {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.soh-info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.soh-info-item .info-icon {
    font-size: 1rem;
}

.soh-info-item strong {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.soh-info-item.warranty {
    color: var(--success);
}

.soh-info-item.warranty strong {
    color: var(--success);
}

/* Locations Page */
.locations-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1rem;
    height: calc(100vh - var(--topbar-height) - 3rem);
}

.locations-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    overflow-y: auto;
}

.geofences-list, .frequent-locations {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.geofence-item, .location-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.geofence-item:hover, .location-item:hover {
    background: var(--bg-card-hover);
}

.geofence-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    color: white;
}

.geofence-icon svg {
    width: 18px;
    height: 18px;
}

.geofence-info {
    flex: 1;
}

.geofence-name {
    display: block;
    font-weight: 500;
}

.geofence-cost {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Settings Page */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.settings-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.settings-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.settings-description {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.settings-info.compact {
    margin-top: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.settings-info.compact .info-row {
    font-size: 0.8rem;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.form-group input, .form-group select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.settings-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
}

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

.info-value {
    font-weight: 500;
}

/* Toggle Switch */
.toggle-group {
    flex-direction: row !important;
    justify-content: space-between;
    align-items: center;
}

.toggle-group label:first-child {
    flex: 1;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
    background-color: white;
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Push Notification Settings */
.notification-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-indicator.status-unknown {
    background-color: var(--text-secondary);
}

.status-indicator.status-granted {
    background-color: var(--success-color);
}

.status-indicator.status-denied {
    background-color: var(--danger-color);
}

.status-indicator.status-unsupported {
    background-color: var(--warning-color);
}

.push-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.push-options.hidden {
    display: none;
}

/* Slider Input */
.slider-input {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
}

.slider-input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    border: none;
}

.form-group .slider-input + span {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-content.large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-light);
}

/* Loading & Empty States */
.loading-placeholder {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
}

/* Leaflet Customization */
.leaflet-container {
    background: var(--bg-primary) !important;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-card-hover) !important;
}

.leaflet-control-attribution {
    background: rgba(10, 10, 15, 0.8) !important;
    color: var(--text-muted) !important;
}

.leaflet-control-attribution a {
    color: var(--text-secondary) !important;
}

/* Responsive */
@media (max-width: 1400px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .charging-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1200px) {
    .live-status-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .drives-content, .charges-content {
        grid-template-columns: 1fr;
    }

    .drives-map-panel {
        height: 300px;
    }
}

@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: -100%;
        transition: left var(--transition-normal);
    }

    .sidebar.open {
        left: 0;
    }

    .menu-toggle {
        display: block;
    }

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

    .charts-row, .activity-row {
        grid-template-columns: 1fr;
    }

    .activity-panel {
        padding: 1rem;
    }

    .activity-item {
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .activity-icon {
        width: 28px;
        height: 28px;
    }

    .activity-icon svg {
        width: 14px;
        height: 14px;
    }

    .activity-title {
        font-size: 0.8rem;
    }

    .activity-value {
        font-size: 0.8rem;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .locations-content {
        grid-template-columns: 1fr;
    }

    .locations-sidebar {
        max-height: 300px;
    }
}

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

    .charging-stats,
    .driving-stats,
    .navigation-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-stats {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

/* Driving Row */
.driving-row {
    margin-bottom: 1.5rem;
}

.driving-panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

.driving-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    color: var(--accent-primary);
    font-weight: 600;
}

.driving-header svg {
    width: 24px;
    height: 24px;
}

.status-indicators {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
}

.status-indicators-main {
    margin-left: 0;
    margin-top: 0.75rem;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.status-indicator {
    font-size: 1rem;
    cursor: help;
}

.driving-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1.5rem;
}

.driving-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.driving-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.driving-stat-unit {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

.driving-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

/* Navigation Row */
.navigation-row {
    margin-bottom: 1.5rem;
}

.navigation-panel {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    border-radius: var(--radius-lg);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 1.25rem 1.5rem;
}

.navigation-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    color: var(--success);
    font-weight: 600;
}

.navigation-header svg {
    width: 24px;
    height: 24px;
}

.navigation-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2rem;
}

.nav-destination-info {
    flex: 1;
    min-width: 200px;
}

.nav-destination-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.nav-destination-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.navigation-stats {
    display: flex;
    gap: 2rem;
}

.nav-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.nav-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
    font-family: 'JetBrains Mono', monospace;
}

.nav-stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

/* Destination marker on map */
.destination-marker {
    background: none !important;
    border: none !important;
}

/* Analytics Page */
#analytics-page {
    overflow-x: hidden;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.analytics-overview {
    grid-column: 1 / -1;
}

.analytics-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.analytics-card.large {
    padding: 1.25rem;
}

.analytics-card.wide {
    grid-column: span 2;
}

.analytics-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.analytics-card-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
}

.badge {
    background: var(--accent-gradient);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.overview-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.overview-stat {
    text-align: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.overview-stat.highlight {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.overview-stat.highlight .overview-value {
    color: var(--success);
}

.overview-value {
    display: block;
    font-size: 1.35rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-primary);
}

.overview-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.destinations-list, .charging-locations-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
}

.destination-item, .charging-location-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.destination-item:hover, .charging-location-item:hover {
    background: var(--bg-card-hover);
}

.destination-rank, .charging-location-rank {
    width: 24px;
    height: 24px;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.destination-info, .charging-location-info {
    flex: 1;
    min-width: 0;
}

.destination-name, .charging-location-name {
    display: block;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.destination-city, .charging-location-energy {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.destination-count, .charging-location-cost {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text-secondary);
}

.cost-summary {
    display: flex;
    justify-content: space-around;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.cost-item {
    text-align: center;
}

.cost-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.cost-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* Analytics Extended Grid */
.analytics-grid-extended {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.analytics-card.full-width {
    grid-column: 1 / -1;
}

/* Overview Stats Extended */
.overview-stats-extended {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    width: 100%;
}

.overview-change {
    display: block;
    font-size: 0.7rem;
    margin-top: 0.25rem;
    font-weight: 500;
}

.overview-change.positive {
    color: var(--success);
}

.overview-change.negative {
    color: var(--error);
}

/* Period Selector */
.period-selector select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
}

/* Environmental Impact */
.env-impact-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.env-stat {
    text-align: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.env-icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.env-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--success);
}

.env-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Charging Split (Home vs Away) */
.charging-split {
    padding: 0.5rem 0;
}

.split-bar {
    height: 12px;
    background: rgba(245, 158, 11, 0.3);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.split-home {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--accent-green));
    border-radius: 6px;
    transition: width 0.5s ease;
}

.split-legend {
    display: flex;
    justify-content: space-around;
    margin-bottom: 1rem;
}

.split-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.split-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.split-item.home .split-dot {
    background: var(--success);
}

.split-item.away .split-dot {
    background: var(--warning);
}

.split-value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.split-details {
    display: flex;
    justify-content: space-around;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Budget Section */
.budget-progress {
    padding: 0.5rem 0;
}

.budget-bar {
    height: 20px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.budget-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--accent-green));
    border-radius: 10px;
    transition: width 0.5s ease;
}

.budget-fill.warning {
    background: linear-gradient(90deg, var(--warning), var(--accent-yellow));
}

.budget-fill.danger {
    background: linear-gradient(90deg, var(--danger), var(--accent-red));
}

.budget-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.budget-spent {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

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

.budget-prediction {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-light);
}

/* Records Grid */
.records-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.record-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    transition: transform 0.2s, background 0.2s;
}

.record-item:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

.record-icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.record-title {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.record-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-primary);
}

.record-date {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Activity Calendar */
.activity-calendar {
    overflow-x: auto;
    padding: 0.5rem 0;
}

.cal-table {
    border-collapse: separate;
    border-spacing: 3px;
}

.cal-table thead th {
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--text-secondary);
    text-align: left;
    padding: 0 0 4px 0;
    vertical-align: bottom;
}

.cal-cell {
    width: 11px;
    height: 11px;
    border-radius: 2px;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: transform 0.1s;
    padding: 0;
}

.cal-cell:hover {
    transform: scale(1.3);
    position: relative;
    z-index: 1;
}

.cal-cell.future {
    opacity: 0.3;
}

.cal-cell.empty {
    visibility: hidden;
}

.cal-cell[data-level="0"] { background: var(--bg-tertiary); }
.cal-cell[data-level="1"] { background: rgba(107, 156, 206, 0.3); }
.cal-cell[data-level="2"] { background: rgba(107, 156, 206, 0.5); }
.cal-cell[data-level="3"] { background: rgba(107, 156, 206, 0.7); }
.cal-cell[data-level="4"] { background: rgba(107, 156, 206, 0.9); }

.calendar-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.cal-level {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.cal-level[data-level="0"] { background: var(--bg-tertiary); }
.cal-level[data-level="1"] { background: rgba(107, 156, 206, 0.3); }
.cal-level[data-level="2"] { background: rgba(107, 156, 206, 0.5); }
.cal-level[data-level="3"] { background: rgba(107, 156, 206, 0.7); }
.cal-level[data-level="4"] { background: rgba(107, 156, 206, 0.9); }

.calendar-summary {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-light);
}

/* Average Trip Stats */
.avg-trip-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.avg-stat {
    text-align: center;
    padding: 1rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.avg-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-primary);
}

.avg-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Responsive for Analytics Extended */
@media (max-width: 1600px) {
    .analytics-grid-extended {
        grid-template-columns: repeat(3, 1fr);
    }

    .overview-stats-extended {
        grid-template-columns: repeat(3, 1fr);
    }

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

@media (max-width: 1200px) {
    .analytics-grid-extended {
        grid-template-columns: repeat(2, 1fr);
    }

    .overview-stats-extended {
        grid-template-columns: repeat(2, 1fr);
    }

    .env-impact-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .analytics-grid-extended {
        grid-template-columns: 1fr;
    }

    .analytics-card.wide,
    .analytics-card.full-width {
        grid-column: 1;
    }

    .overview-stats-extended {
        grid-template-columns: repeat(2, 1fr);
    }

    .env-impact-grid {
        grid-template-columns: 1fr;
    }

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

    .avg-trip-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .calendar-grid {
        min-width: 600px;
    }
}

@media (max-width: 1400px) {
    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .analytics-card.wide {
        grid-column: span 2;
    }

    .overview-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

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

    .analytics-card.wide {
        grid-column: span 1;
    }

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

@media (max-width: 768px) {
    #analytics-page {
        overflow-x: hidden;
        width: 100%;
    }

    .analytics-grid {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
        max-width: 100%;
    }

    .analytics-overview {
        width: 100%;
    }

    .analytics-card {
        padding: 1rem;
        border-radius: var(--radius-md);
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        box-sizing: border-box;
    }

    .analytics-card.large {
        padding: 1rem;
    }

    .analytics-card.wide {
        width: 100%;
    }

    .analytics-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .analytics-card-header h3 {
        font-size: 0.85rem;
    }

    .overview-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        width: 100%;
    }

    .overview-stat {
        padding: 0.6rem 0.4rem;
        min-width: 0;
        overflow: hidden;
    }

    .overview-value {
        font-size: 1rem;
        word-break: break-all;
    }

    .overview-label {
        font-size: 0.6rem;
        word-break: break-word;
    }

    .chart-container {
        height: 180px !important;
        min-height: 180px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .chart-container.large {
        height: 220px !important;
    }

    .chart-container canvas {
        max-width: 100% !important;
        width: 100% !important;
    }

    .destinations-list,
    .charging-locations-list {
        max-height: 200px;
    }

    .destination-item,
    .charging-location-item {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .destination-name,
    .charging-location-name {
        font-size: 0.8rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .destination-visits,
    .charging-location-visits {
        font-size: 0.7rem;
    }

    .cost-summary {
        flex-direction: column;
        gap: 0.5rem;
    }

    .cost-item {
        flex-direction: row;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .overview-stats {
        grid-template-columns: 1fr;
    }

    .overview-stat {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: left;
        padding: 0.75rem 1rem;
    }

    .overview-value {
        font-size: 1.1rem;
        order: 2;
    }

    .overview-label {
        font-size: 0.75rem;
        margin-top: 0;
        order: 1;
    }
}

/* =================== */
/* Timeline Page       */
/* =================== */

.timeline-container {
    max-width: 900px;
    margin: 0 auto;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.timeline-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.timeline-filters {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.filter-btn.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 40px;
    flex-shrink: 0;
}

.timeline-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.timeline-icon svg {
    width: 20px;
    height: 20px;
}

.timeline-icon.drive {
    background: var(--info-bg);
    color: var(--info);
}

.timeline-icon.charge {
    background: var(--warning-bg);
    color: var(--warning);
}

.timeline-icon.sleep {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.timeline-icon.update {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-secondary);
}

.timeline-line {
    width: 2px;
    flex: 1;
    background: var(--border-color);
    margin-top: 0.5rem;
}

.timeline-content {
    flex: 1;
    min-width: 0;
}

.timeline-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.timeline-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.timeline-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.timeline-stats {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.timeline-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.timeline-stat-value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

.timeline-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.timeline-date-separator {
    padding: 1rem 0;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* =================== */
/* Stats Page          */
/* =================== */

#stats-page .stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stats-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.stats-card.hero {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, var(--bg-card), var(--bg-tertiary));
}

.stats-card.wide {
    grid-column: span 2;
}

.stats-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.stats-card-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Lifetime Stats */
.lifetime-stats {
    text-align: center;
}

.lifetime-main {
    margin-bottom: 2rem;
}

.lifetime-odometer {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
}

.odo-value {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.odo-unit {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.lifetime-since {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.lifetime-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.lifetime-item {
    text-align: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.lifetime-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-primary);
}

.lifetime-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Mileage Stats */
.mileage-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mileage-avg {
    display: flex;
    justify-content: space-around;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.avg-item {
    text-align: center;
}

.avg-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.avg-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Charging Breakdown */
.charging-breakdown {
    padding: 0.5rem 0;
}

.charge-types {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.charge-type {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.charge-type .type-icon {
    font-size: 1.25rem;
}

.charge-type .type-name {
    flex: 1;
    font-weight: 500;
}

.charge-type .type-value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-primary);
}

.charge-type.home {
    border-left: 3px solid var(--success);
}

.charge-type.supercharger {
    border-left: 3px solid var(--warning);
}

.charge-type.public {
    border-left: 3px solid var(--info);
}

/* Tire Pressure */
.tire-pressure-display {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.car-outline {
    position: relative;
    width: 140px;
    height: 220px;
}

.car-body {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    opacity: 0.3;
}

.car-body svg {
    width: 100px;
    height: 180px;
}

.tire {
    position: absolute;
    text-align: center;
    background: var(--bg-tertiary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    min-width: 50px;
}

.tire.fl { top: 20px; left: -10px; }
.tire.fr { top: 20px; right: -10px; }
.tire.rl { bottom: 30px; left: -10px; }
.tire.rr { bottom: 30px; right: -10px; }

.tire-value {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.tire-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.tire.warning {
    border: 1px solid var(--warning);
    background: var(--warning-bg);
}

.tire.danger {
    border: 1px solid var(--danger);
    background: var(--danger-bg);
}

/* Eco Stats */
.eco-stats {
    text-align: center;
    padding: 1rem;
}

.eco-main {
    margin-bottom: 1rem;
}

.eco-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--success);
}

.eco-unit {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.eco-equivalent {
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 0.75rem;
    background: var(--success-bg);
    border-radius: var(--radius-md);
}

.eco-equivalent span {
    color: var(--success);
    font-weight: 600;
}

/* Range Projection */
.range-projection {
    padding: 1rem;
}

.range-current {
    display: flex;
    justify-content: space-around;
    margin-bottom: 1.5rem;
}

.range-item {
    text-align: center;
}

.range-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.range-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.range-chart-container {
    height: 200px;
    margin-bottom: 1rem;
}

.range-predictions {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.prediction-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.prediction-item strong {
    color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace;
}

/* TCO Stats */
.tco-stats {
    padding: 1rem;
}

.tco-main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tco-item {
    text-align: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.tco-item.large {
    background: var(--accent-gradient);
}

.tco-item.large .tco-value {
    color: white;
}

.tco-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.tco-item.large .tco-label {
    color: rgba(255, 255, 255, 0.8);
}

.tco-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.tco-value.positive {
    color: var(--success);
}

.tco-breakdown {
    margin-bottom: 1.5rem;
}

.tco-breakdown h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.tco-breakdown-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.tco-breakdown-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.tco-breakdown-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.tco-breakdown-value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.tco-comparison h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.tco-comparison .chart-container {
    position: relative;
    height: 200px;
    width: 100%;
}

/* Stats Page Responsive */
@media (max-width: 1200px) {
    #stats-page .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-card.wide {
        grid-column: span 2;
    }

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

@media (max-width: 768px) {
    #stats-page .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-card.hero,
    .stats-card.wide {
        grid-column: span 1;
    }

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

    .odo-value {
        font-size: 2.5rem;
    }

    .timeline-filters {
        flex-wrap: wrap;
    }
}

/* =================== */
/* Drive Detail Modal  */
/* =================== */

.modal-content.xlarge {
    max-width: 1200px;
    width: 95%;
    max-height: 95vh;
}

.drive-detail-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
    max-height: calc(95vh - 60px);
    padding: 1rem;
}

/* Drive Summary */
.drive-detail-summary {
    display: flex;
    gap: 2rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
}

.drive-route {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 250px;
}

.route-point {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.route-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-top: 4px;
    flex-shrink: 0;
}

.route-point.start .route-dot {
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.route-point.end .route-dot {
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.route-line {
    width: 2px;
    height: 30px;
    background: var(--border-color);
    margin-left: 5px;
}

.route-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.route-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.route-address {
    font-weight: 500;
    font-size: 0.9rem;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.route-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

.drive-stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    flex: 1;
    justify-content: flex-end;
    align-items: center;
}

.drive-stat {
    text-align: center;
    min-width: 80px;
}

.drive-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-primary);
}

.drive-stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 0.25rem;
}

/* Drive Map */
.drive-detail-map {
    position: relative;
}

.track-map {
    height: 400px;
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
}

.map-legend {
    display: flex;
    gap: 1rem;
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: var(--bg-card);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    z-index: 1000;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 16px;
    height: 4px;
    border-radius: 2px;
}

.legend-color.speed-low {
    background: var(--success);
}

.legend-color.speed-medium {
    background: var(--warning);
}

.legend-color.speed-high {
    background: var(--danger);
}

/* Drive Charts */
.drive-detail-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.drive-chart-container {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.drive-chart-container h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.drive-chart-container canvas {
    height: 150px !important;
}

/* Clickable table rows */
#drives-tbody tr {
    cursor: pointer;
    transition: background var(--transition-fast);
}

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

/* ========================
   ALERTS PAGE
   ======================== */

.alerts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 1.25rem;
}

.alerts-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.alerts-config-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.alerts-history-panel {
    grid-column: 1 / -1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    max-height: 300px;
    overflow-y: auto;
}

.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.alerts-list .no-alerts {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-muted);
}

.alerts-list .no-alerts svg {
    color: var(--success);
    opacity: 0.6;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--info);
}

.alert-item.critical {
    border-left-color: var(--danger);
    background: var(--danger-bg);
}

.alert-item.warning {
    border-left-color: var(--warning);
    background: var(--warning-bg);
}

.alert-item.info {
    border-left-color: var(--info);
    background: var(--info-bg);
}

.alert-item .alert-icon {
    font-size: 1.2rem;
}

.alert-item .alert-content {
    flex: 1;
}

.alert-item .alert-message {
    font-weight: 500;
}

.alert-item .alert-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Thresholds form */
.thresholds-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.threshold-group {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.threshold-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.threshold-header label {
    font-weight: 500;
}

.threshold-header input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

.threshold-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.threshold-input input[type="number"] {
    width: 70px;
    padding: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    text-align: center;
}

.threshold-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Alert badge in nav */
.nav-item .alert-badge {
    position: absolute;
    top: 8px;
    right: 10px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

.nav-item .alert-badge.hidden {
    display: none;
}

/* Alert history list */
.alerts-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.alert-history-item .history-icon {
    opacity: 0.7;
}

.alert-history-item .history-message {
    flex: 1;
}

.alert-history-item .history-time {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Responsive */
@media (max-width: 992px) {
    .drive-detail-summary {
        flex-direction: column;
    }

    .drive-stats-grid {
        justify-content: flex-start;
    }

    .drive-detail-charts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .modal-content.xlarge {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .track-map {
        height: 300px;
    }
}

/* ===========================================
   Climate Page (Nouveau)
   =========================================== */

.climate-current-grid {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 2rem;
    align-items: center;
}

.climate-temp-display {
    display: flex;
    gap: 1.5rem;
}

.temp-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.1));
    border: 2px solid rgba(239, 68, 68, 0.3);
}

.temp-circle.outside {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.1));
    border-color: rgba(59, 130, 246, 0.3);
}

.temp-circle .temp-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.temp-circle .temp-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.climate-settings {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.climate-setting {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.climate-setting .setting-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.climate-setting .setting-value {
    font-weight: 600;
    font-family: var(--font-mono);
}

.climate-status-indicators {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.climate-status-indicators .status-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.climate-status-indicators .status-indicator.active {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}

.climate-status-indicators .indicator-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.climate-status-indicators .indicator-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
}

.climate-status-indicators .indicator-value {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.climate-impact-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Mise en page dédiée Climat : cartes en colonne et graphiques pleine largeur */
#climate-page .page-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

#climate-page .stat-card {
    flex-direction: column;
    align-items: stretch;
}

#climate-page .chart-container {
    height: 320px;
}

#climate-page .chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

@media (min-width: 1280px) {
    #climate-page .chart-container {
        height: 360px;
    }
}

.impact-stat {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.impact-stat .impact-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.impact-stat .impact-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.impact-stat .impact-count {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.impact-difference {
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 600;
}

.impact-difference.negative {
    color: var(--danger);
}

@media (max-width: 992px) {
    .climate-current-grid {
        grid-template-columns: 1fr;
    }

    .climate-temp-display {
        justify-content: center;
    }
}

/* ===========================================
   Software Page (Nouveau)
   =========================================== */

.software-current {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.version-number {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--primary);
}

.update-badge {
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.software-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.software-stats .stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.software-stats .stat-label {
    color: var(--text-secondary);
}

.software-stats .stat-value {
    font-weight: 600;
    font-family: var(--font-mono);
}

.software-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.software-update-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--success);
}

.software-update-item.in_progress {
    border-left-color: var(--warning);
}

.update-version {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.update-version .version {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.1rem;
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.completed {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.status-badge.in_progress {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.update-details {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.update-duration {
    font-family: var(--font-mono);
}

/* ===========================================
   Patterns Page (Nouveau)
   =========================================== */

.card-description {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.recurring-trips-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recurring-trip-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary);
}

.trip-route {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.trip-from, .trip-to {
    font-weight: 500;
}

.trip-arrow {
    color: var(--text-tertiary);
}

.trip-stats {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.trip-count {
    font-weight: 600;
    color: var(--primary);
}

/* Heatmap */
.heatmap-container {
    overflow-x: auto;
}

.heatmap-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 600px;
}

.heatmap-row {
    display: flex;
    gap: 2px;
    align-items: center;
}

.heatmap-row.header {
    margin-bottom: 0.25rem;
}

.heatmap-label {
    width: 40px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: right;
    padding-right: 0.5rem;
}

.heatmap-hour {
    width: 20px;
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-tertiary);
}

.heatmap-cell {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    transition: all var(--transition-fast);
}

.heatmap-cell:hover {
    transform: scale(1.2);
}

.heatmap-cell.level-0 { background: var(--bg-tertiary); }
.heatmap-cell.level-1 { background: rgba(16, 185, 129, 0.2); }
.heatmap-cell.level-2 { background: rgba(16, 185, 129, 0.4); }
.heatmap-cell.level-3 { background: rgba(16, 185, 129, 0.6); }
.heatmap-cell.level-4 { background: rgba(16, 185, 129, 0.9); }

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.heatmap-legend .legend-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.heatmap-legend .legend-scale {
    display: flex;
    gap: 2px;
}

.heatmap-legend .legend-item {
    width: 16px;
    height: 16px;
    border-radius: 2px;
}

/* Comparison */
.period-selector {
    margin-bottom: 1rem;
}

.period-selector select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.comparison-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.comparison-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

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

.comparison-current {
    font-weight: 600;
    font-family: var(--font-mono);
}

.comparison-previous {
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

.change {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.change.positive {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.change.negative {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.change.neutral {
    background: var(--bg-secondary);
    color: var(--text-tertiary);
}

/* Export */
.export-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.export-buttons .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Alerts */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border-left: 3px solid;
}

.alert-item.critical {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: var(--danger);
}

.alert-item.warning {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: var(--warning);
}

.alert-item.info {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--info);
}

.no-alerts {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.no-data, .loading, .error {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.error {
    color: var(--danger);
}

/* =====================
   Theme Toggle
   ===================== */

.theme-toggle {
    position: relative;
}

.theme-toggle .theme-icon-light {
    display: none;
}

.theme-toggle .theme-icon-dark {
    display: block;
}

[data-theme="light"] .theme-toggle .theme-icon-light {
    display: block;
}

[data-theme="light"] .theme-toggle .theme-icon-dark {
    display: none;
}

/* =====================
   Light Theme Variables
   ===================== */

[data-theme="light"] {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f2f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f5f7fa;
    --bg-input: #f0f2f5;

    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --text-dim: #a0aec0;

    --accent-primary: #5a5fd9;
    --accent-secondary: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #5a5fd9, #7c3aed);

    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.1);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.1);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.1);
    --info: #2563eb;
    --info-bg: rgba(37, 99, 235, 0.1);

    --border-color: #e2e8f0;
    --border-light: #edf2f7;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(90, 95, 217, 0.2);
}

/* Light theme specific adjustments */
[data-theme="light"] body {
    background: var(--bg-primary);
}

[data-theme="light"] .sidebar {
    background: var(--bg-secondary);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .top-bar {
    background: var(--bg-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .metric-card,
[data-theme="light"] .data-card,
[data-theme="light"] .panel,
[data-theme="light"] .live-card {
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .metric-card:hover,
[data-theme="light"] .data-card:hover {
    box-shadow: var(--shadow-md);
}

[data-theme="light"] .nav-item:hover {
    background: var(--bg-tertiary);
}

[data-theme="light"] .nav-item.active {
    background: var(--accent-primary);
    color: white;
}

[data-theme="light"] .nav-item.active svg {
    color: white;
}

[data-theme="light"] .btn-primary {
    background: var(--accent-gradient);
    color: white;
}

[data-theme="light"] .data-table thead {
    background: var(--bg-tertiary);
}

[data-theme="light"] .data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

[data-theme="light"] .modal-content {
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
}

[data-theme="light"] .chart-container {
    background: var(--bg-card);
}

[data-theme="light"] select,
[data-theme="light"] input {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="light"] .badge {
    background: var(--bg-tertiary);
}

[data-theme="light"] .vehicle-dropdown {
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
}

[data-theme="light"] .dropdown-item:hover {
    background: var(--bg-tertiary);
}

[data-theme="light"] .login-card {
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
}

[data-theme="light"] .notification {
    background: var(--bg-card);
    box-shadow: var(--shadow-md);
}

[data-theme="light"] .tab-btn {
    color: var(--text-secondary);
}

[data-theme="light"] .tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

[data-theme="light"] .threshold-group {
    background: var(--bg-tertiary);
}

[data-theme="light"] .soh-history-panel,
[data-theme="light"] .soh-predictions-panel,
[data-theme="light"] .range-projection-panel,
[data-theme="light"] .tco-stats-panel {
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .tco-breakdown-item,
[data-theme="light"] .prediction-item {
    background: var(--bg-tertiary);
}

/* Theme transition */
body,
.sidebar,
.top-bar,
.metric-card,
.data-card,
.panel,
.live-card,
.modal-content,
.chart-container,
select,
input,
.badge,
.vehicle-dropdown,
.dropdown-item,
.login-card,
.notification,
.nav-item {
    transition: background-color var(--transition-normal),
                border-color var(--transition-normal),
                box-shadow var(--transition-normal),
                color var(--transition-normal);
}

/* =====================
   Toast Notifications
   ===================== */

.toast-container {
    position: fixed;
    top: calc(var(--topbar-height) + 1rem);
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease;
    max-width: 100%;
}

.toast.exiting {
    animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.toast-icon svg {
    width: 16px;
    height: 16px;
}

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

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

.toast.warning .toast-icon {
    background: var(--warning-bg);
    color: var(--warning);
}

.toast.info .toast-icon {
    background: var(--info-bg);
    color: var(--info);
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    word-wrap: break-word;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    margin: -0.25rem -0.25rem -0.25rem 0.5rem;
}

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

.toast-close svg {
    width: 16px;
    height: 16px;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--accent-primary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    animation: toastProgress 4s linear forwards;
}

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

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

.toast.warning .toast-progress {
    background: var(--warning);
}

.toast.info .toast-progress {
    background: var(--info);
}

@keyframes toastProgress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

/* Light theme toast adjustments */
[data-theme="light"] .toast {
    background: var(--bg-card);
    box-shadow: var(--shadow-md), 0 0 0 1px var(--border-light);
}

/* =========================================
   MOBILE OPTIMIZATION - Complete Overhaul
   ========================================= */

/* Mobile Variables */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        --topbar-height: 56px;
        --radius-sm: 4px;
        --radius-md: 8px;
        --radius-lg: 12px;
    }
}

/* =====================
   Mobile Sidebar
   ===================== */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

    .sidebar.open {
        left: 0;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.5);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    .sidebar-header {
        padding: 1rem;
    }

    .logo-text {
        font-size: 1.25rem;
    }

    .vehicle-selector {
        margin: 0.5rem 0.75rem;
    }

    .nav-item {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
    }

    .nav-item svg {
        width: 22px;
        height: 22px;
    }

    .sidebar-footer {
        padding: 0.75rem 1rem;
    }

    /* Main content when sidebar is open */
    .main-content {
        margin-left: 0;
        width: 100%;
    }
}

/* =====================
   Mobile Top Bar
   ===================== */
@media (max-width: 768px) {
    .top-bar {
        padding: 0 0.75rem;
        height: var(--topbar-height);
        gap: 0.5rem;
    }

    .top-bar-left {
        gap: 0.5rem;
    }

    .page-title {
        font-size: 1rem;
        max-width: 120px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .menu-toggle {
        display: flex;
        width: 40px;
        height: 40px;
    }

    .top-bar-right {
        gap: 0.25rem;
    }

    .date-range-selector select {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
        min-width: auto;
        max-width: 100px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
    }

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

    /* Hide theme toggle text on mobile */
    .theme-toggle {
        width: 36px;
        height: 36px;
    }
}

/* =====================
   Mobile Page Container
   ===================== */
@media (max-width: 768px) {
    .page {
        padding: 0.75rem;
        padding-top: calc(var(--topbar-height) + 0.75rem);
        overflow-x: hidden;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .main-content {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .page-header h2 {
        font-size: 1.25rem;
    }

    .page-actions {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }

    .page-actions .btn {
        flex: 1;
        justify-content: center;
    }
}

/* =====================
   Mobile Live Status Cards
   ===================== */
@media (max-width: 768px) {
    .live-status-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .live-card {
        padding: 1rem;
    }

    .live-card-header {
        margin-bottom: 0.75rem;
    }

    .live-card-title {
        font-size: 0.75rem;
    }

    /* Vehicle state card */
    .vehicle-state-card .vehicle-illustration {
        height: 100px;
    }

    .vehicle-state-card .state-badge {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }

    /* Battery card */
    .battery-visual {
        height: 80px;
    }

    .battery-percentage {
        font-size: 2rem;
    }

    .battery-details {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Location card */
    .location-info {
        font-size: 0.9rem;
    }

    /* Stats row in live cards */
    .live-stats-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .live-stat {
        flex: 1;
        min-width: calc(50% - 0.5rem);
        padding: 0.5rem;
        background: var(--bg-tertiary);
        border-radius: var(--radius-sm);
        text-align: center;
    }

    .live-stat-value {
        font-size: 1.1rem;
    }

    .live-stat-label {
        font-size: 0.65rem;
    }
}

/* =====================
   Mobile Metric Cards
   ===================== */
@media (max-width: 768px) {
    .stats-grid,
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .metric-card,
    .stats-card {
        padding: 0.875rem;
    }

    .metric-icon {
        width: 32px;
        height: 32px;
    }

    .metric-icon svg {
        width: 16px;
        height: 16px;
    }

    .metric-value {
        font-size: 1.25rem;
    }

    .metric-unit {
        font-size: 0.7rem;
    }

    .metric-label {
        font-size: 0.65rem;
    }

    .metric-change {
        font-size: 0.6rem;
    }

    /* Hero cards full width on mobile */
    .stats-card.hero,
    .metric-card.hero {
        grid-column: 1 / -1;
    }
}

/* =====================
   Mobile Charts
   ===================== */
@media (max-width: 768px) {
    .charts-row,
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .chart-card,
    .panel {
        padding: 0.875rem;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .chart-title {
        font-size: 0.9rem;
    }

    .chart-container {
        height: 200px !important;
        min-height: 200px;
    }

    /* Smaller charts on mobile */
    .chart-container.small {
        height: 150px !important;
    }

    .chart-container.large {
        height: 250px !important;
    }

    .chart-legend {
        flex-wrap: wrap;
        gap: 0.5rem;
        font-size: 0.7rem;
    }
}

/* =====================
   Mobile Tables
   ===================== */
@media (max-width: 768px) {
    .data-table-container {
        margin: 0 -0.75rem;
        border-radius: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        font-size: 0.8rem;
        min-width: 600px;
    }

    .data-table th,
    .data-table td {
        padding: 0.6rem 0.75rem;
        white-space: nowrap;
    }

    .data-table th:first-child,
    .data-table td:first-child {
        position: sticky;
        left: 0;
        background: var(--bg-card);
        z-index: 1;
    }

    /* Mobile card view for tables */
    .mobile-card-view {
        display: block;
    }

    .mobile-card-view .data-table {
        display: none;
    }

    .mobile-card-item {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 1rem;
        margin-bottom: 0.75rem;
    }

    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
        border-bottom: 1px solid var(--border-light);
    }

    .mobile-card-title {
        font-weight: 600;
        font-size: 0.9rem;
        color: var(--text-primary);
    }

    .mobile-card-subtitle {
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    .mobile-card-body {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .mobile-card-stat {
        display: flex;
        flex-direction: column;
    }

    .mobile-card-stat-label {
        font-size: 0.65rem;
        color: var(--text-muted);
        text-transform: uppercase;
    }

    .mobile-card-stat-value {
        font-size: 0.9rem;
        font-weight: 500;
        color: var(--text-primary);
    }
}

/* =====================
   Mobile Drives Page
   ===================== */
@media (max-width: 768px) {
    .drives-content {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .drives-list-panel {
        order: 2;
    }

    .drives-map-panel {
        order: 1;
        height: 200px;
        border-radius: var(--radius-md);
    }

    .drive-item {
        padding: 0.875rem;
    }

    .drive-item-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .drive-route-info {
        width: 100%;
    }

    .drive-item-stats {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        width: 100%;
    }

    .drive-stat {
        text-align: center;
        padding: 0.5rem;
        background: var(--bg-tertiary);
        border-radius: var(--radius-sm);
    }
}

/* =====================
   Mobile Charges Page
   ===================== */
@media (max-width: 768px) {
    .charges-content {
        grid-template-columns: 1fr;
    }

    .charges-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .charge-item {
        padding: 0.875rem;
    }

    .charge-item-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .charge-item-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        width: 100%;
    }

    .charge-type-badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
}

/* =====================
   Mobile Stats Page
   ===================== */
@media (max-width: 768px) {
    #stats-page .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-card.hero {
        grid-column: span 1;
    }

    .odo-value {
        font-size: 2rem;
    }

    .odo-unit {
        font-size: 1rem;
    }

    .lifetime-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .lifetime-stat {
        padding: 0.75rem;
    }

    .lifetime-value {
        font-size: 1.25rem;
    }

    /* Range projection */
    .range-projection-panel {
        padding: 1rem;
    }

    .range-chart-container {
        height: 200px;
    }

    /* TCO Stats */
    .tco-stats-panel {
        padding: 1rem;
    }

    .tco-summary {
        flex-direction: column;
        gap: 1rem;
    }

    .tco-breakdown {
        grid-template-columns: 1fr;
    }
}

/* =====================
   Mobile Battery Page
   ===================== */
@media (max-width: 768px) {
    .battery-grid {
        grid-template-columns: 1fr;
    }

    .battery-main-card {
        padding: 1rem;
    }

    .soh-display {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .soh-percentage {
        font-size: 3rem;
    }

    .soh-history-panel,
    .soh-predictions-panel {
        padding: 1rem;
    }

    .prediction-grid {
        grid-template-columns: 1fr;
    }
}

/* =====================
   Mobile Modals
   ===================== */
@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }

    .modal-content.small,
    .modal-content.medium,
    .modal-content.large,
    .modal-content.xlarge {
        width: 100%;
        max-width: 100%;
    }

    .modal-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        background: var(--bg-card);
        z-index: 10;
        border-bottom: 1px solid var(--border-color);
    }

    .modal-header h2 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 1rem;
        overflow-y: auto;
        flex: 1;
    }

    .modal-footer {
        padding: 1rem;
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        gap: 0.5rem;
    }

    .modal-footer .btn {
        flex: 1;
    }

    /* Drive detail modal */
    .drive-detail-body {
        padding: 0;
        max-height: none;
    }

    .drive-detail-summary {
        flex-direction: column;
        gap: 1rem;
        padding: 0.75rem;
    }

    .drive-route {
        min-width: auto;
        width: 100%;
    }

    .drive-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .drive-detail-map {
        height: 200px;
        margin: 0 -1rem;
        border-radius: 0;
    }

    .drive-charts-row {
        grid-template-columns: 1fr;
    }

    /* Charge detail modal */
    .charge-detail-grid {
        grid-template-columns: 1fr;
    }

    .charge-charts-grid {
        grid-template-columns: 1fr;
    }
}

/* =====================
   Mobile Settings Page
   ===================== */
@media (max-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .settings-panel {
        padding: 1rem;
    }

    .settings-panel h3 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    .form-group {
        margin-bottom: 0.75rem;
    }

    .form-group label {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }

    .form-group input,
    .form-group select {
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
}

/* =====================
   Mobile Alerts Page
   ===================== */
@media (max-width: 768px) {
    .alerts-grid {
        grid-template-columns: 1fr;
    }

    .alerts-active-panel,
    .alerts-config-panel,
    .alerts-history-panel {
        padding: 1rem;
    }

    .alert-item {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .threshold-group {
        padding: 0.75rem;
    }

    .threshold-inputs {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* =====================
   Mobile Timeline Page
   ===================== */
@media (max-width: 768px) {
    .timeline-filters {
        flex-direction: column;
        gap: 0.5rem;
    }

    .timeline-filters select,
    .timeline-filters input {
        width: 100%;
    }

    .timeline-content {
        padding: 0;
    }

    .timeline-item {
        padding: 0.75rem;
        margin-left: 1.5rem;
    }

    .timeline-item::before {
        left: -1.5rem;
        width: 10px;
        height: 10px;
    }

    .timeline-item::after {
        left: calc(-1.5rem + 4px);
    }
}

/* =====================
   Mobile Locations Page
   ===================== */
@media (max-width: 768px) {
    .locations-content {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .locations-map {
        height: 250px;
        order: 1;
    }

    .locations-sidebar {
        order: 2;
        max-height: 300px;
    }

    .location-item {
        padding: 0.75rem;
    }
}

/* =====================
   Mobile Patterns Page
   ===================== */
@media (max-width: 768px) {
    .patterns-grid {
        grid-template-columns: 1fr;
    }

    .pattern-card {
        padding: 1rem;
    }

    .heatmap-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* =====================
   Mobile Toast Notifications
   ===================== */
@media (max-width: 768px) {
    .toast-container {
        top: auto;
        bottom: 1rem;
        left: 0.75rem;
        right: 0.75rem;
        max-width: none;
    }

    .toast {
        padding: 0.875rem 1rem;
    }

    .toast-title {
        font-size: 0.85rem;
    }

    .toast-message {
        font-size: 0.8rem;
    }
}

/* =====================
   Mobile Tabs
   ===================== */
@media (max-width: 768px) {
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }

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

    .tab-btn {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* =====================
   Mobile Badges
   ===================== */
@media (max-width: 768px) {
    .badge {
        padding: 0.2rem 0.5rem;
        font-size: 0.65rem;
    }

    .status-badge {
        padding: 0.25rem 0.6rem;
        font-size: 0.7rem;
    }
}

/* =====================
   Mobile Utility Classes
   ===================== */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }

    .text-truncate-mobile {
        max-width: 150px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Prevent zoom on input focus */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Better touch targets */
    button, .btn, a, .nav-item, .clickable {
        min-height: 44px;
        min-width: 44px;
    }

    /* Disable hover effects on touch */
    @media (hover: none) {
        .metric-card:hover,
        .data-card:hover,
        .nav-item:hover,
        .btn:hover {
            transform: none;
            box-shadow: none;
        }
    }
}

/* =====================
   Very Small Screens (< 375px)
   ===================== */
@media (max-width: 375px) {
    .stats-grid,
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .metric-card,
    .stats-card {
        padding: 0.75rem;
    }

    .page-title {
        font-size: 0.9rem;
        max-width: 80px;
    }

    .date-range-selector {
        display: none;
    }

    .live-stat {
        min-width: 100%;
    }

    .drive-item-stats,
    .charge-item-stats {
        grid-template-columns: 1fr 1fr;
    }
}

/* =====================
   Landscape Mobile
   ===================== */
@media (max-width: 992px) and (orientation: landscape) {
    .page {
        padding-top: calc(var(--topbar-height) + 0.5rem);
    }

    .live-status-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .modal-content {
        height: auto;
        max-height: 90vh;
        border-radius: var(--radius-lg);
        margin: 5vh auto;
    }
}

/* =====================
   Safe Area (Notch support)
   ===================== */
@supports (padding: max(0px)) {
    .sidebar {
        padding-left: max(0px, env(safe-area-inset-left));
    }

    .page {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    .modal-footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .toast-container {
        bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* =====================
   Pull to Refresh
   ===================== */
.pull-to-refresh::before {
    content: '';
    position: fixed;
    top: var(--topbar-height);
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: var(--accent-primary);
    border-radius: 50%;
    z-index: 100;
    animation: pullRefreshPulse 0.5s ease infinite;
}

@keyframes pullRefreshPulse {
    0%, 100% {
        opacity: 0.5;
        transform: translateX(-50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

/* =====================
   Mobile Bottom Navigation (Optional)
   ===================== */
@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        padding: 0.5rem;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
        z-index: 100;
        justify-content: space-around;
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
        padding: 0.5rem;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.65rem;
        min-width: 60px;
        border-radius: var(--radius-sm);
        transition: color var(--transition-fast);
    }

    .bottom-nav-item svg {
        width: 22px;
        height: 22px;
    }

    .bottom-nav-item.active {
        color: var(--accent-primary);
    }

    .bottom-nav-item:active {
        background: var(--bg-tertiary);
    }

    /* Adjust main content when bottom nav is present */
    .has-bottom-nav .page {
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    }
}

/* =====================
   Mobile Touch Feedback
   ===================== */
@media (max-width: 992px) {
    .touchable {
        -webkit-tap-highlight-color: transparent;
    }

    .touchable:active {
        opacity: 0.7;
        transform: scale(0.98);
    }

    /* Ripple effect for buttons */
    .btn {
        position: relative;
        overflow: hidden;
    }

    .btn::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 50%;
        transform: translate(-50%, -50%);
        transition: width 0.3s, height 0.3s;
    }

    .btn:active::after {
        width: 200%;
        height: 200%;
    }
}

/* =====================
   Mobile Scrollbar Hide
   ===================== */
@media (max-width: 768px) {
    .page,
    .modal-body,
    .sidebar-nav,
    .data-table-container {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .page::-webkit-scrollbar,
    .modal-body::-webkit-scrollbar,
    .sidebar-nav::-webkit-scrollbar,
    .data-table-container::-webkit-scrollbar {
        display: none;
    }
}

/* =====================
   Mobile Loading States
   ===================== */
@media (max-width: 768px) {
    .skeleton {
        background: linear-gradient(
            90deg,
            var(--bg-tertiary) 25%,
            var(--bg-card-hover) 50%,
            var(--bg-tertiary) 75%
        );
        background-size: 200% 100%;
        animation: skeleton-loading 1.5s infinite;
        border-radius: var(--radius-sm);
    }

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

    .skeleton-text {
        height: 1em;
        margin-bottom: 0.5em;
    }

    .skeleton-title {
        height: 1.5em;
        width: 60%;
        margin-bottom: 0.75em;
    }

    .skeleton-card {
        height: 100px;
    }
}

/* =====================
   Live Map Expanded Modal
   ===================== */
.live-map-modal-content {
    max-width: 95vw;
    width: 95vw;
    max-height: 90vh;
    height: 85vh;
}

.live-map-modal-content .modal-header {
    padding: 1rem 1.5rem;
}

.live-map-modal-content .modal-header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.live-map-modal-content .modal-header h2 svg {
    color: var(--accent-primary);
}

.live-map-modal-body {
    padding: 0 !important;
    height: calc(100% - 60px);
    overflow: hidden;
}

.expanded-map-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.expanded-live-map {
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
}

/* Route Info Panel */
.route-info-panel {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(21, 21, 31, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    z-index: 1000;
    min-width: 280px;
    box-shadow: var(--shadow-lg);
}

.route-destination {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.route-destination svg {
    color: var(--success);
    flex-shrink: 0;
    margin-top: 2px;
}

.route-destination-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.route-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.route-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.route-stats {
    display: flex;
    gap: 1.5rem;
}

.route-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.route-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.route-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Live Trip Stats */
.live-trip-stats {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(21, 21, 31, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    z-index: 1000;
    display: flex;
    gap: 1.25rem;
    box-shadow: var(--shadow-lg);
}

.live-trip-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.live-trip-stat svg {
    color: var(--accent-primary);
    opacity: 0.8;
}

.live-trip-stat span {
    font-weight: 500;
    color: var(--text-primary);
}

/* Map Legend */
.expanded-map-legend {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    background: rgba(21, 21, 31, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    z-index: 1000;
    display: flex;
    gap: 1.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.expanded-map-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-marker.car-marker-legend {
    width: 12px;
    height: 12px;
    background: var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-primary);
}

.legend-line {
    width: 24px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.route-line-legend {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.legend-line.trail-line-legend {
    background: var(--accent-primary);
    opacity: 0.7;
}

/* Location Card Click Indicator */
.location-card {
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.location-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.location-card::after {
    content: '';
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 24px;
    height: 24px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='2'%3E%3Cpath d='M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7'/%3E%3C/svg%3E") center/contain no-repeat;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.location-card:hover::after {
    opacity: 0.6;
}

/* Expanded map markers */
.expanded-car-marker {
    background: transparent !important;
    border: none !important;
}

.expanded-destination-marker {
    background: transparent !important;
    border: none !important;
}

/* Route polyline animation */
@keyframes route-dash {
    to {
        stroke-dashoffset: -20;
    }
}

.route-polyline {
    animation: route-dash 1s linear infinite;
}

/* Trail gradient colors */
.trail-segment-recent {
    stroke: var(--accent-primary);
    stroke-opacity: 0.9;
}

.trail-segment-old {
    stroke: var(--accent-primary);
    stroke-opacity: 0.3;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .live-map-modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .route-info-panel {
        top: auto;
        bottom: 5rem;
        left: 0.5rem;
        right: 0.5rem;
        min-width: auto;
    }

    .live-trip-stats {
        top: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
        justify-content: space-around;
    }

    .expanded-map-legend {
        bottom: 0.5rem;
        left: 0.5rem;
        right: 0.5rem;
        justify-content: center;
        flex-wrap: wrap;
    }

    .route-stats {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

/* Leaflet Layer Control Styling */
.leaflet-control-layers {
    background: rgba(21, 21, 31, 0.95) !important;
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0.5rem !important;
}

.leaflet-control-layers-list {
    padding: 0 !important;
}

.leaflet-control-layers-base label {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    margin: 0.25rem 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.leaflet-control-layers-base label:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.leaflet-control-layers-base label span {
    margin-left: 0.5rem;
}

.leaflet-control-layers-selector {
    accent-color: var(--accent-primary);
    width: 16px;
    height: 16px;
}

.leaflet-control-layers-toggle {
    background-color: var(--bg-card) !important;
    border-radius: var(--radius-sm) !important;
}

/* Leaflet Zoom Control Styling */
.leaflet-control-zoom {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    background: rgba(21, 21, 31, 0.95) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-light) !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-card-hover) !important;
    color: var(--accent-primary) !important;
}

.leaflet-control-zoom a:last-child {
    border-bottom: none !important;
}

/* Drives Map Panel Clickable */
.drives-map-panel {
    cursor: pointer;
    position: relative;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.drives-map-panel:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.drives-map-panel::after {
    content: '';
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 28px;
    height: 28px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='2'%3E%3Cpath d='M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7'/%3E%3C/svg%3E") center/contain no-repeat;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: 500;
    pointer-events: none;
}

.drives-map-panel:hover::after {
    opacity: 0.8;
}

/* Drives map legend */
.drives-map-legend {
    justify-content: space-between;
}

.legend-marker.drive-marker-legend {
    width: 12px;
    height: 12px;
    background: var(--info);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--info);
}

.legend-info {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* =====================
   Charges Map Legend
   ===================== */
.charges-legend {
    background: rgba(21, 21, 31, 0.95) !important;
    backdrop-filter: blur(12px);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.charges-legend .legend-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.charges-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-primary);
    padding: 0.25rem 0;
}

.charges-legend .legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Charges Map Popup Styling */
.charge-popup {
    font-size: 0.85rem;
    line-height: 1.5;
}

.charge-popup strong {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.charge-popup .popup-badge {
    display: inline-block;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    margin: 0.25rem 0;
}

.charge-popup .popup-stats {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-light);
}

.charge-popup .popup-stats div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.charge-popup .popup-label {
    font-weight: 600;
    color: var(--accent-primary);
}

.charge-popup .popup-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* =====================
   Charge Detail Modal
   ===================== */
.charge-modal-content {
    max-width: 1000px;
    margin: 0 auto;
}

.charge-modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.charge-type-badges {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.charge-modal-location {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.charge-modal-date {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Stats cards */
.charge-modal-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.charge-stat-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.charge-stat-card.primary {
    background: linear-gradient(135deg, rgba(107, 156, 206, 0.15), rgba(90, 139, 184, 0.15));
    border-color: rgba(107, 156, 206, 0.3);
}

.charge-stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.charge-stat-card .stat-icon svg {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
}

.charge-stat-card.primary .stat-icon {
    background: var(--accent-primary);
}

.charge-stat-card.primary .stat-icon svg {
    color: white;
}

.charge-stat-card .stat-content {
    display: flex;
    flex-direction: column;
}

.charge-stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
    line-height: 1.2;
}

.charge-stat-card.primary .stat-value {
    color: var(--accent-primary);
}

.charge-stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Editable stat card (cost) */
.charge-stat-card.editable {
    position: relative;
}

.charge-stat-card .edit-cost-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition-fast);
}

.charge-stat-card.editable:hover .edit-cost-btn {
    opacity: 1;
}

.charge-stat-card .edit-cost-btn:hover {
    background: var(--accent);
    color: white;
}

.charge-stat-card .edit-cost-form {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.charge-stat-card .edit-cost-form.hidden {
    display: none;
}

.charge-stat-card .edit-cost-form input {
    width: 80px;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: 'JetBrains Mono', monospace;
}

.charge-stat-card .edit-cost-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.charge-stat-card .edit-cost-form .btn-confirm,
.charge-stat-card .edit-cost-form .btn-cancel {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.charge-stat-card .edit-cost-form .btn-confirm {
    background: var(--success);
    color: white;
}

.charge-stat-card .edit-cost-form .btn-confirm:hover {
    background: var(--success-hover);
}

.charge-stat-card .edit-cost-form .btn-cancel {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.charge-stat-card .edit-cost-form .btn-cancel:hover {
    background: var(--danger);
    color: white;
}

/* Battery progress */
.charge-battery-progress {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.battery-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.battery-progress-header span:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

.battery-progress-header span:last-child {
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

.battery-progress-bar {
    height: 24px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    margin-bottom: 0.5rem;
}

.battery-progress-start {
    height: 100%;
    background: var(--text-muted);
    transition: width 0.5s ease;
}

.battery-progress-added {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--success-very-bright));
    transition: width 0.5s ease;
}

.battery-progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace;
}

.battery-progress-labels span:first-child {
    color: var(--text-muted);
}

.battery-progress-labels span:last-child {
    color: var(--success);
    font-weight: 600;
}

/* Details grid */
.charge-modal-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.charge-detail-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.charge-detail-card h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.detail-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.detail-row span:first-child {
    color: var(--text-secondary);
}

.detail-row span:last-child {
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

/* Heating warning */
.charge-heating-warning {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--warning-bg);
    border: 1px solid rgba(255, 152, 48, 0.3);
    border-radius: var(--radius-lg);
    color: var(--warning);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.charge-heating-warning svg {
    flex-shrink: 0;
}

/* Charts */
.charge-modal-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.charge-modal-charts .chart-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.charge-modal-charts .chart-card h4 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.charge-modal-charts .chart-container {
    height: 200px;
}

/* Responsive */
@media (max-width: 992px) {
    .charge-modal-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .charge-modal-details {
        grid-template-columns: 1fr;
    }

    .charge-modal-charts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .charge-modal-stats {
        grid-template-columns: 1fr;
    }

    .charge-stat-card {
        padding: 1rem;
    }

    .charge-stat-card .stat-value {
        font-size: 1.25rem;
    }

    /* Charge modal mobile specific */
    .charge-modal-content {
        max-width: 100%;
        padding: 0;
    }

    .charge-modal-header {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }

    .charge-modal-location {
        font-size: 1rem;
        word-break: break-word;
    }

    .charge-modal-date {
        font-size: 0.8rem;
    }

    .charge-stat-card .stat-icon {
        width: 40px;
        height: 40px;
    }

    .charge-stat-card .stat-icon svg {
        width: 20px;
        height: 20px;
    }

    .charge-stat-card .stat-label {
        font-size: 0.65rem;
    }

    .charge-battery-progress {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .battery-progress-header {
        font-size: 0.8rem;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .battery-progress-bar {
        height: 20px;
    }

    .battery-progress-labels {
        font-size: 0.75rem;
    }

    .charge-detail-card {
        padding: 0.75rem;
    }

    .charge-detail-card h4 {
        font-size: 0.7rem;
        margin-bottom: 0.5rem;
    }

    .detail-row {
        font-size: 0.8rem;
    }

    .charge-heating-warning {
        font-size: 0.8rem;
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    .charge-modal-charts .chart-card {
        padding: 0.75rem;
    }

    .charge-modal-charts .chart-card h4 {
        font-size: 0.8rem;
    }

    .charge-modal-charts .chart-container {
        height: 180px;
    }
}

/* =====================
   Mobile Stats Page
   ===================== */
@media (max-width: 768px) {
    #stats-page .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    #stats-page .stats-card {
        padding: 1rem;
    }

    #stats-page .stats-card.hero,
    #stats-page .stats-card.wide {
        grid-column: 1;
    }

    .stats-card-header h3 {
        font-size: 0.85rem;
    }

    /* Lifetime stats */
    .lifetime-main {
        margin-bottom: 1rem;
    }

    .odo-value {
        font-size: 2.25rem;
    }

    .odo-unit {
        font-size: 1rem;
    }

    .lifetime-since {
        font-size: 0.75rem;
    }

    .lifetime-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-top: 1rem;
    }

    .lifetime-item {
        padding: 0.75rem 0.5rem;
    }

    .lifetime-value {
        font-size: 1.1rem;
    }

    .lifetime-label {
        font-size: 0.65rem;
    }

    /* Efficiency card */
    .efficiency-display {
        flex-direction: column;
        gap: 1rem;
    }

    .efficiency-main {
        text-align: center;
    }

    .efficiency-value {
        font-size: 2rem;
    }

    .efficiency-bars {
        width: 100%;
    }

    /* Mileage card */
    .mileage-display {
        flex-direction: column;
        gap: 0.75rem;
    }

    .mileage-value {
        font-size: 1.5rem;
    }

    .mileage-breakdown {
        flex-direction: row;
        justify-content: space-around;
    }

    /* TCO card */
    .tco-summary {
        flex-direction: column;
        gap: 0.75rem;
    }

    .tco-item {
        padding: 0.75rem;
    }

    .tco-value {
        font-size: 1.25rem;
    }

    .tco-breakdown-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .tco-breakdown-item {
        padding: 0.5rem;
    }

    .tco-comparison {
        margin-top: 1rem;
    }

    .tco-comparison .chart-container {
        height: 180px;
    }

    /* Driving style card */
    .driving-style-display {
        flex-direction: column;
        gap: 1rem;
    }

    .style-meter {
        width: 100%;
        max-width: 150px;
        margin: 0 auto;
    }

    .style-stats {
        width: 100%;
    }

    /* Records card */
    .records-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .record-item {
        padding: 0.75rem;
    }

    .record-value {
        font-size: 1.1rem;
    }
}

/* =====================
   Mobile Battery Page
   ===================== */
@media (max-width: 768px) {
    .battery-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .battery-health-panel,
    .battery-level-chart,
    .vampire-drain-panel,
    .degradation-panel,
    .charging-panel {
        padding: 1rem;
    }

    .panel-header h3 {
        font-size: 0.9rem;
    }

    /* Health gauge */
    .health-gauge svg {
        max-width: 160px;
    }

    .health-value span:first-child {
        font-size: 1.5rem;
    }

    .health-label {
        font-size: 0.7rem;
    }

    .health-stats {
        margin-top: 1rem;
    }

    .health-stat {
        padding: 0.4rem 0;
        font-size: 0.85rem;
    }

    .health-stat-label {
        font-size: 0.75rem;
    }

    .health-stat-value {
        font-size: 0.85rem;
    }

    /* Battery level chart */
    .battery-level-chart {
        grid-column: 1;
    }

    /* Vampire drain */
    .vampire-stats {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .vampire-stat {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: left;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--border-light);
    }

    .vampire-stat:last-child {
        border-bottom: none;
    }

    .vampire-value {
        font-size: 1.25rem;
    }

    .vampire-label {
        font-size: 0.75rem;
    }

    /* Degradation panel */
    .degradation-timeline {
        gap: 0.5rem;
    }

    .degradation-item {
        padding: 0.75rem;
    }

    .degradation-date {
        font-size: 0.75rem;
    }

    .degradation-value {
        font-size: 1rem;
    }

    /* SOH History */
    .soh-history-panel {
        padding: 1rem;
    }

    .soh-history-chart {
        height: 200px;
    }

    /* Predictions */
    .prediction-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .prediction-card {
        padding: 0.75rem;
    }

    .prediction-value {
        font-size: 1.25rem;
    }

    .prediction-label {
        font-size: 0.7rem;
    }

    /* Charging stats */
    .charging-stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .charging-stat-card {
        padding: 0.75rem;
    }
}

/* ================================
   EXPENSES PAGE - TCO
   ================================ */

.expenses-layout {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    padding: 1.5rem;
}

/* TCO Summary Panel */
.tco-summary-panel {
    grid-column: 1 / -1;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.tco-summary-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.tco-summary-panel .panel-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.tco-period {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.tco-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.tco-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
}

.tco-card.primary {
    background: var(--accent-gradient);
}

.tco-card-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tco-card.primary .tco-card-label {
    color: rgba(255, 255, 255, 0.8);
}

.tco-card-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Purchase Info Panel */
.purchase-info-panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.purchase-info-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.purchase-info-panel .panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.purchase-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.purchase-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.purchase-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.purchase-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Expenses Category Panel */
.expenses-category-panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.expenses-category-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.expenses-category-panel .panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.category-total {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.expenses-by-category {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.category-breakdown-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.category-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.category-name {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.category-amount {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-amount .amount {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.category-amount .percentage {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.category-bar {
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
}

.category-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width var(--transition-normal);
}

/* Expenses List Panel */
.expenses-list-panel {
    grid-column: 1 / -1;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.expenses-list-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.expenses-list-panel .panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Expense table styles */
.expenses-table .expense-date {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.expense-category {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.expense-description {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.expense-vendor {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.recurring-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 0.125rem 0.375rem;
    background: var(--info-bg);
    color: var(--info);
    border-radius: 4px;
    margin-left: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.expense-amount {
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
}

.actions-cell {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.btn-icon.edit-expense,
.btn-icon.delete-expense {
    padding: 0.375rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.btn-icon.edit-expense:hover {
    color: var(--accent-primary);
    background: var(--accent-primary-10);
}

.btn-icon.delete-expense:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

/* Small button variant */
.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-small svg {
    width: 14px;
    height: 14px;
    margin-right: 0.375rem;
}

/* Form row */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Checkbox label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.empty-cell {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Modal textarea */
.modal textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
    transition: border-color var(--transition-fast);
}

.modal textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Expenses Page Responsive */
@media (max-width: 1024px) {
    .expenses-layout {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 768px) {
    .expenses-layout {
        padding: 1rem;
        gap: 1rem;
    }

    .tco-summary-panel,
    .purchase-info-panel,
    .expenses-category-panel,
    .expenses-list-panel {
        padding: 1rem;
    }

    .tco-cards {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .tco-card {
        padding: 1rem;
    }

    .tco-card-value {
        font-size: 1.25rem;
    }

    .purchase-info-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .expenses-table {
        font-size: 0.8rem;
    }

    .expenses-table th,
    .expenses-table td {
        padding: 0.5rem;
    }

    /* Hide less important columns on mobile */
    .expenses-table th:nth-child(3),
    .expenses-table td:nth-child(3) {
        display: none;
    }
}

/* ===========================================
   LEASING PAGE - SUIVI KM
   =========================================== */

/* Leasing page grid layout */
#leasing-page .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

#leasing-page .stats-card.hero {
    grid-column: 1 / -1;
}

#leasing-page .stats-card.wide {
    grid-column: 1 / -1;
}

/* Period budgets grid */
.period-budgets-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.period-budget-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.period-budget-card:hover {
    border-color: var(--accent-primary);
}

.period-budget-card.on_track {
    border-left: 3px solid var(--success-bright);
}

.period-budget-card.under_budget {
    border-left: 3px solid var(--info);
}

.period-budget-card.over_budget {
    border-left: 3px solid var(--danger);
}

.period-budget-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.period-icon {
    font-size: 1.25rem;
}

.period-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.period-budget-progress {
    margin-bottom: 0.75rem;
}

.period-progress-bar {
    position: relative;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: visible;
}

.period-progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.period-progress-fill.on_track {
    background: linear-gradient(90deg, var(--success-bright), var(--success-very-bright));
}

.period-progress-fill.under_budget {
    background: linear-gradient(90deg, var(--info), var(--info-bright));
}

.period-progress-fill.over_budget {
    background: linear-gradient(90deg, var(--danger), var(--danger-bright));
}

.period-progress-limit {
    position: absolute;
    top: -3px;
    width: 2px;
    height: 12px;
    background: var(--text-secondary);
    border-radius: 1px;
}

.period-budget-stats {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.period-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.period-stat-value {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.period-stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
}

.period-stat.variance.on_track .period-stat-value {
    color: var(--success-bright);
}

.period-stat.variance.under_budget .period-stat-value {
    color: var(--info);
}

.period-stat.variance.over_budget .period-stat-value {
    color: var(--danger);
}

/* Responsive period budgets */
@media (max-width: 1200px) {
    .period-budgets-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .period-budgets-grid {
        grid-template-columns: 1fr;
    }

    .period-budget-stats {
        flex-wrap: wrap;
    }

    .period-stat {
        min-width: 30%;
    }
}

/* Leasing overview */
.leasing-overview {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.leasing-status {
    display: flex;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.9rem;
}

.status-badge.on_track {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success-bright);
}

.status-badge.under_budget {
    background: var(--info-bg);
    color: var(--info);
}

.status-badge.over_budget {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Progress sections */
.leasing-progress-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.progress-bar-container {
    position: relative;
    height: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: visible;
}

.progress-bar-container.time {
    height: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.progress-bar.on_track {
    background: linear-gradient(90deg, var(--success-bright), var(--success-very-bright));
}

.progress-bar.under_budget {
    background: linear-gradient(90deg, var(--info), var(--info-bright));
}

.progress-bar.over_budget {
    background: linear-gradient(90deg, var(--danger), var(--danger-bright));
}

.progress-bar.time {
    background: linear-gradient(90deg, var(--accent-secondary), var(--warning-bright));
}

.progress-marker {
    position: absolute;
    top: -4px;
    width: 3px;
    height: 20px;
    background: var(--success-bright);
    border-radius: 2px;
    transform: translateX(-50%);
    box-shadow: 0 0 4px rgba(34, 197, 94, 0.5);
}

.progress-legend {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.legend-dot.actual {
    background: var(--accent-primary);
}

.legend-dot.theoretical {
    background: var(--success-bright);
}

/* Variance display */
.leasing-variance {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    font-weight: 600;
}

.leasing-variance.on_track {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success-bright);
}

.leasing-variance.under_budget {
    background: var(--info-bg);
    color: var(--info);
}

.leasing-variance.over_budget {
    background: var(--danger-bg);
    color: var(--danger);
}

#leasing-variance-label {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-secondary);
}

/* Stats list */
.stats-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-item.highlight {
    background: var(--bg-tertiary);
    margin: 0 -1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border-bottom: none;
}

.stat-item.warning {
    background: rgba(239, 68, 68, 0.1);
}

.stat-item.warning .stat-value {
    color: var(--danger);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Empty state for not configured */
#leasing-not-configured {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    min-height: 400px;
}

#leasing-not-configured h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
}

#leasing-not-configured p {
    color: var(--text-secondary);
    margin: 0 0 1.5rem 0;
    max-width: 400px;
}

/* Leasing page responsive */
@media (max-width: 1024px) {
    #leasing-page .stats-grid {
        grid-template-columns: 1fr;
    }

    #leasing-page .stats-card.hero,
    #leasing-page .stats-card.wide {
        grid-column: 1;
    }
}

@media (max-width: 768px) {
    .leasing-overview {
        gap: 1rem;
    }

    .leasing-variance {
        flex-wrap: wrap;
        text-align: center;
    }

    #leasing-variance-label {
        width: 100%;
    }
}

/* ===========================================
   HISTORY PAGE - TIMELINE
   =========================================== */

.history-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: calc(100vh - var(--topbar-height) - 3rem);
}

/* Date Navigation */
.history-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.history-date-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
}

.date-input {
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    min-width: 140px;
}

.date-input:hover {
    border-color: var(--accent-primary);
}

.date-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(107, 156, 206, 0.2);
}

/* Style the date picker for dark theme */
.date-input::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
    cursor: pointer;
}

.date-separator {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Period selection buttons */
.history-period-btns {
    display: flex;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.btn-period {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 36px;
}

.btn-period:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.btn-period.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover:not(:disabled) {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

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

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

.history-range-select {
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    min-width: 100px;
}

.history-range-select:hover {
    border-color: var(--accent-primary);
}

/* Summary Stats */
.history-summary {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.history-stat {
    flex: 1;
    min-width: 120px;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    text-align: center;
}

.history-stat .stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.history-stat .stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Main Content */
.history-content {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Map Container */
.history-map-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    min-height: 400px;
}

.history-map {
    width: 100%;
    height: 100%;
    min-height: 400px;
}

/* Sidebar */
.history-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

/* Calendar Panel */
.history-calendar-panel {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 1rem;
}

.mini-calendar {
    width: 100%;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.calendar-title {
    font-weight: 600;
    color: var(--text-primary);
}

.calendar-nav {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

.calendar-nav svg {
    width: 16px;
    height: 16px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day-header {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.25rem;
    text-transform: uppercase;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.calendar-day:hover:not(.empty) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.calendar-day.empty {
    cursor: default;
}

.calendar-day.today {
    font-weight: 700;
    color: var(--accent-primary);
}

.calendar-day.selected {
    background: var(--accent-primary);
    color: white;
}

.calendar-day.has-activity::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-primary);
}

.calendar-day.has-drive::after {
    background: var(--info);
}

.calendar-day.has-charge::after {
    background: var(--success);
}

.calendar-day.selected::after {
    background: white;
}

/* Events Panel */
.history-events-panel {
    flex: 1;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* h4 style moved to .panel-header */

.history-events-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

/* Event Items */
.history-event {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    margin-bottom: 0.5rem;
}

.history-event:hover {
    background: var(--bg-tertiary);
}

.history-event.active {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-primary);
}

.event-time {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 45px;
    line-height: 1.4;
}

.event-time .time-start {
    font-weight: 600;
    color: var(--text-secondary);
}

.event-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.event-icon svg {
    width: 16px;
    height: 16px;
}

.event-icon.drive {
    background: var(--info-bg);
    color: var(--info);
}

.event-icon.charge {
    background: var(--success-bg);
    color: var(--success);
}

.event-icon.parking {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.event-content {
    flex: 1;
    min-width: 0;
}

.event-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.event-title .from,
.event-title .to,
.event-title .location {
    display: inline;
}

.event-title .arrow {
    color: var(--text-muted);
    margin: 0 0.25rem;
}

.event-title .charger-brand {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    background: var(--success-bg);
    color: var(--success);
    border-radius: 4px;
    margin-left: 0.5rem;
}

.event-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.event-details .detail {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.event-details .detail:not(:last-child)::after {
    content: '·';
    margin-left: 0.5rem;
    color: var(--text-dim);
}

.event-indicator {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 2px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.history-event.drive .event-indicator {
    opacity: 1;
    /* Color set inline via JS */
}

.history-event.charge .event-indicator {
    background: var(--success);
}

.history-event.charge:hover .event-indicator,
.history-event.charge.active .event-indicator,
.history-event.parking:hover .event-indicator,
.history-event.parking.active .event-indicator {
    opacity: 1;
}

/* Charge marker on map */
.charge-marker {
    background: none;
    border: none;
}

.charge-marker svg {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Highlight pulse animation for map markers */
@keyframes highlight-pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.3;
    }
    100% {
        transform: scale(1);
        opacity: 0.6;
    }
}

.highlight-pulse {
    animation: highlight-pulse 1s ease-in-out infinite;
}

/* History events panel header */
.history-events-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.history-events-panel .panel-header h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-icon.btn-small {
    width: 28px;
    height: 28px;
}

.btn-icon.btn-small svg {
    width: 14px;
    height: 14px;
}

/* Responsive History */
@media (max-width: 1200px) {
    .history-content {
        grid-template-columns: 1fr 320px;
    }
}

@media (max-width: 900px) {
    .history-content {
        grid-template-columns: 1fr;
    }

    .history-sidebar {
        flex-direction: row;
    }

    .history-calendar-panel {
        flex: 0 0 auto;
        width: 300px;
    }

    .history-events-panel {
        flex: 1;
        max-height: 300px;
    }
}

@media (max-width: 768px) {
    .history-nav {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .history-date-inputs {
        order: -1;
        flex-basis: 100%;
        justify-content: center;
        margin-bottom: 0.25rem;
    }

    .date-input {
        min-width: 120px;
        font-size: 0.85rem;
        padding: 0.4rem 0.5rem;
    }

    .history-period-btns {
        margin-left: 0;
    }

    .btn-period {
        padding: 0.35rem 0.5rem;
        font-size: 0.7rem;
        min-width: 32px;
    }

    #history-today {
        font-size: 0.75rem;
        padding: 0.35rem 0.6rem;
    }
}

@media (max-width: 600px) {
    .history-layout {
        height: auto;
    }

    .history-nav {
        justify-content: center;
        padding: 0.75rem;
    }

    .history-date-inputs {
        gap: 0.25rem;
    }

    .date-input {
        min-width: 105px;
        font-size: 0.8rem;
    }

    .date-separator {
        font-size: 0.85rem;
    }

    .history-summary {
        flex-wrap: wrap;
    }

    .history-stat {
        min-width: calc(50% - 0.5rem);
        padding: 0.75rem;
    }

    .history-stat .stat-value {
        font-size: 1rem;
    }

    .history-content {
        grid-template-columns: 1fr;
    }

    .history-sidebar {
        flex-direction: column;
    }

    .history-calendar-panel {
        width: 100%;
    }

    .history-map-container {
        min-height: 300px;
    }

    .history-events-panel {
        max-height: none;
    }

    .history-events-list {
        max-height: 400px;
    }
}

@media (max-width: 600px) {
    /* History events for mobile */
    .history-event {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .event-time {
        font-size: 0.7rem;
        min-width: 40px;
    }

    .event-icon {
        width: 28px;
        height: 28px;
    }

    .event-icon svg {
        width: 14px;
        height: 14px;
    }

    .event-title {
        font-size: 0.85rem;
    }

    .event-details {
        font-size: 0.7rem;
    }

    /* Calendar mobile */
    .calendar-day {
        font-size: 0.7rem;
    }

    .calendar-day-header {
        font-size: 0.6rem;
    }

    .calendar-header {
        padding: 0.5rem;
    }

    .calendar-title {
        font-size: 0.85rem;
    }
}

@media (max-width: 400px) {
    .history-nav {
        padding: 0.5rem;
    }

    .history-period-btns {
        gap: 0.15rem;
    }

    .btn-period {
        padding: 0.3rem 0.4rem;
        font-size: 0.65rem;
        min-width: 28px;
    }

    .date-input {
        min-width: 95px;
        font-size: 0.75rem;
        padding: 0.35rem 0.4rem;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
    }

    #history-today {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }

    /* History stats mobile */
    .history-stat {
        min-width: calc(50% - 0.25rem);
        padding: 0.5rem;
    }

    .history-stat .stat-label {
        font-size: 0.65rem;
    }

    .history-stat .stat-value {
        font-size: 0.9rem;
    }

    /* Events mobile */
    .history-event {
        padding: 0.4rem;
        gap: 0.4rem;
        margin-bottom: 0.25rem;
    }

    .event-time {
        font-size: 0.65rem;
        min-width: 35px;
    }

    .event-icon {
        width: 24px;
        height: 24px;
    }

    .event-icon svg {
        width: 12px;
        height: 12px;
    }

    .event-title {
        font-size: 0.8rem;
    }

    .event-title .arrow {
        margin: 0 0.15rem;
    }

    .event-details {
        font-size: 0.65rem;
        gap: 0.25rem;
    }

    .event-details .detail {
        padding: 0.1rem 0.25rem;
    }
}

/* =====================
   Phase 1 & 2 Improvements
   ===================== */

/* Battery details secondary row */
.battery-details-secondary {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

/* Climate indicators in header */
.climate-indicators {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.climate-indicator {
    font-size: 1rem;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.climate-indicator.active {
    opacity: 1;
}

.climate-indicator.battery-heater {
    color: var(--warning);
}

/* Fan level indicator */
.fan-level-container {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.fan-level-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.fan-level-label svg {
    color: var(--text-muted);
}

.fan-level-bars {
    display: flex;
    gap: 4px;
    align-items: flex-end;
    height: 20px;
}

.fan-bar {
    width: 12px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    transition: all var(--transition-fast);
}

.fan-bar:nth-child(1) { height: 6px; }
.fan-bar:nth-child(2) { height: 8px; }
.fan-bar:nth-child(3) { height: 10px; }
.fan-bar:nth-child(4) { height: 12px; }
.fan-bar:nth-child(5) { height: 14px; }
.fan-bar:nth-child(6) { height: 16px; }
.fan-bar:nth-child(7) { height: 18px; }

.fan-bar.active {
    background: var(--accent-primary);
}

/* Scheduled charging panel */
.scheduled-charging-row {
    margin-bottom: 1.5rem;
}

.scheduled-charging-panel {
    background: linear-gradient(135deg, rgba(107, 156, 206, 0.1), rgba(107, 156, 206, 0.05));
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.scheduled-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--accent-primary);
    font-weight: 600;
}

.scheduled-header svg {
    width: 24px;
    height: 24px;
}

.scheduled-time {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-primary);
}

/* Charging type badge */
.charging-type-badge {
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.charging-type-badge.dc {
    background: var(--danger-bg);
    color: var(--danger);
}

.charging-type-badge.ac {
    background: var(--success-bg);
    color: var(--success);
}

/* Responsive adjustments for charging stats */
@media (max-width: 900px) {
    .charging-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .charging-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .charging-stat-value {
        font-size: 1.25rem;
    }

    .scheduled-charging-panel {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .fan-level-bars {
        justify-content: center;
    }
}

/* Map click overlay for mobile touch support */
.location-map-container {
    position: relative;
}

.map-click-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Show expand icon on overlay hover/touch */
.map-click-overlay::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(107, 156, 206, 0.9);
    border-radius: 50%;
    opacity: 0;
    transition: opacity var(--transition-fast);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'%3E%3Cpath d='M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7'/%3E%3C/svg%3E");
    background-size: 24px;
    background-position: center;
    background-repeat: no-repeat;
}

.map-click-overlay:active::after,
.location-card:hover .map-click-overlay::after {
    opacity: 1;
}

/* Mobile: always show a subtle indicator */
@media (max-width: 768px) {
    .map-click-overlay::before {
        content: 'Agrandir';
        position: absolute;
        bottom: 8px;
        right: 8px;
        padding: 4px 8px;
        background: rgba(0, 0, 0, 0.7);
        color: white;
        font-size: 0.65rem;
        border-radius: 4px;
        opacity: 0.8;
    }
}

/* ===============================================
   ELECTRICITY TARIFFS
   =============================================== */

.settings-panel.wide {
    grid-column: span 2;
}

.panel-header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.panel-header-with-action h3 {
    margin: 0;
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.tariffs-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.tariff-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

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

.tariff-item.default {
    border-color: var(--success);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), transparent);
}

.tariff-item.expired {
    opacity: 0.5;
}

.tariff-info {
    flex: 1;
}

.tariff-name {
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tariff-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 500;
}

.tariff-badge.default {
    background: var(--success);
    color: white;
}

.tariff-badge.location {
    background: var(--accent);
    color: white;
}

.tariff-badge.vehicle {
    background: var(--accent-primary);
    color: white;
}

.tariff-details {
    display: flex;
    gap: 1rem;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tariff-price {
    font-weight: 600;
    color: var(--accent);
}

/* Tariff Groups (new design) */
.tariff-group {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.tariff-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tariff-location {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tariff-location .location-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.tariff-current-rate {
    text-align: right;
}

.tariff-current-rate .rate-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.tariff-current-rate .rate-unit {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

.tariff-group-details {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tariff-future {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--warning-bg);
    color: var(--warning);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.tariff-history {
    margin-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
}

.tariff-history-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
}

.tariff-history-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform var(--transition-fast);
}

.tariff-history.expanded .tariff-history-toggle svg {
    transform: rotate(180deg);
}

.tariff-history-list {
    display: none;
    margin-top: 0.5rem;
}

.tariff-history.expanded .tariff-history-list {
    display: block;
}

.tariff-history-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
}

.tariff-history-item:last-child {
    border-bottom: none;
}

.tariff-history-item .history-price {
    color: var(--text-primary);
}

.tariff-history-item .history-dates {
    color: var(--text-secondary);
}

.tariff-group-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

/* Rate change info in modal */
.rate-change-info {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.rate-change-info .label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.rate-change-info .value {
    font-weight: 600;
    color: var(--text-primary);
    margin-left: 0.5rem;
}

.rate-change-location,
.rate-change-current {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.rate-change-current:last-child {
    margin-bottom: 0;
}

.tariff-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--accent);
    color: white;
}

.btn-icon.danger:hover {
    background: var(--danger);
}

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

/* Tariff Modal */
#tariff-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

#tariff-modal.active {
    display: block;
}

#tariff-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
}

#tariff-modal .modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

#tariff-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

#tariff-modal .modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

#tariff-modal .modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

#tariff-modal .modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

#tariff-modal .modal-close svg {
    width: 20px;
    height: 20px;
}

#tariff-modal .modal-body {
    padding: 1.5rem;
}

#tariff-modal .form-group {
    margin-bottom: 1rem;
}

#tariff-modal .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#tariff-modal .form-group input[type="text"],
#tariff-modal .form-group input[type="number"],
#tariff-modal .form-group input[type="date"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
}

#tariff-modal .form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

#tariff-modal .form-group.checkbox label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

#tariff-modal .form-group.checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

#tariff-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

#tariff-modal .btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

#tariff-modal .btn-secondary {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

#tariff-modal .btn-secondary:hover {
    background: var(--bg-tertiary);
}

#tariff-modal .btn-primary {
    background: var(--accent);
    border: none;
    color: white;
}

#tariff-modal .btn-primary:hover {
    background: var(--accent-hover);
}

@media (max-width: 768px) {
    .settings-panel.wide {
        grid-column: span 1;
    }

    .tariff-details {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* ===========================================
   PWA Install Banner
   =========================================== */
.pwa-install-banner {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border: 1px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    box-shadow: 0 -4px 20px rgba(107, 156, 206, 0.3);
    transition: bottom 0.4s ease-out;
    max-width: 90%;
    width: 450px;
}

.pwa-install-banner.visible {
    bottom: 20px;
}

.pwa-install-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pwa-install-icon {
    width: 44px;
    height: 44px;
    background: var(--accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pwa-install-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.pwa-install-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.pwa-install-text strong {
    color: var(--text-primary);
    font-size: 0.95rem;
}

.pwa-install-text span {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.pwa-install-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pwa-install-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.pwa-install-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.pwa-dismiss-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.pwa-dismiss-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.pwa-dismiss-btn svg {
    width: 18px;
    height: 18px;
}

/* iOS-specific install banner */
.pwa-install-banner.ios .pwa-install-text span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.ios-share-icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    color: var(--accent);
}

/* ===========================================
   Update Available Banner
   =========================================== */
.update-banner {
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: linear-gradient(135deg, var(--success-dark), var(--success));
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    box-shadow: 0 4px 20px rgba(115, 191, 105, 0.4);
    transition: top 0.4s ease-out, opacity 0.3s ease-out;
    max-width: 90%;
    width: 450px;
    opacity: 0;
    visibility: hidden;
}

.update-banner.visible {
    top: 20px;
    opacity: 1;
    visibility: visible;
}

.update-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.update-icon {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.update-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.update-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.update-text strong {
    color: white;
    font-size: 0.95rem;
}

.update-text span {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.8rem;
}

.update-version {
    font-weight: 600;
    color: white;
}

.update-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.update-btn {
    background: white;
    color: var(--success-dark);
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.update-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.02);
}

.update-dismiss-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.update-dismiss-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.update-dismiss-btn svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 480px) {
    .pwa-install-banner {
        flex-direction: column;
        gap: 1rem;
        width: calc(100% - 2rem);
        padding: 1rem;
    }

    .pwa-install-actions {
        width: 100%;
    }

    .pwa-install-btn {
        flex: 1;
    }

    .update-banner {
        flex-direction: column;
        gap: 1rem;
        width: calc(100% - 2rem);
        padding: 1rem;
    }

    .update-actions {
        width: 100%;
    }

    .update-btn {
        flex: 1;
    }
}

/* =====================
   Visited Places Heatmap Page
   ===================== */
.visited-places-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: calc(100vh - 140px);
    min-height: 500px;
}

/* Stats bar */
.heatmap-stats-bar {
    display: flex;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.heatmap-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.heatmap-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.heatmap-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Controls */
.heatmap-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.heatmap-controls .control-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.heatmap-controls .control-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.heatmap-controls select {
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
}

/* Toggle buttons */
.toggle-buttons {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
}

.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.toggle-btn.active {
    background: var(--accent-primary);
    color: white;
}

/* Extended stats */
.heatmap-extended-stats {
    display: flex;
    gap: 2rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.extended-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.extended-stat-icon {
    font-size: 1.1rem;
}

.extended-stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.extended-stat-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main content with panel */
.heatmap-main-content {
    flex: 1;
    display: flex;
    gap: 1rem;
    min-height: 0;
}

/* Map wrapper */
.heatmap-map-wrapper {
    flex: 1;
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* Map container (legacy) */
.heatmap-map-container {
    flex: 1;
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.heatmap-map {
    width: 100%;
    height: 100%;
    min-height: 400px;
    background: var(--bg-tertiary);
}

/* Heatmap legend */
.heatmap-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(21, 21, 31, 0.95);
    backdrop-filter: blur(12px);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    z-index: 1000;
}

.heatmap-legend .legend-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.heatmap-legend .legend-gradient {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.heatmap-legend .legend-min,
.heatmap-legend .legend-max {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.heatmap-legend .gradient-bar {
    width: 100px;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right, var(--info), var(--success), var(--warning), var(--danger), var(--danger-dark));
}

/* Top Places Panel */
.top-places-panel {
    width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-normal);
    overflow: hidden;
}

.top-places-panel.collapsed {
    width: 48px;
}

.top-places-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.top-places-panel .panel-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
}

.top-places-panel.collapsed .panel-header h3 {
    display: none;
}

.panel-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-card);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.panel-toggle:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.top-places-panel.collapsed .panel-toggle svg {
    transform: rotate(180deg);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.top-places-panel.collapsed .panel-content {
    display: none;
}

/* Top place item */
.top-place-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.top-place-item:hover {
    background: var(--bg-card-hover);
}

.top-place-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    flex-shrink: 0;
}

.top-place-rank.rank-1 {
    background: linear-gradient(135deg, var(--warning-bright), var(--warning));
    color: var(--bg-primary);
}

.top-place-rank.rank-2 {
    background: linear-gradient(135deg, var(--gray-medium), var(--gray));
    color: white;
}

.top-place-rank.rank-3 {
    background: linear-gradient(135deg, var(--bronze), var(--bronze-dark));
    color: white;
}

.top-place-rank.rank-other {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.top-place-info {
    flex: 1;
    min-width: 0;
}

.top-place-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.top-place-stats {
    display: flex;
    gap: 0.75rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.top-place-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-xs);
    font-size: 0.65rem;
    font-weight: 500;
}

.top-place-badge.destination {
    background: var(--success-bg);
    color: var(--success);
}

.top-place-badge.departure {
    background: var(--info-bg);
    color: var(--info);
}

.top-place-badge.charging {
    background: var(--warning-bg);
    color: var(--warning);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .heatmap-extended-stats {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .extended-stat {
        flex: 1 1 100%;
    }

    .heatmap-main-content {
        flex-direction: column;
    }

    .top-places-panel {
        width: 100%;
        max-height: 200px;
    }

    .top-places-panel.collapsed {
        width: 100%;
        max-height: 48px;
    }

    .visited-places-container {
        height: auto;
        min-height: calc(100vh - 100px);
    }

    .heatmap-stats-bar {
        flex-wrap: wrap;
        gap: 1rem;
        padding: 1rem;
    }

    .heatmap-stat {
        flex: 1 1 45%;
    }

    .heatmap-controls {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .heatmap-map-container {
        min-height: 50vh;
    }

    .heatmap-legend {
        bottom: 10px;
        left: 10px;
        right: 10px;
    }

    .heatmap-legend .gradient-bar {
        flex: 1;
    }
}

/* ============================================
   TRIP/VOYAGE PAGE
   ============================================ */

.trip-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.trip-header h2 {
    margin: 0;
    color: var(--text-primary);
}

.trip-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.trip-quick-btns {
    display: flex;
    gap: 0.5rem;
}

.trip-quick-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

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

.trip-quick-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--text-inverse, #fff);
}

.trip-date-range {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.trip-date-range input[type="date"] {
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.trip-date-range span {
    color: var(--text-secondary);
}

.trip-period {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.trip-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.summary-card {
    flex: 1;
    min-width: 120px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    text-align: center;
}

.summary-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.summary-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

.trip-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.trip-stats-row .stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.trip-stats-row .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.trip-stats-row .stat-value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.trip-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.trip-card h3 {
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.trip-card.wide {
    grid-column: span 2;
}

.trip-card.map-card {
    grid-column: span 2;
    grid-row: span 2;
}

.trip-map {
    height: 300px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.trip-list {
    max-height: 300px;
    overflow-y: auto;
}

.trip-list-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.trip-list-item:last-child {
    border-bottom: none;
}

.trip-list-item .item-time {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.trip-list-item .item-main {
    color: var(--text-primary);
    font-weight: 500;
}

.trip-list-item .item-details {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-inverse, #fff);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-small:hover {
    background: var(--accent-hover);
}

.trip-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.trip-map-container {
    height: 400px;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.trip-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.trip-charts .panel {
    height: 300px;
}

.trip-lists {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.trip-selector {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.trip-selector .date-input {
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.trip-selector .btn {
    padding: 0.5rem 1rem;
}

@media (max-width: 1200px) {
    .trip-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .trip-charts,
    .trip-lists {
        grid-template-columns: 1fr;
    }
}

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

/* ============================================
   DRIVE STATS PAGE (Tabular Statistics)
   ============================================ */

.page-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header-row h2 {
    margin: 0;
    color: var(--text-primary);
}

.page-header-row .controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.page-header-row .controls select {
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 120px;
}

.dstats-summary {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dstats-selectors {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.dstats-selectors select {
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 150px;
}

.dstats-chart-container {
    height: 350px;
    margin-bottom: 1.5rem;
}

.stats-table {
    width: 100%;
    font-size: 0.8rem;
}

.stats-table th {
    background: var(--bg-panel-header);
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 500;
    white-space: nowrap;
}

.stats-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.stats-table tr:hover {
    background: var(--bg-hover);
}

.efficiency-gauge {
    position: relative;
    width: 80px;
    height: 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.efficiency-gauge .gauge-bar {
    height: 100%;
    transition: width var(--transition-normal);
}

.efficiency-gauge .gauge-value {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 0 2px rgba(0,0,0,0.8);
}

.period-link {
    color: var(--accent-primary);
    text-decoration: none;
}

.period-link:hover {
    text-decoration: underline;
}

@media (max-width: 1400px) {
    .dstats-summary {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .dstats-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-table {
        font-size: 0.7rem;
    }
    .stats-table th,
    .stats-table td {
        padding: 0.35rem 0.5rem;
    }
}

/* ============================================
   CHARGING STATS PAGE (AC vs DC)
   ============================================ */

.cs-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.cs-card {
    flex: 1;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.cs-card h3 {
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cs-card.wide {
    flex: 2;
    min-width: 400px;
}

.cs-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.cs-stat:last-child {
    margin-bottom: 0;
}

.cs-stat .stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cs-stat .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.cs-stats-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cs-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.cs-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.cs-charts .panel {
    height: 350px;
}

.cs-comparison {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.cs-comparison .comparison-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.comparison-card h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.comparison-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
}

.comparison-stat:last-child {
    border-bottom: none;
}

.comparison-stat .label {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.comparison-stat .value {
    font-weight: 600;
    font-size: 0.9rem;
}

.ac-value { color: var(--accent-blue); }
.dc-value { color: var(--accent-purple); }

.power-curve-container {
    height: 300px;
}

@media (max-width: 1200px) {
    .cs-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .cs-charts,
    .cs-comparison {
        grid-template-columns: 1fr;
    }
}

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

/* ============================================
   VAMPIRE DRAIN PAGE
   ============================================ */

.drain-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.drain-card {
    flex: 1;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.drain-card h3 {
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.drain-card.wide {
    flex: 2;
    min-width: 400px;
}

.drain-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.drain-chart-container {
    height: 350px;
    margin-bottom: 1.5rem;
}

.drain-periods {
    margin-top: 1.5rem;
}

.drain-table {
    width: 100%;
    font-size: 0.8rem;
}

.drain-table th {
    background: var(--bg-panel-header);
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 500;
}

.drain-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.drain-table tr:hover {
    background: var(--bg-hover);
}

.drain-severity {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
}

.drain-severity.low {
    background: var(--success-bg);
    color: var(--success);
}

.drain-severity.medium {
    background: var(--warning-bg);
    color: var(--warning);
}

.drain-severity.high {
    background: var(--danger-bg);
    color: var(--danger);
}

@media (max-width: 1200px) {
    .drain-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

/* ============================================
   STATES TIMELINE PAGE
   ============================================ */

.states-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.states-timeline-container {
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.states-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 100%;
}

.timeline-day {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.timeline-day-label {
    width: 100px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.timeline-bar {
    flex: 1;
    height: 24px;
    display: flex;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-tertiary);
}

.timeline-segment {
    height: 100%;
    position: relative;
    transition: opacity var(--transition-fast);
    cursor: pointer;
}

.timeline-segment:hover {
    opacity: 0.8;
}

.timeline-segment[data-state="driving"] { background: var(--accent-blue); }
.timeline-segment[data-state="charging"] { background: var(--accent-green); }
.timeline-segment[data-state="online"] { background: var(--accent-cyan); }
.timeline-segment[data-state="asleep"] { background: var(--text-dim); }
.timeline-segment[data-state="offline"] { background: var(--text-muted); }
.timeline-segment[data-state="suspended"] { background: var(--accent-purple); }

.states-distribution {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.states-distribution .panel {
    height: 300px;
}

.states-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-sm);
}

@media (max-width: 1400px) {
    .states-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .states-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .states-distribution {
        grid-template-columns: 1fr;
    }
}

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

/* ============================================
   PROJECTED RANGE PAGE
   ============================================ */

.range-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.range-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.range-charts .panel {
    height: 350px;
}

.range-scatter {
    height: 400px;
    margin-bottom: 1.5rem;
}

.range-factors {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.factor-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.factor-card h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.factor-impact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
}

.factor-impact .factor-name {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.factor-impact .factor-value {
    font-weight: 600;
    font-size: 0.85rem;
}

.factor-impact.positive .factor-value { color: var(--success); }
.factor-impact.negative .factor-value { color: var(--danger); }
.factor-impact.neutral .factor-value { color: var(--text-secondary); }

@media (max-width: 1200px) {
    .range-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .range-charts {
        grid-template-columns: 1fr;
    }
    .range-factors {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .range-grid {
        grid-template-columns: 1fr;
    }
    .range-factors {
        grid-template-columns: 1fr;
    }
}

/* ===========================================
   Advanced Pages - Common Styles
   =========================================== */

/* Button Group */
.btn-group {
    display: inline-flex;
    gap: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.btn-group .trip-quick-btn {
    padding: 0.4rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-right: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-group .trip-quick-btn:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.btn-group .trip-quick-btn:last-child {
    border-right: 1px solid var(--border-color);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.btn-group .trip-quick-btn:hover {
    background: var(--bg-hover);
}

.btn-group .trip-quick-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Date Input */
.date-input {
    padding: 0.4rem 0.6rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8rem;
}

.date-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.date-separator {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* Period Info */
.period-info {
    margin: 0.5rem 0 0 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

.stat-box {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
}

.stat-box .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.stat-box .stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Map Container */
.map-container {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-tertiary);
    min-height: 400px;
    height: 100%;
}

/* Trip page map - ensure proper sizing */
#trip-map {
    height: 450px !important;
    min-height: 450px;
}

/* Make analytics cards with maps fill their grid area */
.analytics-card.large {
    display: flex;
    flex-direction: column;
}

.analytics-card.large .map-container {
    flex: 1;
    min-height: 400px;
}

/* States Timeline Container */
.states-timeline-container {
    padding: 1rem 0;
}

.states-bar {
    display: flex;
    height: 24px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-tertiary);
}

.state-segment {
    min-width: 1px;
    transition: all 0.2s;
}

.state-segment:hover {
    opacity: 0.8;
}

.states-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Items List */
.items-list {
    max-height: 350px;
    overflow-y: auto;
}

.items-list .trip-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.items-list .trip-item:last-child {
    border-bottom: none;
}

.items-list .trip-item:hover {
    background: var(--bg-hover);
}

.trip-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.trip-item-icon svg {
    width: 18px;
    height: 18px;
    color: white;
}

.trip-item-icon.ac {
    background: var(--success);
}

.trip-item-icon.dc {
    background: var(--warning);
}

.trip-item-content {
    flex: 1;
    min-width: 0;
}

.trip-item-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trip-item-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.trip-item-stats {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.trip-item-stats .stat {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.trip-item-stats .stat.battery {
    color: var(--success);
}

.trip-item-stats .stat.cost {
    color: var(--warning);
    font-weight: 500;
}

/* Data Table Container */
.data-table-container {
    overflow-x: auto;
}

.data-table-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table-container th,
.data-table-container td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table-container th {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table-container td {
    color: var(--text-primary);
}

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

/* Stats List */
.stats-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.stat-row .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-row .stat-value {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* AC/DC Stat Highlight */
.overview-stat.ac-stat .overview-value {
    color: var(--success);
}

.overview-stat.dc-stat .overview-value {
    color: var(--warning);
}

/* Badge in trip items */
.trip-item .badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-xs, 3px);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 0.5rem;
}

.trip-item .badge.ac {
    background: var(--success-bg, rgba(115, 191, 105, 0.2));
    color: var(--success);
}

.trip-item .badge.dc {
    background: var(--warning-bg, rgba(255, 152, 0, 0.2));
    color: var(--warning);
}

/* State Badge */
.state-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
}

.state-badge.online { background: var(--info-bg); color: var(--info); }
.state-badge.offline { background: var(--warning-bg); color: var(--warning); }
.state-badge.asleep { background: var(--success-bg); color: var(--success); }
.state-badge.driving { background: var(--accent-bg); color: var(--accent-primary); }
.state-badge.charging { background: var(--warning-bg); color: var(--warning); }

/* Responsive */
@media (max-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .trip-item-stats {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .btn-group {
        flex-wrap: wrap;
    }

    .period-selector {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem !important;
    }

    .trip-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .trip-item-stats {
        width: 100%;
        justify-content: flex-start;
        margin-top: 0.5rem;
    }
}
