/* VinChecker — Apple glass / soft-futurism design system */

:root {
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --surface-grouped: #f2f2f7;
  --separator: rgba(60, 60, 67, 0.18);
  --text: #1d1d1f;
  --text-secondary: rgba(60, 60, 67, 0.78);
  --text-tertiary: rgba(60, 60, 67, 0.55);

  --tint: #007aff;
  --tint-halo: rgba(0, 122, 255, 0.18);
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;

  --material-thin: rgba(255, 255, 255, 0.6);
  --material-regular: rgba(255, 255, 255, 0.78);
  --material-thick: rgba(255, 255, 255, 0.92);
  --scrim: rgba(0, 0, 0, 0.18);
  --hairline: 0 1px 0 rgba(0, 0, 0, 0.04);

  --font-text: -apple-system, "SF Pro Text", system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: -apple-system, "SF Pro Display", system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;

  --r-sm: 10px;
  --r-md: 12px;
  --r-lg: 14px;
  --r-xl: 16px;

  --nav-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --surface-grouped: #2c2c2e;
    --separator: rgba(84, 84, 88, 0.65);
    --text: #f5f5f7;
    --text-secondary: rgba(235, 235, 245, 0.7);
    --text-tertiary: rgba(235, 235, 245, 0.45);
    --tint: #0a84ff;
    --tint-halo: rgba(10, 132, 255, 0.22);
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --material-thin: rgba(28, 28, 30, 0.6);
    --material-regular: rgba(28, 28, 30, 0.78);
    --material-thick: rgba(28, 28, 30, 0.92);
    --scrim: rgba(0, 0, 0, 0.5);
    --hairline: 0 1px 0 rgba(255, 255, 255, 0.05);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; font-optical-sizing: auto; }
body {
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
img { max-width: 100%; display: block; }
a { color: var(--tint); text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
.t-display  { font-size: 34px; line-height: 1.15; letter-spacing: -0.02em; }
.t-title    { font-size: 22px; line-height: 1.2; }
.t-body     { font-size: 15px; }
.t-footnote { font-size: 13px; color: var(--text-secondary); }
.t-caption  { font-size: 12px; color: var(--text-tertiary); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  border-radius: var(--r-md);
  font-weight: 600; font-size: 15px; line-height: 1;
  transition: transform .12s ease, opacity .12s ease, background .15s ease;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--tint-halo); }
.btn-primary { background: var(--tint); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-bordered { background: transparent; color: var(--tint); box-shadow: inset 0 0 0 1px var(--tint); }
.btn-plain { background: transparent; color: var(--tint); padding: 10px 12px; }
.btn-plain:hover { background: var(--tint-halo); }
.btn-sm { min-height: 32px; padding: 6px 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.input {
  width: 100%; min-height: 44px; padding: 11px 14px;
  background: var(--surface-grouped); border: 0; border-radius: var(--r-sm);
  color: var(--text); font-size: 15px; outline: none;
  transition: box-shadow .15s ease;
  -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: var(--text-tertiary); }
.input:focus { box-shadow: 0 0 0 4px var(--tint-halo); }
.input-row { display: grid; grid-template-columns: 88px 1fr; gap: 8px; }

.check { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; color: var(--text-secondary); cursor: pointer; min-height: 28px; }
.check input { width: 20px; height: 20px; accent-color: var(--tint); margin: 0; }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 14px; border-radius: var(--r-sm); font-size: 13px; line-height: 1.35;
  background: var(--surface-grouped); color: var(--text);
}
.alert-error { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }
.alert-success { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }

/* ---------- Wordmark ---------- */
.logo {
  display: inline-flex; align-items: baseline; gap: 2px;
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.03em;
  color: var(--text); line-height: 1; white-space: nowrap; user-select: none;
}
.logo .slashes { color: var(--tint); font-weight: 800; letter-spacing: -0.06em; margin-right: 0.18em; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-elevated); border-radius: var(--r-lg);
  box-shadow: var(--hairline);
}

/* ---------- Auth pages ---------- */
.auth {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(60% 50% at 15% 10%, color-mix(in srgb, var(--tint) 14%, transparent), transparent 70%),
    radial-gradient(50% 40% at 90% 90%, color-mix(in srgb, #af52de 12%, transparent), transparent 70%),
    var(--surface-grouped);
}
.auth-card {
  width: 100%; max-width: 400px; min-width: 0;
  padding: 32px 24px 24px;
  border-radius: var(--r-xl);
  background: var(--material-regular);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  display: flex; flex-direction: column; gap: 20px;
}
.auth-logo { justify-content: center; margin-bottom: 4px; font-size: 28px; }
.auth-card h1 { text-align: center; }
.auth-card .sub { text-align: center; margin-top: -12px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-foot { text-align: center; color: var(--text-secondary); font-size: 13px; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--nav-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--material-thin);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: 0 0.5px 0 var(--separator);
}
.nav-inner {
  max-width: 1120px; margin: 0 auto; height: var(--nav-h);
  padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.nav-logo { font-size: 20px; }
.nav-right { display: flex; align-items: center; gap: 8px; }
.balance {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--surface-grouped); font-size: 13px; font-weight: 500; color: var(--text-secondary);
}
.balance strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Page ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 24px 20px 120px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .t-footnote { margin-top: 4px; }
.search { position: relative; width: 100%; max-width: 320px; }
.search .input { padding-left: 38px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-tertiary); pointer-events: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

/* Report card */
.report { padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.report-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.report-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; word-break: break-word; }
.report-vin { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.badge {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge-ready { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.badge-processing { color: var(--orange); background: color-mix(in srgb, var(--orange) 16%, transparent); }
.badge-processing::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .3 } 50% { opacity: 1 } }

.report-specs { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; font-weight: 500; padding: 4px 9px; border-radius: 8px; background: var(--surface-grouped); color: var(--text-secondary); }

.report-values { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--separator); border-radius: var(--r-sm); overflow: hidden; }
.value { background: var(--surface-grouped); padding: 10px 12px; }
.value:last-child:nth-child(odd) { grid-column: span 2; }
.value .k { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .04em; }
.value .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }

.report-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 4px; }
.report-actions { display: flex; gap: 6px; }

/* Empty / skeleton */
.empty { text-align: center; padding: 64px 16px; color: var(--text-secondary); }
.empty .t-title { color: var(--text); margin-bottom: 6px; }
.skeleton { height: 200px; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface-grouped) 25%, var(--bg-elevated) 50%, var(--surface-grouped) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { from { background-position: 200% 0 } to { background-position: -200% 0 } }

/* Floating action */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30;
  min-height: 52px; padding: 12px 24px; border-radius: 999px; font-size: 16px;
}
.fab:active { transform: translateX(-50%) scale(0.98); }

/* Toast */
.toast {
  position: fixed; top: calc(var(--nav-h) + 12px + env(safe-area-inset-top)); left: 50%; transform: translate(-50%, -8px);
  z-index: 40; padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 500;
  background: var(--material-thick); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  color: var(--text); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { color: var(--green); }
.toast.err { color: var(--red); }

/* ---------- Sheet (modal) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; max-width: 480px;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0;
  background: var(--material-regular);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  transform: translateY(24px); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; gap: 16px;
}
.sheet-backdrop.open .sheet { transform: none; }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--separator); margin: 0 auto 4px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-actions { display: flex; gap: 8px; }
.sheet-actions .btn { flex: 1; }
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; padding: 16px; }
  .sheet { border-radius: 16px; padding-bottom: 20px; }
  .grabber { display: none; }
}

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

@media (max-width: 480px) {
  .t-display { font-size: 28px; }
  .balance span.lbl { display: none; }
}
