:root {
    color-scheme: light;
    --bg: #eef2f7;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --line: #dbe3ee;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --success: #15803d;
    --warning: #a16207;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
.site-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.25rem clamp(1rem, 4vw, 3rem); background: #0f172a; color: #fff; }
.site-header h1 { margin: .15rem 0 0; font-size: clamp(1.35rem, 4vw, 2rem); }
.site-header .eyebrow { color: #93c5fd; }
.text-link { color: #fff; text-decoration: none; font-weight: 700; white-space: nowrap; }
.app-shell { width: min(980px, calc(100% - 2rem)); margin: 1.25rem auto 3rem; display: grid; gap: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: clamp(1.1rem, 3vw, 1.75rem); }
.eyebrow { margin: 0; color: var(--primary); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 800; }
h1, h2 { letter-spacing: -.025em; }
h2 { margin: .2rem 0 .35rem; }
p { line-height: 1.55; }
.tracker-heading, .section-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.tracker-heading p { margin: 0; color: var(--muted); }
.badge { border-radius: 999px; padding: .45rem .75rem; font-size: .75rem; font-weight: 800; white-space: nowrap; }
.badge.idle { background: #e2e8f0; color: #475569; }
.badge.recording { background: #dcfce7; color: #166534; animation: pulse 1.5s infinite; }
.badge.paused { background: #fef3c7; color: #92400e; }
.badge.saved { background: #dbeafe; color: #1e40af; }
@keyframes pulse { 50% { opacity: .55; } }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; margin: 1.35rem 0; }
.metrics div { background: #f8fafc; border: 1px solid var(--line); border-radius: 14px; padding: .85rem; }
.metrics span { display: block; color: var(--muted); font-size: .75rem; margin-bottom: .25rem; }
.metrics strong { font-size: 1.15rem; }
.button-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.button { border: 0; border-radius: 12px; padding: .9rem 1rem; cursor: pointer; font-weight: 800; transition: transform .15s, opacity .15s, background .15s; text-decoration: none; text-align: center; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.primary { background: var(--primary); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--primary-dark); }
.button.danger { background: var(--danger); color: #fff; }
.button.danger:hover:not(:disabled) { background: var(--danger-dark); }
.button.secondary { background: #e2e8f0; color: #1e293b; }
.button.small { padding: .55rem .8rem; font-size: .8rem; }
.button.wide { width: 100%; }
.message-box { min-height: 1.5rem; margin-top: .9rem; font-size: .9rem; color: var(--muted); }
.message-box.error { color: var(--danger); }
.message-box.success { color: var(--success); }
.message-box.warning { color: var(--warning); }
.privacy-note, .small-note { color: var(--muted); font-size: .82rem; margin: .75rem 0 0; }
.map { width: 100%; height: min(62vh, 560px); min-height: 360px; border-radius: 14px; background: #dbe3ee; margin-top: 1rem; overflow: hidden; }
.trip-summary { color: var(--muted); margin-top: .6rem; }
.icon-button { border: 0; background: #e2e8f0; width: 2.25rem; height: 2.25rem; border-radius: 999px; cursor: pointer; font-size: 1.5rem; line-height: 1; }
.hidden { display: none !important; }
.trip-list { display: grid; gap: .65rem; margin-top: 1rem; }
.trip-item { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border: 1px solid var(--line); border-radius: 14px; padding: .85rem; }
.trip-item strong, .trip-item span { display: block; }
.trip-item span { color: var(--muted); font-size: .82rem; margin-top: .18rem; }
.empty-state { color: var(--muted); }
.alert { border-radius: 14px; padding: .9rem 1rem; border: 1px solid; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.warning { background: #fffbeb; border-color: #fde68a; color: #854d0e; }
.alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert ul { margin-bottom: 0; }
.installer-body { display: grid; place-items: center; padding: 1rem; }
.installer-shell { width: min(780px, 100%); }
.login-shell { width: min(430px, 100%); }
.installer-card h1, .login-card h1 { margin: .25rem 0; }
.installer-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.25rem; }
.field { display: grid; gap: .4rem; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 750; font-size: .88rem; }
.field input { width: 100%; border: 1px solid #cbd5e1; border-radius: 11px; padding: .78rem .85rem; background: #fff; color: var(--text); }
.field input:focus { outline: 3px solid rgba(37, 99, 235, .15); border-color: var(--primary); }
.field small { color: var(--muted); line-height: 1.4; }

.permission-dialog { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 1rem; background: rgba(15, 23, 42, .72); }
.permission-dialog-card { width: min(520px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: clamp(1.25rem, 4vw, 2rem); box-shadow: 0 24px 70px rgba(15, 23, 42, .28); }
.permission-dialog-card h2 { margin: .3rem 0 .55rem; }
.permission-dialog-card > p { margin-top: .35rem; }
.permission-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 1.1rem; }
.permission-recovery { margin-top: 1rem; border: 1px solid #fecaca; border-radius: 14px; padding: .9rem 1rem; background: #fef2f2; color: #991b1b; }
.permission-recovery ol { margin: .65rem 0 0; padding-left: 1.25rem; }
.permission-recovery li + li { margin-top: .35rem; }
.location-status { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.15rem; border: 1px solid var(--line); border-radius: 14px; padding: .8rem .9rem; }
.location-status > div { min-width: 0; }
.location-status-label { display: block; color: var(--muted); font-size: .75rem; margin-bottom: .15rem; }
.location-status.permission-granted { background: #f0fdf4; border-color: #bbf7d0; }
.location-status.permission-granted strong { color: #166534; }
.location-status.permission-needed { background: #eff6ff; border-color: #bfdbfe; }
.location-status.permission-needed strong { color: #1e40af; }
.location-status.permission-denied { background: #fef2f2; border-color: #fecaca; }
.location-status.permission-denied strong { color: #991b1b; }
.location-status.permission-unavailable { background: #fffbeb; border-color: #fde68a; }
.location-status.permission-unavailable strong { color: #854d0e; }
body.permission-open { overflow: hidden; }

@media (max-width: 640px) {
    .site-header { align-items: flex-start; }
    .metrics { grid-template-columns: 1fr; }
    .button-row { grid-template-columns: 1fr; }
    .installer-form { grid-template-columns: 1fr; }
    .trip-item { align-items: flex-start; }
    .map { min-height: 430px; }
    .permission-actions { grid-template-columns: 1fr; }
    .location-status { align-items: stretch; flex-direction: column; }
    .location-status .button { width: 100%; }
}
