/* ─────────────────────────────────────────
   CREDENCEHUB — GLOBAL STYLES
   Brand: Navy #0F2D5E | Gold #F5A623
   Full Mobile Responsive
───────────────────────────────────────── */

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

/* ── CSS Variables ── */
:root {
  --navy: #0F2D5E;
  --navy-dark: #0a1f42;
  --navy-light: #1a3f7a;
  --gold: #F5A623;
  --gold-dark: #d4891a;
  --gold-light: #f7b84b;
  --white: #ffffff;
  --gray-50: #F4F6FA;
  --gray-100: #e8ecf4;
  --gray-200: #d1d8e8;
  --gray-300: #a0aec0;
  --gray-400: #718096;
  --gray-500: #4a5568;
  --gray-600: #2d3748;
  --gray-700: #1a202c;
  --success: #38a169;
  --success-light: #c6f6d5;
  --warning: #d69e2e;
  --warning-light: #fefcbf;
  --danger: #e53e3e;
  --danger-light: #fed7d7;
  --info: #3182ce;
  --info-light: #bee3f8;

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 64px;
  --header-height: 60px;

  /* 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 20px 40px rgba(0,0,0,0.15);

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --transition: all 0.25s ease;
}

/* ── Dark Mode Variables ── */
[data-theme="dark"] {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #1e2130;
  --bg-hover: #252840;
  --text-primary: #e2e8f0;
  --text-secondary: #a0aec0;
  --text-muted: #718096;
  --border-color: #2d3748;
  --sidebar-bg: #0a0d14;
  --sidebar-text: #e2e8f0;
  --sidebar-hover: rgba(245, 166, 35, 0.1);
  --header-bg: #1a1d27;
}

[data-theme="light"] {
  --bg-primary: #f4f6fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f0f4ff;
  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --border-color: #e2e8f0;
  --sidebar-bg: #0F2D5E;
  --sidebar-text: rgba(255,255,255,0.85);
  --sidebar-hover: rgba(245, 166, 35, 0.15);
  --header-bg: #ffffff;
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: var(--transition);
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
ul, ol { list-style: none; }

/* ── App Layout ── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ─────────────────────────────────────────
   SIDEBAR
───────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--header-height);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.sidebar-logo-icon {
  width: 34px;
  height: 34px;
  background: var(--gold);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: var(--navy);
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-logo-text {
  opacity: 0;
  pointer-events: none;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  color: var(--gold);
  background: rgba(255,255,255,0.08);
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  padding: 10px 6px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-section { margin-bottom: 6px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.35);
  padding: 8px 10px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--gold);
}

.nav-item.active {
  background: rgba(245, 166, 35, 0.15);
  color: var(--gold);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}

.nav-item-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item-text {
  transition: opacity 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed .nav-item-text { opacity: 0; width: 0; }

.nav-item-badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--navy);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 10px;
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .nav-item-badge { opacity: 0; }

/* Sidebar Footer */
.sidebar-footer {
  padding: 10px 6px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

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

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

.sidebar-user-info {
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-user-info { opacity: 0; width: 0; }

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

.sidebar-user-plan {
  font-size: 10px;
  color: var(--gold);
  font-weight: 500;
  text-transform: capitalize;
}

/* ─────────────────────────────────────────
   MAIN CONTENT
───────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

/* ─────────────────────────────────────────
   HEADER
───────────────────────────────────────── */
.app-header {
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
  flex-shrink: 0;
}

.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.notification-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--header-bg);
}

.plan-switcher {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  white-space: nowrap;
}

.plan-switcher:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.plan-badge {
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.plan-badge.lite { background: var(--gray-200); color: var(--gray-600); }
.plan-badge.premium { background: var(--navy); color: var(--gold); }
.plan-badge.pro { background: var(--gold); color: var(--navy); }

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────
   PAGE CONTENT
───────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 20px 20px;
}

.page-header { margin-bottom: 20px; }

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

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

.card-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

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

.card-body { padding: 18px; }

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: var(--transition);
}

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

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon.navy { background: rgba(15, 45, 94, 0.12); color: var(--navy); }
.kpi-icon.gold { background: rgba(245, 166, 35, 0.12); color: var(--gold-dark); }
.kpi-icon.success { background: var(--success-light); color: var(--success); }
.kpi-icon.info { background: var(--info-light); color: var(--info); }
.kpi-icon.danger { background: var(--danger-light); color: var(--danger); }

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-change {
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--danger); }

/* ─────────────────────────────────────────
   BUTTONS
───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary { background: var(--navy); color: #ffffff; }
.btn-primary:hover { background: var(--navy-light); box-shadow: var(--shadow-md); }

.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: var(--gold-dark); box-shadow: var(--shadow-md); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-outline:hover { border-color: var(--navy); color: var(--navy); background: var(--bg-hover); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger { background: var(--danger); color: #ffffff; }
.btn-danger:hover { background: #c53030; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }

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

/* ─────────────────────────────────────────
   FORMS
───────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(15, 45, 94, 0.1);
}

.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
.form-text { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--danger); margin-top: 4px; }

/* ─────────────────────────────────────────
   TABLES
───────────────────────────────────────── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

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

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ─────────────────────────────────────────
   BADGES & STATUS
───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-active { background: var(--success-light); color: var(--success); }
.badge-archived { background: var(--gray-100); color: var(--gray-500); }
.badge-sold { background: var(--info-light); color: var(--info); }
.badge-pending { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-navy { background: rgba(15,45,94,0.1); color: var(--navy); }
.badge-gold { background: rgba(245,166,35,0.15); color: var(--gold-dark); }
.badge-wholesale { background: #e8f5e9; color: #2e7d32; }
.badge-fix_flip { background: #fff3e0; color: #e65100; }
.badge-brrrr { background: #e3f2fd; color: #1565c0; }
.badge-construction { background: #f3e5f5; color: #6a1b9a; }
.badge-commercial { background: #e8eaf6; color: #283593; }

/* ─────────────────────────────────────────
   ALERTS
───────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.alert-success { background: var(--success-light); color: #276749; border-left: 3px solid var(--success); }
.alert-danger { background: var(--danger-light); color: #9b2c2c; border-left: 3px solid var(--danger); }
.alert-info { background: var(--info-light); color: #2c5282; border-left: 3px solid var(--info); }
.alert-warning { background: var(--warning-light); color: #7b341e; border-left: 3px solid var(--warning); }

/* ─────────────────────────────────────────
   EMPTY STATES
───────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; }

.empty-state-icon {
  width: 56px;
  height: 56px;
  background: var(--bg-hover);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* ─────────────────────────────────────────
   GRID UTILITIES
───────────────────────────────────────── */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap-8 { gap: 8px; }
.flex-gap-12 { gap: 12px; }
.flex-gap-16 { gap: 16px; }

/* ─────────────────────────────────────────
   TOAST NOTIFICATIONS
───────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  max-width: 360px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-icon { flex-shrink: 0; }
.toast-message { font-size: 13px; font-weight: 500; color: var(--text-primary); flex: 1; }
.toast-close { cursor: pointer; color: var(--text-muted); background: none; border: none; padding: 4px; }

/* ─────────────────────────────────────────
   LOADING SKELETON
───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-secondary) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

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

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  z-index: 1000;
  overflow: hidden;
  display: none;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.dropdown-item:hover { background: var(--bg-hover); color: var(--navy); }
.dropdown-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

/* ─────────────────────────────────────────
   MODAL
───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.show .modal { transform: scale(1); }

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

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body { padding: 20px 22px; }

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ─────────────────────────────────────────
   MOBILE OVERLAY
───────────────────────────────────────── */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}

.mobile-overlay.show { display: block; }

/* ─────────────────────────────────────────
   UTILITY CLASSES
───────────────────────────────────────── */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-gold { color: var(--gold); }
.text-navy { color: var(--navy); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }

.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.p-16 { padding: 16px; }
.p-20 { padding: 20px; }
.p-24 { padding: 24px; }

.w-full { width: 100%; }
.hidden { display: none; }
.rounded { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-lg); }
.cursor-pointer { cursor: pointer; }
.overflow-hidden { overflow: hidden; }

/* ─────────────────────────────────────────
   RESPONSIVE — TABLET (max 1024px)
───────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }

  /* Collapse sidebar on tablet */
  .sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .sidebar .sidebar-logo-text,
  .sidebar .nav-item-text,
  .sidebar .nav-item-badge,
  .sidebar .nav-section-label,
  .sidebar .sidebar-user-info {
    opacity: 0;
    width: 0;
    pointer-events: none;
  }

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

  /* Hide desktop collapse toggle on tablet */
  .sidebar-toggle { display: none; }
}

/* ─────────────────────────────────────────
   RESPONSIVE — MOBILE (max 768px)
───────────────────────────────────────── */
@media (max-width: 768px) {

  /* Safety net: stop any stray fixed-width element from creating horizontal scroll */
  html, body { overflow-x: hidden; max-width: 100vw; }

  /* Sidebar slides off screen, opened by overlay */
  .sidebar {
    width: var(--sidebar-width) !important;
    transform: translateX(-100%);
    box-shadow: none;
  }

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

  /* Restore text in mobile open state */
  .sidebar.mobile-open .sidebar-logo-text,
  .sidebar.mobile-open .nav-item-text,
  .sidebar.mobile-open .nav-item-badge,
  .sidebar.mobile-open .nav-section-label,
  .sidebar.mobile-open .sidebar-user-info {
    opacity: 1;
    width: auto;
    pointer-events: all;
  }

  /* Main content takes full width */
  .main-content {
    margin-left: 0 !important;
  }

  /* Show mobile menu button */
  .mobile-menu-btn {
    display: flex !important;
  }

  /* Hide desktop sidebar toggle */
  .sidebar-toggle { display: none; }

  /* Page content padding */
  .page-content { padding: 14px 14px; }

  /* KPI grid 2 columns on mobile */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* All grids stack to 1 column */
  .grid-2,
  .grid-3,
  .grid-4 { grid-template-columns: 1fr; }

  /* Two column and multi-column layouts stack to a single column */
  [style*="grid-template-columns:1fr 320px"],
  [style*="grid-template-columns:1fr 340px"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:240px 1fr"],
  [style*="grid-template-columns:1fr 2fr"],
  [style*="grid-template-columns:repeat(2, 1fr)"],
  [style*="grid-template-columns: repeat(2, 1fr)"],
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"],
  [style*="grid-template-columns:repeat(3, 1fr)"],
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns: 2fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Sticky panels unstick on mobile */
  [style*="position:sticky"] {
    position: relative !important;
    top: auto !important;
  }

  /* Header adjustments */
  .app-header { padding: 0 12px; gap: 8px; }
  .header-title { font-size: 14px; }
  .header-subtitle { display: none; }

  /* Plan switcher text hide on mobile */
  .plan-switcher span:last-child { display: none; }

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

  /* Cards */
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }

  /* KPI values smaller */
  .kpi-value { font-size: 18px; }
  .kpi-card { padding: 12px; gap: 10px; }
  .kpi-icon { width: 36px; height: 36px; }

  /* Buttons wrap */
  .flex-between {
    flex-wrap: wrap;
    gap: 10px;
  }

  /* Forms two-col to one-col */
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Tables horizontal scroll */
  .table-wrapper { overflow-x: auto; }

  /* Modal full width — !important beats any inline max-width set on individual modals */
  .modal,
  [class="modal"][style*="max-width"] {
    max-width: calc(100% - 24px) !important;
    width: calc(100% - 24px) !important;
    border-radius: var(--radius-lg);
  }
  .modal-body { padding: 16px; }
  .modal-header { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; }

  /* Toast position */
  .toast-container { right: 10px; left: 10px; }
  .toast { min-width: unset; max-width: 100%; }

  /* Section titles */
  .section-title { font-size: 20px; }

  /* Tab navigation horizontal scroll */
  [style*="display:flex; gap:4px; background:var(--bg-card)"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
  }

  /* Tab buttons smaller on mobile */
  .tab-btn {
    padding: 8px 12px !important;
    font-size: 12px !important;
    flex-shrink: 0;
  }
}

/* ─────────────────────────────────────────
   RESPONSIVE — SMALL MOBILE (max 480px)
───────────────────────────────────────── */
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-value { font-size: 16px; }
  .kpi-label { font-size: 10px; }
  .kpi-icon { width: 32px; height: 32px; }

  .page-content { padding: 12px 10px; }

  .btn { padding: 7px 12px; font-size: 12px; }
  .btn-lg { padding: 10px 18px; font-size: 14px; }

  /* Hide some header elements on very small screens */
  .header-btn[title="Notifications"],
  .header-btn[title="Toggle dark mode"] {
    display: none;
  }
}

/* ─────────────────────────────────────────
   PRINT STYLES
───────────────────────────────────────── */
@media print {
  .sidebar,
  .app-header,
  .mobile-overlay,
  .toast-container,
  .btn,
  .no-print {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .page-content {
    padding: 0 !important;
  }

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