:root {
  --bg: #f4f4f4;
  --surface: #ffffff;
  --surface-2: #eeeeee;
  --text: #171a20;
  --muted: #5c5e62;
  --line: #d0d1d2;
  --primary: #171a20;
  --primary-dark: #000000;
  --danger: #b3261e;
  --success-bg: #f0f7f1;
  --success-text: #1d4f2a;
  --error-bg: #fff0ee;
  --error-text: #8a1f15;
  --shadow: none;
  font-family: "Helvetica Neue", Arial, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}

a {
  color: var(--primary-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 56px;
  padding: 10px 32px;
  border-bottom: 1px solid rgba(23, 26, 32, 0.08);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
}

.app-brand span,
.tesla-wordmark {
  color: #171a20;
  font-size: 18px;
  font-weight: 800;
}

.app-brand strong {
  color: #5c5e62;
  font-size: 13px;
  font-weight: 600;
}

.app-header nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
}

.app-header nav a {
  padding: 8px 12px;
  border-radius: 4px;
  color: #171a20;
  font-size: 13px;
  font-weight: 600;
}

.app-header nav a.active,
.app-header nav a:hover {
  background: rgba(23, 26, 32, 0.08);
  color: #0f172a;
  text-decoration: none;
}

.car-switcher {
  display: flex;
  align-items: end;
  gap: 8px;
  margin-left: auto;
}

.car-switcher label {
  min-width: 230px;
}

.car-switcher label span {
  font-size: 11px;
  text-transform: uppercase;
}

.car-switcher select {
  min-height: 36px;
  padding: 7px 9px;
}

.car-switcher .secondary-button {
  min-height: 36px;
  padding: 7px 12px;
}

.app-main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.15;
  font-weight: 700;
}

h2 {
  font-size: 18px;
}

p {
  color: var(--muted);
  line-height: 1.5;
  margin: 6px 0 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 6px 0 3px;
  font-size: 25px;
  font-weight: 700;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.8fr) minmax(0, 1.4fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 20px;
}

.panel.narrow {
  max-width: 760px;
}

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

.month-block {
  margin-bottom: 16px;
}

.month-block.compact {
  margin-bottom: 14px;
}

.month-block.compact:last-child,
.month-block:last-child {
  margin-bottom: 0;
}

.month-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.stack-form {
  display: grid;
  gap: 14px;
}

.wide {
  grid-column: 1 / -1;
}

.route-helper {
  display: grid;
  gap: 8px;
}

.route-status {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.route-status[data-type="success"] {
  color: var(--success-text);
}

.route-status[data-type="error"] {
  color: var(--error-text);
}

.route-map {
  width: 100%;
  height: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eeeeee;
}

.route-attribution {
  color: var(--muted);
  font-size: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

input:focus,
select:focus {
  outline: 3px solid rgba(23, 26, 32, 0.12);
  border-color: var(--primary);
}

.check-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--text);
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 4px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  color: #fff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

.secondary-button {
  color: var(--text);
  background: #eeeeee;
  border-color: #eeeeee;
}

.secondary-button:hover {
  background: #e2e3e3;
  text-decoration: none;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  background: #fff;
}

.data-table th,
.data-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #5c5e62;
  background: #f7f7f7;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table td {
  color: #253044;
  line-height: 1.35;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.inline-form {
  display: inline;
}

.link-button {
  border: 0;
  padding: 0;
  color: var(--danger);
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.table-search {
  max-width: 360px;
  margin-bottom: 12px;
}

.flash {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.flash.success {
  color: var(--success-text);
  background: var(--success-bg);
  border-color: #b7ebce;
}

.flash.error {
  color: var(--error-text);
  background: var(--error-bg);
  border-color: #ffc7bf;
}

.auth-body,
.vehicle-select-body {
  min-height: 100vh;
  color: #171a20;
  background: #f4f4f4;
}

.auth-header,
.vehicle-select-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 42px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
}

.auth-header span,
.vehicle-select-header nav,
.vehicle-select-header a {
  color: #171a20;
  font-size: 13px;
  font-weight: 700;
}

.vehicle-select-header nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: minmax(260px, 1fr) auto;
  place-items: center;
  padding: 92px 24px 52px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.25), rgba(244, 244, 244, 0.98)),
    url("https://images.unsplash.com/photo-1619767886558-efdc259cde1a?auto=format&fit=crop&w=1800&q=80") center 34% / cover no-repeat;
}

.auth-hero {
  text-align: center;
}

.auth-hero h1,
.vehicle-select-hero h1 {
  font-size: 42px;
  line-height: 1.05;
}

.auth-hero p,
.vehicle-select-hero p {
  margin-top: 8px;
  color: #393c41;
  font-size: 15px;
  font-weight: 600;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.vehicle-select-page {
  min-height: 100vh;
  padding: 92px 42px 48px;
  background:
    linear-gradient(rgba(244, 244, 244, 0.26), rgba(244, 244, 244, 0.96)),
    url("https://images.unsplash.com/photo-1560958089-b8a1929cea89?auto=format&fit=crop&w=1800&q=80") center 28% / cover no-repeat;
}

.vehicle-select-hero {
  min-height: 32vh;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.vehicle-select-form {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.vehicle-card {
  position: relative;
  display: grid;
  align-content: end;
  min-height: 210px;
  padding: 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  color: #171a20;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  backdrop-filter: blur(18px);
}

.vehicle-card::before {
  content: "";
  position: absolute;
  top: 44px;
  left: 18%;
  right: 18%;
  height: 52px;
  border-top: 3px solid rgba(23, 26, 32, 0.48);
  border-radius: 60% 60% 12px 12px;
}

.vehicle-card::after {
  content: "";
  position: absolute;
  top: 92px;
  left: 13%;
  right: 13%;
  height: 2px;
  background: rgba(23, 26, 32, 0.42);
}

.vehicle-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.vehicle-card:has(input:checked) {
  color: #fff;
  background: rgba(23, 26, 32, 0.92);
  border-color: rgba(23, 26, 32, 0.92);
}

.vehicle-card:has(input:checked)::before,
.vehicle-card:has(input:checked)::after {
  border-color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.58);
}

.vehicle-card-model {
  position: relative;
  z-index: 1;
  display: block;
  font-size: 26px;
  font-weight: 700;
}

.vehicle-card-trim {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 6px;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
}

.vehicle-select-actions {
  display: flex;
  justify-content: center;
  padding-top: 22px;
}

.vehicle-select-actions .primary-button,
.auth-panel .primary-button {
  min-width: 260px;
  border-radius: 4px;
}

.tesla-wordmark {
  letter-spacing: 0;
}

@media (max-width: 980px) {
  .metrics,
  .split-layout {
    grid-template-columns: 1fr 1fr;
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .vehicle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .car-switcher {
    width: 100%;
    margin-left: 0;
  }

  .car-switcher label {
    min-width: 0;
    flex: 1;
  }

  .app-header nav {
    justify-content: flex-start;
  }

  .app-main {
    padding: 18px 14px;
  }

  .auth-header,
  .vehicle-select-header {
    padding: 0 18px;
  }

  .auth-page,
  .vehicle-select-page {
    padding: 78px 16px 26px;
  }

  .auth-hero h1,
  .vehicle-select-hero h1 {
    font-size: 32px;
  }

  .vehicle-select-hero {
    min-height: 24vh;
  }

  .vehicle-grid {
    grid-template-columns: 1fr;
  }

  .vehicle-card {
    min-height: 150px;
  }

  .toolbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .grid-form {
    grid-template-columns: 1fr;
  }

  .metric strong {
    font-size: 21px;
  }

  h1 {
    font-size: 24px;
  }
}
