/* ── Design tokens ─────────────────────────────────── */
:root {
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --border:      #e2e8f0;
  --shadow:      0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
  --primary:     #2563eb;
  --primary-bg:  #eff6ff;
  --primary-dk:  #1d4ed8;
  --danger:      #ef4444;
  --success:     #16a34a;
  --txt-1:       #0f172a;
  --txt-2:       #475569;
  --txt-3:       #94a3b8;
  --radius:      16px;
  --radius-sm:   10px;
}
html.dark {
  --bg:         #0f172a;
  --surface:    #1e293b;
  --surface-2:  #162032;
  --border:     #334155;
  --primary:    #3b82f6;
  --primary-bg: #1e3a5f;
  --primary-dk: #2563eb;
  --txt-1:      #f1f5f9;
  --txt-2:      #94a3b8;
  --txt-3:      #475569;
}

/* ── Reset & base ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--txt-1);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button { font-family: 'Cairo', sans-serif; }

/* ── App shell ─────────────────────────────────────── */
#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: white;
  padding: calc(env(safe-area-inset-top) + .9rem) 1.25rem .9rem;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 12px rgba(37,99,235,.4);
}
.header-inner { display: flex; justify-content: space-between; align-items: center; }
.header-title { font-size: 1.2rem; font-weight: 800; display: flex; align-items: center; gap: .5rem; }
.header-sub   { font-size: .68rem; opacity: .7; margin-top: 3px; }
.icon-btn {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.18);
  border: none; border-radius: 50%;
  font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
}
.icon-btn:active { background: rgba(255,255,255,.3); }

/* ── Main content ──────────────────────────────────── */
#mainContent {
  flex: 1;
  padding: 1rem;
  padding-bottom: calc(env(safe-area-inset-bottom) + 5.5rem);
  overflow-y: auto;
}

/* ── Bottom nav ────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0;
  left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(0,0,0,.07);
  z-index: 20;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: .5rem 0; gap: 2px;
  background: none; border: none; cursor: pointer;
  color: var(--txt-3);
  font-size: .6rem; font-weight: 600;
  transition: color .2s;
}
.nav-icon {
  font-size: 1.25rem;
  width: 44px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  transition: background .2s;
}
.nav-btn.active           { color: var(--primary); }
.nav-btn.active .nav-icon { background: var(--primary-bg); }

/* ── Utility ───────────────────────────────────────── */
.space-y > * + * { margin-top: .75rem; }
.flex-between    { display: flex; justify-content: space-between; align-items: center; }

/* ── Card ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ── Hero card ─────────────────────────────────────── */
.hero-card {
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: white;
  display: flex; justify-content: space-between; align-items: flex-start;
  box-shadow: var(--shadow-md);
}
.hero-name { font-size: 1.3rem; font-weight: 800; }
.hero-year { font-size: .8rem; opacity: .75; margin-top: 2px; }
.hero-odo  { font-size: .78rem; opacity: .7; margin-top: 6px; }
.hero-change-btn {
  background: rgba(255,255,255,.2);
  border: 1.5px solid rgba(255,255,255,.35);
  color: white; padding: .4rem .9rem;
  border-radius: 20px;
  font-size: .78rem; font-weight: 700; cursor: pointer;
  transition: background .2s; white-space: nowrap;
}
.hero-change-btn:active { background: rgba(255,255,255,.35); }

/* ── Section header ────────────────────────────────── */
.sec-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .9rem 1rem .5rem;
}
.sec-title { font-size: .92rem; font-weight: 700; }
.link-btn {
  background: none; border: none; color: var(--primary);
  font-size: .78rem; cursor: pointer; padding: 0;
}

/* ── Info rows (oil card) ──────────────────────────── */
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .5rem 1rem; border-bottom: 1px solid var(--border);
}
.info-row:last-of-type { border-bottom: none; }
.info-label { font-size: .8rem; color: var(--txt-2); }
.info-value { font-size: .84rem; font-weight: 600; color: var(--txt-1); }
.info-value.accent { color: var(--primary); }

/* ── Badges ────────────────────────────────────────── */
.badge {
  font-size: .65rem; font-weight: 700;
  padding: 2px 9px; border-radius: 20px;
  display: inline-flex; align-items: center; gap: 3px;
}
.badge-ok      { background: #dcfce7; color: #15803d; }
.badge-soon    { background: #fef9c3; color: #92400e; }
.badge-overdue { background: #fee2e2; color: #b91c1c; }
.badge-gray    { background: var(--surface-2); color: var(--txt-2); border: 1px solid var(--border); }
.badge-active  { background: var(--primary-bg); color: var(--primary); }
html.dark .badge-ok      { background: #14532d; color: #4ade80; }
html.dark .badge-soon    { background: #451a03; color: #fbbf24; }
html.dark .badge-overdue { background: #450a0a; color: #f87171; }

/* ── Service items ─────────────────────────────────── */
.svc-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1rem; border-bottom: 1px solid var(--border);
}
.svc-item:last-child { border-bottom: none; }
.svc-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; flex-shrink: 0;
}
.svc-oil   { background: #fef3c7; }
.svc-tire  { background: #dbeafe; }
.svc-brake { background: #fee2e2; }
.svc-other { background: var(--surface-2); border: 1px solid var(--border); }
html.dark .svc-oil   { background: #451a03; }
html.dark .svc-tire  { background: #1e3a5f; }
html.dark .svc-brake { background: #450a0a; }
.svc-name { font-size: .86rem; font-weight: 600; }
.svc-meta { font-size: .72rem; color: var(--txt-3); margin-top: 1px; }
.svc-odo  { font-size: .82rem; font-weight: 700; color: var(--txt-2); white-space: nowrap; }
.cost-chip {
  display: inline-block; font-size: .68rem; font-weight: 700;
  background: #dcfce7; color: #15803d;
  padding: 1px 7px; border-radius: 10px; margin-top: 3px;
}
html.dark .cost-chip { background: #14532d; color: #4ade80; }
.notes-txt { font-size: .72rem; color: var(--txt-3); margin-top: 2px; }
.next-due  { font-size: .7rem; color: var(--primary); margin-top: 2px; }
.del-svc-btn {
  background: none; border: none; font-size: 1rem;
  cursor: pointer; color: var(--txt-3); padding: .3rem;
  border-radius: 8px; transition: color .2s, background .2s;
}
.del-svc-btn:active { color: var(--danger); background: #fee2e2; }

/* ── Car cards ─────────────────────────────────────── */
.car-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color .2s;
  margin-bottom: .75rem;
}
.car-card.active   { border-color: var(--primary); }
.car-card-body     { padding: 1rem 1.1rem .85rem; }
.car-card-body.hi  { background: var(--primary-bg); }
.car-name-row      { display: flex; align-items: center; gap: .5rem; margin-bottom: 3px; }
.car-name          { font-size: 1rem; font-weight: 700; }
.car-sub           { font-size: .76rem; color: var(--txt-2); margin-top: 2px; }
.car-odo-row       { font-size: .72rem; color: var(--txt-3); margin-top: 3px; }
.car-actions       { display: flex; border-top: 1px solid var(--border); }
.car-act-btn {
  flex: 1; padding: .72rem 0;
  background: none; border: none; cursor: pointer;
  font-size: .8rem; transition: background .15s; color: var(--txt-2);
}
.car-act-btn:active  { background: var(--surface-2); }
.car-act-btn.sel     { color: var(--primary); font-weight: 700; }
.car-act-btn.del-act { color: var(--danger); }
.sep-v { width: 1px; background: var(--border); flex-shrink: 0; }

/* ── Forms ─────────────────────────────────────────── */
.form-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.form-title { font-size: 1.1rem; font-weight: 800; margin-bottom: .25rem; }
.form-sub   { font-size: .8rem; color: var(--txt-2); margin-bottom: 1.1rem; }
.form-group { margin-bottom: .9rem; }
.form-label {
  display: block; font-size: .78rem; font-weight: 600;
  color: var(--txt-2); margin-bottom: .3rem;
}
.form-input {
  width: 100%; padding: .62rem .9rem;
  background: var(--surface-2); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); outline: none;
  font-size: .9rem; color: var(--txt-1);
  -webkit-appearance: none; transition: border-color .2s;
}
.form-input:focus { border-color: var(--primary); }
textarea.form-input { resize: vertical; min-height: 60px; }

/* ── Segmented control ─────────────────────────────── */
.seg-ctrl { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.seg-btn {
  padding: .55rem .4rem; background: var(--surface-2);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .78rem; font-weight: 600; cursor: pointer;
  color: var(--txt-2); transition: all .15s; text-align: center;
}
.seg-btn.active {
  background: var(--primary-bg); border-color: var(--primary);
  color: var(--primary);
}

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: block; width: 100%;
  padding: .75rem 1rem; border: none;
  border-radius: var(--radius-sm);
  font-size: .95rem; font-weight: 700; cursor: pointer;
  text-align: center; transition: opacity .2s, transform .1s;
}
.btn:active       { transform: scale(.98); }
.btn-primary      { background: var(--primary); color: white; }
.btn-success      { background: var(--success); color: white; }
.btn-ghost        { background: var(--surface-2); color: var(--txt-2); border: 1.5px solid var(--border); margin-top: .5rem; }

/* ── Empty states ──────────────────────────────────── */
.empty      { text-align: center; padding: 2.5rem 1rem; }
.empty-icon { font-size: 3rem; display: block; margin-bottom: .75rem; }
.empty-text { font-size: .88rem; color: var(--txt-2); }

/* ── Install banner ────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 72px);
  left: 50%; transform: translateX(-50%) translateY(140%);
  width: calc(100% - 2rem); max-width: 398px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  border: 1px solid var(--border);
  z-index: 30;
  transition: transform .4s cubic-bezier(.34,1.46,.64,1);
}
.install-banner.show { transform: translateX(-50%) translateY(0); }
.install-banner-inner {
  display: flex; align-items: center; gap: .85rem;
  padding: .9rem 1rem;
}
.install-banner-icon { font-size: 2rem; flex-shrink: 0; }
.install-banner-body { flex: 1; min-width: 0; }
.install-banner-title { font-size: .88rem; font-weight: 800; }
.install-banner-desc  { font-size: .75rem; color: var(--txt-2); margin-top: 2px; line-height: 1.4; }
.install-banner-close {
  background: var(--surface-2); border: none;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: .75rem; cursor: pointer; color: var(--txt-3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.install-banner-btn {
  display: block; width: calc(100% - 2rem);
  margin: 0 1rem .85rem;
  padding: .65rem; background: var(--primary); color: white;
  border: none; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 700; cursor: pointer;
}
/* little arrow pointing down toward Safari share bar */
.install-banner-arrow {
  text-align: center; font-size: 1.3rem;
  padding-bottom: .5rem; color: var(--txt-3);
  animation: bounce-down .9s ease-in-out infinite;
}
@keyframes bounce-down {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(5px); }
}

/* ── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar       { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
