:root {
  color-scheme: dark;
  --bg: #10141a;
  --panel: #1a222d;
  --panel-2: #121820;
  --border: #2e3948;
  --text: #f1f4f8;
  --muted: #9eabbc;
  --blue: #3f82db;
  --blue-hover: #5593e3;
  --green: #52c78a;
  --orange: #f0a44b;
  --red: #ef6b72;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { border: 1px solid var(--border); border-radius: 7px; padding: .68rem 1rem; background: #222c39; color: var(--text); cursor: pointer; }
button:hover { border-color: #4a5b70; background: #293647; }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--blue); border-color: var(--blue); font-weight: 700; }
.primary:hover { background: var(--blue-hover); }
.full { width: 100%; }
.quiet { background: transparent; }
.warning { color: #ffd59b; }
.danger { color: #ffacb0; }
.subtle { color: var(--muted); margin-left: .7rem; }
.subtle.block { display: block; margin: -.35rem 0 1rem; }
.eyebrow { color: #82aee9; font-size: .75rem; letter-spacing: .12em; font-weight: 800; margin: 0 0 .25rem; }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: clamp(1.65rem, 4vw, 2.15rem); }
h2 { font-size: 1.15rem; }
.login-body { display: grid; place-items: start center; padding-top: 80px; }
.login-card { width: min(420px, calc(100% - 32px)); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 25px; box-shadow: 0 16px 50px rgba(0,0,0,.2); }
.login-card h1 { font-size: 2rem; margin: 16px 0 20px; }
.login-card label { display: block; margin: 0 0 13px; }
.login-card input { display: block; width: 100%; margin-top: 5px; border: 1px solid #344052; border-radius: 6px; background: #10151d; color: var(--text); padding: .62rem .7rem; }
.login-card .primary { margin-top: 6px; }
.forgot { display: block; color: #8fb4e7; text-align: center; text-decoration: none; margin-top: 14px; }
.error-banner, .notice { border: 1px solid #7d3e46; background: #351e24; color: #ffc4c8; border-radius: 7px; padding: .7rem .8rem; margin-bottom: 1rem; }
.topbar { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--border); background: #121821; }
.topbar > div { display: flex; align-items: center; gap: .65rem; }
.topbar form { margin: 0; }
.top-actions { display: flex; align-items: center; gap: .5rem; }
.top-link, .back-link { color: #9fc4f3; text-decoration: none; }
.back-link { margin-right: .6rem; }
.optional { color: var(--muted); font-size: .82rem; font-weight: 400; }
.dashboard-shell, .trip-shell { width: min(1220px, calc(100% - 32px)); margin: 30px auto 60px; }
.connect-panel { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem; padding: clamp(1.25rem, 3vw, 2rem); background: linear-gradient(135deg, #1c2734, #17202a); border: 1px solid var(--border); border-radius: 12px; }
.connect-panel p:not(.eyebrow) { color: var(--muted); margin: .45rem 0 0; }
.device-status { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; }
.device-status span { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #667386; margin-right: .45rem; }
.device-status.connected span { background: var(--green); box-shadow: 0 0 0 4px rgba(82,199,138,.12); }
.command-panel { display: flex; flex-wrap: wrap; gap: .55rem; margin: 15px 0; }
.notice { margin: 15px 0; border-color: #35557e; background: #17273b; color: #cfe2fa; }
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.count-pill { min-width: 2rem; padding: .18rem .55rem; border-radius: 999px; text-align: center; background: #273446; color: #bcd4f3; font-size: .85rem; }
.empty-state { color: var(--muted); padding: 32px 20px; text-align: center; }
.trip-list { display: grid; }
.trip-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 14px 18px; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.trip-row:first-child { border-top: 0; }
.trip-row:hover { background: #202b39; }
.trip-row input { width: 17px; height: 17px; }
.trip-row strong { display: block; }
.trip-row small { color: var(--muted); display: block; margin-top: 2px; }
.trip-row .arrow { color: #81a9dc; font-size: 1.25rem; }
.logger-trip-row { grid-template-columns: 1fr auto; }
.trip-actions { display: flex; gap: .5rem; align-items: center; }
dialog { width: min(800px, calc(100% - 30px)); border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.68); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; }
pre { max-height: 60vh; overflow: auto; background: #0d1218; border-radius: 6px; padding: 1rem; white-space: pre-wrap; }
.trip-title-row { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: 18px; }
.trip-title-actions { display: flex; gap: .55rem; align-items: center; }
.chart-panel { margin-bottom: 18px; }
.chart-panel canvas { display: block; width: 100%; padding: 12px 16px 18px; }
.metric { color: #cde0fa; font-weight: 700; }
.map-layout { display: grid; grid-template-columns: 270px 1fr; gap: 18px; }
.overlay-panel { padding: 18px; }
.overlay-list { display: grid; gap: .25rem; max-height: 360px; overflow: auto; }
.overlay-list label { display: flex; gap: .55rem; align-items: center; padding: .45rem 0; }
.legend { display: grid; gap: .55rem; border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; color: var(--muted); font-size: .87rem; }
.dot { width: 10px; height: 10px; display: inline-block; border-radius: 50%; margin-right: .45rem; }
.dot.real { background: #3f82db; }.dot.estimated { background: #f0a44b; }.dot.impact { background: #ef6b72; }
.map-panel { min-height: 620px; position: relative; }
#map { width: 100%; height: 620px; }
.map-message { padding: 1rem; color: #ffd59b; background: #352819; border-bottom: 1px solid #684f2e; }
.users-shell { width: min(860px, calc(100% - 32px)); margin: 30px auto 60px; }
.users-heading { margin-bottom: 18px; }
.users-card { margin-bottom: 18px; }
.invite-email-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; padding: 18px 20px; }
.invite-email-form label { color: var(--muted); }
.invite-email-form input { display: block; width: 100%; margin-top: 5px; border: 1px solid #344052; border-radius: 6px; background: #10151d; color: var(--text); padding: .62rem .7rem; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 14px 18px; border-top: 1px solid var(--border); }
.user-row:first-of-type { border-top: 0; }
.user-row strong, .user-row small { display: block; }
.user-row small { color: var(--muted); margin-top: 2px; }
.owner-badge { color: #bfe7ce; background: #193328; border-radius: 999px; padding: .25rem .65rem; font-size: .82rem; }
.invite-copy, .password-hint { color: var(--muted); }
.button-link { display: block; text-align: center; text-decoration: none; border-radius: 7px; padding: .68rem 1rem; color: var(--text); }
@media (max-width: 800px) {
  .content-grid, .map-layout { grid-template-columns: 1fr; }
  .connect-panel { grid-template-columns: 1fr; }
  .connect-panel button { width: 100%; }
  .device-status { grid-column: auto; }
  .map-panel, #map { min-height: 480px; height: 480px; }
  .topbar .subtle { display: none; }
  .invite-email-form { grid-template-columns: 1fr; }
  .invite-email-form button { width: 100%; }
  .user-row { align-items: flex-start; }
}

