:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  background: var(--cc-bg);
  color: var(--cc-text);
  --cc-bg: #07090d;
  --cc-surface: #10151d;
  --cc-surface-raised: #151c26;
  --cc-panel: #0c1118;
  --cc-text: #f4f7fb;
  --cc-muted: #9aa7b7;
  --cc-subtle: #6d7887;
  --cc-line: #2a3442;
  --cc-line-strong: #3a4656;
  --cc-blue: #1f6feb;
  --cc-blue-strong: #2f81f7;
  --cc-red: #f04438;
  --cc-green: #22c55e;
  --cc-amber: #f59e0b;
  --cc-focus: #7dd3fc;
  --cc-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

:root[data-theme="light"] {
  color-scheme: light;
  --cc-bg: #f5f7fa;
  --cc-surface: #ffffff;
  --cc-surface-raised: #f9fbfd;
  --cc-panel: #ffffff;
  --cc-text: #101722;
  --cc-muted: #536170;
  --cc-subtle: #728091;
  --cc-line: #d9e0e8;
  --cc-line-strong: #b9c4d0;
  --cc-blue: #155eef;
  --cc-blue-strong: #0f4fc9;
  --cc-red: #d92d20;
  --cc-green: #16803f;
  --cc-amber: #b54708;
  --cc-focus: #155eef;
  --cc-shadow: 0 18px 42px rgba(16, 24, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--cc-bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  min-height: 88px;
  border-bottom: 1px solid var(--cc-line);
}

.brand-kicker,
.section-label {
  margin: 0 0 6px;
  color: var(--cc-red);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--cc-text);
  font-size: 34px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 8px;
  color: var(--cc-text);
  font-size: 22px;
  line-height: 1.18;
}

h3 {
  margin-bottom: 10px;
  color: var(--cc-text);
  font-size: 15px;
  line-height: 1.25;
}

.theme-toggle,
.primary-action,
.secondary-action {
  min-height: 44px;
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
}

.theme-toggle {
  min-width: 136px;
  border: 1px solid var(--cc-line-strong);
  background: var(--cc-surface);
  color: var(--cc-text);
}

.hero-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 18px 0;
  overflow: hidden;
  border: 1px solid var(--cc-line);
  border-radius: 8px;
  background: var(--cc-line);
}

.hero-strip div {
  min-height: 76px;
  padding: 16px;
  background: var(--cc-surface);
}

.hero-strip p {
  margin: 8px 0 0;
  color: var(--cc-text);
  font-size: 15px;
  font-weight: 750;
}

.step-marker {
  color: var(--cc-blue-strong);
  font-size: 12px;
  font-weight: 900;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 408px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.workspace > *,
.panel > *,
.result-heading > *,
.seller-support > *,
.evidence-grid > *,
.feedback-grid > *,
.alternative-card > *,
.vehicle-facts > * {
  min-width: 0;
}

.panel,
.limits {
  border: 1px solid var(--cc-line);
  border-radius: 8px;
  background: var(--cc-panel);
  box-shadow: var(--cc-shadow);
}

.panel {
  padding: 20px;
}

.panel-heading p,
.field small,
.status-message,
.limits li,
#result-subtitle,
.empty-state,
.source-box dd {
  color: var(--cc-muted);
  overflow-wrap: anywhere;
}

.input-panel {
  position: sticky;
  top: 16px;
}

.field-grid {
  display: grid;
  gap: 14px;
}

.field {
  position: relative;
  display: grid;
  gap: 6px;
  color: var(--cc-text);
  font-weight: 800;
}

.field small {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--cc-line-strong);
  border-radius: 6px;
  background: var(--cc-surface);
  color: var(--cc-text);
}

input,
select {
  min-height: 44px;
}

input[readonly],
input:disabled,
select:disabled {
  background: var(--cc-surface-raised);
  color: var(--cc-subtle);
  cursor: not-allowed;
}

.typeahead-list {
  position: absolute;
  z-index: 20;
  top: calc(100% - 18px);
  right: 0;
  left: 0;
  max-height: 196px;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--cc-line-strong);
  border-radius: 6px;
  background: var(--cc-surface);
  box-shadow: var(--cc-shadow);
  list-style: none;
}

.typeahead-option {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--cc-text);
  font-weight: 750;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.typeahead-option:hover,
.typeahead-option.is-active {
  background: var(--cc-surface-raised);
  outline: 1px solid var(--cc-blue-strong);
}

.typeahead-empty {
  min-height: 36px;
  padding: 8px 10px;
  color: var(--cc-muted);
  font-weight: 600;
  overflow-wrap: anywhere;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--cc-focus);
  outline-offset: 2px;
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.primary-action {
  border: 1px solid var(--cc-blue-strong);
  background: var(--cc-blue);
  color: #ffffff;
}

.primary-action:not(:disabled):hover {
  background: var(--cc-blue-strong);
}

.secondary-action {
  padding: 0 16px;
  border: 1px solid var(--cc-line-strong);
  background: transparent;
  color: var(--cc-text);
}

.secondary-action:not(:disabled):hover,
.theme-toggle:hover {
  border-color: var(--cc-blue-strong);
}

.status-message {
  min-height: 20px;
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.45;
}

.result-panel {
  min-height: 560px;
}

.result-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--cc-line-strong);
  border-radius: 6px;
  color: var(--cc-muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
  white-space: normal;
}

.empty-state,
.error-state,
.summary-panel,
.facts-panel,
.alternatives-panel,
.seller-support,
.trust-card,
.traceability-panel {
  border: 1px solid var(--cc-line);
  border-radius: 8px;
  background: var(--cc-surface);
}

.empty-state,
.error-state {
  padding: 16px;
}

.error-state {
  border-color: rgba(240, 68, 56, 0.65);
}

.error-state p:first-child {
  color: var(--cc-red);
  font-weight: 850;
}

.result-content {
  display: grid;
  gap: 14px;
}

.summary-panel,
.facts-panel,
.alternatives-panel,
.seller-support,
.trust-card,
.traceability-panel {
  padding: 14px;
}

.result-summary p:last-child,
.empty-state p:last-child,
.error-state p:last-child,
.seller-support p:last-child {
  margin-bottom: 0;
}

.vehicle-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.vehicle-facts div,
.alternative-card {
  padding: 12px;
  border: 1px solid var(--cc-line);
  border-radius: 6px;
  background: var(--cc-surface-raised);
}

.vehicle-facts dt {
  color: var(--cc-muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.vehicle-facts dd {
  margin: 4px 0 0;
  color: var(--cc-text);
  overflow-wrap: anywhere;
}

.alternative-list {
  display: grid;
  gap: 10px;
}

.alternative-card {
  display: grid;
  gap: 8px;
}

.alternative-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.alternative-card h4 {
  margin: 0;
  color: var(--cc-text);
  font-size: 15px;
}

.alternative-card p {
  margin-bottom: 0;
  color: var(--cc-muted);
  line-height: 1.45;
}

.seller-support {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border-color: rgba(31, 111, 235, 0.58);
}

.trust-note {
  margin-bottom: 10px;
  color: var(--cc-muted);
  line-height: 1.45;
}

.traceability-panel {
  display: block;
}

.traceability-panel > summary {
  min-height: 36px;
  color: var(--cc-text);
  font-weight: 850;
  cursor: pointer;
}

.traceability-panel > summary:focus-visible {
  border-radius: 6px;
  outline: 3px solid var(--cc-focus);
  outline-offset: 2px;
}

.traceability-panel > p {
  color: var(--cc-muted);
}

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

.trust-card ul,
.limits ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.55;
}

.source-box dl {
  margin: 0;
}

.source-box dt {
  margin-top: 8px;
  color: var(--cc-text);
  font-weight: 800;
}

.source-box dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.feedback-box {
  margin-top: 16px;
  padding: 14px;
  border-top: 1px solid var(--cc-line);
}

.feedback-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.feedback-comment {
  margin-top: 14px;
}

.limits {
  margin-top: 18px;
  padding: 18px 20px;
}

@media (max-width: 840px) {
  .topbar,
  .result-heading,
  .seller-support {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace,
  .hero-strip,
  .evidence-grid,
  .feedback-grid,
  .seller-support {
    grid-template-columns: 1fr;
  }

  .workspace {
    min-width: 0;
  }

  .input-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .shell {
    width: 100%;
    padding: 16px 0;
  }

  .topbar,
  .hero-strip,
  .workspace,
  .limits {
    margin-right: 12px;
    margin-left: 12px;
  }

  h1 {
    font-size: 28px;
  }

  .panel {
    padding: 16px;
  }

  .vehicle-facts {
    grid-template-columns: 1fr;
  }

  .alternative-card header {
    display: grid;
  }
}
