:root {
  color-scheme: light;
  --ink: #17251f;
  --muted: #6e7b74;
  --paper: #f3f1ea;
  --panel: #fffdf8;
  --forest: #173e32;
  --forest-deep: #10251f;
  --accent: #e86f3b;
  --line: #deddd5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); }
button { font: inherit; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 4px; color: #789084; font-size: 11px; font-weight: 800; letter-spacing: .16em; }

.loading-screen, .login-view { min-height: 100%; display: grid; place-items: center; }
.loading-screen { background: var(--forest-deep); color: #d9e4de; align-content: center; gap: 16px; }
.loading-mark, .mini-mark { border: 3px solid #dce9e1; border-top-color: var(--accent); border-radius: 50%; }
.loading-mark { width: 40px; height: 40px; animation: spin .9s linear infinite; }
.loading-screen p { font-size: 14px; letter-spacing: .04em; }

.login-view {
  padding: 24px;
  background: radial-gradient(circle at 20% 5%, #315b4c 0, transparent 35%), linear-gradient(145deg, #10251f, #183a30 60%, #0d211b);
}
.login-card { width: min(430px, 100%); padding: 52px 48px 42px; background: #fffdf8; border-radius: 28px; box-shadow: 0 32px 90px #06110d99; text-align: center; }
.brand-mark { position: relative; width: 74px; height: 74px; margin: 0 auto 28px; border: 2px solid #cbd6cf; border-radius: 50%; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; inset: 15px; border: 3px solid var(--forest); border-radius: 50% 50% 50% 6px; transform: rotate(-45deg); }
.brand-mark::after { inset: 31px; border: 0; background: var(--accent); border-radius: 50%; }
.login-card h1 { margin: 3px 0 12px; font-family: Georgia, serif; font-size: 46px; font-weight: 500; letter-spacing: -.04em; }
.login-copy { margin: 0 auto 30px; max-width: 310px; color: var(--muted); line-height: 1.55; }
.google-button { width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 20px; color: #fff; background: var(--forest); border: 0; border-radius: 12px; font-weight: 750; cursor: pointer; transition: transform .2s, background .2s; }
.google-button:hover { background: #215242; transform: translateY(-1px); }
.google-button:disabled { cursor: wait; opacity: .7; transform: none; }
.google-button svg { width: 20px; height: 20px; padding: 2px; background: white; border-radius: 3px; }
.privacy-note { margin: 22px 0 0; color: #8b938f; font-size: 12px; }
.login-error, .data-error { min-height: 20px; color: #a53d26; font-size: 13px; }

.app-view { height: 100%; display: grid; grid-template-rows: auto 1fr; }
.topbar { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 15px 28px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand-row, .account-row { display: flex; align-items: center; gap: 14px; }
.brand-row h1 { margin: 0; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.mini-mark { width: 42px; height: 42px; border-color: var(--forest); border-top-color: var(--accent); }
.account-row { color: var(--muted); font-size: 13px; }
.menu-button { display: none; color: var(--forest); background: transparent; border: 1px solid #ccd4cf; border-radius: 9px; padding: 8px 11px; font-weight: 750; cursor: pointer; }
.quiet-button { padding: 8px 12px; color: var(--forest); background: transparent; border: 1px solid #ccd4cf; border-radius: 9px; cursor: pointer; }

.workspace { min-height: 0; display: grid; grid-template-columns: 330px 1fr; gap: 14px; padding: 14px; }
.status-panel, .map-shell { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; box-shadow: 0 8px 24px #25392e0c; }
.status-panel { padding: 28px 24px 22px; overflow-y: auto; }
.status-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.status-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
.state-badge { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 999px; background: #eef0ed; color: #66726c; font-size: 12px; font-weight: 750; }
.state-badge i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state-badge.online { background: #e0f3e8; color: #167245; }
.state-badge.stale { background: #fff0cd; color: #966710; }
.state-badge.offline { background: #f6dfdb; color: #a34632; }

.speed-card { margin: 28px 0 24px; padding: 22px; background: var(--forest-deep); color: white; border-radius: 18px; }
.speed-card > span { font-family: Georgia, serif; font-size: 64px; line-height: .9; letter-spacing: -.05em; }
.speed-card small { margin-left: 5px; color: #a8b9b1; font-weight: 700; }
.speed-card p { margin: 14px 0 0; color: #b8c8c0; font-size: 12px; }
.trip-picker { display: grid; gap: 13px; margin: 0 0 22px; }
.delete-trip-button { padding: 10px 12px; color: #9d3e2e; background: #fff6f2; border: 1px solid #e9b9ad; border-radius: 10px; font-weight: 700; cursor: pointer; }
.delete-trip-button:disabled { color: #9c8b85; background: #f2eeee; border-color: #e5dcd8; cursor: not-allowed; }
.trip-picker label { display: block; margin: 0 0 7px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.trip-picker select, .trip-picker input { width: 100%; min-height: 43px; padding: 10px 12px; color: var(--ink); background: #f4f5f1; border: 1px solid #d5dad5; border-radius: 10px; font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; }
.trip-picker select { padding-right: 36px; }
.trip-picker select:disabled { color: var(--muted); cursor: default; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; margin: 0; border-top: 1px solid var(--line); }
.metrics div { padding: 15px 4px; border-bottom: 1px solid var(--line); }
.metrics div:nth-child(odd):not(.wide) { border-right: 1px solid var(--line); }
.metrics div:nth-child(even) { padding-left: 18px; }
.metrics .wide { grid-column: 1 / -1; }
.metrics dt { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.metrics dd { margin: 5px 0 0; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.panel-actions { display: flex; gap: 9px; margin-top: 22px; }
.primary-button, .icon-button { border: 0; border-radius: 11px; cursor: pointer; }
.primary-button { flex: 1; padding: 12px 15px; color: white; background: var(--forest); font-weight: 750; }
.icon-button { width: 44px; color: var(--forest); background: #e9eee9; font-size: 22px; }
.icon-button.spinning { animation: spin .8s linear infinite; }
.shutdown-button { width: 100%; margin-top: 10px; padding: 11px 14px; color: #9d3e2e; background: #fff6f2; border: 1px solid #e9b9ad; border-radius: 11px; font-weight: 750; cursor: pointer; }
.shutdown-button:disabled { color: #9c8b85; background: #f2eeee; border-color: #e5dcd8; cursor: wait; }
.usage-summary { margin-top: 22px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.section-heading h3 { margin: 0; font-family: Georgia, serif; font-size: 21px; font-weight: 500; }
.small-note { color: var(--muted); font-size: 11px; text-align: right; }
.usage-today { margin: 13px 0 3px; color: var(--forest); font-size: 15px; font-weight: 800; }
.usage-month { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.usage-details { margin-top: 13px; color: var(--muted); font-size: 12px; }
.usage-details summary { color: var(--forest); font-weight: 700; cursor: pointer; }
.usage-details table { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: 10px; }
.usage-details th, .usage-details td { padding: 6px 2px; border-bottom: 1px solid #ebe9e2; text-align: right; white-space: nowrap; }
.usage-details th:first-child, .usage-details td:first-child { text-align: left; }
.camera-summary { margin-top: 22px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.camera-button { width: 100%; margin-top: 13px; padding: 11px 14px; color: white; background: var(--forest); border: 0; border-radius: 11px; font-weight: 750; cursor: pointer; }
.camera-button:disabled { opacity: .65; cursor: wait; }
.camera-preview-button { display: block; width: 100%; margin-top: 12px; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.camera-preview { display: block; width: 100%; max-height: 190px; object-fit: cover; border: 1px solid var(--line); border-radius: 10px; background: #e9eee9; }
.camera-list { display: grid; gap: 5px; margin-top: 9px; }
.camera-item { padding: 7px 0; color: var(--forest); background: transparent; border: 0; border-bottom: 1px solid #ebe9e2; font-size: 11px; font-weight: 650; text-align: left; cursor: pointer; }
.settings-modal { width: min(430px, calc(100% - 28px)); padding: 0; color: var(--ink); background: transparent; border: 0; border-radius: 20px; box-shadow: 0 25px 70px #07140f80; }
.settings-modal::backdrop { background: #10251fa8; }
.settings-card { padding: 25px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; }
.settings-card h2 { margin: 2px 0 0; font-family: Georgia, serif; font-size: 26px; font-weight: 500; }
.settings-copy { margin: 16px 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.settings-toggle { display: flex; gap: 11px; align-items: center; margin: 11px 0; padding: 12px; background: #f3f5f1; border: 1px solid #dce1dc; border-radius: 10px; font-weight: 700; cursor: pointer; }
.settings-toggle input { width: 18px; height: 18px; accent-color: var(--forest); }
.modal-actions { display: flex; gap: 9px; margin-top: 17px; }
.modal-actions .primary-button { flex: 1; }
.photo-modal { width: min(1100px, calc(100% - 24px)); height: min(900px, calc(100% - 24px)); padding: 44px 12px 12px; background: #101411; border: 0; border-radius: 16px; }
.photo-modal::backdrop { background: #08110ddd; }
.photo-modal img { width: 100%; height: 100%; object-fit: contain; }
.photo-close-button { position: absolute; z-index: 1; top: 8px; right: 10px; width: 30px; height: 30px; color: white; background: #ffffff22; border: 1px solid #ffffff66; border-radius: 50%; font-size: 23px; line-height: 1; cursor: pointer; }

.map-shell { position: relative; min-height: 420px; }
#map { position: absolute; inset: 0; background: #d8dfd8; }
.map-style-control { position: absolute; z-index: 500; top: 16px; left: 50%; transform: translateX(-50%); display: flex; padding: 4px; background: #fffefaf0; backdrop-filter: blur(10px); border: 1px solid #d9ddd7; border-radius: 11px; box-shadow: 0 5px 16px #23352c26; }
.map-style { padding: 8px 13px; color: #526159; background: transparent; border: 0; border-radius: 8px; font-size: 12px; font-weight: 750; cursor: pointer; }
.map-style.active { color: white; background: var(--forest); }
.map-legend { position: absolute; z-index: 500; left: 16px; bottom: 16px; padding: 8px 11px; background: #fffefae8; border-radius: 8px; color: #526159; font-size: 11px; box-shadow: 0 4px 12px #23352c1f; }
.map-legend span { display: inline-block; width: 22px; margin-right: 6px; border-top: 4px solid var(--accent); border-radius: 2px; vertical-align: middle; }
.vehicle-icon-wrap { background: transparent; border: 0; }
.vehicle-icon { position: relative; width: 44px; height: 44px; background: var(--forest); border: 4px solid white; border-radius: 50%; box-shadow: 0 5px 15px #13261e70; }
.vehicle-icon::before { content: ""; position: absolute; top: -11px; left: 13px; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 11px solid white; }
.vehicle-icon span { position: absolute; inset: 11px; background: var(--accent); border-radius: 50%; }
.vehicle-speed { position: absolute; top: 51px; left: 50%; transform: translateX(-50%); padding: 3px 6px; color: var(--forest-deep); background: #fffefae8; border: 1px solid #d9ddd7; border-radius: 7px; box-shadow: 0 2px 7px #23352c30; font: 700 10px/1 Inter, ui-sans-serif, system-ui, sans-serif; white-space: nowrap; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .app-view { display: block; height: auto; min-height: 100%; }
  .topbar { position: relative; min-height: 68px; padding: 11px 14px; gap: 10px; }
  .mini-mark { width: 35px; height: 35px; }
  .brand-row h1 { font-size: 20px; }
  .brand-row { min-width: 0; }
  .brand-row h1 { white-space: nowrap; }
  .account-row { display: none; position: absolute; z-index: 1000; top: calc(100% + 7px); right: 8px; width: min(280px, calc(100vw - 16px)); padding: 10px; align-items: stretch; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px #25392e2b; }
  .account-row.open { display: flex; }
  .account-row span { padding: 5px 3px; font-size: 12px; overflow-wrap: anywhere; }
  .account-row .quiet-button { width: 100%; text-align: left; }
  .menu-button { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto minmax(470px, 65vh); padding: 8px; gap: 8px; }
  .status-panel { padding: 20px 18px; }
  .speed-card { margin: 18px 0; padding: 17px 20px; }
  .speed-card > span { font-size: 48px; }
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .metrics div, .metrics div:nth-child(even) { padding: 11px 8px; border-right: 1px solid var(--line); }
  .metrics .wide { grid-column: span 2; }
  .login-card { padding: 42px 25px 34px; }
}

@media (max-width: 480px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics .wide { grid-column: 1 / -1; }
  .map-shell { min-height: 480px; }
}
