:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --ink: #202528;
  --muted: #677176;
  --line: #d8ddd9;
  --green: #0f6b56;
  --green-dark: #0a4a3d;
  --red: #9b2f2f;
  --gold: #b8871b;
  --blue: #295f92;
  --shadow: 0 10px 28px rgba(28, 34, 32, 0.08);
  --content: min(1440px, calc(100% - 48px));
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: 100%;
  margin: 0 auto;
  padding: 0 0 40px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  width: 100%;
  padding: 18px max(24px, calc((100vw - 1440px) / 2 + 24px)) 12px;
  background: linear-gradient(180deg, #fbfcfb 0%, var(--bg) 100%);
}

.eyebrow,
.brand-line {
  margin: 0;
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4.2vw, 3.6rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
}

.store-title {
  position: relative;
  min-width: 0;
}

.store-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.store-toggle {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--green);
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: 700;
}

.store-toggle:hover,
.store-toggle[aria-expanded="true"] {
  border-color: var(--green);
  background: #e8f3ee;
}

.store-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  z-index: 30;
  display: grid;
  gap: 6px;
  min-width: min(360px, calc(100vw - 32px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.store-menu[hidden] {
  display: none;
}

.store-menu-item {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 650;
  text-align: left;
  padding: 0 10px;
}

.store-menu-item:hover,
.store-menu-item.active {
  background: #edf5f1;
  color: var(--green-dark);
}

.summary-strip {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 8px;
}

.header-actions {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  text-align: left;
}

.summary-chip span {
  display: inline;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.summary-chip strong {
  display: inline;
  margin-top: 0;
  font-size: 1rem;
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(280px, 1fr) minmax(260px, 380px);
  gap: 10px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  width: 100%;
  padding: 10px max(24px, calc((100vw - 1440px) / 2 + 24px));
  background: rgba(247, 248, 246, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(32, 37, 40, 0.08);
  box-shadow: 0 8px 24px rgba(28, 34, 32, 0.05);
}

.control-panel {
  min-height: 48px;
  border: 1px solid rgba(32, 37, 40, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.sticky-store-name {
  overflow: hidden;
  color: var(--green-dark);
  font-size: 1.18rem;
  line-height: 1.08;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-switcher {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 5px 10px 5px 6px;
  cursor: pointer;
}

.store-context {
  min-width: 0;
}

.store-context span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
}

.filter-toggle {
  display: none;
}

.filter-icon {
  position: relative;
  display: block;
  width: 18px;
  height: 14px;
  background:
    linear-gradient(var(--green), var(--green)) 0 1px / 18px 2px no-repeat,
    linear-gradient(var(--green), var(--green)) 0 6px / 18px 2px no-repeat,
    linear-gradient(var(--green), var(--green)) 0 11px / 18px 2px no-repeat;
}

.filter-icon::before,
.filter-icon::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border: 2px solid var(--green);
  border-radius: 999px;
  background: var(--surface);
}

.filter-icon::before {
  left: 3px;
  top: -1px;
}

.filter-icon::after {
  right: 4px;
  bottom: -1px;
}

.tabs {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding: 5px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-button,
.ghost-button,
.image-button,
.save-image-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 650;
}

.tab-button {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
  min-width: 0;
  padding: 0 9px 0 12px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.tab-button.active {
  border-color: rgba(15, 107, 86, 0.2);
  color: var(--green-dark);
  background: #e8f3ee;
}

.tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #edf1ee;
  color: var(--green-dark);
  font-size: 0.72rem;
  font-weight: 700;
}

.tab-button.active .tab-badge {
  background: #ffffff;
  color: var(--green-dark);
}

.search-box {
  position: relative;
  display: block;
  color: var(--muted);
  font-weight: 600;
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  color: var(--green);
  font-size: 1.65rem;
  font-weight: 700;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px 0 48px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  outline: none;
}

.search-box input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 107, 86, 0.14);
}

.sync-status {
  min-height: 22px;
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto 14px;
  color: var(--muted);
  font-weight: 600;
}

.ghost-button {
  padding: 0 14px;
}

.sync-row {
  display: flex;
  justify-content: flex-end;
  width: min(1440px, calc(100% - 32px));
  margin: 2px auto 14px;
}

.sync-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  min-height: 0;
  padding: 0;
  align-self: stretch;
  color: var(--green);
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 16px;
  width: var(--content);
  margin: 18px auto 0;
}

.vehicle-card {
  overflow: hidden;
  border: 1px solid rgba(32, 37, 40, 0.09);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.vehicle-media {
  position: relative;
  display: grid;
  place-items: center;
  height: 220px;
  overflow: hidden;
  border-bottom: 1px solid rgba(32, 37, 40, 0.08);
  background: #ffffff;
}

.vehicle-image {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.vehicle-card.has-image .vehicle-image {
  display: block;
}

.vehicle-card.has-image .image-placeholder {
  display: none;
}

.image-placeholder {
  color: #8b9492;
  font-weight: 700;
  text-transform: uppercase;
}

.image-actions {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: calc(100% - 20px);
}

.image-button,
.save-image-button {
  min-height: 38px;
  padding: 0 12px;
}

.save-image-button {
  color: #ffffff;
  border-color: var(--green);
  background: var(--green);
}

.image-button.loading,
.save-image-button.loading {
  cursor: wait;
  opacity: 0.76;
}

.vehicle-body {
  padding: 18px;
}

.vehicle-title-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  min-height: 64px;
}

.brand-line {
  margin-bottom: 4px;
  font-size: 0.76rem;
}

.vehicle-body h3 {
  margin-bottom: 0;
  font-size: 1.18rem;
  line-height: 1.18;
}

.availability-pill {
  flex: 0 0 auto;
  padding: 7px 9px;
  border-radius: 999px;
  color: var(--green-dark);
  background: #dff0e9;
  font-size: 0.75rem;
  font-weight: 700;
}

.availability-pill.unavailable {
  color: var(--red);
  background: #f5dfdc;
}

.price-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

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

.price-row div {
  min-height: 72px;
  padding: 12px;
  border-radius: 8px;
  background: #f6f8f7;
}

.price-row span,
.spec-list dt {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 650;
  text-transform: uppercase;
}

.price-row strong {
  display: block;
  margin-top: 6px;
  font-size: 1.15rem;
  font-weight: 700;
}

.offer-value {
  color: var(--green);
}

.spec-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0 0 14px;
}

.spec-list div {
  min-width: 0;
}

.spec-list dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.notes,
.installment {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.38;
}

.installment {
  color: var(--blue);
  font-weight: 650;
}

.legal-block {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.legal-block:empty {
  display: none;
}

.legal-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green-dark);
  cursor: pointer;
  font-weight: 650;
  text-align: left;
}

.legal-toggle-icon {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6f8f7;
  color: var(--green);
  font-size: 1rem;
  font-weight: 700;
}

.empty-message {
  grid-column: 1 / -1;
  min-height: 220px;
  display: grid;
  gap: 12px;
  place-items: center;
  align-content: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-weight: 500;
  text-align: center;
}

.empty-message strong {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 650;
}

.empty-message span {
  max-width: 360px;
  line-height: 1.45;
}

.primary-empty-button {
  height: 44px;
  padding: 0 18px;
  border: 1px solid rgba(15, 107, 86, 0.2);
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.primary-empty-button:hover {
  background: var(--green-dark);
}

.catalog-grid.is-empty {
  display: grid;
  grid-template-columns: 1fr;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 25, 24, 0.46);
}

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

.legal-modal {
  position: relative;
  width: min(680px, 100%);
  max-height: min(74vh, 720px);
  overflow: auto;
  padding: 26px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(20, 25, 24, 0.22);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.modal-eyebrow {
  margin: 0 42px 8px 0;
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.legal-modal h2 {
  margin: 0 42px 16px 0;
  color: var(--ink);
  font-size: 1.3rem;
  line-height: 1.2;
}

.modal-body {
  margin: 0;
  color: var(--muted);
  line-height: 1.52;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 1120px) {
  .controls {
    grid-template-columns: minmax(240px, 320px) minmax(260px, 1fr);
  }

  .search-box {
    grid-column: 1 / -1;
  }

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

@media (max-width: 860px) {
  .app-shell {
    padding-top: 0;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
    padding: 14px 12px 10px;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 0.66rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  .summary-strip {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: stretch;
    gap: 6px;
  }

  .header-actions {
    align-items: stretch;
    gap: 6px;
    min-width: 0;
  }

  .summary-chip {
    flex: 1 1 0;
    min-width: 0;
    min-height: 38px;
    justify-content: center;
    gap: 4px;
    padding: 0 6px;
    text-align: center;
  }

  .summary-chip span {
    font-size: 0.61rem;
  }

  .summary-chip strong {
    font-size: 0.92rem;
  }

  .controls {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px 12px;
  }

  .store-switcher {
    grid-column: 1 / -1;
    min-height: 50px;
  }

  .sticky-store-name {
    font-size: 1.13rem;
  }

  .filter-toggle {
    grid-column: 2;
    grid-row: 2;
    display: inline-grid;
    place-items: center;
    width: 48px;
    min-height: 48px;
    border: 1px solid rgba(32, 37, 40, 0.09);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--green);
    cursor: pointer;
    font-weight: 700;
  }

  .filter-toggle[aria-expanded="true"] {
    border-color: var(--green);
    background: #e8f3ee;
  }

  .tabs {
    display: none;
    grid-column: 1 / -1;
    grid-row: 3;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    padding: 5px;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tabs.open {
    display: flex;
  }

  .tab-button {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 34px;
    padding: 0 9px;
    font-size: 0.82rem;
  }

  .sync-status,
  .catalog-grid {
    width: min(100% - 24px, 620px);
  }

  .sync-button {
    width: 38px;
    min-width: 38px;
  }

  .search-box {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
  }

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

  .vehicle-media {
    height: 200px;
  }

  .legal-modal {
    max-height: 82vh;
    padding: 22px 18px;
  }

  .legal-modal h2 {
    font-size: 1.12rem;
  }
}
