:root {
  --primary: #1e2a38;
  --primary-light: #2a3a4d;
  --secondary: #f5a623;
  --accent: #4a90e2;
  --danger: #d94b4b;
  --ink: #1a1a1a;
  --paper: #fdfcf8;
  --muted: #8a8a86;
  --dash: #585e66;
  --dash-dark: #3f444b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Courier New", "Courier", monospace;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.06) 0, transparent 40%),
    linear-gradient(180deg, var(--dash) 0%, var(--dash-dark) 100%);
  background-size: 6px 6px, auto;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Receipt roll header ---------- */
.roll {
  background: var(--paper);
  border-radius: 0 0 14px 14px;
  position: relative;
  box-shadow: 0 6px 16px rgba(0,0,0,0.45);
  padding: calc(14px + env(safe-area-inset-top)) 14px 12px;
  z-index: 2;
}
.perf {
  position: absolute;
  top: 4px; left: 0; right: 0;
  display: flex; justify-content: space-around;
}
.perf span {
  width: 2px; height: 2px; border-radius: 50%;
  background: var(--muted); display: block;
}
.roll-header {
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 {
  margin: 0; font-size: 22px; letter-spacing: 3px; font-weight: 700;
}
.brand .tagline { margin: 2px 0 0; font-size: 10px; letter-spacing: 2px; color: var(--muted); }
.pump-icon { font-size: 28px; line-height: 1; }
.clock { font-size: 14px; color: var(--primary); letter-spacing: 1px; }
.paper-stripe {
  margin-top: 10px;
  border-top: 2px dashed var(--muted);
  padding-top: 8px;
  display: flex; justify-content: center;
  font-size: 9px; letter-spacing: 3px; color: var(--muted);
}
.paper-stripe::after { content: "*  .  *  .  *  .  *  .  *"; }

/* ---------- Content ---------- */
.content {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px;
}
.tab { display: none; }
.tab.active { display: block; animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none;} }

/* ---------- Gauges ---------- */
.gauges {
  background: var(--primary);
  border-radius: 12px;
  padding: 16px 10px;
  display: flex; gap: 8px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5), 0 3px 8px rgba(0,0,0,0.4);
}
.gauge { flex: 1; text-align: center; }
.bezel {
  background: linear-gradient(180deg, #0b0d10, #23262b);
  border-radius: 40px;
  padding: 6px;
  box-shadow: inset 0 1px 3px #000, 0 1px 2px rgba(255,255,255,0.12);
  position: relative;
}
.bezel::before {
  content: ""; position: absolute; inset: 0; border-radius: 40px;
  border: 1px solid rgba(255,255,255,0.18);
}
.odo-display {
  background: #0a0b0c;
  border-radius: 34px;
  padding: 10px 4px;
  font-family: "Courier New", monospace;
  color: #ff2d2d;
  text-shadow: 0 0 6px rgba(255,45,45,0.9), 0 0 12px rgba(255,45,45,0.5);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
}
.plate {
  margin-top: 8px;
  background: linear-gradient(180deg, #cdd3da, #aeb4bc);
  border-radius: 4px;
  padding: 4px 2px;
  font-size: 9px; letter-spacing: 1px; color: #333;
  text-transform: uppercase;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.mpg-tag { font-size: 9px; letter-spacing: 1px; }

.btn-primary {
  width: 100%;
  margin-top: 16px;
  padding: 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--secondary), #e08c0e);
  color: #1a1a1a;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1px;
  box-shadow: 0 4px 0 #b06f0a, 0 6px 12px rgba(0,0,0,0.35);
  cursor: pointer;
}
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #b06f0a; }
.hint { text-align: center; color: #dfe2e6; font-size: 11px; margin-top: 14px; }

/* ---------- Log list ---------- */
.filter-row { margin-bottom: 14px; }
.filter-row input {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--paper);
  font-family: inherit;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.log-list { display: flex; flex-direction: column; gap: 12px; }

.receipt {
  background: var(--paper);
  border-radius: 10px;
  padding: 14px;
  position: relative;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4);
  transition: transform 0.25s ease, opacity 0.25s ease;
  touch-action: pan-y;
}
.receipt::before {
  content: ""; display: block;
  border-top: 2px dashed var(--muted);
  margin: -4px 0 10px;
}
.receipt-top { display: flex; align-items: center; gap: 8px; }
.receipt-top .pump { font-size: 20px; }
.receipt-date { font-size: 11px; color: var(--muted); flex: 1; letter-spacing: 1px; text-transform: uppercase; }
.stamp {
  color: #c22;
  border: 2px solid rgba(200,34,34,0.6);
  border-radius: 50%;
  padding: 3px 6px;
  font-size: 9px;
  letter-spacing: 1px;
  font-weight: 700;
  transform: rotate(-8deg);
}
.receipt-grid { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; }
.receipt-grid .col { display: flex; flex-direction: column; gap: 6px; }
.receipt-grid .label { color: var(--muted); font-size: 9px; letter-spacing: 1px; text-transform: uppercase; }
.receipt-grid .val { font-weight: 700; }
.mpg-row {
  margin-top: 10px; padding-top: 8px;
  border-top: 2px dashed var(--muted);
  display: flex; justify-content: space-between; align-items: center;
}
.mpg-badge {
  background: var(--primary); color: var(--secondary);
  padding: 5px 10px; border-radius: 6px;
  font-weight: 700; font-size: 13px;
}
.receipt.swiping { transform: translateX(-60%); opacity: 0.4; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; margin-top: 30px; color: #dfe2e6; }
.roll-illustration {
  width: 80px; height: 80px; margin: 0 auto 16px;
  border: 2px dashed #dfe2e6;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.roll-illustration .dashed-line { width: 40px; border-top: 2px dashed #dfe2e6; }
.empty-state p { font-size: 13px; letter-spacing: 1px; }

/* ---------- Forms ---------- */
#add-form, .vehicle-form {
  background: var(--paper);
  border-radius: 12px;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
}
#form-title { margin: 0 0 16px; font-size: 18px; letter-spacing: 1px; }
label {
  display: block;
  font-size: 11px; letter-spacing: 1px; color: var(--muted);
  text-transform: uppercase; margin: 12px 0 6px;
}
input, select {
  width: 100%;
  padding: 14px;
  border: 2px solid #d8d6d0;
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
select { appearance: none; }
.form-error { color: var(--danger); font-size: 12px; min-height: 16px; margin: 8px 0 0; }
.btn-ghost {
  width: 100%; margin-top: 10px; padding: 14px;
  border: 2px solid #d8d6d0; border-radius: 10px;
  background: transparent; font-family: inherit;
  font-size: 14px; letter-spacing: 1px; color: var(--primary);
  cursor: pointer;
}
.btn-danger {
  width: 100%; padding: 15px;
  border: none; border-radius: 10px;
  background: linear-gradient(180deg, #e26060, var(--danger));
  color: #fff; font-family: inherit; font-weight: 700;
  font-size: 14px; letter-spacing: 1px;
  box-shadow: 0 4px 0 #a33535, 0 6px 12px rgba(0,0,0,0.35);
  cursor: pointer;
}
.btn-danger:active { transform: translateY(3px); box-shadow: 0 1px 0 #a33535; }
.saved-note {
  text-align: center; color: #2a8f4a; font-size: 12px; margin: 10px 0 0;
  opacity: 0; transition: opacity 0.3s;
}
.saved-note.show { opacity: 1; }
.vehicle-form hr { border: none; border-top: 2px dashed var(--muted); margin: 20px 0; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--dash-dark), #33383e);
  border-top: 2px solid #555c63;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.4);
  display: flex;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  justify-content: space-around;
}
.tab-btn {
  flex: 1;
  background: none; border: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer;
  padding: 6px 0;
}
.tab-btn .lbl {
  font-family: inherit; font-size: 9px; letter-spacing: 1px;
  color: #b9bec4; text-transform: uppercase;
}
.cap {
  width: 34px; height: 34px; border-radius: 50%;
  display: block;
  box-shadow: 0 2px 4px rgba(0,0,0,0.6);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.cap-black { background: radial-gradient(circle at 35% 30%, #3a4250, #14181d 70%); }
.cap-silver { background: radial-gradient(circle at 35% 30%, #f0f3f6, #9aa0a6 70%); }
.cap-red { background: radial-gradient(circle at 35% 30%, #ff6b6b, #9c1f1f 70%); }
.cap-blue { background: radial-gradient(circle at 35% 30%, #6faef0, #20568f 70%); }
.tab-btn.active .cap {
  transform: translateY(-8px) scale(1.08);
}
.tab-btn.active.cap-on-black .cap { box-shadow: 0 8px 16px rgba(20,24,29,0.9), 0 0 16px rgba(58,66,80,0.6); }
.tab-btn.active.cap-on-silver .cap { box-shadow: 0 8px 16px rgba(154,160,166,0.9), 0 0 16px rgba(240,243,246,0.6); }
.tab-btn.active.cap-on-red .cap { box-shadow: 0 8px 16px rgba(156,31,31,0.9), 0 0 16px rgba(255,107,107,0.7); }
.tab-btn.active.cap-on-blue .cap { box-shadow: 0 8px 16px rgba(32,86,143,0.9), 0 0 16px rgba(111,174,240,0.7); }
.tab-btn.active .lbl { color: var(--secondary); }

.bottom-spacer { height: 96px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-card {
  position: relative;
  background: var(--paper);
  border-radius: 14px;
  padding: 22px 18px;
  max-width: 320px; width: 90%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.modal-card h3 { margin: 0 0 10px; letter-spacing: 1px; }
.modal-question { font-size: 14px; color: var(--muted); margin: 0 0 18px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn-ghost, .modal-actions .btn-danger { width: auto; flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 110px;
  transform: translateX(-50%) translateY(20px);
  background: var(--primary); color: #fff;
  padding: 10px 16px; border-radius: 8px;
  font-size: 13px; letter-spacing: 0.5px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 30;
  max-width: 86%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }