:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1b1e27;
  --muted: #8e939e;
  --line: #e4e7ee;
  --accent: #2f6fed;
  --accent-soft: #e7f0fe;
  --photo: #e7f0fc;
  --dash: #eef1f6;
  --shadow: 0 10px 28px rgba(28, 39, 64, 0.08);
  --radius: 22px;
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.boot { color: var(--muted); text-align: center; padding: 30vh 16px; }

.shell { min-height: 100vh; }
.sidebar { display: none; }
.workspace { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  background: rgba(245, 246, 248, 0.92);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--ink);
  flex: none;
}
.brand-name { font-weight: 700; letter-spacing: 0.04em; line-height: 1.1; }
.brand-vehicle {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  max-width: 60vw;
}
.brand-vehicle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--ink);
}

.banner {
  margin: 0 16px 8px;
  padding: 10px 14px;
  border-radius: 14px;
  background: #eceff4;
  color: #5c6370;
  font-size: 13px;
}
.due {
  margin: 0 16px 8px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: #1d4fbf;
  font-size: 13px;
}

.content {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 4px 16px calc(108px + var(--safe-bottom));
}

.hero-photo {
  width: 100%;
  height: 188px;
  border-radius: 20px;
  background: var(--photo);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #8eabda;
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; }
.hero-title { margin: 16px 0 0; font-size: 22px; letter-spacing: -0.02em; }
.hero-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.dash {
  margin-top: 18px;
  background: var(--dash);
  border-radius: 28px;
  padding: 16px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat {
  background: rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  padding: 12px 10px;
}
.stat b { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.stat strong { display: block; margin-top: 4px; font-size: 16px; letter-spacing: -0.03em; }
.chart-grid { display: grid; gap: 12px; margin-top: 12px; }
.chart-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 12px 12px 8px;
}
.chart-card h2, .section-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 650;
}
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 18px 0; }

.record {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
}
.record .when { font-weight: 650; }
.record .meta, .record .sub { color: var(--muted); font-size: 13px; }
.record .money { font-weight: 650; text-align: right; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 22px;
}
.section-head h2 { margin: 0; font-size: 16px; }
.section-head span { color: var(--muted); font-size: 13px; }

.form-kicker {
  width: fit-content;
  margin: 8px auto 18px;
  padding: 8px 16px;
  border-radius: 999px;
  background: #eceff3;
  color: #4d5562;
  font-size: 14px;
  font-weight: 600;
}
.station-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 4px 2px 14px;
  flex-wrap: wrap;
}
.field-label { color: var(--muted); font-size: 14px; }
.radio { position: relative; display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.radio input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.radio i { pointer-events: none; }
.radio i {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #c5cad3;
  display: grid;
  place-items: center;
}
.radio input:checked + i { border-color: var(--accent); }
.radio input:checked + i::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }

.pill {
  position: relative;
  display: block;
  min-height: 56px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}
.pill-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa1ac;
  display: grid;
}
.date-pill .date-face { display: block; padding: 24px 44px 8px 18px; font-weight: 650; }
.date-pill .date-glyph { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: #9aa1ac; display: grid; }
.date-pill input[type="date"] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; padding: 0; }
.pill select { appearance: none; padding-top: 22px; }
.pill input, .pill select, .pill textarea {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 999px;
  min-height: 54px;
  padding: 16px 16px 0 44px;
}
.pill textarea { padding-top: 22px; min-height: 72px; resize: vertical; border-radius: 22px; }
.pill .cap {
  position: absolute;
  left: 44px;
  top: 8px;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}
.pill input::placeholder, .pill textarea::placeholder { color: transparent; }
.pill:focus-within { border-color: #b9c7ee; }
.pill.readonly { background: #fbfcfe; }
.pill.readonly strong {
  display: block;
  padding: 24px 16px 8px 44px;
  font-weight: 600;
  font-size: 16px;
}
.tall { border-radius: 22px; }

.btn-primary {
  height: 56px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 8px 18px rgba(47, 111, 237, 0.28);
}
.btn-primary:disabled { opacity: 0.55; }
.btn-ghost {
  height: 44px;
  border-radius: 999px;
  color: var(--muted);
  padding: 0 8px;
}
.btn-danger { color: #b42338; }
.form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 0 12px; }
.chip {
  flex: none;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: #4d5562;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: white; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + var(--safe-bottom));
  backdrop-filter: blur(12px);
}
.tab {
  color: #9aa1ac;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 4px 0;
}
.tab.on { color: var(--accent); font-weight: 650; }
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(78px + var(--safe-bottom));
  z-index: 7;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 22px rgba(47, 111, 237, 0.35);
}
.view-info .fab,
.view-fuelForm .fab,
.view-expenseForm .fab,
.is-archived .fab { display: none; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 33, 0.38);
  z-index: 20;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 21;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(18px + var(--safe-bottom));
  max-height: min(80vh, 640px);
  overflow: auto;
  box-shadow: var(--shadow);
}
.grab {
  width: 40px; height: 4px; border-radius: 99px; background: #e1e4ea;
  margin: 2px auto 12px;
}
.sheet h3 { margin: 0 0 12px; font-size: 18px; }
.v-row, .menu-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  border-bottom: 1px solid #f1f3f6;
  text-align: left;
}
.v-main { flex: 1; min-width: 0; text-align: left; }
.v-name { display: block; font-weight: 650; }
.v-plate { display: block; color: var(--muted); font-size: 13px; }
.v-row.on { background: var(--accent-soft); border-radius: 14px; border-bottom-color: transparent; padding-inline: 10px; }
.star { color: #c5cad3; width: 36px; height: 36px; display: grid; place-items: center; }
.star.on { color: var(--accent); }
.badge {
  font-size: 12px;
  color: #667085;
  background: #eef0f3;
  border-radius: 999px;
  padding: 4px 8px;
}
.side-label {
  margin: 16px 8px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.empty {
  text-align: center;
  padding: 48px 12px;
}
.empty h2 { margin: 0 0 8px; font-size: 22px; }
.empty p { color: var(--muted); margin: 0 0 18px; }
.empty .btn-primary { width: min(100%, 280px); margin: 6px auto; }

.toast {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 40;
  background: #1b1e27;
  color: white;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  max-width: min(90vw, 420px);
}

@media (min-width: 800px) and (max-width: 1023px) {
  .hero-photo { height: 240px; }
  .chart-grid { grid-template-columns: 1fr 1fr; }
  .stats strong { font-size: 20px; }
}

@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 18px 12px 16px;
    overflow: auto;
  }
  .side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 750;
    letter-spacing: 0.04em;
    padding: 4px 8px 12px;
  }
  .side-nav { display: grid; gap: 4px; margin-top: 8px; }
  .side-link {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    color: #3d4451;
    text-align: left;
  }
  .side-link.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
  .side-add {
    margin-top: auto;
    height: 42px;
    border-radius: 12px;
    color: var(--accent);
    font-weight: 700;
    text-align: left;
    padding: 0 12px;
  }
  .menu-btn, .brand-vehicle, .tabbar, .fab { display: none !important; }
  .workspace { min-width: 0; }
  .topbar { padding: 18px 28px 0; background: transparent; }
  .content { width: min(1080px, calc(100% - 56px)); padding: 12px 0 48px; }
  .banner, .due { margin-left: 0; margin-right: 0; }
  .hero {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: center;
  }
  .hero-photo { height: 180px; }
  .chart-grid { grid-template-columns: 1fr 1fr; }
  .split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 22px;
    align-items: start;
  }
  .split .panel {
    background: transparent;
  }
  .split .form-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 28px;
    padding: 8px 16px 18px;
    position: sticky;
    top: 16px;
  }
  .sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 12vh;
    width: min(440px, calc(100vw - 48px));
    transform: translateX(-50%);
    border-radius: 24px;
    max-height: 70vh;
  }
}
