/* 차일지 — DESIGN.md 디자인 시스템.
 * 색·크기는 아래 토큰만 사용한다. 그림자·그라데이션·이모지 금지, 라이트 단일 모드. */
:root {
  --bg:            #FFFFFF;
  --surface:       #F6F7F9;
  --ink:           #191F28;
  --ink-secondary: #4E5968;
  --ink-muted:     #8B95A1;
  --border:        #E5E8EB;
  --accent:        #1A56DB;
  --accent-bg:     #EBF2FE;
  --warning:       #B45309;
  --warning-bg:    #FEF3C7;
  --danger:        #DC2626;
  --danger-bg:     #FEE2E2;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- 상단바 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 20px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
}
.topbar-title {
  font-size: 17px; font-weight: 700; color: var(--ink);
  background: none; border: none; padding: 8px 0; cursor: pointer;
  text-decoration: none; display: inline-block; letter-spacing: -0.01em;
}
.topbar-right { display: flex; align-items: center; gap: 4px; }
.topbar-nav a, .topbar-btn {
  color: var(--ink-secondary); text-decoration: none;
  font-size: 13px; font-weight: 500;
  padding: 8px; border-radius: 8px; white-space: nowrap;
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.btn, .chip, .part-row-main, .quick-btn, .topbar-btn, .topbar-nav a, .topbar-title,
.linklike, .history-del, .sched-row { transition: background-color 0.15s ease, color 0.15s ease; }
@media (hover: hover) {
  .topbar-nav a:hover, .topbar-btn:hover { background: var(--surface); }
  .part-row-main:hover, .sched-row:hover { background: var(--surface); }
}
.btn:active, .chip:active, .part-row-main:active, .quick-btn:active, .topbar-btn:active,
.topbar-nav a:active, .topbar-title:active, .linklike:active, .history-del:active, .sched-row:active { background: var(--surface); }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 20px 48px;
}

.loading { color: var(--ink-muted); text-align: center; padding: 40px 0; }

/* ---------- 카드 ---------- */
.card {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
}
.card h2 {
  font-size: 12px; margin: 0 0 8px; color: var(--ink-muted); font-weight: 500;
}
.card .big { font-size: 20px; font-weight: 700; }

/* ---------- 온보딩 ---------- */
.hero { text-align: center; padding: 48px 8px; }
.hero h1 { font-size: 20px; font-weight: 700; margin: 0 0 8px; }
.hero p { color: var(--ink-secondary); margin: 0 0 24px; }

/* ---------- 차 요약 ---------- */
.car-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.car-name { font-size: 17px; font-weight: 700; margin: 0; color: var(--ink); }
.car-sub { color: var(--ink-muted); font-size: 12px; margin: 2px 0 0; }
.odo-row { display: flex; align-items: baseline; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.odo-km { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.odo-unit { color: var(--ink-muted); font-size: 15px; }

/* ---------- D-day 배지 (DESIGN: 임박=warning, 초과=danger, 여유=텍스트만) ---------- */
.dday { font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--ink-secondary); }
.dday.b-warn { background: var(--warning-bg); color: var(--warning); padding: 3px 8px; border-radius: 6px; }
.dday.b-danger { background: var(--danger-bg); color: var(--danger); padding: 3px 8px; border-radius: 6px; }

/* ---------- 다가오는 일정 리스트 ---------- */
.sched-list { list-style: none; margin: 0; padding: 0; }
.sched-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 12px 0;
  background: none; border: none; border-bottom: 0.5px solid var(--border);
  cursor: pointer; color: var(--ink); font: inherit; font-size: 15px;
}
li:last-child > .sched-row { border-bottom: none; }
.sched-main { min-width: 0; }
.sched-name { font-weight: 500; }
.sched-sub { color: var(--ink-muted); font-size: 12px; }

/* ---------- 차 전환 ---------- */
.car-switch { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 8px; padding: 8px 12px; font-size: 13px; font-weight: 500;
  background: var(--bg); color: var(--ink); border: 0.5px solid var(--border);
  cursor: pointer; white-space: nowrap; font-family: inherit;
}
.car-switch .chip.active { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-bg); }

/* ---------- 소모품 리스트 ---------- */
.part-list { list-style: none; margin: 0; padding: 0; }
.part-row { display: flex; align-items: center; gap: 8px; border-bottom: 0.5px solid var(--border); }
li:last-child > .part-row { border-bottom: none; }
.part-row-main {
  flex: 1; min-width: 0;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  text-align: left; padding: 12px 0;
  background: none; border: none;
  cursor: pointer; color: var(--ink); font: inherit;
}
.part-main { min-width: 0; flex: 1; }
.part-name { font-weight: 500; font-size: 15px; }
.part-sub { color: var(--ink-muted); font-size: 12px; margin-top: 2px; }
.quick-btn {
  flex-shrink: 0; padding: 8px 12px; border-radius: 8px;
  border: 0.5px solid var(--border); color: var(--ink); background: var(--bg);
  font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit;
}

/* 상태 배지: soon=임박, overdue=초과, 나머지는 텍스트 */
.badge { flex-shrink: 0; font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--ink-secondary); }
.badge.soon { background: var(--warning-bg); color: var(--warning); padding: 3px 8px; border-radius: 6px; }
.badge.overdue { background: var(--danger-bg); color: var(--danger); padding: 3px 8px; border-radius: 6px; }
.badge.no-record, .badge.no-data, .badge.manual { color: var(--ink-muted); }

/* ---------- 프로그레스 바 (소모품 사용량) ---------- */
.progress { height: 4px; background: var(--surface); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; }

.section-title {
  font-size: 12px; font-weight: 500; color: var(--ink-muted);
  margin: 24px 0 8px;
}

/* ---------- 폼 ---------- */
.form-view h1 { font-size: 20px; font-weight: 700; margin: 4px 0 16px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; height: 48px; padding: 0 12px;
  border: 0.5px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--ink);
  font-size: 16px; font-family: inherit; /* iOS 줌 방지 */
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg); /* 유일하게 허용된 box-shadow */
}
.field .hint { font-size: 12px; color: var(--ink-muted); margin-top: 4px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-block; width: 100%; height: 48px;
  padding: 0 16px; border-radius: 8px; border: none;
  background: var(--accent); color: #FFFFFF;
  font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit;
  line-height: 48px; text-align: center;
}
.btn.secondary {
  background: var(--bg); color: var(--ink);
  border: 0.5px solid var(--border); line-height: 46px;
}
.btn.danger-outline { background: var(--bg); color: var(--danger); border: 0.5px solid var(--danger); line-height: 46px; }
.btn.small { width: auto; height: 40px; line-height: 38px; padding: 0 14px; font-size: 14px; }
.btn + .btn { margin-top: 8px; }

.back-btn {
  background: none; border: none; color: var(--accent);
  font-size: 14px; font-weight: 500; padding: 4px 0; cursor: pointer;
  margin-bottom: 4px; font-family: inherit;
}
.linklike {
  background: none; border: none; color: var(--accent); font: inherit;
  cursor: pointer; padding: 0; text-decoration: none;
}

/* ---------- 기록 이력 ---------- */
.history-item { padding: 12px 0; border-bottom: 0.5px solid var(--border); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.history-item:last-child { border-bottom: none; }
.history-main { font-size: 14px; }
.history-sub { font-size: 12px; color: var(--ink-muted); }
.history-del {
  background: none; border: none; color: var(--ink-muted); cursor: pointer;
  font-size: 13px; padding: 12px 8px; margin: -12px -8px -12px 0;
  align-self: center; font-family: inherit;
}

.notice { font-size: 12px; color: var(--ink-muted); margin-top: 8px; }
.empty { color: var(--ink-muted); text-align: center; padding: 20px 0; font-size: 14px; }

/* ---------- 설정 ---------- */
.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 0.5px solid var(--border); font-size: 15px;
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row input { width: 20px; height: 20px; accent-color: var(--accent); }

.foot {
  max-width: 640px; margin: 0 auto; padding: 0 20px 32px;
  color: var(--ink-muted); font-size: 12px; text-align: center;
}
.foot a { color: var(--ink-muted); }

/* ---------- 토스트 ---------- */
.msg-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 12px 20px; border-radius: 8px; font-size: 14px; font-weight: 500;
  z-index: 50;
  display: flex; align-items: center; white-space: nowrap;
}
.msg-toast-action {
  background: none; border: none; cursor: pointer;
  color: inherit; font: inherit; font-weight: 700; text-decoration: underline;
  margin-left: 12px; padding: 4px; font-family: inherit;
}
