:root {
  color-scheme: light;
  --page: #f2f4f7;
  --surface: #fbfcfe;
  --text: #111318;
  --muted: #68707d;
  --line: #d7dbe2;
  --line-strong: #c4cad4;
  --accent: #0a43bf;
  --accent-dark: #073493;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #166534;
  --success-bg: #eefbf2;
  --warning: #8a4b08;
  --warning-bg: #fff8e6;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--page); }

body {
  margin: 0;
  color: var(--text);
  background: var(--page);
  font-size: 15px;
  line-height: 1.5;
}

button, input, select { font: inherit; }
button, select, input[type="checkbox"], input[type="radio"] { cursor: pointer; }

.lead-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 20px 18px 0;
  background: var(--surface);
}

.lead-header {
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.lead-header h1 {
  margin: 0;
  font-size: clamp(24px, 6vw, 28px);
  line-height: 1.18;
  letter-spacing: -0.025em;
  font-weight: 730;
}

.lead-header p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

#lead-form { padding-top: 15px; }

.field { margin-bottom: 12px; }

.field label,
.dealer-fieldset legend {
  display: block;
  margin: 0 0 6px;
  padding: 0;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 620;
}

.field input,
.field select,
.login-form input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
  font-size: 14px;
}

.field input::placeholder { color: #8a919e; opacity: 1; }
.field select:disabled { cursor: not-allowed; background: #f1f3f5; color: #7d8591; }

.field input:focus,
.field select:focus,
.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(10 67 191 / 14%);
}

[aria-invalid="true"] { border-color: var(--danger) !important; }

.field-error {
  min-height: 0;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
}

.field-error.visible { margin-top: 4px; min-height: 18px; }

.dealer-fieldset {
  min-width: 0;
  margin: 2px 0 14px;
  padding: 0;
  border: 0;
}

.dealer-help {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
}

.dealer-list {
  display: grid;
  gap: 7px;
  max-height: 198px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.dealer-option {
  display: grid;
  grid-template-columns: 1fr 24px;
  align-items: center;
  gap: 9px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color 140ms ease, background 140ms ease;
}

.dealer-option:hover { border-color: #9ba7ba; }
.dealer-option.is-selected { border-color: var(--accent); background: #f7f9ff; }

.dealer-option input {
  grid-column: 2;
  grid-row: 1;
  width: 19px;
  height: 19px;
  margin: 0;
  accent-color: var(--accent);
}

.dealer-copy { grid-column: 1; grid-row: 1; min-width: 0; display: grid; gap: 2px; }
.dealer-copy strong { font-size: 14px; font-weight: 680; }
.dealer-copy span { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.action-panel {
  position: sticky;
  z-index: 2;
  bottom: 0;
  margin: 0 -18px;
  padding: 12px 18px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgb(251 252 254 / 97%);
  box-shadow: 0 -8px 24px rgb(30 45 70 / 8%);
}

.consent-row {
  display: grid;
  grid-template-columns: 21px 1fr;
  align-items: start;
  gap: 8px;
  color: #2f3540;
  font-size: 12px;
  line-height: 1.45;
}

.consent-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.consent-row a, .text-link { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.consent-error.visible { margin: 3px 0 0 29px; }

#submit-button,
.login-form button {
  width: 100%;
  min-height: 46px;
  margin-top: 9px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: background 140ms ease, transform 100ms ease;
}

#submit-button:hover, .login-form button:hover { background: var(--accent-dark); }
#submit-button:active, .login-form button:active { transform: translateY(1px); }
#submit-button:disabled, .login-form button:disabled { cursor: not-allowed; opacity: 0.58; }

.result-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  margin-top: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #f6f7f9;
  color: #606876;
  font-size: 12px;
}

.result-strip.is-error { border-color: #f1b2ad; background: var(--danger-bg); color: var(--danger); }
.result-strip.is-success { border-color: #9fd5af; background: var(--success-bg); color: var(--success); }
.result-strip.is-warning { border-color: #efc786; background: var(--warning-bg); color: var(--warning); }
.inline-retry { border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

.document-shell,
.login-shell {
  width: min(calc(100% - 32px), 680px);
  margin: 48px auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.document-shell h1, .login-shell h1 { margin: 0 0 16px; }
.document-shell p, .login-shell p { color: #4d5561; }
.document-kicker { margin: 0 0 4px !important; color: var(--warning) !important; font-weight: 700; }

.login-form { margin: 22px 0; }
.login-form label { display: block; margin-bottom: 7px; font-weight: 650; }

.admin-shell { width: min(calc(100% - 32px), 1180px); margin: 28px auto; }
.admin-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.admin-header h1 { margin: 0; font-size: 28px; }
.admin-header p { margin: 5px 0 0; color: var(--muted); }
.secondary-button, .retry-button { min-height: 36px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--text); }
.retry-button { border-color: var(--accent); color: var(--accent); font-weight: 650; }

.admin-message { margin: 0 0 14px; padding: 10px 12px; border-left: 3px solid var(--accent); background: #eef3ff; }
.admin-message.is-error { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.admin-message.is-success { border-color: var(--success); background: var(--success-bg); color: var(--success); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f5f7fa; color: #4c5563; font-size: 12px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }

.status { display: inline-block; padding: 3px 7px; border-radius: 6px; background: #eef0f3; white-space: nowrap; }
.status-success { background: var(--success-bg); color: var(--success); }
.status-failed { background: var(--danger-bg); color: var(--danger); }
.status-unknown { background: var(--warning-bg); color: var(--warning); }
.muted { color: var(--muted); }
.empty-state { padding: 48px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 12px; background: #fff; color: var(--muted); }

@media (max-width: 640px) {
  .admin-shell { width: min(calc(100% - 24px), 520px); margin: 18px auto; }
  .admin-header { align-items: center; }
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tbody { display: grid; gap: 10px; }
  tr { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
  td { display: grid; grid-template-columns: 82px 1fr; gap: 8px; padding: 6px 0; border: 0; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
}

@media (max-width: 520px) {
  .lead-shell { padding-bottom: 164px; }
  .action-panel {
    position: fixed;
    left: 50%;
    width: min(100%, 520px);
    margin: 0;
    transform: translateX(-50%);
  }
}

@media (min-width: 521px) {
  .lead-shell { border-left: 1px solid var(--line); border-right: 1px solid var(--line); box-shadow: 0 18px 60px rgb(30 45 70 / 10%); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
