:root {
    /* Tesla Modern Palette */
    --color-primary: #E82127;
    --color-primary-hover: #B41217;
    --color-primary-glow: rgba(232, 33, 39, 0.4);

    --color-bg-body: #050505;
    --color-bg-card: #141414;
    --color-bg-card-hover: #1f1f1f;
    --color-bg-input: #222222;

    --color-text-main: #FFFFFF;
    --color-text-muted: #999999;
    --color-text-accent: #E82127;

    --color-border: #333333;
    --text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);

    --color-success: #3E8E41;
    --color-warning: #FF9800;
    --color-danger: #E82127;
    --color-info: #2196F3;

    /* Metrics */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Gotham SSm', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--color-bg-body);
    color: var(--color-text-main);
    line-height: 1.5;
    font-size: 16px;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

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

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s;
}

/* Layout Utilities */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-sm);
}

/* Background Animation */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
    animation: drift 20s infinite alternate ease-in-out;
}

.orb-1 {
    width: 60vw;
    height: 60vw;
    background: var(--color-primary);
    top: -20%;
    left: -10%;
    animation-delay: 0s;
}

.orb-2 {
    width: 50vw;
    height: 50vw;
    background: #4a4a4a;
    bottom: -20%;
    right: -10%;
    animation-delay: -5s;
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(30px, -30px) scale(1.1);
    }
}

/* Login Page Styling */
.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: var(--spacing-sm);
}

.welcome-card {
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.welcome-logo {
    color: var(--color-primary);
    margin-bottom: var(--spacing-md);
}

.welcome-title {
    font-size: 1.75rem;
    margin-bottom: var(--spacing-xs);
}

.welcome-subtitle {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin-bottom: var(--spacing-lg);
}

/* Form Elements */
.login-steps {
    text-align: left;
    margin-top: 1rem;
}

.instruction-box {
    background: var(--color-bg-input);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    font-size: 0.9rem;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.instruction-box ol {
    margin-left: 1.2rem;
    margin-top: 0.5rem;
}

.instruction-box li {
    margin-bottom: 0.4rem;
}

.input-field {
    width: 100%;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    color: var(--color-text-main);
    font-family: monospace;
    font-size: 0.9rem;
    margin-bottom: var(--spacing-md);
    transition: all 0.2s;
    outline: none;
    resize: none;
    min-height: 100px;
}

.input-field:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-glow);
}

/* Buttons */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background-color: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--color-primary-glow);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-main);
    margin-bottom: var(--spacing-sm);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--color-text-muted);
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    text-decoration: underline;
    margin-top: var(--spacing-sm);
}

/* Dashboard Header */
.header {
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-logo {
    color: var(--color-primary);
    font-size: 1.5rem;
}

/* Vehicle List Grid */
.vehicles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-md);
    padding: var(--spacing-lg) 0;
}

.vehicle-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.vehicle-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    background: var(--color-bg-card-hover);
}

.vehicle-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-sm);
}

.vehicle-name {
    font-size: 1.4rem;
    font-weight: 700;
}

.vehicle-vin {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-family: monospace;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-online {
    background: rgba(62, 142, 65, 0.2);
    color: #4CAF50;
}

.status-offline {
    background: rgba(153, 153, 153, 0.2);
    color: #999;
}

.status-asleep {
    background: rgba(33, 150, 243, 0.2);
    color: #2196F3;
}

/* Dashboard / Telemetry Specifics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    text-align: center;
}

.stat-label {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text-main);
}

.stat-unit {
    font-size: 0.8em;
    color: var(--color-text-muted);
    font-weight: 400;
}

.chart-container {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    position: relative;
    height: 300px;
}

/* Modal for Charts */
.modal-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-sm);
}

.modal-content {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 1000px;
    height: 80vh;
    padding: var(--spacing-md);
    position: relative;
    display: flex;
    flex-direction: column;
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--color-text-main);
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
}

.fullscreen-chart-container {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
}

/* Loading & Toast */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: rotation 0.8s linear infinite;
}

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

/* Responsive Adjustments */
@media (max-width: 768px) {
    :root {
        --spacing-md: 1rem;
        --spacing-lg: 1.5rem;
    }

    .welcome-card {
        padding: var(--spacing-md);
        max-width: 100%;
    }

    .welcome-title {
        font-size: 1.5rem;
    }

    .header-title {
        font-size: 1.1rem;
    }

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

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

    .stat-value {
        font-size: 1.5rem;
    }

    .chart-container {
        height: 250px;
        padding: 0.5rem;
    }

    .header-content {
        padding: 0 1rem;
    }
}