:root {
  color-scheme: dark;
  --ink: #f4f0e8;
  --muted: #a9a29a;
  --line: #302c2a;
  --panel: #171514;
  --soft: #0c0b0b;
  --soft-2: #211f1d;
  --accent: #d94a36;
  --accent-2: #5da6a7;
  --accent-3: #c99539;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 86% 8%, rgba(217, 74, 54, 0.1), transparent 26%),
    radial-gradient(circle at 16% 92%, rgba(201, 149, 57, 0.09), transparent 28%),
    var(--soft);
  color: var(--ink);
}

body.guest-mode .admin-only {
  display: none !important;
}

body.guest-mode .detail-panel .verification-form,
body.guest-mode .detail-panel .verification-actions,
body.guest-mode .detail-panel .card-actions {
  display: none !important;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 70% 20%, rgba(217, 74, 54, 0.16), transparent 30%),
    rgba(12, 11, 11, 0.96);
}

.auth-screen.hidden {
  display: none;
}

.auth-box {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: rgba(23, 21, 20, 0.96);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.auth-box img {
  display: block;
  width: 92px;
  margin-bottom: 14px;
}

.auth-box h2,
.auth-box p {
  margin: 0 0 8px;
}

.auth-box p,
.auth-error {
  color: var(--muted);
}

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

.auth-form.hidden {
  display: none;
}

.auth-error {
  min-height: 20px;
  color: #ffad9f;
  font-weight: 800;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  background: #100f0f;
  color: #f8fbfa;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  background: #050505;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.sidebar-panel h2,
.quick-stats small {
  color: #8f8981;
}

.quick-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.quick-stats div {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
  border-radius: 8px;
}

.quick-stats span {
  display: block;
  font-size: 1.75rem;
  font-weight: 850;
}

.quick-stats small {
  display: block;
  margin-top: 2px;
}

.nav-pills {
  display: grid;
  gap: 8px;
}

.nav-pill,
.density-btn,
.dialog-actions button,
.icon-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
}

.nav-pill {
  border-color: rgba(255, 255, 255, 0.08);
  background: transparent;
  color: #ecf5f3;
  text-align: left;
}

.nav-pill.active {
  border-color: var(--accent-3);
  background: rgba(244, 181, 63, 0.14);
}

.sidebar-panel h2 {
  margin: 0 0 12px;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.series-breakdown {
  display: grid;
  gap: 10px;
}

.series-row {
  display: grid;
  gap: 5px;
}

.series-row header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
}

.series-bar {
  height: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.series-bar span {
  display: block;
  height: 100%;
  background: var(--accent-3);
}

.workspace {
  min-width: 0;
  padding: 28px clamp(18px, 4vw, 48px) 48px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.1rem);
  line-height: 0.98;
}

.primary-action {
  flex: 0 0 auto;
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(232, 63, 50, 0.22);
}

.secondary-action {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #211f1d;
  color: var(--ink);
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 800;
}

.cloud-action.dirty {
  border-color: var(--accent-3);
  background: rgba(244, 181, 63, 0.16);
  color: #ffd37a;
}

.cloud-action:disabled {
  cursor: wait;
  opacity: 0.74;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #100f0f;
  color: var(--ink);
  border-radius: 8px;
  padding: 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(15, 123, 140, 0.13);
}

.garage-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.garage-meta p {
  margin: 0;
  color: var(--muted);
}

.view-toggle {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.density-btn {
  border: 0;
  padding: 8px 10px;
  background: transparent;
}

.density-btn.active {
  background: var(--accent);
  color: #fff7f0;
}

.garage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 16px;
}

.garage-grid.compact {
  grid-template-columns: 1fr;
  gap: 8px;
}

.car-card {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(17, 27, 28, 0.04);
}

.list-row {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(74px, 0.5fr) minmax(110px, 0.8fr) minmax(110px, 0.8fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 12px 14px;
}

.list-row h2 {
  margin: 0 0 4px;
  font-size: 0.98rem;
  line-height: 1.25;
}

.list-row small,
.list-row span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.list-row strong {
  font-size: 0.92rem;
}

.list-row button {
  border: 1px solid var(--line);
  background: #211f1d;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 800;
}

.car-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.car-visual {
  position: relative;
  display: grid;
  height: 176px;
  overflow: hidden;
  place-items: center;
  background: linear-gradient(135deg, #211f1d, #121110);
}

.car-visual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  box-sizing: border-box;
  padding: 10px;
}

.car-photo {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  cursor: zoom-in;
}

.car-silhouette {
  position: relative;
  width: 74%;
  max-width: 220px;
  height: 70px;
}

.car-silhouette::before {
  content: "";
  position: absolute;
  inset: 18px 12px 20px;
  background: var(--car-color, var(--accent));
  border-radius: 38px 46px 16px 16px;
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.11);
}

.car-silhouette::after {
  content: "";
  position: absolute;
  left: 36%;
  top: 5px;
  width: 35%;
  height: 30px;
  background: rgba(15, 123, 140, 0.18);
  border-radius: 20px 22px 4px 4px;
  border: 3px solid rgba(17, 27, 28, 0.18);
}

.wheel {
  position: absolute;
  bottom: 10px;
  width: 30px;
  height: 30px;
  border: 7px solid #070707;
  background: #b8b0a5;
  border-radius: 50%;
}

.wheel.left {
  left: 22%;
}

.wheel.right {
  right: 16%;
}

.status-chip,
.favorite-chip {
  position: absolute;
  top: 10px;
  border: 1px solid rgba(244, 240, 232, 0.16);
  background: rgba(12, 11, 11, 0.72);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 850;
}

.status-chip {
  left: 10px;
}

.favorite-chip {
  right: 10px;
  color: var(--accent);
}

.car-body {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
}

.car-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.car-title h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.model-series-tag {
  display: inline-block;
  margin-left: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  opacity: 0.72;
  vertical-align: baseline;
}

.car-title small {
  color: var(--muted);
}

.car-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.fact {
  border: 1px solid var(--line);
  background: #100f0f;
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.verification-unverified {
  border-color: #3a3531;
  background: #121110;
}

.verification-candidate {
  border-color: rgba(244, 181, 63, 0.52);
  background: rgba(244, 181, 63, 0.16);
  color: #e8bf67;
}

.verification-verified {
  border-color: rgba(15, 123, 140, 0.34);
  background: rgba(15, 123, 140, 0.12);
  color: #80cfd0;
}

.verification-unsure {
  border-color: rgba(232, 63, 50, 0.34);
  background: rgba(232, 63, 50, 0.1);
  color: #ec8b7e;
}

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

.card-actions button {
  flex: 1;
  border: 1px solid var(--line);
  background: #211f1d;
  color: var(--ink);
  border-radius: 8px;
  padding: 9px;
  font-weight: 800;
}

.card-actions button:first-child {
  background: var(--accent);
  color: #fff7f0;
}

.research-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 0 10px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 8px;
}

.research-tabs button {
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 8px;
  font-size: 0.78rem;
  font-weight: 850;
}

.research-tabs button.active {
  background: var(--accent);
  color: #fff7f0;
}

.research-panel {
  display: none;
}

.research-panel.active {
  display: block;
}

.source-links,
.verification-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.source-links a,
.verification-actions button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #211f1d;
  color: var(--ink);
  border-radius: 8px;
  padding: 9px;
  text-align: center;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 800;
}

.verification-actions button:nth-child(2) {
  border-color: rgba(15, 123, 140, 0.34);
  background: rgba(15, 123, 140, 0.12);
}

.price-links a:first-child {
  border-color: rgba(244, 181, 63, 0.52);
  background: rgba(244, 181, 63, 0.16);
}

.verification-form {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 8px;
}

.verification-form button {
  border: 0;
  background: var(--accent);
  color: #fff7f0;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 800;
}

.danger-action {
  border-color: rgba(232, 63, 50, 0.4) !important;
  background: rgba(232, 63, 50, 0.13) !important;
  color: #ffb0a6 !important;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 48px 24px;
  border: 1px dashed var(--line);
  background: rgba(23, 21, 20, 0.76);
  border-radius: 8px;
  text-align: center;
}

.car-dialog {
  width: min(760px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: var(--panel);
  color: var(--ink);
}

.car-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.image-dialog {
  width: min(1100px, calc(100vw - 28px));
  height: min(760px, calc(100vh - 28px));
  padding: 48px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080707;
  box-shadow: var(--shadow);
}

.image-dialog::backdrop {
  background: rgba(0, 0, 0, 0.84);
}

.image-dialog .icon-button {
  position: absolute;
  top: 10px;
  right: 10px;
}

.image-preview {
  width: 100%;
  height: 100%;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.dialog-header h2 {
  margin: 0;
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-weight: 900;
}

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

.wide {
  grid-column: 1 / -1;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 0 0;
}

.dialog-actions button {
  min-width: 110px;
}

.detail-panel {
  position: fixed;
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100vw - 36px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateX(calc(100% + 36px));
  transition: transform 180ms ease;
  z-index: 5;
}

.detail-panel.open {
  transform: translateX(0);
}

.detail-panel h2 {
  margin-bottom: 6px;
}

.detail-panel .car-visual {
  height: 230px;
  margin-bottom: 16px;
  border-radius: 8px;
  overflow: hidden;
}

.detail-panel dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  margin: 18px 0;
}

.detail-panel dt {
  color: var(--muted);
  font-weight: 800;
}

.detail-panel dd {
  margin: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(244, 181, 63, 0.42);
  background: rgba(18, 17, 16, 0.96);
  color: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

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

  .sidebar {
    position: static;
  }

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

  h1 {
    font-size: 2.4rem;
  }
}

@media (max-width: 620px) {
  .topbar,
  .garage-meta {
    align-items: stretch;
    flex-direction: column;
  }

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

  .wide {
    grid-column: auto;
  }

  .primary-action {
    width: 100%;
  }

  .topbar-actions {
    flex-direction: column;
  }

  .secondary-action {
    width: 100%;
  }

  .research-tabs {
    grid-template-columns: 1fr;
  }

  .source-links,
  .verification-actions {
    grid-template-columns: 1fr;
  }

  .list-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}
