/* ══════════════════════════════════════════════════════════════
   Nutshell AI GmbH · Vehicle Inspector — design tokens
   Minimal European dealer UI · 4px spacing base · WCAG AA
   ══════════════════════════════════════════════════════════════ */

:root {
  /* surfaces */
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f2f4f6;

  /* lines */
  --border: #e6e7e9;
  --border-strong: #d3d6da;

  /* text */
  --text: #0b0d0f;
  --text-2: #4d545c;
  --text-3: #6f757d;

  /* brand */
  --accent: #1c69d4;
  --accent-hover: #0f4fa8;
  --accent-soft: #eaf1fc;
  --danger: #c62828;
  --danger-soft: #fdf1f1;

  /* geometry */
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.2, .7, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0; min-height: 100%;
  font-family: var(--font); font-size: 14px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─────────────── wordmark ─────────────── */
.brand { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -.01em; line-height: 1; }

/* ─────────────── view switching ─────────────── */
.view[hidden] { display: none; }

/* ─────────────── 1. login ─────────────── */
#login-view {
  min-height: 100vh;
  background: radial-gradient(760px 420px at 50% -8%, #ffffff 0%, rgba(255,255,255,0) 70%), var(--bg);
}
.brandbar {
  height: 62px; padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(11, 13, 15, .06);
}
.brandbar-meta {
  font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--text-3); font-weight: 600;
}
.login-main {
  min-height: calc(100vh - 62px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 44px 24px 56px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 30px 28px 26px;
  box-shadow: 0 1px 2px rgba(11, 13, 15, .04), 0 28px 52px -34px rgba(11, 13, 15, .3);
}
.login-title { font-size: 23px; font-weight: 600; letter-spacing: -.022em; }
.login-sub { margin-top: 7px; font-size: 13px; line-height: 1.55; color: var(--text-2); }
#login-form { margin-top: 24px; display: grid; gap: 15px; }

.field { display: grid; gap: 6px; }
.field > label, .field-head label {
  font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: .01em;
}
.field-head { display: flex; align-items: baseline; justify-content: space-between; }
.link-quiet {
  font-size: 11.5px; color: var(--text-3); text-decoration: none;
  border-bottom: 1px solid transparent; transition: color .15s, border-color .15s;
}
.link-quiet:hover { color: var(--accent); border-bottom-color: currentColor; }

.input {
  width: 100%; height: 42px; padding: 0 12px;
  font-family: var(--font); font-size: 13.5px; color: var(--text);
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #a7acb3; }
.input:hover { border-color: #c2c6cb; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(28, 105, 212, .13); }

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--text-3); cursor: pointer; transition: color .15s, background .15s;
}
.pw-toggle:hover { color: var(--text); background: var(--surface-3); }
.pw-toggle .ico-eye-off { display: none; }
.pw-toggle[aria-pressed="true"] .ico-eye { display: none; }
.pw-toggle[aria-pressed="true"] .ico-eye-off { display: block; }

.check {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.5px; color: var(--text-2); cursor: pointer; user-select: none; margin-top: 1px;
}
.check input {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; flex: none; margin: 0;
  border: 1px solid var(--border-strong); border-radius: 4px; background: #fff;
  position: relative; cursor: pointer; transition: background .15s, border-color .15s;
}
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after {
  content: ""; position: absolute; left: 4.6px; top: 1.4px;
  width: 4.6px; height: 8.4px;
  border: 2px solid #fff; border-top: 0; border-left: 0; transform: rotate(42deg);
}
.form-error {
  margin: -2px 0 0; padding: 9px 11px;
  font-size: 12.5px; line-height: 1.45; color: var(--danger);
  background: var(--danger-soft); border: 1px solid #f4d5d5; border-radius: var(--r-sm);
}

/* buttons */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px;
  font-size: 13.5px; font-weight: 600; letter-spacing: .01em;
  border: 1px solid transparent; border-radius: var(--r-sm);
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s, color .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: default; }
.btn-block { width: 100%; margin-top: 3px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(28, 105, 212, .22); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { background: #7ea7e4; box-shadow: none; }

.spinner {
  display: none; width: 14px; height: 14px; flex: none;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
.btn.is-loading .spinner { display: block; }
.btn.is-loading { pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.legal {
  max-width: 400px; text-align: center;
  font-size: 11px; line-height: 1.6; color: var(--text-3); text-wrap: pretty;
}

/* ─────────────── shared authed shell ─────────────── */
.appbar {
  position: sticky; top: 0; z-index: 20;
  height: 62px; padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.appbar[hidden] { display: none; }

.user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: #0b0d0f; color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .04em;
}
.user-meta { display: grid; gap: 1px; line-height: 1.25; }
.user-name { font-size: 12.5px; font-weight: 600; }
.user-sub { font-size: 11px; color: var(--text-3); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 11px; margin-left: 6px;
  font-size: 12px; font-weight: 500; color: var(--text-2);
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.btn-ghost:hover { border-color: #b9bec4; background: var(--surface-2); color: var(--text); }

#app-view, #result-view { display: flex; flex-direction: column; min-height: calc(100vh - 62px); }
#app-view[hidden], #result-view[hidden] { display: none; }

.appfoot {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 18px;
  padding: 15px 32px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-3);
}

.eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-3);
}

/* ─────────────── 2. VIN lookup page ─────────────── */
.app-main {
  flex: 1 1 auto; width: 100%; max-width: 840px; margin: 0 auto;
  display: flex; flex-direction: column; justify-content: center;
  /* 在剩余视口内垂直居中；底部留白更大，使内容落在「中间偏上」 */
  padding: 40px 24px clamp(96px, 18vh, 200px);
}
.lookup h1 { margin-top: 11px; font-size: 34px; line-height: 1.1; font-weight: 600; letter-spacing: -.03em; }
.lede { margin-top: 11px; max-width: 58ch; font-size: 14px; line-height: 1.6; color: var(--text-2); }

.vin-form { margin-top: 30px; display: flex; align-items: flex-start; gap: 10px; }
.vin-box { position: relative; flex: 1 1 auto; min-width: 0; }
.vin-input {
  width: 100%; height: 54px; padding: 0 62px 0 15px;
  font-family: var(--mono); font-size: 16.5px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text);
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s;
}
.vin-input::placeholder {
  font-family: var(--font); font-size: 13.5px; letter-spacing: 0; text-transform: none; color: #a7acb3;
}
.vin-input:hover { border-color: #c2c6cb; }
.vin-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(28, 105, 212, .13); }
.vin-input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(198, 40, 40, .1); }
.vin-count {
  position: absolute; top: 50%; right: 14px; transform: translateY(-50%);
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.vin-box.is-complete .vin-count { color: var(--accent); }
.btn-decode { height: 54px; padding: 0 20px; flex: none; }

.vin-error { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12.5px; color: var(--danger); }
.vin-error[hidden] { display: none; }

.samples { margin-top: 26px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.samples-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3); margin-right: 2px;
}
.chip {
  height: 28px; padding: 0 11px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .03em; color: var(--text-2);
  background: #fff; border: 1px solid var(--border); border-radius: 999px;
  cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ─────────────── 3. result page ─────────────── */
.result-main { flex: 1 1 auto; width: 100%; max-width: 940px; margin: 0 auto; padding: 28px 24px 64px; }

.result-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.back-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px;
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.crumb { font-size: 11.5px; color: var(--text-3); }
.crumb-sep { margin: 0 7px; color: #b9bec4; }

.result-head { margin-top: 26px; }
.vin-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.result-vin {
  font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: .02em;
  color: var(--text); overflow-wrap: anywhere;
}
.result-summary { margin-top: 9px; font-size: 13px; color: var(--text-2); }

.icon-btn {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  color: var(--text-3); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.is-copied { color: var(--accent); border-color: var(--accent); }

.panel {
  margin-top: 20px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 22px 24px;
}
.panel-title { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.count {
  display: inline-grid; place-items: center;
  height: 19px; padding: 0 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2);
  font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}

/* spec table — two label/value columns, stacks on mobile */
.spec-grid {
  margin-top: 12px;
  display: grid; grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden;
}
.spec-col { display: grid; grid-template-columns: minmax(92px, .82fr) minmax(0, 1.18fr); }
.spec-col + .spec-col { border-left: 1px solid var(--border); }
.spec-cell {
  min-width: 0; padding: 9px 13px; font-size: 12.5px;
  border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
}
.spec-cell.k { background: var(--surface-2); color: var(--text-2); font-size: 11.5px; }
.spec-cell.v { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.spec-cell:nth-child(2n) { border-right: 0; }
.spec-cell:nth-last-child(-n+2) { border-bottom: 0; }

/* PR list — description only, flows with the page */
.pr-scroll {
  margin-top: 12px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: #fff; overflow: hidden;
}
.pr-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3);
}
.pr-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 14px;
  font-size: 12.5px; line-height: 1.45; color: var(--text-2);
  border-top: 1px solid #f1f2f4;
}
.pr-row:first-child { border-top: 0; }

.result-foot {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px 20px;
  margin-top: 18px; font-size: 11px; color: var(--text-3);
}
.result-foot-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.foot-sep { color: #b9bec4; }
.back-link {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 0; font-size: 11.5px; font-weight: 500;
  color: var(--text-2); background: none; border: 0;
  border-bottom: 1px solid transparent; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.back-link:hover { color: var(--accent); border-bottom-color: currentColor; }

/* ─────────────── responsive ─────────────── */
@media (max-width: 860px) {
  .appbar, .brandbar { padding: 0 20px; }
  .app-main { justify-content: flex-start; padding: 40px 20px 72px; }
  .result-main { padding: 24px 20px 56px; }
  .appfoot { padding: 14px 20px; }
  .lookup h1 { font-size: 28px; }
}

@media (max-width: 700px) {
  .login-card { padding: 26px 22px 24px; }
  .login-title { font-size: 21px; }
  .user-meta { display: none; }
  .btn-ghost span { display: none; }
  .btn-ghost { width: 32px; padding: 0; justify-content: center; margin-left: 0; }

  .vin-form { flex-direction: column; align-items: stretch; }
  .btn-decode { width: 100%; }
  .vin-input { font-size: 15px; letter-spacing: .06em; }
  .samples { margin-top: 22px; }
  .samples-label { flex-basis: 100%; margin: 0 0 2px; }

  .result-nav { gap: 10px; }
  .crumb { display: none; }
  .result-head { margin-top: 24px; }
  .result-vin { font-size: 19px; }
  .panel { padding: 18px 16px; }
  .spec-grid { grid-template-columns: 1fr; }
  .spec-col + .spec-col { border-left: 0; border-top: 1px solid var(--border); }
  .result-foot { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

.query-status { margin-top: 14px; color: var(--text-2); font-size: 12.5px; }
.query-status[hidden] { display: none; }
.session-error { max-width: 900px; margin: 12px auto; padding: 10px 16px; color: var(--danger); background: var(--danger-soft); border-radius: var(--r-sm); }
.session-error[hidden] { display: none; }
