@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Layout */
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 80px;
  --top-height: 70px;
  --bottom-height: 46px;

  /* Theme */
  --shell-bg: #0f172a;
  --shell-border: rgba(255, 255, 255, 0.12);
  --body-bg: #f0f9ff;
  --card-bg: #ffffff;
  --card-border: #bae6fd;
  --input-bg: #ffffff;
  --input-border: #7dd3fc;
  --input-focus: #0284c7;
  --text-main: #0f172a;
  --text-muted: #475569;
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text-main);
}

.dashboard-shell {
  min-height: 100vh;
}

.dashboard-body {
  background: var(--body-bg);
  transition: padding-left 0.3s ease;
}

.dashboard-no-sidebar .top-bar-toggle {
  display: none;
}

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

.form-label,
.form-check-label {
  color: #000;
  font-weight: 600;
}

/* Top bar */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-height);
  background: var(--shell-bg);
  border-bottom: 1px solid var(--shell-border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.top-bar-title {
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #f8fafc;
}

.top-bar-toggle {
  border-radius: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  background: transparent;
}

.top-bar-brand {
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 1.05rem;
  color: #f8fafc;
}

.top-bar-guest-action {
  border-radius: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #f8fafc;
  background: transparent;
  padding: 0.35rem 0.9rem;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  transition: background 0.2s ease, color 0.2s ease;
}

.top-bar-guest-action:first-of-type {
  margin-right: 0.5rem;
}

.top-bar-guest-action:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-end;
}

.notification-menu {
  position: relative;
}

.notification-bell-button {
  position: relative;
}

.notification-unread-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.notification-dropdown {
  position: absolute;
  right: 0;
  top: 110%;
  width: min(360px, 90vw);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.8rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1150;
}

.notification-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.notification-dropdown-header,
.notification-dropdown-footer {
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.notification-dropdown-footer {
  border-top: 1px solid #e2e8f0;
  border-bottom: none;
}

.notification-list {
  max-height: 360px;
  overflow-y: auto;
}

.notification-item {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid #edf2f7;
}

.notification-item:hover {
  background: #f8fafc;
}

.notification-item.is-unread {
  background: #f0f9ff;
}

.notification-item-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #0f172a;
}

.notification-item-message {
  margin-top: 0.1rem;
  font-size: 0.78rem;
  color: #475569;
}

.notification-item-time {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: #64748b;
}

.notification-empty {
  padding: 1rem;
  color: #64748b;
  font-size: 0.82rem;
}

.top-bar-greeting {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.top-bar-greeting-text {
  font-weight: 500;
  color: #f8fafc;
}

.top-bar-greeting-subtext {
  font-size: 0.75rem;
  color: rgba(241, 245, 249, 0.7);
}

.user-menu {
  position: relative;
}

.user-menu-button {
  width: 42px;
  height: 42px;
  border-radius: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.05);
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background 0.2s ease;
}

.user-menu-button:hover {
  background: rgba(255, 255, 255, 0.15);
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: 110%;
  width: 200px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.8rem;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.45);
  padding: 0.4rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  opacity: 0;
  transform: translateY(-5px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 1100;
}

.user-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  color: #f8fafc;
  text-decoration: none;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
}

.user-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: var(--top-height);
  left: 0;
  bottom: var(--bottom-height);
  width: var(--sidebar-width);
  background: var(--shell-bg);
  /* background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%); */
  border-right: 1px solid var(--shell-border);
  display: flex;
  flex-direction: column;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 900;
  overflow: hidden;
  color: #94a3b8;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1.5rem 1rem 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #f8fafc;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.sidebar-brand i {
  color: var(--primary);
  font-size: 1.25rem;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 0 0.75rem 1.5rem 0.75rem;
  gap: 0.25rem;
}

/* Scrollbar for sidebar */
.sidebar-menu::-webkit-scrollbar {
  width: 4px;
}
.sidebar-menu::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1); 
  border-radius: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  color: #94a3b8;
  text-decoration: none;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.sidebar-link i {
  font-size: 1rem;
  min-width: 1.2rem;
  text-align: center;
  transition: color 0.2s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}

.sidebar-link:hover i {
  color: var(--primary);
}

.sidebar-link.active {
  background: linear-gradient(90deg, rgba(14, 165, 233, 0.15), rgba(14, 165, 233, 0.05));
  color: #ffffff;
}

.sidebar-link.active i {
  color: var(--primary);
}

/* Active indicator strip */
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  bottom: 15%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
  display: none; /* Pill style doesn't need this, but keeping optionally */
} 

.sidebar-link.text-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444 !important;
}
.sidebar-link.text-danger:hover i {
  color: #ef4444 !important;
}

.sidebar-item {
  display: flex;
  flex-direction: column;
}

.sidebar-submenu {
  max-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-left: 0;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  /* background: rgba(0, 0, 0, 0.15); */
  /* border-radius: 0.5rem; */
  /* margin-top: 0.1rem; */
}

.sidebar-submenu.open {
  max-height: 500px;
  margin-bottom: 0.25rem;
}

.sidebar-submenu .sidebar-link {
  padding-left: 3rem;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
  font-size: 0.85rem;
  opacity: 0.9;
}

.sidebar-submenu .sidebar-link i {
  font-size: 0.5rem; /* Small dot */
  min-width: 1.2rem;
  display: flex;
  justify-content: center;
}

.sidebar-submenu .sidebar-link:hover,
.sidebar-submenu .sidebar-link.active {
  background: transparent;
  color: #fff;
}
.sidebar-submenu .sidebar-link.active {
  font-weight: 600;
  color: var(--primary);
}

.submenu-icon {
  margin-left: auto;
  font-size: 0.7rem !important;
  opacity: 0.5;
  transition: transform 0.3s ease;
}

.sidebar-link[aria-expanded="true"] .submenu-icon {
  transform: rotate(180deg);
  opacity: 1;
}

.sidebar-pill-wrap {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.sidebar-pill {
  min-width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  padding: 0 0.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  border: 1px solid transparent;
}

.sidebar-pill-danger {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.45);
}

.sidebar-pill-warning {
  color: #fef3c7;
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(251, 191, 36, 0.45);
}

/* Content */
.main-content {
  margin-top: var(--top-height);
  margin-left: var(--sidebar-width);
  margin-bottom: var(--bottom-height);
  padding: 2.1rem 1.5rem calc(var(--bottom-height) + 1.5rem) 1.5rem;
  min-height: calc(100vh - var(--top-height) - var(--bottom-height));
  background: var(--body-bg);
}

.dashboard-no-sidebar .main-content {
  margin-left: 0;
}

.content-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--bottom-height);
  background: #1f2937;
  border-top: 1px solid var(--shell-border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  z-index: 1000;
  color: #e2e8f0;
}

.bottom-bar-left {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.bottom-bar-copy {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footer-mobile-nav {
  align-items: center;
  gap: 0.5rem;
}

.footer-icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.footer-icon-btn i {
  font-size: 0.92rem;
}

/* Cards & sections */
.section-card,
.lead-card,
.lead-shell,
.lead-toolbar,
.profile-section.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  color: var(--text-main);
}

.section-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

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

.lead-shell {
  border-radius: 1rem;
  padding: 1.5rem;
}

.lead-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.lead-hero h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: 0.02em;
}

.lead-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.lead-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.lead-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.lead-card header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.35rem;
}

.lead-card header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.lead-card header small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.lead-card--wide {
  grid-column: span 2;
}

.lead-card--notes textarea {
  min-height: 160px;
  resize: vertical;
}

.lead-control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.lead-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.lead-field span {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lead-field input,
.lead-field select,
.lead-field textarea,
.form-control,
.form-select {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 0.6rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  color: #000;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.lead-field input:focus,
.lead-field select:focus,
.lead-field textarea:focus,
.form-control:focus,
.form-select:focus {
  outline: none;
  background: #f0f9ff;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.25);
  color: #000;
}

select option {
  background-color: var(--card-bg);
  color: #000;
}

.lead-radio {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.lead-radio input {
  width: 16px;
  height: 16px;
}

.lead-subtext {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lead-two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.lead-field--inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.lead-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.lead-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.lead-form-actions .btn {
  border-radius: 0.85rem;
  padding: 0.85rem 1.75rem;
}

.lead-field-lead-add {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.lead-field-lead-add .btn {
  border-radius: 0.85rem;
}

.lead-dynamic-row {
  position: relative;
}

.remove-dynamic-entry {
  align-self: flex-start;
}

.lead-toolbar {
  border: 1px solid var(--card-border);
}

.lead-toolbar .lead-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.lead-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.lead-filter-group label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lead-toolbar .btn-outline-light {
  border-radius: 0.65rem;
  padding: 0.45rem 0.85rem;
  font-weight: 600;
}

.lead-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-radius: 0.85rem;
  border: 1px solid var(--card-border);
  padding: 0.9rem 1.1rem;
  background: var(--card-bg);
}

.lead-bulk-actions .form-check {
  margin-bottom: 0;
}

.lead-export-group .btn {
  min-width: 70px;
  padding: 0.35rem 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lead-name-link {
  font-weight: 600;
  color: var(--primary);
}

.lead-name-link:hover {
  color: var(--primary-hover);
  text-decoration: none;
}

.lead-table-wrapper {
  overflow-x: auto;
  position: relative;
}

.lead-card-stack {
  display: none;
}

.lead-table thead th {
  position: sticky;
  top: 0;
  background: #e0f2fe;
  color: #0f172a;
  z-index: 2;
  border-bottom: 2px solid var(--card-border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  padding: 1rem 0.75rem;
  font-weight: 700;
}

.lead-table td {
  padding: 1rem 0.75rem;
  border-bottom: 1px solid #e0f2fe;
  vertical-align: middle;
  color: #000;
}

.lead-table td .btn {
  padding: 0.35rem 0.8rem;
  font-size: 0.75rem;
}

.lead-table .badge {
  font-size: 0.7rem;
}

.lead-table tbody tr:hover {
  background-color: #e0f2fe;
}

.lead-detail-card {
  border-radius: 0.85rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-card);
}

.lead-score {
  position: relative;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.lead-score-meter {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #fbbf24, #f97316);
}

.lead-assigned {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lead-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.lead-badge {
  display: inline-flex;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #030712;
  border: 1px solid transparent;
}

.badge-followup {
  color: #111827;
  background: #fef3c7;
}

.lead-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.lead-card-actions .btn {
  flex: 1 1 auto;
  min-width: 120px;
}

.lead-followup-alert {
  border-radius: 0.75rem;
  border: 1px solid rgba(248, 113, 113, 0.4);
  background: rgba(249, 115, 22, 0.15);
}

.lead-loader {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--card-border);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  color: #000;
}

.lead-loader.visible {
  opacity: 1;
  pointer-events: auto;
}

.lead-row-followup {
  background: rgba(249, 115, 22, 0.08);
}

/* Profile pages */
.profile-page {
  min-height: 70vh;
}

.profile-header {
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 1rem;
}

.profile-actions {
  flex-wrap: wrap;
}

.profile-page:not(.editing) [data-editable-control] {
  display: none;
}

.extra-address-row {
  background: rgba(0, 0, 0, 0.02);
}

.profile-section .card-title,
.profile-header h1 {
  color: #000;
  font-weight: 700;
}

.profile-section .card-body,
.profile-section textarea {
  color: #000;
}

.profile-section textarea {
  min-height: 60px;
}

.profile-section .form-label {
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #000;
}

.profile-page.editing input:not(.form-control-plaintext),
.profile-page.editing select,
.profile-page.editing textarea {
  background: #d4edda;
}

.form-control-plaintext.fw-semibold {
  color: #000;
  font-weight: 700;
}

.main-placeholder {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.main-placeholder h1 {
  margin: 0;
  font-size: 2rem;
}

.main-placeholder p {
  margin: 0;
  color: rgba(55, 65, 81, 0.85);
  max-width: 480px;
}

.footer-meta {
  color: rgba(226, 232, 240, 0.8);
}

/* Buttons */
.btn-primary {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
  background-color: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
}

.btn-outline-light {
  color: #0369a1 !important;
  border-color: var(--input-border) !important;
  background: #fff !important;
}

.btn-outline-light:hover {
  background-color: #e0f2fe !important;
  color: #0c4a6e !important;
}

/* Neon badge fallbacks */
.lead-badge[style*='#38bdf8'] {
  background-color: rgba(56, 189, 248, 0.15) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.lead-badge[style*='#a855f7'] {
  background-color: rgba(168, 85, 247, 0.15) !important;
  color: #a855f7 !important;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.lead-badge[style*='#f97316'] {
  background-color: rgba(249, 115, 22, 0.15) !important;
  color: #f97316 !important;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.lead-badge[style*='#22c55e'] {
  background-color: rgba(34, 197, 94, 0.15) !important;
  color: #22c55e !important;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.lead-badge[style*='#facc15'] {
  background-color: rgba(250, 204, 21, 0.15) !important;
  color: #facc15 !important;
  border: 1px solid rgba(250, 204, 21, 0.3);
}

.lead-badge[style*='#14b8a6'] {
  background-color: rgba(20, 184, 166, 0.15) !important;
  color: #14b8a6 !important;
  border: 1px solid rgba(20, 184, 166, 0.3);
}

.lead-badge[style*='#ef4444'],
.lead-badge[style*='#dc2626'] {
  background-color: rgba(239, 68, 68, 0.15) !important;
  color: #ef4444 !important;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.lead-badge[style*='#0ea5e9'] {
  background-color: rgba(14, 165, 233, 0.15) !important;
  color: #0ea5e9 !important;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

/* Role colouring */
.role-row {
  border-left: 4px solid transparent;
}

.role-superadmin {
  background: #fff1f2 !important;
  border-left-color: #be123c;
}

.role-admin {
  background: #ecfeff !important;
  border-left-color: #0ea5e9;
}

.role-manager {
  background: #fef3c7 !important;
  border-left-color: #d97706;
}

.role-sales {
  background: #ecfdf3 !important;
  border-left-color: #16a34a;
}

.role-superadmin td,
.role-superadmin th {
  background: #fff1f2 !important;
}

.role-admin td,
.role-admin th {
  background: #ecfeff !important;
}

.role-manager td,
.role-manager th {
  background: #fef3c7 !important;
}

.role-sales td,
.role-sales th {
  background: #ecfdf3 !important;
}

/* Responsive */
@media (max-width: 991px) {
  :root {
    --bottom-height: 64px;
  }

  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }

  .main-content {
    margin-left: 0;
    padding-bottom: calc(var(--bottom-height) + env(safe-area-inset-bottom, 0px) + 1.25rem);
  }

  .bottom-bar,
  .top-bar {
    padding-inline: 1rem;
  }

  .bottom-bar {
    min-height: var(--bottom-height);
    height: auto;
    justify-content: center;
    padding-top: 0.5rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  }

  .bottom-bar-left {
    width: 100%;
    justify-content: center;
  }

  .bottom-bar-copy {
    display: none;
  }

  .footer-meta {
    display: none;
  }

  .lead-table-wrapper {
    display: none;
  }

  .lead-card-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
}

@media (max-width: 720px) {
  .lead-card--wide {
    grid-column: span 1;
  }

  .lead-two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 575px) {
  .top-bar {
    height: var(--top-height);
    flex-wrap: nowrap;
    padding: 0 1rem;
    gap: 0.5rem;
  }

  .top-bar-left {
    gap: 0.5rem;
    overflow: hidden;
  }

  .top-bar-greeting-text {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    display: inline-block;
  }

  .top-bar-greeting-subtext {
    font-size: 0.65rem;
    line-height: 1;
  }

  .top-bar-actions {
    width: auto;
    justify-content: flex-end;
    flex-shrink: 0;
  }

  .notification-dropdown {
    right: -14px;
    width: min(340px, 96vw);
  }

  .main-content {
    padding: 1.5rem 1rem calc(var(--bottom-height) + env(safe-area-inset-bottom, 0px) + 1rem);
  }
}

/* Bulk unit entry: keep inputs usable on phones (stack + prevent iOS zoom). */
@media (max-width: 768px) {
  #bulkStartUnit,
  #bulkEndUnit,
  #bulkSize,
  #bulkPrice,
  #bulkTower,
  #bulkTowerFloors,
  #bulkFloor,
  #bulkComment {
    font-size: 16px;
  }
}

/* Desktop-only flex fill for the bulk unit entry row.
   Important: don't set flex inline, it breaks the bootstrap `col-*` widths on mobile. */
@media (min-width: 768px) {
  .bulk-flex-1 {
    flex: 1 1 0% !important;
  }

  .bulk-flex-2 {
    flex: 2 1 0% !important;
  }
}

/* Mobile table cards */
@media (max-width: 768px) {

  .table-responsive:not(.no-auto-card) table,
  .table-responsive:not(.no-auto-card) thead,
  .table-responsive:not(.no-auto-card) tbody,
  .table-responsive:not(.no-auto-card) th,
  .table-responsive:not(.no-auto-card) tr,
  .table-responsive:not(.no-auto-card) td {
    display: block;
  }

  .table-responsive:not(.no-auto-card) thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .table-responsive:not(.no-auto-card) tr {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    background: #fff;
    box-shadow: var(--shadow-card);
    position: relative;
    padding: 1.5rem;
    padding-top: 2rem;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'header header'
      'details action';
    row-gap: 1.5rem;
    overflow: hidden;
  }

  .table-responsive:not(.no-auto-card) tr::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #10b981;
  }

  .table-responsive:not(.no-auto-card) td {
    border: none !important;
    padding: 0 !important;
    text-align: left;
    display: block;
  }

  .table-responsive:not(.no-auto-card) td::before {
    display: none !important;
  }

  .table-responsive:not(.no-auto-card) td:first-child {
    grid-area: header;
    position: relative;
    padding-right: 120px !important;
    display: flex;
    align-items: center;
  }

  .table-responsive:not(.no-auto-card) td:nth-child(2) {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: auto;
  }

  .table-responsive:not(.no-auto-card) td:nth-child(2) .status-badge-wrapper {
    display: flex;
    justify-content: flex-end;
  }

  .table-responsive:not(.no-auto-card) td:nth-child(3) {
    grid-area: details;
    align-self: end;
    font-size: 0.9rem;
    color: var(--text-muted);
  }

  .table-responsive:not(.no-auto-card) td:last-child {
    grid-area: action;
    justify-self: end;
  }
}

/* Collapsed sidebar handling */
.dashboard-body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

.dashboard-body.sidebar-collapsed .sidebar-link span,
.dashboard-body.sidebar-collapsed .sidebar-brand span {
  display: none;
}

.dashboard-body.sidebar-collapsed .sidebar-pill {
  display: none;
}

.dashboard-body.sidebar-collapsed .sidebar-link,
.dashboard-body.sidebar-collapsed .sidebar-brand {
  justify-content: center;
}

.dashboard-body.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

.dashboard-body.sidebar-visible .sidebar {
  transform: translateX(0);
}

.dashboard-body.sidebar-visible::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  z-index: 850;
}

/* Responsive Avatar Sizes */
.avatar-circle {
  width: 40px;
  height: 40px;
  min-width: 40px;
}

@media (max-width: 768px) {
  .avatar-circle {
    width: 48px;
    height: 48px;
    min-width: 48px;
    font-size: 1.25rem;
  }
}
