/* ----------------------------------------------------------------------
   Dealer workbench — 1:1 port of the v17 reference
   (前端HTML版本备份/17-用户提供参考稿/车行端查价.html).
   Geometric background, glassmorphic top bar, dual-price preview card.
   ---------------------------------------------------------------------- */

.dealer-page {
  position: relative;
  margin: 0;
  min-height: 100vh;
  color: var(--fg);
  background:
    linear-gradient(135deg, rgba(5, 5, 5, 0.05) 0%, transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(200, 50, 42, 0.1), transparent 28%),
    linear-gradient(135deg, #ffffff 0%, var(--bg) 52%, #fff6f5 100%);
  font-family: var(--font);
  line-height: 1.45;
  overflow-x: hidden;
}

/* ---------- Page shell ---------- */
.dealer-page .page {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 28px;
}

.dealer-page .page.hidden {
  display: none;
}

/* ---------- Topbar ---------- */
.dealer-page .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 70px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 30px rgba(5, 5, 5, 0.04);
  backdrop-filter: blur(12px);
}

.dealer-page .brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.dealer-page .brand img {
  width: 124px;
  height: 50px;
  object-fit: contain;
  object-position: left center;
  mix-blend-mode: multiply;
}

.dealer-page .brand-copy {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.dealer-page .brand-copy strong {
  display: block;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.dealer-page .brand-copy span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dealer-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dealer-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(22, 101, 52, 0.14);
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.dealer-pill.is-success {
  border-color: rgba(22, 101, 52, 0.18);
  background: var(--success-soft);
  color: var(--success);
}

.dealer-pill.is-warn {
  border-color: rgba(180, 83, 9, 0.22);
  background: var(--warn-soft);
  color: var(--warn);
}

.dealer-pill.is-off {
  border-color: rgba(185, 28, 28, 0.2);
  background: var(--danger-soft);
  color: var(--danger);
}

/* Login state pill (greyish, no checkmark) */
.dealer-page #loginPanel .dealer-pill {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--muted);
}

/* ---------- Buttons (override base.css) ---------- */
.dealer-page .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 18px;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.dealer-page .btn:hover {
  transform: translateY(-1px);
}

.dealer-page .btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.dealer-page .btn-primary:hover {
  background: var(--accent-dark);
}

.dealer-page .btn-secondary {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--line);
}

.dealer-page .btn-secondary:hover {
  border-color: rgba(200, 50, 42, 0.32);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Tabs ---------- */
.dealer-link-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.dealer-link-bar[hidden] {
  display: none;
}

.dealer-link-qr {
  display: grid;
  justify-items: center;
  gap: 5px;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.dealer-link-qr[hidden] {
  display: none;
}

.dealer-link-qr img {
  display: block;
  width: 74px;
  height: 74px;
}

.dealer-link-qr figcaption {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.dealer-link-bar-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
}

.dealer-link-bar-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dealer-link-bar-url {
  display: block;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dealer-link-bar-url:hover {
  text-decoration: underline;
}

.dealer-tabs {
  display: flex;
  gap: 6px;
  margin-top: 18px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 30px rgba(5, 5, 5, 0.04);
  backdrop-filter: blur(12px);
  overflow-x: auto;
}

.dealer-tab {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.dealer-tab:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.dealer-tab.active {
  background: var(--accent);
  color: #ffffff;
}

.tag-count {
  min-width: 20px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.dealer-tab:not(.active) .tag-count {
  background: var(--accent);
  color: #ffffff;
}

.tag-count:empty,
.tag-count[data-count="0"] {
  display: none;
}

.dealer-content {
  margin-top: 18px;
}

.dealer-panel {
  display: grid;
  gap: 18px;
}

.dealer-panel.hidden {
  display: none;
}

/* ---------- Workbench grid (matches v17) ---------- */
.workbench {
  display: grid;
  grid-template-columns: minmax(0, 0.96fr) minmax(360px, 1.04fr);
  gap: 18px;
  align-items: stretch;
}

.workbench-left {
  display: grid;
  gap: 18px;
}

/* ---------- Panel ---------- */
.dealer-page .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.dealer-page .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.dealer-page .panel-head h2 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.dealer-page .panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.dealer-page .panel-body {
  padding: 18px;
}

/* ---------- Field (override base.css) ---------- */
.dealer-page .field {
  display: grid;
  gap: 8px;
}

.dealer-page .field label {
  color: var(--fg);
  font-size: 13px;
  font-weight: 800;
}

.dealer-page .field input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--fg);
  outline: 0;
  padding: 0 13px;
  font-size: 15px;
  font-weight: 700;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.dealer-page .field input:focus {
  border-color: rgba(200, 50, 42, 0.58);
  box-shadow: 0 0 0 4px rgba(200, 50, 42, 0.08);
}

/* ---------- Quote form (3 inputs + 1 button across) ---------- */
.quote-form {
  display: grid;
  grid-template-columns: 1fr 0.56fr 0.44fr auto;
  gap: 12px;
  align-items: end;
}

.quote-form .field {
  margin: 0;
}

.quote-form .btn {
  height: 46px;
  white-space: nowrap;
}

#lookupVin {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dealer-page .error {
  min-height: 18px;
  margin-top: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

.dealer-page .error:empty {
  display: none;
}

.dealer-page .quote-progress {
  margin-top: 12px;
}

/* ---------- Adjust panel ---------- */
.adjust-grid {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.percent-input {
  display: flex;
  align-items: center;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  overflow: hidden;
}

.percent-input input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0 6px 0 13px;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 850;
}

.percent-input b {
  padding-right: 12px;
  color: var(--muted);
  font-size: 14px;
}

.dealer-page input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--fg);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.chip:hover,
.chip.active {
  border-color: rgba(200, 50, 42, 0.26);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Preview panel (the dual-price card) ---------- */
.preview-panel {
  display: grid;
  min-height: 100%;
  padding: 0;
}

.vehicle-card {
  display: grid;
  grid-template-rows: auto auto auto auto;
  min-height: 100%;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0) 52%, rgba(200, 50, 42, 0.07) 100%),
    #ffffff;
}

.vehicle-head {
  padding: 22px 22px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.vehicle-head span {
  display: block;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.vehicle-head strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(22px, 2.2vw, 27px);
  line-height: 1.24;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.price-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line-soft);
}

.price-box {
  padding: 22px;
}

.price-box + .price-box {
  border-left: 1px solid var(--line-soft);
}

.price-box span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.price-box strong {
  display: block;
  margin-top: 9px;
  font-family: var(--font-mono);
  font-size: clamp(30px, 3.5vw, 42px);
  line-height: 1;
  letter-spacing: -0.055em;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.price-box.final strong {
  color: var(--accent);
}

.dealer-result-message {
  margin: 0;
  padding: 14px 22px;
  color: var(--muted);
  font-size: 13px;
}

.dealer-result-message:empty {
  display: none;
}

.dealer-result-message.error {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Toast ---------- */
.dealer-page .toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  padding: 12px 14px;
  border: 1px solid rgba(22, 101, 52, 0.18);
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: var(--shadow-lg);
  color: var(--success);
  font-size: 13px;
  font-weight: 850;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.dealer-page .toast.show {
  opacity: 1;
  transform: translateY(0);
}

.dealer-page .toast.error {
  border-color: rgba(185, 28, 28, 0.22);
  color: var(--danger);
}

/* ---------- Auth screen (for login state) ---------- */
.auth-page .topbar + .auth-screen {
  margin-top: 18px;
}

.auth-screen {
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.dealer-auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.86fr);
  gap: 22px;
  align-items: center;
  padding: 28px 0 60px;
  place-items: stretch;
}

.dealer-auth .auth-card {
  width: 100%;
  max-width: 460px;
  margin-left: auto;
}

.dealer-auth .console-auth-stage {
  position: relative;
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 28% 22%, rgba(200, 50, 42, 0.12), transparent 38%),
    radial-gradient(circle at 78% 84%, rgba(5, 5, 5, 0.06), transparent 42%),
    linear-gradient(180deg, #ffffff 0%, #fff8f6 60%, var(--bg) 100%);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

@media (max-width: 900px) {
  .dealer-auth {
    grid-template-columns: 1fr;
  }

  .dealer-auth .console-auth-stage {
    min-height: 260px;
    order: -1;
  }

  .dealer-auth .auth-card {
    margin-left: 0;
    max-width: 100%;
  }
}

.auth-card {
  width: min(440px, 100%);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 60px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--surface-2);
  color: var(--accent);
}

.auth-message {
  min-height: 18px;
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.auth-message:empty {
  display: none;
}

/* ---------- Form rows ---------- */
.dealer-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dealer-link-form {
  display: grid;
  gap: 14px;
}

/* ---------- Lists (links / requests / events) ---------- */
.dealer-link-list,
.dealer-request-list,
.dealer-event-list {
  display: grid;
  gap: 10px;
}

.link-row,
.request-row,
.event-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.link-row-info,
.request-row-info {
  min-width: 0;
}

.link-row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.link-row-title strong {
  font-size: 14px;
  font-weight: 800;
}

.link-row-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.link-row-url {
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-row-url a {
  color: var(--accent);
}

.link-row-actions,
.request-row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.link-row-actions .btn,
.request-row-actions .btn {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.request-row {
  align-items: start;
}

.request-row.is-new {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 50, 42, 0.12);
}

.request-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.request-row-head strong {
  font-size: 15px;
  font-weight: 800;
}

.request-row-head time {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.request-row-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.request-row-grid > div {
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.request-row-grid > .request-row-grid-full {
  grid-column: 1 / -1;
}

.request-row-grid dt {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.request-row-grid dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.event-row strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
}

.event-row span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.event-row time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- Tab badge with count override (active state) ---------- */
.dealer-tab.active .tag-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* ---------- Responsive (matches v17) ---------- */
@media (max-width: 900px) {
  .workbench {
    grid-template-columns: 1fr;
  }

  .vehicle-card {
    min-height: auto;
  }

  .quote-form {
    grid-template-columns: 1fr 1fr;
  }

  .quote-form .field:first-child {
    grid-column: 1 / -1;
  }

  .quote-form .btn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .dealer-page .page {
    width: min(100vw - 20px, 1180px);
    padding-top: 12px;
  }

  .dealer-page .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .dealer-top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .dealer-page .brand-copy {
    display: none;
  }

  .quote-form,
  .adjust-grid,
  .price-row,
  .dealer-form-row {
    grid-template-columns: 1fr;
  }

  .dealer-page .btn {
    width: 100%;
  }

  .dealer-link-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .dealer-link-qr {
    justify-self: start;
  }

  .price-box + .price-box {
    border-left: 0;
    border-top: 1px solid var(--line-soft);
  }

  .link-row,
  .request-row {
    grid-template-columns: 1fr;
  }

  .link-row-actions,
  .request-row-actions {
    justify-content: flex-start;
  }
}

/* ---------- Detailed quote table (dealer config) ---------- */
.detail-table {
  display: grid;
  gap: 8px;
}

.detail-row {
  display: grid;
  grid-template-columns: 56px 1fr 140px;
  align-items: center;
  gap: 12px;
}

.detail-row-head {
  padding: 0 4px 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.detail-switch {
  display: flex;
  justify-content: center;
}

.detail-switch input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent, #c8322a);
  cursor: pointer;
}

.detail-row.is-locked {
  padding: 8px;
  border: 1px solid color-mix(in oklab, var(--accent, #c8322a), transparent 74%);
  border-radius: var(--radius-md, 12px);
  background: color-mix(in oklab, var(--accent, #c8322a), transparent 94%);
}

.detail-row.is-locked .detail-switch input[type="checkbox"],
.detail-row.is-locked .detail-label-input {
  cursor: not-allowed;
}

.detail-row.is-locked .detail-label-input {
  color: var(--fg);
  background: var(--surface-2, #f6f7f9);
  font-weight: 700;
}

.detail-label-input,
.detail-deduction-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 10px);
  background: var(--surface, #fff);
  color: var(--fg);
  font-size: 14px;
}

.detail-label-input:focus,
.detail-deduction-input:focus {
  outline: none;
  border-color: var(--accent, #c8322a);
  box-shadow: 0 0 0 3px var(--accent-ring, rgba(200, 50, 42, 0.18));
}

.detail-deduction {
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-deduction b {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 800;
  color: var(--muted);
}

.detail-deduction-input {
  padding: 0 10px;
  text-align: right;
  font-family: var(--font-mono, ui-monospace, monospace);
}

.detail-locked-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--accent, #c8322a), transparent 88%);
  color: var(--accent, #c8322a);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.detail-save-hint {
  font-size: 13px;
  color: var(--muted);
}

.detail-save-hint.error {
  color: var(--danger, #b91c1c);
}

@media (max-width: 640px) {
  .detail-row {
    grid-template-columns: 44px 1fr 110px;
    gap: 8px;
  }
  .detail-actions .btn {
    width: auto;
  }
}
