:root {
  --color-bg-page: #f3f5fa;
  --color-bg-main: #f7f8fb;
  --color-surface: rgba(255, 255, 255, 0.96);
  --color-surface-solid: #ffffff;
  --color-surface-soft: rgba(255, 255, 255, 0.76);
  --color-sidebar: rgba(255, 255, 255, 0.8);
  --color-sidebar-active: #f1f5f9;
  --color-border: #e2e8f0;
  --color-divider: #e7ebf1;
  --color-primary-dark: #4d8feb;
  --color-primary-purple: #5794ea;
  --color-accent-violet: #4d8feb;
  --color-accent-bright: #5794ea;
  --color-text-primary: #263247;
  --color-text-secondary: #3f4656;
  --color-text-muted: #7d8798;
  --color-text-placeholder: #a8b0be;
  --color-success: #22c55e;
  --color-success-bg: #ecfdf5;
  --color-success-text: #166534;
  --color-warning: #ffbe20;
  --color-warning-text: #92400e;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;
  --color-tag-bg: #eef5ff;
  --color-tag-text: #4d8feb;
  --shadow-card: 0 18px 36px rgba(41, 74, 119, 0.06);
  --shadow-card-hover: 0 16px 40px rgba(40, 66, 111, 0.12);
  --shadow-button: 0 20px 38px rgba(57, 86, 130, 0.08);
  --radius-shell: 28px;
  --radius-section: 28px;
  --radius-card: 16px;
  --radius-control: 12px;
  --radius-pill: 999px;
  --sidebar-width: 220px;
  --header-height: 64px;
  --content-max: 1600px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-shell: 0.5rem;
  --panel-body-padding: var(--space-5);
  --panel-section-gap: var(--space-4);
  --grid-gap: var(--space-4);
  --control-gap: var(--space-3);
  --focus-border: rgba(77, 143, 235, 0.45);
  --focus-ring: 0 0 0 4px rgba(77, 143, 235, 0.14);
  --focus-ring-soft: 0 0 0 4px rgba(77, 143, 235, 0.12);
  --gradient-primary: linear-gradient(135deg, #5794ea, #4d8feb, #5794ea);
  --gradient-brand: linear-gradient(135deg, #5794ea 0%, #4d8feb 55%, #3d7ed7 100%);
  --surface-subtle: rgba(248, 247, 251, 0.85);
  --surface-subtle-strong: rgba(248, 247, 251, 0.9);
  --surface-highlight: rgba(238, 245, 255, 0.84);
  --surface-highlight-soft: rgba(238, 245, 255, 0.74);
  --color-danger-text: #b91c1c;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;
  --panel-header-padding: var(--space-5) var(--space-5) var(--space-4);
  --panel-inline-padding: var(--space-5);
  --card-padding: var(--space-4);
  --card-gap: var(--space-3);
  --field-gap: var(--space-2);
  --control-min-height: 42px;
  --control-padding-y: 10px;
  --control-padding-x: 12px;
  --button-padding-x: 14px;
  --table-cell-padding-y: 14px;
  --table-cell-padding-x: var(--panel-body-padding);
  --section-divider: 1px solid var(--color-divider);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --color-bg-page: #0b1220;
  --color-bg-main: #101826;
  --color-surface: rgba(17, 24, 39, 0.92);
  --color-surface-solid: #162132;
  --color-surface-soft: rgba(22, 33, 50, 0.88);
  --color-sidebar: rgba(12, 19, 32, 0.92);
  --color-sidebar-active: #1c2940;
  --color-border: #2a3a52;
  --color-divider: #223149;
  --color-text-primary: #edf3fb;
  --color-text-secondary: #c9d4e5;
  --color-text-muted: #8c9bb0;
  --color-text-placeholder: #708198;
  --color-success-text: #86efac;
  --color-warning-text: #facc15;
  --color-warning-bg: rgba(250, 204, 21, 0.12);
  --color-warning-border: rgba(250, 204, 21, 0.28);
  --color-tag-bg: rgba(77, 143, 235, 0.16);
  --color-tag-text: #a9c8ff;
  --shadow-card: 0 16px 34px rgba(2, 6, 23, 0.28);
  --shadow-card-hover: 0 18px 40px rgba(2, 6, 23, 0.4);
  --shadow-button: 0 16px 30px rgba(2, 6, 23, 0.32);
  --surface-subtle: rgba(22, 33, 50, 0.84);
  --surface-subtle-strong: rgba(28, 41, 64, 0.9);
  --surface-highlight: rgba(31, 60, 104, 0.48);
  --surface-highlight-soft: rgba(22, 33, 50, 0.84);
}

* {
  box-sizing: border-box;
}

[hidden],
.theme-picker[hidden],
.theme-menu[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--color-bg-page);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--color-text-primary);
  background:
    radial-gradient(circle at top left, rgba(77, 143, 235, 0.08), transparent 24%),
    radial-gradient(circle at top right, rgba(123, 215, 0, 0.08), transparent 18%),
    linear-gradient(180deg, #f9fbfe 0%, var(--color-bg-page) 34%, #eef5ff 100%);
  line-height: 1.45;
}

[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(77, 143, 235, 0.12), transparent 24%),
    radial-gradient(circle at top right, rgba(34, 197, 94, 0.06), transparent 16%),
    linear-gradient(180deg, #0f1726 0%, #0b1220 40%, #0f1a2d 100%);
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-button:focus-visible,
.settings-tab:focus-visible,
.record-card:focus-visible {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: var(--focus-ring);
}

.app-shell {
  width: min(calc(100vw - (var(--space-shell) * 2)), var(--content-max));
  min-height: calc(100vh - (var(--space-shell) * 2));
  margin: var(--space-shell) auto;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  background: var(--color-bg-main);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-shell);
  box-shadow: var(--shadow-card-hover);
  overflow: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  height: calc(100vh - 1rem);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5) 14px;
  background: var(--color-sidebar);
  backdrop-filter: blur(22px);
  border-right: 1px solid var(--color-border);
}

.brand-block {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: var(--space-3);
  align-items: center;
  padding: 6px 6px 18px;
  border-bottom: var(--section-divider);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #ffffff;
  background: var(--gradient-brand);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-button);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
}

.brand-mark.has-logo {
  padding: 0;
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-name {
  color: var(--color-text-primary);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.35;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: var(--control-gap);
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.nav-button:hover {
  color: var(--color-text-primary);
  background: var(--color-sidebar-active);
}

.nav-button.active {
  color: var(--color-text-primary);
  background: var(--color-sidebar-active);
  border-color: var(--color-border);
  box-shadow: var(--shadow-card);
}

.nav-button svg,
.button-icon svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: var(--space-3);
  padding: 12px;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-card);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--color-success);
}

.main-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-8);
  background: color-mix(in srgb, var(--color-bg-main) 86%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
}

.topbar-copy {
  min-width: 0;
}

.topbar h1,
.modal h2 {
  margin: 0;
  color: var(--color-text-primary);
  font-size: 24px;
  font-weight: 600;
  line-height: 32px;
  letter-spacing: -0.02em;
}

.modal h2 {
  font-size: 22px;
}

.eyebrow {
  margin-bottom: 2px;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--control-gap);
  min-width: 0;
}

.search-box[hidden] {
  display: none;
}

.search-box {
  width: min(360px, 36vw);
  min-width: 220px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: var(--control-gap);
  padding: 0 var(--button-padding-x);
  color: var(--color-text-muted);
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-card);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.search-box.active,
.search-box:focus-within {
  border-color: var(--focus-border);
  box-shadow: var(--focus-ring);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--color-text-primary);
  background: transparent;
}

.search-box input::placeholder {
  color: var(--color-text-placeholder);
}

.theme-picker[hidden] {
  display: none;
}

.theme-picker {
  position: relative;
  flex: 0 0 auto;
}

.theme-button {
  min-width: 110px;
}

.theme-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(320px, 88vw);
  display: grid;
  gap: var(--space-2);
  padding: 10px;
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card-hover);
}

.theme-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  padding: 12px;
  color: var(--color-text-primary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.theme-option:hover {
  background: var(--color-sidebar-active);
  border-color: var(--color-border);
}

.theme-option.active {
  background: var(--color-tag-bg);
  border-color: rgba(77, 143, 235, 0.28);
  box-shadow: inset 0 0 0 1px rgba(77, 143, 235, 0.08);
}

.theme-option-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--color-tag-bg);
  font-size: 16px;
}

.theme-option-copy {
  display: grid;
  gap: 2px;
}

.theme-option-copy strong {
  font-size: 14px;
  line-height: 20px;
}

.theme-option-copy small {
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 16px;
}

.theme-picker.open .theme-button {
  border-color: var(--focus-border);
  box-shadow: var(--focus-ring-soft);
}

.theme-option-icon {
  color: var(--color-accent-violet);
}

.theme-option-icon svg {
  width: 18px;
  height: 18px;
}

[data-theme="dark"] .app-shell {
  border-color: rgba(42, 58, 82, 0.95);
  box-shadow: 0 28px 70px rgba(2, 6, 23, 0.42);
}

[data-theme="dark"] .topbar {
  background: rgba(12, 19, 32, 0.84);
}

[data-theme="dark"] .sidebar-footer,
[data-theme="dark"] .search-box,
[data-theme="dark"] .theme-menu,
[data-theme="dark"] .secondary-button,
[data-theme="dark"] .icon-button,
[data-theme="dark"] td select,
[data-theme="dark"] .modal,
[data-theme="dark"] .settings-tabs {
  background: var(--color-surface-solid);
}

[data-theme="dark"] .sidebar-footer {
  background: rgba(22, 33, 50, 0.82);
}

[data-theme="dark"] .nav-button:hover,
[data-theme="dark"] tbody tr:hover,
[data-theme="dark"] .selectable-row:hover {
  background: rgba(28, 41, 64, 0.9);
}

[data-theme="dark"] th {
  background: rgba(14, 22, 36, 0.88);
}

[data-theme="dark"] .selected-row {
  background: rgba(31, 60, 104, 0.48);
}

[data-theme="dark"] .dashboard-overview,
[data-theme="dark"] .workshop-overview {
  background:
    linear-gradient(135deg, rgba(77, 143, 235, 0.14), rgba(22, 33, 50, 0.96) 38%),
    var(--color-surface);
}

[data-theme="dark"] .overview-chip {
  background: rgba(17, 24, 39, 0.84);
}

[data-theme="dark"] .ghost-button {
  background: rgba(18, 28, 44, 0.88);
}

[data-theme="dark"] .empty-state {
  background: repeating-linear-gradient(
      -45deg,
      rgba(77, 143, 235, 0.05) 0,
      rgba(77, 143, 235, 0.05) 8px,
      transparent 8px,
      transparent 16px
    ),
    var(--color-surface-solid);
}

[data-theme="dark"] .theme-option:hover {
  background: rgba(28, 41, 64, 0.95);
}

[data-theme="dark"] .theme-option.active {
  background: rgba(77, 143, 235, 0.18);
  border-color: rgba(77, 143, 235, 0.34);
}

[data-theme="dark"] .message-preview {
  color: #c4d0e1;
  background: linear-gradient(180deg, rgba(22, 33, 50, 0.96), rgba(17, 26, 40, 0.96));
  border-color: rgba(57, 78, 108, 0.95);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 10px 24px rgba(2, 6, 23, 0.14);
  text-shadow: none;
}

[data-theme="dark"] .message-preview strong,
[data-theme="dark"] .message-preview b {
  color: #edf3fb;
}

[data-theme="dark"] .key-value {
  background: linear-gradient(180deg, rgba(22, 33, 50, 0.96), rgba(17, 26, 40, 0.96));
  border-color: rgba(57, 78, 108, 0.95);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 10px 24px rgba(2, 6, 23, 0.16);
  text-shadow: none;
}

[data-theme="dark"] .key-label {
  color: #91a4be;
}

[data-theme="dark"] .key-data {
  color: #edf3fb;
}

[data-theme="dark"] .customer-workspace > .panel:last-child,
[data-theme="dark"] .vehicle-workspace > .panel:last-child {
  background: rgba(17, 24, 39, 0.94);
  border-color: rgba(57, 78, 108, 0.85);
}

[data-theme="dark"] .customer-workspace > .panel:last-child .panel-header,
[data-theme="dark"] .vehicle-workspace > .panel:last-child .panel-header {
  border-bottom-color: rgba(57, 78, 108, 0.78);
}

.content {
  width: 100%;
  padding: var(--space-8);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease;
}

.content.content-switching {
  opacity: 0.32;
  transform: translateY(8px);
}

.view-stack {
  display: grid;
  gap: var(--space-5);
}

.dashboard-overview,
.panel,
.metric-card,
.record-card,
.modal,
.empty-state {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
}

.dashboard-overview,
.panel,
.metric-card,
.record-card {
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.dashboard-overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-6);
  border-radius: var(--radius-section);
  background:
    linear-gradient(135deg, rgba(77, 143, 235, 0.12), rgba(255, 255, 255, 0.94) 32%),
    var(--color-surface);
}

.dashboard-overview-copy {
  max-width: 720px;
}

.dashboard-overview-title {
  margin: 12px 0 8px;
  font-size: 24px;
  font-weight: 600;
  line-height: 32px;
  letter-spacing: -0.02em;
}

.dashboard-overview-note {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 14px;
  line-height: 20px;
}

.dashboard-overview-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--control-gap);
}

.overview-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--button-padding-x);
  color: var(--color-text-secondary);
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
}

.workshop-overview {
  background:
    linear-gradient(135deg, rgba(77, 143, 235, 0.14), rgba(255, 255, 255, 0.96) 36%),
    var(--color-surface);
}

.action-chip {
  cursor: pointer;
}

.action-chip:hover {
  color: var(--color-text-primary);
  border-color: rgba(77, 143, 235, 0.26);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--grid-gap);
}

.customer-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
  padding: var(--space-5);
  border-radius: var(--radius-card);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
}

.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 18px;
}

.metric-head-main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.metric-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--color-accent-violet);
  background: var(--color-tag-bg);
  border-radius: 12px;
}

.metric-label {
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}

.metric-menu {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.metric-menu span {
  width: 4px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: #cbd5e1;
}

.metric-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.metric-value {
  color: var(--color-text-primary);
  font-size: 30px;
  font-weight: 600;
  line-height: 36px;
}

.metric-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: var(--color-success);
  background: var(--color-success-bg);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.metric-note {
  margin-top: var(--space-3);
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 16px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
  gap: var(--space-4);
}

.panel {
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius-section);
}

.panel-body {
  display: grid;
  gap: var(--panel-section-gap);
  padding: var(--panel-body-padding);
}

.panel-header,
.panel-heading,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--panel-header-padding);
  border-bottom: var(--section-divider);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.panel-title {
  margin: 0;
  color: var(--color-text-primary);
  font-size: 18px;
  font-weight: 600;
  line-height: 24px;
  letter-spacing: -0.01em;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--color-text-muted);
  font-size: 14px;
  line-height: 20px;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  min-width: 0;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
  min-width: 0;
}

.search-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--control-padding-y) var(--button-padding-x);
  color: var(--color-text-secondary);
  background: var(--surface-highlight);
  border: 1px solid color-mix(in srgb, var(--color-accent-violet) 18%, var(--color-border));
  border-radius: 16px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--button-padding-x);
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
  transition: opacity 160ms ease, transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover,
.table-action:hover {
  opacity: 0.95;
  transform: scale(1.01);
}

.primary-button {
  color: #ffffff;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-button);
}

.secondary-button {
  color: var(--color-text-primary);
  background: var(--color-surface-solid);
  border-color: var(--color-border);
  box-shadow: var(--shadow-card);
}

.ghost-button {
  color: var(--color-text-secondary);
  background: color-mix(in srgb, var(--color-bg-main) 76%, var(--color-surface-solid));
  border-color: var(--color-border);
}

.icon-button {
  width: 40px;
  padding: 0;
  color: var(--color-text-secondary);
  background: var(--color-surface-solid);
  border-color: var(--color-border);
  box-shadow: var(--shadow-card);
}

.topbar-icon {
  position: relative;
  flex: 0 0 auto;
}

.topbar-icon.has-alerts {
  color: #ffffff;
  background: var(--color-danger);
  border-color: var(--color-danger);
}

.topbar-icon.has-alerts::after {
  content: attr(data-count);
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: #111827;
  border: 2px solid var(--color-surface-solid);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.notification-list {
  display: grid;
  gap: var(--space-3);
}

.notification-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.notification-card.unread {
  border-color: color-mix(in srgb, var(--color-accent-violet) 42%, var(--color-border));
  box-shadow: inset 3px 0 0 var(--color-accent-violet);
}

.insight-button {
  flex: 0 0 auto;
}

.table-action {
  min-height: 34px;
  padding: 0 var(--control-padding-x);
  color: var(--color-tag-text);
  background: var(--color-tag-bg);
  border-color: rgba(77, 143, 235, 0.18);
}

.table-action.next-action {
  color: #ffffff;
  background: var(--gradient-primary);
  border-color: transparent;
  box-shadow: var(--shadow-button);
}

.table-action.danger {
  color: var(--color-danger-text);
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
}

.table-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border-top: 1px solid transparent;
}

.table-wrap::-webkit-scrollbar {
  height: 10px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-pill);
  border: 3px solid transparent;
  background-clip: padding-box;
}

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

.compact-table table {
  min-width: 560px;
}

th,
td {
  padding: var(--table-cell-padding-y) var(--table-cell-padding-x);
  text-align: left;
  border-top: var(--section-divider);
  vertical-align: middle;
}

th {
  color: var(--color-text-muted);
  background: var(--surface-subtle);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  text-transform: uppercase;
}

td {
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

td select {
  min-height: 36px;
  padding: 0 34px 0 10px;
  color: var(--color-text-primary);
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
}

.selectable-row {
  cursor: pointer;
}

tbody tr {
  transition: background 160ms ease;
}

tbody tr:hover,
.selectable-row:hover {
  background: var(--surface-subtle-strong);
}

.selected-row {
  background: var(--surface-highlight);
  box-shadow: inset 3px 0 0 var(--color-accent-violet);
}

.highlight-row {
  background: var(--surface-highlight) !important;
  box-shadow: inset 4px 0 0 var(--color-accent-violet);
}

.highlight-row td {
  color: var(--color-text-primary);
}

.vehicle-workspace,
.customer-workspace,
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.7fr);
  gap: var(--space-4);
}

.vehicle-workspace > .panel:last-child,
.customer-workspace > .panel:last-child {
  position: sticky;
  top: 96px;
}

.record-list {
  display: grid;
  gap: var(--card-gap);
  padding: var(--panel-body-padding);
}

.panel-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 24px;
  margin-left: var(--space-2);
  padding: 0 9px;
  color: var(--color-tag-text);
  background: var(--color-tag-bg);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

.attention-list {
  max-height: 250px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: calc(var(--panel-body-padding) - 4px);
}

.attention-list::-webkit-scrollbar {
  width: 10px;
}

.attention-list::-webkit-scrollbar-track {
  background: transparent;
}

.attention-list::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border: 3px solid transparent;
  border-radius: var(--radius-pill);
  background-clip: padding-box;
}

.attention-card {
  cursor: pointer;
}

.attention-card:focus-visible {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: var(--focus-ring);
}

/* Consistent panel-body spacing after panel headers across all modules */
.panel > .key-value-grid,
.panel > .metric-grid,
.panel > .form-grid,
.panel > .message-preview,
.panel > .export-grid,
.panel > .template-preview-card {
  margin: var(--panel-section-gap) var(--panel-body-padding);
}

.panel-header + .key-value-grid,
.panel-header + .metric-grid,
.panel-header + .form-grid,
.panel-header + .message-preview,
.panel-header + .export-grid,
.panel-header + .template-preview-card {
  margin-top: var(--panel-section-gap);
}

.record-list .key-value-grid,
.record-card .key-value-grid,
.record-list .message-preview {
  margin: 0;
  padding: 0;
}

.panel > .table-wrap {
  margin-top: 0;
}

/* Keep nested two-column card groups aligned with the standard panel body padding. */
.panel > .two-col {
  margin: var(--panel-section-gap) var(--panel-body-padding) var(--panel-body-padding);
}

.panel-header + .two-col {
  margin-top: var(--panel-section-gap);
}


.record-card {
  display: grid;
  gap: var(--space-2);
  width: 100%;
  padding: var(--card-padding);
  text-align: left;
  border-radius: var(--radius-card);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.record-card:hover {
  transform: none;
  box-shadow: var(--shadow-card);
}

.attention-card {
  background: var(--color-surface-solid);
}

.message-line {
  display: grid;
  gap: var(--space-2);
  padding-top: 12px;
  margin-top: var(--space-3);
  border-top: var(--section-divider);
}

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

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

.small {
  font-size: 12px;
  line-height: 16px;
}


/* Dashboard informational pills - kept separate from workflow status tags */
.dashboard-context-pill,
.status.context-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 10px;
  color: var(--color-tag-text);
  background: var(--color-tag-bg);
  border: 0;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  text-transform: none;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}

/* Standardized V5 status/tag palette */
.status.is-invoiced,
.status.invoiced,
.status.completed,
.status.complete,
.status.approved,
.status.paid,
.status.closed,
.status.active {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
}

.status.in-progress,
.status.diagnosing,
.status.partial {
  color: #1d4ed8;
  background: #dbeafe;
  border: 1px solid #bfdbfe;
}

.status.scheduled,
.status.booked,
.status.confirmed {
  color: #0369a1;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
}

.status.waiting,
.status.pending,
.status.pending-invoice {
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
}

.status.sent {
  color: #0e7490;
  background: #cffafe;
  border: 1px solid #a5f3fc;
}

.status.open {
  color: #854d0e;
  background: #fef9c3;
  border: 1px solid #fde047;
}

.status.checked-in {
  color: #3f6212;
  background: #d9f99d;
  border: 1px solid #bef264;
}

.status.cancelled,
.status.rejected,
.status.declined,
.status.overdue,
.status.revoked {
  color: #f8fafc;
  background: #374151;
  border: 1px solid #4b5563;
}

.status.draft,
.status.low {
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
}

.split-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.key-value-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.key-value {
  min-height: 78px;
  padding: var(--card-padding);
  background: var(--surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.key-label {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}

.key-data {
  margin-top: 8px;
  color: var(--color-text-primary);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  overflow-wrap: anywhere;
}

.message-preview {
  padding: var(--space-4);
  color: var(--color-text-secondary);
  background: var(--surface-highlight-soft);
  border: 1px solid rgba(77, 143, 235, 0.12);
  border-radius: var(--radius-card);
}

.email-identity-notice {
  display: grid;
  gap: 10px;
}

.email-identity-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.domain-status-list {
  display: grid;
  gap: 4px;
}

.domain-attention {
  color: var(--color-warning-text);
  font-weight: 600;
}

.warning-notice {
  color: var(--color-warning-text);
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
}

.success-notice {
  border-color: color-mix(in srgb, var(--color-success-text) 30%, transparent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.form-field {
  display: grid;
  gap: var(--field-gap);
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
}

.label-with-help {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tooltip-wrap {
  position: relative;
  display: inline-flex;
}

.tooltip-trigger {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  color: var(--color-text-secondary);
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.tooltip-trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring-soft);
}

.tooltip-content {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 5;
  width: min(260px, calc(100vw - 32px));
  padding: 10px 12px;
  color: #ffffff;
  background: #111827;
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-card);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.tooltip-wrap:hover .tooltip-content,
.tooltip-trigger:focus + .tooltip-content {
  opacity: 1;
  transform: translate(-50%, 0);
}

.form-field input,
.form-field select,
.form-field textarea,
.line-item-row input,
.line-item-row select {
  width: 100%;
  min-height: var(--control-min-height);
  padding: var(--control-padding-y) var(--control-padding-x);
  color: var(--color-text-primary);
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.form-field textarea {
  min-height: 96px;
  resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.line-item-row input:focus,
.line-item-row select:focus {
  border-color: var(--focus-border);
  box-shadow: var(--focus-ring-soft);
}

.form-field.danger-field label {
  color: var(--color-danger-text);
}

.form-field.danger-field select,
.form-field.danger-field input,
.form-field.danger-field textarea {
  color: var(--color-danger-text);
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
}

.danger-notice {
  color: var(--color-danger-text);
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: color-mix(in srgb, var(--color-text-primary) 36%, transparent);
  backdrop-filter: blur(10px);
}

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

.modal {
  width: min(860px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-section);
  background: var(--color-surface-solid);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--panel-header-padding);
  border-bottom: var(--section-divider);
}

.modal-body {
  padding: var(--space-5);
  overflow: auto;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--control-gap);
  margin-top: var(--space-5);
  padding-top: 16px;
  border-top: var(--section-divider);
}

.toast {
  position: fixed;
  right: var(--space-6);
  bottom: var(--space-6);
  z-index: 30;
  max-width: min(380px, calc(100vw - 32px));
  padding: 14px var(--space-4);
  color: #ffffff;
  background: var(--gradient-primary);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-button);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  padding: var(--space-7);
  border-radius: var(--radius-card);
  color: var(--color-text-muted);
  text-align: center;
  background: repeating-linear-gradient(
      -45deg,
      rgba(77, 143, 235, 0.025) 0,
      rgba(77, 143, 235, 0.025) 8px,
      transparent 8px,
      transparent 16px
    ),
    var(--color-surface-solid);
}

.settings-tabs,
.employee-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-2);
  padding: var(--space-2);
  background: color-mix(in srgb, var(--color-surface-solid) 80%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.settings-tab {
  min-height: 40px;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-size: 14px;
  font-weight: 500;
}

.settings-tab:hover,
.settings-tab.active {
  color: var(--color-text-primary);
  background: var(--color-surface-solid);
  border-color: var(--color-border);
  box-shadow: var(--shadow-card);
}

.settings-panel {
  padding-bottom: var(--panel-body-padding);
}

.settings-form {
  padding: var(--panel-body-padding) var(--panel-body-padding) 0;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-4);
  background: color-mix(in srgb, var(--color-bg-main) 86%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.logo-preview {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #ffffff;
  background: var(--gradient-primary);
  border-radius: var(--radius-card);
  font-size: 20px;
  font-weight: 700;
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 240px;
  flex-wrap: wrap;
}

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

.export-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--control-gap);
}

.line-items-editor {
  display: grid;
  gap: var(--space-2);
}

.line-item-head,
.line-item-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(110px, 0.45fr) minmax(80px, 0.25fr) minmax(120px, 0.35fr) auto;
  gap: var(--space-2);
  align-items: center;
}


.line-remove-button {
  min-width: 86px;
}

.line-item-head {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  text-transform: uppercase;
}

.inventory-level {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--control-gap);
  align-items: center;
}

.bar {
  height: 8px;
  overflow: hidden;
  background: var(--color-tag-bg);
  border-radius: var(--radius-pill);
}

.bar span {
  display: block;
  width: var(--bar-width, 0%);
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent-bright), var(--color-accent-violet));
  border-radius: inherit;
}

.bar.low span {
  background: linear-gradient(90deg, #ff9aac, #e95275);
}


/* Shared spacing utilities for generated views and modal helper copy */
.spaced-preview {
  margin-top: var(--space-3);
}

.stacked-key-grid {
  margin-top: var(--panel-section-gap);
  margin-bottom: var(--panel-section-gap);
  padding: 0 var(--panel-body-padding);
}


@media (max-width: 1180px) {
  .app-shell {
    width: calc(100vw - 1rem);
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .sidebar-footer {
    display: none;
  }

  .dashboard-grid,
  .two-col,
  .vehicle-workspace,
  .customer-workspace {
    grid-template-columns: 1fr;
  }

  .vehicle-workspace > .panel:last-child,
  .customer-workspace > .panel:last-child {
    position: static;
  }

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

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

@media (max-width: 820px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-4) var(--space-6);
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .search-box {
    width: 100%;
  }

  .dashboard-overview {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-overview-meta {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .sidebar {
    padding: var(--space-4);
    border-radius: 0;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    gap: var(--space-2);
  }

  .nav-button {
    flex: 0 0 auto;
    width: auto;
  }

  .topbar {
    padding: var(--space-4);
  }

  .content {
    padding: var(--space-4);
  }

  .metric-grid,
  .customer-metrics,
  .key-value-grid,
  .form-grid,
  .export-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .panel-header,
  .panel-heading,
  .search-status,
  .split-row {
    flex-direction: column;
    align-items: stretch;
  }

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

  .topbar-actions .search-box,
  .topbar-actions .insight-button,
  .toolbar-actions button,
  .form-actions .primary-button,
  .form-actions .secondary-button {
    width: 100%;
  }

  .topbar-icon {
    width: 40px;
  }

  th,
  td {
    padding: 12px 16px;
  }

  .settings-tabs {
    grid-template-columns: 1fr;
  }

  .line-item-head {
    display: none;
  }

  .line-item-row {
    grid-template-columns: 1fr;
    padding: 12px;
    background: color-mix(in srgb, var(--color-bg-main) 86%, transparent);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
  }

  .modal-backdrop {
    padding: 12px;
  }
}

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


/* V4 clickable dashboard metric cards */
.metric-card-button {
  display: block;
  width: 100%;
  color: inherit;
  text-align: left;
  appearance: none;
  cursor: pointer;
}

.metric-card-button:focus-visible {
  outline: none;
  border-color: rgba(77, 143, 235, 0.45);
  box-shadow: 0 0 0 4px rgba(77, 143, 235, 0.14), var(--shadow-card-hover);
}


/* V5 document templating system */
.wrap-actions {
  flex-wrap: wrap;
}

.template-preview-card {
  display: grid;
  gap: 14px;
  padding: var(--space-4);
  color: var(--color-text-primary);
  background: linear-gradient(135deg, color-mix(in srgb, var(--template-accent, #4d8feb) 9%, transparent), var(--color-surface-solid));
  border: 1px solid color-mix(in srgb, var(--template-accent, #4d8feb) 24%, var(--color-border));
  border-radius: var(--radius-card);
}

.template-preview-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.template-preview-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #ffffff;
  background: var(--template-accent, #4d8feb);
  border-radius: var(--radius-card);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.template-preview-lines {
  display: grid;
  gap: var(--space-2);
}

.template-preview-lines span {
  display: block;
  height: 9px;
  background: color-mix(in srgb, var(--template-accent, #4d8feb) 18%, var(--color-border));
  border-radius: var(--radius-pill);
}

.template-preview-lines span:nth-child(1) { width: 82%; }
.template-preview-lines span:nth-child(2) { width: 62%; }
.template-preview-lines span:nth-child(3) { width: 74%; }

.template-checks {
  padding: 14px;
  background: color-mix(in srgb, var(--color-bg-main) 86%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

.template-check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--control-gap);
}

.check-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-min-height);
  padding: var(--control-padding-y) var(--control-padding-x);
  color: var(--color-text-secondary);
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  cursor: pointer;
}

.check-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent-violet);
}

.document-preview-frame {
  width: 100%;
  min-height: 70vh;
  margin-top: 14px;
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

[data-theme="dark"] .template-preview-card,
[data-theme="dark"] .template-checks {
  background: color-mix(in srgb, var(--color-surface-solid) 92%, transparent);
}

@media (max-width: 760px) {
  .settings-tabs,
  .template-check-grid {
    grid-template-columns: 1fr;
  }
}


/* V8 employee time and attendance */
.attendance-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: var(--section-divider);
}

.inline-filter {
  display: grid;
  gap: var(--space-2);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.inline-filter input,
.inline-filter select {
  min-height: 38px;
  padding: var(--space-2) 10px;
  color: var(--color-text-primary);
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
}

.mini-key-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-top: var(--control-gap);
}

[data-theme="dark"] .employee-tabs,
[data-theme="dark"] .attendance-filters {
  background: var(--surface-subtle);
  border-color: rgba(57, 78, 108, 0.85);
}

[data-theme="dark"] .inline-filter input,
[data-theme="dark"] .inline-filter select {
  background: var(--color-surface-solid);
  border-color: rgba(57, 78, 108, 0.95);
}

@media (max-width: 820px) {
  .employee-tabs,
  .attendance-filters,
  .mini-key-grid {
    grid-template-columns: 1fr;
  }
}

.attendance-followup-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 760px) {
  .attendance-followup-actions {
    align-items: stretch;
  }

  .attendance-followup-actions .primary-button,
  .attendance-followup-actions .secondary-button {
    width: 100%;
    justify-content: center;
  }
}


/* Employee admin summary bubbles are informational, so they should not jump on hover. */
body:has(.employee-tabs) .metric-card:hover,
body:has(.employee-tabs) .record-card:hover {
  transform: none;
  box-shadow: var(--shadow-card);
}

/* V8 global divider spacing consistency
   Any content immediately following a header/filter divider gets a consistent breathing gap. */
.panel-header + :is(.metric-grid, .key-value-grid, .form-grid, .message-preview, .export-grid, .template-preview-card, .two-col, .record-list, .table-wrap, .attendance-filters),
.section-header + :is(.metric-grid, .key-value-grid, .form-grid, .message-preview, .export-grid, .template-preview-card, .two-col, .record-list, .table-wrap, .attendance-filters),
.attendance-filters + :is(.metric-grid, .key-value-grid, .form-grid, .message-preview, .export-grid, .template-preview-card, .two-col, .record-list, .table-wrap),
.employee-tabs + :is(.metric-grid, .key-value-grid, .form-grid, .message-preview, .export-grid, .template-preview-card, .two-col, .record-list, .table-wrap),
.settings-tabs + :is(.metric-grid, .key-value-grid, .form-grid, .message-preview, .export-grid, .template-preview-card, .two-col, .record-list, .table-wrap) {
  margin-top: var(--panel-section-gap);
}

.panel > :is(.metric-grid, .key-value-grid, .form-grid, .message-preview, .export-grid, .template-preview-card, .two-col, .record-list):not(.panel-header + *) {
  margin-top: var(--panel-section-gap);
}

.panel > .table-wrap:not(.panel-header + *) {
  margin-top: var(--panel-section-gap);
}



/* V8 frontend consistency pass: normalize layout, section spacing, and non-interactive card motion across all generated views. */
.view-stack > :is(.panel, .metric-grid, .dashboard-grid, .toolbar, .search-status, .employee-tabs, .settings-tabs, .attendance-filters, .two-col) {
  margin-top: 0;
}

.view-stack > :is(.panel, .metric-grid, .dashboard-grid, .toolbar, .search-status, .employee-tabs, .settings-tabs, .attendance-filters, .two-col) + :is(.panel, .metric-grid, .dashboard-grid, .toolbar, .search-status, .employee-tabs, .settings-tabs, .attendance-filters, .two-col) {
  margin-top: var(--panel-section-gap);
}

.panel > :is(.record-list, .form-grid, .metric-grid, .key-value-grid, .message-preview, .export-grid, .template-preview-card, .two-col, .attendance-filters, .settings-tabs, .employee-tabs) {
  margin-inline: var(--panel-body-padding);
}

.panel > :is(.record-list, .form-grid, .metric-grid, .key-value-grid, .message-preview, .export-grid, .template-preview-card, .two-col, .attendance-filters, .settings-tabs, .employee-tabs):first-child {
  margin-top: var(--panel-body-padding);
}

.panel > :is(.record-list, .form-grid, .metric-grid, .key-value-grid, .message-preview, .export-grid, .template-preview-card, .two-col, .attendance-filters, .settings-tabs, .employee-tabs):last-child {
  margin-bottom: var(--panel-body-padding);
}

.panel > .table-wrap + :is(.record-list, .message-preview, .form-grid, .key-value-grid),
.panel > :is(.record-list, .message-preview, .form-grid, .key-value-grid) + .table-wrap {
  margin-top: var(--panel-section-gap);
}

.panel :is(.key-value, .record-card, .metric-card):not([data-view-route]):not(.action-chip) {
  transform: none;
}

.panel :is(.key-value, .record-card, .metric-card):not([data-view-route]):not(.action-chip):hover {
  transform: none;
  box-shadow: var(--shadow-card);
}

.form-grid,
.key-value-grid,
.metric-grid,
.export-grid,
.record-list,
.template-preview-card,
.line-items-editor,
.attendance-filters,
.employee-tabs,
.settings-tabs {
  gap: var(--grid-gap);
}

/* Informational bubbles inside panel sections should stay static on hover. */
.panel :is(.metric-card, .record-card):hover,
.record-list :is(.metric-card, .record-card):hover,
.key-value-grid .key-value:hover {
  transform: none;
  box-shadow: var(--shadow-card);
}


/* V8 workflow intelligence */
.next-action-panel,
.workflow-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4, 16px);
  padding: var(--space-4, 16px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: linear-gradient(135deg, rgba(77, 143, 235, 0.08), var(--color-surface-solid));
}

.workflow-card {
  min-height: 96px;
}

.timeline-list {
  display: grid;
  gap: var(--space-3, 12px);
  margin-top: var(--space-3, 12px);
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-solid);
}

.timeline-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--color-accent-blue);
  box-shadow: 0 0 0 4px rgba(77, 143, 235, 0.12);
}

[data-theme="dark"] .next-action-panel,
[data-theme="dark"] .workflow-card {
  background: linear-gradient(135deg, rgba(77, 143, 235, 0.14), var(--color-surface-solid));
}

@media (max-width: 720px) {
  .next-action-panel,
  .workflow-card {
    align-items: stretch;
    flex-direction: column;
  }
}

/* V8 status filters */
.list-filter-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.compact-filter-field {
  width: min(320px, 100%);
}

[data-theme="dark"] .list-filter-bar {
  background: var(--color-surface-solid);
  border-color: rgba(57, 78, 108, 0.85);
}

@media (max-width: 720px) {
  .list-filter-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-filter-field {
    width: 100%;
  }
}

/* V8 status filters in view toolbars */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.inline-status-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 220px;
}

.inline-status-filter select {
  min-width: 190px;
  height: 40px;
  padding: 0 38px 0 var(--space-3);
  color: var(--color-text-primary);
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-card);
}

[data-theme="dark"] .inline-status-filter select {
  background: var(--color-surface-solid);
  border-color: rgba(57, 78, 108, 0.85);
}

@media (max-width: 860px) {
  .inline-status-filter,
  .inline-status-filter select {
    width: 100%;
    min-width: 0;
  }
}

/* V8 fix: toolbar status filters should visually match action buttons. */
.inline-status-filter select {
  min-height: 40px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: 0;
}

.inline-status-filter .table-action {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
}

/* V8 helper copy typography consistency
   Keep informational helper bubbles aligned with the rest of the app and prevent cramped wrapping. */
.message-preview {
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
  letter-spacing: 0;
  padding: 14px 16px;
  min-height: auto;
  white-space: normal;
  overflow-wrap: break-word;
}

.record-list > .message-preview,
.panel > .message-preview {
  max-width: 100%;
}

[data-theme="dark"] .message-preview {
  line-height: 22px;
}

/* V8 fix: informational helper bubbles inside record/detail panels need real internal padding.
   Earlier global spacing normalization accidentally zeroed padding for .record-list .message-preview,
   causing text to touch the bubble edge. Keep the bubble full-width and let it grow downward. */
.record-list > .message-preview,
.record-list .message-preview,
.record-card .message-preview,
.panel .record-list .message-preview {
  display: block;
  width: 100%;
  min-height: auto;
  height: auto;
  padding: var(--space-4) var(--space-5) !important;
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 400;
  line-height: 24px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
}

.record-list > .message-preview:last-child,
.panel .record-list .message-preview:last-child {
  margin-bottom: 0;
}

/* V8 customer/vehicle flow refinement */
.compact-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: var(--font-size-sm, 0.875rem);
  line-height: var(--line-height-sm, 1.25rem);
}

.record-card .split-row .compact-button {
  flex: 0 0 auto;
}


.danger-ghost {
  color: var(--color-danger-text);
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
}

.startup-wizard {
  display: grid;
  gap: var(--space-4);
}

.startup-progress {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
}

.startup-task-list {
  display: grid;
  gap: 0;
  border-top: var(--section-divider);
}

.startup-task {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  min-height: 46px;
  border-bottom: var(--section-divider);
}

.startup-check {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  color: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.startup-task.done .startup-check {
  background: var(--color-success);
  border-color: var(--color-success);
}

.startup-label {
  color: var(--color-text-primary);
  font-size: 14px;
  font-weight: 500;
}

.startup-task-action {
  min-height: 32px;
  padding: 0 4px;
  color: var(--color-danger-text);
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 600;
}

.startup-hide-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-secondary);
  font-size: 13px;
}

.startup-hide-option input {
  width: 16px;
  height: 16px;
}

.startup-wizard-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding-top: var(--space-3);
  border-top: var(--section-divider);
}

/* V9 login and startup polish */
body[data-auth="checking"] .app-shell,
body[data-auth="checking"] .login-page,
body[data-auth="checking"] .toast,
body[data-auth="checking"] .modal-backdrop,
body[data-auth="locked"] .app-shell,
body[data-auth="locked"] .toast,
body[data-auth="locked"] .modal-backdrop {
  display: none !important;
}

body[data-auth="locked"] .auth-loading-page,
body[data-auth="unlocked"] .auth-loading-page,
body[data-auth="unlocked"] .login-page {
  display: none !important;
}

.auth-loading-page,
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background:
    radial-gradient(circle at top left, rgba(77, 143, 235, 0.12), transparent 28%),
    linear-gradient(180deg, #f9fbfe 0%, var(--color-bg-page) 100%);
}

.auth-loading-card {
  width: min(360px, calc(100vw - 48px));
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card-hover);
}

.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: var(--space-5);
  padding: var(--space-7);
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-section);
  box-shadow: var(--shadow-card-hover);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: var(--section-divider);
}

.login-copy h1 {
  margin: 0;
  color: var(--color-text-primary);
  font-size: 26px;
  line-height: 32px;
}

.login-copy p:last-child {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
}

.login-form {
  display: grid;
  gap: var(--space-4);
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
  padding: 4px;
  background: var(--color-bg-page);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
}

.auth-switch-button {
  min-height: 38px;
  color: var(--color-text-muted);
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius-control) - 4px);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.auth-switch-button.active {
  color: var(--color-text-primary);
  background: var(--color-surface-solid);
  box-shadow: var(--shadow-soft);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--color-border);
}

.login-error {
  padding: var(--space-3);
  color: var(--color-danger-text);
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
  border-radius: var(--radius-control);
  font-size: 13px;
}

.logout-button {
  width: 100%;
  min-height: 40px;
  justify-content: center;
  color: var(--color-text-primary);
  background: var(--color-surface-solid);
  border-color: var(--color-border);
  box-shadow: 0 10px 24px rgba(40, 66, 111, 0.06);
}

.logout-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(40, 66, 111, 0.1);
}

.startup-wizard {
  display: grid;
  gap: 0;
}

.startup-progress {
  padding: var(--space-5) 0 var(--space-7);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
}

.startup-task-list {
  display: grid;
  gap: 0;
  border-top: 0;
}

.startup-task {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  min-height: 46px;
  padding: 0 2px;
  border-bottom: var(--section-divider);
}

.startup-check {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  color: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.startup-task.done .startup-check {
  background: var(--color-success);
  border-color: var(--color-success);
}

.startup-label {
  color: var(--color-text-primary);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.startup-task-action {
  min-height: 32px;
  padding: 0 6px;
  color: var(--color-danger-text);
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 700;
}

.startup-hide-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 64px;
  padding: var(--space-4) 2px;
  color: var(--color-text-secondary);
  border-bottom: var(--section-divider);
  font-size: 13px;
}

.startup-hide-option input {
  width: 16px;
  height: 16px;
}

.startup-wizard-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 0;
}

.startup-wizard-footer .secondary-button {
  margin-left: auto;
}

/* V9 startup wizard final layout pass */
.startup-modal {
  width: min(846px, calc(100vw - 28px));
  max-height: min(94vh, 720px);
}

.startup-modal .modal-header {
  min-height: 74px;
  padding: 11px 16px 14px;
}

.startup-modal .modal-body {
  padding: 0 14px 16px;
}

.startup-modal .eyebrow {
  margin-bottom: 4px;
}

.startup-modal .startup-wizard {
  display: grid;
  gap: 0;
}

.startup-modal .startup-progress {
  min-height: 84px;
  display: flex;
  align-items: flex-start;
  padding: 22px 2px 0;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 16px;
}

.startup-modal .startup-task-list {
  display: grid;
  gap: 0;
  border-top: 0;
}

.startup-modal .startup-task {
  min-height: 46px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 0 4px 0 2px;
  border-bottom: var(--section-divider);
}

.startup-modal .startup-check {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  color: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.startup-modal .startup-task.done .startup-check {
  background: var(--color-success);
  border-color: var(--color-success);
}

.startup-modal .startup-label {
  color: var(--color-text-primary);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.startup-modal .startup-task-action {
  min-height: 32px;
  padding: 0 2px;
  color: var(--color-danger-text);
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 700;
}

.startup-modal .startup-wizard-footer {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 12px 0 0 2px;
  border-top: 0;
}

.startup-modal .startup-hide-option {
  min-height: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  color: var(--color-text-secondary);
  border-bottom: 0;
  font-size: 13px;
  line-height: 20px;
}

.startup-modal .startup-hide-option input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.startup-modal .startup-wizard-footer .secondary-button {
  margin-left: auto;
  min-width: 118px;
}

.line-item-rows {
  display: grid;
  gap: var(--space-2);
}

.line-item-add-row {
  padding-top: var(--space-2);
  border-top: var(--section-divider);
}

.line-item-add-row input[readonly] {
  color: var(--color-text-muted);
  background: var(--surface-subtle);
}

.lookup-field {
  position: relative;
}

.lookup-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  display: grid;
  max-height: 240px;
  overflow-y: auto;
  padding: var(--space-2);
  background: var(--color-surface-solid);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-card-hover);
}

.lookup-result {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  color: var(--color-text-primary);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.lookup-result:hover,
.lookup-result:focus-visible {
  background: var(--surface-highlight);
  outline: none;
}

.lookup-result small,
.lookup-empty {
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 16px;
}

.lookup-empty {
  padding: 10px 12px;
}
