:root {
  --ink: #111827;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #f7f9fc;
  --white: #ffffff;
  --red: #b42318;
  --teal: #007c89;
  --gold: #b7791f;
  --green: #16803c;
  --surface: #ffffff;
  --soft-accent: #e6f7f8;
  --admin-gradient: linear-gradient(180deg, rgba(0, 124, 137, 0.12), transparent 280px);
  --sidebar-bg: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.82);
  --shadow: 0 18px 45px rgba(17, 24, 39, 0.12);
  --font-body: 14px;
  --font-control: 13px;
  --font-small: 11px;
  --font-page-title: clamp(28px, 3vw, 36px);
  --font-section-title: clamp(22px, 2.1vw, 27px);
  --font-card-title: 17px;
  --font-table: 13px;
}

body[data-theme="graphite"] {
  --ink: #13151a;
  --muted: #667085;
  --line: #d6cfc2;
  --paper: #f3efe8;
  --surface: #fffcf6;
  --teal: #2f4858;
  --gold: #b7791f;
  --soft-accent: #fff3d6;
  --admin-gradient: linear-gradient(180deg, rgba(183, 121, 31, 0.18), transparent 280px);
  --sidebar-bg: #fffaf1;
  --header-bg: rgba(255, 250, 241, 0.88);
}

body[data-theme="racing"] {
  --ink: #102018;
  --muted: #5f6f66;
  --line: #cfdcd3;
  --paper: #eef5ef;
  --surface: #fbfffc;
  --teal: #006b4f;
  --gold: #c58a2b;
  --soft-accent: #dff3e9;
  --admin-gradient: linear-gradient(180deg, rgba(0, 107, 79, 0.18), transparent 280px);
  --sidebar-bg: #f8fff9;
  --header-bg: rgba(248, 255, 249, 0.9);
}

body[data-theme="navy"] {
  --ink: #102033;
  --muted: #607089;
  --line: #bfd0e8;
  --paper: #eaf1fb;
  --surface: #fbfdff;
  --teal: #1d4ed8;
  --gold: #b7791f;
  --soft-accent: #dbeafe;
  --admin-gradient: linear-gradient(180deg, rgba(29, 78, 216, 0.16), transparent 310px);
  --sidebar-bg: #12233a;
  --header-bg: rgba(251, 253, 255, 0.92);
  --shadow: 0 18px 45px rgba(16, 32, 51, 0.14);
}

body[data-theme="navy"] .sidebar {
  color: #dbeafe;
  border-right-color: #29415f;
}

body[data-theme="navy"] .sidebar .brand small,
body[data-theme="navy"] .side-nav [data-panel],
body[data-theme="navy"] .help-trigger {
  color: #b8c7dc;
}

body[data-theme="navy"] .side-nav [data-panel].active,
body[data-theme="navy"] .side-nav [data-panel]:hover {
  color: #ffffff;
  background: #24446f;
}

body[data-theme="navy"] .help-trigger {
  background: #172e4c;
  border-color: #315072;
}

body[data-theme="navy"] .help-trigger:hover,
body[data-theme="navy"] .help-trigger:focus-visible {
  color: #ffffff;
  background: var(--teal);
  border-color: var(--teal);
}

body[data-theme="navy"] .brand-mark {
  color: #12233a;
  background: #dbeafe;
}

body[data-theme="navy"] input,
body[data-theme="navy"] select,
body[data-theme="navy"] textarea {
  background: #ffffff;
  border-color: #b7c9e4;
}

body[data-theme="navy"] .form-section,
body[data-theme="navy"] .dashboard-header,
body[data-theme="navy"] .dashboard-table-wrap,
body[data-theme="navy"] .profile-form,
body[data-theme="navy"] .company-preview,
body[data-theme="navy"] .stat,
body[data-theme="navy"] .work-card,
body[data-theme="navy"] .vehicle-card {
  border-color: #b7c9e4;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: var(--font-body);
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

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

[dir="rtl"] body,
[dir="rtl"] input,
[dir="rtl"] select,
[dir="rtl"] textarea,
[dir="rtl"] button {
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
}

[dir="rtl"] body {
  --font-body: 13px;
  --font-control: 12px;
  --font-page-title: clamp(26px, 2.7vw, 34px);
  --font-section-title: clamp(21px, 2vw, 26px);
  --font-card-title: 16px;
  --font-table: 12px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px clamp(18px, 4vw, 54px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  color: white;
  background: var(--ink);
  border-radius: 8px;
  font-weight: 800;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
  background: transparent;
}

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

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  color: var(--muted);
  font-weight: 600;
}

.admin-link {
  color: var(--teal);
}

.hero {
  position: relative;
  min-height: 620px;
  display: grid;
  align-items: end;
  padding: clamp(28px, 5vw, 64px);
  overflow: hidden;
  color: white;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(12, 18, 28, 0.86), rgba(12, 18, 28, 0.28) 58%, rgba(12, 18, 28, 0.68));
}

.hero-media {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14) 0 18%, transparent 18% 100%),
    linear-gradient(160deg, #101828 0%, #1d5f6f 42%, #d0a44d 100%);
}

.hero-media::before {
  content: "";
  position: absolute;
  left: 9%;
  right: 9%;
  bottom: 12%;
  height: 30%;
  border-radius: 90px 90px 24px 24px;
  background: linear-gradient(180deg, #f5f7fb, #7f8da3);
  box-shadow: 0 42px 0 -22px #101828;
}

.hero-media::after {
  content: "";
  position: absolute;
  left: 17%;
  right: 17%;
  bottom: 17%;
  height: 12%;
  border-radius: 80px 80px 12px 12px;
  background: linear-gradient(90deg, #111827, #344054, #111827);
  opacity: 0.82;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 680px;
}

.hero-logo {
  position: absolute;
  left: 50%;
  top: 34%;
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(210px, 18vw, 320px);
  height: clamp(210px, 18vw, 320px);
  overflow: hidden;
  color: white;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 56px;
  font-weight: 900;
  transform: translate(-50%, -50%);
}

.hero-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0;
  background: transparent;
  filter: drop-shadow(0 22px 34px rgba(0, 0, 0, 0.45));
}

.hero h1,
.dashboard h1 {
  margin: 0;
  font-size: var(--font-page-title);
  line-height: 1;
  letter-spacing: 0;
}

.hero p {
  max-width: 560px;
  font-size: 17px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-weight: 800;
  text-transform: uppercase;
  font-size: var(--font-small);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  font-size: var(--font-control);
}

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

.button.ghost {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

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

.button.full {
  width: 100%;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.filters {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 14px;
  padding: 22px clamp(18px, 4vw, 54px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: var(--font-control);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--font-control);
}

textarea {
  resize: vertical;
}

.content-band,
.split-band,
.contact-band {
  padding: 58px clamp(18px, 4vw, 54px);
}

.section-title h2,
.split-band h2,
.contact-band h2,
.panel h2 {
  margin: 0 0 18px;
  font-size: var(--font-section-title);
  letter-spacing: 0;
}

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

.vehicle-card,
.work-card,
.stat,
.lead-form,
.dashboard-table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.06);
}

.vehicle-card {
  overflow: hidden;
}

.vehicle-photo {
  position: relative;
  min-height: 190px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.88);
  font-size: 34px;
  font-weight: 900;
  background: #64748b;
}

.vehicle-photo::before {
  content: "";
  position: absolute;
  width: 72%;
  height: 32%;
  bottom: 22%;
  border-radius: 70px 70px 18px 18px;
  background: rgba(255, 255, 255, 0.88);
}

.vehicle-photo span {
  position: relative;
  z-index: 1;
  color: rgba(17, 24, 39, 0.6);
}

.vehicle-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vehicle-photo:has(img)::before,
.vehicle-photo:has(img)::after {
  display: none;
}

.vehicle-photo.blue { background: linear-gradient(135deg, #0f4c81, #3ab0c8); }
.vehicle-photo.silver { background: linear-gradient(135deg, #667085, #d0d5dd); }
.vehicle-photo.red { background: linear-gradient(135deg, #7a271a, #d92d20); }
.vehicle-photo.black { background: linear-gradient(135deg, #111827, #475467); }

.vehicle-body {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.vehicle-body h3,
.work-card h3 {
  margin: 0;
  font-size: var(--font-card-title);
}

.vehicle-body p,
.work-card p {
  margin: 4px 0 0;
  color: var(--muted);
}

.vehicle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--teal);
  background: var(--soft-accent);
  font-size: 12px;
  font-weight: 800;
}

.status.reserved {
  color: var(--gold);
  background: #fff4df;
}

.pill.success {
  color: var(--green);
  background: #e8f6ed;
}

.split-band {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 32px;
  align-items: start;
  background: color-mix(in srgb, var(--paper) 86%, var(--teal) 8%);
}

.lead-form,
.admin-form {
  display: grid;
  gap: 12px;
}

.lead-form {
  padding: 22px;
}

.lead-form h3 {
  margin: 0;
}

.contact-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 24, 39, 0.68);
}

.modal[hidden] {
  display: none;
}

.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3, 12, 22, 0.86);
}

.photo-lightbox[hidden] {
  display: none;
}

.photo-lightbox img {
  display: block;
  max-width: min(1100px, 94vw);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

.photo-lightbox .icon-button {
  top: 18px;
  right: 18px;
}

.modal-panel {
  position: relative;
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  background: var(--surface);
  border-radius: 8px;
}

.icon-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-size: 24px;
}

.modal-photo {
  min-height: 0;
  height: min(360px, 42vh);
  margin: -22px -22px 22px;
  background: #0f172a;
}

.modal-photo img {
  object-fit: contain;
  padding: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.detail-grid span,
.locked-info {
  display: grid;
  gap: 4px;
  padding: 14px;
  background: color-mix(in srgb, var(--paper) 78%, var(--surface) 22%);
  border-radius: 8px;
}

.detail-grid strong {
  color: var(--muted);
  font-size: var(--font-small);
}

.check-list {
  padding-left: 20px;
}

.locked-info p {
  margin: 0;
  color: var(--muted);
}

.vehicle-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.vehicle-gallery figure {
  margin: 0;
  overflow: hidden;
  background: color-mix(in srgb, var(--paper) 78%, var(--surface) 22%);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.vehicle-gallery figure.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--teal) 28%, transparent);
}

.vehicle-gallery button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.vehicle-gallery img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.vehicle-gallery figcaption {
  padding: 7px 8px;
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.admin-body {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    var(--admin-gradient),
    var(--paper);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
}

.side-nav {
  display: grid;
  gap: 6px;
}

.side-nav-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
  align-items: center;
}

.side-nav [data-panel] {
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  font-size: var(--font-control);
  font-weight: 700;
}

.side-nav [data-panel].active,
.side-nav [data-panel]:hover {
  background: var(--soft-accent);
  color: var(--teal);
}

.help-trigger {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-size: var(--font-control);
  font-weight: 900;
}

.help-trigger:hover,
.help-trigger:focus-visible {
  color: white;
  background: var(--teal);
  border-color: var(--teal);
}

.dashboard {
  padding: 24px;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.dashboard-header,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.dashboard-header {
  padding: 16px;
  background: var(--header-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.05);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.current-user {
  display: grid;
  gap: 1px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.current-user span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.current-user strong {
  font-size: 13px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  min-width: 38px;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.segmented button.active {
  color: white;
  background: var(--teal);
}

.panel {
  display: none;
  min-width: 0;
  max-width: 100%;
}

.panel.active {
  display: block;
}

.subsection-switch {
  display: inline-flex;
  gap: 4px;
  margin: 0 0 18px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.subsection-switch button {
  min-height: 34px;
  padding: 7px 12px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 900;
}

.subsection-switch button.active {
  color: white;
  background: var(--teal);
}

.subpanel {
  display: none;
}

.subpanel.active {
  display: block;
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.56);
}

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

.help-card {
  position: relative;
  width: min(560px, 100%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.help-card h2 {
  margin: 0 0 12px;
  font-size: 24px;
}

.help-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.help-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

[dir="rtl"] .side-nav [data-panel],
[dir="rtl"] th,
[dir="rtl"] td {
  text-align: right;
}

[dir="rtl"] .help-close {
  right: auto;
  left: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.stat {
  display: grid;
  gap: 6px;
  padding: 20px;
}

.stat span {
  font-size: 24px;
  font-weight: 900;
}

.stat small {
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 700;
}

.admin-form {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
  margin-bottom: 20px;
}

.purchase-form,
.inspection-form,
.service-form,
.listing-form,
.ready-listing-form,
.sale-form {
  display: grid;
  gap: 16px;
  margin-bottom: 22px;
}

.form-section {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.06);
}

.form-section h3 {
  margin: 0;
  font-size: var(--font-card-title);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.vin-field,
.photo-upload-field,
.purchase-actions {
  grid-column: 1 / -1;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 8px;
}

#purchaseVin {
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: 0;
}

.cost-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.total-cost-field input {
  color: var(--teal);
  background: var(--soft-accent);
  border-color: #b8e7ea;
  font-weight: 900;
}

.purchase-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(12px);
}

.purchase-actions .button {
  min-width: 160px;
}

.purchase-actions span {
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 700;
}

.purchase-actions span.error {
  color: var(--red);
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 700;
}

.form-note.error {
  color: var(--red);
}

.upload-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.upload-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 8px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: var(--font-small);
  font-weight: 800;
}

.upload-chip button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--red);
  cursor: pointer;
  font-weight: 900;
}

.empty-upload {
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 700;
}

.work-order-preview {
  display: grid;
  gap: 6px;
  padding: 12px;
  background: color-mix(in srgb, var(--paper) 84%, var(--teal) 7%);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.work-order-preview span {
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 900;
  text-transform: uppercase;
}

.work-order-preview p {
  margin: 0;
  white-space: pre-wrap;
}

.bos-preview {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: color-mix(in srgb, var(--paper) 78%, var(--surface) 22%);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.bos-preview div {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.bos-preview div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.bos-preview strong {
  color: var(--muted);
  font-size: var(--font-small);
  text-transform: uppercase;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.profile-form,
.company-preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.06);
}

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

.profile-form .file-field,
.profile-form button {
  grid-column: 1 / -1;
}

.company-preview {
  padding: 18px;
}

.company-preview h3 {
  margin: 14px 0 6px;
  font-size: var(--font-card-title);
}

.company-preview p {
  margin: 0 0 16px;
  color: var(--muted);
}

.logo-preview {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  overflow: hidden;
  color: white;
  background: var(--ink);
  border-radius: 8px;
  font-size: 28px;
  font-weight: 900;
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--surface);
}

.company-preview dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.company-preview dl div {
  padding: 12px;
  background: color-mix(in srgb, var(--paper) 78%, var(--surface) 22%);
  border-radius: 8px;
}

.company-preview dt {
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 800;
}

.company-preview dd {
  margin: 3px 0 0;
}

.vehicle-form {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.dashboard-table-wrap {
  overflow: auto;
  max-width: 100%;
  padding: 14px;
}

#users .dashboard-table-wrap {
  overflow-x: auto;
}

#users table {
  min-width: 0;
}

#users th,
#users td {
  padding: 9px 7px;
}

#users td:nth-child(3),
#users td:nth-child(5) {
  max-width: 190px;
}

.permission-wrap {
  margin-top: 20px;
}

.dashboard-table-wrap h2 {
  font-size: var(--font-card-title);
}

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  vertical-align: top;
  font-size: var(--font-table);
}

td {
  max-width: 220px;
}

th {
  color: var(--muted);
  font-size: var(--font-small);
  text-transform: uppercase;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--teal);
  cursor: pointer;
  font-weight: 800;
}

.cell-note {
  display: block;
  max-width: 360px;
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--font-small);
  white-space: normal;
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.work-card {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.cost-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.cost-summary div {
  padding: 8px;
  background: color-mix(in srgb, var(--paper) 78%, var(--surface) 22%);
  border-radius: 8px;
}

.cost-summary dt {
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 800;
}

.cost-summary dd {
  margin: 2px 0 0;
  font-weight: 800;
}

.file-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-status-button {
  min-height: 34px;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-weight: 900;
}

.file-status-button.has-file {
  background: var(--green);
}

.file-status-button.missing-file {
  background: var(--red);
}

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

.inspection-badge {
  display: grid;
  gap: 2px;
  padding: 9px;
  background: color-mix(in srgb, var(--paper) 78%, var(--surface) 22%);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
}

.inspection-badge small {
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 900;
  text-transform: uppercase;
}

.inspection-badge strong {
  font-size: var(--font-control);
}

.inspection-badge.pass {
  border-color: var(--green);
}

.inspection-badge.needs-work {
  border-color: var(--gold);
}

.inspection-badge.fail,
.inspection-badge.major-issue,
.inspection-badge.declined {
  border-color: var(--red);
}

.align-start {
  justify-self: start;
}

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

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.9), rgba(0, 124, 137, 0.76)),
    var(--paper);
}

.login-shell {
  width: min(440px, 100%);
}

.login-panel {
  display: grid;
  gap: 28px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form h1 {
  margin: 0;
  font-size: var(--font-section-title);
}

.form-error {
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

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

  .split-band,
  .admin-body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    gap: 14px;
  }

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

  .admin-form,
  .vehicle-form,
  .user-form,
  .profile-layout,
  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .profile-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .site-header,
  .contact-band,
  .dashboard-header,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-header .brand {
    order: 1;
  }

  .top-nav {
    order: 2;
    flex-wrap: wrap;
    gap: 12px;
  }

  .subsection-switch {
    display: grid;
    width: 100%;
  }

  .hero {
    min-height: 560px;
  }

  .hero-logo {
    top: 29%;
    width: 150px;
    height: 150px;
    font-size: 36px;
  }

  .hero h1,
  .dashboard h1 {
    font-size: 27px;
  }

  .filters,
  .vehicle-grid,
  .work-grid,
  .stat-grid,
  .inspection-grid,
  .admin-form,
  .vehicle-form,
  .user-form,
  .profile-form,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .dashboard {
    padding: 14px;
  }

  .dashboard-header {
    padding: 14px;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .side-nav {
    grid-template-columns: 1fr;
  }

  .side-nav-item {
    grid-template-columns: minmax(0, 1fr) 30px;
  }

  .help-trigger {
    width: 30px;
    height: 30px;
  }

  .button {
    width: 100%;
  }

  .segmented .button,
  .segmented button {
    width: auto;
  }

  .dashboard-table-wrap {
    padding: 10px;
  }

  .modal-photo {
    height: min(280px, 36vh);
  }

  th,
  td {
    font-size: var(--font-table);
  }

  .input-action,
  .purchase-actions {
    grid-template-columns: 1fr;
  }

  .purchase-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .cost-summary {
    grid-template-columns: 1fr 1fr;
  }
}
