/* 版面：單欄、手機優先的保養手冊；里程與金額用窄體數字呈現，像儀表板讀數 */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --ink: #17222c;
  --muted: #5b6875;
  --line: #d5dbe2;
  --accent: #0f5f7d;
  --accent-ink: #ffffff;
  --ok: #1f7a4d;
  --soon: #a86200;
  --over: #b3261e;
  --ok-bg: #e1f2e9;
  --soon-bg: #fbecd2;
  --over-bg: #fbe2df;
  --font-body: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-num: ui-rounded, system-ui, -apple-system, "PingFang TC", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10171d; --surface: #1a232b; --ink: #e6ecf1; --muted: #9aa8b5; --line: #2e3a45;
    --accent: #5db6d6; --accent-ink: #08202b;
    --ok: #6fd3a0; --soon: #f0b65a; --over: #ff8a80;
    --ok-bg: #173527; --soon-bg: #3b2c10; --over-bg: #421c19;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #10171d; --surface: #1a232b; --ink: #e6ecf1; --muted: #9aa8b5; --line: #2e3a45;
  --accent: #5db6d6; --accent-ink: #08202b;
  --ok: #6fd3a0; --soon: #f0b65a; --over: #ff8a80;
  --ok-bg: #173527; --soon-bg: #3b2c10; --over-bg: #421c19;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.6; }
#app { max-width: 720px; margin: 0 auto; padding: calc(20px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 16px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; font-weight: 700; text-wrap: balance; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
.sub, .meta { color: var(--muted); font-size: .875rem; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.banner { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between;
  background: var(--soon-bg); border: 1px solid var(--soon); border-radius: 10px; padding: 10px 14px; font-size: .9rem; }

.vehicles { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); }
.chip.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 500; }
.chip.add { background: transparent; border-style: dashed; color: var(--muted); }
.tag { font-size: .75rem; padding: 1px 7px; border-radius: 4px; background: var(--bg); color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.vhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; min-width: 0; }
.label { font-size: .8rem; color: var(--muted); }
.big { font-family: var(--font-num); font-size: 1.75rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.big small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.big.date { font-size: 1.35rem; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }

.pill { display: inline-block; font-size: .78rem; font-weight: 500; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.soon { background: var(--soon-bg); color: var(--soon); }
.pill.over { background: var(--over-bg); color: var(--over); }
.pill.none, .pill.off { background: var(--bg); color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--ink); font-weight: 700; border-bottom-color: var(--accent); }

.list { display: flex; flex-direction: column; gap: 10px; }
.row { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px; }
.row.s-over { border-left-color: var(--over); }
.row.s-soon { border-left-color: var(--soon); }
.row.s-ok { border-left-color: var(--ok); }
.rmain { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.rmain h3 { margin-right: auto; }
.rem { font-family: var(--font-num); font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.s-over .rem { color: var(--over); }
.s-soon .rem { color: var(--soon); }
.bar { height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.s-soon .bar i { background: var(--soon); }
.s-over .bar i { background: var(--over); }
.date, .odo, .cost { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
h3.date { font-size: 1.1rem; font-weight: 600; }
.odo { color: var(--muted); }
.cost { font-weight: 600; }
.items { display: flex; flex-wrap: wrap; gap: 6px; }
.item { font-size: .85rem; padding: 2px 10px; border-radius: 6px; background: var(--bg); }
.rowact { display: flex; gap: 16px; justify-content: flex-end; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grow { flex: 1; }
.btn { padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.btn.small { padding: 5px 12px; font-size: .875rem; white-space: nowrap; }
.link { background: none; border: 0; padding: 2px 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: .9rem; }
.link.danger { color: var(--over); }

.empty { text-align: left; background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 20px 16px;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

.ivrow { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ivrow label { display: flex; align-items: center; gap: 4px; min-width: 0; }
.ivrow label span { font-size: .8rem; color: var(--muted); white-space: nowrap; }
#ivform { display: flex; flex-direction: column; gap: 14px; }
input:not([type="checkbox"]):not([type="radio"]) { width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
@media (max-width: 480px) {
  .ivrow { grid-template-columns: 1fr 1fr; }
  .ivrow .iv-item { grid-column: 1 / -1; }
  .ivrow .link { grid-column: 1 / -1; justify-self: end; }
}

dialog { width: min(520px, calc(100% - 24px)); max-height: calc(100% - 24px); border: 1px solid var(--line); border-radius: 14px; padding: 0;
  background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(10, 16, 22, .55); }
dialog form { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field label, .field legend { font-size: .85rem; color: var(--muted); padding: 0; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 6px; }
.check { cursor: pointer; }
.check input { position: absolute; opacity: 0; }
.check span { display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: .9rem; color: var(--ink); }
.check input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.radio { display: inline-flex; gap: 6px; align-items: center; margin-right: 16px; color: var(--ink); font-size: 1rem; }
.err { color: var(--over); font-size: .9rem; min-height: 0; }
.err:empty { display: none; }

.foot { color: var(--muted); font-size: .8rem; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: .9rem; max-width: calc(100% - 32px);
  transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* ---------- v2：主畫面車體與選單 ---------- */
:root { --ev: #0d7a6f; --ev-bg: #d9f1ee; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ev: #6fd6c8; --ev-bg: #12322f; }
}
:root[data-theme="dark"] { --ev: #6fd6c8; --ev-bg: #12322f; }

.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line); flex: none; }
.hero { gap: 12px; }
.heroTop { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hero h2 { font-size: 1.5rem; line-height: 1.3; }
.kinds { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.pill.kind { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.pill.k-ev { background: var(--ev-bg); color: var(--ev); border-color: transparent; }
.photo { margin: 0; position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; background: #ffffff; }
.photo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.photobtn { position: absolute; right: 10px; bottom: 10px; background: #ffffff; color: #17222c; border-color: #c9d1d9; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
label.photo.empty { background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer;
  border: 2px dashed var(--line); color: var(--ink); font-weight: 500; }
label.photo.empty:hover { border-color: var(--accent); }
.ph-icon { font-size: 2rem; line-height: 1; color: var(--accent); }
.thumb { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: none; margin-left: -6px; }
.flabel { font-size: .85rem; color: var(--muted); }
.photopick { display: flex; gap: 12px; align-items: center; }
.pp-img { width: 120px; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--bg); display: flex; align-items: center; justify-content: center; flex: none; }
.pp-img img { width: 100%; height: 100%; object-fit: cover; }
.pp-act { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.nextitem { font-weight: 700; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.nextrem { font-family: var(--font-num); font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.nextrem.s-over { color: var(--over); }
.nextrem.s-soon { color: var(--soon); }
.big small { font-family: var(--font-body); }
.stat .link { font-size: .8rem; }
.tabs { overflow-x: auto; }
.tab { white-space: nowrap; }
select { font: inherit; color: inherit; width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.check span { display: inline-flex; align-items: center; gap: 6px; }
[hidden] { display: none !important; }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }
.check { position: relative; }

/* ---------- 正式版（PWA）追加 ---------- */
html { -webkit-text-size-adjust: 100%; }
button, .btn, .chip, .tab, label.photo { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.btn.small { min-height: 36px; }
.link { min-height: 32px; }
.foot { line-height: 1.7; }
.backup h3 { margin-bottom: 2px; }
.backup .actions { margin-top: 4px; }
.pill.ok, .pill.soon, .pill.over { font-weight: 700; }
dialog p { margin: 0; }
@media (max-width: 420px) { .tab { padding: 10px 6px; font-size: .95rem; } .tabs { gap: 2px; } }
