/* ═══════════════════════════════════════════════
   Motor Survey Pro — Design System
   Premium dark-sidebar, light content layout
   Mobile-first, CSS Grid/Flexbox
   ═══════════════════════════════════════════════ */

/* ── Variables ── */
:root {
  --clr-bg: #f0f2f7;
  --clr-surface: #ffffff;
  --clr-sidebar: #0f1729;
  --clr-sidebar-2: #162040;
  --clr-brand: #3b6ef8;
  --clr-brand-dk: #2a56d8;
  --clr-brand-lt: #e8effe;
  --clr-success: #22c55e;
  --clr-warning: #f59e0b;
  --clr-danger: #ef4444;
  --clr-info: #06b6d4;
  --clr-text: #1a2236;
  --clr-text-2: #4b5877;
  --clr-text-3: #8b95ab;
  --clr-border: #e2e8f3;
  --clr-border-dk: #c8d0df;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .06);
  --shadow: 0 4px 16px rgba(0, 0, 0, .10);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .14);
  --transition: .2s ease;
  --font-main: 'Inter', system-ui, sans-serif;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --clr-table-hover: #f7f9ff;
  --clr-table-stripe: #f9fafb;
}

:root[data-theme="dark"] {
  --clr-bg: #0f172a;
  --clr-surface: #1e293b;
  --clr-sidebar: #090d16;
  --clr-sidebar-2: #111827;
  --clr-brand: #6366f1;
  --clr-brand-dk: #4f46e5;
  --clr-brand-lt: #312e81;
  --clr-text: #f8fafc;
  --clr-text-2: #94a3b8;
  --clr-text-3: #64748b;
  --clr-border: #334155;
  --clr-border-dk: #475569;
  --clr-table-hover: #192333;
  --clr-table-stripe: #121828;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background: var(--clr-bg);
  color: var(--clr-text);
  min-height: 100vh;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--clr-brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ═══════════════════════
   SIDEBAR LAYOUT
═══════════════════════ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--clr-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.brand-icon {
  font-size: 28px;
  line-height: 1;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.brand-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--clr-brand);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .3);
  padding: 16px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .65);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
  text-decoration: none;
}

.nav-item.active {
  background: var(--clr-brand);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 110, 248, .4);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-label {
  white-space: nowrap;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--clr-brand), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: rgba(255, 255, 255, .45);
  text-transform: capitalize;
}

.btn-logout {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, .6);
  font-size: 16px;
  transition: all var(--transition);
  flex-shrink: 0;
  text-decoration: none;
  cursor: pointer;
}

.btn-logout:hover {
  background: var(--clr-danger);
  color: #fff;
}

/* ═══════════════════════
   MAIN WRAPPER
═══════════════════════ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--clr-text-2);
  padding: 4px;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--clr-text);
  flex: 1;
}

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

.main-content {
  flex: 1;
  padding: 28px 28px 40px;
  max-width: 1400px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 190;
}

/* ═══════════════════════
   BUTTONS
═══════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  font-family: var(--font-main);
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn:active {
  transform: translateY(0);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-primary {
  background: var(--clr-brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--clr-brand-dk);
}

.btn-success {
  background: var(--clr-success);
  color: #fff;
}

.btn-danger {
  background: var(--clr-danger);
  color: #fff;
}

.btn-warning {
  background: var(--clr-warning);
  color: #fff;
}

.btn-secondary {
  background: var(--clr-border);
  color: var(--clr-text-2);
}

.btn-secondary:hover {
  background: var(--clr-border-dk);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--clr-brand);
  color: var(--clr-brand);
}

.btn-outline:hover {
  background: var(--clr-brand-lt);
}

.btn-ghost {
  background: transparent;
  color: var(--clr-text-2);
}

.btn-ghost:hover {
  background: var(--clr-border);
}

.btn-icon {
  padding: 8px;
  border-radius: 8px;
}

/* ═══════════════════════
   CARDS
═══════════════════════ */
.card {
  background: var(--clr-surface);
  border-radius: var(--radius);
  border: 1px solid var(--clr-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--clr-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--clr-text);
}

.card-body {
  padding: 24px;
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--clr-border);
  background: var(--clr-bg);
}

/* ═══════════════════════
   FORMS
═══════════════════════ */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--clr-text-2);
  margin-bottom: 6px;
  letter-spacing: .3px;
}

.form-label .req {
  color: var(--clr-danger);
  margin-left: 3px;
}

.form-control {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-main);
  color: var(--clr-text);
  background: var(--clr-surface);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--clr-brand);
  box-shadow: 0 0 0 3px rgba(59, 110, 248, .14);
}

.form-control::placeholder {
  color: var(--clr-text-3);
}

.form-control:disabled {
  background: var(--clr-bg);
  color: var(--clr-text-3);
  cursor: not-allowed;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  padding-right: 36px;
}

.form-hint {
  font-size: 12px;
  color: var(--clr-text-3);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--clr-danger);
  margin-top: 4px;
  display: none;
}

.form-control.is-invalid {
  border-color: var(--clr-danger);
}

.form-control.is-invalid+.form-error {
  display: block;
}

.form-row {
  display: grid;
  gap: 20px;
}

.form-row-2 {
  grid-template-columns: 1fr 1fr;
}

.form-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-row-4 {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}

.form-row-auto {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--clr-brand);
  cursor: pointer;
}

.form-check label {
  font-size: 14px;
  cursor: pointer;
  color: var(--clr-text);
}

/* ═══════════════════════
   TABLES
═══════════════════════ */
.table-wrapper {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th {
  background: var(--clr-bg);
  color: var(--clr-text-2);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--clr-border);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--clr-border);
  color: var(--clr-text);
  vertical-align: middle;
}

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

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover {
  background: var(--clr-table-hover);
}

.table-striped tbody tr:nth-child(even) {
  background: var(--clr-table-stripe);
}

.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ═══════════════════════
   DROPDOWN MENUS
═══════════════════════ */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  font-size: 16px;
  padding: 4px 8px;
  font-weight: bold;
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--clr-surface);
  min-width: 140px;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--clr-border);
  z-index: 1000;
  padding: 8px 0;
}

.dropdown-menu.show {
  display: block;
  animation: fadeIn 0.2s ease;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--clr-text);
  font-size: 13px;
  text-decoration: none;
  font-weight: 500;
}

.dropdown-item:hover {
  background: var(--clr-table-hover);
  text-decoration: none;
  color: var(--clr-brand);
}

.dropdown-divider {
  height: 1px;
  background: var(--clr-border);
  margin: 6px 0;
}

/* ═══════════════════════
   STATUS BADGES
═══════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
}

.badge-draft {
  background: #fef3c7;
  color: #92400e;
}

.badge-final {
  background: #d1fae5;
  color: #065f46;
}

.badge-locked {
  background: #e0e7ff;
  color: #3730a3;
}

.badge-admin {
  background: linear-gradient(135deg, #3b6ef8, #7c3aed);
  color: #fff;
}

.badge-staff {
  background: var(--clr-border);
  color: var(--clr-text-2);
}

/* ═══════════════════════
   STATS / KPI CARDS
═══════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue {
  background: #eff4ff;
}

.stat-icon.green {
  background: #f0fdf4;
}

.stat-icon.amber {
  background: #fffbeb;
}

.stat-icon.violet {
  background: #f5f3ff;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--clr-text-3);
  margin-top: 4px;
  font-weight: 500;
}

/* ═══════════════════════
   ALERTS
═══════════════════════ */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fed7aa;
  color: #92400e;
}

.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

/* ═══════════════════════
   MULTI-STEP FORM
═══════════════════════ */
.step-progress {
  display: flex;
  gap: 0;
  margin-bottom: 32px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.step-item {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--clr-border);
  background: var(--clr-surface);
  color: var(--clr-text-3);
  transition: all var(--transition);
  flex-shrink: 0;
  cursor: pointer;
}

.step-dot.active {
  border-color: var(--clr-brand);
  background: var(--clr-brand);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(59, 110, 248, .2);
}

.step-dot.done {
  border-color: var(--clr-success);
  background: var(--clr-success);
  color: #fff;
}

.step-line {
  width: 40px;
  height: 2px;
  background: var(--clr-border);
  flex-shrink: 0;
  transition: background var(--transition);
}

.step-line.done {
  background: var(--clr-success);
}

.step-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--clr-text-3);
  text-align: center;
  margin-top: 4px;
  white-space: nowrap;
}

.step-section {
  display: none;
}

.step-section.active {
  display: block;
  animation: fadeIn .25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.step-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--clr-border);
  gap: 12px;
  flex-wrap: wrap;
}

/* ═══════════════════════
   DYNAMIC TABLE (Parts/Labour)
═══════════════════════ */
.dynamic-table {
  margin-bottom: 16px;
}

.dynamic-table .table input,
.dynamic-table .table select {
  border: 1px solid var(--clr-border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font-main);
  width: 100%;
  min-width: 80px;
  background: #fff;
  transition: border-color var(--transition);
}

.dynamic-table .table input:focus,
.dynamic-table .table select:focus {
  outline: none;
  border-color: var(--clr-brand);
  box-shadow: 0 0 0 2px rgba(59, 110, 248, .12);
}

.dynamic-table .table input.auto-val {
  background: #f7f9ff;
  color: var(--clr-brand);
  font-weight: 600;
}

.dynamic-table tfoot td {
  font-weight: 700;
  background: var(--clr-bg);
}

.dynamic-table tfoot td.total-label {
  text-align: right;
  color: var(--clr-text-2);
}

.add-row-btn {
  font-size: 13px;
}

.del-row-btn {
  padding: 5px 9px;
  font-size: 14px;
}

/* ═══════════════════════
   SUMMARY TABLE (auto-computed)
═══════════════════════ */
.summary-table td {
  padding: 10px 16px;
}

.summary-table .summary-total td {
  font-weight: 700;
  font-size: 15px;
  background: linear-gradient(90deg, var(--clr-brand-lt), #f0f4ff);
  color: var(--clr-brand-dk);
  border-top: 2px solid var(--clr-brand);
}

.summary-table .section-head td {
  background: var(--clr-bg);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--clr-text-2);
}

/* ═══════════════════════
   PHOTO UPLOAD / DRAG-DROP
═══════════════════════ */
.photo-dropzone {
  border: 2px dashed var(--clr-brand);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  background: var(--clr-brand-lt);
  cursor: pointer;
  transition: all var(--transition);
}

.photo-dropzone:hover,
.photo-dropzone.dragover {
  background: #dce8ff;
  border-color: var(--clr-brand-dk);
}

.photo-dropzone p {
  color: var(--clr-text-2);
  font-size: 14px;
  margin-top: 8px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.photo-thumb {
  border-radius: var(--radius-sm);
  border: 1px solid var(--clr-border);
  overflow: hidden;
  background: var(--clr-bg);
  position: relative;
  cursor: grab;
}

.photo-thumb:active {
  cursor: grabbing;
}

.photo-thumb img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.photo-thumb-info {
  padding: 8px;
}

.photo-thumb-info input {
  width: 100%;
  font-size: 12px;
  border: 1px solid var(--clr-border);
  border-radius: 4px;
  padding: 4px 8px;
}

.photo-thumb .del-photo {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--clr-danger);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ═══════════════════════
   LOGIN PAGE
═══════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1729 0%, #1a2f5e 50%, #0f1729 100%);
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius-lg);
  padding: 40px;
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .4);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-icon {
  font-size: 48px;
  display: block;
}

.login-logo h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-top: 10px;
}

.login-logo p {
  color: rgba(255, 255, 255, .5);
  font-size: 13px;
  margin-top: 6px;
}

.login-box .form-label {
  color: rgba(255, 255, 255, .7);
}

.login-box .form-control {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .15);
  color: #fff;
}

.login-box .form-control:focus {
  border-color: var(--clr-brand);
  background: rgba(255, 255, 255, .12);
}

.login-box .form-control::placeholder {
  color: rgba(255, 255, 255, .3);
}

.login-box .btn-primary {
  background: linear-gradient(135deg, var(--clr-brand), #7c3aed);
  border: none;
}

.login-forgot {
  display: block;
  text-align: center;
  color: rgba(255, 255, 255, .5);
  font-size: 13px;
  margin-top: 16px;
}

.login-forgot:hover {
  color: rgba(255, 255, 255, .8);
}

/* ═══════════════════════
   PAGE HEADER
═══════════════════════ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--clr-text);
}

.page-header p {
  font-size: 14px;
  color: var(--clr-text-3);
  margin-top: 4px;
}

/* ═══════════════════════
   SEARCH / FILTER BAR
═══════════════════════ */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: flex-end;
}

.filter-bar .form-group {
  margin-bottom: 0;
  min-width: 160px;
}

.filter-bar .form-control {
  min-width: 0;
}

/* ═══════════════════════
   PROGRESS STEPPER (top of case form)
═══════════════════════ */
.stepper-container {
  background: var(--clr-surface);
  border-radius: var(--radius);
  border: 1px solid var(--clr-border);
  padding: 20px 24px 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

/* ═══════════════════════
   SECTION DIVIDERS
═══════════════════════ */
.section-divider {
  border-top: 1px solid var(--clr-border);
  margin: 28px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-divider span {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: var(--clr-text-3);
  letter-spacing: .5px;
  text-transform: uppercase;
  background: var(--clr-surface);
  padding: 0 12px;
}

/* ═══════════════════════
   MODALS
═══════════════════════ */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--clr-surface);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: fadeIn .2s ease;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--clr-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--clr-text-3);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--clr-border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ═══════════════════════
   UTILITY
═══════════════════════ */
.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

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

.text-bold {
  font-weight: 700;
}

.text-brand {
  color: var(--clr-brand);
}

.text-danger {
  color: var(--clr-danger);
}

.text-success {
  color: var(--clr-success);
}

.mt-0 {
  margin-top: 0;
}

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mt-3 {
  margin-top: 24px;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-1 {
  margin-bottom: 8px;
}

.mb-2 {
  margin-bottom: 16px;
}

.mb-3 {
  margin-bottom: 24px;
}

.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 {
  gap: 8px;
}

.gap-2 {
  gap: 16px;
}

.w-100 {
  width: 100%;
}

.hidden {
  display: none !important;
}

.ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bill total highlight */
.bill-total-row td {
  font-weight: 700;
  font-size: 15px;
  background: #f0f4ff;
}

.net-liability-display {
  background: linear-gradient(135deg, var(--clr-brand), #7c3aed);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-top: 20px;
  text-align: center;
}

.net-liability-display .amount {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
}

.net-liability-display .words {
  font-size: 13px;
  opacity: .8;
  margin-top: 6px;
}

/* ═══════════════════════
   RESPONSIVE MOBILE
═══════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
  }

  .main-content {
    padding: 16px 16px 32px;
  }

  .topbar {
    padding: 0 16px;
  }

  .form-row-2,
  .form-row-3,
  .form-row-4 {
    grid-template-columns: 1fr;
  }

  /* Table → stacked cards on mobile */
  .table-responsive-stack thead {
    display: none;
  }

  .table-responsive-stack tbody tr {
    display: block;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
  }

  .table-responsive-stack tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--clr-border);
    font-size: 13px;
  }

  .table-responsive-stack tbody td:last-child {
    border-bottom: none;
  }

  .table-responsive-stack tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--clr-text-2);
    font-size: 12px;
    margin-right: 10px;
    flex-shrink: 0;
  }

  .step-progress {
    gap: 0;
  }

  .step-line {
    width: 20px;
  }

  .filter-bar {
    flex-direction: column;
  }

  .filter-bar .form-group {
    width: 100%;
  }

  .page-header {
    flex-direction: column;
  }

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

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .login-box {
    padding: 28px 20px;
  }
}

/* ═══════════════════════
   LOADING SPINNER
═══════════════════════ */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ═══════════════════════
   PRINT-SAFE HELPERS
═══════════════════════ */
@media print {

  .sidebar,
  .topbar,
  .step-nav-bar,
  .btn {
    display: none !important;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}