/* ===== 차계부 디자인 시스템 ===== */
:root {
  --bg: #F4F5F7;
  --card: #FFFFFF;
  --navy: #10192E;
  --navy-2: #1B2740;
  --mint: #17C3A2;
  --mint-dark: #0FA88A;
  --mint-tint: #E4F9F4;
  --orange: #FF9457;
  --orange-tint: #FFF1E7;
  --text-1: #16181D;
  --text-2: #6B7280;
  --text-3: #9AA1AC;
  --line: #ECEDF0;
  --danger: #E4574C;
  --danger-tint: #FDECEA;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(16,25,46,0.04), 0 8px 24px rgba(16,25,46,0.05);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: #DEE1E6;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: var(--text-1);
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(0,0,0,0.08);
}

@media (min-width: 640px) {
  body { padding: 24px 0; }
  #app { min-height: calc(100vh - 48px); border-radius: 28px; overflow: hidden; }
}

/* ===== 상단바 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 20px 14px;
  background: var(--bg);
}
.topbar-title { display: flex; align-items: center; gap: 8px; }
.app-name { font-size: 21px; font-weight: 800; letter-spacing: -0.3px; color: var(--navy); }
.admin-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--mint-dark);
  background: var(--mint-tint);
  padding: 4px 9px;
  border-radius: 100px;
}
.lock-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  box-shadow: var(--shadow-card);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  cursor: pointer;
}
.lock-btn svg { width: 19px; height: 19px; }
.lock-btn.is-admin { color: var(--mint-dark); }
.hidden { display: none !important; }

/* ===== 본문 ===== */
.main-content {
  flex: 1;
  padding: 4px 20px calc(96px + var(--safe-bottom));
  overflow-y: auto;
}
.screen { animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  margin: 24px 0 12px;
}
.section-title:first-child { margin-top: 8px; }

.month-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px;
  margin: 22px 0 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-2);
}
.month-label:first-of-type { margin-top: 4px; }
.month-label-sum {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-3);
}

.year-select-row { margin: 6px 0 2px; }
.year-select {
  width: auto;
  display: inline-block;
  font-weight: 700;
  font-size: 15px;
  color: var(--navy);
  padding: 9px 32px 9px 14px;
  border-radius: 100px;
  border: 1.5px solid var(--line);
  background: var(--card);
}

/* ===== 카드 ===== */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
  margin-bottom: 12px;
}

/* ===== 홈: 차량 헤더 ===== */
.vehicle-header {
  padding: 6px 2px 14px;
}
.vehicle-nickname { font-size: 22px; font-weight: 800; color: var(--navy); letter-spacing: -0.3px; }
.vehicle-type { font-size: 14px; color: var(--text-2); margin-top: 2px; }

/* ===== 히어로 카드 (연비) ===== */
.hero-card {
  background: linear-gradient(155deg, var(--navy) 0%, var(--navy-2) 100%);
  border-radius: var(--radius-lg);
  padding: 22px;
  color: #fff;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: "";
  position: absolute;
  right: -40px; top: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(23,195,162,0.25), transparent 70%);
}
.hero-row { display: flex; justify-content: space-between; gap: 10px; position: relative; z-index: 1; }
.hero-metric { flex: 1; }
.hero-label { font-size: 12.5px; color: rgba(255,255,255,0.55); margin-bottom: 6px; }
.hero-value { font-size: 24px; font-weight: 800; letter-spacing: -0.3px; }
.hero-value .unit { font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.6); margin-left: 3px; }
.hero-divider { width: 1px; background: rgba(255,255,255,0.12); margin: 2px 6px; }
.hero-hint {
  margin-top: 14px;
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 8px 10px;
  position: relative; z-index: 1;
}

/* ===== 통계 카드 그리드 ===== */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.stat-box {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 14px 15px;
  box-shadow: var(--shadow-card);
}
.stat-box-label { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.stat-box-value { font-size: 18px; font-weight: 800; color: var(--text-1); }
.stat-box-value .unit { font-size: 12px; font-weight: 600; color: var(--text-3); }

/* ===== 리스트 아이템 ===== */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
  cursor: default;
}
.list-item:last-child { border-bottom: none; }
.list-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--mint-tint);
  color: var(--mint-dark);
}
.list-icon.maint { background: var(--orange-tint); color: var(--orange); }
.list-icon svg { width: 19px; height: 19px; }
.list-body { flex: 1; min-width: 0; }
.list-title { font-size: 14.5px; font-weight: 700; color: var(--text-1); }
.list-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.list-value { text-align: right; flex-shrink: 0; }
.list-amount { font-size: 14.5px; font-weight: 700; color: var(--text-1); }
.list-amount-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:active { background: #FAFAFB; }

.badge-dday {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--orange-tint);
  color: var(--orange);
  margin-top: 3px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
}
.empty-state-icon { font-size: 32px; margin-bottom: 10px; opacity: 0.6; }
.empty-state-title { font-size: 14.5px; font-weight: 700; color: var(--text-2); margin-bottom: 4px; }
.empty-state-desc { font-size: 13px; color: var(--text-3); line-height: 1.5; }

/* ===== 상단 요약 바 (주유/정비 화면) ===== */
.summary-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  margin: 4px 0 16px;
}
.summary-bar-label { font-size: 13px; color: var(--text-2); }
.summary-bar-value { font-size: 17px; font-weight: 800; color: var(--navy); }

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 6px;
}
.screen-header-title { font-size: 21px; font-weight: 800; color: var(--navy); letter-spacing: -0.3px; }

/* ===== FAB / 추가 버튼 ===== */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(88px + var(--safe-bottom));
  width: 54px; height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--mint);
  color: #fff;
  box-shadow: 0 8px 20px rgba(23,195,162,0.4);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 15;
  transition: transform .15s ease;
}
.fab:active { transform: scale(0.93); }
.fab svg { width: 24px; height: 24px; }
@media (min-width: 640px) { .fab { right: calc(50% - 240px + 20px); } }

/* ===== 하단 네비게이션 ===== */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + var(--safe-bottom));
  z-index: 30;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  border: none;
  background: none;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--mint-dark); }

/* ===== 버튼 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 15px;
  padding: 14px 18px;
  cursor: pointer;
  width: 100%;
  min-height: 48px;
  transition: opacity .15s ease, transform .1s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--mint); color: #fff; }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-ghost { background: var(--bg); color: var(--text-1); }
.btn-danger { background: var(--danger-tint); color: var(--danger); }
.btn-outline { background: transparent; color: var(--text-2); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.55; pointer-events: none; }
.btn-sm { padding: 9px 14px; font-size: 13px; min-height: 36px; width: auto; }

.btn-row { display: flex; gap: 10px; margin-top: 18px; }
.btn-row .btn { flex: 1; }

.edit-actions { display: flex; gap: 8px; margin-top: 10px; }
.edit-actions .btn { flex: 1; }

/* ===== 폼 ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 7px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 15.5px;
  color: var(--text-1);
  background: #fff;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--mint);
}
.form-textarea { resize: vertical; min-height: 70px; }
.form-input.error, .form-select.error { border-color: var(--danger); }
.form-error-msg { font-size: 12px; color: var(--danger); margin-top: 5px; }
.form-check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px;
}
.form-check-label { font-size: 14.5px; font-weight: 600; color: var(--text-1); }

.switch { position: relative; width: 46px; height: 27px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0;
  background: #D9DCE1;
  border-radius: 100px;
  transition: background .15s ease;
  cursor: pointer;
}
.switch-track::before {
  content: "";
  position: absolute;
  width: 21px; height: 21px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch input:checked + .switch-track { background: var(--mint); }
.switch input:checked + .switch-track::before { transform: translateX(19px); }

/* ===== 모달 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16,20,30,0.48);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadein .15s ease;
}
@media (min-width: 640px) { .modal-overlay { align-items: center; } }
.modal-sheet {
  background: var(--bg);
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  padding: 20px 20px calc(24px + var(--safe-bottom));
  animation: slideup .2s ease;
}
@media (min-width: 640px) { .modal-sheet { border-radius: 22px; max-height: 80vh; } }
@keyframes slideup { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.modal-handle {
  width: 36px; height: 4px;
  background: var(--line);
  border-radius: 100px;
  margin: 0 auto 14px;
}
.modal-title { font-size: 18px; font-weight: 800; color: var(--navy); margin-bottom: 18px; }
.modal-confirm-text { font-size: 15px; color: var(--text-1); line-height: 1.6; margin-bottom: 4px; }
.modal-confirm-sub { font-size: 13px; color: var(--text-2); margin-bottom: 18px; }

/* ===== 관리자 로그인 모달 ===== */
.login-icon-circle {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin: 4px auto 16px;
}
.login-icon-circle svg { width: 24px; height: 24px; }
.login-modal-title { text-align: center; font-size: 17px; font-weight: 800; margin-bottom: 4px; }
.login-modal-sub { text-align: center; font-size: 13px; color: var(--text-2); margin-bottom: 20px; }

/* ===== 통계: 막대 차트 ===== */
.chart-box { padding: 6px 2px 2px; overflow-x: auto; }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding: 0 2px; min-width: min-content; }
.bar-col { flex: 0 0 auto; width: 30px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bar-fill { width: 100%; max-width: 22px; background: var(--mint); border-radius: 6px 6px 3px 3px; min-height: 3px; transition: height .3s ease; }
.bar-col-label { font-size: 10px; color: var(--text-3); }

.split-bar { display: flex; height: 12px; border-radius: 100px; overflow: hidden; margin: 12px 0; background: var(--line); }
.split-seg-fuel { background: var(--mint); height: 100%; }
.split-seg-maint { background: var(--orange); height: 100%; }
.split-legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--text-2); }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

.category-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.category-row:last-child { border-bottom: none; }
.category-name { font-size: 14px; font-weight: 600; color: var(--text-1); }
.category-amount { font-size: 14px; font-weight: 700; color: var(--text-1); }

/* ===== 로딩 / 스켈레톤 ===== */
.skeleton { background: linear-gradient(90deg, #ECEDF0 25%, #F5F6F7 37%, #ECEDF0 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-card { height: 92px; margin-bottom: 12px; border-radius: var(--radius-lg); }
.loading-wrap { padding: 8px 0; }

.center-fallback {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60vh; text-align: center; padding: 20px;
}
.center-fallback-title { font-size: 15.5px; font-weight: 700; color: var(--text-1); margin-bottom: 6px; }
.center-fallback-desc { font-size: 13.5px; color: var(--text-2); margin-bottom: 18px; line-height: 1.5; }

/* ===== 토스트 ===== */
.toast {
  position: fixed;
  left: 50%; bottom: calc(94px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 100px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 200;
  max-width: 86%;
  text-align: center;
  animation: toastin .2s ease;
}
@keyframes toastin { from { opacity:0; transform: translate(-50%, 8px);} to { opacity:1; transform: translate(-50%,0);} }
.toast.toast-error { background: var(--danger); }

/* ===== 설정 화면 ===== */
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 13px 2px; border-bottom: 1px solid var(--line); }
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 14px; color: var(--text-2); }
.info-value { font-size: 14.5px; font-weight: 700; color: var(--text-1); }

.reminder-toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.reminder-toggle-row:last-child { border-bottom: none; }

::-webkit-scrollbar { width: 0; height: 0; }
