:root {
  --background: #f9fafb;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --secondary: #4b5563;
  --border: rgba(0, 0, 0, 0.1);
  --input: #f3f4f6;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --primary-text: #1e40af;
  --success: #16a34a;
  --warning: #c2410c;
  --warning-soft: #ffedd5;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--background);
  overflow-x: hidden;
  overscroll-behavior-x: none;
  -webkit-text-size-adjust: 100%;
}

#app {
  width: 100%;
  max-width: 100vw;
  min-height: 100dvh;
  overflow-x: hidden;
}

img,
svg {
  max-width: 100%;
}

button,
input,
textarea {
  font: inherit;
  min-width: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: 100%;
  min-height: 100dvh;
  background: var(--background);
  overflow-x: clip;
  touch-action: pan-y;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 88px 1fr 88px;
  align-items: center;
  min-height: 60px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.top-bar > * {
  min-width: 0;
}

.top-bar h1 {
  margin: 0;
  overflow: hidden;
  font-size: 20px;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.content {
  width: 100%;
  max-width: 672px;
  margin: 0 auto;
  padding: 16px 16px 104px;
  overflow-x: clip;
}

.screen-meta {
  margin: -6px 0 16px;
  color: var(--muted);
  text-align: center;
}

.onboarding {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 auto;
  padding: 32px 20px;
  background: linear-gradient(#dbeafe, #ffffff 50%, #f9fafb);
  overflow-x: clip;
  touch-action: pan-y;
}

.onboarding > * {
  max-width: 100%;
}

.brand-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 18px;
  box-shadow: 0 14px 36px rgba(37, 99, 235, 0.25);
}

.onboarding h1 {
  margin: 0;
  font-size: 36px;
  line-height: 1.1;
  text-align: center;
}

.tagline {
  margin: 12px 0 20px;
  color: var(--secondary);
  text-align: center;
  font-size: 18px;
}

.value-list {
  display: grid;
  gap: 10px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.value-list li {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.privacy {
  margin: 14px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.stack {
  display: grid;
  gap: 16px;
}

.form-card,
.detail-card,
.stat-card,
.record-card,
.empty-state,
.settings-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.form-card {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.form-card h2,
.section-header h2,
.detail-card h2,
.empty-state h2 {
  margin: 0;
  font-size: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--secondary);
  font-size: 14px;
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--input);
  padding: 10px 12px;
  color: var(--text);
  font-weight: 500;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
textarea:focus,
button:focus-visible,
.record-card:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}

.check-field input {
  border-color: var(--warning);
  background: #fff7ed;
}

.check-field::after {
  content: "Check this value";
  color: var(--warning);
  font-size: 12px;
  font-weight: 600;
}

.segmented {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented legend {
  margin-bottom: 8px;
  color: var(--secondary);
  font-size: 14px;
  font-weight: 700;
}

.segmented div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--secondary);
  font-weight: 700;
}

.segmented input:checked + span {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.button {
  display: inline-grid;
  place-items: center;
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.button.primary {
  background: var(--primary);
  color: white;
}

.button.secondary {
  border-color: rgba(255, 255, 255, 0.65);
  background: transparent;
  color: white;
}

.content > .button.secondary {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--surface);
  margin-bottom: 12px;
}

.button.text {
  background: transparent;
  color: white;
}

.icon-button,
.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 800;
}

.icon-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
}

.icon-button.danger {
  color: var(--danger);
}

.stats-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card,
.detail-card {
  display: grid;
  gap: 6px;
  padding: 16px;
}

.stat-card span,
.detail-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat-card strong,
.detail-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 22px;
  line-height: 1.2;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 12px;
}

.record-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  margin-bottom: 12px;
  text-align: left;
}

.record-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.record-head div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.record-head span,
.record-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.record-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.record-facts span {
  display: grid;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.record-facts small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.chip {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
}

.fab {
  position: fixed;
  right: max(24px, calc((100vw - 672px) / 2 + 24px));
  bottom: 24px;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow);
  font-size: 32px;
  line-height: 1;
}

.empty-state {
  padding: 24px;
  text-align: center;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
}

.callout {
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
}

.callout.info {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.callout.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.callout.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.issue-list {
  display: grid;
  gap: 8px;
}

.method-card {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 14px;
  align-items: center;
  width: 100%;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  text-align: left;
}

.method-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 900;
}

.method-card span:last-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.method-card small {
  color: var(--muted);
  font-size: 14px;
}

.camera-screen {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  padding: 16px;
  background: black;
  color: white;
}

.camera-top {
  display: flex;
  justify-content: space-between;
}

.camera-icon {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  padding: 8px 12px;
  font-weight: 800;
}

.camera-frame {
  align-self: center;
  justify-self: center;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: min(420px, calc(100vw - 32px));
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  overflow: hidden;
  text-align: center;
}

.receipt-frame {
  aspect-ratio: 3 / 4;
}

.odometer-frame {
  aspect-ratio: 16 / 7;
}

.camera-frame h1 {
  margin: 0 0 8px;
  font-size: 20px;
}

.camera-frame p {
  margin: 0;
  color: rgba(255, 255, 255, 0.75);
}

.camera-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.camera-controls {
  display: grid;
  gap: 10px;
  padding-bottom: 12px;
}

.progress-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.progress-card {
  width: 100%;
  max-width: 360px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 28px;
  text-align: center;
}

.progress-card h1 {
  margin: 14px 0 6px;
  font-size: 20px;
}

.progress-card p {
  margin: 0;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border: 4px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.image-name {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.review-panel {
  display: grid;
  gap: 16px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, #eef6ff 0%, #ffffff 58%, #ecfdf5 100%);
  padding: 18px;
}

.review-panel h2,
.review-panel p {
  margin: 0;
}

.review-panel h2 {
  font-size: 18px;
}

.review-panel p {
  color: var(--secondary);
  font-size: 14px;
}

.review-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--primary-text);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.review-source-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.review-source-list div {
  display: grid;
  grid-template-columns: minmax(88px, auto) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.review-source-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.review-source-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
}

.status-pill {
  display: inline-grid;
  place-items: center;
  min-height: 26px;
  border: 1px solid rgba(194, 65, 12, 0.22);
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 900;
}

.settings-list {
  display: grid;
  overflow: hidden;
}

.settings-list > * {
  display: grid;
  gap: 3px;
  min-height: 58px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 16px;
  color: var(--text);
  text-align: left;
}

.settings-list > *:last-child {
  border-bottom: 0;
}

.settings-list span {
  color: var(--muted);
  font-size: 14px;
}

.danger-row {
  color: var(--danger);
  font-weight: 800;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 420px) {
  .top-bar {
    grid-template-columns: 64px minmax(0, 1fr) 64px;
    padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right));
  }

  .content {
    padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
  }

  .stat-card strong,
  .detail-card strong {
    font-size: 18px;
  }

  .record-facts {
    grid-template-columns: 1fr;
  }

  .review-source-list div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
