/* ============================================================
   Garage Management System — Professional UI
   ============================================================ */
:root {
  /* Refined light — neutral, high-end */
  --primary: #1e3a5f;
  --primary-hover: #152a45;
  --primary-soft: #eef2f7;
  --accent: #2563eb;
  --secondary: #64748b;
  --success: #0f766e;
  --success-soft: #f0fdfa;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --info: #0369a1;
  --info-soft: #f0f9ff;
  --dark: #0f172a;
  --sidebar-bg: #0b1220;
  --sidebar-hover: rgba(255,255,255,.06);
  --sidebar-active: rgba(37,99,235,.22);
  --muted: #64748b;
  --border: #e8ecf1;
  --bg: #f4f6f9;
  --card: #ffffff;
  --elevated: #ffffff;
  --sidebar-w: 248px;
  --header-h: 56px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 16px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.08);
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --transition: 0.18s ease;
  color-scheme: light;
}

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

html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--dark);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--primary); }
img { max-width: 100%; height: auto; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #d0d5dd;
  z-index: 1040;
  display: flex; flex-direction: column;
  transition: transform var(--transition);
  overflow: hidden;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: var(--header-h);
}
.sidebar-brand .logo-mark {
  width: 32px; height: 32px; border-radius: 4px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 13px; flex-shrink: 0;
  letter-spacing: -0.02em;
}
.sidebar-brand .brand-text {
  font-weight: 650; font-size: 0.95rem; color: #fff;
  white-space: nowrap; letter-spacing: -0.01em;
}
.sidebar-brand .brand-sub {
  font-size: 10px; color: #98a2b3; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 500;
}

.sidebar-nav {
  flex: 1; overflow-y: auto; padding: 10px 10px 20px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent;
}
.nav-section {
  font-size: 10px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: #667085;
  padding: 14px 10px 6px; white-space: nowrap;
}
.sidebar .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: #98a2b3; font-weight: 500; font-size: 0.875rem;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.sidebar .nav-link i {
  font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; opacity: .9;
  transition: transform .2s ease, color .15s ease, opacity .15s ease;
  display: inline-flex; align-items: center; justify-content: center;
}
.sidebar .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar .nav-link:hover i { transform: scale(1.08); opacity: 1; }
.sidebar .nav-link.active { background: var(--sidebar-active); color: #fff; }
.sidebar .nav-link.active i { color: #93c5fd; }

.sidebar-footer {
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px; color: #667085;
}

.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; min-height: 100vh;
}

.topbar {
  position: sticky; top: 0; z-index: 1030;
  height: var(--header-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-weight: 600; font-size: 0.95rem; color: var(--dark); }
.menu-toggle {
  display: none; border: 1px solid var(--border); background: #fff; color: var(--dark);
  width: 36px; height: 36px; border-radius: var(--radius-sm); cursor: pointer;
  align-items: center; justify-content: center; font-size: 1.15rem;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: var(--radius);
  border: 1px solid var(--border); background: #fff;
  font-size: 0.8125rem; font-weight: 500; color: var(--dark);
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 4px;
  background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 11px;
}

.content { padding: 20px 24px 32px; flex: 1; }

/* ---------- Page header ---------- */
.page-header {
  display: flex; flex-wrap: wrap; align-items: flex-start;
  justify-content: space-between; gap: 12px; margin-bottom: 20px;
}
.page-header h1 {
  font-size: 1.35rem; font-weight: 650; letter-spacing: -0.02em;
  color: var(--dark); margin: 0;
}
.page-header .subtitle { color: var(--muted); font-size: 0.8125rem; margin-top: 2px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 0;
  overflow: hidden;
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  font-weight: 600;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--dark);
  letter-spacing: -0.01em;
}
.card-body { padding: 16px; }
.card-footer {
  background: transparent; border-top: 1px solid var(--border);
  padding: 10px 16px;
}

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  min-height: 112px;
  position: relative;
}
.stat-card:hover {
  border-color: #d8dee8;
  box-shadow: var(--shadow-md);
}
.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  margin-bottom: 14px;
  flex-shrink: 0;
  transition: transform .25s cubic-bezier(.34,1.2,.64,1), box-shadow .25s ease, background-color .2s ease;
}
.stat-card .stat-icon i {
  display: inline-block;
  transition: transform .25s cubic-bezier(.34,1.2,.64,1);
}
.stat-card:hover .stat-icon {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(15,23,42,.08);
}
.stat-card:hover .stat-icon i {
  transform: scale(1.12);
}
.stat-card .stat-label {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0;
}
.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  margin-top: 4px;
  color: var(--dark);
  line-height: 1.2;
}
/* Colour only on the icon — card surface stays clean white */
.stat-card.primary .stat-icon { background: #eff4ff; color: #2563eb; }
.stat-card.success .stat-icon { background: #ecfdf5; color: #059669; }
.stat-card.warning .stat-icon { background: #fffbeb; color: #d97706; }
.stat-card.danger .stat-icon { background: #fef2f2; color: #dc2626; }
.stat-card.info .stat-icon { background: #f0f9ff; color: #0284c7; }
.stat-card.dark .stat-icon { background: #f1f5f9; color: #334155; }
.stat-card.secondary .stat-icon { background: #f8fafc; color: #64748b; }


/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; margin-bottom: 0; border-collapse: collapse; }
.table thead th {
  background: #f8fafc; color: #475569; font-weight: 650;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: .05em;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 11px 14px; border-bottom: 1px solid #f1f5f9;
  vertical-align: middle; font-size: 0.875rem;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.table .fw-semibold { font-weight: 600; }

/* ---------- Forms ---------- */
.form-label {
  font-weight: 500; font-size: 0.8125rem; color: var(--dark);
  margin-bottom: 4px;
}
.form-control, .form-select {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: #fff; color: var(--dark);
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  outline: none;
}
.form-text { font-size: 0.75rem; color: var(--muted); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  border-radius: var(--radius-sm); font-weight: 550; font-size: 0.8125rem;
  padding: 7px 14px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all var(--transition); cursor: pointer; line-height: 1.4;
  text-align: center;
}
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-outline-primary { border-color: #b8c5d6; color: var(--primary); background: #fff; }
.btn-outline-primary:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.btn-outline-secondary { border-color: var(--border); color: var(--secondary); background: #fff; }
.btn-outline-secondary:hover { background: #f9fafb; color: var(--dark); }
.btn-outline-danger { border-color: #fecdca; color: var(--danger); background: #fff; }
.btn-outline-danger:hover { background: var(--danger-soft); }
.btn-outline-warning { border-color: #fedf89; color: var(--warning); background: #fff; }
.btn-outline-warning:hover { background: var(--warning-soft); }
.btn-outline-success { border-color: #a6f4c5; color: var(--success); background: #fff; }
.btn-outline-success:hover { background: var(--success-soft); }
.btn-outline-dark { border-color: var(--border); color: var(--dark); background: #fff; }
.btn-outline-dark:hover { background: #f9fafb; }
.btn-link { color: var(--accent); text-decoration: none; padding: 4px 8px; }

/* ---------- Badges ---------- */
.badge {
  font-weight: 600; font-size: 0.68rem; padding: 3px 7px;
  border-radius: 3px; letter-spacing: .02em; text-transform: capitalize;
}
.bg-success { background: var(--success-soft) !important; color: var(--success) !important; }
.bg-danger { background: var(--danger-soft) !important; color: var(--danger) !important; }
.bg-warning { background: var(--warning-soft) !important; color: var(--warning) !important; }
.bg-info { background: var(--info-soft) !important; color: var(--info) !important; }
.bg-secondary { background: #f2f4f7 !important; color: var(--secondary) !important; }
.bg-primary { background: var(--primary-soft) !important; color: var(--primary) !important; }
.bg-dark { background: #f2f4f7 !important; color: var(--dark) !important; }
.bg-light { background: #f9fafb !important; color: var(--dark) !important; }

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: 10px 14px; font-size: 0.875rem;
}
.alert-success { background: var(--success-soft); border-color: #a6f4c5; color: #054f31; }
.alert-danger { background: var(--danger-soft); border-color: #fecdca; color: #7a271a; }
.alert-info { background: var(--info-soft); border-color: #b2ddff; color: #0b4a6f; }

/* ---------- Quick actions ---------- */
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-action {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--border);
  color: var(--dark); font-weight: 500; font-size: 0.8125rem;
  transition: border-color var(--transition), background var(--transition);
  box-shadow: var(--shadow);
}
.quick-action:hover {
  border-color: #b8c5d6; color: var(--primary); background: #fafbfc;
}
.quick-action i {
  font-size: 1.05rem;
  color: var(--primary);
  display: inline-block;
  transition: transform .22s cubic-bezier(.34,1.2,.64,1), color .15s ease;
}
.quick-action:hover i {
  transform: scale(1.12) translateY(-1px);
}

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state i { font-size: 2rem; opacity: .35; margin-bottom: 10px; display: block; }

.pagination { gap: 4px; margin: 0; }
.page-link {
  border-radius: var(--radius-sm) !important; border: 1px solid var(--border);
  color: var(--dark); padding: 5px 10px; font-size: 0.8125rem;
}
.page-item.active .page-link {
  background: var(--primary); border-color: var(--primary); color: #fff;
}

/* ---------- Auth ---------- */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: #0f1c2e;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px; background: #fff;
  border-radius: 8px; padding: 32px 28px;
  box-shadow: var(--shadow-lg); border: 1px solid rgba(255,255,255,.06);
}
.auth-card .brand { text-align: center; margin-bottom: 24px; }
.auth-card .brand-mark {
  width: 40px; height: 40px; border-radius: 6px; margin: 0 auto 12px;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
}
.auth-card h1 { font-size: 1.2rem; font-weight: 650; margin-bottom: 4px; color: var(--dark); }
.auth-card .lead { color: var(--muted); font-size: 0.8125rem; }
.auth-card .form-control { padding: 10px 12px; border-radius: var(--radius-sm); }
.auth-card .btn-primary {
  width: 100%; padding: 10px; border-radius: var(--radius-sm);
  font-weight: 600; margin-top: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  text-align: center;
}
.auth-card form .btn { width: 100%; justify-content: center; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 0.8125rem; color: var(--muted); }

.list-group-item { border-color: var(--border); padding: 10px 14px; }
.list-group-flush .list-group-item { border-left: 0; border-right: 0; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(16,24,40,.45);
  z-index: 1035;
}
.sidebar-overlay.show { display: block; }

/* Search */
.topbar { gap: 12px; }
.topbar-search { flex: 1; max-width: 420px; margin: 0 auto; }
.search-box { position: relative; width: 100%; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 0.9rem; pointer-events: none;
}
.search-input {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 12px 7px 36px; font-size: 0.8125rem; background: #f9fafb;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.search-input:focus {
  outline: none; background: #fff; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.search-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 1060; max-height: 340px; overflow-y: auto;
}
.search-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  color: var(--dark); border-bottom: 1px solid var(--border);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: #f9fafb; color: var(--dark); }
.search-item i { color: var(--primary); font-size: 1rem; width: 20px; text-align: center; }
.search-item-body { display: flex; flex-direction: column; min-width: 0; }
.search-item-label { font-weight: 500; font-size: 0.8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item-type { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.search-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 0.8125rem; }

.pagination-info { font-size: 0.8125rem; }
.card-footer .pagination { margin: 0; }

/* Notifications */
.notif-wrap { position: relative; }
.notif-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #fff; color: var(--dark); display: inline-flex; align-items: center;
  justify-content: center; cursor: pointer; position: relative; font-size: 1.05rem;
}
.notif-btn:hover { background: #f9fafb; }
.notif-badge {
  position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px;
  padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 6px); width: 320px; max-width: 92vw;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 1080; overflow: hidden;
}
.notif-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.8125rem;
}
.notif-panel-body { max-height: 300px; overflow-y: auto; }
.notif-item {
  display: block; padding: 10px 12px; border-bottom: 1px solid var(--border);
  color: var(--dark);
}
.notif-item:hover { background: #f9fafb; color: var(--dark); }
.notif-item.unread { background: var(--primary-soft); }
.notif-item-title { font-weight: 600; font-size: 0.8125rem; }
.notif-item-msg { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.notif-item-time { font-size: 0.68rem; color: #98a2b3; margin-top: 3px; }
.notif-empty { padding: 24px 14px; text-align: center; color: var(--muted); font-size: 0.8125rem; }
.notif-panel-foot {
  padding: 8px 12px; text-align: center; border-top: 1px solid var(--border);
  font-size: 0.8125rem; font-weight: 500;
}

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-wrap { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 14px; }
  .page-header h1 { font-size: 1.15rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card .stat-value { font-size: 1.2rem; }
  .topbar { padding: 0 12px; }
  .user-chip .user-name { display: none; }
}
@media (max-width: 767.98px) {
  .topbar-search { max-width: none; order: 3; flex-basis: 100%; margin: 0; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; min-height: var(--header-h); }
}
@media (max-width: 575.98px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 24px 18px; }
  .table thead th, .table tbody td { padding: 8px 10px; font-size: 0.8125rem; }
  .page-actions .btn { width: 100%; justify-content: center; }
  .page-header { flex-direction: column; align-items: stretch; }
}

.text-muted { color: var(--muted) !important; }
.shadow-sm { box-shadow: var(--shadow) !important; }
.border-0 { border: 0 !important; }
.bg-white { background: #fff !important; }



/* ============================================================
   CSS Grid system — executive layouts
   ============================================================ */

/* App content stack */
.content-stack {
  display: grid;
  gap: 1.25rem;
}

/* Auto-fit card grids */
.grid {
  display: grid;
  gap: 1rem;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-gap-sm { gap: 0.75rem; }
.grid-gap-lg { gap: 1.5rem; }

/* Dashboard KPI strip — responsive auto-fit */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0;
}

/* Dashboard main board: primary chart + side panel */
.dash-board {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}
.dash-board > * { min-width: 0; }

/* Two equal panels */
.dash-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
}
.dash-split > * { min-width: 0; }

/* Shortcuts + navigate */
.dash-lower {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.dash-lower > * { min-width: 0; }

/* Form field grids */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
}
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem 1.25rem;
}
.form-grid .full,
.form-grid-3 .full {
  grid-column: 1 / -1;
}

/* Page header as grid */
.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem 1rem;
  align-items: center;
  margin-bottom: 1.25rem;
}
.page-header .page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Topbar as grid */
.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  height: var(--header-h);
  padding: 0 1.25rem;
}
.topbar-left { display: flex; align-items: center; gap: 0.5rem; }
.topbar-search { justify-self: stretch; max-width: 28rem; width: 100%; margin: 0 auto; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-self: end;
}

/* Quick actions grid */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 0.5rem;
}

/* Card body metric pairs */
.kv-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  align-items: baseline;
}
.kv-grid .k { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: .04em; }
.kv-grid .v { font-weight: 600; }

@media (max-width: 991.98px) {
  .dash-board,
  .dash-lower,
  .dash-split {
    grid-template-columns: 1fr;
  }
  .form-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3, .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 767.98px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    height: auto;
    min-height: var(--header-h);
    padding: 0.5rem 0.75rem;
  }
  .topbar-search {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: none;
    justify-self: stretch;
  }
  .page-header {
    grid-template-columns: 1fr;
  }
  .page-header .page-actions {
    justify-content: stretch;
  }
  .page-header .page-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
  .form-grid,
  .form-grid-3,
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 399.98px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}




/* ============================================================
   Light mode — premium controls (restrained)
   ============================================================ */
html:not([data-theme="dark"]) .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(37,99,235,.18);
  font-weight: 600;
}
html:not([data-theme="dark"]) .btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 2px 6px rgba(37,99,235,.22);
}
html:not([data-theme="dark"]) .btn-outline-primary {
  color: var(--accent);
  border-color: #c7d7f5;
  background: #fff;
}
html:not([data-theme="dark"]) .btn-outline-primary:hover {
  background: #f5f8ff;
  border-color: var(--accent);
  color: var(--primary-hover);
}
html:not([data-theme="dark"]) .btn-success {
  background: var(--success);
  border-color: var(--success);
}
html:not([data-theme="dark"]) .user-chip {
  background: #fff;
  border-color: var(--border);
}
html:not([data-theme="dark"]) .user-avatar {
  background: var(--primary);
}
html:not([data-theme="dark"]) .sidebar {
  box-shadow: 1px 0 0 rgba(15,23,42,.06);
}
html:not([data-theme="dark"]) .sidebar .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
}
html:not([data-theme="dark"]) .sidebar .nav-link.active i {
  color: #93c5fd;
}
html:not([data-theme="dark"]) .content {
  padding: 24px 28px 40px;
}
html:not([data-theme="dark"]) .page-header h1 {
  color: var(--dark);
  font-weight: 650;
  letter-spacing: -0.025em;
}
html:not([data-theme="dark"]) .list-group-item {
  border-color: #eef1f5;
}
html:not([data-theme="dark"]) .list-group-item:hover {
  background: #f8fafc;
}
html:not([data-theme="dark"]) .badge.bg-secondary-subtle,
html:not([data-theme="dark"]) .bg-secondary-subtle {
  background: #f1f5f9 !important;
  color: #475569 !important;
}
html:not([data-theme="dark"]) .badge.bg-primary-subtle,
html:not([data-theme="dark"]) .bg-primary-subtle {
  background: #eff4ff !important;
  color: #1d4ed8 !important;
}
html:not([data-theme="dark"]) .badge.bg-success-subtle {
  background: #ecfdf5 !important;
  color: #047857 !important;
}
html:not([data-theme="dark"]) .badge.bg-danger-subtle {
  background: #fef2f2 !important;
  color: #b91c1c !important;
}
html:not([data-theme="dark"]) .badge.bg-warning-subtle {
  background: #fffbeb !important;
  color: #b45309 !important;
}
html:not([data-theme="dark"]) .form-control:focus,
html:not([data-theme="dark"]) .form-select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
html:not([data-theme="dark"]) .quick-action {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 500;
  color: var(--dark);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
html:not([data-theme="dark"]) .quick-action:hover {
  border-color: #c7d7f5;
  background: #fafbff;
  box-shadow: var(--shadow);
  color: var(--primary);
}
html:not([data-theme="dark"]) .quick-action i {
  color: var(--accent);
}
html:not([data-theme="dark"]) .alert-success {
  background: #f0fdfa; border-color: #99f6e4; color: #115e59;
}
html:not([data-theme="dark"]) .alert-danger {
  background: #fef2f2; border-color: #fecaca; color: #991b1b;
}
html:not([data-theme="dark"]) .alert-info {
  background: #f0f9ff; border-color: #bae6fd; color: #075985;
}
html:not([data-theme="dark"]) .alert-warning {
  background: #fffbeb; border-color: #fde68a; color: #92400e;
}
html:not([data-theme="dark"]) .table thead th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
html:not([data-theme="dark"]) .table tbody tr:hover {
  background: #f8fafc;
}
html:not([data-theme="dark"]) .chart-box {
  background: transparent;
}


/* ============================================================
   Subtle icon & card motion
   ============================================================ */
@keyframes gm-icon-in {
  from { opacity: 0; transform: translateY(6px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes gm-soft-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

.stat-grid .stat-card {
  animation: gm-icon-in .45s ease both;
}
.stat-grid .stat-card:nth-child(1) { animation-delay: .02s; }
.stat-grid .stat-card:nth-child(2) { animation-delay: .05s; }
.stat-grid .stat-card:nth-child(3) { animation-delay: .08s; }
.stat-grid .stat-card:nth-child(4) { animation-delay: .11s; }
.stat-grid .stat-card:nth-child(5) { animation-delay: .14s; }
.stat-grid .stat-card:nth-child(6) { animation-delay: .17s; }
.stat-grid .stat-card:nth-child(7) { animation-delay: .2s; }
.stat-grid .stat-card:nth-child(8) { animation-delay: .23s; }

/* Topbar controls */
.topbar .btn i,
.menu-toggle i,
#themeToggle i {
  display: inline-block;
  transition: transform .2s ease;
}
.topbar .btn:hover i,
.menu-toggle:hover i,
#themeToggle:hover i {
  transform: scale(1.1);
}

/* Page action icons */
.page-actions .btn i {
  display: inline-block;
  transition: transform .2s ease;
}
.page-actions .btn:hover i {
  transform: translateX(-1px) scale(1.06);
}
.page-actions .btn.btn-primary:hover i {
  transform: scale(1.08);
}

/* List / empty state icons if present */
.stat-icon i,
.nav-link i,
.quick-action i {
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .stat-grid .stat-card,
  .stat-card .stat-icon,
  .stat-card .stat-icon i,
  .sidebar .nav-link i,
  .quick-action i,
  .topbar .btn i,
  .page-actions .btn i {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}

/* ============================================================
   Dark mode — refined enterprise surfaces
   ============================================================ */
[data-theme="dark"] {
  --primary: #4f8cff;
  --primary-hover: #6ba0ff;
  --primary-soft: rgba(79,140,255,.14);
  --accent: #4f8cff;
  --secondary: #9aa4b2;
  --success: #3ecf8e;
  --success-soft: rgba(62,207,142,.12);
  --danger: #f07178;
  --danger-soft: rgba(240,113,120,.12);
  --warning: #e6b450;
  --warning-soft: rgba(230,180,80,.12);
  --info: #5ccfe6;
  --info-soft: rgba(92,207,230,.12);
  --text: #e7ecf3;
  --text-secondary: #9aa4b2;
  --dark: #e7ecf3;
  --muted: #9aa4b2;
  --border: #2a3341;
  --bg: #12151c;
  --card: #1a1f29;
  --elevated: #222833;
  --sidebar-bg: #0e1117;
  --sidebar-hover: rgba(255,255,255,.05);
  --sidebar-active: rgba(79,140,255,.16);
  --shadow: 0 1px 2px rgba(0,0,0,.45);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 28px rgba(0,0,0,.5);
  color-scheme: dark;
  /* Align Bootstrap 5 utilities with dark surfaces */
  --bs-body-color: #e7ecf3;
  --bs-body-bg: #12151c;
  --bs-secondary-color: #9aa4b2;
  --bs-tertiary-color: #8b95a5;
  --bs-emphasis-color: #f3f6fb;
  --bs-border-color: #2a3341;
  --bs-card-bg: #1a1f29;
  --bs-card-color: #e7ecf3;
  --bs-card-border-color: #2a3341;
  --bs-list-group-bg: #1a1f29;
  --bs-list-group-color: #e7ecf3;
  --bs-list-group-border-color: #2a3341;
  --bs-heading-color: #e7ecf3;
  --bs-link-color: #7aabff;
  --bs-link-hover-color: #9ec0ff;
  --bs-secondary-bg: #222833;
  --bs-tertiary-bg: #1a1f29;
  --bs-body-color-rgb: 231, 236, 243;
  --bs-body-bg-rgb: 18, 21, 28;
}

[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

/* Shell */
[data-theme="dark"] .sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid #1c212b;
}
[data-theme="dark"] .sidebar .nav-link { color: #8b95a5; }
[data-theme="dark"] .sidebar .nav-link:hover { background: var(--sidebar-hover); color: #e7ecf3; }
[data-theme="dark"] .sidebar .nav-link.active { background: var(--sidebar-active); color: #e7ecf3; }
[data-theme="dark"] .sidebar .nav-link.active i { color: #4f8cff; }
[data-theme="dark"] .nav-section { color: #5c6573; }
[data-theme="dark"] .sidebar-brand { border-bottom-color: #1c212b; }
[data-theme="dark"] .sidebar-footer { border-top-color: #1c212b; color: #5c6573; }
[data-theme="dark"] .sidebar-brand .logo-mark { background: #4f8cff; }

[data-theme="dark"] .main-wrap { background: var(--bg); }
[data-theme="dark"] .topbar {
  background: #161b24;
  border-bottom: 1px solid var(--border);
  backdrop-filter: none;
}
[data-theme="dark"] .topbar-title { color: var(--text); }
[data-theme="dark"] .menu-toggle,
[data-theme="dark"] .theme-btn,
[data-theme="dark"] .notif-btn {
  background: var(--elevated);
  border-color: var(--border);
  color: var(--text-secondary);
}
[data-theme="dark"] .menu-toggle:hover,
[data-theme="dark"] .theme-btn:hover,
[data-theme="dark"] .notif-btn:hover {
  background: #2a3341;
  color: var(--text);
}
[data-theme="dark"] .user-chip {
  background: var(--elevated);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .user-avatar { background: #3a4a66; color: #fff; }

/* Content */
[data-theme="dark"] .page-header h1 { color: var(--text); }
[data-theme="dark"] .page-header .subtitle { color: var(--muted); }
[data-theme="dark"] .content { color: var(--text); }

/* Cards & tables */
[data-theme="dark"] .card {
  background: var(--card);
  border-color: var(--border);
  box-shadow: none;
}
[data-theme="dark"] .card-header {
  background: transparent;
  border-bottom-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .card-footer {
  background: transparent;
  border-top-color: var(--border);
}
[data-theme="dark"] .table thead th {
  background: var(--elevated);
  color: var(--muted);
  border-bottom-color: var(--border);
}
[data-theme="dark"] .table tbody td {
  border-bottom-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .table tbody tr:hover { background: rgba(255,255,255,.025); }

/* Forms */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] textarea.form-control {
  background: var(--elevated) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  border-color: #4f8cff !important;
  box-shadow: 0 0 0 3px rgba(79,140,255,.18) !important;
  background: var(--elevated) !important;
}
[data-theme="dark"] .form-control::placeholder { color: #5c6573; }
[data-theme="dark"] .form-label { color: var(--text-secondary); }
[data-theme="dark"] .form-text { color: var(--muted); }
[data-theme="dark"] .form-check-input {
  background-color: var(--elevated);
  border-color: var(--border);
}
[data-theme="dark"] .form-check-input:checked {
  background-color: #4f8cff;
  border-color: #4f8cff;
}

/* Buttons */
[data-theme="dark"] .btn-primary {
  background: #3d7aef;
  border-color: #3d7aef;
  color: #fff;
}
[data-theme="dark"] .btn-primary:hover {
  background: #4f8cff;
  border-color: #4f8cff;
  color: #fff;
}
[data-theme="dark"] .btn-outline-primary,
[data-theme="dark"] .btn-outline-secondary,
[data-theme="dark"] .btn-outline-dark,
[data-theme="dark"] .btn-outline-success,
[data-theme="dark"] .btn-outline-danger,
[data-theme="dark"] .btn-outline-warning {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}
[data-theme="dark"] .btn-outline-primary:hover,
[data-theme="dark"] .btn-outline-secondary:hover,
[data-theme="dark"] .btn-outline-dark:hover {
  background: var(--elevated);
  border-color: #3a4454;
  color: var(--text);
}
[data-theme="dark"] .btn-outline-danger:hover {
  background: var(--danger-soft);
  border-color: #5c2a2e;
  color: var(--danger);
}
[data-theme="dark"] .btn-outline-success:hover {
  background: var(--success-soft);
  border-color: #1e4d38;
  color: var(--success);
}
[data-theme="dark"] .btn-link { color: var(--accent); }

/* Badges — muted, not neon */
[data-theme="dark"] .badge.bg-success,
[data-theme="dark"] .bg-success {
  background: rgba(62,207,142,.15) !important;
  color: #6ed9a8 !important;
}
[data-theme="dark"] .badge.bg-danger,
[data-theme="dark"] .bg-danger {
  background: rgba(240,113,120,.15) !important;
  color: #f5a0a5 !important;
}
[data-theme="dark"] .badge.bg-warning,
[data-theme="dark"] .bg-warning {
  background: rgba(230,180,80,.15) !important;
  color: #e8c878 !important;
}
[data-theme="dark"] .badge.bg-info,
[data-theme="dark"] .bg-info {
  background: rgba(92,207,230,.15) !important;
  color: #8ad8e8 !important;
}
[data-theme="dark"] .badge.bg-secondary,
[data-theme="dark"] .bg-secondary,
[data-theme="dark"] .badge.bg-dark,
[data-theme="dark"] .bg-dark,
[data-theme="dark"] .badge.bg-primary,
[data-theme="dark"] .bg-primary {
  background: rgba(255,255,255,.08) !important;
  color: #c5cdd8 !important;
}
[data-theme="dark"] .bg-light {
  background: var(--elevated) !important;
  color: var(--text) !important;
}

/* Stats & shortcuts */
[data-theme="dark"] .stat-card {
  background: var(--card);
  border-color: var(--border);
  box-shadow: none;
}
[data-theme="dark"] .stat-card:hover { border-color: #3a4454; }
[data-theme="dark"] .stat-card .stat-value { color: var(--text); }
[data-theme="dark"] .stat-card .stat-label { color: var(--muted); }
[data-theme="dark"] .stat-card.primary .stat-icon { background: var(--primary-soft); color: #7aabff; }
[data-theme="dark"] .stat-card.success .stat-icon { background: var(--success-soft); color: #6ed9a8; }
[data-theme="dark"] .stat-card.warning .stat-icon { background: var(--warning-soft); color: #e8c878; }
[data-theme="dark"] .stat-card.danger .stat-icon { background: var(--danger-soft); color: #f5a0a5; }
[data-theme="dark"] .stat-card.info .stat-icon { background: var(--info-soft); color: #8ad8e8; }
[data-theme="dark"] .stat-card.dark .stat-icon { background: rgba(255,255,255,.06); color: #c5cdd8; }

[data-theme="dark"] .quick-action {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
  box-shadow: none;
}
[data-theme="dark"] .quick-action:hover {
  background: var(--elevated);
  border-color: #3a4454;
  color: var(--text);
}
[data-theme="dark"] .quick-action i { color: #7aabff; }

/* Lists, search, notif */
[data-theme="dark"] .list-group-item {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .list-group-item-action:hover,
[data-theme="dark"] .list-group-item-action:focus {
  background: var(--elevated);
  color: var(--text);
}
[data-theme="dark"] .search-input {
  background: var(--elevated);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .search-input:focus {
  background: var(--elevated);
  border-color: #4f8cff;
  box-shadow: 0 0 0 3px rgba(79,140,255,.18);
}
[data-theme="dark"] .search-dropdown {
  background: var(--card);
  border-color: var(--border);
  box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .search-item {
  color: var(--text);
  border-bottom-color: var(--border);
}
[data-theme="dark"] .search-item:hover { background: var(--elevated); }
[data-theme="dark"] .search-item i { color: #7aabff; }
[data-theme="dark"] .search-item-type,
[data-theme="dark"] .search-empty { color: var(--muted); }

[data-theme="dark"] .notif-panel {
  background: var(--card);
  border-color: var(--border);
  box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .notif-panel-head,
[data-theme="dark"] .notif-panel-foot {
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .notif-item {
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .notif-item:hover { background: var(--elevated); }
[data-theme="dark"] .notif-item.unread { background: rgba(79,140,255,.1); }
[data-theme="dark"] .notif-item-msg,
[data-theme="dark"] .notif-item-time,
[data-theme="dark"] .notif-empty { color: var(--muted); }

/* Pagination & alerts */
[data-theme="dark"] .page-link {
  background: var(--card);
  border-color: var(--border);
  color: var(--text-secondary);
}
[data-theme="dark"] .page-link:hover {
  background: var(--elevated);
  color: var(--text);
}
[data-theme="dark"] .page-item.active .page-link {
  background: #3d7aef;
  border-color: #3d7aef;
  color: #fff;
}
[data-theme="dark"] .page-item.disabled .page-link {
  background: var(--card);
  color: #5c6573;
}
[data-theme="dark"] .alert-success {
  background: var(--success-soft);
  border-color: #2a5a44;
  color: #9ae0c0;
}
[data-theme="dark"] .alert-danger {
  background: var(--danger-soft);
  border-color: #5c2a2e;
  color: #f5b0b4;
}
[data-theme="dark"] .alert-info {
  background: var(--info-soft);
  border-color: #2a5560;
  color: #a0e0ee;
}

/* Auth */
[data-theme="dark"] .auth-page { background: #0e1117; }
[data-theme="dark"] .auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .auth-card h1 { color: var(--text); }
[data-theme="dark"] .auth-card .lead,
[data-theme="dark"] .auth-footer { color: var(--muted); }
[data-theme="dark"] .auth-card .brand-mark { background: #3d7aef; }

/* Bootstrap utility overrides that break dark UI */
[data-theme="dark"] .bg-white { background: var(--card) !important; }
[data-theme="dark"] .text-dark { color: var(--text) !important; }
[data-theme="dark"] .text-muted { color: var(--muted) !important; }
[data-theme="dark"] .border,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-start,
[data-theme="dark"] .border-end { border-color: var(--border) !important; }
[data-theme="dark"] .shadow-sm { box-shadow: none !important; }
[data-theme="dark"] hr { border-color: var(--border); opacity: 1; }
[data-theme="dark"] .dropdown-menu {
  background: var(--card);
  border-color: var(--border);
}

/* File inputs + import dropdown (light & dark) */
.form-control[type="file"] {
  padding: 0.35rem 0.5rem;
  line-height: 1.4;
}
.form-control[type="file"]::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.35rem 0.75rem;
  border: 0;
  border-radius: 6px;
  background: #eef2f6;
  color: #344054;
  font-weight: 550;
  font-size: 0.8125rem;
  cursor: pointer;
}
.form-control[type="file"]::-webkit-file-upload-button {
  margin-right: 0.75rem;
  padding: 0.35rem 0.75rem;
  border: 0;
  border-radius: 6px;
  background: #eef2f6;
  color: #344054;
  font-weight: 550;
  font-size: 0.8125rem;
  cursor: pointer;
}

.ie-import-menu {
  min-width: 280px;
  padding: 0.85rem 1rem !important;
}
.ie-import-menu .dropdown-item {
  border-radius: 6px;
  color: inherit;
}
.ie-import-menu .dropdown-item:hover,
.ie-import-menu .dropdown-item:focus {
  background: var(--primary-soft, #eef4ff);
  color: inherit;
}

[data-theme="dark"] .dropdown-menu {
  background: var(--elevated) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  box-shadow: 0 12px 28px rgba(0,0,0,.45) !important;
}
[data-theme="dark"] .dropdown-item {
  color: var(--text) !important;
}
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
  background: rgba(79,140,255,.14) !important;
  color: #fff !important;
}
[data-theme="dark"] .dropdown-divider {
  border-color: var(--border);
}

[data-theme="dark"] .form-control[type="file"] {
  background: var(--card) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  color-scheme: dark;
}
[data-theme="dark"] .form-control[type="file"]::file-selector-button {
  background: #2a3341 !important;
  color: #e7ecf3 !important;
}
[data-theme="dark"] .form-control[type="file"]::-webkit-file-upload-button {
  background: #2a3341 !important;
  color: #e7ecf3 !important;
}
[data-theme="dark"] .form-control[type="file"]:hover::file-selector-button,
[data-theme="dark"] .form-control[type="file"]:hover::-webkit-file-upload-button {
  background: #343e4f !important;
}

[data-theme="dark"] .modal-content {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { border-color: var(--border); }

/* Theme toggle base (light) */
.theme-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff; color: #344054;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.05rem;
}
.theme-btn:hover { background: #f9fafb; }


/* Bootstrap 5 table variables + forced row surfaces */
[data-theme="dark"] .table {
  --bs-table-bg: var(--card);
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-striped-bg: var(--elevated);
  --bs-table-striped-color: var(--text);
  --bs-table-hover-bg: rgba(255,255,255,.04);
  --bs-table-hover-color: var(--text);
  --bs-table-active-bg: rgba(79,140,255,.1);
  --bs-table-active-color: var(--text);
  color: var(--text);
  background-color: var(--card);
  border-color: var(--border);
}
[data-theme="dark"] .table > :not(caption) > * > * {
  background-color: var(--card) !important;
  color: var(--text) !important;
  border-bottom-color: var(--border) !important;
  box-shadow: none !important;
}
[data-theme="dark"] .table thead th,
[data-theme="dark"] .table > thead > tr > th {
  background-color: var(--elevated) !important;
  color: var(--muted) !important;
  border-bottom-color: var(--border) !important;
}
[data-theme="dark"] .table-hover > tbody > tr:hover > * {
  background-color: rgba(255,255,255,.04) !important;
  color: var(--text) !important;
}
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: var(--elevated) !important;
  color: var(--text) !important;
}
[data-theme="dark"] .table-responsive,
[data-theme="dark"] .table-wrap {
  background: var(--card);
}
[data-theme="dark"] .card .table { margin-bottom: 0; }

/* Neutral surface helper — use instead of bg-white */
.surface { background: var(--card, #fff); }
[data-theme="dark"] .surface { background: var(--card) !important; }
[data-theme="dark"] .card-header.bg-white,
[data-theme="dark"] .card-footer.bg-white,
[data-theme="dark"] .bg-white {
  background: var(--card) !important;
  color: var(--text) !important;
}

/* Dashboard charts responsive */
.chart-box { position: relative; width: 100%; min-height: 220px; }
.chart-box.chart-box-lg { min-height: 260px; }
@media (max-width: 575.98px) {
  .chart-box, .chart-box.chart-box-lg { min-height: 200px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-card .stat-value { font-size: 1.15rem; }
  .stat-card .stat-icon { width: 30px; height: 30px; font-size: 0.95rem; margin-bottom: 8px; }
  .quick-actions { gap: 6px; }
  .quick-action { flex: 1 1 calc(50% - 6px); justify-content: center; padding: 10px 8px; font-size: 0.75rem; }
}
@media (max-width: 991.98px) {
  .dash-charts .col-lg-8,
  .dash-charts .col-lg-4,
  .dash-charts .col-lg-6 { margin-bottom: 0; }
}


/* Executive page title — single source of truth */
.page-header {
  margin-bottom: 1.25rem;
  padding-bottom: 0;
  border-bottom: none;
}
.page-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--dark);
}
[data-theme="dark"] .page-header h1 { color: var(--text); }
.page-header .subtitle {
  margin-top: 0.2rem;
  font-size: 0.8125rem;
  color: var(--muted);
  max-width: 42rem;
}
.topbar-left { min-width: 0; }
@media (min-width: 992px) {
  .topbar-left:empty { display: none; }
}

/* Permission picker */
.perm-group { padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }
.perm-group:last-child { border-bottom: 0; padding-bottom: 0; }
.perm-group-title {
  font-size: 0.7rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); margin-bottom: 0.5rem;
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.4rem 0.75rem;
}
.perm-item {
  display: flex; align-items: flex-start; gap: 0.5rem;
  padding: 0.5rem 0.65rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card);
  cursor: pointer; margin: 0;
}
.perm-item:hover { border-color: #b8c5d6; }
.perm-item .form-check-input { margin-top: 0.2rem; flex-shrink: 0; }
.perm-name { display: block; font-weight: 550; font-size: 0.8125rem; color: var(--dark); }
.perm-desc { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 0.1rem; }
[data-theme="dark"] .perm-item { background: var(--elevated); border-color: var(--border); }
[data-theme="dark"] .perm-item:hover { border-color: #3a4454; }
[data-theme="dark"] .perm-name { color: var(--text); }

/* Definition lists on document views */
.doc-meta {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 0.5rem 1rem;
  margin: 0;
}
.doc-meta dt {
  margin: 0; color: var(--muted); font-weight: 500; font-size: 0.8125rem;
}
.doc-meta dd {
  margin: 0; color: var(--dark); font-size: 0.875rem;
}
[data-theme="dark"] .doc-meta dd { color: var(--text); }

/* Bootstrap dl.row leftovers on views */
[data-theme="dark"] dl.row dt,
[data-theme="dark"] .col-form-label {
  color: var(--muted) !important;
}
[data-theme="dark"] dl.row dd {
  color: var(--text) !important;
}
[data-theme="dark"] .row > [class*="col-"] {
  color: inherit;
}
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 {
  color: var(--text);
}
[data-theme="dark"] .card .table thead th { background: var(--elevated) !important; }
[data-theme="dark"] a:not(.btn):not(.nav-link):not(.list-group-item):not(.stat-card):not(.quick-action):not(.search-item):not(.notif-item) {
  color: var(--accent);
}
[data-theme="dark"] .subtitle { color: var(--muted); }
[data-theme="dark"] .badge { border: 0; }

/* Totals block on document views */
.doc-totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1.5rem;
  max-width: 280px;
  margin-left: auto;
  font-size: 0.875rem;
}
.doc-totals .grand {
  font-weight: 700; font-size: 1rem;
  border-top: 1px solid var(--border); padding-top: 0.4rem; margin-top: 0.2rem;
}
[data-theme="dark"] .doc-totals .grand { border-top-color: var(--border); }

/* Compact permission matrix */
.perm-matrix thead th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.perm-matrix tbody td {
  vertical-align: middle;
  padding: 0.45rem 0.5rem;
}
.perm-matrix .form-check-input {
  margin: 0;
  cursor: pointer;
}
[data-theme="dark"] .perm-matrix thead th {
  background: var(--elevated) !important;
}

/* Drag and drop line items */
.dnd-handle {
  cursor: grab;
  color: var(--muted);
  text-align: center;
  vertical-align: middle !important;
  width: 36px;
  user-select: none;
}
.dnd-handle:active { cursor: grabbing; }
.dnd-handle .bi { font-size: 1.1rem; }
tr.dnd-dragging {
  opacity: 0.55;
  background: var(--primary-soft, #e8eef5) !important;
}
tr.dnd-over {
  box-shadow: inset 0 2px 0 0 var(--accent, #2563eb);
}
[data-theme="dark"] tr.dnd-dragging {
  background: rgba(79,140,255,.12) !important;
}
[data-theme="dark"] .dnd-handle { color: var(--muted); }

/* ---------- Combobox (line items editor) ---------- */
.cb-wrap { position: relative; }
.cb-list {
  /* position/size applied by JS (fixed, under input) */
  z-index: 2000;
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #ffffff;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.16), 0 0 0 1px rgba(16,24,40,.04);
  padding: 6px 0;
  color: #101828;
}
.cb-option {
  padding: 9px 14px;
  cursor: pointer;
  color: #101828;
  border: 0;
  border-left: 3px solid transparent;
}
.cb-option:hover,
.cb-option.active {
  background: #eef4ff;
  border-left-color: #3d7aef;
}
.cb-opt-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: #101828;
  line-height: 1.35;
}
.cb-opt-meta {
  font-size: 0.75rem;
  color: #475467;
  margin-top: 2px;
  line-height: 1.3;
}
.cb-option:hover .cb-opt-title,
.cb-option.active .cb-opt-title {
  color: #1849a9;
}
.cb-option:hover .cb-opt-meta,
.cb-option.active .cb-opt-meta {
  color: #344054;
}
.cb-empty {
  padding: 12px 14px;
  color: #667085;
  font-size: 0.8125rem;
}

[data-theme="dark"] .cb-list {
  background: #1e2533 !important;
  border-color: #3a4556 !important;
  box-shadow: 0 14px 36px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.04) !important;
  color: #e7ecf3;
}
[data-theme="dark"] .cb-option {
  color: #e7ecf3;
  border-left-color: transparent;
}
[data-theme="dark"] .cb-option:hover,
[data-theme="dark"] .cb-option.active {
  background: rgba(79, 140, 255, 0.22);
  border-left-color: #6ba0ff;
}
[data-theme="dark"] .cb-opt-title {
  color: #f2f5fa !important;
  font-weight: 600;
}
[data-theme="dark"] .cb-opt-meta {
  color: #a8b3c4 !important;
}
[data-theme="dark"] .cb-option:hover .cb-opt-title,
[data-theme="dark"] .cb-option.active .cb-opt-title {
  color: #ffffff !important;
}
[data-theme="dark"] .cb-option:hover .cb-opt-meta,
[data-theme="dark"] .cb-option.active .cb-opt-meta {
  color: #c5cdd9 !important;
}
[data-theme="dark"] .cb-empty {
  color: #8b95a5 !important;
}

/* Bootstrap body/surface utilities under custom data-theme */
[data-theme="dark"] .bg-body,
[data-theme="dark"] .bg-body-tertiary,
[data-theme="dark"] .bg-body-secondary,
[data-theme="dark"] .bg-light {
  background-color: var(--elevated) !important;
  color: var(--text) !important;
}
[data-theme="dark"] .bg-white { background-color: var(--card) !important; }

/* Line items tables in dark mode */
[data-theme="dark"] .line-items-table,
[data-theme="dark"] .line-items-table thead th,
[data-theme="dark"] .line-items-table tbody td {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
[data-theme="dark"] .line-items-table thead th {
  color: var(--muted);
  background: var(--elevated);
}
[data-theme="dark"] .line-items-table .form-control,
[data-theme="dark"] .line-items-table .form-select,
[data-theme="dark"] .line-items-table .cb-input {
  background: var(--elevated) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
[data-theme="dark"] .line-items-table .form-control::placeholder,
[data-theme="dark"] .line-items-table .cb-input::placeholder {
  color: #5c6573 !important;
}
[data-theme="dark"] .line-items-table .form-control:focus,
[data-theme="dark"] .line-items-table .cb-input:focus {
  border-color: #4f8cff !important;
  box-shadow: 0 0 0 3px rgba(79,140,255,.18) !important;
}
[data-theme="dark"] tr.dnd-over {
  box-shadow: inset 0 2px 0 0 #4f8cff;
}

/* list-group / table leftovers that stay light in dark mode */
[data-theme="dark"] .list-group-item {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}
[data-theme="dark"] .list-group-item-action:hover,
[data-theme="dark"] .list-group-item-action:focus {
  background: var(--elevated);
  color: var(--text);
}
[data-theme="dark"] .table-light,
[data-theme="dark"] .table-secondary {
  --bs-table-bg: var(--elevated);
  --bs-table-color: var(--text);
  background: var(--elevated) !important;
  color: var(--text) !important;
}
[data-theme="dark"] .accordion-item {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .accordion-button {
  background: var(--elevated);
  color: var(--text);
}
[data-theme="dark"] .accordion-button:not(.collapsed) {
  background: var(--elevated);
  color: var(--text);
  box-shadow: none;
}
[data-theme="dark"] .accordion-body {
  background: var(--card);
  color: var(--text);
}
[data-theme="dark"] .popover {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .popover-header {
  background: var(--elevated);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .popover-body { color: var(--text); }
[data-theme="dark"] .tooltip-inner {
  background: #0e1117;
  color: #e7ecf3;
}


/* File drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  background: var(--card, #fff);
  color: var(--muted);
  transition: border-color .15s ease, background .15s ease;
  cursor: pointer;
}
.drop-zone:hover,
.drop-zone.drop-zone-active {
  border-color: var(--accent, #2563eb);
  background: var(--primary-soft, #e8eef5);
  color: var(--dark);
}
[data-theme="dark"] .drop-zone {
  background: var(--card);
  border-color: var(--border);
}
[data-theme="dark"] .drop-zone:hover,
[data-theme="dark"] .drop-zone.drop-zone-active {
  background: var(--primary-soft);
  border-color: var(--accent);
  color: var(--text);
}
.drop-zone .drop-zone-icon { font-size: 1.75rem; margin-bottom: 0.35rem; display: block; }
.drop-zone input[type="file"] { display: none; }


/* ============================================================
   Mobile UX improvements
   ============================================================ */

/* Touch-friendly targets */
@media (max-width: 991.98px) {
  .sidebar-overlay {
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .sidebar {
    width: min(var(--sidebar-w), 88vw);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .sidebar .nav-link {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.9375rem;
  }
  .menu-toggle {
    width: 44px;
    height: 44px;
  }
  .topbar {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .content {
    padding: 12px max(12px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .btn, .form-control, .form-select {
    min-height: 42px;
  }
  .btn-sm {
    min-height: 36px;
    padding-left: 12px;
    padding-right: 12px;
  }
  .form-control, .form-select {
    font-size: 16px; /* prevent iOS zoom on focus */
  }
  .form-control-sm, .form-select-sm {
    font-size: 16px;
    min-height: 40px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

@media (max-width: 767.98px) {
  /* Sticky form actions */
  .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin-left: -12px;
    margin-right: -12px;
    margin-bottom: 0 !important;
    padding: 12px max(12px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(15,23,42,.06);
    flex-wrap: wrap;
  }
  [data-theme="dark"] .form-actions {
    background: rgba(26,31,41,.94);
    border-top-color: var(--border);
  }
  .form-actions .btn {
    flex: 1 1 auto;
    min-width: calc(50% - 6px);
    justify-content: center;
  }
  .form-actions .btn-primary {
    flex: 1 1 100%;
    order: -1;
  }

  /* Tables: horizontal scroll cue */
  .table-wrap {
    margin: 0 -2px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap::after {
    content: "";
    display: block;
    height: 0;
  }
  .table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
  }

  /* Line items: prioritise item + qty + total */
  .line-items-table {
    min-width: 520px;
  }
  .line-items-table .form-control,
  .line-items-table .form-select {
    min-width: 0;
  }
  .line-items-table .cb-wrap {
    min-width: 160px;
  }
  .line-items-table .cb-list {
    max-height: 180px;
    font-size: 0.875rem;
  }
  .line-items-totals .card-body {
    justify-content: space-between !important;
    gap: 12px !important;
  }
  .line-items-totals #discountInput {
    width: 100% !important;
  }

  /* Cards tighter */
  .card-header, .card-body {
    padding-left: 14px;
    padding-right: 14px;
  }
  .page-header {
    gap: 10px;
    margin-bottom: 14px;
  }
  .page-header h1 {
    font-size: 1.2rem;
  }
  .page-actions {
    width: 100%;
  }
  .page-actions .btn {
    flex: 1 1 calc(50% - 4px);
  }

  /* Dashboard */
  .dash-board,
  .dash-split,
  .dash-lower {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .stat-grid {
    gap: 8px;
  }
  .stat-card {
    min-height: 96px;
    padding: 14px 12px 12px;
  }
  .quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .quick-action {
    justify-content: center;
    min-height: 48px;
    margin: 0;
  }

  /* Hide less critical table columns on index lists when marked */
  .table-responsive-stack thead {
    display: none;
  }
}

@media (max-width: 575.98px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  .user-chip {
    padding: 4px;
    border: none;
    background: transparent;
  }
  .topbar-search input {
    font-size: 16px;
  }
  /* Combobox full width feel */
  .cb-list {
    left: 0 !important;
    right: 0 !important;
  }
  /* List groups denser but tappable */
  .list-group-item {
    padding: 12px 14px;
  }
  /* Modal-like forms */
  .row.g-3 > [class*="col-"] {
    margin-bottom: 0;
  }
}

/* Prevent double-tap zoom delay where supported */
@media (hover: none) and (pointer: coarse) {
  .btn, .nav-link, .quick-action, .stat-card {
    touch-action: manipulation;
  }
  .stat-card:hover {
    transform: none;
    box-shadow: var(--shadow);
  }
  .stat-card:active {
    border-color: #c7d7f5;
  }
}


/* ---------- Toast notifications ---------- */
.gm-toast-container {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(22rem, calc(100vw - 1.5rem));
  width: min(22rem, calc(100vw - 1.5rem));
  pointer-events: none;
}
.gm-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.5rem;
  background: var(--card, #fff);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  border: 1px solid var(--border, #e2e8f0);
  max-width: 100%;
  font-size: 0.875rem;
  line-height: 1.35;
  animation: gm-toast-in 0.18s ease-out;
}
.gm-toast.hiding {
  animation: gm-toast-out 0.2s ease-in forwards;
}
.gm-toast-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  margin-top: 1px;
}
.gm-toast-body { flex: 1; min-width: 0; line-height: 1.4; }
.gm-toast-title { font-weight: 650; margin-bottom: 2px; }
.gm-toast-close {
  border: 0;
  background: transparent;
  color: var(--muted, #6b7280);
  padding: 0;
  line-height: 1;
  cursor: pointer;
  font-size: 1.1rem;
}
.gm-toast-close:hover { color: var(--dark, #111827); }
.gm-toast-success { border-left: 3px solid #12b76a; }
.gm-toast-success .gm-toast-icon { background: #dcfae6; color: #039855; }
.gm-toast-error { border-left: 3px solid #f04438; }
.gm-toast-error .gm-toast-icon { background: #fee4e2; color: #d92d20; }
.gm-toast-info { border-left: 3px solid #3d7aef; }
.gm-toast-info .gm-toast-icon { background: #e8f0fe; color: #3d7aef; }
.gm-toast-warning { border-left: 3px solid #f79009; }
.gm-toast-warning .gm-toast-icon { background: #fef0c7; color: #dc6803; }

@keyframes gm-toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes gm-toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-6px); }
}

[data-theme="dark"] .gm-toast {
  background: #1a2230;
  border-color: #2a3341;
  color: #e8edf5;
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
[data-theme="dark"] .gm-toast-close { color: #8b95a8; }
[data-theme="dark"] .gm-toast-close:hover { color: #e8edf5; }
[data-theme="dark"] .gm-toast-success .gm-toast-icon { background: rgba(18,183,106,.15); color: #32d583; }
[data-theme="dark"] .gm-toast-error .gm-toast-icon { background: rgba(240,68,56,.15); color: #f97066; }
[data-theme="dark"] .gm-toast-info .gm-toast-icon { background: rgba(61,122,239,.15); color: #84adff; }
[data-theme="dark"] .gm-toast-warning .gm-toast-icon { background: rgba(247,144,9,.15); color: #fdb022; }

@media (max-width: 576px) {
  .gm-toast-container {
    top: auto;
    bottom: 16px;
    left: 12px;
    right: 12px;
    max-width: none;
  }
}


/* ---------- Media viewer (vehicle photos) ---------- */
.media-thumb {
  cursor: zoom-in;
  display: block;
  position: relative;
  overflow: hidden;
}
.media-thumb img {
  transition: transform 0.2s ease;
}
.media-thumb:hover img {
  transform: scale(1.03);
}
.media-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 0.15s ease;
  pointer-events: none;
}
.media-thumb:hover::after {
  background: rgba(0,0,0,.12);
}

body.media-viewer-open { overflow: hidden; }

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-viewer[hidden] { display: none !important; }

.media-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 20, 0.88);
  backdrop-filter: blur(4px);
}

.media-viewer-stage {
  position: relative;
  z-index: 1;
  max-width: min(92vw, 1100px);
  max-height: calc(100vh - 100px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-viewer-stage img {
  max-width: 100%;
  max-height: calc(100vh - 100px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  background: #0a0e14;
}

.media-viewer-close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-viewer-close:hover { background: rgba(255,255,255,.22); }

.media-viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-viewer-nav:hover { background: rgba(255,255,255,.22); }
.media-viewer-prev { left: 12px; }
.media-viewer-next { right: 12px; }

.media-viewer-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 14px 20px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.55));
  color: #eef2f7;
  font-size: 0.875rem;
}
.media-viewer-caption { flex: 1; min-width: 0; }
.media-viewer-counter { opacity: 0.75; white-space: nowrap; }

@media (max-width: 576px) {
  .media-viewer-nav { width: 36px; height: 36px; }
  .media-viewer-prev { left: 6px; }
  .media-viewer-next { right: 6px; }
  .media-viewer-stage img { max-height: calc(100vh - 80px); }
}


.media-viewer-stage video {
  max-width: 100%;
  max-height: calc(100vh - 100px);
  border-radius: 8px;
  background: #000;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
}
.media-thumb-video {
  position: relative;
  background: #0a0e14;
}
.media-thumb-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.media-thumb-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 1;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}


.media-viewer-audio {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  min-width: min(420px, 90vw);
  padding: 2rem 1.5rem;
  background: rgba(255,255,255,.06);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.1);
}
.media-viewer-audio-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(79,140,255,.2);
  color: #8eb6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
}
.media-viewer-audio audio {
  width: min(360px, 85vw);
}
.media-thumb-audio {
  background: linear-gradient(145deg, #1a2230, #121820);
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: #c5d0e0;
  text-decoration: none;
}
.media-thumb-audio .media-thumb-audio-icon {
  font-size: 1.75rem;
  opacity: 0.9;
}


/* Background audio mini-player */
.gm-bg-audio {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2500;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #1a2230;
  border: 1px solid #2a3341;
  box-shadow: 0 12px 32px rgba(0,0,0,.4);
  color: #e7ecf3;
}
.gm-bg-audio[hidden] { display: none !important; }
.gm-bg-audio-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(79,140,255,.2);
  color: #9ec0ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
}
.gm-bg-audio-btn:hover { background: rgba(79,140,255,.35); color: #fff; }
.gm-bg-audio-meta {
  flex: 1;
  min-width: 0;
}
.gm-bg-audio-title {
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gm-bg-audio-sub {
  font-size: 0.7rem;
  color: #8b95a5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gm-bg-audio-progress {
  flex: 1.2;
  min-width: 80px;
  max-width: 160px;
}
.gm-bg-audio-progress input[type="range"] {
  width: 100%;
  accent-color: #4f8cff;
  cursor: pointer;
}
.gm-bg-audio-time {
  font-size: 0.7rem;
  color: #8b95a5;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
body.gm-bg-audio-active .content {
  padding-bottom: 72px;
}
.media-viewer-audio-hint {
  color: rgba(255,255,255,.75);
  font-size: 0.875rem;
  margin: 0;
}
html:not([data-theme="dark"]) .gm-bg-audio {
  background: #fff;
  border-color: #e5e7eb;
  color: #111827;
  box-shadow: 0 12px 28px rgba(16,24,40,.18);
}
html:not([data-theme="dark"]) .gm-bg-audio-sub,
html:not([data-theme="dark"]) .gm-bg-audio-time { color: #667085; }
html:not([data-theme="dark"]) .gm-bg-audio-btn {
  background: #eef4ff;
  color: #1849a9;
}

@media (max-width: 576px) {
  .gm-bg-audio {
    left: 8px;
    right: 8px;
    bottom: 8px;
    max-width: none;
  }
  .gm-bg-audio-progress { display: none; }
  .gm-bg-audio-time { display: none; }
}


/* ---------- Appointment calendar ---------- */
.apt-cal-toolbar { border-radius: var(--radius, 12px); }
.apt-nav-btn {
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.6rem;
}
.apt-cal-month-label { font-size: 0.95rem; }
.apt-cal { --apt-gap: 1px; background: var(--border, #e5e7eb); }
.apt-cal-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--card, #fff);
}
.apt-cal-dow {
  padding: 10px 8px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #667085);
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.apt-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--apt-gap);
}
.apt-cal-cell {
  min-height: 110px;
  background: var(--card, #fff);
  padding: 6px 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: background 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.apt-cal-cell:hover { background: var(--elevated, #f8fafc); }
.apt-cal-out { background: var(--elevated, #f8fafc); opacity: 0.72; }
.apt-cal-today { box-shadow: inset 0 0 0 2px #4f8cff; }
.apt-cal-selected { background: rgba(79,140,255,.08) !important; }
.apt-cal-daynum {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary, #475467);
  padding: 2px 4px;
}
.apt-cal-today .apt-cal-daynum {
  display: inline-flex;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #4f8cff;
  color: #fff;
}
.apt-cal-events { display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 0; }
.apt-cal-pill {
  display: block;
  font-size: 0.68rem;
  line-height: 1.25;
  padding: 3px 6px;
  border-radius: 5px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 3px solid transparent;
  color: inherit;
  background: rgba(79,140,255,.12);
  border-left-color: #4f8cff;
}
.apt-cal-pill:hover { filter: brightness(0.95); }
.apt-cal-more { font-size: 0.65rem; color: var(--muted); padding: 0 4px; }
.apt-cal-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 2px 2px 0;
  justify-content: center;
  align-items: center;
}
.apt-cal-dot-more { font-size: 0.6rem; color: var(--muted); font-weight: 600; }

.apt-st-requested { background: rgba(148,163,184,.2); border-left-color: #64748b; }
.apt-st-confirmed { background: rgba(79,140,255,.15); border-left-color: #4f8cff; }
.apt-st-checked { background: rgba(14,165,233,.15); border-left-color: #0ea5e9; }
.apt-st-progress { background: rgba(245,158,11,.18); border-left-color: #f59e0b; }
.apt-st-done { background: rgba(34,197,94,.15); border-left-color: #22c55e; }
.apt-st-cancel { background: rgba(239,68,68,.12); border-left-color: #ef4444; }
.apt-st-noshow { background: rgba(168,85,247,.15); border-left-color: #a855f7; }

.apt-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  background: #64748b;
  border-left: none !important;
}
.apt-dot.apt-st-requested { background: #64748b; }
.apt-dot.apt-st-confirmed { background: #4f8cff; }
.apt-dot.apt-st-checked { background: #0ea5e9; }
.apt-dot.apt-st-progress { background: #f59e0b; }
.apt-dot.apt-st-done { background: #22c55e; }
.apt-dot.apt-st-cancel { background: #ef4444; }
.apt-dot.apt-st-noshow { background: #a855f7; }

.apt-day-panel { border-radius: var(--radius, 12px); }
.apt-day-item { padding: 0.85rem 1rem; }
.apt-badge-requested { background: #e2e8f0; color: #334155; }
.apt-badge-confirmed { background: #dbeafe; color: #1e40af; }
.apt-badge-checked_in { background: #e0f2fe; color: #0369a1; }
.apt-badge-in_progress { background: #fef3c7; color: #b45309; }
.apt-badge-completed { background: #dcfce7; color: #166534; }
.apt-badge-cancelled { background: #fee2e2; color: #b91c1c; }
.apt-badge-no_show { background: #f3e8ff; color: #7e22ce; }

[data-theme="dark"] .apt-cal { background: var(--border); }
[data-theme="dark"] .apt-cal-cell { background: var(--card); }
[data-theme="dark"] .apt-cal-out { background: var(--elevated); }
[data-theme="dark"] .apt-cal-cell:hover { background: var(--elevated); }
[data-theme="dark"] .apt-cal-selected { background: rgba(79,140,255,.16) !important; }
[data-theme="dark"] .apt-cal-pill:hover { filter: brightness(1.15); }
[data-theme="dark"] .apt-badge-requested { background: #334155; color: #e2e8f0; }
[data-theme="dark"] .apt-badge-confirmed { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .apt-badge-checked_in { background: #0c4a6e; color: #7dd3fc; }
[data-theme="dark"] .apt-badge-in_progress { background: #78350f; color: #fcd34d; }
[data-theme="dark"] .apt-badge-completed { background: #14532d; color: #86efac; }
[data-theme="dark"] .apt-badge-cancelled { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .apt-badge-no_show { background: #581c87; color: #e9d5ff; }

/* Mobile: compact month + agenda */
@media (max-width: 767.98px) {
  .apt-cal-cell {
    min-height: 52px;
    padding: 4px 2px 6px;
    align-items: center;
  }
  .apt-cal-daynum {
    font-size: 0.78rem;
    text-align: center;
    width: 100%;
  }
  .apt-cal-today .apt-cal-daynum {
    width: 28px;
    height: 28px;
    margin: 0 auto;
  }
  .apt-cal-dow {
    font-size: 0.7rem;
    padding: 8px 0;
  }
  .apt-cal-month-label {
    font-size: 0.9rem;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .apt-nav-btn {
    min-width: 44px;
    min-height: 44px;
  }
  .apt-day-panel {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin-bottom: 0.5rem;
    box-shadow: 0 -8px 24px rgba(0,0,0,.12);
  }
  body.gm-bg-audio-active .apt-day-panel {
    margin-bottom: 4.5rem;
  }
}

@media (min-width: 768px) {
  .apt-day-panel { margin-top: 1rem; }
}


/* Vehicle form suggest (replaces native datalist) */
.gm-suggest { position: relative; }
.gm-suggest .form-control { padding-right: 2.25rem; }
.gm-suggest-toggle {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted, #667085);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  z-index: 2;
}
.gm-suggest-toggle:hover { color: var(--text, #111); background: rgba(0,0,0,.04); }
[data-theme="dark"] .gm-suggest-toggle:hover { background: rgba(255,255,255,.06); color: #e7ecf3; }
.gm-suggest-list {
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--border, #e5e7eb);
  background: #fff;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.18);
  color: #111827;
}
.gm-suggest-item {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1.3;
  color: inherit;
}
.gm-suggest-item:hover,
.gm-suggest-item.active {
  background: #eef4ff;
  color: #1849a9;
}
[data-theme="dark"] .gm-suggest-list {
  background: #1a2230 !important;
  border-color: #2a3341 !important;
  color: #e7ecf3 !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55) !important;
}
[data-theme="dark"] .gm-suggest-item:hover,
[data-theme="dark"] .gm-suggest-item.active {
  background: rgba(79, 140, 255, 0.18) !important;
  color: #fff !important;
}


/* Customer profile & general dark readability */
[data-theme="dark"] .card,
[data-theme="dark"] .card-body {
  color: var(--text) !important;
}
[data-theme="dark"] .card-body .fs-1,
[data-theme="dark"] .card-body .fs-2,
[data-theme="dark"] .card-body .fs-3,
[data-theme="dark"] .card-body .fs-4,
[data-theme="dark"] .card-body .fs-5,
[data-theme="dark"] .card-body strong,
[data-theme="dark"] .card-body .fw-semibold,
[data-theme="dark"] .card-body .fw-bold {
  color: var(--text) !important;
}
[data-theme="dark"] .text-muted,
[data-theme="dark"] .small.text-muted,
[data-theme="dark"] .card-body .text-muted {
  color: #9aa4b2 !important;
}
[data-theme="dark"] .list-group-item {
  background: var(--card) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
[data-theme="dark"] .list-group-item .fw-semibold,
[data-theme="dark"] .list-group-item a {
  color: #7aabff !important;
}
[data-theme="dark"] .list-group-item .text-muted,
[data-theme="dark"] .list-group-item .small {
  color: #9aa4b2 !important;
}
[data-theme="dark"] .badge.bg-success,
[data-theme="dark"] .text-bg-success,
[data-theme="dark"] .bg-success {
  background-color: rgba(62, 207, 142, 0.22) !important;
  color: #8aefc0 !important;
}
[data-theme="dark"] .badge.bg-danger,
[data-theme="dark"] .text-bg-danger,
[data-theme="dark"] .bg-danger {
  background-color: rgba(240, 113, 120, 0.22) !important;
  color: #ffb0b5 !important;
}
[data-theme="dark"] .badge.bg-warning,
[data-theme="dark"] .text-bg-warning,
[data-theme="dark"] .bg-warning {
  background-color: rgba(230, 180, 80, 0.22) !important;
  color: #f0d08a !important;
}
[data-theme="dark"] .badge.bg-info,
[data-theme="dark"] .text-bg-info,
[data-theme="dark"] .bg-info {
  background-color: rgba(92, 207, 230, 0.22) !important;
  color: #9ee8f5 !important;
}
[data-theme="dark"] .badge.bg-primary,
[data-theme="dark"] .text-bg-primary,
[data-theme="dark"] .bg-primary {
  background-color: rgba(79, 140, 255, 0.25) !important;
  color: #a8c6ff !important;
}
[data-theme="dark"] .badge.bg-secondary,
[data-theme="dark"] .text-bg-secondary,
[data-theme="dark"] .bg-secondary,
[data-theme="dark"] .badge.bg-dark,
[data-theme="dark"] .text-bg-dark {
  background-color: rgba(255, 255, 255, 0.12) !important;
  color: #d0d7e2 !important;
}
[data-theme="dark"] .badge.bg-light,
[data-theme="dark"] .text-bg-light,
[data-theme="dark"] .badge.bg-light.text-dark {
  background-color: rgba(255, 255, 255, 0.1) !important;
  color: #e7ecf3 !important;
}
[data-theme="dark"] .table {
  --bs-table-color: #e7ecf3;
  --bs-table-bg: transparent;
  --bs-table-border-color: #2a3341;
  --bs-table-striped-bg: rgba(255,255,255,.03);
  --bs-table-hover-bg: rgba(255,255,255,.05);
  color: var(--text);
}
[data-theme="dark"] .table > :not(caption) > * > * {
  color: inherit;
  border-color: var(--border);
  background-color: transparent;
}
[data-theme="dark"] .table thead th {
  color: #9aa4b2 !important;
  background: var(--elevated) !important;
}


/* Bootstrap subtle badges in dark mode (customer profile job status pills) */
[data-theme="dark"] .badge.bg-secondary-subtle,
[data-theme="dark"] .bg-secondary-subtle {
  background-color: rgba(255, 255, 255, 0.1) !important;
  color: #d0d7e2 !important;
}
[data-theme="dark"] .text-secondary {
  color: #9aa4b2 !important;
}
[data-theme="dark"] .badge.bg-primary-subtle,
[data-theme="dark"] .bg-primary-subtle {
  background-color: rgba(79, 140, 255, 0.2) !important;
  color: #a8c6ff !important;
}
[data-theme="dark"] .badge.bg-success-subtle,
[data-theme="dark"] .bg-success-subtle {
  background-color: rgba(62, 207, 142, 0.2) !important;
  color: #8aefc0 !important;
}
[data-theme="dark"] .profile-metric-card .profile-metric-value,
[data-theme="dark"] .profile-metric-value {
  color: #e7ecf3 !important;
}
[data-theme="dark"] .stat-card.primary,
[data-theme="dark"] .stat-card.warning,
[data-theme="dark"] .stat-card.info,
[data-theme="dark"] .stat-card.danger {
  color: inherit;
}
[data-theme="dark"] a.stat-card:hover {
  border-color: #4f8cff;
}


/* Appointment drag & drop */
.apt-cal-pill.apt-draggable { cursor: grab; }
.apt-cal-pill.apt-draggable:active { cursor: grabbing; }
.apt-cal-pill.apt-dragging {
  opacity: 0.45;
  outline: 2px dashed #4f8cff;
}
.apt-cal-pill.apt-saving { opacity: 0.6; pointer-events: none; }
.apt-cal-pill.apt-locked { cursor: pointer; opacity: 0.85; }
.apt-cal-cell.apt-drop-target {
  background: rgba(79, 140, 255, 0.14) !important;
  box-shadow: inset 0 0 0 2px #4f8cff;
}
[data-theme="dark"] .apt-cal-cell.apt-drop-target {
  background: rgba(79, 140, 255, 0.22) !important;
}








/* Soft multi-tab lock — matches app toast notification style */
.gm-tab-lock-bar {
  position: sticky;
  top: 0;
  z-index: 1085;
  padding: 0.65rem 1rem;
  background: transparent;
  pointer-events: none;
}
.gm-tab-lock-bar .gm-tab-lock-toast {
  animation: none !important; /* steady bar — no enter pulse on refresh */
  pointer-events: auto;
  max-width: 36rem;
  margin: 0 auto;
  width: 100%;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  align-items: center;
  gap: 0.75rem;
}
.gm-tab-lock-bar .gm-tab-lock-toast .btn {
  flex-shrink: 0;
  white-space: nowrap;
}
body.gm-tab-passive form[data-gm-tab-locked="1"] {
  opacity: 0.72;
}
body.gm-tab-passive form[data-gm-tab-locked="1"] [type="submit"],
body.gm-tab-passive form[data-gm-tab-locked="1"] button[type="submit"] {
  cursor: not-allowed;
}
@media (max-width: 576px) {
  .gm-tab-lock-bar .gm-tab-lock-toast {
  animation: none !important; /* steady bar — no enter pulse on refresh */
    flex-wrap: wrap;
  }
  .gm-tab-lock-bar .gm-tab-lock-toast .btn {
    width: 100%;
  }
}

/* Tab lock bar must not re-animate */
.gm-tab-lock-bar .gm-toast,
.gm-tab-lock-bar .gm-tab-lock-toast {
  animation: none !important;
}
