/* Car interface (/car): dark, mobile-first. Independent of the logger's app.css. */

:root {
    color-scheme: dark;

    --bg: #07090d;
    --bg-raised: #0e1219;
    --card: #121822;
    --card-hover: #171f2c;
    --border: #1f2836;
    --border-strong: #2b3648;

    --text: #e8edf4;
    --text-muted: #8a96a8;
    --text-faint: #5d687a;

    --accent: #4f8cff;
    --accent-strong: #3b76ec;
    --charge: #34d399;
    --climate: #38bdf8;
    --heat: #fb923c;
    --sleep: #8b5cf6;
    --warn: #f59e0b;
    --danger: #f43f5e;

    --radius: 20px;
    --radius-sm: 12px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100dvh;
    background:
        radial-gradient(1200px 500px at 50% -200px, rgba(79, 140, 255, 0.12), transparent 70%),
        var(--bg);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }
.muted { color: var(--text-muted); }
.hint { color: var(--text-muted); font-size: 0.85rem; margin: 0.75rem 0 0; }

/* ---------- App shell ---------- */

/* A phone-width column, wider in landscape on tablets and phones turned
   sideways so the screen isn't mostly empty. */
.car-app {
    max-width: 560px;
    margin: 0 auto;
    padding:
        calc(env(safe-area-inset-top, 0px) + 0.5rem)
        calc(env(safe-area-inset-right, 0px) + 1rem)
        calc(env(safe-area-inset-bottom, 0px) + 2rem)
        calc(env(safe-area-inset-left, 0px) + 1rem);
}
@media (orientation: landscape) and (min-width: 700px) {
    .car-app { max-width: 1100px; }
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 56px;
    margin: 0 -1rem 0.75rem;
    padding: calc(env(safe-area-inset-top, 0px)) 1rem 0;
    background: linear-gradient(to bottom, rgba(7, 9, 13, 0.95) 70%, rgba(7, 9, 13, 0));
    backdrop-filter: blur(8px);
}

.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.topbar-heading { font-size: 1.25rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: 0.8rem; color: var(--text-muted); }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.icon-btn:hover { background: var(--card-hover); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:disabled { opacity: 0.6; cursor: default; }
.icon-btn.spinning .icon { animation: spin 0.9s linear infinite; }
/* Keep screen on: the app's orange highlight while active. */
.icon-btn.active { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }

.car-switch { position: relative; display: inline-flex; align-items: center; max-width: 100%; }
.car-switch select {
    appearance: none;
    -webkit-appearance: none;
    max-width: 100%;
    padding: 0.35rem 2rem 0.35rem 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 1.25rem;
    font-weight: 650;
    cursor: pointer;
    text-overflow: ellipsis;
}
.car-switch select:focus-visible { outline: 2px solid var(--accent); border-radius: 8px; }
.car-switch option { background: var(--bg-raised); color: var(--text); }
.car-switch-chevron { position: absolute; right: 0.2rem; pointer-events: none; color: var(--text-muted); }

/* ---------- Status hero ---------- */

.hero {
    --tone: var(--accent);
    position: relative;
    overflow: hidden;
    padding: 1.1rem 1.2rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background:
        /* Sized to the tile, so a wide one (landscape) is shaded right across. */
        radial-gradient(110% 100% at 100% 0%, color-mix(in srgb, var(--tone) 26%, transparent), transparent 70%),
        linear-gradient(160deg, var(--card), var(--bg-raised));
    box-shadow: var(--shadow);
}
.hero.tone-sleep { --tone: var(--sleep); }
.hero.tone-charge { --tone: var(--charge); }
.hero.tone-drive { --tone: var(--accent); }
.hero.tone-plugged { --tone: #22d3ee; }
.hero.tone-awake { --tone: #60a5fa; }
.hero.tone-idle { --tone: #64748b; }

.hero-top { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.state-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.8rem 0.35rem 0.6rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--tone);
    background: color-mix(in srgb, var(--tone) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--tone) 35%, transparent);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
}
.chip-climate { color: var(--climate); border-color: color-mix(in srgb, var(--climate) 35%, transparent); }
.chip-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.chip-odometer { margin-left: auto; font-variant-numeric: tabular-nums; }

.hero-main { display: flex; align-items: flex-end; gap: 1rem; margin: 0.9rem 0 0.8rem; }
.soc { display: flex; align-items: baseline; line-height: 1; }
.soc-value { font-size: 4.2rem; font-weight: 700; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.soc-unit { font-size: 1.6rem; font-weight: 600; color: var(--text-muted); margin-left: 0.15rem; }
.soc-empty { color: var(--text-faint); }
.hero-range { display: flex; flex-direction: column; padding-bottom: 0.45rem; min-width: 0; }
.range-value { font-size: 1.15rem; font-weight: 600; }
.hero-detail { font-size: 0.9rem; color: var(--text-muted); }

.battery-bar {
    position: relative;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    overflow: visible;
}
.battery-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, color-mix(in srgb, var(--tone) 70%, #fff 0%), var(--tone));
    transition: width 0.6s ease;
}
.battery-limit {
    position: absolute;
    top: -3px;
    width: 2px;
    height: 14px;
    border-radius: 1px;
    background: var(--text-muted);
    transform: translateX(-1px);
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.85rem;
    font-size: 0.82rem;
    color: var(--text-faint);
}
.hero-meta .icon { width: 1em; height: 1em; }

/* ---------- Tiles ---------- */

.tiles {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 0.75rem;
}
/* Two tiles across from small-tablet width; three on wide landscape screens,
   where the page is allowed to widen (below). */
@media (min-width: 440px) {
    .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
    .tiles { grid-template-columns: repeat(3, 1fr); }
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    min-height: 150px;
    padding: 1rem 1.05rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.tile:hover { background: var(--card-hover); border-color: var(--border-strong); }
.tile:active { transform: scale(0.985); }
.tile-active { border-color: color-mix(in srgb, var(--climate) 45%, transparent); }

.tile-head { display: flex; align-items: center; gap: 0.55rem; }
.tile-icon {
    display: inline-grid;
    place-items: center;
    width: 34px; height: 34px;
    border-radius: 10px;
    color: var(--climate);
    background: color-mix(in srgb, var(--climate) 14%, transparent);
}
.tile-title { font-weight: 600; flex: 1; }
.tile-state { font-size: 0.82rem; color: var(--text-muted); }
.tile-active .tile-state { color: var(--climate); }
.tile-chevron { color: var(--text-faint); }

.tile-temps { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.tile-temps > div { display: flex; flex-direction: column; }
/* Charging tile: energy and cost since the last reset. */
.tile-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.6rem; padding-top: 0.55rem; border-top: 1px solid var(--border); }
.tile-totals > div { display: flex; flex-direction: column; }
.tile-totals.three { grid-template-columns: repeat(3, 1fr); }
.totals-kwh.charging-cost { color: var(--charge); }
.totals-kwh { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.totals-kwh small { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); }
.totals-cost { font-size: 0.85rem; color: var(--charge); font-variant-numeric: tabular-nums; }
.totals-since { font-size: 0.72rem; color: var(--text-faint); margin-top: 0.25rem; }
.tile-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.tile-value { font-size: 1.9rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.tile-foot { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: var(--text-muted); margin-top: auto; }

/* ---------- Cards (detail pages) ---------- */

.card {
    padding: 1rem 1.1rem;
    margin-bottom: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
}
.card-title { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 0.8rem; }
.label { display: block; font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.climate-now {
    background:
        radial-gradient(380px 180px at 100% 0%, rgba(56, 189, 248, 0.10), transparent 70%),
        var(--card);
}
.climate-now.is-on { border-color: color-mix(in srgb, var(--climate) 40%, transparent); }
/* Get ready to drive: warm border while preconditioning; the flame in the
   heat colour while the battery heater runs. */
.get-ready.is-on { border-color: color-mix(in srgb, var(--heat) 40%, transparent); }
.get-ready .battery-note { margin-top: 0.4rem; }
.battery-note.heating { color: var(--text); }
.battery-note.heating .icon { color: var(--heat); }
.climate-now-main { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.climate-now-side { text-align: right; }
.big-temp { font-size: 3.4rem; font-weight: 700; letter-spacing: -0.04em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.mid-temp { font-size: 1.8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.climate-now-status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; margin-top: 0.75rem; font-size: 0.88rem; }
.battery-note { display: flex; align-items: flex-start; gap: 0.45rem; margin-top: 0.8rem; font-size: 0.85rem; color: var(--text-muted); }
.battery-note .icon { margin-top: 0.1rem; }
.battery-note-sub { display: block; font-size: 0.78rem; color: var(--text-faint); margin-top: 0.1rem; }

.stepper { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.stepper-value { font-size: 3rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.stepper-value .unit { font-size: 1.2rem; color: var(--text-muted); margin-left: 0.2rem; font-weight: 600; }

.round-btn {
    display: grid;
    place-items: center;
    width: 60px; height: 60px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--bg-raised);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.round-btn .icon { width: 1.5rem; height: 1.5rem; }
.round-btn:hover { background: var(--card-hover); }
.round-btn:active { transform: scale(0.92); }
.round-btn:disabled { opacity: 0.35; cursor: default; }

.seat-row { display: grid; gap: 0.5rem; padding: 0.35rem 0; }
.seat-row + .seat-row { border-top: 1px solid var(--border); padding-top: 0.75rem; margin-top: 0.4rem; }
.seat-name { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 550; }

.segmented {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 3px;
    border-radius: 14px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
}
.segmented button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    min-height: 40px;
    padding: 0 0.4rem;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.segmented button.selected { background: color-mix(in srgb, var(--heat) 22%, var(--card)); color: var(--heat); font-weight: 600; }
.segmented button.level-2.selected { background: color-mix(in srgb, var(--heat) 32%, var(--card)); }
.segmented button.level-3.selected { background: color-mix(in srgb, var(--heat) 44%, var(--card)); color: #ffe4cc; }
.segmented button:first-child.selected { background: var(--card-hover); color: var(--text); }
.segmented button:disabled { cursor: default; }

/* ---------- Buttons, banners, toasts ---------- */

.actions { display: grid; gap: 0.6rem; margin: 1rem 0; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.75rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 50px;
    padding: 0 1.2rem;
    border-radius: 14px;
    border: 1px solid var(--border-strong);
    background: var(--card);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, opacity 0.15s;
}
.btn:hover { background: var(--card-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn-primary { border-color: transparent; background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 8%, var(--card)); }
.btn-large { min-height: 58px; font-size: 1.05rem; }

.banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.8rem;
    padding: 0.65rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}
.banner-warn { color: #fcd34d; background: rgba(245, 158, 11, 0.10); border: 1px solid rgba(245, 158, 11, 0.25); }
.banner-info { color: #c4b5fd; background: rgba(139, 92, 246, 0.10); border: 1px solid rgba(139, 92, 246, 0.25); }
.banner-error { color: #fda4af; background: rgba(244, 63, 94, 0.10); border: 1px solid rgba(244, 63, 94, 0.3); }

.confirm { border-color: rgba(139, 92, 246, 0.35); }
.confirm p { margin: 0; display: flex; gap: 0.5rem; align-items: flex-start; }

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
    transform: translateX(-50%);
    width: min(520px, calc(100% - 2rem));
    padding: 0.8rem 1rem;
    border-radius: 14px;
    background: #1b2433;
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow);
    font-size: 0.92rem;
    animation: toast-in 0.25s ease;
}
.toast-ok { border-color: color-mix(in srgb, var(--charge) 40%, transparent); }
.toast-error { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }

/* ---------- Loading, empty, errors ---------- */

.skeleton {
    min-height: 220px;
    background: linear-gradient(90deg, var(--card) 0%, var(--card-hover) 50%, var(--card) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
}
.tile.skeleton { min-height: 150px; }
.card.skeleton.tall { min-height: 420px; }

.loading { display: grid; place-items: center; min-height: 60dvh; }
.spinner {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 3px solid var(--border-strong);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

.empty { text-align: center; padding: 4rem 1rem; display: grid; gap: 0.8rem; justify-items: center; }
.empty p { color: var(--text-muted); margin: 0; max-width: 32ch; }
.empty-icon { width: 3rem; height: 3rem; color: var(--text-faint); }

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 1rem; right: 1rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
    z-index: 1000;
    padding: 0.8rem 1rem;
    border-radius: 14px;
    background: #3b1320;
    color: #fecdd3;
    box-shadow: var(--shadow);
}
#blazor-error-ui .reload { text-decoration: underline; margin-left: 0.5rem; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ---------- Sign in ---------- */

.login { display: grid; place-items: center; min-height: 90dvh; }
.login-card {
    width: 100%;
    max-width: 380px;
    padding: 2rem 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
    box-shadow: var(--shadow);
    text-align: center;
}
.login-logo {
    display: inline-grid;
    place-items: center;
    width: 64px; height: 64px;
    margin-bottom: 0.8rem;
    border-radius: 18px;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.login-logo .icon { width: 2rem; height: 2rem; }
.login-card h1 { font-size: 1.5rem; }
.login-card p { color: var(--text-muted); margin: 0.3rem 0 1.4rem; }
.login-card form { display: grid; gap: 0.8rem; text-align: left; }
.login-card label { font-size: 0.85rem; color: var(--text-muted); }
.login-card input {
    width: 100%;
    min-height: 50px;
    padding: 0 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: var(--bg-raised);
    color: var(--text);
    font: inherit;
    font-size: 16px; /* 16px stops iOS zooming into the field */
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Motion ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.spin-slow { animation: spin 2.5s linear infinite; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Seat heating: other seats ---------- */

.expand-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 44px;
    margin-top: 0.6rem;
    padding: 0 0.2rem;
    border: 0;
    border-top: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
}
.expand-btn > span:first-child { font-weight: 550; color: var(--text); }
.expand-summary { flex: 1; color: var(--heat); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expand-btn .icon { margin-left: auto; transition: transform 0.2s; }
.expand-btn .icon.flip { transform: rotate(180deg); }

/* ---------- Scheduled departure ---------- */

.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.2rem; }
.card-head .chip { white-space: nowrap; }
.card-head .card-title { margin-bottom: 0; }
.hint.first { margin-top: 0.5rem; }

.field { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.field > span { font-weight: 550; }

.time-input {
    min-height: 48px;
    padding: 0 0.8rem;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: var(--bg-raised);
    color: var(--text);
    font: inherit;
    font-size: 1.35rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    color-scheme: dark;
}
.time-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 52px;
    border-top: 1px solid var(--border);
    margin-top: 0.8rem;
    padding-top: 0.2rem;
    cursor: pointer;
}
.switch-row + .switch-row { margin-top: 0; }
.switch-row > span { font-weight: 550; }
.switch-row.dimmed > span { color: var(--text-faint); }

.switch {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    flex: none;
    width: 52px;
    height: 32px;
    margin: 0;
    border-radius: 999px;
    background: var(--border-strong);
    cursor: pointer;
    transition: background 0.2s;
}
.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.45; cursor: default; }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.save-departure { width: 100%; margin-top: 1rem; }
.departure .confirm { margin: 1rem 0 0; }

/* ---------- Charging ---------- */

.tile-icon.charge { color: var(--charge); background: color-mix(in srgb, var(--charge) 14%, transparent); }
.tile-charge { border-color: color-mix(in srgb, var(--charge) 45%, transparent); }
.tile-charge .tile-state { color: var(--charge); }
.tile-value small { font-size: 0.95rem; font-weight: 600; color: var(--text-muted); margin-left: 0.1rem; }

.chip-charge { color: var(--charge); border-color: color-mix(in srgb, var(--charge) 40%, transparent); }

.charge-now {
    background:
        radial-gradient(380px 180px at 100% 0%, rgba(52, 211, 153, 0.08), transparent 70%),
        var(--card);
}
.charge-now.is-charging { border-color: color-mix(in srgb, var(--charge) 40%, transparent); }
.charge-now-top { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; font-size: 0.88rem; }

.charge-soc { display: flex; align-items: baseline; margin: 0.8rem 0 0.6rem; line-height: 1; }
.charge-target { display: inline-flex; align-items: center; gap: 0.2rem; margin-left: 0.8rem; font-size: 1.3rem; font-weight: 600; color: var(--text-muted); }
.charge-target .icon { width: 1rem; height: 1rem; }
.charge-bar { --tone: var(--charge); }
.charge-range { margin-top: 0.5rem; font-size: 0.85rem; }

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem 1rem;
    margin-top: 1rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border);
}
.stat-grid > div { display: flex; flex-direction: column; min-width: 0; }
.stat { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat.small { font-size: 1rem; }

.card-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.small { font-size: 0.82rem; }
.hint.center { text-align: center; }
.btn.full { width: 100%; margin-top: 0.9rem; }
.btn-charge { background: #10b981; }
.btn-charge:hover { background: #059669; }

.slider {
    width: 100%;
    margin: 1rem 0 0.4rem;
    accent-color: var(--charge);
    height: 32px;
    cursor: pointer;
}
.slider:disabled { opacity: 0.5; cursor: default; }

.presets { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.preset {
    flex: 1;
    min-width: 52px;
    min-height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-raised);
    color: var(--text-muted);
    font-size: 0.88rem;
    cursor: pointer;
}
.preset.selected { color: var(--charge); border-color: color-mix(in srgb, var(--charge) 45%, transparent); background: color-mix(in srgb, var(--charge) 10%, var(--card)); font-weight: 600; }
.preset:disabled { cursor: default; }

/* ---------- Drives ---------- */

.tile-icon.drive { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.tile-drive { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.tile-drive .tile-state { color: var(--accent); }

.week-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.week-summary > div { display: flex; flex-direction: column; }

.day-heading {
    margin: 1.2rem 0.2rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.drive-list {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
    overflow: hidden;
}
.drive-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-height: 64px;
    padding: 0.7rem 1rem;
    transition: background 0.15s;
}
.drive-row + .drive-row { border-top: 1px solid var(--border); }
.drive-row:hover { background: var(--card-hover); }
.drive-row.in-progress { box-shadow: inset 3px 0 0 var(--accent); }
/* Found by the odometer only: lighter, so tracked drives stand out. */
.drive-row.untracked .drive-distance { color: var(--text-muted); }
.drive-row.untracked .drive-time { opacity: 0.7; }
.drive-time { display: flex; flex-direction: column; width: 3.2rem; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.drive-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.drive-distance { font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.map-card {
    position: relative;
    margin-bottom: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    background: var(--bg-raised);
}
.drive-map { height: min(52vh, 380px); width: 100%; background: #0d1117; }
/* Standard OSM tiles turned dark: invert, then rotate hues back so water stays blue. */
.drive-map .drive-map-tiles { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.85) saturate(0.6); }
.map-overlay { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-muted); font-size: 0.9rem; }
.drive-map .leaflet-control-attribution { background: rgba(7, 9, 13, 0.7); color: var(--text-faint); font-size: 10px; }
.drive-map .leaflet-control-attribution a { color: var(--text-muted); }

.drive-headline { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.drive-times { margin: 0.3rem 0 0; font-variant-numeric: tabular-nums; }

/* ---------- Battery health ---------- */

.tile-icon.health { color: var(--charge); background: color-mix(in srgb, var(--charge) 14%, transparent); }

.health-hero {
    background:
        radial-gradient(380px 180px at 100% 0%, rgba(52, 211, 153, 0.08), transparent 70%),
        var(--card);
}
.health-main { display: flex; align-items: baseline; margin: 0.6rem 0 0.8rem; line-height: 1; }
.health-pm { margin-left: 0.6rem; color: var(--text-muted); font-size: 1rem; font-variant-numeric: tabular-nums; }
.health-meter {
    height: 8px;
    border-radius: 999px;
    /* Unfilled track: a darker step of the fill's own hue. */
    background: color-mix(in srgb, var(--charge) 16%, var(--bg-raised));
    overflow: hidden;
}
.health-meter-fill { height: 100%; border-radius: 999px; background: var(--charge); }
.health-line { margin: 0.7rem 0 0; }
.health-empty { text-align: center; padding: 1rem 0.5rem; }
.health-empty h1 { font-size: 1.25rem; margin: 0.6rem 0 0.4rem; }
.health-empty p { margin: 0; }

.trend-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 0.9rem; }
.trend-row:empty { display: none; }
.trend-row > div { display: flex; flex-direction: column; }

.chart { position: relative; margin-top: 0.6rem; touch-action: pan-y; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-tick { fill: var(--text-faint); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: var(--accent); opacity: 0.1; }
.chart-dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.chart-crosshair { stroke: var(--text-faint); stroke-width: 1; }
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-end-label {
    position: absolute;
    margin-left: 10px;
    transform: translateY(-50%);
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}
.chart-tooltip {
    position: absolute;
    top: 0;
    transform: translateX(10px);
    padding: 0.45rem 0.6rem;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--bg-raised);
    box-shadow: var(--shadow);
    white-space: nowrap;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}
.chart-tooltip.left { transform: translateX(calc(-100% - 10px)); }
.chart-tooltip-row { display: flex; align-items: center; gap: 0.4rem; }
.chart-key { width: 12px; height: 2px; border-radius: 1px; background: var(--accent); }

.data-table { width: 100%; border-collapse: collapse; margin-top: 0.4rem; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.data-table th { text-align: left; font-weight: 550; color: var(--text-muted); padding: 0.4rem 0.3rem; border-bottom: 1px solid var(--border); }
.data-table td { padding: 0.4rem 0.3rem; border-bottom: 1px solid var(--border); }
.data-table th:not(:first-child), .data-table td:not(:first-child) { text-align: right; }

.measure-list { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.measure-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0;
    border-top: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}
.measure-list li:first-child { border-top: 0; }
.measure-list li > div { display: flex; flex-direction: column; min-width: 0; }

.input-unit { display: inline-flex; align-items: center; gap: 0.5rem; }
.number-input { width: 6.5rem; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Sign out ---------- */

.signout { display: flex; justify-content: center; margin-top: 1.5rem; }
.btn-link {
    min-height: 44px;
    padding: 0 1rem;
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
}
.btn-link:hover { color: var(--text); }

/* ---------- Charging history ---------- */

.drive-row.charging { box-shadow: inset 3px 0 0 var(--charge); }
.drive-list + .signout, .actions + .drive-list { margin-top: 0.75rem; }
.drive-times + .charge-bar { margin: 0.9rem 0 0.2rem; }
.charge-span { position: absolute; top: 0; height: 100%; border-radius: 999px; background: var(--charge); }
.charge-map { height: 200px; }
.measure-list li { padding: 0; }
.measure-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    padding: 0.6rem 0;
}
.measure-link > div { display: flex; flex-direction: column; min-width: 0; }

/* ---------- Quick actions ---------- */

.quick-actions {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.4rem;
    margin-top: 0.75rem;
}
.quick-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    min-width: 0;
    min-height: 88px;
    padding: 0.6rem 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.quick-btn:hover { background: var(--card-hover); }
.quick-btn:active { transform: scale(0.97); }
.quick-btn:disabled { cursor: default; opacity: 0.7; }
.quick-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}
/* Five across on a phone: labels may wrap to two lines rather than being cut. */
.quick-label { font-size: 0.8rem; font-weight: 600; line-height: 1.15; text-align: center; max-width: 100%; overflow-wrap: anywhere; }
.quick-state { font-size: 0.7rem; color: var(--text-muted); line-height: 1.15; text-align: center; max-width: 100%; }
.quick-btn.attention .quick-icon { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.quick-btn.confirming { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.quick-btn.confirming .quick-state { color: var(--text); }
.small-spinner { width: 18px; height: 18px; border-width: 2px; }
.quick-actions + .confirm { margin-top: 0.75rem; }

/* Hero range: the car's figure, then the estimate from past drives. */
.range-row { display: flex; align-items: baseline; gap: 0.4rem; white-space: nowrap; }
.range-label { font-size: 0.75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.range-row.mine .range-value { color: var(--accent); }
.range-row.mine { margin-top: 0.1rem; }

/* Cabin overheat protection has three settings, not four levels. */
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented.two { grid-template-columns: repeat(2, 1fr); }

/* ---------- Footer: version and sign out ---------- */

.app-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    margin-top: 1.5rem;
}
.app-footer .signout { margin-top: 0; }
.version-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 40px;
    padding: 0 1rem;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--text-faint);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.version-btn:hover { color: var(--text-muted); }
.version-btn.update {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    font-weight: 600;
}
.version-btn .icon { width: 1em; height: 1em; }

/* Drives list: selecting drives to add up their distance. */
.drives-toolbar { display: flex; justify-content: flex-end; margin: 0.6rem 0.2rem -0.6rem; }
.day-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.day-heading .day-select { font-size: 0.8rem; text-transform: none; letter-spacing: 0; }
.day-heading .day-km { text-transform: none; letter-spacing: 0; font-weight: 500; font-variant-numeric: tabular-nums; }
button.drive-row {
    width: 100%;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.select-mark {
    display: grid;
    place-items: center;
    flex: none;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    color: transparent;
}
.select-mark .icon { width: 0.95rem; height: 0.95rem; }
.drive-row.selected { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.drive-row.selected .select-mark { background: var(--accent); border-color: var(--accent); color: #fff; }
.selection-spacer { height: 5.5rem; }
.selection-bar {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
    transform: translateX(-50%);
    width: min(520px, calc(100% - 2rem));
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.7rem 0.8rem 0.7rem 1rem;
    border-radius: 16px;
    background: #1b2433;
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow);
    z-index: 10;
}
.selection-bar > .muted { flex: 1; font-size: 0.9rem; }
.selection-total { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.selection-km { font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Notifications page: each event's explanation under its name. */
.notify-row > span { display: flex; flex-direction: column; gap: 0.15rem; }
.notify-row .hint { font-weight: 400; margin: 0; }
.app-footer > a.btn-link { display: inline-flex; align-items: center; gap: 0.35rem; }

/* Preconditioning schedules (climate page, firmware 2024.26+). */
.schedule-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0; border-top: 1px solid var(--border); }
.schedule-row:first-of-type { border-top: 0; }
.schedule-row.off .schedule-time, .schedule-row.off .schedule-days { color: var(--text-faint); }
.schedule-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.schedule-time { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.schedule-days { font-size: 0.82rem; color: var(--text-muted); }
.schedule-toggle { cursor: pointer; }
.btn-link.danger { color: var(--danger); }
.schedule-editor { margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--border); }
.day-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.3rem; margin: 0.7rem 0; }
.day-picker .day {
    min-height: 40px; border-radius: 50%; aspect-ratio: 1; border: 1px solid var(--border-strong);
    background: var(--bg-raised); color: var(--text-muted); font: inherit; font-weight: 600; cursor: pointer;
}
.day-picker .day.selected { background: color-mix(in srgb, var(--accent) 22%, var(--card)); border-color: var(--accent); color: var(--text); }
.schedule-skeleton { height: 56px; border-radius: var(--radius-sm); margin: 0.4rem 0; }

/* Charge history: totals since the last reset, and each charge's cost. */
.totals-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 1rem; margin: 0.4rem 0 0.6rem; }
.totals-grid > div { display: flex; flex-direction: column; }
.charge-cost { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; font-size: 0.9rem; font-weight: 600; color: var(--charge); font-variant-numeric: tabular-nums; white-space: nowrap; }
.charge-cost small { font-size: 0.72rem; font-weight: 500; color: var(--text-muted); }

/* Drives: what the driving would have cost in a petrol car. */
.petrol-note { grid-column: 1 / -1; margin: 0.2rem 0 0; font-size: 0.85rem; color: var(--text-muted); }
.petrol-note strong { color: var(--text); }

/* Trip meters: dashboard tiles and the trip page. */
.tile-icon.trip { color: var(--accent); }
.trip-tile .trip-figures { margin-top: 0.2rem; padding-top: 0; border-top: 0; }
.trip-tile .trip-charges { margin-top: 0.5rem; }
.totals-small { font-size: 0.8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.new-trip { margin-top: 0.75rem; }
.trip-saving { margin: 0.2rem 0 0; font-size: 0.9rem; color: var(--text-muted); }
.trip-saving strong { color: var(--charge); }
.trip-line { display: grid; grid-template-columns: 1fr auto auto; gap: 0.8rem; padding: 0.45rem 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.trip-line:first-of-type { border-top: 0; }

/* Current drive: under the status tile, beside it in landscape. */
.hero-row { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (orientation: landscape) and (min-width: 700px) {
    .hero-row.driving { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
}
.cd-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin: 0.8rem 0 0.4rem; }
.cd-grid > div { display: flex; flex-direction: column; }
.cd-value { font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.cd-value small { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); }
.cd-block { margin-top: 0.7rem; padding-top: 0.55rem; border-top: 1px solid var(--border); }
.cd-row { display: grid; grid-template-columns: 1.1fr 1fr 1.2fr; gap: 0.5rem; padding: 0.2rem 0; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.cd-row.four { grid-template-columns: 1.1fr 0.9fr 0.8fr 1.1fr; }
.cd-row.cd-actual { border-top: 1px dashed var(--border); margin-top: 0.15rem; padding-top: 0.3rem; font-weight: 600; }
.cd-row.cd-head { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.cd-closer { color: var(--charge); font-weight: 600; }
.cd-note { margin: 0.35rem 0 0; font-size: 0.75rem; color: var(--text-faint); }
.cd-route { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.35rem; font-weight: 600; }
.cd-route .muted { font-weight: 400; margin-left: auto; }
.drive-edit { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }
.drive-edit-problem { margin-top: 0.6rem; }
/* Battery page: a charge left out of the measurements. */
.measure-list li.excluded strong { text-decoration: line-through; color: var(--text-muted); }
.toggle-row { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; cursor: pointer; }
.toggle-row input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
/* Current drive: the distance to the destination typed in. */
.cd-route-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.75rem; }
.cd-route-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--text-muted); }
.cd-route-form input { width: 100%; padding: 0.45rem 0.55rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-raised); color: var(--text); font-size: 1rem; }
.cd-route-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.cd-block > .btn { margin-top: 0.5rem; }
.error-text { color: #fda4af; }
