:root {
  --bg: #f2f2f4;
  --surface: #ffffff;
  --surface-2: #f6f6f8;
  --ink: #0a0a0b;
  --muted: #6e6e73;
  --muted-2: #9a9aa0;
  --line: rgba(10, 10, 11, .09);
  --stage: #050505;
  --stage-ink: #f2f2f2;
  --stage-muted: #86868b;
  --red: #ff453a;
  --green: #3ecf7e;
  --amber: #ff9f0a;
  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(.4, 0, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #17171a;
    --surface-2: #202024;
    --ink: #f5f5f5;
    --muted: #98989d;
    --muted-2: #636366;
    --line: rgba(255, 255, 255, .09);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -.005em;
}

::selection { background: rgba(10, 132, 255, .25); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(133, 133, 138, .35); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(62, 207, 126, .5); }
  70% { box-shadow: 0 0 0 5px rgba(62, 207, 126, 0); }
}

.app { max-width: 560px; margin: auto; padding: 18px 16px 40px; }

.topbar {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.brand { display: flex; gap: 8px; align-items: center; border: 0; background: transparent; padding: 4px 2px; margin: -4px -2px; cursor: pointer; font: inherit; }
.brand:active { opacity: .7; }
.brand h1 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.brand-logo {
  display: block;
  width: 133px;
  height: 13px;
  background-color: var(--ink);
  -webkit-mask: url(/assets/tesla.svg) no-repeat left center / contain;
  mask: url(/assets/tesla.svg) no-repeat left center / contain;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.menu-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.menu-btn svg { width: 20px; height: 20px; }
.menu-btn:hover { background: var(--surface-2); }
.menu-btn[hidden] { display: none; }

/* ---------- Login ---------- */
.login-card {
  margin-top: 12vh;
  padding: 30px 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  animation: rise .4s var(--ease) both;
}
.login-logo {
  display: block;
  width: 182px;
  height: 18px;
  margin-bottom: 28px;
  background-color: var(--ink);
  -webkit-mask: url(/assets/tesla.svg) no-repeat left center / contain;
  mask: url(/assets/tesla.svg) no-repeat left center / contain;
}
.login-card h2 { margin: 0 0 8px; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.login-sub { color: var(--muted); line-height: 1.6; margin: 0 0 24px; font-size: 13.5px; }

form { display: grid; gap: 10px; }
label, .label { font-size: 12px; color: var(--muted); font-weight: 600; }

input {
  width: 100%;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  outline: 0;
  font: 16px inherit;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
input:focus { border-color: var(--muted-2); box-shadow: 0 0 0 3px var(--line); }

form button {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  background: var(--ink);
  color: var(--bg);
  font: 700 15px inherit;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: opacity .15s var(--ease), transform .15s var(--ease);
}
form button:hover { opacity: .88; }
form button:active { transform: scale(.985); }
.error { min-height: 1.2em; color: var(--red); margin: 0; font-size: 13px; font-weight: 600; }

/* ---------- Vehicle stage (always dark, like Tesla's own app) ---------- */
.vehicle-card {
  position: relative;
  overflow: hidden;
  padding: 20px 20px 24px;
  background: radial-gradient(120% 90% at 50% -10%, #1c1c1f 0%, var(--stage) 62%);
  border-radius: var(--radius-xl);
  color: var(--stage-ink);
  animation: rise .45s var(--ease) both;
}
.vehicle-head { display: flex; justify-content: space-between; align-items: flex-start; }
.model { font-size: 19px; font-weight: 700; letter-spacing: .06em; }
.state {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--stage-muted);
  font-weight: 500;
}
.state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: dot-pulse 2.2s infinite;
}
.update { font-size: 11px; color: #55555a; margin-top: 6px; }
.temperature { text-align: right; font-size: 12px; line-height: 1.8; color: var(--stage-muted); }
.temperature b { color: var(--stage-ink); font-weight: 600; }

.car {
  display: block;
  width: 104%;
  height: auto;
  max-height: 210px;
  object-fit: contain;
  margin: 4px 0 -6px -2%;
  -webkit-mask-image: radial-gradient(72% 68% at 50% 42%, #000 62%, transparent 100%);
  mask-image: radial-gradient(72% 68% at 50% 42%, #000 62%, transparent 100%);
}

.battery-gauge { margin-top: 4px; }
.gauge-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.gauge-level { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.gauge-level small { font-size: 14px; font-weight: 600; color: var(--stage-muted); margin-left: 1px; }
.gauge-range { text-align: right; font-size: 12.5px; color: var(--stage-muted); }
.gauge-range b { display: block; font-size: 15px; color: var(--stage-ink); font-weight: 600; }
.gauge-bar {
  position: relative;
  height: 8px;
  border-radius: 5px;
  background: var(--line);
  overflow: visible;
}
.gauge-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
  transition: width .6s var(--ease);
}
.gauge-bar.is-charging i { background: var(--green); }
/* 车辆卡片始终是深色底（和 Tesla App 一致），条形图需要单独的浅色配色 */
.vehicle-card .gauge-bar { background: rgba(255, 255, 255, .14); }
.vehicle-card .gauge-bar i { background: linear-gradient(90deg, #d8dee4, #ffffff); }
.vehicle-card .gauge-bar.is-charging i { background: linear-gradient(90deg, #1f8a4c, var(--green)); }

/* ---------- Quick actions: Tesla-style circular shortcuts ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 18px; }
.quick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 11.5px inherit;
  font-weight: 500;
  cursor: pointer;
}
.quick-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: transform .15s var(--ease), background .15s var(--ease);
}
.quick-icon svg { width: 21px; height: 21px; }
.quick:hover .quick-icon { transform: translateY(-2px); }
.quick:active .quick-icon { transform: scale(.94); }

/* ---------- Section headers ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 26px 2px 11px;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.section-head small { font-size: 12px; color: var(--muted-2); font-weight: 500; }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  animation: rise .4s var(--ease) both;
}

.board { padding: 18px; }
.board-top { display: flex; justify-content: space-between; align-items: center; }
.board-top h2 { font-size: 15.5px; margin: 0; font-weight: 700; }
.mock-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 4px 8px;
}
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 20px; gap: 8px; }
.metric-label { display: block; font-size: 11px; color: var(--muted); line-height: 1.4; font-weight: 500; }
.metric b { display: block; font-size: 19px; letter-spacing: -.02em; margin-top: 7px; font-weight: 700; }
.metric small { color: var(--muted); font-weight: 500; font-size: 11px; }

.reminder { padding: 18px; margin-top: 12px; }
.reminder h2 { display: flex; align-items: center; gap: 6px; font-size: 15.5px; margin: 0 0 9px; font-weight: 700; }
.reminder h2 svg { width: 15px; height: 15px; color: var(--amber); }
.reminder p { color: var(--muted); margin: 0 0 16px; line-height: 1.6; font-size: 13px; }
.route { display: grid; grid-template-columns: 1fr 20px 1fr; gap: 8px; align-items: center; }
.place {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
}
.place small { display: block; color: var(--muted); margin-bottom: 3px; font-weight: 500; font-size: 11px; }
.place b { font-weight: 600; font-size: 13.5px; }
.route-arrow { display: flex; align-items: center; justify-content: center; color: var(--muted-2); font-size: 16px; }
.route-arrow svg { width: 16px; height: 16px; }
.charge-bar { margin-top: 18px; }
.sub { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- Lists ---------- */
.recent { padding: 2px 16px; }
.row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border: 0; }
.row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.primary { font-weight: 600; }
.right { float: right; color: var(--muted); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 46px 10px; font-weight: 500; font-size: 13px; }
.empty::before {
  content: "";
  display: block;
  width: 30px;
  height: 30px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 1.5px dashed var(--muted-2);
}
.empty.big-empty::before { content: none; }
.empty.big-empty svg { width: 30px; height: 30px; margin: 0 auto 12px; color: var(--muted-2); display: block; }

.drive-row, .charge-row { padding: 15px 0; }
.drive-row { cursor: pointer; margin: 0 -16px; padding: 15px 16px; border-radius: var(--radius-sm); transition: background .15s var(--ease); }
.drive-row:hover { background: var(--surface-2); }
.drive-row:active { opacity: .8; }
.stat-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 9px; }
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.stat-chip svg { width: 12px; height: 12px; flex: none; color: var(--muted-2); }
.stat-chip:not(:first-child)::before { content: "·"; margin-right: 5px; color: var(--muted-2); }
.stat-chip.rate-valley { color: var(--green); font-weight: 600; }
.stat-chip.rate-peak { color: var(--amber); font-weight: 600; }
.stat-chip.rate-valley svg, .stat-chip.rate-peak svg { color: inherit; }

/* ---------- Drive detail ---------- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 4px 0 16px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 600 14px inherit;
  cursor: pointer;
}
.back-btn svg { width: 17px; height: 17px; }
.detail-date { font-size: 13px; color: var(--muted); font-weight: 500; margin: 0 2px 12px; }
.route-panel { padding: 18px; }
.route-svg { width: 100%; height: 96px; display: block; margin-bottom: 14px; color: var(--ink); }

/* ---------- Charts ---------- */
.chart-wrap { position: relative; height: 170px; padding: 16px 14px 10px; margin-bottom: 12px; }

/* ---------- Nav menu (hamburger + slide-in panel, Tesla App style) ---------- */
.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, .38);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease);
}
.menu-overlay.open { opacity: 1; pointer-events: auto; }
.menu-panel {
  width: 78%;
  max-width: 300px;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 18px) 10px 18px;
  background: var(--surface);
  box-shadow: -8px 0 32px rgba(0, 0, 0, .18);
  transform: translateX(100%);
  transition: transform .28s var(--ease);
}
.menu-overlay.open .menu-panel { transform: translateX(0); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font: 500 15px inherit;
  text-align: left;
  cursor: pointer;
}
.menu-item .icon { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; flex: none; color: var(--muted); }
.menu-item .icon svg { width: 20px; height: 20px; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.active { font-weight: 700; }
.menu-item.active .icon { color: var(--ink); }
.menu-divider { height: 1px; margin: 10px 6px; background: var(--line); }
.menu-logout, .menu-logout .icon { color: var(--red); }

@media (max-width: 380px) {
  .metrics { grid-template-columns: repeat(2, 1fr); row-gap: 16px; }
  .quick-grid { gap: 2px; }
  .quick-icon { width: 46px; height: 46px; }
  .app { padding-left: 12px; padding-right: 12px; }
}
