/**
 * Car Collection — base layout & components
 * Breakpoints (documented): 640px (mobile/tablet), 1024px (tablet/desktop), 1440px (wide desktop)
 * All colours via var(--...); never raw colour keywords/hex here.
 */

/* --- Reset / normalize (subset) --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text);
  background-color: var(--bg);
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

h1,
h2,
h3,
h4,
p {
  margin: 0 0 var(--space-sm);
}

ul,
ol {
  margin: 0;
  padding-left: 1.25rem;
}

/* --- Motion --- */
@media (prefers-reduced-motion: no-preference) {
  .transitionable,
  .btn,
  .nav-link,
  .bottom-nav__link,
  .fab,
  .toast,
  .modal__panel,
  .chip,
  .pagination__btn {
    transition:
      background-color 0.2s ease,
      color 0.2s ease,
      border-color 0.2s ease,
      box-shadow 0.2s ease,
      transform 0.2s ease,
      opacity 0.2s ease;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- App shell --- */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.app-shell--with-bottom-nav {
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0));
}

/* --- Top nav --- */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  min-height: var(--nav-height);
  padding: var(--space-xs) var(--space-md);
  padding-top: calc(var(--space-xs) + env(safe-area-inset-top, 0));
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.nav-bar__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  white-space: nowrap;
  line-height: 0;
}

.nav-bar__brand:hover {
  color: var(--accent);
}

.brand-logo {
  box-sizing: content-box;
  display: block;
  height: 2.03125rem;
  width: auto;
  max-width: min(52vw, 8.75rem);
  padding: var(--space-sm);
  object-fit: contain;
  flex-shrink: 0;
  filter: var(--logo-filter, none);
  transition: filter 150ms ease;
}

@media (min-width: 640px) {
  .brand-logo {
    height: 2.1875rem;
    max-width: min(48vw, 10rem);
  }
}

.nav-bar__center {
  flex: 1;
  display: none;
  justify-content: flex-start;
}

.nav-tabs {
  display: flex;
  gap: var(--space-xs);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  min-height: 44px;
}

.nav-link svg {
  display: none;
}

.nav-link:hover {
  background-color: var(--bg-hover);
  color: var(--text);
}

.nav-link.is-active {
  background-color: var(--accent-muted);
  color: var(--accent);
}

/* --- Quick action buttons (desktop right side) --- */
.nav-bar__quick-actions {
  display: none;
  align-items: center;
  gap: var(--space-xs);
}

.quick-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-muted);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  text-decoration: none;
}

.quick-action svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
}

.quick-action:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.quick-action:active {
  transform: scale(0.97);
}

.nav-bar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  color: var(--text);
  border: 1px solid transparent;
}

.icon-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border);
}

.icon-btn svg {
  width: 1.35rem;
  height: 1.35rem;
}

.lang-switch {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-shrink: 0;
}

.lang-switch__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  background: transparent;
  border: 2px solid transparent;
  padding: 2px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 150ms, opacity 150ms;
  line-height: 0;
  opacity: var(--lang-switch-inactive-opacity, 0.55);
  flex: 0 0 auto;
}

.lang-switch__btn svg {
  display: block;
  width: 20px;
  height: 14px;
  min-width: 20px;
  min-height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
  filter: var(--lang-flag-filter, none);
  box-shadow: var(--lang-flag-ring, none);
}

.lang-switch__btn.is-active {
  border-color: var(--accent);
  opacity: var(--lang-switch-active-opacity, 1);
}

.lang-switch__btn:hover:not(.is-active) {
  opacity: var(--lang-switch-hover-inactive-opacity, 0.85);
}

.theme-select {
  min-height: 44px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--bg-input);
  color: var(--text);
  max-width: 11rem;
}

.theme-select:focus {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* --- Bottom nav (mobile) --- */
.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  min-height: var(--bottom-nav-height);
  padding-bottom: env(safe-area-inset-bottom, 0);
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px var(--shadow);
}

.bottom-nav__link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  min-height: 44px;
}

.bottom-nav__link svg {
  width: 1.35rem;
  height: 1.35rem;
}

.bottom-nav__link.is-active {
  color: var(--accent);
}

@media (min-width: 640px) {
  .bottom-nav {
    display: none;
  }

  .app-shell--with-bottom-nav {
    padding-bottom: 0;
  }
}

@media (min-width: 1024px) {
  /* Desktop-only: top bar + brand mark (mobile/tablet unchanged above). */
  html[data-theme] {
    --nav-height: 5.625rem;
  }

  .brand-logo {
    height: 3.59375rem;
    max-width: min(48vw, 18.75rem);
  }

  .nav-bar__center {
    display: flex;
  }
  .nav-bar__quick-actions {
    display: flex;
  }
  .fab {
    display: none !important;
  }
}

@media (min-width: 1440px) {
  html[data-theme] {
    --nav-height: 5.9375rem;
  }

  .brand-logo {
    height: 3.90625rem;
    max-width: min(44vw, 21.25rem);
  }
}

/* --- Main content --- */
#main-app,
#app {
  flex: 1;
  width: 100%;
}

/* --- App footer (signed-in shell) --- */
.app-footer {
  flex-shrink: 0;
  padding: var(--space-sm) var(--space-md);
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--border);
  background-color: var(--bg-surface);
  text-align: center;
  font-size: 0.8125rem;
}

.app-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.app-footer__link {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.app-footer__link:hover {
  color: var(--accent);
}

.app-footer__sep {
  color: var(--text-muted);
  user-select: none;
}

.login-auth-footer {
  margin-top: 0.5rem;
  text-align: center;
  font-size: 0.8125rem;
}

.login-auth-footer a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.login-auth-footer a:hover {
  color: var(--accent);
}

.login-auth-footer__sep {
  user-select: none;
}

.page {
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: var(--space-sm) var(--space-md) var(--space-md);
}

@media (min-width: 1024px) {
  .page {
    padding: var(--space-sm) var(--space-lg) var(--space-lg);
  }
}

.page__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  color: var(--text);
}

@media (min-width: 1024px) {
  .page__title {
    font-size: 1.75rem;
  }
}

/* --- Sidebar layout (desktop 2-col, mobile stacked) --- */
.layout-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

@media (min-width: 1024px) {
  .layout-sidebar {
    flex-direction: row;
    align-items: flex-start;
  }

  .layout-sidebar__main {
    flex: 1;
    min-width: 0;
  }

  .layout-sidebar__aside {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--nav-height) + var(--space-md));
  }
}

/* --- Summary stats row --- */
.summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.summary-stats__item {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.summary-stats__item strong {
  color: var(--text);
  font-weight: 600;
}

/* --- Toolbar --- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.toolbar__grow {
  flex: 1;
  min-width: 8rem;
}

/* --- KPI grid --- */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

@media (min-width: 640px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1440px) {
  .kpi-grid {
    grid-template-columns: repeat(7, 1fr);
  }
}

.kpi-card {
  position: relative;
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  opacity: 0.85;
}

.kpi-card__icon {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 2rem;
  height: 2rem;
  color: var(--accent);
  opacity: 0.9;
}

.kpi-card__value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
}

.kpi-card__label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.kpi-card--warning::before {
  background: var(--warning);
}

.kpi-card--warning .kpi-card__value {
  color: var(--warning);
}

/* --- Cards --- */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.card__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* --- Card grid (3 / 2 / 1) --- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.vehicle-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--bg-surface);
  padding: var(--space-md);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.vehicle-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.vehicle-card--restoration {
  border-left: 3px solid var(--warning);
  background-color: color-mix(in srgb, var(--warning) 10%, var(--bg-surface));
}

.vehicle-card--restoration:hover {
  border-color: var(--warning);
}

.vehicle-card__title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.vehicle-card__meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.car-photo-preview {
  width: 100%;
  max-width: 320px;
  max-height: 260px;
  object-fit: cover;
  display: block;
}

/* --- Pills / badges --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background-color: var(--bg-muted);
  color: var(--text);
}

.pill--success {
  border-color: var(--success);
  background-color: color-mix(in srgb, var(--success) 18%, var(--bg-surface));
  color: var(--success);
}

.pill--warning {
  border-color: var(--warning);
  background-color: color-mix(in srgb, var(--warning) 18%, var(--bg-surface));
  color: var(--warning);
}

.pill--error {
  border-color: var(--error);
  background-color: color-mix(in srgb, var(--error) 18%, var(--bg-surface));
  color: var(--error);
}

.pill--accent {
  border-color: var(--accent);
  background-color: var(--accent-muted);
  color: var(--accent);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 44px;
  padding: 0 var(--space-md);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
}

.btn--primary:hover:not(:disabled) {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--danger {
  background-color: color-mix(in srgb, var(--error) 12%, var(--bg-surface));
  border-color: var(--error);
  color: var(--error);
}

.btn--ghost {
  background-color: transparent;
}

.btn--sm {
  min-height: 36px;
  padding: 0 var(--space-sm);
  font-size: 0.85rem;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* --- Forms --- */
.form-section {
  margin-bottom: var(--space-lg);
}

.form-section__title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.field-group {
  display: grid;
  gap: var(--space-md);
}

@media (min-width: 640px) {
  .field-group--2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .field-group--3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field__error {
  font-size: 0.8rem;
  color: var(--error);
}

.input,
.select,
.textarea {
  min-height: 44px;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--bg-input);
  color: var(--text);
  width: 100%;
}

.textarea {
  min-height: 6rem;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 2px solid var(--border-focus);
  outline-offset: 1px;
}

.input--invalid,
.select--invalid,
.textarea--invalid {
  border-color: var(--error);
}

/* Currency pickers: regional-indicator flags + ISO code in option text */
.select.select--currency {
  font-size: 1.02rem;
  line-height: 1.35;
}

/* --- Tables --- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
}

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

.data-table th,
.data-table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background-color: var(--bg-muted);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.data-table th.data-table__th--sortable {
  cursor: pointer;
  user-select: none;
  color: var(--text);
}

.data-table th.data-table__th--sortable .data-table__sort-indicator {
  font-size: 0.65rem;
  opacity: 0.9;
}

@media (hover: hover) {
  .data-table th.data-table__th--sortable:hover {
    background-color: color-mix(in srgb, var(--accent) 14%, var(--bg-muted));
  }
}

.data-table tbody tr {
  cursor: pointer;
}

@media (hover: hover) {
  .data-table tbody tr:hover {
    background-color: var(--bg-hover);
  }
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr.tr--restoration {
  background-color: color-mix(in srgb, var(--warning) 10%, var(--bg-surface));
  border-left: 3px solid var(--warning);
}

@media (hover: hover) {
  .data-table tbody tr.tr--restoration:hover {
    background-color: color-mix(in srgb, var(--warning) 18%, var(--bg-surface));
  }
}

.th-sort {
  cursor: pointer;
  user-select: none;
}

.th-sort.is-active {
  color: var(--accent);
}

/* --- Filter chips --- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background-color: var(--bg-muted);
  font-size: 0.8rem;
  color: var(--text);
  min-height: 36px;
}

.chip button {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.chip button:hover {
  color: var(--error);
  background-color: var(--bg-hover);
}

/* --- Pagination --- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-top: var(--space-lg);
}

.pagination__btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  color: var(--text);
  font-weight: 600;
}

.pagination__btn:hover:not(:disabled) {
  background-color: var(--bg-hover);
}

.pagination__btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pagination__btn.is-active {
  border-color: var(--accent);
  background-color: var(--accent-muted);
  color: var(--accent);
}

.pagination__ellipsis {
  padding: 0 var(--space-sm);
  color: var(--text-muted);
  font-weight: 600;
}

/* --- Chart container --- */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 1024px) {
  .chart-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.chart-card {
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  min-height: 260px;
}

.chart-card__title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--text);
}

.chart-card canvas {
  max-height: 220px;
}

.dashboard-highlight {
  display: grid;
  gap: var(--space-sm);
}

.dashboard-highlight__photo {
  width: 100%;
  max-width: 220px;
  max-height: 130px;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.dashboard-highlight__name {
  margin-top: 0.1rem;
}

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-md);
  background-color: var(--overlay-scrim);
}

@media (min-width: 640px) {
  .modal {
    align-items: center;
  }
}

.modal__panel {
  width: min(100%, 32rem);
  max-height: 90dvh;
  overflow: auto;
  border-radius: var(--radius-lg);
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.modal__title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal__body {
  padding: var(--space-md);
  flex: 1;
  overflow: auto;
}

.modal__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-top: 1px solid var(--border);
}

.modal__panel--wide {
  width: min(100%, 42rem);
}

/* Multi-document upload wizard: near-fullscreen PDF preview */
.modal--doc-bulk-wizard {
  align-items: stretch;
  padding: var(--space-sm);
}

@media (min-width: 640px) {
  .modal--doc-bulk-wizard {
    align-items: center;
    padding: var(--space-md);
  }
}

.modal__panel--doc-bulk {
  width: min(100%, min(96vw, 72rem));
  max-height: min(96dvh, 100%);
  display: flex;
  flex-direction: column;
}

.modal__body--doc-bulk {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  flex: 1;
  min-height: 0;
}

.doc-bulk-wizard__embed {
  width: 100%;
  flex: 1;
  min-height: min(78vh, 52rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-muted, var(--bg-hover));
}

.doc-bulk-wizard__meta {
  flex-shrink: 0;
}

.photo-lightbox__panel {
  width: min(100%, 70rem);
  max-height: 95dvh;
  background: transparent;
  border: none;
  box-shadow: none;
}

.photo-lightbox__img {
  width: 100%;
  max-height: 90dvh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.modal__footer--split {
  justify-content: space-between;
  align-items: center;
}

/* --- Spare parts --- */
.spare-parts__head {
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: flex-start;
}

.spare-parts__title {
  margin-bottom: 0;
}

.spare-parts__add-btn {
  min-height: 44px;
  min-width: 44px;
}

.spare-parts__stock-field {
  display: flex;
  align-items: flex-end;
  min-height: 100%;
}

/* ---- Toggle switch ---- */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  user-select: none;
  min-height: 44px;
}

.toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__track {
  position: relative;
  display: inline-block;
  width: 2.5rem;
  height: 1.375rem;
  border-radius: 999px;
  background: var(--color-border, #ccc);
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.toggle__knob {
  position: absolute;
  top: 0.125rem;
  left: 0.125rem;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: var(--color-bg, #fff);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease;
}

.toggle__input:checked + .toggle__track {
  background: var(--color-primary, #4f6ef7);
}

.toggle__input:checked + .toggle__track .toggle__knob {
  transform: translateX(1.125rem);
}

.toggle__input:focus-visible + .toggle__track {
  outline: 2px solid var(--color-primary, #4f6ef7);
  outline-offset: 2px;
}

.toggle__text {
  font-size: 0.875rem;
  color: var(--color-text-muted, #666);
}

@media (prefers-reduced-motion: reduce) {
  .toggle__track,
  .toggle__knob {
    transition: none;
  }
}

.spare-parts__multi {
  min-height: 8rem;
}

.spare-parts__compat-row {
  gap: var(--space-sm);
  align-items: flex-start;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
}

.spare-parts__compat-row:last-child {
  border-bottom: none;
}

.spare-parts__compat-title {
  font-weight: 600;
}

.spare-parts__compat-notes {
  font-size: 0.85rem;
}

.spare-parts__compat-remove {
  min-width: 44px;
  min-height: 44px;
  font-size: 1.25rem;
  line-height: 1;
}

.parts-table__money {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: min(100%, 22rem);
  pointer-events: none;
}

.toast-container .toast {
  pointer-events: auto;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--bg-surface-elevated);
  box-shadow: var(--shadow-md);
  color: var(--text);
}

@media (prefers-reduced-motion: no-preference) {
  .toast--enter {
    animation: toast-in 0.25s ease forwards;
  }

  @keyframes toast-in {
    from {
      opacity: 0;
      transform: translateX(12px);
    }

    to {
      opacity: 1;
      transform: translateX(0);
    }
  }
}

.toast--success {
  border-color: var(--success);
}

.toast--error {
  border-color: var(--error);
}

.toast--warning {
  border-color: var(--warning);
}

.toast--info {
  border-color: var(--info);
}

.toast__message {
  flex: 1;
  font-size: 0.9rem;
}

.toast__close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.toast__close:hover {
  background-color: var(--bg-hover);
  color: var(--text);
}

/* --- FAB --- */
.fab {
  position: fixed;
  right: var(--space-md);
  bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0));
  z-index: 55;
  display: none;
  align-items: center;
  gap: var(--space-sm);
  min-height: var(--fab-size);
  padding: 0 var(--space-lg);
  border-radius: var(--radius-full);
  background-color: var(--accent);
  color: var(--text-on-accent);
  font-weight: 700;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--accent-hover);
}

.fab:hover {
  background-color: var(--accent-hover);
}

.fab.is-visible {
  display: inline-flex;
}

@media (max-width: 639px) {
  .fab {
    bottom: calc(var(--bottom-nav-height) + var(--space-md) + env(safe-area-inset-bottom, 0));
  }
}

/* --- Search overlay --- */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
}

.search-overlay__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  padding-top: calc(var(--space-md) + env(safe-area-inset-top, 0));
  border-bottom: 1px solid var(--border);
  background-color: var(--bg-surface);
}

.search-overlay__input {
  flex: 1;
  min-height: 48px;
  font-size: 1.1rem;
}

.search-overlay__body {
  flex: 1;
  overflow: auto;
  padding: var(--space-md);
}

.search-group__title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: var(--space-md) 0 var(--space-sm);
}

.search-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  margin-bottom: var(--space-sm);
  color: var(--text);
  min-height: 44px;
}

.search-result:hover {
  border-color: var(--accent);
}

.search-result__label {
  font-weight: 600;
}

.search-result__meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Loading --- */
.spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-top-color: var(--border);
  }
}

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

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.skeleton {
  position: relative;
  overflow: hidden;
  background-color: var(--bg-muted);
  border-radius: var(--radius-md);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--text) 8%, transparent),
    transparent
  );
}

@media (prefers-reduced-motion: no-preference) {
  .skeleton::after {
    animation: shimmer 1.2s infinite;
  }
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.skeleton-line {
  height: 0.85rem;
  margin-bottom: var(--space-sm);
}

.skeleton-card {
  height: 5rem;
  margin-bottom: var(--space-md);
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--bg-muted);
  color: var(--text-muted);
}

.empty-state__icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto var(--space-md);
  color: var(--accent);
}

.empty-state__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.empty-state__message {
  font-size: 0.95rem;
  margin-bottom: var(--space-md);
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}

/* --- Action items --- */
.action-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.action-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}

.action-item:last-child {
  border-bottom: none;
}

.action-item__dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  margin-top: 6px;
  flex-shrink: 0;
}

.action-item__dot--red {
  background-color: var(--error);
}

.action-item__dot--yellow {
  background-color: var(--warning);
}

.action-item__dot--orange {
  background-color: color-mix(in srgb, var(--warning) 70%, var(--error));
}

.action-item__link {
  color: var(--accent);
  font-weight: 600;
}

/* --- Activity feed --- */
.activity-feed {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-item {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-item__date {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.activity-item__title {
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
}

.activity-item__desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Toggle segmented --- */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--bg-muted);
}

.segmented__btn {
  min-height: 44px;
  padding: 0 var(--space-md);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.segmented__btn.is-active {
  background-color: var(--bg-surface);
  color: var(--accent);
}

/* --- Accordion (mobile sidebar) --- */
.accordion__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.accordion__panel {
  margin-bottom: var(--space-md);
}

.accordion__panel[hidden] {
  display: none;
}

/* --- Utility --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Public auth routes: no top bar, bottom nav, or FAB — language lives in the login card. */
.app-shell--logged-out .nav-bar {
  display: none !important;
}

.app-shell--logged-out .bottom-nav,
.app-shell--logged-out .fab {
  display: none !important;
}

.login-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem 1.5rem;
}

.login-center {
  width: min(100%, 30rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.landing-auth {
  width: 100%;
}

.login-logo {
  box-sizing: content-box;
  display: block;
  width: auto;
  height: 137.5px;
  padding: var(--space-sm);
  margin: 0 auto;
  object-fit: contain;
  filter: var(--logo-filter, none);
}

.auth-logo {
  box-sizing: content-box;
  display: block;
  width: auto;
  height: 137.5px;
  max-width: min(100%, 27.5rem);
  padding: var(--space-sm);
  margin: 0 auto var(--space-md);
  object-fit: contain;
  filter: var(--logo-filter, none);
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.login-form .input,
.login-submit {
  min-height: 44px;
}

.login-submit {
  width: 100%;
}

.login-forgot {
  margin-top: 0.15rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem 0;
  text-align: left;
}

.login-inline-error {
  margin: 0;
  font-size: 0.85rem;
  color: var(--error);
}

.forgot-form {
  width: min(100%, 30rem);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

@media (min-width: 860px) {
  .login-logo {
    height: 162.5px;
  }

  .auth-logo {
    height: 162.5px;
  }
}

@media (max-width: 640px) {
  .login-logo {
    height: 93.75px;
  }

  .auth-logo {
    height: 93.75px;
  }
}

.text-link {
  color: var(--accent);
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.form-error {
  color: var(--error);
  margin: 0;
}

.form-success {
  color: var(--success);
  margin: 0;
}

.text-muted {
  color: var(--text-muted);
}

.admin-branding-layout {
  display: grid;
  gap: var(--space-md);
  align-items: start;
}

@media (min-width: 640px) {
  .admin-branding-layout {
    grid-template-columns: auto 1fr;
  }
}

.admin-branding-preview {
  max-height: 5.5rem;
  width: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: var(--space-xs);
  background: var(--bg-surface);
}

.admin-branding-controls {
  display: grid;
  gap: var(--space-sm);
  align-content: start;
}

.admin-branding-file-field span {
  font-size: 0.85rem;
}

.admin-preferences-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: flex-end;
}

.admin-preferences-row .field {
  min-width: 12rem;
}

.admin-users-page {
  display: grid;
  gap: var(--space-md);
}

.admin-users-header {
  display: grid;
  gap: 0.25rem;
}

.admin-user-create-form {
  display: grid;
  gap: var(--space-sm);
}

@media (min-width: 760px) {
  .admin-user-create-form {
    grid-template-columns: minmax(220px, 1fr) 180px auto;
    align-items: end;
  }
}

.admin-users-list {
  width: 100%;
}

.admin-users-table tbody tr {
  cursor: default;
}

.admin-users-actions {
  align-items: center;
}

.admin-users-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.admin-users-status--set {
  background: color-mix(in srgb, var(--success) 14%, var(--bg-surface));
  color: var(--success);
}

.admin-users-status--not-set {
  background: color-mix(in srgb, var(--warning) 18%, var(--bg-surface));
  color: color-mix(in srgb, var(--warning) 85%, var(--text));
}

.admin-users-self-tag {
  font-size: 0.78rem;
}

/* Vehicle detail: read-only specs — body-sized type (matches page default 1rem) */
.car-detail-vehicle-view {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem 0;
  padding: 0 var(--space-md) var(--space-md);
  font-size: 1rem;
  line-height: 1.45;
}

@media (min-width: 640px) {
  .car-detail-vehicle-view {
    grid-template-columns: 1fr 1fr;
    column-gap: var(--space-lg);
    row-gap: 0.3rem;
  }
}

.car-detail-vehicle-view__row {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 0;
}

.car-detail-vehicle-view__icon {
  flex-shrink: 0;
  width: 1.5rem;
  text-align: center;
  font-size: 1.1rem;
  line-height: 1;
}

.car-detail-vehicle-view__label {
  flex-shrink: 0;
  font-size: 0.95rem;
  font-weight: 600;
  max-width: 46%;
}

.car-detail-vehicle-view__value {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  font-weight: 500;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
}

.car-detail-vehicle-view__value a {
  color: var(--accent);
  text-decoration: underline;
}

/* Full-width rule before display defaults (currency, volume unit, speed) at card bottom */
.car-detail-vehicle-view__divider {
  grid-column: 1 / -1;
  margin: 0.75rem 0 0.55rem;
  border: 0;
  border-top: 1px solid var(--border);
}

/* Vehicle detail: tire size callouts (paired boxes under tire pressures) */
.car-detail__tire-size-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

@media (max-width: 639px) {
  .car-detail__tire-size-row {
    grid-template-columns: 1fr;
  }
}

.car-detail__tire-size-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  background-color: var(--bg-muted);
}

.car-detail__tire-size-box-label {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.car-detail__tire-size-box-value {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

/* Vehicle detail: compatible spare parts rows open part edit page */
.car-detail-spare-row {
  cursor: pointer;
}

@media (hover: hover) {
  .car-detail-spare-row:hover {
    background-color: var(--bg-hover);
  }
}

.car-detail-spare-row:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: -2px;
}

.stack-sm > * + * {
  margin-top: var(--space-sm);
}

.stack-md > * + * {
  margin-top: var(--space-md);
}

.mt-md {
  margin-top: var(--space-md);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

/* ── Photo upload widget ────────────────────────────── */

.photo-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.photo-upload__preview {
  width: 200px;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md);
  border: 2px dashed var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
}

.photo-upload__placeholder {
  font-size: 3rem;
  opacity: 0.3;
}

.photo-upload__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-upload__status {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

/* ---- Drive map markers ---- */
.drive-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.drive-marker--start {
  background: #22c55e;
}

.drive-marker--end {
  background: #ef4444;
}

.drive-marker--flag {
  background: none;
  border: none;
  font-size: 1.5rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
  width: auto;
  height: auto;
}

.drive-marker--car {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
  background: none;
  border: none;
}

/* ---- Drive detail: bottom action row (GPS + back) ---- */
.drive-detail-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border, var(--border));
}

/* ---- Drive map wrapper + timeline ---- */
.drive-map-wrap {
  margin-bottom: var(--space-md);
}

.drive-timeline {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface, #f8f8f8);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  border-top: 1px solid var(--color-border, #ddd);
}

.drive-timeline__play {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary, #4f6ef7);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.drive-timeline__play:hover {
  opacity: 0.85;
}

.drive-timeline__slider {
  flex: 1;
  min-width: 0;
  accent-color: var(--color-primary, #4f6ef7);
  cursor: pointer;
  height: 6px;
}

.drive-timeline__readout {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted, #666);
  white-space: nowrap;
}

@media (max-width: 639px) {
  .drive-timeline {
    flex-wrap: wrap;
  }
  .drive-timeline__readout {
    width: 100%;
    text-align: center;
    margin-top: var(--space-xs);
  }
}

/* ---- Drive charts side-by-side grid ---- */
.drive-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.drive-charts-grid__card {
  padding: var(--space-md);
  min-width: 0;
}

.drive-charts-grid__canvas-wrap {
  position: relative;
  height: 200px;
}

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

/* ---- Spare part photo gallery ---- */
.part-photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.part-photo-gallery__cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-xs);
}

.part-photo-thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-hover);
  cursor: zoom-in;
  aspect-ratio: 4 / 3;
}

.part-photo-thumb:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.part-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.part-photo-remove {
  align-self: flex-end;
  min-height: 36px;
  min-width: 36px;
  padding: 0.15rem 0.35rem;
}

.part-photo-upload-row {
  margin-top: var(--space-md);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.photo-lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: color-mix(in srgb, var(--text) 55%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  cursor: zoom-out;
}

.photo-lightbox-inner {
  position: relative;
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  cursor: default;
}

.photo-lightbox-img {
  display: block;
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.photo-lightbox-close {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  z-index: 1;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.5rem;
  line-height: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* Car detail: fullscreen-style gallery (main + extra photos), prev/next, close */
.photo-lightbox-overlay.vehicle-photo-lightbox-overlay {
  z-index: 300;
  padding: max(var(--space-sm), env(safe-area-inset-top))
    max(var(--space-sm), env(safe-area-inset-right))
    max(var(--space-sm), env(safe-area-inset-bottom))
    max(var(--space-sm), env(safe-area-inset-left));
  background: color-mix(in srgb, var(--text) 72%, transparent);
  /* Default overlay centers a shrink-wrapped inner; we need full height so the image flex slot is non-zero */
  align-items: stretch;
  justify-content: center;
}

.photo-lightbox-overlay.vehicle-photo-lightbox-overlay .vehicle-photo-lightbox__inner {
  position: relative;
  width: 100%;
  max-width: 100%;
  /* Fit inside padded overlay — avoid 100vh here or the panel exceeds the flex area and clips the image */
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  /* Minimal inset: leave room for close (top-right), nav pills at sides, counter floats over bottom */
  padding-top: max(0.35rem, env(safe-area-inset-top));
  padding-bottom: max(0.35rem, env(safe-area-inset-bottom));
  padding-left: max(0.35rem, env(safe-area-inset-left));
  padding-right: max(0.35rem, env(safe-area-inset-right));
  box-sizing: border-box;
}

.vehicle-photo-lightbox__frame {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  z-index: 0;
  /* Occupy almost the entire inner panel so the image can scale to the largest contained box */
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.photo-lightbox-overlay.vehicle-photo-lightbox-overlay .vehicle-photo-lightbox__close {
  top: max(var(--space-xs), env(safe-area-inset-top));
  right: max(var(--space-xs), env(safe-area-inset-right));
  z-index: 4;
}

.photo-lightbox-overlay.vehicle-photo-lightbox-overlay .vehicle-photo-lightbox__img {
  display: block;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  /* Intrinsic size when smaller than the frame; shrink only when larger (no upscaling). */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.vehicle-photo-lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  min-width: 48px;
  min-height: 48px;
  padding: 0 var(--space-sm);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.vehicle-photo-lightbox__nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.vehicle-photo-lightbox__nav--prev {
  left: max(var(--space-xs), env(safe-area-inset-left));
}

.vehicle-photo-lightbox__nav--next {
  right: max(var(--space-xs), env(safe-area-inset-right));
}

.vehicle-photo-lightbox__counter {
  position: absolute;
  bottom: max(var(--space-sm), env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  margin: 0;
  padding: 0.2rem 0.65rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .part-photo-thumb,
  .photo-lightbox-overlay {
    transition: none;
  }
}
