/* ========== CSS VARIABLES – LIGHT & DARK THEMES ========== */
:root,
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --card-bg: #ffffff;
  --sidebar-bg: #f8fafc;
  --topbar-bg: rgba(255, 255, 255, 0.8);
  --hover-bg: #eef2f6;
  --active-bg: #e0e7ff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1);
  --primary: #4154f1;
  --primary-dark: #2f45c5;
  --success: #2eca6a;
  --warning: #ff771d;
  --danger: #dc3545;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #e2e8f0;
  --text-muted: #b8c9e0;
  --border-color: #3d5068;
  --card-bg: #1e293b;
  --sidebar-bg: #1e293b;
  --topbar-bg: rgba(30, 41, 59, 0.8);
  --hover-bg: #334155;
  --active-bg: #2d3a5e;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.5);
  --primary: #7b9cff;
  --primary-dark: #5b7cfa;
}

/* ========== BASE & REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

* {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.1s ease;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  margin: 0;
  min-height: 100vh;
  animation: fadeIn 0.4s ease-out;
  overflow-x: hidden;
  max-width: 100%;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ========== PAGE TRANSITIONS ========== */
.main-content {
  animation: slideUpFade 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-x: hidden;
  word-wrap: break-word;
  min-height: 60vh;
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered children animation for lists/cards */
.stagger-item {
  opacity: 0;
  animation: slideUpFade 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.2s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.3s; }
.stagger-item:nth-child(7) { animation-delay: 0.35s; }
.stagger-item:nth-child(8) { animation-delay: 0.4s; }
.stagger-item:nth-child(9) { animation-delay: 0.45s; }
.stagger-item:nth-child(10) { animation-delay: 0.5s; }

/* ========== SIDEBAR ========== */
.desktop-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  z-index: 1030;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(8px);
  box-shadow: 2px 0 12px rgba(0,0,0,0.03);
}
.sidebar-collapsed .desktop-sidebar {
  transform: translateX(-100%);
  box-shadow: none;
}

.sidebar-header { padding: 1rem 1rem 0.5rem; }
.brand-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
  transition: transform 0.2s ease;
}
.brand-icon:hover { transform: scale(1.05); }
.brand-name { color: var(--text-primary); }
.sidebar-collapse-btn {
  background: var(--bg-tertiary);
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}
.sidebar-collapse-btn:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
  transform: rotate(180deg);
}
.new-chat-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  padding: 0.6rem 1rem;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}
.new-chat-btn:hover {
  background: var(--hover-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.new-chat-btn i {
  transition: transform 0.2s ease;
}
.new-chat-btn:hover i {
  transform: rotate(90deg);
}
.sidebar-search { padding: 0.75rem 1rem; }
.sidebar-search input {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.5rem 1rem 0.5rem 2.2rem;
  font-size: 0.9rem;
  color: var(--text-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.sidebar-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(65, 84, 241, 0.15);
  outline: none;
}
.sidebar-nav-section { flex: 1; overflow-y: auto; padding: 0.5rem 0.75rem; }
.nav-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.75rem 0.75rem 0.25rem;
  font-weight: 600;
  opacity: 0.7;
}
.ai-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}
.ai-nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
  transform: scaleY(0);
  transition: transform 0.2s ease;
}
.ai-nav-link:hover::before,
.ai-nav-link.active::before {
  transform: scaleY(1);
}
.ai-nav-link i { font-size: 1.1rem; color: var(--text-muted); width: 20px; text-align: center; transition: transform 0.2s ease; }
.ai-nav-link:hover i { transform: translateX(3px); }
.ai-nav-link:hover { background: var(--hover-bg); color: var(--text-primary); transform: translateX(4px); }
.ai-nav-link.active { background: var(--active-bg); color: var(--primary); transform: translateX(4px); }
.ai-nav-link.active i { color: var(--primary); }
.recent-section { margin-top: 1rem; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s ease;
}
.recent-item:hover {
  background: var(--hover-bg);
  transform: translateX(4px);
}
.recent-item i { font-size: 0.9rem; color: var(--text-muted); flex-shrink: 0; transition: transform 0.2s; }
.recent-item:hover i { transform: scale(1.1); }
.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}
.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 12px;
  transition: background 0.2s, transform 0.2s;
}
.user-profile:hover {
  background: var(--hover-bg);
  transform: translateY(-2px);
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.user-profile:hover .user-avatar { transform: scale(1.05); }
.user-info { overflow: hidden; }
.user-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-email {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
}
.logout-btn:hover {
  color: var(--danger);
  transform: scale(1.1);
}

/* ========== TOPBAR ========== */
.topbar {
  height: 60px;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1020;
  transition: box-shadow 0.2s;
}
.topbar.scrolled {
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.page-title { color: var(--text-primary); font-size: 1.1rem; }
.mobile-menu-btn,
.desktop-menu-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 0.5rem;
  border-radius: 8px;
  transition: background 0.2s, transform 0.1s;
}
.mobile-menu-btn:hover,
.desktop-menu-btn:hover {
  background: var(--hover-bg);
}
.mobile-menu-btn:active,
.desktop-menu-btn:active {
  transform: scale(0.95);
}
.desktop-menu-btn {
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 0.2s, transform 0.3s;
}
.theme-toggle-btn:hover {
  background: var(--hover-bg);
  transform: rotate(15deg);
}
.light-icon, .dark-icon {
  font-size: 1.25rem;
  position: absolute;
  transition: opacity 0.2s, transform 0.3s;
}
[data-theme="light"] .dark-icon { display: none; }
[data-theme="dark"] .light-icon { display: none; }

/* ========== MAIN CONTENT ========== */
.main-content {
  min-height: calc(100vh - 60px);
  transition: margin-left 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.main-content-desktop { margin-left: 280px; }
.sidebar-collapsed .main-content-desktop { margin-left: 0; }

/* ========== CONTAINER & ROW FIXES ========== */
.container-fluid {
  padding-left: 1rem;
  padding-right: 1rem;
}
.row {
  margin-left: 0;
  margin-right: 0;
}

/* ========== CARDS ========== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.25s ease,
              border-color 0.2s;
  animation: cardAppear 0.5s ease-out forwards;
  overflow-x: hidden;
  word-break: break-word;
}
@keyframes cardAppear {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  animation: statPulse 0.6s ease-out;
}
@keyframes statPulse {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.stat-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  transition: color 0.2s;
}
.stat-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ========== TABLES ========== */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.modern-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 600px;
}
.modern-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}
.modern-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}
.modern-table tbody tr {
  transition: background-color 0.2s, transform 0.2s;
}
.modern-table tbody tr:hover {
  background-color: var(--hover-bg);
  transform: scale(1.002);
}
.modern-table tbody tr:last-child td { border-bottom: none; }

/* Bootstrap tables adaptation */
.table {
  color: var(--text-primary);
  border-color: var(--border-color);
}
.table-hover tbody tr:hover {
  background-color: var(--hover-bg);
  color: var(--text-primary);
}
.table-dark {
  background-color: #1e293b;
  color: #f8fafc;
}
[data-theme="dark"] .table-dark {
  background-color: #0f172a;
}

/* ========== MOBILE CARD LIST ========== */
.list-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  animation: cardAppear 0.4s ease-out;
  overflow-x: hidden;
  word-break: break-word;
}
.list-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.list-card-title { font-weight: 600; color: var(--text-primary); }
.list-card-meta { font-size: 0.85rem; color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 0.75rem; }
.list-card { color: var(--text-primary); }
.list-card .small, .list-card small { color: var(--text-secondary); }

/* ========== FORMS ========== */
.form-floating-custom {
  position: relative;
  margin-bottom: 1.5rem;
}
.form-floating-custom input,
.form-floating-custom select,
.form-floating-custom textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.form-floating-custom input:focus,
.form-floating-custom select:focus,
.form-floating-custom textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(65, 84, 241, 0.1);
  outline: none;
  transform: scale(1.01);
}
.form-floating-custom label {
  position: absolute;
  left: 1rem;
  top: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  background: transparent;
  padding: 0 0.25rem;
}
.form-floating-custom input:focus ~ label,
.form-floating-custom input:not(:placeholder-shown) ~ label,
.form-floating-custom select:focus ~ label,
.form-floating-custom textarea:focus ~ label,
.form-floating-custom textarea:not(:placeholder-shown) ~ label {
  top: -0.5rem;
  left: 0.75rem;
  font-size: 0.75rem;
  color: var(--primary);
  background: var(--bg-primary);
  font-weight: 600;
}

/* Buttons */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(65, 84, 241, 0.25);
}

/* ========== INFO LIST ========== */
.info-list { list-style: none; padding: 0; margin: 0; }
.info-list li {
  display: flex;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.2s;
  flex-wrap: wrap;
}
.info-list li:hover {
  background: var(--hover-bg);
  padding-left: 0.5rem;
  border-radius: 8px;
}
.info-list li:last-child { border-bottom: none; }
.info-list .label { width: 120px; color: var(--text-muted); font-size: 0.85rem; }
.info-list .value { flex: 1; color: var(--text-primary); font-weight: 500; word-break: break-word; }

/* ========== BOTTOM NAV ========== */
.bottom-nav {
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding-bottom: env(safe-area-inset-bottom);
  transition: transform 0.3s;
}
.bottom-nav-inner { display: flex; justify-content: space-around; padding: 0.5rem 0; }
.bottom-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  background: none;
  border: none;
  padding: 0.25rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 12px;
}
.bottom-link i {
  font-size: 1.4rem;
  margin-bottom: 0.2rem;
  transition: transform 0.2s;
}
.bottom-link:hover {
  color: var(--primary);
  transform: translateY(-3px);
}
.bottom-link:hover i { transform: scale(1.1); }
.bottom-link.active { color: var(--primary); }

/* ========== OFFCANVAS ========== */
.offcanvas {
  background: var(--sidebar-bg);
  color: var(--text-primary);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.offcanvas-header { background: var(--primary); color: white; }
.offcanvas .nav-link {
  color: var(--text-secondary);
  border-radius: 10px;
  margin: 0 0.5rem;
  transition: all 0.2s;
}
.offcanvas .nav-link:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
  transform: translateX(5px);
}
.offcanvas .nav-link.active {
  background: var(--active-bg);
  color: var(--primary);
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  animation: fadeIn 0.6s;
}
.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.6;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ========== LOADING SPINNER ========== */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== DARK MODE OVERRIDES ========== */
[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-body-secondary {
  color: var(--text-muted) !important;
}
[data-theme="dark"] .text-dark {
  color: var(--text-primary) !important;
}
[data-theme="dark"] .bg-light,
[data-theme="dark"] .bg-white {
  background-color: var(--bg-secondary) !important;
}
[data-theme="dark"] .border-light {
  border-color: var(--border-color) !important;
}

/* Helper class for theme-aware tertiary background */
.bg-body-tertiary {
  background-color: var(--bg-tertiary);
}

/* Internal note styling */
.internal-note {
  background: rgba(255, 193, 7, 0.15);
  border-radius: 12px;
  padding: 1rem;
}
[data-theme="dark"] .internal-note {
  background: rgba(255, 193, 7, 0.25);
}

/* Print styles */
@media print {
  * {
    background-color: white !important;
    color: black !important;
    border-color: #ccc !important;
    box-shadow: none !important;
  }
  .sidebar, .topbar, .bottom-nav, .page-header .btn, .btn, form, .offcanvas, .theme-toggle-btn {
    display: none !important;
  }
  .main-content-desktop { margin-left: 0 !important; }
  .card { break-inside: avoid; }
}

/* ========== RESPONSIVE OVERRIDES ========== */
@media (min-width: 1400px) {
  .container-fluid { padding-left: 2rem; padding-right: 2rem; }
  .stat-value { font-size: 2.25rem; }
}
@media (min-width: 768px) and (max-width: 991.98px) {
  .row-cols-md-4 > * { flex: 0 0 50%; max-width: 50%; }
  .stat-value { font-size: 1.75rem; }
  .stat-card { padding: 1.25rem; }
  .modern-table td, .modern-table th { padding: 0.75rem 0.6rem; font-size: 0.875rem; }
}
@media (max-width: 991.98px) {
  .desktop-sidebar { display: none !important; }
  .main-content-desktop { margin-left: 0 !important; }
  .topbar { height: 56px; }
  .page-title { font-size: 1rem; }
  .container-fluid { padding-left: 0.75rem; padding-right: 0.75rem; }
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }
  .page-header h1 { font-size: 1.4rem; margin-bottom: 0; }
  .page-header .d-flex { justify-content: flex-start; flex-wrap: wrap; gap: 0.5rem; }
  .page-breadcrumb { font-size: 0.8rem; }
  .card { border-radius: 12px; margin-bottom: 1rem; }
  .card-body { padding: 0.875rem; }
  .card-header { padding: 0.75rem 1rem; }
  .stat-card { padding: 1rem; border-radius: 12px; }
  .stat-value { font-size: 1.6rem; }
  .stat-label { font-size: 0.75rem; }
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; }
  .modern-table { min-width: 500px; }
  .modern-table td, .modern-table th { padding: 0.65rem 0.75rem; }
  .list-card { padding: 0.875rem; border-radius: 12px; margin-bottom: 0.625rem; }
  .list-card-title { font-size: 0.95rem; }
  .list-card-meta { font-size: 0.8rem; gap: 0.5rem; }
  .btn { min-height: 38px; }
  .btn-sm { min-height: 32px; font-size: 0.8rem; }
  .card-body .row.g-2 { gap: 0.5rem !important; }
  .card-body .row.g-2 .col-auto { flex: 1 1 auto; }
  .card-body .row.g-2 input.form-control,
  .card-body .row.g-2 select.form-select { width: 100%; }
  .form-floating-custom input,
  .form-floating-custom select,
  .form-floating-custom textarea { font-size: 1rem; }
  .offcanvas .nav-link { padding: 0.65rem 1rem; font-size: 0.95rem; }
  .bottom-nav { padding-bottom: max(env(safe-area-inset-bottom), 4px); }
  .bottom-link { font-size: 0.65rem; padding: 0.3rem 0.5rem; }
  .bottom-link i { font-size: 1.3rem; }
  .ai-nav-link:hover, .ai-nav-link.active,
  .recent-item:hover, .offcanvas .nav-link:hover { transform: none !important; }
  .ai-nav-link:hover i { transform: translateX(2px); }
  .card:hover { transform: translateY(-2px) !important; box-shadow: var(--shadow-md) !important; }
  .stat-card:hover { transform: translateY(-2px) !important; }
  .btn-primary:hover, .new-chat-btn:hover { transform: translateY(-1px); }
  .list-card:hover { transform: translateY(-2px); }
  .info-list .label { width: 100px; font-size: 0.8rem; }
}
@media (max-width: 575.98px) {
  .stat-card { padding: 0.875rem; }
  .stat-value { font-size: 1.4rem; }
  .page-title { font-size: 0.95rem; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .list-card { padding: 0.75rem; }
  .card-body .row.g-2 .col-auto { width: 100%; }
  .list-card .badge { font-size: 0.7rem; }
  .page-header .btn { width: 100%; justify-content: center; }
  .bottom-nav-inner { padding: 0.4rem 0; }
}
@media (min-width: 992px) {
  .bottom-nav { display: none !important; }
  .sidebar-collapsed .main-content-desktop { margin-left: 0; }
}

/* Utilities */
.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.overflow-auto { overflow: auto; }
.w-100 { width: 100%; }
img, video, iframe, embed, object { max-width: 100%; height: auto; }
*, *::before, *::after { box-sizing: border-box; }