/* ============================================================
   Portal — Layout, Sidebar, Topbar, Nav
   ============================================================ */

/* ---- Portal layout shell ---- */
.portal-body {
  background-color: #f0f0ef;
  min-height: 100vh;
}

.portal-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.portal-sidebar {
  width: 240px;
  min-width: 240px;
  background-color: var(--color-black);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform 300ms ease, width 300ms ease;
  z-index: 200;
  border-right: 3px solid var(--accent);
}

.portal-sidebar.is-collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

.portal-sidebar__header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.portal-sidebar__logo-link {
  display: block;
}

.portal-sidebar__logo {
  width: 80px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.portal-sidebar__title {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-silver-mid);
}

/* ---- Portal nav ---- */
.portal-nav {
  flex: 1;
  padding: 16px 8px;
  overflow-y: auto;
}

.portal-nav__section-label {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-silver-mid);
  padding: 8px 8px 4px;
  margin-top: 4px;
}

.portal-nav__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.portal-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-silver);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}

.portal-nav__link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.portal-nav__link:hover {
  background-color: rgba(255,255,255,0.07);
  color: var(--color-white);
}

.portal-nav__link--active {
  background-color: var(--accent);
  color: var(--color-white);
}

.portal-nav__link--active:hover {
  background-color: var(--accent-hover);
}

/* ---- Sidebar footer ---- */
.portal-sidebar__footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.portal-sidebar__user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-sidebar__user-role {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-silver-mid);
  margin-top: 2px;
}

.portal-sidebar__logout {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  color: var(--color-silver-mid);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.portal-sidebar__logout:hover { color: var(--accent); }

/* ---- Language toggle (sidebar) ---- */
.portal-lang-toggle {
  display: flex;
  align-items: center;
  background-color: rgba(255,255,255,0.08);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 0;
  margin-top: 12px;
  width: fit-content;
}

.portal-lang-btn {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--color-silver-mid);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.portal-lang-btn:hover { color: var(--color-white); }

.portal-lang-btn--active {
  background-color: var(--accent);
  color: var(--color-white);
}

/* ---- Main area ---- */
.portal-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ---- Topbar ---- */
.portal-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 60px;
  background-color: var(--color-white);
  border-bottom: 1px solid var(--border-color-light);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.portal-sidebar-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--color-silver-dark);
  transition: background-color var(--transition-fast);
  flex-shrink: 0;
}

.portal-sidebar-toggle:hover {
  background-color: var(--color-grey-bg);
}

.portal-sidebar-toggle svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.portal-topbar__title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-black);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-topbar__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ---- Content area ---- */
.portal-content {
  flex: 1;
  padding: 28px 28px 40px;
  overflow-y: auto;
  overflow-x: hidden;
  max-width: 100%;
}

/* ---- Auth shell (login page) ---- */
.portal-auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-black);
  background-image: radial-gradient(ellipse at 50% 30%, rgba(200,16,46,0.10), transparent 60%);
  padding: var(--space-xl);
}

.portal-auth-shell main {
  width: 100%;
  max-width: 440px;
}

/* ---- Toolbar (search + filters bar above tables) ---- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar__form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}

.toolbar__form .form-input,
.toolbar__form .form-select {
  width: auto;
  flex: 1 1 auto;
  min-width: 120px;
  max-width: 280px;
}

/* Toolbar-specific inputs — not inheriting form-input height issues */
.toolbar-input,
.toolbar-select {
  height: 38px;
  padding: 0 12px;
  border: 1.5px solid #b0b0b0;
  border-radius: 4px;
  background-color: #ffffff;
  color: #1a1a1a;
  font-family: var(--font-body);
  font-size: 14px;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  flex: 1 1 auto;
  min-width: 120px;
  max-width: 280px;
}

.toolbar-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

.toolbar-input:focus,
.toolbar-select:focus {
  outline: none;
  border-color: #C8102E;
  box-shadow: 0 0 0 3px rgba(200,16,46,0.12);
}

.toolbar-input::placeholder { color: #aaa; }

@media (max-width: 640px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar__form {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-input,
  .toolbar-select {
    width: 100%;
    max-width: 100%;
    flex: none;
  }
}

/* ---- Table wrapper: horizontal scroll on mobile ---- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Remove duplicate shadow from table when inside wrapper */
.table-wrap .data-table {
  box-shadow: none;
  border-radius: 0;
}

/* ---- Clickable table rows ---- */
.data-table tbody tr[data-href],
.vehicle-row[data-href],
.attention-item[data-href] {
  cursor: pointer;
}
.data-table tbody tr[data-href]:hover,
.vehicle-row[data-href]:hover {
  background-color: #f0f0f0;
}
.attention-item[data-href]:hover {
  filter: brightness(0.97);
}
.data-table tbody tr[data-href]:focus-visible,
.vehicle-row[data-href]:focus-visible,
.attention-item[data-href]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* Keep action buttons from triggering row click */
.data-table tbody tr[data-href] .btn-group a {
  position: relative;
  z-index: 1;
}

/* ---- Results count line ---- */
.results-count {
  font-size: 13px;
  color: var(--color-silver-mid);
  margin-bottom: 12px;
}

/* ---- Portal data tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table thead tr {
  background-color: var(--color-black);
  color: var(--color-white);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color-light);
  color: var(--color-black);
  vertical-align: middle;
}

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

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

/* ---- Dashboard stat cards ---- */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.dash-stat-card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--accent);
}

.dash-stat-card__label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-silver-mid);
  margin-bottom: 8px;
}

.dash-stat-card__value {
  font-family: var(--font-display);
  font-size: 36px;
  color: var(--color-black);
  line-height: 1;
}

.dash-stat-card__sub {
  font-size: 13px;
  color: var(--color-silver-mid);
  margin-top: 4px;
}

/* ---- Portal page section ---- */
.portal-section {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
}

.portal-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color-light);
  background-color: var(--color-white);
}

.portal-section__title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-black);
}

.portal-section__body {
  padding: 20px;
}

/* ---- Profile type badge ---- */
.profile-badge {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.profile-badge--business { background: #dbeafe; color: #1e40af; }
.profile-badge--personal { background: #d1fae5; color: #065f46; }

/* Responsive */
@media (max-width: 768px) {
  .portal-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    height: 100vh;
  }

  .portal-sidebar.is-mobile-open {
    transform: translateX(0);
  }

  .portal-content { padding: 16px; }

  .portal-topbar {
    padding: 0 16px;
  }

  .portal-topbar__actions .btn { display: none; }
}

/* ============================================================
   Work Order Flow — New styles
   ============================================================ */

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-silver-mid);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb__sep { color: var(--border-color-light); }

/* Vehicle page title */
.page-vehicle-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-black);
  margin: 0;
}
.page-vehicle-meta {
  font-size: 14px;
  color: var(--color-silver-dark);
  margin-top: 4px;
}

/* view-grid with sidebar on right */
.view-grid--sidebar-right {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  max-width: 100%;
  overflow-wrap: break-word;
}
.empty-state__title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-black);
  margin-bottom: 8px;
  overflow-wrap: break-word;
  word-break: break-word;
}
.empty-state__sub {
  font-size: 14px;
  color: var(--color-silver-mid);
  margin-bottom: 24px;
  overflow-wrap: break-word;
}

/* Type badge */
.type-badge {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
}
.type-badge--estimate {
  background: #e0e7ff;
  color: #3730a3;
}
.type-badge--invoice {
  background: #dcfce7;
  color: #166534;
}

/* Detail list (vehicle sidebar) */
.detail-list { display: flex; flex-direction: column; gap: 12px; }
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-item--full { grid-column: 1 / -1; }
.detail-item__label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-silver-mid);
}

/* Vehicle row in customer view */
.vehicle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color-light);
  gap: 12px;
}
.vehicle-row:last-child { border-bottom: none; }

/* Work Order Type Selector */
.wo-type-selector {
  background: var(--color-white);
  border: 2px solid var(--border-color-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}
.wo-type-selector__label {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-silver-dark);
  margin-bottom: 16px;
}
.wo-type-selector__options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.wo-type-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px;
  border: 2px solid var(--border-color-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  gap: 8px;
}
.wo-type-option input[type=radio] { display: none; }
.wo-type-option:hover { border-color: var(--accent); background: rgba(200,16,46,0.03); }
.wo-type-option--active { border-color: var(--accent); background: rgba(200,16,46,0.05); }
.wo-type-option__icon { font-size: 28px; }
.wo-type-option__title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-black);
}
.wo-type-option--active .wo-type-option__title { color: var(--accent); }
.wo-type-option__sub { font-size: 13px; color: var(--color-silver-mid); line-height: 1.5; }

/* Work order summary card (pre-filled customer/vehicle) */
.wo-summary-card {
  background: var(--color-grey-bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wo-summary-card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}
.wo-summary-card__label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-silver-mid);
  flex-shrink: 0;
}

/* Estimate grid layout */
.estimate-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}
.estimate-col { display: flex; flex-direction: column; gap: 20px; }
.estimate-sidebar { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 80px; }

/* Line items */
.line-items-header {
  display: grid;
  grid-template-columns: 160px 1fr 80px 110px 110px 36px;
  gap: 8px;
  padding: 10px 20px;
  background: var(--color-black);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-silver-mid);
}
.line-items-container { padding: 12px 20px; display: flex; flex-direction: column; gap: 10px; }
.line-items-footer { padding: 0 20px 20px; }

/* Totals list */
.totals-list { display: flex; flex-direction: column; gap: 0; font-size: 15px; }
.totals-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border-color-light); }
.totals-row--accent span:first-child { color: var(--accent); }
.totals-row--accent span:last-child { color: var(--accent); }
.totals-row--total { border-bottom: none; padding: 10px 0; }
.totals-row--total span:first-child { font-family: var(--font-heading); font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.totals-total { font-family: var(--font-display); font-size: 24px; color: var(--accent); }

/* Responsive */
@media (max-width: 900px) {
  .estimate-grid { grid-template-columns: 1fr; }
  .estimate-sidebar { position: static; }
  .view-grid--sidebar-right { grid-template-columns: 1fr; }
  .wo-type-selector__options { grid-template-columns: 1fr; }
  .line-items-header { display: none; }
}

/* ============================================================
   Form + Button overrides — explicit portal styles
   These ensure visibility regardless of base.css version
   ============================================================ */

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #b0b0b0 !important;
  border-radius: 4px;
  background-color: #ffffff !important;
  color: #1a1a1a !important;
  font-family: var(--font-body);
  font-size: 15px;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
}

.form-input:hover,
.form-textarea:hover,
.form-select:hover {
  border-color: #888888 !important;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none !important;
  border-color: #C8102E !important;
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12) !important;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: #aaaaaa;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}

.form-label {
  display: block;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #555555;
  margin-bottom: 6px;
}

/* Button scale consistency */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
  box-sizing: border-box;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.btn--sm {
  padding: 7px 14px !important;
  font-size: 12px !important;
}

.btn--lg {
  padding: 13px 28px !important;
  font-size: 15px !important;
}

.btn--full { width: 100%; }

/* ============================================================
   VIN Scanner + Decode Controls
   ============================================================ */

/* VIN input row — input + buttons side by side */
.vin-input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.vin-input-row input {
  flex: 1;
  min-width: 0;
}

.vin-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 10px 14px !important;
  font-size: 13px !important;
}

/* VIN status message */
.vin-status {
  font-size: 13px;
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: 4px;
  font-weight: 500;
}
.vin-status--loading {
  background: #f0f4ff;
  color: #1e40af;
}
.vin-status--success {
  background: #dcfce7;
  color: #166534;
}
.vin-status--error {
  background: #fee2e2;
  color: #991b1b;
}

/* ---- Scanner Modal ---- */
.vin-scan-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.vin-scan-modal__box {
  background: var(--color-black);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.12);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(0,0,0,0.6);
}

.vin-scan-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.vin-scan-modal__title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-white);
  margin: 0;
}

.vin-scan-modal__close {
  background: none;
  border: none;
  color: var(--color-silver-mid);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color var(--transition-fast);
}
.vin-scan-modal__close:hover { color: var(--color-white); }

.vin-scan-modal__body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Camera viewport */
.vin-scan-modal__viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.vin-scan-modal__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Scanning reticle overlay */
.vin-scan-modal__reticle {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Corner brackets */
.vin-scan-modal__reticle::before,
.vin-scan-modal__reticle::after {
  content: '';
  position: absolute;
  width: 80%;
  height: 60%;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
}

/* Animated scan line */
.vin-scan-modal__reticle-line {
  position: absolute;
  width: 76%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #C8102E, transparent);
  animation: vin-scan-sweep 2s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(200,16,46,0.8);
}

@keyframes vin-scan-sweep {
  0%   { top: 22%; }
  50%  { top: 74%; }
  100% { top: 22%; }
}

.vin-scan-modal__hint {
  font-size: 13px;
  color: var(--color-silver-mid);
  text-align: center;
  margin: 0;
}

.vin-scan-modal__result {
  font-family: monospace;
  font-size: 14px;
  color: var(--color-silver);
  text-align: center;
  min-height: 20px;
  margin: 0;
}

@media (max-width: 600px) {
  .vin-scan-modal__box { max-width: 100%; }
  .vin-input-row { flex-wrap: wrap; }
  .vin-input-row input { width: 100%; }
}

/* ============================================================
   Line Item Rows (estimate/work order forms)
   Replaces inline styles removed for CSP compliance
   ============================================================ */

.line-item-row {
  display: grid;
  grid-template-columns: 160px 1fr 80px 110px 110px 36px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color-light);
}

.line-item-row .form-select,
.line-item-row .form-input {
  font-size: 13px !important;
  padding: 8px 10px !important;
}

.line-item-row .line-qty,
.line-item-row .line-price {
  text-align: right;
}

.line-total {
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}
.line-total--normal   { color: var(--color-black); }
.line-total--discount { color: var(--accent); }

.line-remove-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--color-silver-mid);
  cursor: pointer;
  font-size: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.line-remove-btn:hover {
  color: var(--accent);
  background: rgba(200,16,46,0.08);
}

@media (max-width: 768px) {
  .line-item-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
}

/* ============================================================
   Status Badge Classes (replaces inline styles)
   ============================================================ */
.status-badge {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
}
.status--estimate    { background: #fef3c7; color: #92400e; }
.status--approved    { background: #d1fae5; color: #065f46; }
.status--in-progress { background: #dbeafe; color: #1e40af; }
.status--complete    { background: #e0e7ff; color: #3730a3; }
.status--invoiced    { background: #fee2e2; color: #991b1b; }
.status--paid        { background: #dcfce7; color: #166534; }
.status--rejected    { background: #fee2e2; color: #991b1b; }
.status--changes-requested { background: #ffedd5; color: #9a3412; }

/* ============================================================
   Needs Attention Banner (dashboard)
   ============================================================ */
.attention-banner {
  background: #fff8f8;
  border: 2px solid #C8102E;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
}

.attention-banner__header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.attention-banner__icon {
  font-size: 28px;
  color: #C8102E;
  line-height: 1;
  flex-shrink: 0;
}

.attention-banner__title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #C8102E;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.attention-banner__sub {
  font-size: 14px;
  color: var(--color-silver-dark);
  margin: 0;
}

.attention-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #C8102E;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  padding: 0 6px;
  font-family: var(--font-body);
  letter-spacing: 0;
}

.attention-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.attention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  border-left: 4px solid #C8102E;
}

.attention-item.attention--rejected {
  border-left-color: #1a1a1a;
}

.attention-item__info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.attention-item__tag {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #C8102E;
  margin-bottom: 2px;
}

.attention-item.attention--rejected .attention-item__tag {
  color: #1a1a1a;
}

.attention-item__wo {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-black);
  margin: 0;
}

.attention-item__customer {
  font-size: 14px;
  color: var(--color-black);
  font-weight: 600;
  margin: 0;
}

.attention-item__vehicle {
  font-size: 13px;
  color: var(--color-silver-dark);
  margin: 0;
}

.attention-item__time {
  font-size: 12px;
  color: var(--color-silver-mid);
  margin: 0;
}

/* ============================================================
   Nav Badge (sidebar Work Orders count)
   ============================================================ */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #C8102E;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-body);
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  padding: 0 5px;
  margin-left: auto;
  letter-spacing: 0;
  line-height: 1;
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}

/* Responsive attention banner */
@media (max-width: 640px) {
  .attention-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .attention-item .btn { align-self: flex-start; }
}

/* ============================================================
   Invoice View — comment bubbles, history, sidebar
   ============================================================ */

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border-left: 3px solid transparent;
}

.comment-bubble--customer {
  background: #eff6ff;
  border-left-color: var(--accent);
}

.comment-bubble--staff {
  background: var(--color-grey-bg);
  border-left-color: var(--color-black);
}

.comment-bubble__meta {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-silver-mid);
  margin-bottom: 4px;
}

.comment-bubble__text {
  font-size: 14px;
  color: var(--color-black);
}

.staff-only-badge {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--color-black);
  color: var(--color-white);
  padding: 2px 8px;
  border-radius: 999px;
}

/* History timeline */
.history-timeline {
  border-left: 2px solid var(--border-color-light);
  margin-left: 8px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  list-style: none;
  padding-top: 4px;
}

.history-timeline__time {
  font-size: 12px;
  color: var(--color-silver-mid);
}

.history-timeline__action {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-black);
  text-transform: capitalize;
}

.history-timeline__detail {
  font-size: 13px;
  color: var(--color-silver-dark);
}

.history-timeline__by {
  font-size: 12px;
  color: var(--color-silver-mid);
  margin-top: 2px;
}

/* Invoice view sidebar */
.invoice-view-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 80px;
}

/* Status center display */
.status-center {
  text-align: center;
  padding: 12px 0;
}

.status-meta {
  font-size: 13px;
  color: var(--color-silver-dark);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color-light);
}

.status-meta__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Print styles */
@media print {
  /* Hide all portal chrome and the sidebar action panel */
  .portal-sidebar,
  .portal-topbar,
  .portal-nav,
  .portal-topbar__actions,
  .invoice-view-sidebar,
  .breadcrumb,
  .alert,
  #printInvoiceBtn { display: none !important; }

  /* Never client-facing: history timeline and staff-only internal notes.
     Note to Customer is intentionally left visible. */
  .no-print,
  .invoice-history,
  .invoice-internal-notes,
  .portal-footer { display: none !important; }

  /* Flatten the layout so the left column fills the page */
  .portal-layout,
  .portal-main,
  .portal-content { display: block !important; }

  /* The two-column invoice grid — collapse to single column for print */
  .portal-content > div[style*="grid"] {
    display: block !important;
  }

  /* Remove card shadows and borders for clean paper output */
  .portal-section {
    box-shadow: none !important;
    border: none !important;
    page-break-inside: avoid;
    margin-bottom: 16px;
  }

  /* Keep section headers visible */
  .portal-section__header {
    border-bottom: 1px solid #ccc;
    padding-bottom: 6px;
    margin-bottom: 8px;
  }

  /* Scrollable comment/history sections — show full content when printing */
  .scrollable-section {
    max-height: none !important;
    overflow: visible !important;
  }

  /* Don't break table rows across pages */
  .data-table tr { page-break-inside: avoid; }

  body { background: #fff !important; }
}

/* ============================================================
   Form stack — vertical button/input groups with consistent spacing
   ============================================================ */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Scrollable comment/history containers */
.scrollable-section {
  max-height: 420px;
  overflow-y: auto;
  scroll-behavior: smooth;
  /* subtle scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: var(--color-silver-mid) transparent;
}
.scrollable-section::-webkit-scrollbar {
  width: 5px;
}
.scrollable-section::-webkit-scrollbar-track {
  background: transparent;
}
.scrollable-section::-webkit-scrollbar-thumb {
  background: var(--color-silver-mid);
  border-radius: 999px;
}
/* ---- Environment badge ---- */
.env-badge {
  display: inline-block;
  font-size: 1em;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  margin-left: 10px;
  vertical-align: middle;
  letter-spacing: 0.04em;
}

.env-badge--staging {
  background: #C8102E;
  color: #000;
}
/* ============================================================
   Toggle Switch (Admin → Settings, dashboard card config)
   ============================================================ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  vertical-align: middle;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch__slider {
  position: absolute;
  inset: 0;
  background: var(--color-silver-light);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle-switch__slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: var(--color-white);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform var(--transition-fast);
}

.toggle-switch input:checked + .toggle-switch__slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-switch__slider::before {
  transform: translateX(20px);
}

.toggle-switch input:focus-visible + .toggle-switch__slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Dashboard Configuration table (Admin → Settings) */
.settings-dash-config {
  margin-bottom: 24px;
}

.dash-config-table__show-col {
  text-align: right;
  width: 80px;
}

/* ============================================================
   Dashboard stat-card link hover
   (moved out of dashboard.php inline <style> for CSP compliance)
   ============================================================ */
a.dash-stat-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
}

a.dash-stat-card:hover {
  box-shadow: 0 4px 18px rgba(0,0,0,0.14);
  transform: translateY(-2px);
  border-color: var(--accent);
  text-decoration: none;
  color: inherit;
}

a.dash-stat-card:hover .dash-stat-card__sub {
  color: var(--accent);
}

/* ============================================================
   VIN decode — "could not determine" warning states
   ============================================================ */
.vin-status--warning {
  background: #fffbeb;
  color: #92400e;
  border-left: 3px solid #f59e0b;
}

.form-hint--warn {
  color: #92400e;
  font-weight: 600;
}

.form-group--unverified .form-select,
.form-group--unverified .form-input {
  border-color: #f59e0b;
  background: #fffbeb;
}

/* ============================================================
   Required-field validation state (vehicle forms)
   Applied on submit by vehicle-form.js and on re-render by PHP.
   ============================================================ */
.form-group--error .form-select,
.form-group--error .form-input,
.form-group--error .form-textarea {
  border-color: var(--accent);
  border-width: 2px;
  background: #fff5f6;
}

/* Tom Select renders its own control; the original <select> is hidden,
   so the error outline has to target the generated wrapper. */
.form-group--error .ts-control {
  border-color: var(--accent);
  border-width: 2px;
  background: #fff5f6;
}

.form-group--error .form-label {
  color: var(--accent);
}

.form-hint--required {
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
  margin-top: 4px;
}

/* ============================================================
   Trigo Digital brandmark — sidebar bottom + content footer
   The PNG is transparent; nothing here paints a background.
   ============================================================ */
.portal-brandmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  text-decoration: none;
  color: var(--color-silver-mid);
  opacity: 0.85;
  transition: opacity var(--transition-fast);
}
.portal-brandmark:hover { opacity: 1; text-decoration: none; color: var(--color-silver-mid); }
.portal-brandmark img {
  height: 22px;
  width: auto;
  display: block;
  background: transparent;
}
.portal-brandmark--sidebar {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  width: 100%;
}
.portal-footer {
  margin-top: 40px;
  padding: 20px 0 4px;
  border-top: 1px solid var(--color-silver-light);
  display: flex;
  justify-content: center;
}

/* ============================================================
   Dropdown menu (<details class="dropdown">) — no JS required to open
   ============================================================ */
.dropdown { position: relative; display: inline-block; }
.dropdown__toggle { list-style: none; cursor: pointer; user-select: none; }
.dropdown__toggle::-webkit-details-marker { display: none; }
.dropdown__toggle::marker { content: ""; }
.dropdown__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 280px;
  background: var(--color-white);
  border: 1px solid var(--color-silver-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
  z-index: 60;
}
.dropdown__label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-silver-mid);
  padding: 8px 14px 4px;
}
.dropdown__item {
  display: block;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-black);
  text-decoration: none;
  white-space: nowrap;
}
.dropdown__item:hover { background: var(--color-off-white); text-decoration: none; }
.dropdown__meta {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--color-silver-mid);
  margin-top: 2px;
}
.dropdown__item--action {
  margin-top: 6px;
  border-top: 1px solid var(--color-silver-light);
  color: var(--accent);
}
.dropdown__empty {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--color-silver-mid);
  font-style: italic;
}
