/* ============================================================
   Teslita · v2 design system
   Inspired by iOS Settings + macOS Ventura Sonoma
   ============================================================ */

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

:root {
    /* ---- Canvas & surfaces ---------------------------------- */
    --bg-canvas:     #ffffff;            /* main content area — pure white */
    --bg-surface:    #ffffff;
    --bg-surface-2:  #f7f7fa;
    --bg-hover:      rgba(60, 60, 67, 0.06);
    --bg-pressed:    rgba(60, 60, 67, 0.10);
    --bg-sidebar:    rgba(242, 242, 247, 0.85); /* sidebar slightly grey, offset against white content */

    /* ---- Borders / hairlines -------------------------------- */
    --hairline:       rgba(60, 60, 67, 0.12);
    --hairline-light: rgba(60, 60, 67, 0.06);
    --hairline-strong:rgba(60, 60, 67, 0.22);

    /* ---- Text --------------------------------------------------- */
    --text-primary:   #1d1d1f;
    --text-secondary: #48484a;
    --text-muted:     #8e8e93;
    --text-tertiary:  #a1a1a6;
    --text-on-accent: #ffffff;

    /* ---- System colors (iOS) ---------------------------------- */
    --sys-blue:     #0a84ff;
    --sys-indigo:   #5856d6;
    --sys-purple:   #bf5af2;
    --sys-pink:     #ff375f;
    --sys-red:      #ff453a;
    --sys-orange:   #ff9f0a;
    --sys-yellow:   #ffd60a;
    --sys-green:    #30d158;
    --sys-teal:     #40c8e0;
    --sys-gray:     #8e8e93;

    --accent:         var(--sys-blue);
    --accent-hover:   #409cff;
    --accent-active:  #0071e3;
    --accent-subtle:  rgba(10, 132, 255, 0.12);
    --accent-ring:    rgba(10, 132, 255, 0.28);

    /* Semantic soft backgrounds ------------------------------- */
    --green:      #2ca64d;
    --green-bg:   rgba(48, 209, 88, 0.16);
    --yellow:     #b08407;
    --yellow-bg:  rgba(255, 214, 10, 0.20);
    --red:        #e53935;
    --red-bg:     rgba(255, 69, 58, 0.12);
    --purple:     var(--sys-purple);
    --purple-bg:  rgba(191, 90, 242, 0.14);

    /* ---- Radii ------------------------------------------------ */
    --r-xs: 6px;
    --r-sm: 8px;
    --r:    12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-2xl:28px;
    --r-pill: 999px;

    /* ---- Shadows --------------------------------------------- */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04),
                 0 2px 6px rgba(16, 24, 40, 0.05);
    --shadow:    0 1px 3px rgba(16, 24, 40, 0.05),
                 0 10px 30px -12px rgba(16, 24, 40, 0.14);
    --shadow-lg: 0 6px 14px -4px rgba(16, 24, 40, 0.10),
                 0 24px 60px -20px rgba(16, 24, 40, 0.24);
    --shadow-pop:0 14px 40px -12px rgba(16, 24, 40, 0.25),
                 0 4px 12px -4px rgba(16, 24, 40, 0.10);

    /* ---- Motion ---------------------------------------------- */
    --ease:     cubic-bezier(0.25, 0.8, 0.25, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --dur-fast: 120ms;
    --dur:      220ms;
    --dur-slow: 360ms;

    /* ---- Legacy aliases (keep JS/CSS refs working) ---------- */
    --bg-primary:   var(--bg-canvas);
    --bg-secondary: var(--bg-surface);
    --bg-tertiary:  var(--bg-surface);
    --bg-surface:   var(--bg-surface);
    --border:       var(--hairline);
    --border-light: var(--hairline-light);
    --radius:       var(--r);
    --radius-lg:    var(--r-lg);
}

/* ============================================================
   Base
   ============================================================ */
html { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
                 "Inter", "Helvetica Neue", "Segoe UI", Roboto, system-ui, sans-serif;
    background: var(--bg-canvas);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    letter-spacing: -0.005em;
}

a { color: var(--accent); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--accent-hover); text-decoration: none; }

::selection { background: var(--accent-subtle); color: var(--text-primary); }

/* Slim macOS-style scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.18) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: var(--r-pill);
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.32); background-clip: padding-box; border: 2px solid transparent; }

button { font: inherit; color: inherit; }

/* ============================================================
   App Layout — sidebar + content
   ============================================================ */
body.app-layout {
    display: flex;
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
    padding: 0;
    margin: 0;
    background:
        radial-gradient(1100px 650px at 0% 0%,   rgba(10, 132, 255, 0.07), transparent 55%),
        radial-gradient(900px  650px at 100% 20%, rgba(191, 90, 242, 0.06), transparent 55%),
        radial-gradient(1100px 700px at 50% 115%, rgba(48, 209, 88, 0.06),  transparent 60%),
        var(--bg-canvas);
}

/* ============================================================
   Sidebar — unified, iOS Settings aesthetic
   The .rail class is kept for legacy JS hooks (mobile toggle).
   ============================================================ */
.sidebar {
    width: 264px;
    min-width: 264px;
    max-width: 264px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-sidebar);
    backdrop-filter: saturate(180%) blur(28px);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
    border-right: 1px solid var(--hairline-light);
    z-index: 300;
    flex-shrink: 0;
    padding: 14px 10px 12px;
}

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 18px;
}
.sidebar-logo {
    width: 28px;
    height: 28px;
    display: block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.10));
}
.sidebar-brand {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

/* ============================================================
   Sidebar car picker — scoped dropdown between brand + nav
   ============================================================ */
.sidebar-carpicker {
    padding: 2px 4px 14px;
}
.sidebar-carpicker-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding: 0 8px 6px;
}
.carpicker-shell {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r);
    box-shadow: var(--shadow-xs);
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.carpicker-shell:hover { border-color: var(--hairline-strong); }
.carpicker-shell:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}
.carpicker-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: 8px;
    border-radius: 6px;
    color: #fff;
    background: linear-gradient(160deg, #d78cff 0%, #bf5af2 60%, #a244e0 100%);
    flex-shrink: 0;
}
/* When the currently-selected car is archived, desaturate the icon so the
   user notices they're browsing historical data. */
.sidebar-carpicker.is-archived .carpicker-icon {
    background: linear-gradient(160deg, #b8b8bd 0%, #8e8e93 60%, #6e6e73 100%);
}
.sidebar-carpicker.is-archived .carpicker-select {
    color: var(--text-secondary);
}
.carpicker-select {
    flex: 1;
    min-width: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: transparent;
    border: none;
    outline: none;
    padding: 9px 28px 9px 10px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    cursor: pointer;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.carpicker-chevron {
    position: absolute;
    right: 9px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
    display: inline-flex;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 2px;
}

.nav-section-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding: 14px 10px 6px;
}
.nav-section-label:first-child { padding-top: 4px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 7px 10px;
    border: none;
    background: transparent;
    border-radius: var(--r-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.005em;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background var(--dur-fast) var(--ease),
                transform var(--dur-fast) var(--ease);
    position: relative;
    user-select: none;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item:active { background: var(--bg-pressed); transform: scale(0.995); }
.nav-item.active {
    background: var(--bg-surface);
    box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--hairline-light);
    font-weight: 600;
}
.nav-item.active .nav-label { color: var(--text-primary); }

.nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Colored icon tile — the signature iOS Settings move */
.nav-tile {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10),
                inset 0 0 0 0.5px rgba(255, 255, 255, 0.18),
                inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition: transform var(--dur-fast) var(--ease);
}
.nav-item:hover .nav-tile { transform: scale(1.04); }

.tile-blue    { background: linear-gradient(160deg, #4aa8ff 0%, #0a84ff 65%, #006edc 100%); }
.tile-orange  { background: linear-gradient(160deg, #ffb75d 0%, #ff9f0a 60%, #f57a00 100%); }
.tile-green   { background: linear-gradient(160deg, #5fe07b 0%, #30d158 60%, #1d9a3c 100%); }
.tile-purple  { background: linear-gradient(160deg, #d78cff 0%, #bf5af2 60%, #a244e0 100%); }
.tile-gray    { background: linear-gradient(160deg, #b5b5ba 0%, #8e8e93 60%, #6e6e73 100%); }
.tile-pink    { background: linear-gradient(160deg, #ff7a8c 0%, #ff375f 60%, #d81c3f 100%); }
.tile-red     { background: linear-gradient(160deg, #ff756d 0%, #ff453a 60%, #d72b22 100%); }
.tile-teal    { background: linear-gradient(160deg, #79d8ea 0%, #40c8e0 60%, #21a5bd 100%); }
.tile-indigo  { background: linear-gradient(160deg, #8a88e6 0%, #5856d6 60%, #3633b8 100%); }
.tile-neutral { background: linear-gradient(160deg, #d9d9de 0%, #b4b4b9 60%, #9a9aa0 100%); color: #4a4a4f; }

/* Sidebar footer: language row + user row */
.sidebar-foot {
    padding: 8px 2px 0;
    border-top: 1px solid var(--hairline-light);
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.nav-item-ghost { font-weight: 500; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    background: var(--bg-surface);
    box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--hairline-light);
    margin-top: 4px;
}
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a84ff 0%, #6a5cff 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(10, 132, 255, 0.30),
                inset 0 0 0 1px rgba(255, 255, 255, 0.15);
    letter-spacing: -0.01em;
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.005em;
}
.icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ============================================================
   Content area
   ============================================================ */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    background: transparent;
}

.mobile-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--hairline-light);
    position: sticky;
    top: 0;
    z-index: 50;
}
.mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--r-sm);
}
.mobile-menu-btn:hover { background: var(--bg-hover); }
.mobile-title {
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.015em;
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 36px 44px 56px;
    max-width: 1120px;
    width: 100%;
    margin: 0 auto;
}

.content-section {
    display: none;
    animation: sectionIn var(--dur-slow) var(--ease-out);
}
.content-section.active { display: block; }

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

/* ============================================================
   Page header — large title, iOS-style
   ============================================================ */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-header-main { flex: 1 1 auto; min-width: 0; }

.page-title {
    font-size: clamp(1.75rem, 2.6vw, 2.35rem);
    font-weight: 700;
    letter-spacing: -0.028em;
    color: var(--text-primary);
    line-height: 1.1;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 6px;
    font-weight: 500;
    letter-spacing: -0.005em;
}

/* Car filter — compact, tucked in the header */
.car-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}
.car-filter label { color: var(--text-muted); }
.car-filter select {
    border: 1px solid var(--hairline);
    border-radius: var(--r-sm);
    padding: 7px 12px;
    font-size: 13px;
    background: var(--bg-surface);
    color: var(--text-primary);
    max-width: 220px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.car-filter select:hover { border-color: var(--hairline-strong); }
.car-filter select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--hairline-light);
    border-radius: var(--r-lg);
    padding: 22px 24px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--dur) var(--ease);
}

.card-flush { padding: 8px; }
.card-flush .data-table th { background: transparent; }
.card-flush .data-table th:first-child { padding-left: 18px; }
.card-flush .data-table td:first-child { padding-left: 18px; }
.card-flush .data-table th:last-child  { padding-right: 18px; }
.card-flush .data-table td:last-child  { padding-right: 18px; }

.card-spot {
    background:
        radial-gradient(900px 300px at 0% 0%, rgba(10, 132, 255, 0.08), transparent 55%),
        var(--bg-surface);
    border-color: rgba(10, 132, 255, 0.18);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px;
    letter-spacing: -0.015em;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.card-header-row .card-title { margin-bottom: 0; }

/* ============================================================
   Hero Live-Status card
   ============================================================ */
.hero-card {
    position: relative;
    background:
        radial-gradient(1000px 400px at -10% -20%, rgba(10, 132, 255, 0.10), transparent 55%),
        radial-gradient(800px 400px at 120% 120%, rgba(48, 209, 88, 0.08),  transparent 55%),
        #ffffff;
    border: 1px solid var(--hairline-light);
    border-radius: var(--r-xl);
    padding: 26px 28px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
#live-map-bg {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 55%;
    background-size: cover;
    background-position: center;
    opacity: 0.18;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, rgba(0,0,0,0.3) 30%, rgba(0,0,0,1) 70%);
    mask-image: linear-gradient(to right, transparent 0%, rgba(0,0,0,0.3) 30%, rgba(0,0,0,1) 70%);
    transition: opacity 0.6s ease;
}
.hero-card::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.hero-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.hero-card-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.hero-card-timestamp {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sys-green);
    box-shadow: 0 0 0 4px rgba(48, 209, 88, 0.18);
    animation: liveDot 1.8s ease-in-out infinite;
}
@keyframes liveDot {
    0%, 100% { box-shadow: 0 0 0 0  rgba(48, 209, 88, 0.35); }
    50%      { box-shadow: 0 0 0 6px rgba(48, 209, 88, 0.00); }
}

/* ============================================================
   Stats grid
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--hairline-light);
    border-radius: var(--r-lg);
    padding: 20px 22px 22px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur) var(--ease),
                box-shadow var(--dur) var(--ease);
    overflow: hidden;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12),
                inset 0 0 0 0.5px rgba(255, 255, 255, 0.2);
    margin-bottom: 14px;
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.028em;
    line-height: 1.05;
}

/* ============================================================
   Segmented control (settings tabs)
   ============================================================ */
.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: rgba(118, 118, 128, 0.12);
    border-radius: var(--r);
    margin-bottom: 18px;
    flex-wrap: wrap;
    max-width: 100%;
}
.segmented .segment {
    padding: 7px 16px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: calc(var(--r) - 3px);
    transition: background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
    letter-spacing: -0.005em;
    white-space: nowrap;
}
.segmented .segment:hover { color: var(--text-primary); }
.segmented .segment.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08),
                0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

/* ============================================================
   Onboarding checklist
   ============================================================ */
.onboarding-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.onboarding-list .ob-step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--hairline-light);
}
.onboarding-list .ob-step:last-child { border-bottom: none; padding-bottom: 4px; }

.onboarding-list .ob-num,
.onboarding-list .ob-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}
.onboarding-list .ob-num {
    background: var(--bg-surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--hairline);
}
.onboarding-list .ob-check {
    background: var(--sys-green);
    color: #fff;
    box-shadow: 0 2px 8px rgba(48, 209, 88, 0.40);
}
.onboarding-list .ob-label {
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}
.onboarding-list .ob-done .ob-label {
    color: var(--text-muted);
    text-decoration: line-through;
}
.onboarding-list .ob-active .ob-num {
    background: var(--accent);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 10px var(--accent-ring);
}

/* ============================================================
   Tesla connection
   ============================================================ */
.tesla-status {
    text-align: center;
    padding: 28px 20px;
}
.tesla-status .connected { color: var(--green); font-weight: 600; }
.tesla-status .disconnected { color: var(--red); font-weight: 500; }

/* ============================================================
   Monthly bar chart
   ============================================================ */
.monthly-bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 210px;
    padding-top: 12px;
}
.monthly-bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}
.monthly-bar-group-clickable {
    cursor: pointer;
    border-radius: 4px;
    outline: none;
}
.monthly-bar-group-clickable:hover .monthly-bar { filter: brightness(1.05); }
.monthly-bar-group-clickable:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.monthly-bar {
    width: 100%;
    max-width: 46px;
    background: linear-gradient(180deg, #4aa8ff 0%, #0a84ff 100%);
    border-radius: 8px 8px 3px 3px;
    min-height: 4px;
    transition: filter var(--dur) var(--ease),
                transform var(--dur-fast) var(--ease),
                height var(--dur-slow) var(--ease-out);
    box-shadow: 0 2px 10px -2px rgba(10, 132, 255, 0.40);
}
.monthly-bar:hover { transform: translateY(-2px); filter: brightness(1.08); }
.monthly-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    font-weight: 500;
}
.monthly-value {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 600;
}

/* ============================================================
   Stat-card splits — small chips under the headline number
   ============================================================ */
.stat-split {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-secondary);
}
.split-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(120, 120, 128, 0.06);
    padding: 3px 8px;
    border-radius: 999px;
    line-height: 1.4;
    white-space: nowrap;
}
.split-label { color: var(--text-muted); font-weight: 500; }
.split-value { font-weight: 600; color: var(--text-primary, #1d1d1f); }
.split-empty { color: var(--text-muted); font-size: 11px; }

/* Type-color dots used in chips and headers. The dots sit on a colored
   background via .seg-* below, so they only need the geometry here. */
.split-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 8px;
    display: inline-block;
}

/* Color tokens shared by chart segments, chips, legend swatches, and the
   inline bars in cost-insights / top-locations. */
.seg-home,
.split-chip-home .split-dot,
.legend-swatch.seg-home {
    background: linear-gradient(180deg, #34c759 0%, #2ca64d 100%);
}
.seg-supercharger,
.split-chip-supercharger .split-dot,
.legend-swatch.seg-supercharger {
    background: linear-gradient(180deg, #ff6b6b 0%, #e53935 100%);
}
.seg-other,
.split-chip-other .split-dot,
.legend-swatch.seg-other {
    background: linear-gradient(180deg, #ffb547 0%, #ff9500 100%);
}

.stat-unit {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 2px;
}

/* ============================================================
   Stacked monthly chart
   ============================================================ */
.monthly-bar-stacked {
    /* Override the solid blue gradient inherited from .monthly-bar. The
       child segments paint their own colors. */
    background: transparent;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column-reverse;   /* stack from bottom up: home → SC → other */
    border-radius: 8px 8px 3px 3px;
}
.monthly-bar-stacked:hover { transform: translateY(-2px); filter: brightness(1.05); }
.monthly-seg {
    width: 100%;
    transition: height var(--dur-slow) var(--ease-out);
}
/* No per-segment rounding — the parent bar has overflow:hidden plus a
   border-radius, which clips the top + bottom of the stack to a clean
   shape. Rounding individual segments here would expose transparent
   gaps at the boundary between two adjacent colors. */

/* Card-title row that hosts the segmented metric toggle on the right. */
.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.card-title-row .card-title { margin-bottom: 0; }

/* Standalone period-filter row that lives directly under the Live Status
   hero card. Right-aligned so it visually anchors to the page edge. */
.period-filter-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

/* Segmented toggle (Energy / Cost). Mirrors the iOS-style segmented
   control used elsewhere in the app. */
.seg-toggle {
    display: inline-flex;
    background: rgba(120, 120, 128, 0.10);
    padding: 2px;
    border-radius: 8px;
}
.seg-btn {
    background: transparent;
    border: none;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg-btn:hover { color: var(--text-primary, #1d1d1f); }
.seg-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10);
}
.seg-btn.active:hover { color: #fff; }

.chart-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-secondary);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

/* ============================================================
   Overview extras — two-column row (cost insights, top locations)
   ============================================================ */
.overview-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 22px;
}
@media (max-width: 760px) {
    .overview-2col { grid-template-columns: 1fr; }
}

.card-sub {
    margin-top: -6px;
    margin-bottom: 14px;
    color: var(--text-muted);
    font-size: 12.5px;
    line-height: 1.45;
}

.empty-state-sm {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 22px 0;
    margin: 0;
}

/* Cost-insights rows (one per type). Track + fill bar with metric on the
   right and a sub-line beneath. */
.ci-row { margin-bottom: 14px; }
.ci-row:last-child { margin-bottom: 0; }
.ci-row-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
    font-size: 13px;
    gap: 12px;
}
.ci-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-weight: 600;
}
.ci-value { font-weight: 700; color: var(--text-primary, #1d1d1f); white-space: nowrap; }
.ci-unit  { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.ci-bar-track {
    background: rgba(120, 120, 128, 0.10);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
}
.ci-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width var(--dur-slow) var(--ease-out);
}
.ci-row-foot {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 11.5px;
}
.ci-savings {
    margin-top: 14px;
    padding: 10px 12px;
    background: rgba(52, 199, 89, 0.08);
    border-radius: 8px;
    color: #1f7a35;
    font-size: 12.5px;
    line-height: 1.45;
}

/* Top charging locations — same row pattern as cost-insights. */
.loc-row { margin-bottom: 14px; }
.loc-row:last-child { margin-bottom: 0; }
.loc-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
    font-size: 13px;
    gap: 12px;
}
.loc-name {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.loc-count {
    font-weight: 700;
    color: var(--text-primary, #1d1d1f);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.loc-bar-track {
    background: rgba(120, 120, 128, 0.10);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
}
.loc-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width var(--dur-slow) var(--ease-out);
}
.loc-foot {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 11.5px;
}

/* ============================================================
   Driving overview — 4-tile grid inside the card
   ============================================================ */
.driving-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}
.driving-tile {
    background: rgba(120, 120, 128, 0.05);
    border-radius: var(--r-md, 10px);
    padding: 14px 16px;
}
.driving-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.driving-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #1d1d1f);
    line-height: 1.1;
}
.driving-sub {
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--text-muted);
}

/* Form hint (used for the home-kWh-price field) */
.form-hint {
    display: block;
    margin-top: 5px;
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ============================================================
   Forms
   ============================================================ */
.form-row { display: flex; gap: 1rem; }

.form-group {
    flex: 1;
    margin-bottom: 1.1rem;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 7px;
    color: var(--text-secondary);
    letter-spacing: -0.005em;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--hairline);
    border-radius: var(--r-sm);
    font-size: 14px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: inherit;
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: var(--hairline-strong);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}
.form-group input::placeholder { color: var(--text-muted); opacity: 0.7; }

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

/* ============================================================
   Buttons (pill-shaped, with subtle inner highlight)
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: -0.005em;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease),
                transform var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
    text-align: center;
    user-select: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

.btn-primary {
    background: var(--accent);
    color: var(--text-on-accent);
    box-shadow: 0 1px 2px rgba(10, 132, 255, 0.25),
                inset 0 0 0 1px rgba(255, 255, 255, 0.16),
                inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 14px rgba(10, 132, 255, 0.32),
                inset 0 0 0 1px rgba(255, 255, 255, 0.18),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-primary:active { background: var(--accent-active); }

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--hairline);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--hairline-strong);
}

.btn-danger {
    background: var(--sys-red);
    color: #fff;
    box-shadow: 0 1px 2px rgba(255, 69, 58, 0.26);
}
.btn-danger:hover { filter: brightness(1.06); box-shadow: 0 4px 14px rgba(255, 69, 58, 0.32); }

.btn-tesla {
    background: #1d1d1f;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.20);
}
.btn-tesla:hover { background: #2b2b2e; }

.btn-warning {
    background: var(--sys-yellow);
    color: #3b2a00;
    font-weight: 600;
}
.btn-warning:hover { filter: brightness(1.04); }

.btn-sm { padding: 6px 13px; font-size: 12px; }
.btn-lg { padding: 12px 26px; font-size: 15px; }
.btn-full { width: 100%; }

/* ============================================================
   Tables
   ============================================================ */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--r);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 13px 14px;
    border-bottom: 1px solid var(--hairline-light);
}
.data-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--bg-surface-2);
    position: sticky;
    top: 0;
    z-index: 1;
}
.data-table td {
    font-size: 13.5px;
    color: var(--text-primary);
}
.data-table tbody tr { transition: background var(--dur-fast) var(--ease); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Currency-converted cost cells. Asterisk is a hint that the value
 * shown was converted from the invoice currency; the title attribute
 * carries the original amount + ECB rate + effective date. */
.cost-converted { cursor: help; }
.cost-asterisk {
    color: var(--accent, #0a8ad0);
    font-weight: 600;
    margin-left: 1px;
}
.cost-conv-failed {
    color: var(--text-muted, #888);
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    cursor: help;
}

/* Footnote below the charging table listing the FX rates that were
 * applied. Mirrors the PDF report's notes section. */
.conversions-note {
    margin: 12px 4px 0;
    padding: 10px 14px;
    background: var(--bg-surface-2, #f7f7f9);
    border: 1px solid var(--hairline-light, #ececf0);
    border-left: 3px solid var(--accent, #0a8ad0);
    border-radius: var(--r, 6px);
    font-size: 12.5px;
    color: var(--text-muted, #555);
    line-height: 1.5;
}
.conversions-note p { margin: 0 0 4px; }
.conversions-note ul { margin: 4px 0 0 18px; padding: 0; }
.conversions-note li { margin: 1px 0; }
.conversions-note .conv-failed { margin-top: 6px; color: #b8721a; }

/* Expandable charging */
.charging-table { min-width: 500px; }
.charge-row { cursor: pointer; }
.charge-row.expanded { background: var(--bg-hover); }
.charge-detail td {
    padding: 0 14px 14px;
    border-bottom: 1px solid var(--hairline-light);
    background: transparent;
}
.charge-detail:hover { background: transparent !important; }
.detail-content {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 12px;
    padding: 14px 16px;
    background: var(--bg-surface-2);
    border: 1px solid var(--hairline-light);
    border-radius: var(--r);
}
.detail-items { display: flex; flex-wrap: wrap; gap: 20px; }
.detail-item { font-size: 12.5px; color: var(--text-secondary); }
.detail-item strong { color: var(--text-primary); font-weight: 600; }
.detail-actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   Trips table — Apple-list redesign
   Each row is a rich "journey card" with a colored calendar tile
   as the leading visual anchor and a hero distance number. The
   <thead> is hidden visually (but kept for a11y); column headers
   are boring and absent from every native iOS list.
   ============================================================ */
.trips-table { min-width: 520px; border-collapse: separate; border-spacing: 0; }
.trips-table thead { clip: rect(0 0 0 0); clip-path: inset(50%); height: 1px; width: 1px; overflow: hidden; position: absolute; white-space: nowrap; }
.trips-table th,
.trips-table td {
    padding: 16px 18px;
    vertical-align: middle;
    border-bottom: 1px solid var(--hairline-light);
    background-clip: padding-box;
}
.trips-table tbody tr:last-child td { border-bottom: none; }

/* Date cell: iOS-Calendar-style tile + time/year meta */
.trips-table .cell-date {
    white-space: nowrap;
    width: 1%; /* shrink-to-fit so distance can breathe */
}
.trip-date-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}
.trip-cal-tile {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.10),
        0 4px 12px rgba(0, 0, 0, 0.06),
        inset 0 0 0 0.5px rgba(255, 255, 255, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
    transition: transform var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.trip-row:hover .trip-cal-tile { transform: scale(1.04); }
.trip-cal-month {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.92;
    margin-bottom: 1px;
}
.trip-cal-day {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.trip-cal-tile-live .trip-cal-pulse {
    position: absolute;
    inset: -2px;
    border-radius: 12px;
    border: 2px solid var(--sys-green);
    animation: tripCalPulse 1.8s ease-out infinite;
    pointer-events: none;
}
@keyframes tripCalPulse {
    0%   { opacity: 0.9; transform: scale(1); }
    70%  { opacity: 0;   transform: scale(1.22); }
    100% { opacity: 0;   transform: scale(1.22); }
}
.trip-date-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}
.trip-date-time {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}
.trip-date-year {
    font-size: 11.5px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Route cell — start/end with an accented arrow between */
.trips-table .cell-route {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.4;
    max-width: 380px;
}
.trip-route-place {
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.trip-route-end { color: var(--text-primary); }
.trip-route-arrow {
    display: inline-block;
    margin: 0 8px;
    color: var(--accent);
    font-weight: 700;
    font-size: 14px;
    transform: translateY(-0.5px);
}

/* Odometer cell — compact primary/secondary stack */
.trips-table .cell-odo {
    white-space: nowrap;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}
.trip-odo-primary {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13.5px;
}
.trip-odo-from {
    display: block;
    font-size: 11.5px;
    color: var(--text-muted);
}
.trip-odo-from::before {
    content: "\2190 ";
    color: var(--text-tertiary);
}

/* Distance cell — the hero number. Big bold tabular digits,
   unit sits quietly alongside. */
.trips-table .cell-distance {
    white-space: nowrap;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}
.trip-dist-value {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    line-height: 1;
}
.trip-dist-unit {
    margin-left: 3px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: lowercase;
    letter-spacing: 0.01em;
}

.trips-table .cell-type {
    white-space: nowrap;
    text-align: right;
}

/* Rows feel like cards with a subtle hover lift */
.trip-row { cursor: pointer; transition: background var(--dur-fast) var(--ease); }
.trip-row:hover { background: var(--bg-hover); }
.trip-row.expanded { background: var(--bg-hover); }
/* Expanded detail panel — iOS-Settings grouped-list treatment.
   The outer grid is a soft grey "background canvas"; each column
   is a white card with a section header above an inset list of
   label/value rows divided by hairlines. */
.trip-detail td {
    padding: 0 14px 18px;
    border-bottom: 1px solid var(--hairline-light);
    background: transparent;
}
.trip-detail:hover { background: transparent !important; }
.trip-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 4px 2px 6px;
    background: transparent;
}
@media (max-width: 700px) { .trip-detail-grid { grid-template-columns: 1fr; } }

.trip-detail-section {
    /* Soft subtly-tinted card — blue radial wash in top-left
       corner adds the Apple "dimensional" feel without going dark. */
    background:
        radial-gradient(520px 180px at 0% 0%, rgba(10, 132, 255, 0.045), transparent 60%),
        #ffffff;
    border-radius: 14px;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.03),
        0 10px 30px rgba(16, 24, 40, 0.06),
        inset 0 0 0 1px var(--hairline-light);
    display: flex;
    flex-direction: column;
}
.trip-detail-section h4 {
    margin: 0;
    padding: 14px 18px 10px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
}
.trip-detail-list { display: flex; flex-direction: column; }

/* Colored leading icon tile — the "iOS Settings" signature. Each row's
   label gets a small 24x24 gradient tile with a white glyph, which
   is the single biggest lever for making a dense list feel vibrant. */
.meta-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.10),
        inset 0 0 0 0.5px rgba(255, 255, 255, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.meta-icon svg { width: 14px; height: 14px; display: block; }

.meta-label-text {
    color: var(--text-primary);
    font-weight: 500;
    letter-spacing: -0.005em;
}

.trip-meta-row {
    display: grid;
    grid-template-columns: minmax(120px, auto) 1fr;
    gap: 14px;
    padding: 11px 18px;
    font-size: 14px;
    align-items: center;
    border-top: 1px solid var(--hairline-light);
    line-height: 1.4;
}
.trip-meta-row:first-child { border-top: none; }
.trip-meta-row .meta-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 500;
    letter-spacing: -0.005em;
}
.trip-meta-row .meta-value {
    color: var(--text-primary);
    text-align: right;
    word-break: break-word;
    letter-spacing: -0.005em;
    font-weight: 500;
}
.trip-meta-row .meta-value em {
    font-style: normal;
    color: var(--text-muted);
    font-size: 12px;
    margin-left: 4px;
    font-weight: 400;
}
.trip-meta-row .coords {
    display: block;
    margin-top: 3px;
    font-size: 11.5px;
    color: var(--text-muted);
    font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
    letter-spacing: 0;
    font-weight: 400;
}

/* Edit form rows — match the grouped-list rhythm */
.trip-edit-row {
    display: grid;
    grid-template-columns: minmax(140px, auto) 1fr;
    gap: 14px;
    padding: 10px 18px;
    align-items: center;
    border-top: 1px solid var(--hairline-light);
}
.trip-edit-row:first-child { border-top: none; }
.trip-edit-row label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
    letter-spacing: -0.005em;
}
.trip-edit-row select,
.trip-edit-row input {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--hairline);
    border-radius: 8px;
    background: var(--bg-surface-2);
    font-family: inherit;
    color: var(--text-primary);
    box-sizing: border-box;
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease),
                background var(--dur-fast) var(--ease);
}
.trip-edit-row select:focus,
.trip-edit-row input:focus {
    border-color: var(--accent);
    background: var(--bg-surface);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Tax-compliance guidance hint */
.trip-tax-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 14px 4px;
    padding: 10px 12px;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--text-muted);
    background: rgba(10, 132, 255, 0.05);
    border-radius: var(--r-md);
    border-left: 3px solid rgba(10, 132, 255, 0.3);
}
.trip-tax-hint svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: rgba(10, 132, 255, 0.5);
}

/* Edit-history link + modal table */
.trip-edit-history-btn {
    display: block;
    margin: 0;
    padding: 8px 18px 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    text-align: right;
    width: 100%;
    transition: color var(--dur-fast) var(--ease);
}
.trip-edit-history-btn:hover {
    color: var(--accent);
}

/* Trips export actions */
.trips-export-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.trips-date-range {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.trips-date-range .input-sm {
    height: 30px;
    padding: 2px 8px;
    border: 1px solid var(--hairline);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-primary);
    background: var(--bg-surface);
    outline: none;
    font-family: inherit;
}
.trips-date-range .input-sm:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(10,132,255,0.15);
}
.date-range-sep {
    color: var(--text-muted);
    font-size: 13px;
    padding: 0 2px;
}
.modal-md { max-width: 740px; }
@media (min-width: 1200px) { .modal-md { max-width: 880px; } }

#edit-history-modal {
    background: rgba(20, 20, 22, 0.55);
}
#edit-history-modal .modal {
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#edit-history-modal .modal-header {
    flex-shrink: 0;
}
#edit-history-modal .modal-body {
    padding: 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.edit-history-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
    table-layout: fixed;
}
.edit-history-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 16px;
    border-bottom: 2px solid var(--hairline-light);
    white-space: nowrap;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 1;
}
.edit-history-table th:nth-child(1) { width: 22%; }
.edit-history-table th:nth-child(2) { width: 20%; }
.edit-history-table th:nth-child(3) { width: 14%; }
.edit-history-table th:nth-child(4) { width: 22%; }
.edit-history-table th:nth-child(5) { width: 22%; }
.edit-history-table td {
    padding: 10px 16px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--hairline-light);
    vertical-align: top;
    overflow: hidden;
    text-overflow: ellipsis;
}
.edit-history-table tbody tr:hover { background: var(--bg-hover); }
.edit-history-table tr:last-child td { border-bottom: none; }
.edit-history-table .edit-date {
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 12px;
}
.edit-history-table .edit-old {
    text-decoration: line-through;
    color: var(--text-muted);
}
.edit-history-table .edit-user {
    font-size: 12px;
    color: var(--text-muted);
}
.edit-history-table .edit-new {
    color: var(--text-primary);
    font-weight: 600;
}
.edit-history-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--hairline-light);
    font-size: 11px;
    color: var(--text-muted);
}
.edit-hash-label { font-weight: 600; white-space: nowrap; }
.edit-hash-value {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 10px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Route / Live-map action — full-width pill at the bottom of the
   left column, accent filled for prominence */
.trip-detail-action {
    padding: 14px 18px 16px;
    margin-top: auto; /* push to bottom so both columns align */
    border-top: 1px solid var(--hairline-light);
}
.route-row-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    border-radius: var(--r-pill);
    color: #fff;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(10, 132, 255, 0.30),
                inset 0 0 0 1px rgba(255, 255, 255, 0.12);
    transition: transform var(--dur-fast) var(--ease),
                filter var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.route-row-btn:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(10, 132, 255, 0.34),
                inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.route-row-ico {
    display: inline-block;
    opacity: 0.95;
    flex-shrink: 0;
}

.optional-hint { font-weight: 400; color: var(--text-muted); font-size: 11px; margin-left: 3px; }
.required-hint { color: var(--red); font-weight: 600; }
.ac-missing { border-color: var(--red) !important; background: var(--red-bg) !important; }

/* Live trip row */
.trip-row-active {
    background: linear-gradient(90deg, rgba(48,209,88,0.14) 0, rgba(48,209,88,0.04) 40%, transparent 100%);
    box-shadow: inset 3px 0 0 var(--sys-green);
}
.trip-row-active:hover {
    background: linear-gradient(90deg, rgba(48,209,88,0.18) 0, rgba(48,209,88,0.06) 40%, rgba(60,60,67,0.03) 100%);
}

/* Incomplete business trip — amber left-edge accent + warning chip
   in the type cell. Subtle so it doesn't scream, obvious enough that
   you can't miss a whole list of incomplete rows at a glance. */
.trip-row-incomplete {
    background: linear-gradient(90deg, rgba(255, 159, 10, 0.08) 0, rgba(255, 159, 10, 0.02) 40%, transparent 100%);
    box-shadow: inset 3px 0 0 var(--sys-orange);
}
.trip-row-incomplete:hover {
    background: linear-gradient(90deg, rgba(255, 159, 10, 0.14) 0, rgba(255, 159, 10, 0.04) 40%, rgba(60,60,67,0.03) 100%);
}
.trip-warn-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding: 3px 9px 3px 7px;
    border-radius: var(--r-pill);
    background: var(--yellow-bg);
    color: #92500c;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: -0.003em;
    line-height: 1.5;
    cursor: help;
    vertical-align: middle;
}
.trip-warn-chip svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    color: var(--sys-orange);
}
.trip-warn-text { white-space: nowrap; }

.trip-live-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--sys-green);
    animation: tripLivePulse 1.8s ease-out infinite;
    vertical-align: baseline; margin-right: 5px;
}
@keyframes tripLivePulse {
    0%   { box-shadow: 0 0 0 0   rgba(48, 209, 88, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(48, 209, 88, 0);    }
    100% { box-shadow: 0 0 0 0   rgba(48, 209, 88, 0);    }
}

.badge-live {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 11px; border-radius: var(--r-pill);
    font-size: 11px; font-weight: 600;
    background: var(--green-bg); color: var(--green);
}
.badge-live .trip-live-dot { margin-right: 0; }

.trip-gap-row { background: transparent !important; }
.trip-gap-row td {
    padding: 6px 14px; border-bottom: none; text-align: center;
}
.odo-gap {
    display: inline-block; padding: 4px 11px;
    font-size: 11px; font-weight: 600; color: #92500c;
    background: var(--yellow-bg); border-radius: var(--r-pill);
}

/* Autocomplete combo */
.ac-combo { flex: 1; position: relative; }
.ac-input {
    width: 100%; padding: 7px 10px; font-size: 13px;
    border: 1px solid var(--hairline); border-radius: var(--r-xs);
    background: var(--bg-surface); box-sizing: border-box;
    font-family: inherit;
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.ac-input:focus {
    border-color: var(--accent); outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
}
.ac-suggestions {
    z-index: 9999; background: var(--bg-surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-sm);
    list-style: none; margin: 4px 0 0; padding: 4px;
    max-height: 210px; overflow-y: auto;
    box-shadow: var(--shadow-pop);
}
.ac-sug-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 7px 10px; cursor: pointer; font-size: 13px;
    border-radius: var(--r-xs);
    transition: background var(--dur-fast) var(--ease);
}
.ac-sug-item:hover { background: var(--bg-hover); }
.ac-sug-value { flex: 1; }
.ac-sug-remove {
    background: none; border: none; color: var(--text-muted);
    font-size: 16px; cursor: pointer; padding: 0 2px;
    line-height: 1; flex-shrink: 0; border-radius: 4px;
}
.ac-sug-remove:hover { color: var(--red); }

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: -0.003em;
    line-height: 1.5;
}
.badge-sc       { background: var(--red-bg);        color: var(--red); }
.badge-home     { background: var(--green-bg);      color: var(--green); }
.badge-pub      { background: rgba(255, 159, 10, 0.14); color: var(--sys-orange); }
.badge-commute  { background: var(--accent-subtle); color: var(--accent); }
.badge-business { background: rgba(88, 86, 214, 0.14); color: var(--sys-indigo); }
.badge-private  { background: var(--green-bg);      color: var(--green); }
.badge-other    {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--hairline);
    font-weight: 500;
}
.badge-charging { background: var(--accent-subtle); color: var(--accent); }
.badge-plugged  { background: var(--accent-subtle); color: var(--accent); }
.badge-unplugged{ background: var(--bg-hover);      color: var(--text-secondary); }
.badge-driving  { background: var(--green-bg);      color: var(--green); }
.badge-archived { background: var(--bg-hover);      color: var(--text-muted); border: 1px solid var(--hairline); }

/* ============================================================
   Garage sync hint + disconnected-car states
   ============================================================ */
.card-hint {
    background: var(--accent-subtle);
    border: 1px solid var(--accent-ring);
}
.card-hint .card-title { color: var(--accent); }
.card-hint .settings-desc { margin-bottom: 0; }

/* Disconnected ("archived") cars get a muted treatment so the user can
   still see the row and open historical data but understands it's no
   longer connected to Tesla. */
.telemetry-vehicle.is-archived {
    opacity: 0.72;
    background: var(--bg-hover);
}
.telemetry-vehicle.is-archived .telemetry-vehicle-label {
    text-decoration: line-through;
    text-decoration-color: var(--hairline);
}
.telemetry-archived-note {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Destructive "remove" button lives under each car row */
.telemetry-vehicle-danger {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--hairline);
    display: flex;
    justify-content: flex-end;
}

/* ============================================================
   Remove-car confirmation modal
   ============================================================ */
.modal-sm { max-width: 460px; }
.danger-copy {
    color: var(--text-primary);
    line-height: 1.5;
    margin: 0 0 14px;
}
.remove-car-target {
    background: var(--bg-hover);
    border: 1px solid var(--hairline);
    border-radius: var(--r);
    padding: 10px 12px;
    font-weight: 600;
    margin-bottom: 16px;
    font-size: 0.95rem;
}
.remove-car-target-vin {
    display: block;
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    margin-top: 2px;
    letter-spacing: 0.02em;
}
.remove-car-label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.remove-car-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--hairline);
    border-radius: var(--r);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.08em;
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.remove-car-input:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(255, 69, 58, 0.18);
}
.remove-car-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* ============================================================
   Setup prompt (connect Tesla)
   ============================================================ */
.setup-prompt {
    text-align: center;
    padding: 64px 28px 56px;
}
.setup-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    display: inline-block;
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.08));
}
.setup-prompt h3 {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}
.setup-prompt p {
    color: var(--text-secondary);
    font-size: 14px;
    max-width: 460px;
    margin: 0 auto 24px;
    line-height: 1.6;
}
.setup-prompt strong { color: var(--text-primary); }

.scope-warning {
    background: var(--yellow-bg);
    border: 1px solid rgba(255, 214, 10, 0.45);
    border-radius: var(--r);
    padding: 14px 18px;
    margin: 14px auto;
    max-width: 460px;
    font-size: 13px;
    color: #6a4a0f;
    text-align: center;
}
.scope-warning p { margin-bottom: 8px; }

/* ============================================================
   Fleet Telemetry — vehicle cards
   ============================================================ */
.telemetry-hint {
    background: var(--accent-subtle);
    border: 1px solid rgba(10, 132, 255, 0.20);
    border-radius: var(--r);
    padding: 14px 18px;
    margin: 0 0 18px 0;
    font-size: 13px;
    color: #123961;
    line-height: 1.55;
}
.telemetry-hint p { margin: 0; }

.telemetry-vehicles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
}

.telemetry-vehicle {
    background: var(--bg-surface);
    border: 1px solid var(--hairline-light);
    border-radius: var(--r-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--dur) var(--ease),
                transform var(--dur) var(--ease);
}
.telemetry-vehicle:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.telemetry-vehicle-head { display: flex; flex-direction: column; gap: 3px; }
.telemetry-vehicle-name {
    font-weight: 600;
    font-size: 15.5px;
    color: var(--text-primary);
    display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
    letter-spacing: -0.012em;
}
.telemetry-vehicle-model {
    font-weight: 500;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 2px 10px;
    border: 1px solid var(--hairline);
    border-radius: var(--r-pill);
    background: var(--bg-surface-2);
}
.telemetry-vehicle-rename {
    background: none; border: none; padding: 4px;
    margin-left: 2px; cursor: pointer;
    color: var(--text-muted);
    border-radius: 6px;
    display: inline-flex; align-items: center;
    transition: background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
}
.telemetry-vehicle-rename:hover {
    background: var(--bg-hover); color: var(--text-primary);
}
.telemetry-vehicle-input {
    font-weight: 600; font-size: 15.5px;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--accent);
    border-radius: var(--r-sm);
    padding: 4px 10px;
    min-width: 170px;
    outline: none;
    font-family: inherit;
    box-shadow: 0 0 0 3px var(--accent-ring);
}
.telemetry-vehicle-vin {
    font-size: 11px;
    color: var(--text-muted);
    font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
    letter-spacing: 0.02em;
}
.telemetry-vehicle-badges {
    display: flex; gap: 6px; flex-wrap: wrap;
}
.telemetry-live {
    font-size: 12.5px;
    background: var(--bg-surface-2);
    border: 1px solid var(--hairline-light);
    padding: 10px 12px;
    border-radius: var(--r);
    line-height: 1.55;
}
.telemetry-live strong {
    color: var(--text-primary);
    text-transform: capitalize;
    font-weight: 600;
}
.telemetry-ts {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 3px;
}
.telemetry-vehicle-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.telemetry-actions {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
}

/* ============================================================
   Empty states
   ============================================================ */
.empty-state, .loading, .empty {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.6;
}
.trips-filter-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 56px 24px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}
.trips-filter-empty p { margin: 0; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translate(-50%, 20px);
    padding: 12px 22px;
    border-radius: var(--r-pill);
    color: #fff;
    font-weight: 500;
    font-size: 13.5px;
    opacity: 0;
    transition: opacity var(--dur) var(--ease),
                transform var(--dur) var(--ease-out);
    z-index: 1000;
    max-width: 420px;
    box-shadow: var(--shadow-pop);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    letter-spacing: -0.005em;
}
.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}
.toast-success { background: rgba(48, 209, 88, 0.94); }
.toast-error   { background: rgba(255, 69, 58, 0.94); }

/* ============================================================
   Settings page content
   ============================================================ */
.settings-desc {
    color: var(--text-secondary);
    font-size: 13.5px;
    margin-bottom: 18px;
    line-height: 1.6;
    max-width: 640px;
}
.settings-form { max-width: 520px; }

.settings-divider {
    border: none;
    border-top: 1px solid var(--hairline-light);
    margin: 32px 0 22px;
}

.code-block {
    background: #1d1d1f;
    color: #f5f5f7;
    font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
    font-size: 12.5px;
    padding: 14px 18px;
    border-radius: var(--r);
    overflow-x: auto;
    white-space: nowrap;
    margin-top: 10px;
    box-shadow: var(--shadow-sm);
}
.settings-poll-info {
    border-top: 1px solid var(--hairline-light);
    padding-top: 18px;
}

/* ============================================================
   Language popover
   ============================================================ */
.lang-popover {
    position: fixed;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: saturate(180%) blur(26px);
    -webkit-backdrop-filter: saturate(180%) blur(26px);
    border: 1px solid var(--hairline-light);
    border-radius: var(--r);
    box-shadow: var(--shadow-pop);
    padding: 6px;
    min-width: 188px;
    max-height: 380px;
    overflow-y: auto;
    z-index: 500;
    animation: popIn var(--dur) var(--ease-out);
}
@keyframes popIn {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.lang-option {
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease);
    border-radius: var(--r-xs);
    font-weight: 500;
}
.lang-option:hover { background: var(--bg-hover); }
.lang-option.active {
    color: var(--accent);
    font-weight: 600;
    background: var(--accent-subtle);
}

/* ============================================================
   Public pages (landing / auth)
   ============================================================ */
body:not(.app-layout) {
    background:
        radial-gradient(1200px 700px at 0% -10%, rgba(10, 132, 255, 0.08), transparent 55%),
        radial-gradient(1000px 600px at 110% 15%, rgba(191, 90, 242, 0.06), transparent 60%),
        var(--bg-canvas);
    min-height: 100vh;
}
body:not(.app-layout) header {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: saturate(180%) blur(22px);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    border-bottom: 1px solid var(--hairline-light);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 1.5rem;
}
header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.018em;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
}
.brand-logo {
    width: 1.7em;
    height: 1.7em;
    display: inline-block;
    vertical-align: middle;
}
header .subtitle {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 1px;
}
.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 1.5rem;
}
.logo-link { color: inherit; text-decoration: none; }
.logo-link:hover { text-decoration: none; }
.nav-user {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-right: 0.75rem;
}
#nav-links {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hero {
    text-align: center;
    padding: 6rem 1rem 4rem;
}
.hero h2 {
    font-size: clamp(2.1rem, 5vw, 3.5rem);
    line-height: 1.05;
    font-weight: 700;
    letter-spacing: -0.028em;
    color: var(--text-primary);
    margin-bottom: 1.1rem;
    background: linear-gradient(180deg, #1d1d1f 0%, #3a3a3c 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero p {
    color: var(--text-secondary);
    font-size: 1.12rem;
    max-width: 640px;
    margin: 0 auto 2.25rem;
    line-height: 1.55;
}
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 4rem;
}
.feature-card {
    background: var(--bg-surface);
    border: 1px solid var(--hairline-light);
    border-radius: var(--r-xl);
    padding: 1.75rem 1.5rem;
    text-align: center;
    transition: transform var(--dur) var(--ease),
                box-shadow var(--dur) var(--ease);
    box-shadow: var(--shadow-sm);
}
.feature-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}
.feature-icon { font-size: 2.4rem; margin-bottom: 0.85rem; }
.feature-card h3 {
    color: var(--text-primary);
    margin-bottom: 0.45rem;
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: -0.012em;
}
.feature-card p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.55; }

.auth-container {
    display: flex;
    justify-content: center;
    padding-top: 4rem;
    padding-bottom: 4rem;
}
.auth-card {
    max-width: 420px;
    width: 100%;
    padding: 36px 32px;
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--hairline-light);
    background: var(--bg-surface);
}
.auth-card h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.6rem;
    letter-spacing: -0.022em;
    text-align: center;
}
.auth-switch {
    text-align: center;
    margin-top: 1.3rem;
    font-size: 0.92rem;
    color: var(--text-muted);
}

.lang-select {
    padding: 7px 12px;
    border: 1px solid var(--hairline);
    border-radius: var(--r-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.lang-select:hover { border-color: var(--hairline-strong); }
.lang-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* ============================================================
   Live Status card (inside hero-card)
   ============================================================ */
.live-updated { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

.live-vehicle {
    display: grid;
    grid-template-columns: 104px 1fr auto;
    gap: 22px;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--hairline-light);
}
.live-vehicle:first-child { padding-top: 8px; }
.live-vehicle:last-child { border-bottom: none; padding-bottom: 4px; }

.battery-ring {
    position: relative;
    width: 104px;
    height: 104px;
    display: grid;
    place-items: center;
}
.battery-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    display: block;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.04));
}
.battery-ring-bg { stroke: rgba(60, 60, 67, 0.10); }
.battery-ring-fg {
    stroke: var(--sys-green);
    transition: stroke-dashoffset var(--dur-slow) var(--ease),
                stroke var(--dur-slow) var(--ease);
}
.battery-ring.medium .battery-ring-fg { stroke: var(--sys-yellow); }
.battery-ring.low    .battery-ring-fg { stroke: var(--sys-red); }

@keyframes battery-ring-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 var(--ring-pulse, rgba(48, 209, 88, 0.55));
    }
    50% {
        transform: scale(1.03);
        box-shadow: 0 0 22px 6px var(--ring-pulse, rgba(48, 209, 88, 0.55));
    }
}
.battery-ring.charging {
    border-radius: 50%;
    animation: battery-ring-pulse 1.7s ease-in-out infinite;
    --ring-pulse: rgba(48, 209, 88, 0.55);
}
.battery-ring.charging.medium { --ring-pulse: rgba(255, 214, 10, 0.55); }
.battery-ring.charging.low    { --ring-pulse: rgba(255, 69, 58, 0.60); }
@media (prefers-reduced-motion: reduce) {
    .battery-ring.charging { animation: none; }
}
.battery-ring-label {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: -0.028em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    line-height: 1;
}

.live-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.live-info .live-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    letter-spacing: -0.018em;
    line-height: 1.2;
}
.live-info .live-state {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.live-info .live-loc {
    color: var(--text-muted);
    font-size: 0.88rem;
    display: inline-flex; align-items: flex-start; gap: 7px;
    line-height: 1.35;
}
.live-info .live-loc a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--dur-fast) var(--ease);
}
.live-info .live-loc a:hover { color: var(--accent-hover); }
.live-info .live-loc .live-loc-lines {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
}
.live-info .live-loc .live-place {
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 500;
}
.live-info .live-loc .live-loc-lines a {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.live-info .live-loc .live-loc-lines a:hover { color: var(--accent); }

.live-tta {
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.live-tta strong {
    display: block;
    font-size: 1.1rem;
    color: var(--text-primary);
    letter-spacing: -0.018em;
    font-weight: 600;
}

.live-rate {
    margin-top: 8px;
    display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.live-rate-main {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.022em;
}
.live-rate-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ============================================================
   Session replay modal
   ============================================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 22, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn var(--dur) var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--bg-surface);
    border-radius: var(--r-xl);
    max-width: 760px;
    width: 92%;
    max-height: 88vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--hairline-light);
    animation: modalIn var(--dur-slow) var(--ease-out);
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--hairline-light);
}
.modal-title {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.015em;
}
.modal-close {
    background: transparent;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
}
.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.modal-body { padding: 22px; }

.replay-chart { width: 100%; height: 280px; }
.replay-meta {
    display: flex; gap: 18px; flex-wrap: wrap;
    font-size: 0.9rem; color: var(--text-secondary);
    margin-bottom: 14px;
}
.replay-legend {
    display: flex; gap: 18px; font-size: 0.85rem; color: var(--text-secondary);
    margin-top: 10px; justify-content: center;
}
.replay-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.replay-legend-swatch {
    width: 14px; height: 3px;
    border-radius: 2px;
    display: inline-block;
}

.replay-row-btn {
    background: var(--bg-surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-pill);
    padding: 3px 11px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--accent);
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
}
.replay-row-btn:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
}

.invoice-row-btn {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    padding: 3px 9px;
    font-size: 0.85rem;
    text-decoration: none;
    border: 1px solid var(--hairline);
    border-radius: var(--r-pill);
    color: var(--text-secondary);
    background: var(--bg-surface);
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
}
.invoice-row-btn:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

/* Base coordinate chip. The trip-detail list further specializes this
   with a block layout + top margin; outside that context (e.g. live
   "en route" updates patched in by JS) we fall back to this style. */
.coords {
    font-size: 11.5px;
    color: var(--text-muted);
    font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
}

/* .route-row-btn styles now live with the trip detail grouped-list
   block above. Kept this placeholder so git blame reveals the move. */

/* ============================================================
   Charging page — month navigator, KPI tiles, export bar
   ============================================================ */
.charging-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.month-nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: rgba(118, 118, 128, 0.10);
    border-radius: var(--r);
    flex-wrap: wrap;
}

.month-nav-btn {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: calc(var(--r) - 4px);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease),
                color     var(--dur-fast) var(--ease);
}
.month-nav-btn:hover:not(:disabled) {
    background: var(--bg-surface);
    color: var(--text-primary);
}
.month-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.month-nav-label {
    min-width: 130px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    padding: 0 4px;
}

.month-nav-today {
    margin-left: 4px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    border-radius: calc(var(--r) - 4px);
    transition: background var(--dur-fast) var(--ease);
}
.month-nav-today:hover:not(:disabled) { background: var(--accent-subtle); }
.month-nav-today:disabled { opacity: 0.35; cursor: not-allowed; }

.month-nav-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 6px;
    padding: 0 10px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.month-nav-all input { margin: 0; cursor: pointer; }

.ch-range-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-left: 4px;
    border: 1px solid var(--hairline);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}
.ch-range-toggle:hover { color: var(--accent); border-color: var(--accent); }
.ch-range-toggle.active {
    color: var(--accent);
    background: var(--accent-subtle, rgba(10,132,255,0.08));
    border-color: var(--accent);
}

.ch-date-range {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-basis: 100%;
    order: 5;
    padding: 8px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--hairline);
    border-radius: 10px;
    animation: chRangeSlide 0.15s ease;
}
@keyframes chRangeSlide {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ch-date-range .input-sm {
    height: 30px;
    padding: 2px 8px;
    border: 1px solid var(--hairline);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-primary);
    background: var(--bg-surface);
    outline: none;
    font-family: inherit;
}
.ch-date-range .input-sm:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(10,132,255,0.15);
}
.ch-range-apply, .ch-range-clear { font-size: 12px !important; padding: 4px 10px !important; }

.charging-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* KPI grid — clickable type-filter tiles */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.kpi-card {
    text-align: left;
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-surface);
    border: 1px solid var(--hairline-light);
    border-radius: var(--r-lg);
    padding: 16px 18px 18px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
    font-family: inherit;
    color: inherit;
}
.kpi-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.kpi-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring), var(--shadow-sm);
}

.kpi-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.kpi-icon {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.10),
                inset 0 0 0 0.5px rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.kpi-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: -0.005em;
}

.kpi-flag {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 2px 7px;
    border-radius: var(--r-pill);
    background: var(--green-bg);
    color: var(--green);
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 4px;
}

.kpi-sub {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.kpi-sub .kpi-dot {
    margin: 0 4px;
    color: var(--hairline-strong);
}

/* Make the "Home" tile feel slightly more prominent — it's the primary
   accounting target. Matches Apple's pattern of giving the canonical
   action a tinted background. */
.kpi-home-card {
    background: linear-gradient(180deg, rgba(48, 209, 88, 0.06), var(--bg-surface) 60%);
}
.kpi-home-card.active {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.20), var(--shadow-sm);
}

/* Print stylesheet — what an accountant actually sees on the saved PDF */
@media print {
    body { background: #fff; }
    .sidebar, .mobile-topbar, .panel-content,
    #sync-btn, .charging-actions, .month-nav-today, .month-nav-all,
    .month-nav-btn, .replay-row-btn, .invoice-row-btn,
    #onboarding-section, #live-status-section { display: none !important; }
    .content-body { padding: 0 !important; max-width: 100% !important; }
    .page-header { margin-bottom: 8px; }
    .month-nav { background: transparent; padding: 0; gap: 0; }
    .month-nav-label { font-size: 16px; }
    .kpi-grid { page-break-inside: avoid; }
    .kpi-card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        transform: none !important;
    }
    .kpi-card:not(.active) { opacity: 0.65; }
    .charge-detail { display: none !important; }
    .data-table { font-size: 11px; }
    .data-table th, .data-table td { padding: 6px 8px !important; }
    .badge { background: transparent !important; color: #000 !important; padding: 0 !important; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 960px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform var(--dur) var(--ease);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open, .rail.open { transform: translateX(0); }

    .mobile-topbar { display: flex; }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.48);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 250;
        animation: fadeIn var(--dur) var(--ease-out);
    }

    .content-body { padding: 22px 18px 36px; }
    .page-title { font-size: 1.75rem; }
}

@media (max-width: 640px) {
    .form-row { flex-direction: column; gap: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .trips-export-actions { width: 100%; justify-content: flex-start; }
    .content-body { padding: 18px 14px 28px; }
    .hero-card { padding: 20px 20px; border-radius: var(--r-lg); }
    .card { padding: 18px 18px; border-radius: var(--r-lg); }
    .stat-card { padding: 18px; }
    .stat-value { font-size: 1.55rem; }
    .kpi-card { padding: 14px 14px 16px; }
    .kpi-value { font-size: 1.3rem; }
    .live-vehicle { grid-template-columns: 72px 1fr; gap: 14px; }
    .live-tta { grid-column: 1 / -1; text-align: left; padding-left: 86px; }
    .battery-ring { width: 72px; height: 72px; }
    .charging-toolbar { gap: 10px; }
    .month-nav-label { min-width: 100px; font-size: 13px; }
}

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