/* =============================================
   RealtorPro — Design System
   Inter font, bold/fat UI, professional SaaS
   ============================================= */

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

:root {
  /* Colors */
  --primary:        #2B6CB0;
  --primary-dark:   #1A4A8A;
  --primary-light:  #EBF4FF;
  --cta:            #3182CE;
  --cta-hover:      #2B6CB0;
  --surface:        #FFFFFF;
  --surface-secondary: #F7FAFC;
  --sidebar-bg:     #1A202C;
  --sidebar-active: #2B6CB0;
  --text-primary:   #1A202C;
  --text-secondary: #4A5568;
  --text-muted:     #A0AEC0;
  --success:        #38A169;
  --success-light:  #F0FFF4;
  --warning:        #D69E2E;
  --warning-light:  #FFFBEB;
  --error:          #E53E3E;
  --error-light:    #FFF5F5;
  --border:         #E2E8F0;
  --border-focus:   #3182CE;

  /* Spacing */
  --xs: 4px;
  --sm: 8px;
  --md: 16px;
  --lg: 24px;
  --xl: 32px;
  --2xl: 48px;

  /* Border Radius */
  --radius-btn:    8px;
  --radius-card:   12px;
  --radius-modal:  16px;
  --radius-input:  8px;
  --radius-pill:   999px;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:   0 8px 24px rgba(0,0,0,0.12);
  --shadow-xl:   0 16px 48px rgba(0,0,0,0.16);

  /* Sidebar */
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--surface-secondary);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ======== LAYOUT ======== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: var(--md) var(--lg);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: var(--sm);
}

/* sidebar-logo = flex row wrapper for logo-mark + logo-text */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.sidebar-brand-text {
  font-weight: 800;
  font-size: 18px;
  color: white;
  letter-spacing: -0.3px;
}

.sidebar-brand-text span {
  color: #63B3ED;
}

.sidebar-nav {
  flex: 1;
  padding: var(--md) var(--sm);
}

.nav-section {
  margin-bottom: var(--lg);
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.3);
  padding: 0 var(--md);
  margin-bottom: var(--sm);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--md);
  border-radius: var(--radius-btn);
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  position: relative;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: white;
}

.nav-item.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  background: var(--error);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  min-width: 20px;
  text-align: center;
}

.nav-badge.yellow { background: var(--warning); }
.nav-badge.green  { background: var(--success); }

.sidebar-footer {
  padding: var(--md);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: var(--radius-btn);
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  transition: background 0.15s;
  min-width: 0;
}

.sidebar-user:hover { background: rgba(255,255,255,0.07); }

.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: white;
  flex-shrink: 0;
}

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

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

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

/* MAIN CONTENT — padded scroll area inside .main-wrapper */
.main-content {
  flex: 1;
  padding: var(--xl);
  overflow-y: auto;
  overflow-x: hidden;
}

/* TOPBAR */
.topbar {
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--xl);
  gap: var(--md);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  flex: 1;
  letter-spacing: -0.3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sm);
}

/* PAGE CONTENT */
.page-content {
  flex: 1;
  padding: var(--xl);
  max-width: 1400px;
  width: 100%;
}

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

.card-header {
  padding: var(--md) var(--lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--md);
}

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

.card-body {
  padding: var(--lg);
}

.card-footer {
  padding: var(--md) var(--lg);
  border-top: 1px solid var(--border);
  background: var(--surface-secondary);
}

/* ======== STAT CARDS ======== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--md);
  margin-bottom: var(--xl);
}

.stat-card {
  background: white;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  padding: var(--lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--md);
  transition: box-shadow 0.2s, transform 0.2s;
}

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

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

.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: #FFFAF0; color: #DD6B20; }
.stat-icon.red    { background: var(--error-light); color: var(--error); }
.stat-icon.purple { background: #FAF5FF; color: #805AD5; }

.stat-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
}

.stat-change {
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--error); }

/* ======== BUTTONS ======== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s, color 0.15s;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* Primary — main CTA, filled */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(43,108,176,0.25), 0 1px 2px rgba(0,0,0,0.06);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(43,108,176,0.35);
  transform: translateY(-1px);
}

/* CTA — teal accent */
.btn-cta {
  background: var(--cta);
  color: #fff;
  border-color: var(--cta);
  box-shadow: 0 1px 3px rgba(49,130,206,0.25), 0 1px 2px rgba(0,0,0,0.06);
}
.btn-cta:hover {
  background: var(--cta-hover);
  border-color: var(--cta-hover);
  box-shadow: 0 4px 12px rgba(49,130,206,0.35);
  transform: translateY(-1px);
}

/* Success */
.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
  box-shadow: 0 1px 3px rgba(56,161,105,0.25);
}
.btn-success:hover { background: #2F855A; border-color: #2F855A; box-shadow: 0 4px 12px rgba(56,161,105,0.3); transform: translateY(-1px); }

/* Danger */
.btn-danger {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
  box-shadow: 0 1px 3px rgba(229,62,62,0.25);
}
.btn-danger:hover { background: #C53030; border-color: #C53030; box-shadow: 0 4px 12px rgba(229,62,62,0.3); transform: translateY(-1px); }

/* Warning */
.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}
.btn-warning:hover { background: #B7791F; border-color: #B7791F; transform: translateY(-1px); }

/* Secondary — outlined, white bg, for non-primary actions */
.btn-secondary {
  background: #fff;
  color: var(--text-primary);
  border-color: #CBD5E0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-secondary:hover {
  background: var(--surface-secondary);
  border-color: #A0AEC0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* Ghost — for cancel / back / low-priority actions */
.btn-ghost {
  background: var(--surface-secondary);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: #EDF2F7;
  color: var(--text-primary);
  border-color: #A0AEC0;
}

.btn-sm  { padding: 6px 12px; font-size: 13px; border-radius: 7px; }
.btn-lg  { padding: 12px 22px; font-size: 15px; }
.btn-xl  { padding: 14px 28px; font-size: 16px; font-weight: 700; }
.btn-icon { padding: 8px; aspect-ratio: 1; border-radius: 8px; }

/* ======== FORMS ======== */
.form-group {
  margin-bottom: var(--md);
}

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

.form-label.required::after {
  content: ' *';
  color: var(--error);
}

.form-control,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-control:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(49,130,206,0.15);
}

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

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

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

.form-error {
  font-size: 12px;
  color: var(--error);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control { border-radius: 0; border-right: none; flex: 1; }
.input-group .form-control:first-child { border-radius: var(--radius-input) 0 0 var(--radius-input); }
.input-group-addon {
  padding: 10px 14px;
  background: var(--surface-secondary);
  border: 1.5px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-input) var(--radius-input) 0;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--md);
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--md);
}

/* ======== TABLES ======== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
}

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

thead {
  background: var(--surface-secondary);
}

thead th {
  padding: 12px var(--md);
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px var(--md);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

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

tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--primary-light); }

/* ======== BADGES ======== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  white-space: nowrap;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: #276749; }
.badge-warning { background: var(--warning-light); color: #975A16; }
.badge-danger  { background: var(--error-light);   color: #C53030; }
.badge-muted   { background: #EDF2F7;              color: var(--text-secondary); }
.badge-blue    { background: #EBF8FF;              color: #2C5282; }
.badge-purple  { background: #FAF5FF;              color: #553C9A; }
.badge-orange  { background: #FFFAF0;              color: #7B341E; }

/* ======== ALERTS ======== */
.alert {
  padding: var(--md);
  border-radius: var(--radius-card);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: var(--md);
}

.alert-success { background: var(--success-light); color: #276749; border: 1px solid #9AE6B4; }
.alert-error   { background: var(--error-light);   color: #C53030; border: 1px solid #FEB2B2; }
.alert-warning { background: var(--warning-light); color: #975A16; border: 1px solid #F6E05E; }
.alert-info    { background: var(--primary-light); color: #2C5282; border: 1px solid #BEE3F8; }

/* ======== AVATAR ======== */
.avatar {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  background: var(--primary);
  flex-shrink: 0;
}

.avatar-sm  { width: 32px; height: 32px; font-size: 12px; }
.avatar-md  { width: 40px; height: 40px; font-size: 14px; }
.avatar-lg  { width: 52px; height: 52px; font-size: 18px; }
.avatar-xl  { width: 72px; height: 72px; font-size: 24px; }

/* ======== PROGRESS ======== */
.progress {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.error   { background: var(--error); }

/* ======== PIPELINE STAGES ======== */
.pipeline {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: var(--sm);
}

.pipeline-col {
  min-width: 200px;
  background: var(--surface-secondary);
  border-radius: var(--radius-card);
  padding: var(--md);
  flex: 1;
}

.pipeline-col-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: var(--sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pipeline-card {
  background: white;
  border-radius: var(--radius-btn);
  padding: var(--md);
  margin-bottom: var(--sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}

.pipeline-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* ======== KANBAN ======== */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--md);
  align-items: start;
}

.kanban-col {
  background: var(--surface-secondary);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  min-height: 400px;
}

.kanban-col-header {
  padding: var(--md);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.kanban-col-body {
  padding: var(--sm);
  min-height: 350px;
}

.kanban-card {
  background: white;
  border-radius: var(--radius-btn);
  padding: var(--md);
  margin-bottom: var(--sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: box-shadow 0.15s;
}

.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card:active { cursor: grabbing; box-shadow: var(--shadow-lg); }

/* ======== INBOX CARDS ======== */
.inbox-card {
  background: white;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: var(--lg);
  margin-bottom: var(--md);
  transition: box-shadow 0.2s;
}

.inbox-card:hover { box-shadow: var(--shadow-md); }

.inbox-card-header {
  display: flex;
  align-items: flex-start;
  gap: var(--md);
  margin-bottom: var(--md);
}

.inbox-card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.inbox-card-actions {
  display: flex;
  gap: var(--sm);
  flex-wrap: wrap;
  margin-top: var(--md);
  padding-top: var(--md);
  border-top: 1px solid var(--border);
}

/* ======== TIMELINE ======== */
.timeline {
  position: relative;
  padding-left: var(--xl);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: var(--md);
}

.timeline-dot {
  position: absolute;
  left: calc(-1 * var(--xl) + 5px);
  top: 5px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
  box-shadow: var(--shadow-sm);
}

.timeline-body {
  background: var(--surface-secondary);
  border-radius: var(--radius-btn);
  padding: var(--md);
  border: 1px solid var(--border);
}

.timeline-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.timeline-text {
  font-size: 14px;
  color: var(--text-primary);
}

/* ======== MODAL ======== */
/* Legacy modal-overlay (used nowhere — kept for safety) */
.modal-overlay-legacy {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--md);
  backdrop-filter: blur(2px);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-body    { padding: var(--lg); }
.modal-footer  { padding: var(--md) var(--lg); border-top: 1px solid var(--border); display: flex; gap: var(--sm); justify-content: flex-end; }

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

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: 150;
  padding: var(--xs) 0;
  display: none;
}

.dropdown-menu.open { display: block; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sm);
  padding: 9px var(--md);
  font-size: 14px;
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.dropdown-item:hover  { background: var(--surface-secondary); }
.dropdown-item.danger { color: var(--error); }
.dropdown-divider { height: 1px; background: var(--border); margin: var(--xs) 0; }

/* ======== TABS ======== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 0;
  margin-bottom: var(--xl);
}

.tab {
  padding: var(--md) var(--lg);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  text-decoration: none;
  transition: all 0.15s;
}

.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ======== EMPTY STATE ======== */
.empty-state {
  text-align: center;
  padding: var(--2xl);
}

.empty-state-icon {
  width: 64px; height: 64px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--md);
  color: var(--primary);
}

.empty-state-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sm);
}

.empty-state-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--lg);
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
}

/* ======== AUTH PAGES ======== */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1A202C 0%, #2D3748 50%, #1A365D 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--md);
}

.auth-card {
  background: white;
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  padding: var(--2xl);
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--xl);
}

.auth-logo-mark {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 22px;
  color: white;
  margin-bottom: var(--sm);
}

.auth-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: -0.4px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: var(--xl);
}

.auth-divider {
  text-align: center;
  position: relative;
  margin: var(--md) 0;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 30px);
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }

/* ======== ONBOARDING ======== */
.onboarding-page {
  min-height: 100vh;
  background: var(--surface-secondary);
}

.onboarding-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: var(--md) var(--xl);
  display: flex;
  align-items: center;
  gap: var(--lg);
}

.step-indicator {
  display: flex;
  gap: 6px;
  flex: 1;
}

.step-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}

.step-dot.done    { background: var(--success); }
.step-dot.active  { background: var(--primary); width: 28px; border-radius: var(--radius-pill); }

.onboarding-body {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--2xl) var(--md);
}

.onboarding-step-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: var(--sm);
  letter-spacing: -0.5px;
}

.onboarding-step-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: var(--xl);
}

/* ======== PLAN CARDS ======== */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--md);
}

.plan-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--lg);
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  position: relative;
}

.plan-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.plan-card.selected { border-color: var(--primary); background: var(--primary-light); }

.plan-card.popular::before {
  content: 'Most Popular';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.plan-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.plan-price {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: var(--sm);
  letter-spacing: -0.5px;
}

.plan-price span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.plan-features {
  font-size: 13px;
  color: var(--text-secondary);
  list-style: none;
}

.plan-features li {
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.plan-features li::before {
  content: '\2713';
  color: var(--success);
  font-weight: 700;
  font-size: 12px;
}

/* ======== HOT LEAD BADGE ======== */
.hot-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #FC8181, #F56565);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ======== SEARCH BAR ======== */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--sm);
  background: var(--surface-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 8px 14px;
  transition: border-color 0.15s;
}

.search-bar:focus-within {
  border-color: var(--border-focus);
  background: white;
}

.search-bar input {
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}

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

/* ======== IMPERSONATION BANNER ======== */
.impersonation-banner {
  background: linear-gradient(90deg, var(--warning), #ED8936);
  color: white;
  padding: 8px var(--xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 200;
}

/* ======== ICON HELPER ======== */
.icon {
  width: 20px; height: 20px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ======== UTILITY ======== */
.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-success   { color: var(--success) !important; }
.text-danger    { color: var(--error) !important; }
.text-warning   { color: var(--warning) !important; }
.text-brand     { color: var(--primary) !important; }

.font-bold   { font-weight: 700 !important; }
.font-black  { font-weight: 900 !important; }
.font-medium { font-weight: 500 !important; }
.font-mono   { font-family: 'JetBrains Mono', monospace !important; font-size: 13px !important; }

.d-flex  { display: flex !important; }
.d-grid  { display: grid !important; }
.d-none  { display: none !important; }
.d-block { display: block !important; }

.align-center   { align-items: center !important; }
.justify-between{ justify-content: space-between !important; }
.justify-center { justify-content: center !important; }
.flex-1         { flex: 1 !important; }
.flex-wrap      { flex-wrap: wrap !important; }
.gap-xs  { gap: var(--xs) !important; }
.gap-sm  { gap: var(--sm) !important; }
.gap-md  { gap: var(--md) !important; }
.gap-lg  { gap: var(--lg) !important; }

.mb-0  { margin-bottom: 0 !important; }
.mb-sm { margin-bottom: var(--sm) !important; }
.mb-md { margin-bottom: var(--md) !important; }
.mb-lg { margin-bottom: var(--lg) !important; }
.mb-xl { margin-bottom: var(--xl) !important; }
.mt-auto { margin-top: auto !important; }
.ms-auto { margin-left: auto !important; }

.p-0   { padding: 0 !important; }
.p-md  { padding: var(--md) !important; }
.p-lg  { padding: var(--lg) !important; }

.rounded     { border-radius: var(--radius-card) !important; }
.rounded-btn { border-radius: var(--radius-btn) !important; }
.rounded-pill{ border-radius: var(--radius-pill) !important; }

.w-100   { width: 100% !important; }
.w-50    { width: 50% !important; }
.h-100   { height: 100% !important; }

.overflow-hidden { overflow: hidden !important; }
.cursor-pointer  { cursor: pointer !important; }
.user-select-none{ user-select: none !important; }

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

/* ======== SCROLLBAR ======== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #A0AEC0; }

/* ======== RESPONSIVE ======== */
@media (max-width: 1024px) {
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }

  .sidebar { transform: translateX(-260px); }
  .sidebar.open { transform: translateX(0); width: 260px; }
  .main-content { margin-left: 0; }
  .page-content { padding: var(--md); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .plan-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0 var(--md); }
  .topbar-title { font-size: 16px; }
}

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

/* ======== ANIMATIONS ======== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { transform: translateX(-20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.animate-fade { animation: fadeIn 0.3s ease; }
.animate-slide { animation: slideIn 0.3s ease; }
.animate-pulse { animation: pulse 2s infinite; }

/* =============================================
   EXTENDED DESIGN TOKENS & COMPONENT PATCHES
   Adds --space-*, --gray-*, --font-*, etc.
   required by all views
   ============================================= */

:root {
  /* Space scale (4px base) */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-7:  28px;
  --space-8:  32px;
  --space-9:  36px;
  --space-10: 40px;
  --space-11: 44px;
  --space-12: 48px;
  --space-14: 56px;
  --space-16: 64px;

  /* Gray scale */
  --gray-50:  #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* Font scale */
  --font-xs:  11px;
  --font-sm:  13px;
  --font-md:  15px;
  --font-lg:  17px;
  --font-xl:  20px;
  --font-2xl: 24px;
  --font-3xl: 30px;

  /* Radius aliases */
  --radius:    8px;
  --radius-lg: 12px;

  /* Extra semantic colors */
  --purple:       #805AD5;
  --purple-light: #FAF5FF;
  --info:         #3182CE;
  --info-light:   #EBF4FF;
  --secondary:    #718096;
}

/* ======== LAYOUT ALIASES ======== */
/* Views use .app-shell / .main-wrapper */
.app-shell { display: flex; min-height: 100vh; }
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ======== TOPBAR EXTENDED ======== */
.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.topbar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  color: var(--text-secondary);
  border-radius: var(--radius);
}
.topbar-toggle:hover { background: var(--gray-100); }
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-sm);
  color: var(--gray-500);
  min-width: 0;
}
.breadcrumb-item {
  color: var(--gray-500);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb-item:last-child { color: var(--gray-800); font-weight: 600; }
.breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-sep { color: var(--gray-300); font-size: var(--font-xs); }
.topbar-notif-btn {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  transition: background 0.15s;
}
.topbar-notif-btn:hover { background: var(--gray-100); color: var(--text-primary); }
.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--error);
  border-radius: 50%;
  border: 2px solid white;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
  transition: background 0.15s;
  position: relative;
}
.topbar-user:hover { background: var(--gray-100); }
.topbar-user-name { font-size: var(--font-sm); font-weight: 600; color: var(--text-primary); }
.topbar-user-role { font-size: var(--font-xs); color: var(--gray-500); }
.topbar-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  z-index: 200;
  padding: var(--space-1) 0;
  display: none;
}
.topbar-dropdown.open { display: block; animation: fadeIn 0.15s ease; }

/* ======== SIDEBAR EXTENDED ======== */
.sidebar-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.logo-mark {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}
.logo-text {
  font-weight: 800;
  font-size: 18px;
  color: white;
  letter-spacing: -0.3px;
}
.logo-text span { color: #63B3ED; }
.nav-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.3);
  padding: 0 var(--space-4);
  margin: var(--space-4) 0 var(--space-2);
  display: block;
}
.sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-btn);
  color: rgba(255,255,255,0.4);
  text-decoration: none;
  transition: all 0.15s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.sidebar-logout:hover { background: rgba(255,0,0,0.15); color: #FC8181; }

/* ======== PAGE HEADER ======== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.page-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.4px;
  line-height: 1.2;
}
.page-subtitle {
  font-size: var(--font-sm);
  color: var(--gray-500);
  margin-top: var(--space-1);
  font-weight: 500;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ======== ANALYTICS GRIDS ======== */
.analytics-chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-6);
  margin-top: var(--space-6);
}
.analytics-stage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  margin-top: var(--space-6);
}

/* ======== PROPERTY SHOW PAGE ======== */
.prop-layout-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
.prop-specs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ======== STATS GRID (alias) ======== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

/* stat icon color variants for views */
.stat-icon-blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon-green  { background: var(--success-light); color: var(--success); }
.stat-icon-orange { background: #FFFAF0; color: #DD6B20; }
.stat-icon-red    { background: var(--error-light); color: var(--error); }
.stat-icon-purple { background: var(--purple-light); color: var(--purple); }
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--error); }

/* ======== FILTER ROW ======== */
.filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.filter-row .form-control,
.filter-row .form-select { width: auto; min-width: 160px; }

/* ======== FORM PAGE GRID ======== */
.form-page-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  max-width: 860px;
}
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) 0;
}

/* ======== TABLE EXTENDED ======== */
.table-wrap { overflow-x: auto; }

/* Mobile-only helpers — hidden on desktop, shown via media query */
.mobile-row-meta { display: none; }
.mobile-sub      { display: none; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  padding: 12px var(--space-4);
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray-500);
  border-bottom: 2px solid var(--border);
  background: var(--gray-50);
  white-space: nowrap;
}
.table tbody td {
  padding: 14px var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--primary-light); }
.table-link {
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s;
}
.table-link:hover { color: var(--primary); }
.table-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ======== BADGE EXTENDED ======== */
.badge-secondary { background: #EDF2F7; color: var(--gray-700); }
.badge-info      { background: var(--info-light); color: var(--info); }
.badge-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--gray-600);
  padding: 2px 10px;
}

/* ======== BUTTON EXTENDED ======== */
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; }
.form-control-lg { padding: 12px 16px; font-size: 15px; }
.form-control-sm { padding: 7px 10px; font-size: 13px; }
.input-group-text {
  padding: 10px 14px;
  background: var(--gray-100);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 14px;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  white-space: nowrap;
}

/* ======== PROGRESS EXTENDED ======== */
.progress-bar-danger  { background: var(--error); }
.progress-bar-warning { background: var(--warning); }

/* ======== TABS EXTENDED ======== */
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--gray-200);
  color: var(--gray-700);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  margin-left: var(--space-1);
}
.tab-count-danger  { background: var(--error-light); color: var(--error); }
.tab-count-warning { background: var(--warning-light); color: #975A16; }

/* ======== ALERTS EXTENDED ======== */
.alert-dismissible { position: relative; padding-right: 40px; }
.alert-close {
  position: absolute;
  top: 50%; right: var(--space-3);
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  color: inherit;
}
.alert-close:hover { opacity: 1; }

/* ======== LIST ITEMS ======== */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--gray-100);
  color: var(--gray-500);
}
.list-item-body { flex: 1; min-width: 0; }
.list-item-title {
  font-weight: 600;
  font-size: var(--font-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-sub {
  font-size: var(--font-xs);
  color: var(--gray-500);
  margin-top: 2px;
}

/* ======== DETAIL LIST ======== */
.detail-list { display: grid; gap: var(--space-3); }
.detail-item {
  display: flex;
  gap: var(--space-4);
  align-items: baseline;
}
.detail-label {
  font-size: var(--font-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  min-width: 120px;
  flex-shrink: 0;
}
.detail-value { font-size: var(--font-sm); color: var(--text-primary); font-weight: 500; }
.contact-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3) var(--space-6);
}

/* ======== INBOX EXTENDED ======== */
.inbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

/* ======== HOT LEAD BADGE ======== */
.hot-lead-badge {
  display: inline-block;
  background: linear-gradient(135deg, #FC8181, #F56565);
  color: white;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
  margin-left: var(--space-1);
}

/* Lead score badge coloring via JS — base style */
.lead-score-badge { font-weight: 700; }

/* ======== SETTINGS PANEL ======== */
.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-6);
  align-items: start;
}
.settings-nav { background: white; border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  border-bottom: 1px solid var(--border);
  transition: all 0.15s;
}
.settings-nav-item:last-child { border-bottom: none; }
.settings-nav-item:hover { background: var(--gray-50); color: var(--text-primary); }
.settings-nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: fadeIn 0.2s ease; }
.hidden { display: none !important; }

/* ======== ONBOARDING SHELL (two-panel layout) ======== */
.onboarding-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}
.onboarding-sidebar {
  background: var(--gray-900);
  padding: var(--space-10);
  display: flex;
  flex-direction: column;
}
.onboarding-content {
  background: var(--gray-50);
  padding: var(--space-10);
  overflow-y: auto;
}

/* ======== WORKING HOURS GRID ======== */
.working-hours-grid {
  display: grid;
  gap: var(--space-3);
}
.working-hours-row {
  display: grid;
  grid-template-columns: 100px 1fr 1fr auto;
  gap: var(--space-3);
  align-items: center;
}

/* ======== BRAND COLORS GRID ======== */
.brand-colors-grid {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.color-swatch {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}
.color-swatch.selected,
.color-swatch:hover { border-color: var(--gray-800); transform: scale(1.1); }

/* ======== MODULE CARDS GRID ======== */
.module-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
}
.module-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  text-align: center;
}
.module-card:hover { border-color: var(--primary); }
.module-card.selected { border-color: var(--primary); background: var(--primary-light); }

/* ======== PLAN CARDS (register page variant) ======== */
.plan-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.plan-card-inner { text-align: center; }
.plan-badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: var(--space-2);
}

/* ======== PROPERTIES GRID ======== */
.properties-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
}
.property-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
}
.property-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.property-card-image {
  width: 100%; height: 180px;
  object-fit: cover;
  background: var(--gray-100);
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-400);
}
.property-card-body { padding: var(--space-4); }
.property-price {
  font-size: var(--font-xl);
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.property-address { font-size: var(--font-sm); color: var(--gray-600); margin: var(--space-1) 0; }
.property-specs {
  display: flex;
  gap: var(--space-3);
  font-size: var(--font-xs);
  color: var(--gray-500);
  margin-top: var(--space-2);
}
.property-spec { display: flex; align-items: center; gap: 4px; font-weight: 600; }

/* ======== DASHBOARD GRID ======== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-6);
  align-items: start;
}
.dashboard-grid > * { min-width: 0; }

/* ======== PIPELINE STAGES BAR ======== */
.pipeline-stages { display: grid; gap: var(--space-3); }
.pipeline-stage-row {
  display: grid;
  grid-template-columns: 120px 1fr 60px;
  align-items: center;
  gap: var(--space-3);
}
.pipeline-stage-label { font-size: var(--font-sm); font-weight: 600; color: var(--gray-700); }
.pipeline-stage-value { font-size: var(--font-sm); font-weight: 700; color: var(--text-primary); text-align: right; }

/* ======== EMPTY STATE (children) ======== */
.empty-state svg {
  width: 48px; height: 48px;
  margin: 0 auto var(--space-4);
  display: block;
  color: var(--gray-300);
}
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--gray-700); margin-bottom: var(--space-2); }
.empty-state p  { font-size: var(--font-sm); color: var(--gray-500); margin-bottom: var(--space-4); }

/* ======== SWIPE GESTURE CARD ======== */
.swipe-card { position: relative; overflow: hidden; }
.swipe-card-inner { position: relative; transition: transform 0.2s ease; }
.swipe-hint {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--font-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--space-2) var(--space-4);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.swipe-hint-approve { right: 0; color: var(--success); }
.swipe-hint-reject  { left: 0; color: var(--error); }

/* ======== RESPONSIVE EXTRAS ======== */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .onboarding-shell { grid-template-columns: 1fr; }
  .onboarding-sidebar { display: none; }
}
@media (max-width: 768px) {
  .topbar-toggle { display: flex; }
  .properties-grid { grid-template-columns: repeat(2, 1fr); }
  .contact-detail-grid { grid-template-columns: 1fr; }
  .working-hours-row { grid-template-columns: 80px 1fr 1fr; }
}
@media (max-width: 480px) {
  .properties-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* =============================================
   UI AUDIT FIXES — round 2
   ============================================= */

/* ── Alert aliases ── */
.alert-danger { background: var(--error-light); color: #C53030; border: 1px solid #FEB2B2; }
.badge-secondary { background: #EDF2F7; color: var(--gray-700); }

/* ── Stat card header (icon row) ── */
.stat-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sm);
}

/* ── Stat icon colour aliases matching view usage ── */
.stat-icon-primary { background: var(--primary-light); color: var(--primary); }
.stat-icon-success { background: var(--success-light); color: var(--success); }
.stat-icon-warning { background: var(--warning-light); color: var(--warning); }
.stat-icon-danger  { background: var(--error-light);   color: var(--error);   }
.stat-icon-info    { background: var(--info-light);    color: var(--info);    }

/* ── List item subclass aliases ── */
.list-item-content {
  flex: 1;
  min-width: 0;
}
.list-item-meta {
  font-size: var(--font-xs);
  color: var(--gray-500);
  margin-top: 2px;
}
.list-item-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background 0.1s;
}
.list-item-link:last-child { border-bottom: none; }
.list-item-link:hover { background: var(--primary-light); }
.list-item-link .list-item-title { color: var(--text-primary); }

/* ── Pipeline bar chart ── */
.pipeline-stages {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  padding: var(--space-4) 0;
  overflow-x: auto;
}
.pipeline-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
  min-width: 60px;
}
.pipeline-bar-wrap {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 88px;
}
.pipeline-bar {
  width: 32px;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.4s ease;
}
.pipeline-count {
  font-size: var(--font-sm);
  font-weight: 800;
  color: var(--text-primary);
}
.pipeline-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-500);
  text-align: center;
  white-space: nowrap;
}

/* ── Modal — hidden by default, shown with .open ── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: var(--md);
}
.modal.open { display: flex; }
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
}
.modal-dialog {
  position: relative;
  z-index: 1;
  background: white;
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: fadeIn 0.2s ease;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
.modal-close:hover { color: var(--text-primary); background: var(--gray-100); }

/* ── Kanban column/card subclasses (aligned to view class names) ── */
.kanban-column {
  background: var(--gray-50);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  min-height: 400px;
  display: flex;
  flex-direction: column;
}
.kanban-column-header {
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: white;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
}
.kanban-column-title { font-weight: 700; color: var(--text-primary); }
.kanban-cards {
  padding: var(--space-3);
  flex: 1;
  min-height: 120px;
  transition: background 0.15s;
}
.kanban-cards.drag-over { background: var(--primary-light); }
.kanban-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.kanban-card-title {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: var(--space-1);
}
.kanban-card-desc {
  font-size: var(--font-xs);
  color: var(--gray-500);
  line-height: 1.5;
  margin-bottom: var(--space-2);
}
.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-2);
  gap: var(--space-2);
}
.kanban-card-actions { display: flex; gap: var(--space-1); }
.kanban-card-due {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 4px;
}
.kanban-card-due.overdue { color: var(--error); }
.kanban-card.dragging { opacity: 0.5; box-shadow: var(--shadow-lg); }

/* ── Auth layout ── */
.auth-body { background: linear-gradient(135deg, #1A202C 0%, #2D3748 50%, #1A365D 100%); }
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--xl) var(--md);
  gap: var(--lg);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--sm);
}
.auth-brand-name {
  font-size: 22px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.4px;
}
.auth-card {
  background: white;
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 460px;
  padding: var(--2xl);
}
.auth-card-header { margin-bottom: var(--lg); }
.auth-form { margin-top: var(--md); }
.auth-switch {
  text-align: center;
  margin-top: var(--md);
  font-size: var(--font-sm);
  color: var(--gray-500);
}
.auth-switch a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.auth-footer-text {
  font-size: var(--font-xs);
  color: rgba(255,255,255,0.35);
  text-align: center;
}
.form-label-link {
  float: right;
  font-size: var(--font-xs);
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.form-label-link:hover { text-decoration: underline; }

/* ── Sidebar toggle button ── */
.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.5);
  padding: var(--space-1);
  border-radius: var(--radius);
  transition: color 0.15s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: white; }

/* ── Responsive: show topbar toggle on mobile ── */
@media (max-width: 768px) {
  .topbar-toggle { display: flex; }
}

/* ── Utility: hide notif-dot count text (dot only) ── */
.notif-dot {
  font-size: 0;
  width: 9px; height: 9px;
}

/* ── Dashboard KPI cards ── */
.db-kpi-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
  color: inherit;
}
.db-kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.db-kpi-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.db-kpi-body { flex: 1; min-width: 0; }
.db-kpi-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
  letter-spacing: -0.5px;
}
.db-kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-top: 4px;
}
.db-kpi-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-400);
  margin-top: 2px;
}

/* ── Settings tab nav ── */
.settings-tab-link:hover {
  background: var(--gray-100) !important;
  color: var(--gray-800) !important;
}

/* ═══════════════════════════════════════════════════
   ONBOARDING — full redesign
   ═══════════════════════════════════════════════════ */

/* Override shell to use a tighter breakpoint */
.onboarding-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
  background: #f8fafc;
}

/* ── Left sidebar ── */
.onboarding-sidebar {
  background: #0f172a;
  padding: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.ob-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 32px 32px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ob-logo-mark {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; color: white;
  flex-shrink: 0;
}
.ob-logo-text {
  font-size: 18px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.3px;
}

.ob-steps {
  flex: 1;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ob-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: default;
  transition: background 0.15s;
}
.ob-step.active { background: rgba(255,255,255,0.08); }

.ob-step-bullet {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  flex-shrink: 0;
  transition: all 0.2s;
}
.ob-step.done .ob-step-bullet {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.ob-step.active .ob-step-bullet {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.2);
}

.ob-step-label {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  transition: color 0.2s;
}
.ob-step.done .ob-step-label { color: rgba(255,255,255,0.6); }
.ob-step.active .ob-step-label { color: white; }

.ob-progress {
  padding: 24px 32px 32px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.ob-progress-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.ob-progress-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ob-progress-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}
.ob-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
  overflow: hidden;
}
.ob-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── Right content area ── */
.onboarding-content {
  background: #f8fafc;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 40px;
  min-height: 100vh;
}

.ob-form-card {
  background: white;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  padding: 48px;
  width: 100%;
  max-width: 600px;
}

.ob-step-header {
  margin-bottom: 36px;
}
.ob-step-num {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  background: var(--primary-light);
  padding: 4px 12px;
  border-radius: 99px;
}
.ob-step-num svg { flex-shrink: 0; }
.ob-title {
  font-size: 28px;
  font-weight: 900;
  color: var(--gray-900);
  letter-spacing: -0.6px;
  margin: 0 0 8px;
}
.ob-subtitle {
  font-size: 15px;
  color: var(--gray-500);
  margin: 0;
  line-height: 1.5;
}

.ob-divider {
  height: 1px;
  background: var(--border);
  margin: 28px 0;
}

.ob-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

/* ── Working hours grid ── */
.wh-grid { display: flex; flex-direction: column; gap: 10px; }
.wh-row {
  display: grid;
  grid-template-columns: 56px 1fr 16px 1fr auto;
  gap: 10px;
  align-items: center;
}
.wh-day {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}
.wh-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.wh-sep { font-size: 12px; color: var(--gray-400); text-align: center; }
.wh-row .form-control-sm { padding: 6px 10px; font-size: 13px; }

/* ── Color swatch picker ── */
.ob-color-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.ob-swatch-label {
  position: relative;
  cursor: pointer;
}
.ob-swatch-label input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.ob-swatch {
  display: block;
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 3px solid transparent;
  outline: 2px solid transparent;
  transition: all 0.15s;
}
.ob-swatch-label input:checked + .ob-swatch {
  border-color: white;
  outline-color: var(--gray-800);
  transform: scale(1.12);
}
.ob-swatch:hover { transform: scale(1.08); }
.ob-custom-color {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.ob-color-input {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 2px;
  background: white;
}

/* ── Module cards ── */
.ob-module-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.ob-module-card {
  position: relative;
  cursor: pointer;
}
.ob-module-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.ob-module-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: white;
  transition: all 0.15s;
}
.ob-module-card input:checked + .ob-module-inner {
  border-color: var(--primary);
  background: var(--primary-light);
}
.ob-module-inner:hover { border-color: var(--primary); }
.ob-module-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--gray-100);
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500);
  flex-shrink: 0;
  transition: all 0.15s;
}
.ob-module-card input:checked + .ob-module-inner .ob-module-icon {
  background: var(--primary);
  color: white;
}
.ob-module-text { flex: 1; }
.ob-module-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 3px;
}
.ob-module-desc {
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.4;
}
.ob-check-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: transparent;
  flex-shrink: 0;
  margin-left: auto;
  transition: all 0.15s;
}
.ob-module-card input:checked + .ob-module-inner .ob-check-icon {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

@media (max-width: 900px) {
  .onboarding-shell { grid-template-columns: 1fr; }
  .onboarding-sidebar { display: none; }
  .onboarding-content { padding: 32px 20px; }
  .ob-form-card { padding: 28px 24px; }
  .ob-module-grid { grid-template-columns: 1fr; }
  .wh-row { grid-template-columns: 56px 1fr 16px 1fr; }
}

/* ======================================================
   APPROVAL INBOX — full component styles
   ====================================================== */

.inbox-list { display: flex; flex-direction: column; gap: var(--space-4); }

/* Base inbox item */
.inbox-item {
  background: white;
  border: 1px solid var(--border);
  border-left: 4px solid transparent;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  transition: box-shadow 0.15s;
}
.inbox-item:hover { box-shadow: var(--shadow-md); }

/* Actioned cards dim slightly */
.inbox-item-actioned { opacity: 0.75; }
.inbox-item-actioned:hover { opacity: 1; }

/* Escalation states */
.inbox-item-warn-24 { border-left-color: #ECC94B; }
.inbox-item-warn-48 { border-left-color: #ED8936; background: #FFFAF0; }
.inbox-item-expired { border-left-color: #FC8181; background: #FFF5F5; opacity: 0.8; }

/* Escalation badge */
.inbox-escalation-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: #FFF3CD;
  color: #856404;
  border: 1px solid #FFEAA7;
}
.inbox-item-warn-48 .inbox-escalation-badge { background: #FEEBC8; color: #7B341E; border-color: #FBBF24; }
.inbox-item-expired .inbox-escalation-badge  { background: #FED7D7; color: #C53030; border-color: #FC8181; }

/* Card header */
.inbox-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

/* Type badge */
.inbox-type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.03em;
}

/* Title */
.inbox-item-title {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 var(--space-3) 0;
  line-height: 1.4;
}

/* Preview section */
.inbox-item-preview {
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  font-size: var(--font-sm);
}

/* Preview helpers */
.preview-row {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  align-items: baseline;
}
.preview-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
  min-width: 60px;
  flex-shrink: 0;
}
.preview-val { color: var(--text-primary); font-weight: 600; }
.preview-body {
  color: var(--gray-700);
  line-height: 1.65;
  margin-bottom: var(--space-2);
}
.preview-transcript { font-style: italic; }
.preview-stat {
  font-size: var(--font-xs);
  color: var(--gray-500);
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
}

/* Poster / social image preview */
.inbox-preview-image {
  max-width: 200px;
  max-height: 160px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: var(--space-3);
  display: block;
}

/* Chat bubbles for ai_reply / review */
.preview-bubble {
  max-width: 90%;
  padding: var(--space-3) var(--space-4);
  border-radius: 12px;
  font-size: var(--font-sm);
  line-height: 1.6;
  margin-bottom: var(--space-2);
}
.preview-bubble-lead {
  background: #EDF2F7;
  color: var(--text-primary);
  border-radius: 12px 12px 12px 2px;
  align-self: flex-start;
}
.preview-bubble-ai {
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 12px 12px 2px 12px;
  margin-left: auto;
}

/* Context chips (contact / deal links) */
.inbox-context-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 9px;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.inbox-context-chip:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* Reject reason inline form */
.inbox-reject-form {
  border-top: 1px dashed var(--border);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  background: #FFF5F5;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: var(--space-3);
}

@media (max-width: 768px) {
  .inbox-item { padding: var(--space-4); }
  .inbox-preview-image { max-width: 100%; }
}

/* =============================================
   RESPONSIVE — COMPREHENSIVE MOBILE PATCH
   ============================================= */

/* Sidebar mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  cursor: pointer;
}
.sidebar-overlay.show { display: block; }

/* ── 1024px: tablets landscape ── */
@media (max-width: 1024px) {
  /* 5-col stats grid → 3-col */
  .stats-grid { grid-template-columns: repeat(3, 1fr) !important; }
  /* Any dashboard-style 2-col inline grid → 1-col */
  .dashboard-grid { grid-template-columns: 1fr !important; }
  /* Settings layout stacks */
  .settings-layout { grid-template-columns: 1fr; }
}

/* ── 768px: tablets portrait / phones landscape ── */
@media (max-width: 768px) {
  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
  .page-actions { width: 100%; flex-wrap: wrap; flex-shrink: unset; }

  /* Tabs — horizontal scroll, no wrapping */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex-shrink: 0; }

  /* Tables — horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Topbar — hide username, manage overflow */
  .topbar-user-name { display: none; }
  .topbar-breadcrumb { min-width: 0; overflow: hidden; }

  /* Stats: 5-col inline → 2-col */
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Any inline 2-col grid (voice, campaigns, etc.) → 1-col */
  .dashboard-grid { grid-template-columns: 1fr !important; }

  /* Page title */
  .page-title { font-size: 20px; }

  /* Card body padding */
  .card-body { padding: var(--space-4); }

  /* Voice outbound side panel — full-width drawer on mobile */
  #call-panel { width: 100vw !important; border-radius: 0; }

  /* Contact detail grid already switches at 768px, but ensure */
  .contact-detail-grid { grid-template-columns: 1fr; }
}

/* ── 480px: phones portrait ── */
@media (max-width: 480px) {
  /* Page header direct-child buttons (e.g. single CTA not in .page-actions) */
  .page-header > a.btn,
  .page-header > button.btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* Page actions — full-width stacked buttons */
  .page-actions { flex-direction: column; }
  .page-actions .btn,
  .page-actions a.btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* Stats — keep 2-col even on phones (single col is too sparse) */
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .stat-grid  { grid-template-columns: repeat(2, 1fr); }

  /* Table action buttons — stack */
  .table-actions { flex-direction: column; gap: var(--space-1); }
  .table-actions .btn { width: 100%; justify-content: center; }

  /* Page title */
  .page-title { font-size: 18px; }

  /* Topbar tighter */
  .topbar { padding: 0 var(--space-3); }

  /* Form rows */
  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  /* Kanban */
  .kanban-board { grid-template-columns: 1fr; }
}

/* =============================================
   UI POLISH — Visual enhancements pass
   ============================================= */

/* ── Sidebar: left accent bar on active nav item ── */
.nav-item.active {
  background: linear-gradient(90deg, rgba(49,130,206,0.25) 0%, rgba(43,108,176,0.15) 100%);
  border-left: 3px solid #63B3ED;
  padding-left: calc(var(--md) - 3px);
  color: white;
  font-weight: 600;
}
.nav-item.active .nav-icon { opacity: 1; }

/* Sidebar logo mark upgrade */
.logo-mark {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #3182CE 0%, #2B6CB0 100%);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  font-weight: 900;
  color: white;
  letter-spacing: -0.5px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(49,130,206,0.4);
}
.logo-text {
  font-size: 17px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.3px;
}

/* Sidebar nav label (section titles) */
.nav-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.3);
  padding: 0 var(--md);
  margin-bottom: var(--sm);
}

/* Sidebar header border */
.sidebar-header {
  padding: 20px var(--md) 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* ── KPI cards: top-border color accent ── */
.db-kpi-card {
  border-top: 3px solid transparent;
  position: relative;
  overflow: hidden;
}
.db-kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3182CE, #63B3ED);
  opacity: 0;
  transition: opacity 0.2s;
}
.db-kpi-card:hover::after { opacity: 1; }
.db-kpi-card:hover {
  box-shadow: 0 8px 24px rgba(43,108,176,0.12);
  transform: translateY(-3px);
}

/* KPI icon upgrade: stronger radius */
.db-kpi-icon { border-radius: 14px; }

/* ── Primary & CTA buttons: subtle gradient ── */
.btn-primary {
  background: linear-gradient(135deg, #3182CE 0%, #2B6CB0 100%);
  box-shadow: 0 2px 6px rgba(43,108,176,0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #2B6CB0 0%, #1A4A8A 100%);
  box-shadow: 0 4px 12px rgba(43,108,176,0.35);
}
.btn-cta {
  background: linear-gradient(135deg, #3182CE 0%, #2563EB 100%);
  box-shadow: 0 2px 8px rgba(37,99,235,0.35);
}
.btn-cta:hover {
  background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
  box-shadow: 0 4px 14px rgba(37,99,235,0.4);
  transform: translateY(-1px);
}

/* ── Card header: subtle gradient tint ── */
.card-header {
  background: linear-gradient(180deg, #FAFBFC 0%, #FFFFFF 100%);
}

/* ── Tables: left-border flash on row hover ── */
.table tbody tr {
  position: relative;
  transition: background 0.12s;
}
.table tbody tr:hover {
  background: #F7FAFF;
}
.table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 #3182CE;
}

/* ── Page header: thin bottom accent line ── */
.page-header {
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-6);
}

/* ── Empty states: gradient icon background ── */
.empty-state svg {
  background: linear-gradient(135deg, #EBF4FF 0%, #E8F4FD 100%);
  border-radius: 50%;
  padding: 16px;
  width: 80px; height: 80px;
  color: #3182CE;
  stroke: #3182CE;
}

/* ── Badges: richer colors ── */
.badge-primary   { background: linear-gradient(135deg,#EBF4FF,#DBEAFE); color:#1D4ED8; border:1px solid #BFDBFE; }
.badge-success   { background: linear-gradient(135deg,#F0FFF4,#DCFCE7); color:#15803D; border:1px solid #BBF7D0; }
.badge-warning   { background: linear-gradient(135deg,#FFFBEB,#FEF9C3); color:#B45309; border:1px solid #FDE68A; }
.badge-danger    { background: linear-gradient(135deg,#FFF5F5,#FEE2E2); color:#B91C1C; border:1px solid #FECACA; }
.badge-info      { background: linear-gradient(135deg,#EFF6FF,#E0F2FE); color:#0369A1; border:1px solid #BAE6FD; }
.badge-secondary { background: linear-gradient(135deg,#F7FAFC,#F1F5F9); color:#475569; border:1px solid #E2E8F0; }

/* ── Avatar: gradient background ── */
.avatar {
  background: linear-gradient(135deg, #3182CE 0%, #2B6CB0 100%);
  box-shadow: 0 2px 6px rgba(43,108,176,0.25);
}

/* ── Stat cards: left accent bar ── */
.stat-card {
  border-left: 3px solid transparent;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}
.stat-card:hover {
  border-left-color: #3182CE;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ── Form controls: focus ring upgrade ── */
.form-control:focus,
select.form-control:focus,
textarea.form-control:focus {
  border-color: #3182CE;
  box-shadow: 0 0 0 3px rgba(49,130,206,0.15);
  outline: none;
}

/* ── Topbar: slightly stronger shadow ── */
.topbar {
  box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(0,0,0,0.04);
}

/* ── Alert: left accent ── */
.alert-success { border-left: 4px solid var(--success); }
.alert-error   { border-left: 4px solid var(--error); }
.alert-info    { border-left: 4px solid var(--primary); }

/* ── Table link: stronger underline on hover ── */
.table-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* ── Quick-action buttons in sidebar: full width ── */
.btn-block { width: 100%; justify-content: center; }

/* ── Score bar: gradient fill ── */
.score-bar-fill {
  background: linear-gradient(90deg, #3182CE, #63B3ED) !important;
}

/* ── Deal/Contact stage badge in tables: pill shape ── */
.table .badge {
  border-radius: var(--radius-pill);
  font-size: 11px;
  padding: 3px 10px;
  font-weight: 600;
}

/* ── Page title: slightly larger on desktop ── */
@media (min-width: 1024px) {
  .page-title { font-size: 26px; }
}

/* ── Sidebar collapse button ──────────────────────────────────────────────── */
.sb-collapse-btn {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.45);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.sb-collapse-btn:hover { background: rgba(255,255,255,.14); color: #fff; }

/* ── Sidebar & main-wrapper: width / margin transition ───────────────────── */
@media (min-width: 769px) {
  .sidebar {
    transition: transform 0.3s ease, width 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow-x: hidden;
  }
  .main-wrapper {
    transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
  }
}

/* ── Base transitions for text elements (enable fade on both open & close) ── */
.logo-text {
  white-space: nowrap;
  overflow: hidden;
  max-width: 200px;
  opacity: 1;
  transition: opacity 0.18s ease, max-width 0.3s cubic-bezier(0.4,0,0.2,1);
}
.nav-item > span,
.nav-group-toggle > span {
  white-space: nowrap;
  overflow: hidden;
  max-width: 160px;
  opacity: 1;
  display: inline-block;
  vertical-align: middle;
  transition: opacity 0.15s ease, max-width 0.28s cubic-bezier(0.4,0,0.2,1);
}
.nav-label {
  overflow: hidden;
  max-height: 28px;
  opacity: 1;
  transition: opacity 0.15s ease, max-height 0.25s ease, margin 0.25s ease;
}
.nav-chevron {
  opacity: 1;
  transition: transform 0.2s ease, opacity 0.15s ease;
}
.nav-badge {
  overflow: hidden;
  max-width: 40px;
  opacity: 1;
  transition: opacity 0.15s ease, max-width 0.25s ease;
}
.sidebar-user-info {
  white-space: nowrap;
  overflow: hidden;
  max-width: 160px;
  opacity: 1;
  transition: opacity 0.15s ease, max-width 0.28s cubic-bezier(0.4,0,0.2,1);
}
.sidebar-logout {
  overflow: hidden;
  max-width: 40px;
  opacity: 1;
  transition: opacity 0.15s ease, max-width 0.25s ease, background 0.15s, color 0.15s;
}
.nav-sub {
  overflow: hidden;
  max-height: 300px;
  opacity: 1;
  transition: opacity 0.15s ease, max-height 0.28s ease;
}
/* Arrow icon flip */
.sb-arrow {
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  transform-origin: center;
}

/* ── Collapsed sidebar state ─────────────────────────────────────────────── */
@media (min-width: 769px) {
  body.sidebar-collapsed { --sidebar-width: 64px; }

  body.sidebar-collapsed .sidebar {
    width: 64px;
    overflow: visible;
  }
  body.sidebar-collapsed .sidebar-nav,
  body.sidebar-collapsed .sidebar-footer {
    overflow: visible;
  }
  body.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    transition: padding 0.3s cubic-bezier(0.4,0,0.2,1);
  }
  body.sidebar-collapsed .sb-collapse-btn { margin-left: 0; }

  /* Arrow flips when collapsed */
  body.sidebar-collapsed .sb-arrow {
    transform: scaleX(-1);
  }

  /* Fade + shrink text elements instead of display:none */
  body.sidebar-collapsed .logo-text {
    opacity: 0;
    max-width: 0;
  }
  body.sidebar-collapsed .nav-item > span,
  body.sidebar-collapsed .nav-group-toggle > span {
    opacity: 0;
    max-width: 0;
  }
  body.sidebar-collapsed .nav-label {
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    margin-bottom: 0;
  }
  body.sidebar-collapsed .nav-chevron {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
  }
  body.sidebar-collapsed .nav-badge {
    opacity: 0;
    max-width: 0;
  }
  body.sidebar-collapsed .sidebar-user-info {
    opacity: 0;
    max-width: 0;
  }
  body.sidebar-collapsed .sidebar-logout {
    opacity: 0;
    max-width: 0;
  }
  body.sidebar-collapsed .nav-sub {
    opacity: 0;
    max-height: 0;
  }

  /* Icon centering */
  body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px;
    gap: 0;
    position: relative;
  }
  body.sidebar-collapsed .sidebar-user {
    justify-content: center;
    padding: 8px 0;
  }

  /* Tooltip labels on hover */
  body.sidebar-collapsed .nav-item[data-label]:hover::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e2532;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 9999;
    border: 1px solid rgba(255,255,255,.12);
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   GLOBAL ANIMATION POLISH
   Rules: GPU-only (transform/opacity), ≤250ms, no layout-triggering props.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Keyframes ─────────────────────────────────────────────────────────────── */
@keyframes ah-drop {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
@keyframes ah-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ah-pop {
  from { opacity: 0; transform: scale(0.93); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes ah-slide-right {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes ah-slide-left {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Dropdown menus (was instant display:block) ────────────────────────────── */
.dropdown-menu.open {
  animation: ah-drop 0.14s cubic-bezier(0.4,0,0.2,1) both;
}
.topbar-dropdown.open {
  animation: ah-drop 0.14s cubic-bezier(0.4,0,0.2,1) both;
}
/* Generic nav-sub expand */
.nav-group.open .nav-sub {
  animation: ah-rise 0.18s ease both;
}

/* ── Modal — scale-pop instead of plain fade ───────────────────────────────── */
.modal-dialog {
  animation: ah-pop 0.22s cubic-bezier(0.34,1.4,0.64,1) both;
}
/* Backdrop fade (overlay was previously un-animated) */
.modal-overlay {
  animation: none; /* overlay handled via .modal.open — use opacity transition */
  transition: opacity 0.2s ease;
}
.modal { transition: opacity 0.2s ease; }
.modal:not(.open) { opacity: 0; pointer-events: none; }
.modal.open       { opacity: 1; }

/* ── Alerts — slide in from left on mount ──────────────────────────────────── */
.alert {
  animation: ah-slide-right 0.22s ease both;
}

/* ── Page content — gentle fade-up on every navigation ────────────────────── */
.main-content {
  animation: ah-rise 0.2s ease both;
}

/* ── Nav icon micro-animation on hover ─────────────────────────────────────── */
.nav-icon {
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1), opacity 0.15s ease;
}
.nav-item:hover .nav-icon,
.nav-group-toggle:hover .nav-icon {
  transform: scale(1.15);
}
.nav-item.active .nav-icon {
  transform: scale(1.08);
}

/* ── Sidebar active indicator bar ─────────────────────────────────────────── */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: rgba(255,255,255,.8);
  border-radius: 0 3px 3px 0;
}

/* ── Card base hover lift (no lift on inner cards that stack) ──────────────── */
.card {
  transition: box-shadow 0.18s ease;
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.kanban-card {
  transition: box-shadow 0.15s ease, transform 0.15s cubic-bezier(0.4,0,0.2,1);
}
.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.pipeline-card {
  transition: box-shadow 0.15s ease, transform 0.15s cubic-bezier(0.4,0,0.2,1);
}
.pipeline-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ── Topbar notif / toggle buttons ─────────────────────────────────────────── */
.topbar-toggle,
.topbar-notif-btn {
  transition: background 0.15s ease, transform 0.12s ease;
}
.topbar-toggle:hover  { transform: scale(1.08); }
.topbar-notif-btn:hover { transform: scale(1.08); }

/* ── Avatar subtle scale on hover ──────────────────────────────────────────── */
.avatar {
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.15s ease;
}
.topbar-user:hover .avatar,
.sidebar-user:hover .avatar {
  transform: scale(1.08);
}

/* ── Logo mark bounce on hover ─────────────────────────────────────────────── */
.logo-mark {
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1);
}
.sidebar-header:hover .logo-mark {
  transform: scale(1.07) rotate(-3deg);
}

/* ── Tab active indicator transition ───────────────────────────────────────── */
.tab {
  transition: color 0.15s ease, border-bottom-color 0.15s ease;
}

/* ── Stat cards — already have transform transition, ensure smoothness ──────── */
.stat-card {
  transition: box-shadow 0.18s ease, transform 0.18s cubic-bezier(0.4,0,0.2,1);
}

/* ── Inbox card lift ────────────────────────────────────────────────────────── */
.inbox-card {
  transition: box-shadow 0.18s ease, transform 0.18s cubic-bezier(0.4,0,0.2,1);
}
.inbox-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ── Sidebar footer items ───────────────────────────────────────────────────── */
.sidebar-logout {
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.sidebar-logout:hover {
  transform: translateX(2px);
}

/* ── Settings panel activate ────────────────────────────────────────────────── */
.settings-panel.active {
  animation: ah-rise 0.18s ease both;
}

/* ── Onboarding banner slide down ───────────────────────────────────────────── */
#ob-banner {
  animation: ah-drop 0.25s ease both;
}

/* ── Reduce motion for users who prefer it ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ================================================================
   MOBILE UI — Comprehensive overhaul
   ================================================================ */

/* ── Bottom nav: hidden on desktop ─────────────────────────────── */
.mobile-nav {
  display: none;
}

@media (max-width: 768px) {

  /* ── Bottom navigation bar ────────────────────────────────────── */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.07), 0 -1px 0 rgba(0,0,0,0.04);
    z-index: 300;
    align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--gray-400);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    transition: color 0.15s ease, transform 0.1s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    padding: 8px 2px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 0;
    outline: none;
  }

  .mobile-nav-item:active {
    transform: scale(0.92);
  }

  .mobile-nav-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }

  .mobile-nav-item.active {
    color: var(--primary);
  }

  .mobile-nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 4px 4px;
  }

  /* ── Constrain main-wrapper to viewport width ────────────────── */
  html, body {
    overflow-x: hidden;
    max-width: 100%;
  }

  .main-wrapper {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* ── Dashboard KPI grid: 2 per row on mobile ─────────────────── */
  .db-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .db-kpi-value { font-size: 20px !important; }
  .db-kpi-icon { width: 40px !important; height: 40px !important; }

  /* ── Push content above bottom nav ───────────────────────────── */
  .main-content {
    padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* ── Topbar ───────────────────────────────────────────────────── */
  .topbar {
    height: 56px;
    padding: 0 12px;
    position: sticky;
    top: 0;
    z-index: 200;
  }

  .topbar-toggle {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--gray-100);
    border: none;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .topbar-toggle:active {
    background: var(--gray-200);
  }

  .topbar-notif-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Sidebar mobile: wider, blurred overlay ───────────────────── */
  .sidebar {
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  }

  .sidebar.open {
    width: min(300px, 88vw) !important;
    box-shadow: 8px 0 32px rgba(0,0,0,0.2);
  }

  .sidebar-overlay.show {
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }

  /* ── Page layout ──────────────────────────────────────────────── */
  .page-content {
    padding: 16px;
  }

  .page-header {
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
  }

  .page-title {
    font-size: 20px !important;
    line-height: 1.2;
  }

  .page-actions {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: var(--space-2);
    flex-shrink: 0;
  }

  .page-actions::-webkit-scrollbar { display: none; }

  .page-actions .btn,
  .page-actions a.btn {
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* ── Cards ────────────────────────────────────────────────────── */
  .card {
    border-radius: 16px;
  }

  .card-header {
    padding: 14px 16px 0;
  }

  .card-title {
    font-size: 15px;
  }

  .card-body {
    padding: 14px 16px;
  }

  /* ── Stat cards ───────────────────────────────────────────────── */
  .stat-card {
    padding: 14px 16px;
    border-radius: 16px;
  }

  .stat-value {
    font-size: 24px !important;
  }

  /* ── List items: taller touch targets ─────────────────────────── */
  .list-item,
  .list-item-link {
    padding: 12px 16px;
    min-height: 54px;
  }

  /* ── Buttons: proper 44px touch target ────────────────────────── */
  .btn {
    min-height: 40px;
    border-radius: 10px;
  }

  .btn-sm {
    min-height: 34px;
    border-radius: 8px;
  }

  /* ── Inputs: prevent iOS auto-zoom (needs 16px+) ─────────────── */
  .form-control,
  .form-select,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
    border-radius: 10px;
  }

  /* ── Tabs: swipeable horizontal scroll ────────────────────────── */
  .tabs {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    gap: 4px;
    -ms-overflow-style: none;
  }

  .tabs::-webkit-scrollbar { display: none; }

  .tab {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 8px 16px;
  }

  /* ── Tables: horizontal scroll ────────────────────────────────── */
  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-card);
    -ms-overflow-style: none;
  }

  /* ── Dashboard grid: single column ────────────────────────────── */
  .dashboard-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  /* ── Stats grid: 2 per row ────────────────────────────────────── */
  .stats-grid,
  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }

  /* ── Grids ────────────────────────────────────────────────────── */
  .contact-detail-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }

  /* ── Properties grid ──────────────────────────────────────────── */
  .properties-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ── Alerts: flush to edges ────────────────────────────────────── */
  .main-content > .alert {
    border-radius: 0;
    margin: 0 0 var(--space-3);
  }

  /* ── Empty states ─────────────────────────────────────────────── */
  .empty-state {
    padding: 32px 16px;
  }

  /* ── Topbar user name: hide on small screens ──────────────────── */
  .topbar-user-name { display: none; }

  /* ── Analytics grids ─────────────────────────────────────── */
  .analytics-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .analytics-chart-grid,
  .analytics-stage-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-4) !important;
    margin-top: var(--space-4) !important;
  }

  /* ── Property show page ───────────────────────────────────── */
  .prop-layout-grid {
    grid-template-columns: 1fr !important;
  }

  .prop-specs-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ── Dashboard bottom grid ────────────────────────────────── */
  .dash-bottom-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── Settings layout ──────────────────────────────────────── */
  .settings-layout {
    grid-template-columns: 1fr !important;
  }

  /* ── Tables: col hiding — no forced min-width ─────────────── */
  .table-wrap table,
  .table-wrap .table {
    min-width: 0;
  }
  .col-mobile-hide { display: none !important; }
  /* ── Invoice line items: hide read-only amount col on mobile ── */
  .line-item-amount-col { display: none !important; }

  /* ── Mobile-only inline meta inside table cells ───────────── */
  .mobile-row-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 5px;
  }
  .mobile-sub {
    display: block;
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 2px;
    line-height: 1.4;
  }

  /* ── Filter card: allow chips to overflow-scroll ────────────── */
  .cfilter { overflow: visible; }

  /* ── Filter chips: single horizontally-scrollable row ──────── */
  .cfilter-chips {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 6px;
    padding-right: 16px;
  }
  .cfilter-chips::-webkit-scrollbar { display: none; }

  /* ── Table action buttons: icon-only on mobile ─────────────── */
  .table-actions .btn-text-hide { display: none; }

  /* ── Deals table: tighter cells ───────────────────────────── */
  .table td, .table th { padding: 10px 10px; }

}

@media (max-width: 480px) {

  .page-content { padding: 12px; }

  .page-title { font-size: 18px !important; }

  .stat-value { font-size: 20px !important; }

  .stats-grid,
  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }

  .properties-grid {
    grid-template-columns: 1fr !important;
  }

  /* Stack page header vertically */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .page-actions .btn,
  .page-actions a.btn {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
    min-width: 0;
  }

  .page-header > a.btn,
  .page-header > button.btn {
    width: 100%;
    justify-content: center;
  }

  .card { border-radius: 12px; }

  .mobile-nav-item { font-size: 9px; }

}
