:root {
    --bg: #f3f6fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d8dee9;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #15803d;
    --warning: #d97706;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at top left, #dbeafe 0, transparent 32rem), var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.login-page {
    background:
        linear-gradient(135deg, rgba(10, 31, 68, 0.50), rgba(124, 176, 235, 0.18)),
        url('login-dashboard-bg.png') center center / cover no-repeat fixed;
}

body.dashboard-page {
    background:
        radial-gradient(circle at 15% 10%, rgba(37, 99, 235, .20), transparent 26rem),
        radial-gradient(circle at 95% 0%, rgba(34, 211, 238, .18), transparent 28rem),
        linear-gradient(135deg, #eef6ff 0%, #f8fbff 48%, #edf7ff 100%);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 28px;
    min-height: 82px;
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(12px);
}

.login-page .topbar,
.dashboard-page .topbar {
    background: rgba(255, 255, 255, .72);
    border-bottom: 1px solid rgba(255, 255, 255, .48);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 245px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: #eff6ff;
    color: var(--primary);
    font-size: 26px;
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.nav a, .btn, button {
    border: 0;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    padding: 10px 14px;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.nav a {
    background: transparent;
    color: #26344f;
}

.nav a:hover {
    background: #eef4ff;
    color: var(--primary-dark);
}

.danger-link, .btn.danger, button.danger { color: white !important; background: var(--danger) !important; }

.user-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 245px;
}

.logout-link {
    border-radius: 999px;
    background: var(--danger);
    color: white;
    padding: 8px 12px;
    text-decoration: none;
    font-weight: 800;
    font-size: 14px;
    white-space: nowrap;
}

.logout-link:hover { filter: brightness(.96); }
.btn.secondary { background: #475569; }
.btn.light { background: #e5e7eb; color: #111827; }
.btn.success { background: var(--success); }
.btn.small { padding: 7px 10px; font-size: 13px; border-radius: 9px; }
.btn:hover, button:hover { filter: brightness(.96); }

.user-pill {
    background: #ecfdf5;
    color: #166534;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 800;
}

.container {
    width: min(1280px, calc(100% - 32px));
    margin: 28px auto 60px;
}

.login-page .container {
    margin-top: 12px;
    margin-bottom: 10px;
}

.page-head,
.section-head,
.dashboard-hero {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.dashboard-hero {
    background: rgba(255, 255, 255, 0.54);
    border: 1px solid rgba(255, 255, 255, 0.62);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(16px);
    border-radius: 26px;
    padding: 22px 24px;
}

.dashboard-hero p { margin: 0; color: #42526d; }

h1 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 42px); }
h2 { margin: 0 0 14px; }
h3 { margin: 0 0 10px; }
p { line-height: 1.55; }
.muted { color: var(--muted); }

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px;
}

.card,
.glass-card {
    background: var(--card);
    border: 1px solid rgba(216, 222, 233, .8);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.glass-card {
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.66);
    box-shadow: 0 24px 55px rgba(21, 67, 132, 0.12);
    backdrop-filter: blur(18px);
}

.login-page .card {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.42);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.13);
    backdrop-filter: blur(16px);
}

.card.span-12 { grid-column: span 12; }
.card.span-8 { grid-column: span 8; }
.card.span-6 { grid-column: span 6; }
.card.span-4 { grid-column: span 4; }
.card.span-3 { grid-column: span 3; }

.ev-dashboard-grid {
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    grid-template-areas:
        "cost power"
        "history trips";
    gap: 18px;
}

.ev-dashboard-grid .stat-card:nth-child(1) { grid-area: cost; }
.ev-dashboard-grid .stat-card:nth-child(2) { grid-area: power; }
.ev-dashboard-grid .history-card { grid-area: history; }
.ev-dashboard-grid .trips-card { grid-area: trips; }

.stat-card {
    min-height: 205px;
    position: relative;
    overflow: hidden;
}

.card-label {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #17365f;
    font-weight: 900;
    margin-bottom: 18px;
}

.dash-icon {
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(37, 99, 235, .10);
}

.big-number {
    font-size: clamp(30px, 4vw, 42px);
    font-weight: 900;
    letter-spacing: -1px;
    color: #10294b;
}

.subline {
    color: #607089;
    font-size: 14px;
}

.trend {
    display: inline-flex;
    align-items: center;
    margin-top: 18px;
    margin-right: 8px;
    padding: 7px 12px;
    border-radius: 12px;
    font-weight: 900;
    color: #075985;
    background: rgba(103, 232, 249, .42);
}

.trend.good { color: #0f766e; background: rgba(153, 246, 228, .55); }
.trend.bad { color: #b45309; background: rgba(254, 215, 170, .55); }
.trend.neutral { color: #1d4ed8; background: rgba(191, 219, 254, .65); }

.mini-bars {
    position: absolute;
    right: 28px;
    bottom: 30px;
    height: 115px;
    width: min(300px, 48%);
    display: flex;
    align-items: end;
    justify-content: flex-end;
    gap: 14px;
    opacity: .95;
}

.mini-bars span {
    width: 18px;
    border-radius: 10px 10px 3px 3px;
    background: linear-gradient(to top, #d7edf9, #b9daf0);
}
.mini-bars span:last-child {
    background: linear-gradient(to top, #1577ff, #7fc5ff);
}

.mini-line {
    position: absolute;
    right: 24px;
    bottom: 24px;
    width: 53%;
    height: 95px;
}
.mini-line path {
    fill: none;
    stroke: #1d7cff;
    stroke-width: 4;
}
.mini-line circle {
    fill: rgba(255,255,255,.9);
    stroke: #1d7cff;
    stroke-width: 4;
}

.map-line {
    position: absolute;
    right: 22px;
    bottom: 18px;
    width: 55%;
    height: 120px;
}
.map-line path {
    fill: none;
    stroke-linecap: round;
}
.map-line .map-bg {
    stroke: rgba(255,255,255,.72);
    stroke-width: 11;
}
.map-line .route {
    stroke: #1d7cff;
    stroke-width: 4;
}
.map-line circle {
    fill: #1d7cff;
    stroke: rgba(255,255,255,.88);
    stroke-width: 4;
}

.history-card { min-height: 205px; }

.history-list {
    display: grid;
    gap: 2px;
}

.history-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 18px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(100, 116, 139, .16);
}

.history-row strong {
    display: block;
    color: #143052;
}
.history-row small {
    display: block;
    color: #718096;
    margin-top: 3px;
}
.history-row span {
    color: #143052;
    font-weight: 800;
}

.history-card a {
    display: inline-flex;
    margin-top: 12px;
    color: #1d4ed8;
    text-decoration: none;
    font-weight: 800;
}

.bottom-metrics {
    margin: 18px 0 26px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.bottom-metrics > div {
    padding: 14px 18px;
    border-right: 1px solid rgba(100, 116, 139, .16);
}
.bottom-metrics > div:last-child { border-right: 0; }
.bottom-metrics strong {
    display: block;
    font-size: clamp(28px, 4vw, 40px);
    color: #15345d;
}
.bottom-metrics small {
    color: #6b7a91;
}

.vehicle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 18px;
}

.vehicle-card {
    overflow: hidden;
    padding: 0;
}

.vehicle-img {
    width: 100%;
    height: 190px;
    object-fit: cover;
    display: block;
    background: #e5e7eb;
}

.vehicle-body { padding: 18px; }
.vehicle-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-weight: 800;
    padding: 5px 9px;
    font-size: 12px;
    white-space: nowrap;
}
.badge.green { background: #ecfdf5; color: #166534; }
.badge.orange { background: #fff7ed; color: #9a3412; }
.badge.gray { background: #f1f5f9; color: #475569; }

.stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.stat {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 12px;
}

.stat small { color: var(--muted); display: block; margin-bottom: 4px; }
.stat strong { font-size: 20px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 14px;
}

.field { grid-column: span 6; }
.field.full { grid-column: span 12; }
.field.third { grid-column: span 4; }
.field.quarter { grid-column: span 3; }

label {
    display: block;
    font-weight: 800;
    margin-bottom: 7px;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: white;
    border-radius: 12px;
    padding: 11px 12px;
    font: inherit;
    color: var(--text);
}

textarea { min-height: 120px; resize: vertical; }
input[type="checkbox"] { width: auto; }

.table-wrap { overflow: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}

th {
    color: #334155;
    font-size: 14px;
}

td.actions, .actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.alert {
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 1px solid;
    font-weight: 700;
}
.alert.success { background: #ecfdf5; color: #166534; border-color: #bbf7d0; }
.alert.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.footer {
    padding: 18px 24px 28px;
    text-align: center;
    color: var(--muted);
}

.login-page .footer {
    padding: 8px 24px 10px;
    color: rgba(255, 255, 255, .86);
    text-shadow: 0 2px 10px rgba(0,0,0,.28);
}

.login-wrap {
    min-height: calc(100vh - 136px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: min(520px, 100%);
    padding: 24px;
}

.login-card h1 {
    font-size: clamp(30px, 4vw, 38px);
}

.login-card .actions {
    margin-top: 2px;
}

.kpi {
    display: grid;
    gap: 4px;
}
.kpi strong {
    font-size: clamp(24px, 4vw, 34px);
}
.small-muted { font-size: 13px; color: var(--muted); }

.empty-dashboard {
    margin-top: 18px;
}

@media (max-width: 1050px) {
    .ev-dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "cost"
            "power"
            "history"
            "trips";
    }
    .mini-bars, .mini-line, .map-line {
        opacity: .35;
    }
}

@media (max-width: 980px) {
    .card.span-8, .card.span-6, .card.span-4, .card.span-3 { grid-column: span 12; }
    .brand, .user-actions { min-width: auto; }
    .topbar {
        flex-wrap: wrap;
        justify-content: center;
    }
    .bottom-metrics { grid-template-columns: 1fr; }
    .bottom-metrics > div {
        border-right: 0;
        border-bottom: 1px solid rgba(100, 116, 139, .16);
    }
    .bottom-metrics > div:last-child { border-bottom: 0; }
}

@media (max-width: 720px) {
    .field, .field.third, .field.quarter { grid-column: span 12; }
    .container { width: min(100% - 18px, 1280px); }
    .page-head, .section-head, .dashboard-hero {
        flex-direction: column;
        align-items: stretch;
    }
    .vehicle-title-row {
        flex-direction: column;
    }
    .stats { grid-template-columns: 1fr; }
    .topbar { padding: 14px 16px; }
    .login-card { padding: 20px; }
    .history-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .mini-bars, .mini-line, .map-line { display: none; }
}
