/* ============================================
   Auto Kilometer Tracker - Apple Style UI
   ============================================ */

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

:root {
    /* Colors - Apple Light Mode */
    --primary: #007AFF;
    --primary-hover: #0066DD;
    --primary-active: #0055CC;
    --success: #34C759;
    --warning: #FF9500;
    --danger: #FF3B30;

    /* Backgrounds */
    --bg-primary: #F5F5F7;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F2F2F7;
    --bg-elevated: #FFFFFF;

    /* Sidebar */
    --sidebar-bg: rgba(255, 255, 255, 0.72);
    --sidebar-border: rgba(0, 0, 0, 0.06);
    --sidebar-width: 280px;
    --sidebar-collapsed: 72px;

    /* Text */
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --text-tertiary: #AEAEB2;

    /* Borders & Shadows */
    --border-color: rgba(0, 0, 0, 0.06);
    --border-color-strong: rgba(0, 0, 0, 0.1);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.16);

    /* Radius */
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 22px;

    /* Transitions */
    --transition-fast: 150ms ease-out;
    --transition-normal: 200ms ease-out;
    --transition-slow: 300ms ease-out;

    /* Nav Item */
    --nav-item-bg: transparent;
    --nav-item-bg-hover: rgba(0, 0, 0, 0.04);
    --nav-item-bg-active: rgba(0, 122, 255, 0.12);
    --nav-item-text-active: var(--primary);
    --sidebar-icon: #86868B;
    --sidebar-icon-hover: #6E6E73;
    --sidebar-icon-active: var(--primary);
    --sidebar-active-indicator: var(--primary);

    /* Header */
    --header-height: 64px;
}

/* Dark Mode */
body.theme-dark {
    --bg-primary: #000000;
    --bg-secondary: #1C1C1E;
    --bg-tertiary: #2C2C2E;
    --bg-elevated: #2C2C2E;

    --sidebar-bg: rgba(28, 28, 30, 0.85);
    --sidebar-border: rgba(255, 255, 255, 0.08);

    --text-primary: #F5F5F7;
    --text-secondary: #98989D;
    --text-tertiary: #636366;

    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-strong: rgba(255, 255, 255, 0.12);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.5);

    --nav-item-bg-hover: rgba(255, 255, 255, 0.06);
    --nav-item-bg-active: rgba(0, 122, 255, 0.2);
    --sidebar-icon: #98989D;
    --sidebar-icon-hover: #C7C7CC;
    --sidebar-icon-active: #0A84FF;
    --sidebar-active-indicator: #0A84FF;
}

/* AKT Logo Colors */
.akt-fg { stroke: #111827; fill: #111827; }
.akt-muted-stroke { stroke: #111827; opacity: 0.18; }
.akt-muted-fill { fill: #111827; opacity: 0.65; }
.akt-accent { stroke: #2563EB; }

body.theme-dark .akt-fg { stroke: #E5E7EB; fill: #E5E7EB; }
body.theme-dark .akt-muted-stroke { stroke: #E5E7EB; }
body.theme-dark .akt-muted-fill { fill: #E5E7EB; }
body.theme-dark .akt-accent { stroke: #4DA3FF; }

/* ============================================
   Typography
   ============================================ */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 22px; line-height: 1.25; }
h3 { font-size: 17px; line-height: 1.3; }

/* ============================================
   App Shell Layout
   ============================================ */

.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition-slow), transform var(--transition-slow);
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.sidebar-logo {
    display: flex;
    align-items: center;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-icon svg {
    display: block;
}

.sidebar-logo-text-full {
    display: flex;
    align-items: center;
    overflow: hidden;
    width: 100%;
}

.sidebar-logo-text-full svg {
    display: block;
    width: 100%;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    border: none;
    background: var(--nav-item-bg);
    width: 100%;
    text-align: left;
}

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

.nav-item {
    position: relative;
}

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

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--sidebar-active-indicator);
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    color: var(--sidebar-icon);
    transition: color var(--transition-fast);
}

.nav-item-icon svg {
    display: block;
}

.nav-item:hover .nav-item-icon {
    color: var(--sidebar-icon-hover);
}

.nav-item.active .nav-item-icon {
    color: var(--sidebar-icon-active);
}

.nav-item-label {
    white-space: nowrap;
    overflow: hidden;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: absolute;
    top: 20px;
    right: -14px;
    width: 28px;
    height: 28px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    z-index: 101;
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
    transform: scale(1.05);
}

.sidebar-toggle svg {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
    transition: transform var(--transition-normal);
}

/* Sidebar Collapsed State */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-logo-text-full {
    display: none;
    opacity: 0;
    visibility: hidden;
}

.sidebar.collapsed .sidebar-logo-icon {
    display: flex;
}

.sidebar.collapsed .nav-item-label,
.sidebar.collapsed .nav-section-title {
    opacity: 0;
    visibility: hidden;
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

/* ============================================
   Main Content Area
   ============================================ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* Top Bar */
.top-bar {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 50;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-left: 17px;
}

.top-bar-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logout-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

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

/* Page Content */
.page-content {
    padding: 32px;
    max-width: 1100px;
    margin: 0 auto;
}

/* Page Header */
.page-header {
    margin-bottom: 32px;
}

#page-wiki .page-header,
#page-architecture .page-header,
#page-settings .page-header {
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

.page-title {
    display: none;
}

.page-subtitle {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

/* ============================================
   Cards
   ============================================ */

.card {
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.card-body {
    padding: 24px;
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.1;
}

.stat-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.btn:active {
    transform: scale(0.98);
}

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

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

.btn-primary:active {
    background: var(--primary-active);
}

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

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

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

.btn-danger:hover {
    background: #E6352B;
}

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

.btn-danger-outline:hover {
    background: rgba(255, 59, 48, 0.1);
}

.btn-tinted {
    background: rgba(0, 122, 255, 0.15);
    color: var(--primary);
}

.btn-tinted:hover {
    background: rgba(0, 122, 255, 0.25);
}

.btn-tinted-secondary {
    background: rgba(142, 142, 147, 0.18);
    color: var(--text-primary);
}

.btn-tinted-secondary:hover {
    background: rgba(142, 142, 147, 0.28);
}

.btn-tinted-danger {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
}

.btn-tinted-danger:hover {
    background: rgba(255, 59, 48, 0.18);
}

.btn-export {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px;
    margin-left: auto;
}

.btn-export:hover {
    border-color: var(--border-color-strong);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 16px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

/* Settings Button (Top Bar) */
.btn-settings {
    background: transparent;
    color: var(--sidebar-icon);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-settings:hover {
    background: var(--nav-item-bg-hover);
    color: var(--sidebar-icon-hover);
}

/* ============================================
   Form Elements
   ============================================ */

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

.form-group .helper-text {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
    background: var(--bg-elevated);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-tertiary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

/* Select Styling */
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}

/* Checkbox */
.checkbox-group {
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 15px;
}

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

/* Settings Select */
.settings-select {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: all var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}

.settings-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
    background-color: var(--bg-elevated);
}

/* ============================================
   Vehicle Section
   ============================================ */

.vehicle-section {
    background: var(--bg-elevated);
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-top: 4px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.vehicle-header {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.vehicle-header select {
    flex: 1;
    min-width: 200px;
    padding: 12px 14px;
    font-size: 15px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.vehicle-header select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

/* ============================================
   Dashboard
   ============================================ */

.dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Progress Section */
.progress-section {
    background: var(--bg-elevated);
    padding: 28px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 14px;
}

.progress-bar {
    height: 10px;
    background: var(--bg-tertiary);
    border-radius: 5px;
    position: relative;
    overflow: visible;
}

.progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease-out;
    background: linear-gradient(90deg, var(--primary) 0%, #5AC8FA 100%);
}

.progress-fill.warning {
    background: linear-gradient(90deg, var(--warning) 0%, #FFCC00 100%);
}

.progress-fill.critical {
    background: linear-gradient(90deg, var(--danger) 0%, #FF6B6B 100%);
}

.progress-marker {
    position: absolute;
    top: -5px;
    width: 3px;
    height: 20px;
    background: var(--text-primary);
    border-radius: 2px;
    transform: translateX(-50%);
    box-shadow: var(--shadow-sm);
}

.progress-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Cost Section */
.cost-section {
    background: var(--bg-elevated);
    padding: 28px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.cost-section h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.cost-display {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.cost-value {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.cost-value.positive {
    color: var(--danger);
}

.cost-value.negative {
    color: var(--success);
}

.cost-label {
    color: var(--text-secondary);
    font-size: 14px;
}

#reports-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Chart Section */
.chart-section {
    background: var(--bg-elevated);
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

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

.chart-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.chart-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chart-year-select {
    padding: 6px 12px;
    font-size: 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
}

.chart-legend {
    display: flex;
    gap: 16px;
    align-items: center;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.chart-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chart-legend-line {
    width: 16px;
    height: 2px;
    flex-shrink: 0;
    border-radius: 1px;
}

.chart-legend-line.dashed {
    background: repeating-linear-gradient(
        90deg,
        currentColor 0, currentColor 4px,
        transparent 4px, transparent 7px
    );
    height: 2px;
}

.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

/* Averages Section */
.avg-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.avg-card {
    background: var(--bg-elevated);
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.avg-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.avg-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.avg-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ============================================
   Mileage Form Section
   ============================================ */

#mileage-form-section {
    background: var(--bg-elevated);
    padding: 28px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-top: 24px;
    box-shadow: var(--shadow-sm);
}

#mileage-form-section h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 24px;
}

/* ============================================
   Notification Banner
   ============================================ */

.notification-banner {
    background: rgba(255, 149, 0, 0.1);
    border: 1px solid rgba(255, 149, 0, 0.25);
    color: #8A5A00;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

body.theme-dark .notification-banner {
    background: rgba(255, 149, 0, 0.15);
    color: #FFB84D;
}

.notification-banner .notification-item + .notification-item {
    margin-top: 8px;
}

/* Compact Cards */
body.compact-cards .stat-card,
body.compact-cards .avg-card,
body.compact-cards .porsche-sync-card {
    padding: 12px 14px;
}

/* ============================================
   Porsche Connect
   ============================================ */

.porsche-sync-card {
    background: linear-gradient(135deg, #B4975A 0%, #8B7342 100%);
    padding: 16px 18px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.cupra-sync-card {
    background: linear-gradient(135deg, #153B42 0%, #0E2A2F 100%);
}

.bmw-sync-card {
    background: linear-gradient(135deg, #0A3260 0%, #061E3D 100%);
}

.porsche-sync-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.porsche-sync-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.porsche-icon {
    font-size: 1.4rem;
}

.porsche-label {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.btn-sync {
    background: rgba(255, 255, 255, 0.18);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-sync:hover {
    background: rgba(255, 255, 255, 0.28);
}

.btn-sync.syncing {
    opacity: 0.7;
    cursor: wait;
}

.sync-icon {
    font-size: 16px;
    display: inline-block;
}

.sync-icon.spinning {
    animation: spin 1s linear infinite;
}

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

.porsche-sync-result {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.sync-mileage {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.sync-mileage-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
}

.sync-mileage-value {
    font-size: 22px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
}

.sync-time {
    margin-top: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

.sync-next {
    margin-top: 4px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

/* SoC (State of Charge) Anzeige - ADDITIV */
.soc-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.soc-display {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.soc-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

.soc-value {
    font-size: 24px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
}

.soc-value.loading {
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    font-weight: 400;
}

.soc-value.unavailable {
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
    font-weight: 400;
}

.soc-time {
    margin-top: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.sync-status {
    margin-top: 16px;
    font-size: 14px;
    font-weight: 500;
    min-height: 22px;
}

.sync-status.success {
    color: #90EE90;
}

.sync-status.error {
    color: #FFB4B4;
    background: rgba(255, 59, 48, 0.2);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
}

/* Porsche Modal Styles */
.porsche-status {
    background: var(--bg-tertiary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    text-align: center;
    font-size: 13px;
}

.porsche-status.connected {
    background: linear-gradient(135deg, rgba(180, 151, 90, 0.1) 0%, rgba(139, 115, 66, 0.1) 100%);
    border: 1px solid rgba(180, 151, 90, 0.25);
}

.porsche-status.connected p {
    color: #8B7342;
    font-weight: 500;
}

.porsche-status.unavailable {
    background: rgba(255, 59, 48, 0.08);
    border: 1px solid rgba(255, 59, 48, 0.2);
}

.porsche-status.unavailable p {
    color: var(--danger);
    font-weight: 500;
}

.porsche-vehicles {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.porsche-vehicle-item {
    background: var(--bg-tertiary);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.porsche-vehicle-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.porsche-vehicle-item .vin {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'SF Mono', Monaco, monospace;
}

/* BMW Profile Cards */
.bmw-profiles-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.bmw-profile-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
}

.bmw-profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.bmw-profile-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.bmw-profile-name {
    font-weight: 600;
    color: var(--text-primary);
}

.bmw-profile-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.bmw-profile-status.connected {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.bmw-profile-status.disconnected {
    background: rgba(239, 68, 68, 0.1);
    color: var(--text-secondary);
}

.bmw-profile-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.bmw-profile-actions .btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

.bmw-profile-details {
    margin-top: 8px;
    color: var(--text-secondary);
}

.bmw-profile-device-flow {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.bmw-profile-vehicles-list {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.bmw-profile-vehicles-list .porsche-vehicle-item {
    margin-bottom: 8px;
}

.bmw-profile-vehicle-info {
    margin-top: 8px;
}

.bmw-profile-vehicle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.bmw-profile-vehicle-row small {
    color: var(--text-secondary);
}

.badge-linked {
    font-size: 11px;
    color: var(--accent-color);
    background: rgba(0, 122, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Captcha */
.captcha-section {
    background: linear-gradient(135deg, rgba(180, 151, 90, 0.1) 0%, rgba(139, 115, 66, 0.1) 100%);
    border: 1px solid rgba(180, 151, 90, 0.25);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin: 20px 0;
}

.captcha-container {
    text-align: center;
}

.captcha-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.captcha-image-wrapper {
    background: white;
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: inline-block;
    box-shadow: var(--shadow-sm);
}

.captcha-image-wrapper img {
    max-width: 100%;
    height: auto;
    display: block;
}

.captcha-section .form-group {
    margin-bottom: 0;
}

.captcha-section input {
    text-align: center;
    font-size: 18px;
    letter-spacing: 2px;
    font-weight: 600;
}

/* BMW Device Flow Styles */
.device-flow-section {
    background: linear-gradient(135deg, rgba(0, 122, 204, 0.1) 0%, rgba(0, 92, 169, 0.1) 100%);
    border: 1px solid rgba(0, 122, 204, 0.25);
    border-radius: var(--radius-sm);
    padding: 24px;
    margin: 20px 0;
    text-align: center;
}

.device-flow-instructions {
    margin-bottom: 20px;
}

.device-flow-instructions p {
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.device-flow-instructions strong {
    color: var(--text-primary);
}

.device-flow-link {
    display: inline-block;
    background: var(--bg-tertiary);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    word-break: break-all;
}

.device-flow-link a {
    color: #007ACC;
    font-weight: 600;
    text-decoration: none;
}

.device-flow-link a:hover {
    text-decoration: underline;
}

.user-code {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 4px;
    color: #007ACC;
    background: var(--bg-secondary);
    padding: 16px 32px;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin: 16px 0;
    border: 2px dashed rgba(0, 122, 204, 0.4);
}

.device-flow-timer {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 16px;
}

.device-flow-timer.warning {
    color: var(--warning);
}

.device-flow-timer.expired {
    color: var(--danger);
}

.device-flow-status {
    margin-top: 16px;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.device-flow-status.pending {
    background: rgba(255, 204, 0, 0.1);
    color: var(--warning);
}

.device-flow-status.success {
    background: rgba(52, 199, 89, 0.1);
    color: var(--success);
}

.device-flow-status.error {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
}

.bmw-status {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    text-align: center;
}

.bmw-status.connected {
    background: linear-gradient(135deg, rgba(0, 122, 204, 0.1) 0%, rgba(0, 92, 169, 0.1) 100%);
    border: 1px solid rgba(0, 122, 204, 0.25);
}

.bmw-status.connected p {
    color: #007ACC;
    font-weight: 500;
}

.bmw-status.unavailable {
    background: rgba(255, 59, 48, 0.08);
    border: 1px solid rgba(255, 59, 48, 0.2);
}

.bmw-status.unavailable p {
    color: var(--danger);
    font-weight: 500;
}

.bmw-config-section {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    margin-top: 20px;
}

.bmw-config-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* ============================================
   Modal
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

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

.modal-content {
    background: var(--bg-elevated);
    padding: 32px;
    border-radius: var(--radius-lg);
    max-width: 520px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

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

.modal-close-btn:active {
    background: var(--bg-active);
    transform: scale(0.95);
}

.modal-content h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
}

.modal-content h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin: 8px 0 16px;
}

.modal-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 28px;
}

.modal-actions-right {
    display: flex;
    gap: 12px;
    margin-left: auto;
}

/* Settings Grid */
.settings-grid {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Settings Card (HA-style) */
.settings-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.settings-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 16px 0;
    margin: 0;
}

.settings-card-body {
    padding: 8px 0;
}

.settings-card-body .porsche-status {
    margin: 0 16px 4px;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

/* Settings Row (HA list-item style) */
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    min-height: 44px;
    border-bottom: 1px solid var(--border-color);
}

.settings-row-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.settings-row:last-child,
.settings-card-body > :last-child .settings-row:last-child {
    border-bottom: none;
}

.settings-row-label {
    font-size: 14px;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
}

.settings-row-control {
    width: auto;
    min-width: 100px;
    max-width: 140px;
    padding: 6px 10px;
    font-size: 13px;
    text-align: right;
    flex-shrink: 0;
}

.settings-input-narrow {
    max-width: 90px;
    text-align: right;
}

.settings-row-chevron {
    font-size: 20px;
    color: var(--text-tertiary);
    margin-left: 8px;
    flex-shrink: 0;
}

.settings-row.clickable {
    cursor: pointer;
    transition: background var(--transition-fast);
}

.settings-row.clickable:hover {
    background: var(--bg-tertiary);
}

.settings-row.clickable:active {
    background: var(--border-color);
}

.settings-row-restore {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.settings-restore-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.settings-restore-controls input[type="file"] {
    font-size: 12px;
    flex: 1;
    min-width: 0;
}

/* Toggle Switch (HA-style) */
.settings-toggle {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

.settings-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--text-tertiary);
    border-radius: 12px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.settings-toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.settings-toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* Settings Card Form (integrations) */
.settings-card-form {
    padding: 8px 16px 4px;
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
}

.settings-card-form h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 4px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.settings-card-form .form-group {
    margin-bottom: 10px;
}

.settings-card-form .form-group label {
    margin-bottom: 3px;
    font-size: 12px;
}

.settings-card-form .form-group input,
.settings-card-form .form-group select,
.settings-card-form .form-group textarea {
    padding: 8px 10px;
    font-size: 13px;
}

.settings-card-form .form-hint {
    margin-top: 2px;
    font-size: 11px;
}

.settings-card-body .porsche-vehicles {
    margin: 0;
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
}

.settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 10px;
}

#delete-porsche {
    margin-right: auto;
}

/* ============================================
   Status Colors
   ============================================ */

.status-good { color: var(--success); }
.status-warning { color: var(--warning); }
.status-critical { color: var(--danger); }

/* ============================================
   Utility Classes
   ============================================ */

.hidden {
    display: none !important;
}

/* ============================================
   Auth Screens
   ============================================ */

.auth-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    margin-bottom: 32px;
}

.auth-logo svg {
    width: 100%;
    height: auto;
    transform: scale(1.15);
    transform-origin: left center;
}

.auth-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.auth-submit {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background var(--transition-fast);
}

.auth-submit:hover {
    background: var(--primary-hover);
}

.auth-error {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    margin-bottom: 16px;
}

.auth-success {
    background: rgba(52, 199, 89, 0.1);
    color: var(--success);
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    margin-bottom: 16px;
}

.auth-forgot-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    color: var(--primary);
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}

.auth-forgot-link:hover:not(.auth-forgot-link-disabled) {
    text-decoration: underline;
}

.auth-forgot-link-disabled {
    color: var(--text-tertiary);
    cursor: default;
    pointer-events: none;
}

.auth-back-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}

.auth-back-link:hover {
    color: var(--text-primary);
}

/* SMTP compact card */
.smtp-desc {
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.smtp-inline-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.smtp-separator {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.smtp-input-wide {
    max-width: 260px;
    min-width: 180px;
}

.smtp-input-host {
    width: 180px;
    padding: 6px 10px;
    font-size: 13px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.smtp-input-port {
    width: 70px;
    padding: 6px 10px;
    font-size: 13px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    -moz-appearance: textfield;
}

.smtp-input-port::-webkit-inner-spin-button,
.smtp-input-port::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.smtp-input-cred {
    width: 140px;
    padding: 6px 10px;
    font-size: 13px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.smtp-input-host:focus,
.smtp-input-port:focus,
.smtp-input-cred:focus,
.smtp-input-wide:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
    background: var(--bg-elevated);
}

.smtp-input-host::placeholder,
.smtp-input-port::placeholder,
.smtp-input-cred::placeholder {
    color: var(--text-tertiary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.smtp-test-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
}

.smtp-test-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.smtp-actions-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
}

.settings-row .smtp-input-wide {
    padding: 6px 10px;
    font-size: 13px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.settings-row .smtp-input-wide::placeholder {
    color: var(--text-tertiary);
}

@media (max-width: 600px) {
    .smtp-inline-group {
        flex-wrap: wrap;
    }
    .smtp-input-host {
        width: 100%;
    }
    .smtp-input-cred {
        width: 100%;
    }
    .smtp-input-wide {
        max-width: 100%;
        min-width: 0;
        width: 100%;
    }
    .smtp-test-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

.auth-user-badge {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
}

@media (max-width: 600px) {
    .auth-card {
        margin: 0 16px;
        padding: 36px 24px;
    }
}

/* ============================================
   Toast Notifications
   ============================================ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlideIn 0.3s ease-out;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    line-height: 1;
}

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

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

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

/* ============================================
   Loading & Empty States
   ============================================ */

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinner 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.loading-state p {
    color: var(--text-secondary);
    font-size: 14px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ============================================
   Page Header
   ============================================ */

.page-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* ============================================
   Filter Bar
   ============================================ */

.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}

.filter-select {
    min-width: 200px;
    padding: 10px 14px;
    font-size: 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-select:hover {
    border-color: var(--border-color-strong);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

/* ============================================
   Trips List
   ============================================ */

.trips-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trip-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.trip-item:hover {
    border-color: var(--border-color-strong);
    box-shadow: var(--shadow-sm);
}

.trip-date {
    min-width: 100px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.trip-km {
    min-width: 120px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

.trip-delta {
    min-width: 80px;
    font-size: 13px;
    color: var(--text-secondary);
}

.trip-delta.positive {
    color: var(--success);
}

.trip-battery {
    min-width: 70px;
    font-size: 13px;
    color: var(--text-secondary);
}

.trip-note {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trip-source {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.trip-source.porsche {
    background: rgba(180, 151, 90, 0.15);
    color: #8B7342;
}

.trip-actions {
    display: flex;
    gap: 8px;
}

/* ============================================
   Vehicles Grid
   ============================================ */

.vehicles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 500px));
    gap: 20px;
    padding-top: 6px;
}

.vehicle-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.vehicle-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.vehicle-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.vehicle-card-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.vehicle-card-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.vehicle-card-badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--radius-xs);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 500;
}

.vehicle-card-badge.porsche {
    background: linear-gradient(135deg, rgba(180, 151, 90, 0.15) 0%, rgba(139, 115, 66, 0.15) 100%);
    color: #8B7342;
}

.vehicle-card-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

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

.vehicle-stat-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.vehicle-stat-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   Source Distribution
   ============================================ */

.source-distribution {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.source-label {
    min-width: 100px;
    font-size: 14px;
    color: var(--text-primary);
}

.source-bar-wrapper {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.source-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease-out;
}

.source-bar.manual {
    background: var(--primary);
}

.source-bar.porsche {
    background: linear-gradient(90deg, #B4975A 0%, #8B7342 100%);
}

.source-count {
    min-width: 60px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: right;
}

/* ============================================
   Energy Usage Table
   ============================================ */

.energy-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.energy-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.energy-table thead th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.energy-table thead th:nth-child(3) {
    text-align: left;
}

.energy-table thead th:nth-child(4) {
    text-align: center;
}

.energy-row td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.energy-row:hover {
    background: var(--bg-tertiary);
}

.energy-month {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

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

.month-year {
    font-size: 12px;
    color: var(--text-secondary);
}

.energy-value-cell {
    text-align: left;
}

.energy-bar-container {
    display: inline-block;
    width: 60px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 10px;
}

.energy-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease-out;
}

.energy-bar-good {
    background: linear-gradient(90deg, #34C759, #30B350);
}

.energy-bar-avg {
    background: linear-gradient(90deg, #FF9500, #FF8000);
}

.energy-bar-high {
    background: linear-gradient(90deg, #FF3B30, #E0342B);
}

.energy-value {
    font-weight: 600;
    color: var(--text-primary);
}

.energy-km {
    text-align: left;
    color: var(--text-secondary);
}

.energy-temp-cell {
    text-align: center;
}

.energy-temp {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
}

.energy-temp.temp-cold {
    background: rgba(0, 122, 255, 0.12);
    color: #007AFF;
}

.energy-temp.temp-mild {
    background: rgba(52, 199, 89, 0.12);
    color: #34C759;
}

.energy-temp.temp-warm {
    background: rgba(255, 149, 0, 0.12);
    color: #FF9500;
}

.energy-table tfoot td {
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.energy-summary td {
    color: var(--text-primary);
}

.energy-summary td:nth-child(3) {
    text-align: left;
}

@media (max-width: 600px) {
    .energy-table thead th,
    .energy-row td,
    .energy-table tfoot td {
        padding: 6px 8px;
        font-size: 12px;
    }

    .energy-bar-container {
        width: 30px;
        margin-right: 6px;
    }

    .energy-value {
        font-size: 12px;
    }

    .energy-km,
    .energy-table thead th:nth-child(3),
    .energy-table tfoot td:nth-child(3) {
        display: none;
    }

    .energy-temp-cell {
        font-size: 11px;
    }

    .month-name {
        font-size: 13px;
    }

    .month-year {
        font-size: 10px;
    }
}

/* Reifensatz-Tabelle */
.tire-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.tire-stats-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.tire-stats-table th:last-child {
    text-align: center;
}

.tire-stats-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

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

.tire-stats-table tr:hover {
    background: var(--bg-tertiary);
}

.tire-stats-table .tire-name {
    font-weight: 400;
}

.tire-stats-table .tire-name.active {
    font-weight: 600;
}

.tire-stats-table .tire-type {
    color: var(--text-secondary);
}

.tire-stats-table .tire-km {
    font-weight: 600;
}

.tire-stats-table .tire-status {
    text-align: center;
}

.tire-status-badge {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.tire-status-badge.active {
    background: rgba(52, 199, 89, 0.12);
    color: var(--success);
}

.tire-status-badge.inactive {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
}

@media (max-width: 600px) {
    .tire-stats-table th,
    .tire-stats-table td {
        padding: 8px 6px;
        font-size: 12px;
    }

    .tire-stats-table th {
        font-size: 10px;
    }

    /* Typ-Spalte auf Mobile ausblenden */
    .tire-stats-table th:nth-child(2),
    .tire-stats-table td:nth-child(2) {
        display: none;
    }

    .tire-status-badge {
        padding: 2px 6px;
        font-size: 10px;
    }
}

/* ============================================
   Form Value Display
   ============================================ */

.form-value {
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
}

/* ============================================
   Button States
   ============================================ */

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
}

/* ============================================
   Scrollbar
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

body.theme-dark ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

body.theme-dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

::selection {
    background: rgba(0, 122, 255, 0.2);
}

/* ============================================
   Mobile Sidebar (Drawer)
   ============================================ */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.sidebar-overlay.visible {
    opacity: 1;
}

.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-icon);
    transition: all var(--transition-fast);
}

.mobile-menu-btn:hover {
    background: var(--nav-item-bg-hover);
    color: var(--sidebar-icon-hover);
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-toggle {
        display: none;
    }
}

@media (max-width: 768px) {
    .page-content {
        padding: 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .avg-section {
        grid-template-columns: 1fr;
    }

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

    .stat-value {
        font-size: 24px;
    }

    .vehicle-header {
        flex-direction: column;
        align-items: stretch;
    }

    .vehicle-header select {
        width: 100%;
    }

    .vehicle-header .btn {
        width: 100%;
    }

    .top-bar {
        padding: 0 16px;
    }

    .top-bar-title {
        font-size: 15px;
    }
}

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

    .cost-value {
        font-size: 28px;
    }

    .modal-content {
        padding: 24px;
        margin: 16px;
        border-radius: var(--radius-md);
    }

    .porsche-sync-header {
        flex-direction: column;
        align-items: stretch;
    }

    .porsche-sync-logo {
        justify-content: center;
    }

    .btn-sync {
        justify-content: center;
    }

    .sync-mileage {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .sync-mileage-value {
        font-size: 32px;
    }

    .page-title {
        display: none;
    }
}

/* ============================================
   MOBILE OPTIMIERUNGEN - Touch & Scroll Fixes
   ============================================ */

/* Body scroll lock when sidebar/modal is open */
body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Safe Area Insets for iPhone Notch */
.top-bar {
    padding-top: env(safe-area-inset-top);
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
}

.sidebar {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
}

.page-content {
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

/* Fix 100vh on mobile browsers (address bar issue) */
@supports (height: 100dvh) {
    .sidebar {
        height: 100dvh;
    }
    .app-shell {
        min-height: 100dvh;
    }
    .main-content {
        min-height: 100dvh;
    }
}

/* iOS smooth scrolling */
.sidebar-nav,
.page-content,
.modal-content,
.trips-list {
    -webkit-overflow-scrolling: touch;
}

/* Ensure main content scrolls properly */
.main-content {
    overflow-y: auto;
    overflow-x: hidden;
}

.page-content {
    overflow-x: hidden;
}

/* Minimum touch target sizes (44px as per Apple HIG) */
.btn,
.nav-item,
.mobile-menu-btn,
.sidebar-toggle,
.filter-select,
.trip-item,
.vehicle-card,
.checkbox-label,
.toast-close {
    min-height: 44px;
}

.sidebar-toggle {
    min-height: 28px;
    min-width: 28px;
}

.btn-sm {
    min-height: 36px;
}

.btn-icon {
    min-width: 44px;
    min-height: 44px;
}

.btn-icon.btn-sm {
    min-width: 36px;
    min-height: 36px;
}

/* Remove hover-only interactions for touch */
@media (hover: none) and (pointer: coarse) {
    .stat-card:hover,
    .avg-card:hover,
    .vehicle-card:hover,
    .trip-item:hover,
    .card:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }

    /* Active states for touch feedback */
    .btn:active,
    .nav-item:active,
    .trip-item:active,
    .vehicle-card:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* ============================================
   Enhanced Mobile Sidebar (< 768px)
   ============================================ */

@media (max-width: 768px) {
    /* Sidebar als Drawer von links */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        max-width: 85vw;
        height: 100%;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Sidebar Overlay - halbtransparent */
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .sidebar-overlay.visible {
        opacity: 1;
        visibility: visible;
    }

    /* Main content nimmt volle Breite */
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }

    .sidebar.collapsed ~ .main-content {
        margin-left: 0 !important;
    }

    /* Mobile Menu Button sichtbar */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        -webkit-tap-highlight-color: transparent;
    }

    /* Sidebar Toggle ausblenden auf Mobile */
    .sidebar-toggle {
        display: none;
    }

    /* Page Content Padding reduzieren */
    .page-content {
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    /* Top Bar anpassen */
    .top-bar {
        padding: 0 12px;
        padding-top: env(safe-area-inset-top);
        height: calc(var(--header-height) + env(safe-area-inset-top));
    }

    /* Stat Cards: 1 pro Zeile auf kleinen Phones */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Reduced padding for cards on mobile */
    .stat-card,
    .avg-card,
    .porsche-sync-card,
    .progress-section,
    .cost-section,
    .chart-section,
    .vehicle-section {
        padding: 16px;
    }

    /* Smaller stat values on mobile */
    .stat-value {
        font-size: 24px;
    }

    .cost-value {
        font-size: 24px;
    }

    /* Avg section stacks */
    .avg-section {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Vehicle header stacks vertically */
    .vehicle-header {
        flex-direction: column;
        gap: 10px;
    }

    .vehicle-header select,
    .vehicle-header .btn {
        width: 100%;
    }

    /* Form rows stack on mobile */
    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Inputs volle Breite auf Mobile */
    .form-group input,
    .form-group select {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    /* Settings-Rows auf Mobile */
    .settings-row {
        padding: 8px 12px;
        min-height: 40px;
        gap: 8px;
    }

    .settings-row-label {
        font-size: 13px;
    }

    .settings-row-control {
        min-width: 80px;
        max-width: 120px;
        font-size: 12px;
    }

    .settings-input-narrow {
        max-width: 70px;
    }

    .settings-row-restore {
        flex-direction: column;
        align-items: stretch;
    }

    /* Settings-Card Forms kompakter */
    .settings-card-form {
        padding: 6px 12px 4px;
    }

    /* Trip items responsive */
    .trip-item {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 16px;
    }

    .trip-date {
        min-width: auto;
        flex: 0 0 auto;
    }

    .trip-km {
        min-width: auto;
        flex: 1;
    }

    .trip-delta {
        min-width: auto;
    }

    .trip-battery {
        min-width: auto;
        font-size: 12px;
    }

    .trip-note {
        flex: 1 1 100%;
        order: 5;
    }

    /* Filter Bar */
    .filter-bar {
        flex-direction: column;
    }

    .filter-select {
        width: 100%;
        min-width: unset;
    }

    /* Page Header */
    .page-header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .page-header-content .btn {
        width: 100%;
    }

    /* Vehicle cards: 1 per row on mobile */
    .vehicles-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .vehicle-card {
        padding: 16px;
    }

    /* Chart smaller height on mobile */
    .chart-container {
        height: 250px;
    }
}

/* ============================================
   Tablet Breakpoint (768px - 1024px)
   ============================================ */

@media (min-width: 768px) and (max-width: 1024px) {
    /* Stat Cards: 2 pro Zeile auf Tablet */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Avg section side by side */
    .avg-section {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Vehicle cards: 2 per row on tablet */
    .vehicles-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   Modal Mobile Optimierungen
   ============================================ */

@media (max-width: 768px) {
    .modal {
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
        align-items: flex-end;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: calc(100% - env(safe-area-inset-top) - 20px);
        margin: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
        animation: slideUpMobile 0.3s ease-out;
    }

    @keyframes slideUpMobile {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }

    .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .modal-actions-right {
        flex-direction: column;
        width: 100%;
        margin-left: 0;
    }

    .modal-actions-right .btn {
        width: 100%;
        justify-content: center;
    }

    /* Porsche Sync Card */
    .porsche-sync-header {
        flex-direction: column;
        gap: 12px;
    }

    .btn-sync {
        width: 100%;
        justify-content: center;
    }

    .sync-mileage {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .sync-mileage-value {
        font-size: 28px;
    }
}

/* ============================================
   Toast Container Mobile
   ============================================ */

@media (max-width: 768px) {
    .toast-container {
        top: calc(10px + env(safe-area-inset-top));
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .toast {
        width: 100%;
    }
}

/* ============================================
   Z-Index Hierarchy (rationalisiert)
   ============================================ */

.sidebar-overlay {
    z-index: 999;
}

.sidebar {
    z-index: 1000;
}

.modal {
    z-index: 1100;
}

.toast-container {
    z-index: 1200;
}

/* ============================================
   Prevent horizontal scroll globally
   ============================================ */

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

/* ============================================
   Fix table/grid overflow on mobile
   ============================================ */

.trips-list,
.stats-grid,
.source-distribution {
    max-width: 100%;
    overflow-x: hidden;
}

.vehicles-grid {
    max-width: 100%;
}

/* ============================================
   Loading & Empty States Mobile
   ============================================ */

@media (max-width: 768px) {
    .loading-state,
    .empty-state {
        padding: 40px 16px;
    }

    .empty-state-icon {
        font-size: 40px;
    }

    .empty-state h3 {
        font-size: 16px;
    }

    .empty-state p {
        font-size: 13px;
    }
}

/* ============================================
   Settings Modal Mobile
   ============================================ */

@media (max-width: 768px) {
    .settings-grid {
        max-width: 100%;
    }
    .settings-row {
        padding: 8px 12px;
        min-height: 40px;
    }

    .settings-actions {
        flex-direction: column;
    }

    .settings-actions .btn {
        width: 100%;
    }

    .porsche-vehicle-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .porsche-vehicle-item .btn {
        width: 100%;
    }
}

/* ============================================
   Landscape Mode Fixes
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        max-height: 95vh;
    }

    .sidebar {
        padding-top: 10px;
    }

    .sidebar-header {
        padding: 10px 16px;
    }

    .nav-item {
        padding: 8px 12px;
    }
}

/* ============================================
   Tire Management
   ============================================ */

.tire-section {
    margin-top: 8px;
}

.tire-sets-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tire-set-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.tire-set-item.active {
    border-color: var(--primary);
    background: rgba(0, 122, 255, 0.06);
}

.tire-set-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.tire-set-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.tire-set-notes {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.tire-stats-summary {
    margin-top: 8px;
}

/* ============================================
   Docs / Wiki / Architecture
   ============================================ */

/* Docs Layout – Card Design */
.docs-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 1100px;
    margin: 0 auto;
    min-width: 0;
}

.docs-sidebar {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px;
}

.docs-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.docs-nav-link {
    display: block;
    padding: 7px 14px;
    border-radius: 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

.docs-nav-link.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.docs-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 28px 32px;
    min-height: 200px;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.7;
    color: var(--text-primary);
}

.docs-content h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 16px 0;
    color: var(--text-primary);
}

.docs-content h2 {
    font-size: 19px;
    font-weight: 600;
    margin: 28px 0 10px 0;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

.docs-content h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 20px 0 6px 0;
    color: var(--text-primary);
}

.docs-content p {
    margin: 8px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.docs-content ul, .docs-content ol {
    margin: 8px 0;
    padding-left: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.docs-content li {
    margin: 3px 0;
}

.docs-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12.5px;
    font-family: 'SF Mono', Monaco, monospace;
}

.docs-content pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    overflow-x: auto;
    margin: 10px 0;
}

.docs-content pre code {
    background: none;
    padding: 0;
    font-size: 12.5px;
    line-height: 1.5;
}

.docs-content .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 10px 0;
}

.docs-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.docs-content th, .docs-content td {
    border: 1px solid var(--border-color);
    padding: 7px 10px;
    text-align: left;
}

.docs-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

.docs-content td {
    color: var(--text-secondary);
}

.docs-content a {
    color: var(--primary);
    text-decoration: none;
}

.docs-content a:hover {
    text-decoration: underline;
}

.docs-content strong {
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .docs-layout {
        max-width: 100%;
    }

    .docs-sidebar {
        padding: 4px;
    }

    .docs-nav-link {
        padding: 6px 10px;
        font-size: 12px;
    }

    .docs-content {
        padding: 16px;
        min-width: 0;
        box-sizing: border-box;
        overflow: hidden;
    }

    .docs-content .table-wrapper,
    .docs-content pre {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .docs-content h1 {
        font-size: 20px;
    }

    .docs-content h2 {
        font-size: 17px;
        margin: 20px 0 8px 0;
    }

    .docs-content h3 {
        font-size: 15px;
    }

    .docs-content pre {
        padding: 10px;
    }

    .docs-content pre code {
        font-size: 12px;
    }

    .docs-content table {
        font-size: 12px;
    }

    .docs-content th, .docs-content td {
        padding: 5px 7px;
    }
}

/* ============================================
   Workshop List
   ============================================ */

.workshop-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.workshop-item {
    padding: 16px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.workshop-item:hover {
    border-color: var(--border-color-strong);
    box-shadow: var(--shadow-sm);
}

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

.workshop-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.workshop-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
}

.workshop-item-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workshop-item-date {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.workshop-item-details {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.workshop-item-cost {
    font-weight: 600;
    color: var(--text-primary);
}

.workshop-item-notes {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workshop-summary {
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .workshop-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .workshop-item-details {
        gap: 8px;
    }
}
