@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

:root {
  --navy:        #0d1b2a;
  --navy-mid:    #102236;
  --navy-light:  #1a3450;
  --navy-card:   #162d46;
  --border:      #1e3a56;
  --border-mid:  #254a6a;
  --red:         #c0392b;
  --red-hover:   #e74c3c;
  --red-pale:    rgba(192,57,43,0.12);
  --text-1:      #e8edf3;
  --text-2:      #8ba4bc;
  --text-3:      #4d6880;
  --success:     #1e8a4a;
  --success-bg:  rgba(30,138,74,0.12);
  --warning:     #b87a00;
  --warning-bg:  rgba(184,122,0,0.12);
  --info:        #1a6fa8;
  --info-bg:     rgba(26,111,168,0.12);
  --danger-bg:   rgba(192,57,43,0.12);
  --font-h:      'Syne', sans-serif;
  --font-b:      'DM Sans', sans-serif;
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   14px;
  --shadow:      0 2px 12px rgba(0,0,0,0.35);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-b);
  background: var(--navy);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 8px; }

/* ─── SIDEBAR ─── */
#sidebar {
  width: 232px;
  min-width: 232px;
  background: var(--navy-mid);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width 0.2s;
  z-index: 100;
}

.sidebar-logo {
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-mark {
  width: 34px; height: 34px;
  background: var(--red);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-h);
  font-weight: 800; font-size: 17px;
  color: #fff;
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-h);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.4px;
}
.logo-text em { color: var(--red); font-style: normal; }

.sidebar-group { padding: 14px 10px 6px; }
.sidebar-group-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 400;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 1px;
  user-select: none;
  position: relative;
}

.nav-link:hover { background: var(--navy-light); color: var(--text-1); }
.nav-link.active { background: var(--red); color: #fff; font-weight: 500; }
.nav-link .icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  display: none;
}
.nav-link.active .nav-badge { display: inline; }
.nav-link:not(.active) .nav-badge {
  display: inline;
  background: var(--red-pale);
  color: var(--red-hover);
}

.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 12px 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

/* ─── MAIN LAYOUT ─── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: 54px;
  background: var(--navy-mid);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 14px;
  flex-shrink: 0;
}

.topbar-title {
  font-family: var(--font-h);
  font-size: 16px;
  font-weight: 700;
  flex: 1;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.search-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  transition: border 0.15s;
}
.search-wrap:focus-within { border-color: var(--red); }
.search-wrap input {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 13px;
  color: var(--text-1);
  width: 210px;
  outline: none;
  font-family: var(--font-b);
}
.search-wrap input::placeholder { color: var(--text-3); }
.search-icon { color: var(--text-3); font-size: 14px; }

/* ─── PAGE ─── */
#page {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-b);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.13s;
  white-space: nowrap;
  line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--red-hover); }
.btn-secondary { background: var(--navy-light); color: var(--text-1); border: 1px solid var(--border-mid); }
.btn-secondary:hover { background: var(--border-mid); }
.btn-outline { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--border-mid); color: var(--text-1); background: var(--navy-light); }
.btn-ghost { background: transparent; color: var(--text-3); border: 1px solid transparent; padding: 5px 8px; }
.btn-ghost:hover { background: var(--navy-light); color: var(--text-2); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-icon { padding: 7px; }

/* ─── CARDS ─── */
.card {
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-sm { padding: 14px 16px; }
.card + .card, .card + .grid, .grid + .card { margin-top: 16px; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-family: var(--font-h);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-1);
}
.card-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ─── GRID ─── */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: 1fr 1fr 1fr; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g-crm { grid-template-columns: 290px 1fr; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }

/* ─── STAT CARDS ─── */
.stat-card {
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.stat-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  margin-bottom: 10px;
}
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); }
.stat-value { font-family: var(--font-h); font-size: 26px; font-weight: 800; color: var(--text-1); margin-top: 2px; }
.stat-sub { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.stat-sub.up { color: var(--success); }
.stat-sub.down { color: var(--red-hover); }

/* ─── FORMS ─── */
.form-group { margin-bottom: 13px; }
.form-row { display: grid; gap: 11px; margin-bottom: 13px; }
.fr2 { grid-template-columns: 1fr 1fr; }
.fr3 { grid-template-columns: 1fr 1fr 1fr; }
.fr4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.fr5 { grid-template-columns: 1fr 1fr 1fr 1fr 1fr; }

label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
  letter-spacing: 0.2px;
}

input[type=text], input[type=number], input[type=email], input[type=tel],
input[type=url], input[type=search], input[type=date], select, textarea {
  width: 100%;
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-b);
  font-size: 13.5px;
  padding: 8px 11px;
  transition: border 0.15s, box-shadow 0.15s;
  outline: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.14);
}
select option { background: var(--navy-mid); }
textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[readonly] { opacity: 0.6; cursor: default; }

/* ─── TABLES ─── */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; min-width: 500px; }
thead tr { background: var(--navy-light); }
thead th {
  padding: 9px 13px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-3);
  text-align: left;
  white-space: nowrap;
}
tbody tr { border-top: 1px solid var(--border); transition: background 0.1s; }
tbody tr:hover { background: rgba(26,52,80,0.5); cursor: pointer; }
tbody td { padding: 10px 13px; font-size: 13.5px; vertical-align: middle; }
.td-muted { font-size: 11.5px; color: var(--text-3); }

/* ─── BADGES ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1px;
  white-space: nowrap;
}
.b-new      { background: var(--info-bg);    color: #5dade2; }
.b-research { background: var(--warning-bg); color: #f0b429; }
.b-waiting  { background: rgba(142,68,173,0.15); color: #bb8fce; }
.b-ordered  { background: var(--success-bg); color: #58d68d; }
.b-complete { background: rgba(30,138,74,0.25); color: #27ae60; }
.b-archived { background: rgba(77,104,128,0.2); color: var(--text-3); }
.b-urgent   { background: var(--danger-bg); color: #e74c3c; }
.b-fleet    { background: var(--info-bg); color: #5dade2; }
.b-repeat   { background: var(--success-bg); color: #58d68d; }
.b-shipped  { background: var(--warning-bg); color: #f0b429; }
.b-arrived  { background: var(--success-bg); color: #27ae60; }
.b-delivered{ background: rgba(30,138,74,0.3); color: #1e8a4a; }

/* ─── TABS ─── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tab {
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
  user-select: none;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--red-hover); border-bottom-color: var(--red-hover); }

/* ─── PAGE HEADER ─── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h1 {
  font-family: var(--font-h);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-1);
}
.page-header p { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* ─── CLIENT LIST ITEMS ─── */
.client-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
  border-left: 3px solid transparent;
}
.client-item:hover { background: var(--navy-light); }
.client-item.selected { background: var(--navy-light); border-left-color: var(--red); }

/* ─── AVATAR ─── */
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--red);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }

/* ─── DIVIDER ─── */
hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ─── TIMELINE ─── */
.timeline { padding-left: 14px; border-left: 2px solid var(--border); }
.tl-item { padding: 0 0 14px 16px; position: relative; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -6px; top: 5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--navy-card);
}
.tl-date { font-size: 10.5px; color: var(--text-3); margin-bottom: 2px; }
.tl-text { font-size: 13px; color: var(--text-1); }

/* ─── PROFIT BOX ─── */
.profit-box {
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 14px;
}
.profit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.profit-row:last-child { border: none; }
.profit-row .lbl { color: var(--text-2); }
.profit-row .val { font-weight: 500; }
.profit-row.total .lbl { font-weight: 700; font-size: 14px; color: var(--text-1); }
.profit-row.total .val { font-weight: 800; font-size: 15px; color: #27ae60; }

/* ─── QUEUE CARD ─── */
.queue-card {
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  margin-bottom: 9px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.queue-card:hover { border-color: var(--border-mid); }
.queue-priority-bar { width: 4px; height: 36px; border-radius: 4px; flex-shrink: 0; }

/* ─── PAYMENT METHOD ─── */
.pay-method {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  transition: all 0.13s;
  user-select: none;
}
.pay-method:hover { border-color: var(--border-mid); color: var(--text-1); }
.pay-method.active { border-color: var(--red); background: var(--red-pale); color: var(--text-1); }

/* ─── STATUS PIPELINE ─── */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 18px 24px;
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}
.pipeline-step { display: flex; flex-direction: column; align-items: center; flex: 1; gap: 6px; }
.pipeline-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  border: 2px solid var(--border);
  background: var(--navy-light);
  color: var(--text-3);
}
.pipeline-dot.done { background: var(--red); border-color: var(--red); color: #fff; }
.pipeline-dot.current { background: var(--navy-light); border-color: var(--red); color: var(--red); }
.pipeline-label { font-size: 10.5px; font-weight: 600; color: var(--text-3); text-align: center; }
.pipeline-label.active { color: var(--text-1); }
.pipeline-line { flex: 1; height: 2px; background: var(--border); margin-top: -20px; }
.pipeline-line.done { background: var(--red); }

/* ─── INVOICE PREVIEW ─── */
.invoice-paper {
  background: #fff;
  color: #1a1a2e;
  padding: 36px 40px;
  border-radius: var(--radius);
  font-family: var(--font-b);
  font-size: 13px;
  line-height: 1.55;
}
.inv-co-name { font-family: var(--font-h); font-size: 22px; font-weight: 800; color: #0d1b2a; }
.inv-co-name em { color: #c0392b; font-style: normal; }
.inv-co-info { font-size: 11px; color: #666; margin-top: 4px; line-height: 1.7; }
.inv-doc-title { font-family: var(--font-h); font-size: 26px; font-weight: 800; color: #0d1b2a; }
.inv-meta { font-size: 12px; color: #555; line-height: 1.8; }
.inv-bill-box { background: #f6f8fb; padding: 14px 16px; border-radius: 8px; }
.inv-bill-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: #999; font-weight: 700; margin-bottom: 5px; }
.inv-bill-name { font-size: 15px; font-weight: 700; color: #0d1b2a; }
.inv-tbl { width: 100%; border-collapse: collapse; margin: 18px 0 8px; }
.inv-tbl th { background: #0d1b2a; color: #fff; padding: 9px 12px; font-size: 11px; text-align: left; }
.inv-tbl td { padding: 8px 12px; font-size: 12.5px; border-bottom: 1px solid #e8edf3; color: #333; }
.inv-tbl tr:nth-child(even) td { background: #f9fafb; }
.inv-total-section { text-align: right; }
.inv-total-table { margin-left: auto; min-width: 240px; }
.inv-total-table td { padding: 4px 10px; font-size: 13px; color: #555; }
.inv-total-table .grand td { font-weight: 800; font-size: 15px; color: #0d1b2a; background: #f0f4f8; border-top: 2px solid #0d1b2a; }
.inv-payment-info { display: flex; gap: 20px; margin-top: 18px; padding: 12px 14px; background: #f6f8fb; border-radius: 8px; }
.inv-payment-col { flex: 1; }
.inv-payment-col-title { font-size: 10px; text-transform: uppercase; font-weight: 700; letter-spacing: 0.8px; color: #0d1b2a; margin-bottom: 5px; }
.inv-payment-col p { font-size: 11.5px; color: #555; }
.inv-tc { margin-top: 20px; padding-top: 14px; border-top: 1px solid #e8edf3; font-size: 11px; color: #999; line-height: 1.7; }
.inv-tc strong { color: #555; }
.inv-footer { text-align: center; margin-top: 14px; font-size: 11px; color: #bbb; }

/* ─── VIN / CATALOG ─── */
.vin-input-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 20px;
}
.vin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.vin-field {
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}
.vin-field-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); margin-bottom: 3px; }
.vin-field-value { font-size: 14px; font-weight: 600; color: var(--text-1); }

.catalog-source-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.catalog-source {
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.13s, background 0.13s;
  text-decoration: none;
  display: block;
}
.catalog-source:hover { border-color: var(--red); background: var(--red-pale); }
.catalog-source-name { font-size: 14px; font-weight: 700; color: var(--text-1); margin-bottom: 4px; }
.catalog-source-desc { font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.catalog-source-url { font-size: 11px; color: var(--red-hover); margin-top: 8px; }

.brand-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.brand-chip {
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.12s;
  user-select: none;
}
.brand-chip:hover, .brand-chip.active { border-color: var(--red); color: var(--text-1); background: var(--red-pale); }

/* ─── PARTS LINE EDITOR ─── */
.parts-editor-header {
  display: grid;
  grid-template-columns: 2.5fr 1.2fr 1fr 1fr 1fr 1fr 120px 36px;
  gap: 8px;
  padding: 7px 10px;
  background: var(--navy-light);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1px solid var(--border);
}
.parts-editor-header span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); }
.parts-line {
  display: grid;
  grid-template-columns: 2.5fr 1.2fr 1fr 1fr 1fr 1fr 120px 36px;
  gap: 8px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-top: none;
  background: var(--navy);
  transition: background 0.1s;
}
.parts-line:last-of-type { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.parts-line:hover { background: rgba(26,52,80,0.4); }
.parts-line input { padding: 6px 8px; font-size: 12.5px; }
.parts-line-add {
  border: 1px dashed var(--border-mid);
  border-top: none;
  background: transparent;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 8px;
  text-align: center;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-3);
  transition: color 0.12s, background 0.12s;
}
.parts-line-add:hover { color: var(--text-1); background: var(--navy-light); }

/* ─── LOOKUP SPINNER ─── */
.lookup-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  font-size: 11px;
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.lookup-btn:hover { border-color: var(--red); color: var(--text-1); }
.lookup-btn.loading { opacity: 0.6; cursor: wait; }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── MODAL ─── */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(5,14,22,0.75);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--navy-mid);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  width: 680px;
  max-width: 96vw;
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px;
  box-shadow: var(--shadow);
}
.modal-lg { width: 860px; }
.modal-title {
  font-family: var(--font-h);
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-close {
  cursor: pointer;
  color: var(--text-3);
  font-size: 18px;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--text-1); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ─── TOAST ─── */
#toast {
  position: fixed;
  bottom: 22px; right: 22px;
  background: var(--navy-card);
  border: 1px solid var(--border-mid);
  border-left: 3px solid var(--success);
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 13px;
  color: var(--text-1);
  z-index: 9999;
  box-shadow: var(--shadow);
  display: none;
  animation: toastIn 0.25s ease;
  max-width: 320px;
}
@keyframes toastIn { from { transform: translateX(80px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── MISC ─── */
.tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px; font-weight: 700;
}
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px; text-align: center;
  color: var(--text-3);
}
.empty-state .icon { font-size: 36px; margin-bottom: 10px; opacity: 0.5; }
.empty-state p { font-size: 14px; }
.empty-state small { font-size: 12px; margin-top: 4px; }

.info-box {
  background: var(--info-bg);
  border: 1px solid rgba(26,111,168,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 12.5px;
  color: #5dade2;
  display: flex; gap: 8px; align-items: flex-start;
}

.notice-box {
  background: var(--warning-bg);
  border: 1px solid rgba(184,122,0,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 12.5px;
  color: #f0b429;
  display: flex; gap: 8px; align-items: flex-start;
}

/* ─── RESPONSIVE / MOBILE ─── */
@media (max-width: 768px) {
  body { flex-direction: column; }

  #sidebar {
    display: none;
  }

  #main {
    flex: 1;
    min-width: 0;
  }

  .topbar {
    height: auto;
    padding: 10px 12px;
    gap: 8px;
  }

  .topbar-title {
    font-size: 14px;
    flex: 1;
  }

  .topbar-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
  }

  .search-wrap {
    flex: 1;
    min-width: 150px;
  }

  .search-wrap input {
    width: 100%;
    font-size: 12px;
  }

  .btn { padding: 6px 12px; font-size: 12px; }

  #page {
    padding: 14px 10px;
    min-width: 0;
    overflow-x: auto;
  }

  /* Grid responsive */
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g-crm { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: span 1; }

  .fr2, .fr3, .fr4, .fr5 { grid-template-columns: 1fr; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }

  /* Cards */
  .card { padding: 16px; }

  /* Tables */
  table { min-width: 100%; }
  .tbl-wrap { font-size: 12px; }
  thead th, tbody td { padding: 8px 10px; font-size: 12px; }

  /* Modal */
  .modal { width: 95vw; padding: 18px; }
  .modal-lg { width: 95vw; }

  /* VIN Grid */
  .vin-grid { grid-template-columns: 1fr 1fr; }

  /* Catalog */
  .catalog-source-grid { grid-template-columns: 1fr; }

  /* Brand grid */
  .brand-grid { grid-template-columns: repeat(2, 1fr); }

  /* Parts editor */
  .parts-editor-header, .parts-line {
    grid-template-columns: 1.5fr 0.8fr 0.8fr 60px 28px;
    font-size: 11px;
  }

  /* Payment info flex */
  .inv-payment-info { flex-direction: column; gap: 12px; }

  /* Stat cards */
  .stat-card { padding: 14px; }

  /* Page header */
  .page-header { flex-direction: column; gap: 12px; }
  .page-header-actions { gap: 6px; }
}

@media (max-width: 480px) {
  .topbar {
    padding: 8px 10px;
  }

  .topbar-title { font-size: 13px; }

  .topbar-right {
    flex-direction: column;
    gap: 8px;
  }

  .search-wrap {
    width: 100%;
    min-width: unset;
  }

  .btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  #page { padding: 10px 8px; }

  .card { padding: 12px; }
  .card-sm { padding: 10px; }

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

  .brand-grid { grid-template-columns: repeat(1, 1fr); }

  /* Large text resize for mobile */
  body { font-size: 13px; }
  .card-title { font-size: 12.5px; }

  /* Modal adjustments */
  .modal { width: 98vw; padding: 12px; }
  .modal-title { font-size: 14px; }

  /* Invoice */
  .inv-tbl th { padding: 5px 8px; font-size: 10px; }
  .inv-tbl td { padding: 5px 8px; font-size: 11px; }

  /* Parts editor */
  .parts-editor-header, .parts-line {
    grid-template-columns: 1fr 0.7fr 50px 24px;
    font-size: 10px;
  }

  /* Tables */
  thead th, tbody td { padding: 6px 8px; font-size: 11px; }

  .stat-value { font-size: 22px; }
}
