/* ChargeMeFree — unified design system */

:root {
    --sidebar-w: 240px;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --border: #e8eaed;
    --text: #111827;
    --muted: #6b7280;
    --accent: #0d9488;
    --accent-soft: #ccfbf1;
    --accent-hover: #0f766e;
    --solar: #d97706;
    --solar-soft: #fef3c7;
    --home: #2563eb;
    --home-soft: #dbeafe;
    --ev: #7c3aed;
    --ev-soft: #ede9fe;
    --ok: #16a34a;
    --ok-soft: #dcfce7;
    --warn: #ca8a04;
    --warn-soft: #fef9c3;
    --err: #dc2626;
    --err-soft: #fee2e2;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    padding: 20px 16px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 24px;
    text-decoration: none;
    color: var(--text);
}

.brand-mark {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white;
    flex-shrink: 0;
}

.brand-name {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.brand-mark svg { width: 20px; height: 20px; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.9375rem;
    transition: background .15s, color .15s;
}

.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-weight: 600;
}

.nav-item svg {
    width: 20px; height: 20px;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-item.active svg { opacity: 1; }

.sidebar-foot {
    padding: 16px 12px 8px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.live-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--muted);
    font-weight: 500;
}

.live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--ok);
    flex-shrink: 0;
}

.live-dot.off { background: var(--err); }

.sidebar-polling {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0 12px;
}

.sidebar-polling-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.sidebar-polling-text strong {
    font-size: 0.8125rem;
    font-weight: 600;
}

.sidebar-polling-text span {
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.3;
}

.sidebar-logout {
    width: 100%;
    margin-top: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.sidebar-logout:hover {
    background: var(--err-soft);
    color: var(--err);
    border-color: #fecaca;
}

/* Login page */
body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #ecfdf5 0%, var(--bg) 45%, #f0f9ff 100%);
    padding: 24px;
}

.login-wrap {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 32px 28px;
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-brand .brand-mark {
    margin: 0 auto 14px;
}

.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
}

.login-brand p {
    color: var(--muted);
    font-size: 0.9375rem;
}

.login-form .form-field {
    margin-bottom: 16px;
}

.login-form label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.login-form input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-form .btn {
    width: 100%;
    margin-top: 8px;
}

.login-error {
    margin-top: 12px;
    font-size: 0.875rem;
    color: var(--err);
    text-align: center;
}

.login-mfa-hint {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 16px;
    line-height: 1.5;
}

.mfa-status-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.mfa-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.mfa-qr-wrap {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    padding: 16px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    width: fit-content;
}

.mfa-qr {
    width: 200px;
    height: 200px;
    image-rendering: pixelated;
}

.mfa-manual-secret {
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.mfa-manual-secret code {
    display: block;
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: 8px;
    font-size: 0.8125rem;
    word-break: break-all;
}

.mfa-backup-box {
    margin-top: 20px;
    padding: 16px;
    border-radius: 12px;
    background: #fffbeb;
    border: 1px solid #f59e0b;
}

.mfa-backup-list {
    list-style: none;
    padding: 0;
    margin: 12px 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    font-family: ui-monospace, monospace;
    font-size: 0.875rem;
}

.mfa-disable-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}


.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 32px 40px 48px;
    max-width: 1100px;
}

/* ── Page header ── */
.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--muted);
    font-size: 0.9375rem;
}

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.header-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
}

.meta-chip-toggle {
    cursor: pointer;
    user-select: none;
    gap: 10px;
}

.meta-chip-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

.switch-sm {
    width: 40px;
    height: 22px;
}

.switch-sm .switch-track::after {
    width: 16px;
    height: 16px;
}

.switch-sm input:checked + .switch-track::after {
    transform: translateX(18px);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8125rem;
    min-height: 34px;
}

.meta-chip.on {
    background: var(--ok-soft);
    border-color: #bbf7d0;
    color: #15803d;
}

.meta-chip .live-dot { width: 6px; height: 6px; }

/* ── Energy stats ── */
.stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
}

.stat-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.stat-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-icon.solar { background: var(--solar-soft); color: var(--solar); }
.stat-icon.home { background: var(--home-soft); color: var(--home); }
.stat-icon.excess { background: var(--ok-soft); color: var(--ok); }

.stat-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 10px;
}

.stat-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 2px;
    width: 0%;
    transition: width .5s ease;
}

.stat-bar-fill.solar { background: var(--solar); }
.stat-bar-fill.home { background: var(--home); }
.stat-bar-fill.excess { background: var(--ok); }

/* ── Setup cards ── */
.section-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 12px;
}

.setup-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.setup-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    transition: border-color .2s;
}

.setup-card.ok { border-color: #86efac; }
.setup-card.warn { border-color: #fde047; }
.setup-card.info { border-color: #93c5fd; }

.setup-card-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.setup-card-icon svg { width: 22px; height: 22px; }

.setup-card-icon.solar { background: var(--solar-soft); color: var(--solar); }
.setup-card-icon.home { background: var(--home-soft); color: var(--home); }
.setup-card-icon.ev { background: var(--ev-soft); color: var(--ev); }

.setup-card-body { flex: 1; min-width: 0; }

.setup-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.setup-card-head h3 {
    font-size: 0.9375rem;
    font-weight: 600;
}

.setup-card-body p {
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.4;
}

.badge {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge.ok { background: var(--ok-soft); color: #15803d; }
.badge.warn { background: var(--warn-soft); color: #a16207; }
.badge.info { background: var(--home-soft); color: #1d4ed8; }
.badge:not(.ok):not(.warn):not(.info) { background: var(--surface-2); color: var(--muted); }

.text-link {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
}

.text-link:hover { text-decoration: underline; }

/* ── Two column ── */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title svg { width: 18px; height: 18px; color: var(--muted); }

.card-title > span { display: inline-flex; align-items: center; color: var(--muted); }

/* Vehicle ring */
.ring-wrap {
    position: relative;
    width: 140px; height: 140px;
    margin: 0 auto 20px;
}

.ring-wrap svg { width: 100%; height: 100%; display: block; }

.ring-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ring-pct {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.ring-label {
    font-size: 0.6875rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.stat-mini-row {
    display: flex;
    justify-content: center;
    gap: 28px;
}

.vehicle-refresh-row {
    display: flex;
    justify-content: center;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.vehicle-refresh-row .btn {
    min-width: 7rem;
}

.vehicle-card {
    position: relative;
}

.vehicle-card-body {
    transition: opacity 0.25s ease, filter 0.25s ease;
}

.vehicle-card.is-stale .vehicle-card-body {
    opacity: 0.5;
    filter: grayscale(0.35) saturate(0.7);
}

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

.stat-mini-label {
    font-size: 0.6875rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 2px;
}

.stat-mini-val {
    font-size: 0.9375rem;
    font-weight: 600;
}

.stat-mini-val.ok { color: var(--ok); }
.stat-mini-val.warn { color: var(--err); }
.stat-mini-val.muted { color: var(--muted); }

/* Controls */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--surface-2);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.toggle-row strong {
    display: block;
    font-size: 0.9375rem;
    margin-bottom: 1px;
}

.toggle-row span {
    font-size: 0.8125rem;
    color: var(--muted);
}

.btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
}

.btn svg { width: 16px; height: 16px; }

.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-start { background: var(--ok); color: white; }
.btn-stop { background: var(--err); color: white; }
.btn-accent { background: var(--accent); color: white; }
.btn-ghost {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-lg { padding: 14px 28px; font-size: 1rem; }

.field-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
}

.field-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.field-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9375rem;
}

.field-row input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}

.chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.chip {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
    transition: border-color .15s, background .15s;
}

.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }

.schedule-days {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.chip-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.8125rem;
    cursor: pointer;
    user-select: none;
}
.chip-check:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-hover);
}
.chip-check input { margin: 0; }

/* Switch */
.switch {
    position: relative;
    width: 48px; height: 26px;
    flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.switch-track {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 999px;
    cursor: pointer;
    transition: background .2s;
}

.switch-track::after {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    left: 3px; top: 3px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
    transition: transform .2s;
}

.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(22px); }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px; left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 200;
    box-shadow: var(--shadow);
    max-width: 90vw;
}

.toast.ok { background: var(--ok-soft); color: #15803d; border: 1px solid #bbf7d0; }
.toast.warn { background: var(--warn-soft); color: #a16207; border: 1px solid #fde047; }
.toast.err { background: var(--err-soft); color: #b91c1c; border: 1px solid #fecaca; }

.toast-inline {
    position: static;
    transform: none;
    margin-bottom: 16px;
}

/* ── Settings ── */
.setup-progress {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.progress-step {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-step .badge { margin-left: auto; }

.step-num {
    width: 32px; height: 32px;
    background: var(--accent);
    color: white;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.step-body { flex: 1; min-width: 0; }
.step-body small {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 2px;
}
.step-body strong {
    font-size: 0.9375rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 24px;
}

.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    background: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--muted);
    cursor: pointer;
    transition: all .15s;
}

.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { background: var(--accent); color: white; font-weight: 600; }

.panel { display: none; }
.panel.open { display: block; }

.integ-list { display: flex; flex-direction: column; gap: 16px; }

.integ-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: border-color .2s, box-shadow .2s;
}

.integ-item.integ-saved {
    border-color: #99f6e4;
    box-shadow: 0 0 0 1px rgba(13,148,136,.08);
}

.integ-item.integ-saved .integ-head h3::after {
    content: ' · Connected';
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
}

/* ── Locked credentials ── */
.cred-locked {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.cred-locked-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--accent-soft) 0%, var(--surface) 100%);
    border-bottom: 1px solid var(--border);
}

.cred-locked-status {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.cred-lock-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cred-lock-icon svg { width: 18px; height: 18px; }

.cred-locked-status strong {
    display: block;
    font-size: 0.9375rem;
    margin-bottom: 2px;
}

.cred-locked-status span {
    display: block;
    font-size: 0.8125rem;
    color: var(--muted);
}

.cred-locked-rows {
    padding: 4px 18px;
}

.cred-locked-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.cred-locked-row:last-child { border-bottom: none; }

.cred-locked-label {
    color: var(--muted);
    font-weight: 500;
    flex-shrink: 0;
}

.cred-locked-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8125rem;
    color: var(--text);
    text-align: right;
    word-break: break-all;
}

.cred-locked-foot {
    padding: 12px 18px 16px;
    border-top: 1px solid var(--border);
}

.cred-edit-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 14px;
    background: var(--warn-soft);
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--warn);
}

.cred-none-box {
    padding: 16px 18px;
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.cred-none-box p {
    margin: 0 0 10px;
    font-size: 0.875rem;
    color: var(--muted);
}

.cred-guide-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}

.cred-guide-link:hover { text-decoration: underline; }

.tesla-oauth-row { margin-top: 12px; }

.tesla-oauth-row .cred-locked { margin-bottom: 12px; }

.tesla-oauth-form {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.help-intro {
    font-size: 0.9375rem;
    color: var(--muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

.integ-head {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.integ-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.integ-icon svg { width: 24px; height: 24px; }

.integ-icon.solar { background: var(--solar-soft); color: var(--solar); }
.integ-icon.home { background: var(--home-soft); color: var(--home); }
.integ-icon.ev { background: var(--ev-soft); color: var(--ev); }

.integ-step-tag {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 2px;
}

.integ-head h3 { font-size: 1.0625rem; font-weight: 700; margin-bottom: 2px; }
.integ-head p { font-size: 0.8125rem; color: var(--muted); }

.form-field { margin-bottom: 14px; }

.form-field label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-field input, .field-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9375rem;
    background: var(--surface);
}

.form-field input:focus, .field-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}

.form-field input.field-highlight {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13,148,136,.2);
}

.form-field small {
    display: block;
    margin-top: 4px;
    font-size: 0.8125rem;
    color: var(--muted);
}

.field-hint {
    font-size: 0.8125rem;
    color: var(--muted);
    padding: 12px;
    background: var(--surface-2);
    border-radius: var(--radius);
}

.btn-test {
    margin-top: 8px;
    padding: 10px 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    transition: all .15s;
}

.btn-test svg { width: 14px; height: 14px; }
.btn-test:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

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

.field-unit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-unit input { flex: 1; }
.field-unit span { font-weight: 600; color: var(--muted); font-size: 0.875rem; }

.save-bar {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-top: 32px;
    border-top: 1px solid var(--border);
    background: linear-gradient(to top, var(--bg) 80%, transparent);
}

.save-bar p { font-size: 0.8125rem; color: var(--muted); }

.help-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.help-tile {
    display: flex;
    gap: 14px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, box-shadow .15s;
}

.help-tile:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.help-tile-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.help-tile-icon svg { width: 20px; height: 20px; }

.help-tile h4 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 2px; }
.help-tile p { font-size: 0.8125rem; color: var(--muted); }

.help-banner {
    text-align: center;
    padding: 28px;
    background: var(--accent-soft);
    border-radius: var(--radius-lg);
    border: 1px solid #99f6e4;
}

.help-banner p { color: var(--accent-hover); margin-bottom: 14px; font-size: 0.9375rem; }

/* ── Guide ── */
.guide-toc {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 28px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: sticky;
    top: 12px;
    z-index: 10;
}

.guide-toc a {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    transition: all .15s;
}

.guide-toc a:hover { background: var(--accent-soft); color: var(--accent-hover); }

.guide-block {
    display: flex;
    gap: 20px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    scroll-margin-top: 80px;
}

.guide-block-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.guide-block-icon svg { width: 24px; height: 24px; }

.guide-block-icon.solar { background: var(--solar-soft); color: var(--solar); }
.guide-block-icon.home { background: var(--home-soft); color: var(--home); }
.guide-block-icon.ev { background: var(--ev-soft); color: var(--ev); }
.guide-block-icon.plug { background: var(--accent-soft); color: var(--accent); }
.guide-block-icon.warn { background: var(--warn-soft); color: var(--warn); }

.help-tile-icon.solar { background: var(--solar-soft); color: var(--solar); }
.help-tile-icon.home { background: var(--home-soft); color: var(--home); }
.help-tile-icon.ev { background: var(--ev-soft); color: var(--ev); }
.help-tile-icon.plug { background: var(--accent-soft); color: var(--accent); }

.tesla-oauth-row {
    margin: 16px 0;
    padding: 16px;
    background: var(--accent-soft);
    border: 1px solid #99f6e4;
    border-radius: var(--radius);
}

.tesla-oauth-row .field-hint { margin-top: 10px; margin-bottom: 0; }

.tesla-vehicle-panel {
    margin: 16px 0;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.tesla-vehicle-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.tesla-vehicle-head h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0;
}

.tesla-vehicle-details {
    display: grid;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.tesla-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.875rem;
}

.tesla-detail-row span { color: var(--muted); }
#chargeAmpsSlider { flex: 1; min-width: 0; }

.field-row input[type="range"] {
    flex: 1;
    min-width: 80px;
}

.guide-block-body h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}

.guide-block-body p {
    color: var(--muted);
    font-size: 0.9375rem;
    margin-bottom: 12px;
    line-height: 1.6;
}

.guide-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 12px;
}

.guide-box.tip {
    background: var(--warn-soft);
    border-color: #fde047;
}

.guide-box h4 { font-weight: 700; font-size: 0.875rem; margin-bottom: 8px; }
.guide-box ul { padding-left: 18px; color: var(--muted); font-size: 0.875rem; line-height: 1.7; }
.guide-box a { color: var(--accent); font-weight: 600; }
.guide-box code {
    background: rgba(0,0,0,.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8125rem;
}

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

.guide-col {
    padding: 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.guide-col h4 { font-weight: 700; font-size: 0.875rem; margin: 8px 0 4px; }
.guide-col p { font-size: 0.8125rem; color: var(--muted); line-height: 1.5; }

.guide-faq details {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
}

.guide-faq summary {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    background: var(--surface-2);
    list-style: none;
}

.guide-faq summary::-webkit-details-marker { display: none; }

.guide-faq details p {
    padding: 12px 16px;
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.6;
}

.guide-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 32px 0 16px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar {
        width: 64px;
        padding: 16px 10px;
    }
    .brand-name, .nav-item span, .sidebar-foot .live-pill span:last-child { display: none; }
    .nav-item { justify-content: center; padding: 12px; }
    .main { margin-left: 64px; padding: 20px 16px 40px; }
    .grid-2, .setup-progress, .form-grid, .help-grid, .guide-cols { grid-template-columns: 1fr; }
    .tabs { flex-direction: column; }
    .page-header-row { flex-direction: column; }
}

@media (max-width: 560px) {
    .stat-row, .setup-row { grid-template-columns: 1fr; }
    .stat-value { font-size: 1.625rem; }
}

/* ── Analytics charts ── */
.analytics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.analytics-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.analytics-stat-label {
    display: block;
    font-size: 0.8125rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.analytics-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.analytics-card { margin-bottom: 16px; }

.analytics-card .chart-wrap-tall {
    height: 360px;
}

.chart-wrap {
    position: relative;
    height: 220px;
    margin-top: 8px;
}

.chart-wrap-tall { height: 280px; }

.analytics-date-input {
    width: auto;
    min-width: 10rem;
    padding: 8px 12px;
}

/* ── Admin ── */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.poll-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    margin-bottom: 0;
}

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

.card-title-row .card-title {
    margin: 0;
}

.card-title-row .chips {
    margin: 0;
}

.poll-source-row {
    font-size: 0.8125rem;
    color: var(--muted);
}

.stat-card.compact {
    padding: 16px 18px;
}

.stat-card.compact .stat-value {
    font-size: 1.5rem;
    margin-top: 4px;
}

.admin-table-wrap { overflow-x: auto; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.admin-table th,
.admin-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.admin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-form { margin-top: 8px; }

@media (max-width: 768px) {
    .analytics-summary, .admin-stats { grid-template-columns: 1fr; }
}

/* ── Admin polling sections ── */
.polling-sections {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.polling-section {
    padding: 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.polling-section-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 4px;
}

.polling-section-head > div {
    flex: 1;
    min-width: 0;
}

.polling-section-head strong {
    display: block;
    font-size: 0.9375rem;
}

.polling-section-head span {
    display: block;
    font-size: 0.8125rem;
    color: var(--muted);
}

.polling-section-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.polling-section-icon svg { width: 20px; height: 20px; }
.polling-section-icon.solar { background: var(--solar-soft); color: var(--solar); }
.polling-section-icon.home { background: var(--home-soft); color: var(--home); }
.polling-section-icon.ev { background: var(--ev-soft); color: var(--ev); }

.polling-form-foot {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ── Admin API call log ── */
.log-filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.log-filter-group label {
    display: block;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.log-filter-search {
    grid-column: span 2;
    min-width: 180px;
}

.log-meta {
    font-size: 0.8125rem;
    color: var(--muted);
}

.log-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 14px;
}

.log-detail {
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    color: var(--muted);
}

.log-type-solar { color: var(--solar); }
.log-type-home { color: var(--home); }
.log-type-ev { color: var(--ev); }

@media (max-width: 768px) {
    .log-filter-search { grid-column: span 1; }
}
