:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #17202a;
  --muted: #6a7280;
  --line: #d9e0ea;
  --blue: #2563eb;
  --green: #0f766e;
  --amber: #b45309;
  --red: #b42318;
  --shadow: 0 16px 45px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #17202a;
  color: #fff;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
}

#last-updated,
.panel-head span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.toolbar,
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-wrap,
.filters label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

select,
input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

select {
  min-width: 82px;
  padding: 0 30px 0 10px;
}

input {
  width: 240px;
  padding: 0 10px;
}

select:focus,
input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.toggle input {
  width: 16px;
  height: 16px;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.filters {
  justify-content: space-between;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.pipeline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.step {
  min-height: 28px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.step.done {
  border-color: rgba(15, 118, 110, 0.28);
  background: rgba(15, 118, 110, 0.08);
  color: var(--green);
}

.step.pending {
  border-color: rgba(180, 83, 9, 0.25);
  background: rgba(180, 83, 9, 0.08);
  color: var(--amber);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.watch-panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.panel-head.compact {
  min-height: 44px;
  padding: 12px 14px;
}

.watch-panel pre {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  padding: 14px;
  border-top: 1px solid var(--line);
  color: var(--text);
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.55;
}

.metric {
  display: grid;
  gap: 6px;
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 25px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}

.list-panel,
.detail-panel {
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.status {
  margin: 12px 16px;
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

.status.error {
  background: rgba(180, 35, 24, 0.08);
  color: var(--red);
}

.status.hidden {
  display: none;
}

.car-list {
  display: grid;
}

.car-row {
  display: grid;
  grid-template-columns: 124px minmax(260px, 1fr) 150px 170px 116px;
  gap: 14px;
  align-items: center;
  min-height: 132px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.car-row:first-child {
  border-top: 0;
}

.car-row:hover,
.car-row.active {
  background: #f9fbfe;
}

.thumb {
  width: 124px;
  height: 84px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--surface-2);
}

.car-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.car-title h3 {
  overflow: hidden;
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.badge.green {
  background: rgba(15, 118, 110, 0.1);
  color: var(--green);
}

.badge.amber {
  background: rgba(180, 83, 9, 0.1);
  color: var(--amber);
}

.badge.blue {
  background: rgba(37, 99, 235, 0.1);
  color: var(--blue);
}

.badge.red {
  background: rgba(180, 35, 24, 0.1);
  color: var(--red);
}

.copy-chip {
  display: inline-flex;
  align-items: center;
  max-width: 150px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(37, 99, 235, 0.24);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.06);
  color: var(--blue);
  cursor: copy;
  font-size: 12px;
  white-space: nowrap;
}

.copy-chip:hover {
  border-color: rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.1);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.number-block {
  display: grid;
  gap: 5px;
}

.number-block span {
  color: var(--muted);
  font-size: 12px;
}

.number-block strong {
  font-size: 18px;
}

.action-col {
  display: grid;
  gap: 8px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
}

.link-button.blue {
  border-color: rgba(37, 99, 235, 0.32);
  background: rgba(37, 99, 235, 0.08);
  color: var(--blue);
}

.link-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.detail-panel {
  position: sticky;
  top: 12px;
  overflow: hidden;
}

.empty-state {
  display: grid;
  min-height: 620px;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--muted);
}

.empty-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 24px;
}

.detail-cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--surface-2);
}

.detail-body {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.detail-title h2 {
  font-size: 17px;
  line-height: 1.4;
}

.detail-title p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.section {
  display: grid;
  gap: 9px;
}

.section h3 {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.kv {
  min-height: 50px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
}

.kv span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.kv strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 4px;
  font-size: 13px;
}

.valuation-box,
.bid-cost-box {
  display: grid;
  gap: 9px;
}

.valuation-url,
.valuation-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.valuation-url input,
.valuation-fields input {
  width: 100%;
}

.valuation-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.valuation-result {
  display: grid;
  gap: 9px;
}

.valuation-state {
  min-height: 40px;
  padding: 10px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

.valuation-state.error {
  background: rgba(180, 35, 24, 0.08);
  color: var(--red);
}

.valuation-range {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 7px;
  background: rgba(37, 99, 235, 0.08);
}

.valuation-range span,
.price-points span,
.condition-price-head span,
.condition-price-points span,
.condition-ranges span {
  color: var(--muted);
  font-size: 12px;
}

.valuation-range strong {
  color: var(--blue);
  font-size: 20px;
}

.price-points {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.price-points div {
  min-height: 48px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
}

.price-points strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
}

.condition-price-grid {
  display: grid;
  gap: 8px;
}

.condition-price-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
}

.condition-price-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.condition-price-head strong {
  font-size: 14px;
}

.condition-price-points,
.condition-ranges {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.condition-price-points div,
.condition-ranges div {
  min-height: 42px;
  padding: 7px;
  border-radius: 6px;
  background: var(--surface);
}

.condition-price-points strong,
.condition-ranges strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}

.bid-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.bid-summary div {
  min-height: 54px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
}

.bid-summary span,
.cost-lines span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.bid-summary strong {
  display: inline-flex;
  margin-top: 4px;
  font-size: 15px;
}

.cost-lines {
  display: grid;
  gap: 7px;
}

.cost-lines div {
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
}

.cost-lines strong {
  font-size: 14px;
}

.cost-lines small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.image-strip {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.image-strip img {
  flex: 0 0 88px;
  width: 88px;
  height: 64px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--surface-2);
}

.conclusions {
  display: grid;
  gap: 7px;
}

.conclusion {
  padding: 9px;
  border-left: 3px solid var(--line);
  background: #fbfcfe;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }

  .car-row {
    grid-template-columns: 112px minmax(0, 1fr) 130px 130px;
  }

  .action-col {
    grid-column: 2 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 18px, 1500px);
    padding-top: 10px;
  }

  .topbar,
  .filters {
    align-items: stretch;
  }

  .topbar,
  .toolbar,
  .filters {
    flex-direction: column;
  }

  .toolbar,
  .filters,
  input,
  select,
  .select-wrap,
  .filters label {
    width: 100%;
  }

  .pipeline {
    margin-left: 0;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .car-row {
    grid-template-columns: 96px minmax(0, 1fr);
    min-height: 150px;
  }

  .thumb {
    width: 96px;
    height: 72px;
  }

  .number-block,
  .action-col {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .car-title h3 {
    white-space: normal;
  }

  .kv-grid {
    grid-template-columns: 1fr;
  }

  .valuation-fields,
  .price-points,
  .bid-summary,
  .condition-price-points,
  .condition-ranges {
    grid-template-columns: 1fr;
  }
}
