:root {
  --color-primary: #0057d9;
  --color-secondary: #1b1f27;
  --color-background: #ffffff;
  --color-text: #111318;
  --color-surface: #f4f5f7;
  --color-border: #e1e4e9;
  --color-on-primary: #ffffff;
  --color-underpriced: #1b8a4b;
  --color-fair: #b07a05;
  --color-overpriced: #c02f2f;
  --color-muted: #9aa0ab;
  --radius: 10px;
  --spacing: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-background);
  color: var(--color-text);
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
}

.app__header {
  display: flex;
  align-items: center;
  gap: var(--spacing);
  padding: var(--spacing);
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.app__logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: #ffffff;
  flex-shrink: 0;
}

.app__logo--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.app__title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.app__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.app__tagline {
  font-size: 0.8rem;
  margin: 0;
  color: color-mix(in srgb, var(--color-on-primary) 85%, transparent);
}

.brand-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px var(--spacing);
  background: var(--color-surface);
  border-radius: var(--radius);
}

.brand-switcher label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-secondary);
  white-space: nowrap;
}

.brand-switcher select {
  flex: 1;
  font-size: 0.95rem;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-background);
  color: var(--color-text);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
}

.tabs__button {
  flex: 1;
  padding: var(--spacing);
  border: none;
  background: none;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.tabs__button[aria-selected='true'] {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.view {
  flex: 1;
  padding: var(--spacing);
  display: flex;
  flex-direction: column;
  gap: var(--spacing);
}

.view[hidden] {
  display: none;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--spacing);
  background: var(--color-surface);
  border-radius: var(--radius);
}

.form[hidden] {
  display: none;
}

.form__row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form__row[hidden] {
  display: none;
}

.form__row--split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--spacing);
}

.form__row--split > * {
  min-width: 0;
}

.form label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-secondary);
}

.form input,
.form select {
  font-size: 1rem;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-background);
  color: var(--color-text);
}

.form input:focus,
.form select:focus {
  outline: none;
  border-color: var(--color-primary);
}

.button {
  padding: 10px 14px;
  border-radius: 999px;
  border: none;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.button--secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

/* Dealer Action Token Portal (UOW-65): the primary "Accept Offer" one-thumb action, kept visually
   distinct (green) from the default --color-primary button used everywhere else. */
.button--accept {
  background: var(--color-underpriced);
}

.view__subtitle {
  margin: 0 0 var(--spacing);
  color: var(--color-secondary);
}

.form--mobile {
  gap: var(--spacing);
}

.input--large {
  min-height: 44px;
  font-size: 1.05rem;
}

/* Sell form (SellerSubmissionView) layout polish. Scoped under .sell-form so the shared
   .form/.form__row/.form__row--split/.input--large rules above stay untouched for
   SpreadConfigView/TestHarnessView/SimulationView, which reuse those same base classes. */
.sell-form label {
  display: block;
  margin-bottom: 4px;
}

.sell-form__vehicle-grid {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.sell-form__vin-input {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  max-width: 22ch;
}

.sell-form__year-input {
  max-width: 8ch;
}

.sell-form__unit-field {
  position: relative;
  display: flex;
  align-items: center;
}

.sell-form__unit-field input {
  flex: 1;
  min-width: 0;
}

.sell-form__unit-field--prefix input {
  padding-left: 26px;
}

.sell-form__unit-field--suffix input {
  padding-right: 32px;
}

.sell-form__unit {
  position: absolute;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-secondary);
  pointer-events: none;
}

.sell-form__unit-field--prefix .sell-form__unit {
  left: 10px;
}

.sell-form__unit-field--suffix .sell-form__unit {
  right: 10px;
}

.sell-form__vin-helper {
  margin: 6px 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-fair);
}

.button--large {
  min-height: 48px;
  font-size: 1.05rem;
}

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  padding: var(--spacing);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-background);
  color: var(--color-secondary);
  text-align: center;
  cursor: pointer;
}

.dropzone--active {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.dropzone__input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.form__status {
  min-height: 1.2em;
  margin: 0;
  color: var(--color-underpriced);
}

.form__status--error {
  color: var(--color-overpriced);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--spacing);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card__top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.card__title {
  font-weight: 700;
  font-size: 1rem;
  margin: 0;
  min-width: 0;
  overflow-wrap: break-word;
}

.card__meta {
  font-size: 0.85rem;
  color: var(--color-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card__price {
  font-weight: 700;
  color: var(--color-primary);
}

.card__actions {
  display: flex;
  gap: 8px;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  color: #ffffff;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge--underpriced {
  background: var(--color-underpriced);
}

.badge--fair {
  background: var(--color-fair);
}

.badge--overpriced {
  background: var(--color-overpriced);
}

.badge--unrated {
  background: var(--color-secondary);
}

.badge--greenlight {
  background: var(--color-underpriced);
}

.badge--marginal {
  background: var(--color-fair);
}

.badge--pass {
  background: var(--color-overpriced);
}

.badge--no-data {
  background: var(--color-secondary);
}

.badge--pending-approval {
  background: var(--color-overpriced);
}

.badge--auto-countered {
  background: var(--color-underpriced);
}

.badge--preliminary-no-vin {
  background: transparent;
  color: var(--color-fair);
  border: 1.5px solid var(--color-fair);
}

.badge--estimate-counter {
  background: var(--color-fair);
}

.badge--firm-counter {
  background: var(--color-underpriced);
}

.badge--passed {
  background: var(--color-muted);
}

.badge--needs-review {
  background: #d93025;
  animation: needs-review-pulse 1.4s ease-in-out infinite;
}

@keyframes needs-review-pulse {
  0%, 100% {
    background: #d93025;
  }
  50% {
    background: #f29900;
  }
}

.card__meta--subtle {
  color: var(--color-muted);
  font-size: 0.85em;
}

.filter-toggle {
  margin-bottom: var(--spacing);
}

.filter-toggle .button--active {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-color: var(--color-primary);
}

.modal--reject {
  max-width: 360px;
  text-align: left;
}

.modal__reject-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-secondary);
  margin: 10px 0 4px;
}

.modal__reject-select,
.modal__reject-notes {
  width: 100%;
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-background);
  color: var(--color-text);
}

.modal__reject-notes {
  resize: vertical;
}

.sync-toast {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--color-primary);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.offline-banner {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--color-fair);
  padding: 8px var(--spacing);
  text-align: center;
}

.card__counter-input {
  font-size: 1rem;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-background);
  color: var(--color-text);
  width: 120px;
}

.card__counter-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.tier-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--spacing);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tier-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tier-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding: 8px;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.tier-row__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 100px;
}

.tier-row__field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-secondary);
}

.tier-row__remove {
  align-self: flex-end;
}

.empty-state {
  color: var(--color-secondary);
  font-size: 0.9rem;
  text-align: center;
  padding: var(--spacing);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 19, 24, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing);
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--color-background);
  color: var(--color-text);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.modal__stage {
  margin: 0 0 8px;
  color: var(--color-primary);
  font-size: 1rem;
}

.modal__message {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-secondary);
}

.modal--doc {
  max-width: 480px;
}

.modal__doc-content {
  margin-bottom: var(--spacing);
}

.modal__doc-image {
  max-width: 100%;
  border-radius: var(--radius);
}

.view--map {
  padding: 0;
  position: relative;
  flex: 1;
}

.map-view__canvas {
  position: absolute;
  inset: 0;
}

.map-dart-pin {
  cursor: pointer;
  display: flex;
  transform: translateY(-50%);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.map-location-bar {
  position: absolute;
  top: var(--spacing);
  left: var(--spacing);
  right: var(--spacing);
  z-index: 15;
  display: block;
  width: auto;
  margin: 0 auto;
  max-width: 280px;
  padding: 8px 14px;
  background: var(--color-background);
  color: var(--color-text);
  border: none;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.map-locate-btn {
  position: absolute;
  right: var(--spacing);
  bottom: calc(var(--spacing) * 2 + 56px);
  z-index: 15;
  width: 48px;
  height: 48px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--color-background);
  color: var(--color-primary);
  font-size: 1.3rem;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-locate-btn[hidden] {
  display: none;
}

.map-locate-btn[disabled] {
  opacity: 0.6;
  cursor: wait;
}

.location-modal {
  text-align: left;
}

.location-modal__label {
  display: block;
  font-size: 0.85rem;
  color: var(--color-secondary);
  margin-bottom: 6px;
}

.location-modal__input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.location-modal__suggestions {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.location-modal__suggestions[hidden] {
  display: none;
}

.location-modal__suggestion {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  color: var(--color-text);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.location-modal__suggestion:not(:last-child) {
  border-bottom: 1px solid var(--color-border);
}

.location-modal__suggestion:hover,
.location-modal__suggestion:focus-visible {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.location-modal__error {
  color: var(--color-overpriced);
  font-size: 0.8rem;
  margin: 0 0 10px;
}

.location-modal__error[hidden] {
  display: none;
}

.location-modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.map-drawer {
  position: absolute;
  left: var(--spacing);
  right: var(--spacing);
  bottom: var(--spacing);
  background: var(--color-background);
  color: var(--color-text);
  border-radius: var(--radius);
  padding: var(--spacing);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Above the locate button (15) and the chat discovery bar (20) — both float over the same bottom
     region, and without this the drawer's own Close button (and any content near its edges) can end
     up underneath one of them, unclickable. */
  z-index: 25;
}

.map-drawer[hidden] {
  display: none;
}

.map-drawer__close {
  align-self: flex-end;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-secondary);
  font-size: 0.85rem;
  cursor: pointer;
}

/*
 * MapLibre's own stylesheet gives popups a plain white card with no theming hooks, so the dark/gold
 * treatment is forced here rather than left to the (always-dark, per the CARTO Dark Matter basemap)
 * map surface — unlike the rest of the chrome, this isn't tenant-themed.
 */
.maplibregl-popup-content {
  background: #0f172a;
  color: #f1f5f9;
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  max-width: 240px;
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
  border-top-color: #0f172a;
}

.maplibregl-popup-anchor-top .maplibregl-popup-tip {
  border-bottom-color: #0f172a;
}

.map-synopsis {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map-synopsis__title {
  font-size: 1rem;
  font-weight: 700;
  color: #fbbf24;
}

.map-synopsis__meta,
.map-synopsis__dealer {
  font-size: 0.85rem;
  color: #f1f5f9;
}

.map-synopsis__price {
  font-weight: 700;
  color: #22c55e;
}

.map-drawer__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-drawer__verdict {
  align-self: flex-start;
}

.map-drawer__summary {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-secondary);
}

.map-drawer__title {
  margin: 0;
  font-size: 1.05rem;
}

.map-drawer__inventory {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 40vh;
  overflow-y: auto;
}

.map-drawer__vehicle-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map-drawer__vehicle-card--highlight {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
}

.map-drawer__vehicle-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.map-drawer__vehicle-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.map-drawer__vehicle-meta {
  font-size: 0.8rem;
  color: var(--color-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.map-drawer__vehicle-price {
  font-weight: 700;
  color: var(--color-primary);
}

.radar-metric-pill {
  position: absolute;
  top: var(--spacing);
  left: var(--spacing);
  right: var(--spacing);
  z-index: 15;
  margin: 0 auto;
  width: fit-content;
  max-width: calc(100% - var(--spacing) * 2);
  padding: 8px 16px;
  background: var(--color-background);
  color: var(--color-text);
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow-x: auto;
}

.radar-unlocated-dock {
  position: absolute;
  right: var(--spacing);
  bottom: var(--spacing);
  z-index: 20;
  width: 260px;
  max-width: calc(100% - var(--spacing) * 2);
  background: var(--color-background);
  color: var(--color-text);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.radar-unlocated-dock__toggle {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.radar-unlocated-dock__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  max-height: 35vh;
  overflow-y: auto;
}

.radar-unlocated-dock__list[hidden] {
  display: none;
}

.radar-unlocated-dock__empty {
  margin: 0;
  padding: 4px;
  font-size: 0.8rem;
  color: var(--color-secondary);
}

.radar-unlocated-dock__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: none;
  color: var(--color-text);
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
}

.radar-unlocated-dock__item-title {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.radar-unlocated-dock__item-offer {
  font-weight: 700;
  color: var(--color-primary);
}

.radar-pin-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #0f172a;
  background: var(--radar-pin-color, #fbbf24);
}

.chat-discovery__bar {
  position: absolute;
  left: var(--spacing);
  right: var(--spacing);
  bottom: var(--spacing);
  display: flex;
  gap: 8px;
  padding: 8px;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  z-index: 20;
}

.chat-discovery__bar:focus-within {
  border-color: var(--color-primary);
}

.chat-discovery__input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.95rem;
  padding: 8px 12px;
  background: transparent;
  color: var(--color-text);
}

.chat-discovery__submit {
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-discovery__results {
  position: absolute;
  left: var(--spacing);
  right: var(--spacing);
  bottom: calc(var(--spacing) * 4 + 48px);
  top: var(--spacing);
  background: var(--color-background);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--spacing);
  z-index: 20;
  overflow: hidden;
}

.chat-discovery__results-summary {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-secondary);
}

.chat-discovery__results-summary[hidden] {
  display: none;
}

.chat-discovery__results[hidden] {
  display: none;
}

.chat-discovery__results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-discovery__results-title {
  margin: 0;
  font-size: 1rem;
}

.chat-discovery__close {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-secondary);
  font-size: 0.85rem;
  cursor: pointer;
}

.chat-discovery__results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.chat-discovery__card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--spacing);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--color-background);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-discovery__card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.chat-discovery__card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.chat-discovery__card-meta {
  font-size: 0.8rem;
  color: var(--color-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-discovery__card-price {
  font-weight: 700;
  color: var(--color-primary);
}

.chat-discovery__empty {
  color: var(--color-secondary);
  font-size: 0.9rem;
  text-align: center;
  padding: var(--spacing);
}

@media (min-width: 600px) {
  .app {
    max-width: 720px;
  }
}

.waiting-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing);
  padding: calc(var(--spacing) * 3) var(--spacing);
  text-align: center;
}

.waiting-screen[hidden] {
  display: none;
}

.waiting-screen__spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  animation: waiting-screen-spin 0.9s linear infinite, waiting-screen-pulse 1.6s ease-in-out infinite;
}

.waiting-screen__spinner[hidden] {
  display: none;
}

.waiting-screen__message {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

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

@keyframes waiting-screen-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.harness__brackets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--spacing);
}

.harness__preview {
  margin-bottom: var(--spacing);
}

.harness__preview-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px var(--spacing);
  margin: 0 0 var(--spacing);
}

.harness__preview-list dt {
  color: var(--color-secondary);
  font-size: 0.85rem;
}

.harness__preview-list dd {
  margin: 0;
  font-weight: 600;
}

.harness__qr {
  display: flex;
  justify-content: center;
  margin-bottom: var(--spacing);
}

.harness__qr svg {
  max-width: 100%;
  height: auto;
}

.testbed {
  position: fixed;
  right: var(--spacing);
  bottom: var(--spacing);
  z-index: 40;
}

.testbed__toggle {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-secondary);
  color: var(--color-on-primary);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.testbed__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: min(340px, calc(100vw - 2 * var(--spacing)));
  max-height: 70vh;
  overflow-y: auto;
  padding: var(--spacing);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-background);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.testbed__panel[hidden] {
  display: none;
}

.testbed__preset-select {
  width: 100%;
  padding: 8px;
  margin-bottom: var(--spacing);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-background);
  color: var(--color-text);
}

.testbed__vin-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.testbed__vin-input {
  flex: 1;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-background);
  color: var(--color-text);
  text-transform: uppercase;
}

.testbed__spec-list,
.testbed__offer-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px var(--spacing);
  margin: 0 0 var(--spacing);
}

.testbed__spec-list dt,
.testbed__offer-list dt {
  color: var(--color-secondary);
  font-size: 0.85rem;
}

.testbed__spec-list dd,
.testbed__offer-list dd {
  margin: 0;
  font-weight: 600;
}

.pairing-card__qr {
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 280px;
  aspect-ratio: 1 / 1;
  margin: 16px auto;
  padding: 16px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid var(--color-border);
}

.pairing-card__qr:empty {
  display: none;
}

.pairing-card__qr svg {
  width: 100%;
  height: 100%;
}

.analytics__filters {
  margin-bottom: var(--spacing);
}

.analytics__charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--spacing);
  margin-bottom: calc(var(--spacing) * 1.5);
}

.analytics__chart {
  padding: var(--spacing);
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  min-width: 0;
}

.analytics-chart__host svg {
  display: block;
  width: 100%;
  height: auto;
}

.analytics-chart__axis {
  stroke: var(--color-border);
  stroke-width: 1;
}

.analytics-chart__line {
  stroke: var(--color-primary);
  stroke-width: 2;
}

.analytics-chart__point {
  fill: var(--color-primary);
}

.analytics-chart__pin-line {
  stroke: var(--color-secondary);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.analytics-chart__pin-label {
  fill: var(--color-secondary);
  font-size: 9px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--spacing);
  margin-bottom: calc(var(--spacing) * 1.5);
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--spacing);
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  min-width: 0;
}

.kpi-card__label {
  font-size: 0.8rem;
  color: var(--color-secondary);
  overflow-wrap: break-word;
}

.kpi-card__value {
  font-size: 1.4rem;
  font-weight: 700;
}

.analytics__table-container {
  margin-bottom: calc(var(--spacing) * 1.5);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 8px var(--spacing);
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  color: var(--color-secondary);
  font-weight: 600;
  font-size: 0.8rem;
}

.offer-grid__table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}

.offer-grid__row--focused {
  background: var(--color-surface);
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.offer-grid__adjust-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--spacing) 0;
  white-space: normal;
}

.offer-grid-drawer {
  background: var(--color-background);
  color: var(--color-text);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  text-align: left;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.offer-grid-drawer__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--spacing);
}

.data-bar {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 90px;
  height: 18px;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-bar__fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--color-primary);
  opacity: 0.25;
}

.data-bar__label {
  position: relative;
  padding: 0 6px;
  font-size: 0.8rem;
  font-weight: 600;
}

.approval-split-bar {
  display: flex;
  width: 100%;
  height: 20px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
}

.approval-split-bar__segment--auto {
  background: var(--color-primary);
}

.approval-split-bar__segment--human {
  background: var(--color-fair);
}

.approval-split__readout {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--color-secondary);
}

.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

.bottom-nav__button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 8px 4px;
  border-radius: var(--radius);
}

.bottom-nav__button[aria-selected='true'] {
  color: var(--color-primary);
  background: var(--color-background);
}

.a2hs-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: calc(var(--spacing) * 1.5) var(--spacing) calc(var(--spacing) * 1.5 + env(safe-area-inset-bottom));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.a2hs-drawer__logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.a2hs-drawer__logo--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: var(--color-on-primary, #ffffff);
  font-weight: 700;
}

.a2hs-drawer__title {
  font-weight: 600;
}

.a2hs-drawer__steps {
  text-align: left;
  font-size: 0.85rem;
  color: var(--color-secondary);
  padding-left: 1.2em;
  margin: 0;
}

.a2hs-drawer__dismiss {
  border: none;
  background: none;
  color: var(--color-secondary);
  font-size: 0.8rem;
  text-decoration: underline;
}

@media (max-width: 640px) {
  .tabs {
    display: none;
  }

  .bottom-nav {
    display: flex;
  }

  /* Bottom nav occupies the viewport's bottom edge on mobile, so the A2HS drawer
     stacks directly above it instead of overlapping it. */
  .a2hs-drawer {
    bottom: calc(52px + env(safe-area-inset-bottom));
  }
}

.vin-input-row {
  display: flex;
  gap: 8px;
}

.vin-input-row > input {
  flex: 1;
  min-width: 0;
}

.scanner-modal {
  max-width: 420px;
  padding: 16px;
}

.scanner-modal__viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.scanner-modal__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-modal__reticle {
  position: absolute;
  inset: 22% 8%;
  border: 3px solid var(--color-primary);
  border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.scanner-modal__status {
  margin: var(--spacing) 0 0;
  font-size: 0.9rem;
  color: var(--color-secondary);
  min-height: 1.2em;
}

.scanner-modal__status--error {
  color: var(--color-overpriced);
}

.scanner-modal__fallback {
  display: flex;
  gap: 8px;
  margin-top: var(--spacing);
}

.scanner-modal__fallback input {
  flex: 1;
  min-width: 0;
}

.scanner-modal__actions {
  margin-top: var(--spacing);
  display: flex;
  justify-content: center;
}

.comparison-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--spacing);
  margin-bottom: calc(var(--spacing) * 1.5);
}

.comparison-card {
  padding: var(--spacing);
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  min-width: 0;
}

.comparison-card__title {
  margin: 0 0 var(--spacing);
}

.pin-challenge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing);
  padding: calc(var(--spacing) * 2);
}

.pin-challenge__digits {
  display: flex;
  gap: 8px;
}

.pin-challenge__digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-background);
  color: var(--color-text);
}

.pin-challenge__digit:focus {
  outline: none;
  border-color: var(--color-primary);
}

.pin-challenge__error {
  color: #c0392b;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.view__header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing);
}

.team-roster {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--spacing);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: calc(var(--spacing) * 1.5);
}

.app__seller-link {
  display: block;
  text-align: center;
  padding: 8px;
  font-size: 0.8rem;
  color: var(--color-secondary);
}

.simulation__results .kpi-row {
  margin-bottom: 0;
}

/* Customer Negotiation Portal (UOW-58) */
.offer-view {
  text-align: center;
}

.offer-view__status {
  padding: calc(var(--spacing) * 3) var(--spacing);
}

.offer-view__header {
  margin-bottom: var(--spacing);
}

.offer-view__comparison {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  margin-bottom: var(--spacing);
}

.offer-view__comparison-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.offer-view__comparison-row--highlight {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-primary);
}

.offer-view__net-gain {
  margin: 0;
  color: var(--color-underpriced);
  font-weight: 600;
}

.offer-view__countdown {
  font-weight: 600;
  color: var(--color-fair);
  margin-bottom: var(--spacing);
}

.offer-view--expired,
.offer-view--decided {
  padding: calc(var(--spacing) * 2) var(--spacing);
}

/* UOW-68: Dealer Desk Spread Intelligence Dashboard — a self-contained dark command-center
   surface (CarBoyZ dark palette), deliberately not using the light-theme --color-* tokens above
   so it reads as its own executive workspace rather than inheriting the rest of the app's chrome. */
.analytics-dashboard {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: calc(var(--spacing) * 1.5);
}

.analytics-dashboard h2,
.analytics-dashboard .view__subtitle {
  color: #e2e8f0;
}

.analytics-dashboard__kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing);
}

.analytics-dashboard__kpi-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--radius);
  padding: var(--spacing);
}

.analytics-dashboard__kpi-label {
  font-size: 0.8rem;
  color: #94a3b8;
}

.analytics-dashboard__kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fbbf24;
}

.analytics-dashboard__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--spacing) * 1.5);
}

.analytics-dashboard__column {
  display: flex;
  flex-direction: column;
  gap: var(--spacing);
}

.analytics-dashboard__chart-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--radius);
  padding: var(--spacing);
}

.analytics-dashboard__chart-title {
  margin: 0 0 8px;
  color: #e2e8f0;
  font-size: 1rem;
}

.analytics-dashboard__chart-host svg {
  width: 100%;
  height: auto;
}

.analytics-dashboard__directives-card {
  background: #1e293b;
  border: 1px solid #fbbf24;
}

.analytics-dashboard__directives-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analytics-dashboard__directive {
  background: #0f172a;
  border-left: 3px solid #fbbf24;
  padding: 8px 10px;
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 0.9rem;
}

/* UOW-69: Desk Observability Data Grid */
.analytics-dashboard__data-grid {
  margin-top: var(--spacing);
}

.analytics-dashboard__data-grid-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing);
  margin-bottom: var(--spacing);
  flex-wrap: wrap;
}

.analytics-dashboard__search {
  flex: 1;
  min-width: 200px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 6px 10px;
}

.analytics-dashboard__filter-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1e293b;
  border: 1px solid #fbbf24;
  color: #fbbf24;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
}

.analytics-dashboard__filter-clear {
  background: none;
  border: none;
  color: #fbbf24;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.analytics-dashboard__deals-table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}

.analytics-dashboard__deals-table th,
.analytics-dashboard__deals-table td {
  color: #e2e8f0;
  border-bottom: 1px solid #334155;
}

.analytics-dashboard__deals-table th[role='button'] {
  cursor: pointer;
  user-select: none;
}

.analytics-dashboard__badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  color: #ffffff;
  white-space: nowrap;
}

.analytics-dashboard__badge--won {
  background: #10b981;
}

.analytics-dashboard__badge--counter_lost {
  background: #64748b;
}

.analytics-dashboard__badge--declined_velocity {
  background: #fbbf24;
}

.analytics-dashboard__badge--declined_margin {
  background: #ef4444;
}

.analytics-dashboard__record-sale-btn {
  white-space: nowrap;
}

/* UOW-71: Lot Aging Decay Monitor ribbon */
.analytics-dashboard__aging-ribbon {
  background: #1e293b;
  border: 1px solid #fbbf24;
  border-radius: var(--radius);
  padding: var(--spacing);
  margin-bottom: var(--spacing);
}

.analytics-dashboard__aging-ribbon[hidden] {
  display: none;
}

.analytics-dashboard__aging-headline {
  margin: 0 0 8px;
  color: #fbbf24;
  font-weight: 700;
}

.analytics-dashboard__aging-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analytics-dashboard__aging-chip {
  border: none;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
}

.analytics-dashboard__aging-chip--yellow {
  background: #fbbf24;
}

.analytics-dashboard__aging-chip--orange {
  background: #f97316;
}

.analytics-dashboard__aging-chip--red {
  background: #ef4444;
  color: #ffffff;
}

/* UOW-71: Record Sale disposition modal */
.disposition-modal__meta {
  color: #94a3b8;
  margin-bottom: var(--spacing);
}

.disposition-modal__preview {
  font-weight: 700;
  color: #10b981;
}

.chart-engine__axis,
.chart-engine__volume-bar {
  stroke: none;
}

.chart-engine__axis {
  stroke: #334155;
  stroke-width: 1;
}

.chart-engine__volume-bar {
  fill: #334155;
}

.chart-engine__step-line {
  stroke: #10b981;
  stroke-width: 2;
}

.chart-engine__step-point {
  fill: #10b981;
}

.chart-engine__axis-label {
  fill: #94a3b8;
  font-size: 10px;
}

.chart-engine__donut-center {
  fill: #e2e8f0;
  font-size: 13px;
  font-weight: 700;
}

/* UOW-69: hover/click affordances for the comparative-bar and donut chart-click filters. */
.chart-engine__bar,
.chart-engine__donut-arc {
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.chart-engine__bar:hover,
.chart-engine__donut-arc:hover {
  opacity: 0.75;
}

@media (max-width: 900px) {
  .analytics-dashboard__kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .analytics-dashboard__grid {
    grid-template-columns: 1fr;
  }
}
