:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-strong: #f8faf7;
  --ink: #17211d;
  --muted: #66736e;
  --line: #d9e1da;
  --green: #2f7d62;
  --green-dark: #23644e;
  --blue: #2f6f9e;
  --orange: #b85f2b;
  --amber: #d9a441;
  --red: #bd3f3f;
  --shadow: 0 18px 50px rgba(28, 41, 35, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(244, 246, 241, 0.96), rgba(236, 242, 236, 0.96)),
    radial-gradient(circle at top left, rgba(47, 125, 98, 0.12), transparent 32rem);
  color: var(--ink);
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar,
.panel-heading,
.inventory-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  margin-bottom: 22px;
}

.topbar h1,
.panel-heading h2,
.inventory-toolbar h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

.panel-heading h2,
.inventory-toolbar h2 {
  font-size: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-actions,
.filters,
.scan-row,
.mode-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.button,
.file-button,
.mode-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 14px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(23, 33, 29, 0.04);
}

.button svg,
.file-button svg,
.search-box svg,
.result-box svg,
.empty-state svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.button.primary {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

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

.button.secondary:hover,
.file-button:hover,
.mode-button:hover {
  border-color: #aebbb4;
}

.button.icon-only {
  width: 44px;
  padding: 0;
}

.button.full {
  width: 100%;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

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

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  min-height: 132px;
  display: grid;
  align-content: space-between;
  box-shadow: var(--shadow);
  border-top-width: 5px;
}

.kpi-card span,
.kpi-card small {
  color: var(--muted);
  font-weight: 750;
}

.kpi-card strong {
  font-size: 42px;
  line-height: 1;
}

.accent-green {
  border-top-color: var(--green);
}

.accent-orange {
  border-top-color: var(--orange);
}

.accent-blue {
  border-top-color: var(--blue);
}

.accent-red {
  border-top-color: var(--red);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 16px;
  align-items: stretch;
}

.tool-panel,
.inventory-section {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.tool-panel {
  padding: 18px;
}

.mode-switch {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
}

.mode-button {
  min-height: 34px;
  border: 0;
  box-shadow: none;
  padding: 0 12px;
  color: var(--muted);
}

.mode-button.active {
  background: var(--ink);
  color: white;
}

.scan-form,
.vehicle-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

label {
  color: #33413b;
  font-size: 13px;
  font-weight: 800;
  display: grid;
  gap: 7px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 98, 0.14);
}

.scan-row {
  flex-wrap: nowrap;
}

.scan-row input {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 18px;
  font-weight: 850;
  letter-spacing: 0;
}

.camera-box {
  margin-top: 14px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #101815;
}

.camera-box video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.camera-box .button {
  margin: 10px;
}

.result-box {
  margin-top: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 14px;
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-strong);
}

.result-box strong,
.result-box span {
  display: block;
}

.result-box span {
  color: var(--muted);
  margin-top: 2px;
}

.result-box.success {
  border-color: rgba(47, 125, 98, 0.38);
  background: #eef8f2;
}

.result-box.warning {
  border-color: rgba(217, 164, 65, 0.5);
  background: #fff8e7;
}

.result-box.error {
  border-color: rgba(189, 63, 63, 0.42);
  background: #fff0ef;
}

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

.inventory-section {
  margin-top: 16px;
  padding: 18px;
}

.inventory-toolbar {
  align-items: flex-end;
  margin-bottom: 14px;
}

.search-box {
  min-width: min(360px, 100%);
  position: relative;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-box input {
  padding-left: 38px;
}

.filters select {
  width: auto;
  min-width: 176px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  background: white;
  max-height: 58vh;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf1ed;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7faf7;
  color: #4f5f58;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.vin-cell {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-weight: 850;
}

.model-cell {
  max-width: 270px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.status-pill.in_yard {
  color: #18533f;
  background: #e7f5ee;
}

.status-pill.exited {
  color: #73400f;
  background: #fff0d7;
}

.days-chip {
  font-weight: 900;
  color: var(--ink);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.row-actions button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}

.row-actions button:hover {
  border-color: #9aa8a1;
}

.row-actions svg {
  width: 16px;
  height: 16px;
}

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

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: #17211d;
  color: white;
  border-radius: 8px;
  padding: 13px 15px;
  box-shadow: 0 20px 60px rgba(23, 33, 29, 0.22);
  font-weight: 800;
}

@media (max-width: 980px) {
  .kpi-grid,
  .workspace-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .topbar,
  .inventory-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 18px;
  }

  .kpi-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .filters {
    width: 100%;
  }

  .topbar-actions > *,
  .filters > *,
  .scan-row .button.primary {
    flex: 1 1 auto;
  }

  .scan-row {
    flex-wrap: wrap;
  }

  .search-box,
  .filters select {
    min-width: 100%;
  }
}
