:root {
    --bg-dark: #0a0c10;
    --bg-card: rgba(22, 27, 34, 0.75);
    --bg-input: #161b22;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --tesla-red: #ff3b30;
    --tesla-red-dark: #d52d24;
    --accent-blue: #2997ff;
    --success: #3fb950;
    --warning: #d29922;
    --radius: 16px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --glass-border: rgba(240, 246, 252, 0.1);
    --glass-highlight: rgba(255, 255, 255, 0.05);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 50% 0%, #1c2128 0%, transparent 70%),
        radial-gradient(circle at 80% 100%, rgba(41, 151, 255, 0.05) 0%, transparent 50%);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px;
    width: 100%;
}

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

.text-red {
    color: var(--tesla-red);
}

.text-blue {
    color: var(--accent-blue);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--tesla-red) 0%, var(--tesla-red-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 59, 48, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 59, 48, 0.4);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(5px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
}

/* Forms */
input,
select,
textarea {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 20px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: white;
    font-size: 1rem;
    transition: all 0.2s ease;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: #1c2128;
    box-shadow: 0 0 0 4px rgba(41, 151, 255, 0.15);
}

/* Flatpickr Customization */
.flatpickr-calendar.dark {
    background: var(--bg-card) !important;
    box-shadow: var(--shadow) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius) !important;
}

/* Login Page */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(255, 59, 48, 0.08) 0%, transparent 70%);
    top: -300px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 0;
    pointer-events: none;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 30px;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow);
    animation: modalSlideIn 0.3s ease;
}

.login-card {
    background: var(--bg-card);
    padding: 48px;
    border-radius: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
    z-index: 1;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.login-logo {
    text-align: center;
    margin-bottom: 40px;
    font-size: 2.2rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.login-logo span {
    color: var(--tesla-red);
}

/* Dashboard Layout */
.dashboard-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
}

.sidebar {
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(10px);
    padding: 30px 20px;
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 60px;
    padding-left: 15px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-logo span {
    color: var(--text-secondary);
    font-weight: 400;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: 0.2s ease;
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.nav-link.active {
    background: rgba(255, 59, 48, 0.1);
    color: var(--tesla-red);
    font-weight: 600;
}

.main-content {
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
    padding: 0;
    overflow-y: auto;
}

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

/* Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.card {
    background: var(--bg-card);
    padding: 28px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(12px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.15);
}

.card-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
    background: linear-gradient(180deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Table */
.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
}

.modern-table th {
    text-align: left;
    padding: 20px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--glass-border);
}

.modern-table td {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.95rem;
    vertical-align: middle;
}

.modern-table tr:last-child td {
    border-bottom: none;
}

.modern-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Battery Visualization */
.battery-container {
    background: #0d1117;
    padding: 24px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.battery-icon {
    width: 70px;
    height: 34px;
    border: 2px solid #30363d;
    border-radius: 8px;
    position: relative;
    display: flex;
    align-items: center;
    padding: 3px;
}

.battery-icon::after {
    content: '';
    position: absolute;
    right: -7px;
    top: 9px;
    width: 4px;
    height: 12px;
    background: #30363d;
    border-radius: 0 4px 4px 0;
}

.battery-level {
    height: 100%;
    background: linear-gradient(90deg, #2ea043 0%, #3fb950 100%);
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 10px rgba(63, 185, 80, 0.4);
}

.battery-text {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    font-variant-numeric: tabular-nums;
}

/* Modal */
.modal {
    backdrop-filter: blur(8px);
    transition: opacity 0.2s ease;
}

/* Headings */
h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0;
}

h2,
h3 {
    color: var(--text-primary);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #424a53;
}

.form-filter input {
    margin-bottom: 0 !important;
}

/* Upload Box Drag & Drop */
.upload-box {
    border: 2px dashed var(--glass-border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.02);
}

.upload-box:hover,
.upload-box.drag-over {
    border-color: var(--accent-blue);
    background: rgba(41, 151, 255, 0.1);
    transform: translateY(-2px);
}

.upload-box input[type="file"] {
    display: none;
}

.upload-label {
    display: block;
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.upload-preview {
    max-width: 100%;
    max-height: 120px;
    margin-top: 15px;
    border-radius: 8px;
    display: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Filter Pills */
.filter-pills {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-pill {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.filter-pill:hover,
.filter-pill.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

/* History Stats Row */
.history-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 25px;
    text-align: center;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 20px;
}

.stat-item-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.text-green {
    color: #34c759;
}

.text-orange {
    color: #ff9f0a;
}

.text-blue {
    color: #2997ff;
}

.text-red {
    color: #ff3b30;
}