/* ========================================
   THEME SYSTEM - Light & Dark Mode
   ======================================== */

/* Prevent FOUC (Flash of Unstyled Content) */
html:not([data-theme]) {
  visibility: hidden;
}

html[data-theme] {
  visibility: visible;
}

:root {
  /* Light Mode Colors */
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e9ecef;
  --text-primary: #111111;
  --text-secondary: #333333;
  --text-muted: #555555;
  --border-color: #dee2e6;
  --card-bg: rgba(255, 255, 255, 0.7);
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(0, 0, 0, 0.13);
  --sidebar-bg: #1a1a2e;
  --sidebar-text: #ffffff;
  --orb-1: rgba(102, 126, 234, 0.6);
  --orb-2: rgba(118, 75, 162, 0.6);
  --orb-3: rgba(77, 171, 247, 0.6);
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-strong: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
  /* Dark Mode Colors */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #9ca3af; /* Brighter muted text for better visibility in dark mode */
  --border-color: #30363d;
  --card-bg: rgba(22, 27, 34, 0.7);
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --sidebar-bg: #0d1117;
  --sidebar-text: #e6edf3;
  --orb-1: rgba(102, 126, 234, 0.4);
  --orb-2: rgba(118, 75, 162, 0.4);
  --orb-3: rgba(77, 171, 247, 0.4);
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-strong: rgba(0, 0, 0, 0.5);
}

html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
  position: relative;
  overflow-x: hidden;
}

/* Animated Background Orbs */
.orbs-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: float 20s infinite ease-in-out;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: var(--orb-1);
  top: -10%;
  left: -10%;
  animation-duration: 25s;
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: var(--orb-2);
  bottom: -10%;
  right: -10%;
  animation-duration: 30s;
  animation-delay: -5s;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: var(--orb-3);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-duration: 35s;
  animation-delay: -10s;
}

@keyframes float {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(50px, 100px) scale(1.1);
  }
  50% {
    transform: translate(-30px, 50px) scale(0.9);
  }
  75% {
    transform: translate(80px, -70px) scale(1.05);
  }
}

/* Frosted Glass Effect */
.glass,
.glass-card {
  background: var(--card-bg) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border) !important;
  box-shadow: 0 8px 32px 0 var(--shadow);
}

.glass-strong {
  background: var(--card-bg) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border) !important;
  box-shadow: 0 8px 32px 0 var(--shadow-strong);
}

/* Card Hover Effects */
.glass:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 40px 0 var(--shadow-strong);
  border-color: var(--primary) !important;
  transition: all 0.3s ease;
}

.card.glass {
  transition: all 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 2px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1050;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px var(--shadow);
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px var(--shadow-strong);
}

.theme-toggle i {
  font-size: 1.5rem;
  color: var(--text-primary);
}

/* --- Global button shape (app-wide consistency) ---
   Standalone buttons (form submits, page actions, modal footers) previously
   used Bootstrap's default 0.375rem radius while toolbar/page-head buttons
   were rounded to 0.7rem — so the same button looked different depending on
   where it sat. Standardise the rounded, medium-weight look everywhere. */
.btn {
  border-radius: 0.7rem;
  font-weight: 600;
}

.btn-sm {
  border-radius: 0.55rem;
}

.btn-lg {
  border-radius: 0.85rem;
}

/* Keep grouped buttons sharing their flush inner edges */
.btn-group > .btn:not(:first-child),
.btn-group > .btn:not(:last-child) {
  border-radius: 0;
}
.btn-group > .btn:first-child {
  border-top-left-radius: 0.7rem;
  border-bottom-left-radius: 0.7rem;
}
.btn-group > .btn:last-child {
  border-top-right-radius: 0.7rem;
  border-bottom-right-radius: 0.7rem;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* Bootstrap Text Utilities - Override for Theme Support */
.text-secondary {
  color: var(--text-secondary) !important;
}

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

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

.small, small {
  color: var(--text-secondary);
}

/* Headings and Text Color Override */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--text-primary);
}

p {
  color: var(--text-primary);
}

/* Form Controls with Theme Support */
.form-control, .form-select {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
  transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-color: #4dabf7 !important;
  box-shadow: 0 0 0 0.2rem rgba(77, 171, 247, 0.25);
}

.form-label {
  color: var(--text-primary);
}

/* Form Text (Help Text) - Make visible in dark mode */
.form-text {
  color: var(--text-secondary) !important;
}

/* Placeholder Text - Make visible in all modes */
.form-control::placeholder,
.form-select::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-secondary) !important;
  opacity: 0.7;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--text-secondary);
  text-align: end;
  opacity: 0.7;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
  opacity: 0.8;
}

/* Bootstrap text-muted override for better visibility in dark mode */
.text-muted {
  color: var(--text-muted) !important;
}

/* Tables with Theme Support and Frosted Glass Effect */
.table {
  color: var(--text-primary) !important;
  background: transparent !important;
  border-color: var(--border-color) !important;
  --bs-table-bg: transparent !important;
  --bs-table-striped-bg: transparent !important;
}

/* Table Header with Frosted Glass */
.table thead th,
.table-dark thead th {
  background: var(--card-bg) !important;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  color: var(--text-primary) !important;
  border-color: var(--glass-border) !important;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  padding: 1rem 0.75rem;
  box-shadow: 0 2px 8px var(--shadow);
  --bs-table-bg: transparent !important;
}

/* Table Body Cells with Frosted Glass */
.table tbody td, .table tbody th {
  background: var(--card-bg) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-color: var(--glass-border) !important;
  color: var(--text-primary) !important;
  padding: 0.75rem;
}

/* Table Rows */
.table tbody tr {
  background: transparent !important;
  transition: all 0.2s ease;
}

/* Striped Tables - Override Bootstrap white background */
.table-striped > tbody > tr:nth-of-type(odd) > * {
  background: var(--glass-bg) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  --bs-table-accent-bg: transparent !important;
}

.table-striped > tbody > tr:nth-of-type(even) > * {
  background: var(--card-bg) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Table Hover Effect */
.table-hover > tbody > tr:hover > * {
  background: var(--bg-tertiary) !important;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  transform: translateX(2px);
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px var(--shadow);
}

/* Table Wrapper for Glass Effect */
.table-responsive {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 0.75rem;
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 16px var(--shadow);
  padding: 0.5rem;
  overflow: hidden;
}

.table-responsive .table {
  margin-bottom: 0;
}

/* Table Borders */
.table-bordered > :not(caption) > * > * {
  border-color: var(--glass-border) !important;
}

/* Bootstrap Background Color Overrides for Theme Support */
.bg-light {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
}

.bg-dark {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
}

.bg-white {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
}

/* Badge with bg-white - Keep good contrast */
.badge.bg-white {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color);
}

/* Badge text colors to ensure visibility */
.badge.text-primary {
  color: #4dabf7 !important;
}

/* List Group Items with Theme Support */
.list-group-item.bg-white {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}

/* Card Header Overrides */
.card-header {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
  border-color: var(--glass-border) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.card-header.bg-primary,
.card-header.bg-success,
.card-header.bg-info,
.card-header.bg-warning,
.card-header.bg-danger {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.card-footer {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
  border-color: var(--glass-border) !important;
}

/* Modals with Glass Effect */
.modal-content {
  background: var(--card-bg) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border) !important;
  color: var(--text-primary);
}

.modal-header, .modal-footer {
  border-color: var(--border-color);
}

.modal-title {
  color: var(--text-primary);
}

/* Accordions with Theme Support */
.accordion {
  --bs-accordion-bg: transparent;
  --bs-accordion-color: var(--text-primary);
  --bs-accordion-border-color: var(--glass-border);
  --bs-accordion-btn-color: var(--text-primary);
  --bs-accordion-btn-bg: var(--card-bg);
  --bs-accordion-active-color: var(--text-primary);
  --bs-accordion-active-bg: var(--bg-tertiary);
  --bs-accordion-btn-focus-border-color: var(--accent-primary);
  --bs-accordion-btn-focus-box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.2);
}

.accordion-item {
  background: var(--card-bg) !important;
  border: 1px solid var(--glass-border) !important;
  color: var(--text-primary);
}

.accordion-button {
  background: var(--card-bg) !important;
  color: var(--text-primary) !important;
}

.accordion-button:not(.collapsed) {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
  box-shadow: none;
}

.accordion-button:focus {
  box-shadow: none;
  border-color: var(--glass-border);
}

.accordion-body {
  background: var(--card-bg) !important;
  color: var(--text-primary);
}

[data-theme="dark"] .accordion-button::after {
  filter: invert(1) grayscale(1);
}

/* List Groups with Glass Effect */
.list-group {
  background: transparent;
}

.list-group-item {
  background: var(--card-bg) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-color: var(--border-color) !important;
  color: var(--text-primary);
}

.list-group-item:hover {
  background: var(--bg-tertiary) !important;
}

/* Alerts with Theme Support */
.alert {
  border-color: var(--border-color);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Canvas and Chart Container */
canvas {
  background: transparent !important;
}

/* Override inline background styles */
[style*="background"] {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Mobile-First Responsive Improvements */
/* Card Spacing with Glass Effect */
.card {
  margin-bottom: 1rem;
  background: var(--card-bg) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border) !important;
  box-shadow: 0 4px 16px var(--shadow);
  transition: all 0.3s ease;
  color: var(--text-primary);
}

.card:hover {
  box-shadow: 0 8px 24px var(--shadow-strong);
  transform: translateY(-2px);
}

.card-body {
  color: var(--text-primary);
}

.card-title {
  color: var(--text-primary) !important;
}

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

.card-text {
  color: var(--text-secondary);
}

/* Bootstrap Badges with Theme Support */
.badge {
  color: #fff !important;
}

/* Allow text-dark to override white on light-background badges */
.badge.text-dark {
  color: #212529 !important;
}

/* Custom purple badge */
.bg-purple {
  background-color: #6f42c1 !important;
  color: #fff !important;
}

/* Notification Badge - Only show when it has content */
.badge.rounded-pill:empty {
  display: none !important;
}

/* Remove list bullet/dot from notification nav-item */
.nav-item.dropdown {
  list-style: none !important;
}

/* Remove Bootstrap dropdown toggle indicator (caret/dot) but keep the bell icon */
#notificationDropdown::after {
  display: none !important;
}

/* Ensure no indicators on the nav-link wrapper */
#notificationDropdown.nav-link::after {
  content: none !important;
  display: none !important;
}

@media (min-width: 768px) {
  .card {
    margin-bottom: 1.5rem;
  }
}

/* Button Spacing in Containers */
.btn-group .btn,
.d-flex .btn,
.d-grid .btn {
  margin: 0.25rem;
}

@media (max-width: 767px) {
  .btn-group {
    flex-direction: column;
    width: 100%;
  }
  
  .btn-group .btn {
    margin-bottom: 0.5rem;
  }
}

/* Table Responsive Improvements */
.table-responsive {
  margin-bottom: 1rem;
}

/* Card Body Padding on Mobile */
@media (max-width: 575px) {
  .card-body {
    padding: 1rem 0.75rem;
  }
}

/* Row Gap for Cards */
.row.g-4 {
  row-gap: 1rem;
}

@media (min-width: 768px) {
  .row.g-4 {
    row-gap: 1.5rem;
  }
}

/* Stat Card Improvements */
.stat-card {
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

/* Mobile Container Padding */
@media (max-width: 575px) {
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

/* Button Margin Utilities */
.btn-spacing {
  margin: 0.25rem;
}

@media (max-width: 575px) {
  .btn-spacing {
    margin: 0.35rem 0;
    width: 100%;
  }
}

/* ===== SIDEBAR NAVIGATION ===== */
/* Sidebar Container with Glass Effect and Theme Support */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1040;
  transition: transform 0.3s ease-in-out, background 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 2px 0 20px var(--shadow-strong);
  border-right: 1px solid var(--glass-border);
}

/* Sidebar hidden state on mobile/tablet (drawer up to large desktop) */
@media (max-width: 1199.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
}

/* Sidebar always visible on large desktop only */
@media (min-width: 1200px) {
  .sidebar {
    transform: translateX(0);
  }
}

/* Sidebar Header */
.sidebar-header {
  padding: 1.5rem 1rem;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

.sidebar-brand {
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.3s ease;
}

.sidebar-brand i {
  font-size: 1.5rem;
  color: #4dabf7;
  transition: color 0.3s ease;
}

.sidebar-brand:hover {
  color: #4dabf7;
}

/* Close button for mobile/tablet */
.sidebar-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  display: none;
  opacity: 0.7;
  transition: opacity 0.2s, color 0.3s ease;
}

.sidebar-close:hover {
  opacity: 1;
  color: #4dabf7;
}

@media (max-width: 1199.98px) {
  .sidebar-close {
    display: block;
  }
}

/* Sidebar Navigation */
.sidebar-nav {
  padding: 0.75rem 0 1rem;
}

.nav-section {
  margin-bottom: 0.35rem;
}

/* Section header doubles as a collapsible toggle */
.nav-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  color: var(--text-secondary);
  font-size: 0.69rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0.55rem 1.15rem 0.4rem;
  margin: 0;
  font-weight: 700;
  background: transparent;
  border: none;
  cursor: pointer;
  user-select: none;
  text-align: left;
  opacity: 0.95;
  transition: color 0.2s ease;
}

/* Coloured marker dot before each section heading */
.nav-section-title::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--section-accent, #4dabf7);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--section-accent, #4dabf7) 22%, transparent);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-section-title:hover {
  color: var(--section-accent, var(--text-primary));
}

.nav-section-title:hover::before {
  transform: scale(1.25);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--section-accent, #4dabf7) 30%, transparent);
}

/* Cycle a tasteful palette across sections for personality */
.nav-section:nth-of-type(6n + 1) { --section-accent: #4dabf7; }
.nav-section:nth-of-type(6n + 2) { --section-accent: #51cf66; }
.nav-section:nth-of-type(6n + 3) { --section-accent: #ffa94d; }
.nav-section:nth-of-type(6n + 4) { --section-accent: #9775fa; }
.nav-section:nth-of-type(6n + 5) { --section-accent: #22b8cf; }
.nav-section:nth-of-type(6n + 6) { --section-accent: #ff6b6b; }

.nav-section .nav-section-title {
  color: color-mix(in srgb, var(--section-accent, #4dabf7) 70%, var(--text-secondary));
}

.nav-section-title .nav-section-chevron {
  font-size: 0.65rem;
  opacity: 0.55;
  margin-left: auto;
  transition: transform 0.25s ease;
}

.nav-section.collapsed .nav-section-chevron {
  transform: rotate(-90deg);
}

/* Collapsible items wrapper (created by JS) */
.nav-section-items {
  overflow: hidden;
  transition: max-height 0.28s ease;
}

.nav-section.collapsed .nav-section-items {
  max-height: 0 !important;
}

.sidebar-nav .nav-link {
  position: relative;
  color: var(--text-primary);
  opacity: 0.85;
  margin: 0.12rem 0.6rem;
  padding: 0.6rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  border-radius: 0.7rem;
  font-size: 0.9rem;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.sidebar-nav .nav-link i {
  font-size: 1.05rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar-nav .nav-link:hover {
  background: var(--glass-bg);
  opacity: 1;
  color: var(--text-primary);
  transform: translateX(2px);
}

.sidebar-nav .nav-link.active {
  opacity: 1;
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, #4dabf7, #667eea);
  box-shadow: 0 4px 14px rgba(77, 171, 247, 0.35);
}

.sidebar-nav .nav-link.active i {
  opacity: 1;
}

/* Keep gradient-badge pills readable on the active (filled) row */
.sidebar-nav .nav-link.active .badge {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* User Info Section */
.sidebar-user {
  padding: 1rem;
  border-top: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  margin-top: auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
  transition: color 0.3s ease;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}

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

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Kebab account menu in the sidebar footer */
.user-menu-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 0.6rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.user-menu-btn:hover,
.user-menu-btn[aria-expanded="true"] {
  background: var(--card-bg);
  color: var(--text-primary);
  border-color: var(--glass-border);
}

/* Account menu — bottom-sheet popup (rendered outside the sidebar) */
.account-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1059;
  background: transparent;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease, background 0.2s ease;
}

.account-sheet-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.account-sheet {
  position: fixed;
  left: 1rem;
  bottom: 5rem;
  z-index: 1060;
  width: 240px;
  max-width: calc(100vw - 2rem);
  background: var(--bg-secondary);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-color);
  border-radius: 0.9rem;
  box-shadow: 0 14px 44px var(--shadow-strong);
  padding: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.98);
  transform-origin: bottom left;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.account-sheet.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.account-sheet-handle {
  display: none;
}

.account-sheet-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.4rem;
}

.account-sheet-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.6rem;
  border-radius: 0.55rem;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.9rem;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.account-sheet-item:hover {
  background: var(--glass-bg);
}

.account-sheet-item.text-danger {
  color: #fa5252 !important;
}

.account-sheet-item i {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.account-sheet form {
  margin: 0;
}

/* On phones, become a true bottom sheet that slides up with a dimmed backdrop */
@media (max-width: 575.98px) {
  .account-sheet-backdrop.show {
    background: rgba(0, 0, 0, 0.45);
  }

  .account-sheet {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 1.1rem 1.1rem 0 0;
    padding: 0.5rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transform-origin: bottom center;
  }

  .account-sheet.show {
    transform: translateY(0);
  }

  .account-sheet-handle {
    display: block;
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-color);
    margin: 0.15rem auto 0.7rem;
  }

  .account-sheet-item {
    padding: 0.8rem 0.6rem;
  }
}

/* Main Content Wrapper */
.main-wrapper {
  display: flex;
  min-height: 100vh;
}

/* 1. The Main Wrapper acts as a column - takes full viewport height */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* Takes up full height of screen */
  transition: margin-left 0.3s ease-in-out;
}

/* Adjust main content margin on large desktop only */
@media (min-width: 1200px) {
  .main-content {
    margin-left: 260px;
  }
}

/* ===== ICON RAIL (collapsed sidebar that expands on hover) ===== */
@media (min-width: 1200px) {
  /* Collapsed rail width gives the content canvas more room */
  .sidebar.mini {
    width: 76px;
  }

  body.sidebar-mini .main-content {
    margin-left: 76px;
  }

  /* Expand to full width on hover, floating over the content */
  .sidebar.mini:hover {
    width: 260px;
    box-shadow: 6px 0 34px var(--shadow-strong);
  }

  /* Hide labels/chrome while collapsed and not hovered */
  .sidebar.mini:not(:hover) .nav-section-title,
  .sidebar.mini:not(:hover) .nav-link span,
  .sidebar.mini:not(:hover) .nav-link .badge,
  .sidebar.mini:not(:hover) .user-details,
  .sidebar.mini:not(:hover) .user-menu-btn {
    display: none;
  }

  /* Centre the icons in the rail */
  .sidebar.mini:not(:hover) .nav-link {
    justify-content: center;
    margin: 0.12rem 0.55rem;
    padding: 0.65rem 0;
  }

  .sidebar.mini:not(:hover) .nav-link:hover {
    transform: none;
  }

  .sidebar.mini:not(:hover) .user-info {
    justify-content: center;
  }

  .sidebar.mini:not(:hover) .sidebar-header {
    padding: 1.25rem 0.5rem;
    text-align: center;
  }

  .sidebar.mini:not(:hover) .sidebar-brand {
    justify-content: center;
  }

  /* The full logo doesn't fit the rail — hide it while collapsed */
  .sidebar.mini:not(:hover) .sidebar-brand img {
    display: none;
  }

  /* Every section's icons stay visible in the rail (ignore collapse state) */
  .sidebar.mini:not(:hover) .nav-section-items {
    max-height: none !important;
  }
}

/* Desktop-only button that toggles the icon rail */
.sidebar-collapse-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1.35rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-collapse-toggle:hover {
  background: var(--glass-bg);
  color: #4dabf7;
}

@media (min-width: 1200px) {
  .sidebar-collapse-toggle {
    display: inline-flex;
  }
}

/* Top Header Bar with Glass Effect */
.top-header {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 2px 8px var(--shadow);
  transition: background 0.3s ease;
}

.menu-toggle {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  color: var(--text-primary);
  display: none;
  transition: color 0.3s ease;
}

@media (max-width: 1199.98px) {
  .menu-toggle {
    display: block;
  }
}

/* Make the hamburger a proper, vertically-centred tap target */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  line-height: 1;
}

@media (max-width: 1199.98px) {
  .menu-toggle {
    display: inline-flex;
  }
}

.menu-toggle:hover {
  background: var(--glass-bg);
}

/* The notifications partial renders a raw <li> inside the header flex row.
   Neutralise list-item styling so the bell/avatar cluster stays in order. */
.top-header .nav-item {
  list-style: none;
  display: inline-flex;
  align-items: center;
  margin: 0 !important;
}

/* Unified header action buttons: the notification bell and the user avatar
   are both rendered as equal 40px circular tap targets so they read as a
   symmetric pair on mobile. */
.top-header .nav-item .nav-link,
.top-header .header-action-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  position: relative;
  color: var(--text-primary);
  transition: background 0.2s ease, color 0.2s ease;
}

.top-header .nav-item .nav-link:hover,
.top-header .header-action-btn:hover {
  background: var(--glass-bg);
}

.top-header .nav-item .nav-link i {
  font-size: 1.25rem;
  line-height: 1;
}

/* Drop Bootstrap's dropdown caret on the avatar trigger */
.top-header .header-action-btn.dropdown-toggle::after {
  display: none;
}

/* Keep the unread badge pinned to the circle's top-right corner */
.top-header .nav-item .nav-link .badge {
  top: 4px !important;
  left: auto !important;
  right: 4px !important;
  transform: translate(50%, -50%) !important;
}

/* Tighten the header on phones so the left/right clusters never collide */
@media (max-width: 575.98px) {
  .top-header {
    padding: 0.6rem 0.75rem;
  }

  .top-header .gap-3 {
    gap: 0.35rem !important;
  }

  .menu-toggle {
    margin-right: 0.4rem !important;
  }
}

/* Elegant welcome / greeting cluster in the top header */
.header-greeting-hi {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.header-greeting-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.2;
  margin-top: 0.1rem;
}

/* Theme-aware, focus-reactive header search pill */
.header-search {
  width: 260px;
  gap: 0.5rem;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.header-search:focus-within {
  border-color: #4dabf7;
  box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.15);
  background: var(--card-bg);
}

.header-search i {
  color: var(--text-muted);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.header-search input {
  border: none;
  background: transparent;
  outline: none;
  box-shadow: none;
  width: 100%;
  font-size: 0.9rem;
  color: var(--text-primary);
  padding: 0;
}

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

/* Backdrop for mobile/tablet */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1039;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* Scrollbar Styling for Sidebar */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* 2. The Content area grows to fill available space - pushes footer down */
.page-content {
  padding: 1.5rem;
  flex: 1 0 auto; /* This pushes the footer down */
  width: 100%;
}

@media (min-width: 768px) {
  .page-content {
    padding: 2rem;
  }
}

/* 3. The Footer sits naturally at the bottom - no overlap */
.app-footer {
  flex-shrink: 0;
  margin-top: auto;
  width: 100%;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}

.app-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.75rem;
}

.app-footer-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.app-footer-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 0.65rem;
  font-size: 1.05rem;
  color: #fff;
  background: linear-gradient(135deg, #4dabf7 0%, #667eea 100%);
  box-shadow: 0 4px 14px rgba(77, 171, 247, 0.35);
}

.app-footer-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.app-footer-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.app-footer-copy {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.app-footer-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.app-footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.2rem 0.1rem;
  transition: color 0.2s ease;
}

.app-footer-links a:hover {
  color: var(--accent-color);
}

.app-footer-dot {
  color: var(--text-muted);
  opacity: 0.6;
}

.app-footer-credit {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.app-footer-credit a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

.app-footer-credit a:hover {
  color: var(--accent-color);
}

.app-footer-credit a i {
  font-size: 0.7rem;
  vertical-align: baseline;
  opacity: 0.7;
}

/* Optional: Fix for Mobile Overlap */
@media (max-width: 767px) {
  .app-footer-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.25rem 1rem;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); /* clear bottom nav */
  }
}

/* ===== PUBLIC NAVBAR (Non-Authenticated Users) ===== */
/* Frosted Glass Navbar with Theme Support */
.navbar {
  background: var(--card-bg) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border) !important;
  box-shadow: 0 2px 10px var(--shadow);
  transition: all 0.3s ease;
}

.navbar-brand {
  color: var(--text-primary) !important;
  font-weight: 600;
  transition: color 0.3s ease;
}

.navbar-brand:hover {
  color: #4dabf7 !important;
}

.navbar-brand i {
  color: #4dabf7;
}

/* Navbar Links with Theme Support */
.navbar-light .navbar-nav .nav-link {
  color: var(--text-primary) !important;
  transition: color 0.3s ease;
}

.navbar-light .navbar-nav .nav-link:hover {
  color: #4dabf7 !important;
}

/* Navbar Toggler for Mobile */
.navbar-toggler {
  border-color: var(--border-color) !important;
}

.navbar-toggler-icon {
  filter: var(--text-primary);
}

[data-theme="dark"] .navbar-toggler-icon {
  filter: invert(1);
}

/* In dark mode Bootstrap's .btn-outline-dark uses a near-black border/text that
   is invisible against the dark surface until hovered. Use a light outline so
   the button reads at rest, and fill it on hover for affordance. */
[data-theme="dark"] .btn-outline-dark {
  color: var(--text-primary);
  border-color: var(--border-color);
}

[data-theme="dark"] .btn-outline-dark:hover,
[data-theme="dark"] .btn-outline-dark:focus,
[data-theme="dark"] .btn-outline-dark:active {
  color: #1a1a1a;
  background-color: #e9ecef;
  border-color: #e9ecef;
}

/* Public Footer Theme Support */
.public-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  transition: background 0.3s ease, color 0.3s ease;
}

.public-footer .footer-text {
  color: var(--text-primary);
}

.public-footer .footer-text-muted {
  color: var(--text-secondary);
}

.public-footer .footer-link {
  color: #667eea;
}

.public-footer .footer-link:hover {
  color: #764ba2;
}

.public-footer .footer-divider {
  border-color: var(--border-color);
  opacity: 0.5;
}

/* Hero Section Theme Support */
.hero-section {
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  min-height: 60vh;
  display: flex;
  align-items: center;
  transition: background 0.3s ease;
}

[data-theme="dark"] .hero-section {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.hero-section h1,
.hero-section .display-3 {
  color: var(--text-primary);
}

.hero-section p,
.hero-section .lead {
  color: var(--text-secondary);
}

/* Badge overrides for hero section */
.hero-section .badge {
  background-color: rgba(77, 171, 247, 0.2) !important;
  color: var(--text-primary) !important;
  border: 1px solid rgba(77, 171, 247, 0.3);
}

[data-theme="dark"] .hero-section .badge {
  background-color: rgba(77, 171, 247, 0.15) !important;
  color: #ffffff !important;
}

/* ===== RESPONSIVE TABLE → CARD LAYOUT (Mobile + Tablet) ===== */
/* Tables collapse into stacked cards up to the tablet breakpoint; the full
   table layout is reserved for desktop (>= 992px). */
@media (max-width: 991.98px) {
  /* Hide the table header on mobile */
  .responsive-card-table thead {
    display: none !important;
  }

  /* Hide tfoot on mobile (page totals etc) */
  .responsive-card-table tfoot {
    display: none !important;
  }

  /* Make the table and tbody block-level */
  .responsive-card-table,
  .responsive-card-table tbody {
    display: block;
    width: 100%;
  }

  /* Each row becomes a card */
  .responsive-card-table tbody tr {
    display: block;
    margin-bottom: 0.85rem;
    border-radius: 0.85rem;
    border: 1px solid var(--border-color) !important;
    background: var(--bg-secondary) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 0 4px 16px var(--shadow);
    overflow: hidden;
    padding: 0;
    transform: none !important;
  }

  .responsive-card-table tbody tr:last-child {
    margin-bottom: 0;
  }

  /* Each cell becomes a flex row with label + value */
  .responsive-card-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem !important;
    border: none !important;
    border-bottom: 1px solid var(--glass-border) !important;
    background: transparent !important;
    backdrop-filter: none !important;
    text-align: right;
    gap: 0.75rem;
    transform: none !important;
    box-shadow: none !important;
    min-height: 0;
    word-break: break-word;
  }

  .responsive-card-table tbody td:last-child {
    border-bottom: none !important;
  }

  /* The label from data-label attribute */
  .responsive-card-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    flex-shrink: 0;
    text-align: left;
    min-width: 5rem;
  }

  /* Value side of each row: group badges to the right, wrap neatly */
  .responsive-card-table tbody td[data-label="Room"],
  .responsive-card-table tbody td[data-label="Status"],
  .responsive-card-table tbody td[data-label="Activity"] {
    flex-wrap: wrap;
    row-gap: 0.35rem;
  }

  .responsive-card-table tbody td[data-label="Activity"] .d-flex {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  /* Hide empty labels (cells without data-label) */
  .responsive-card-table tbody td:not([data-label])::before,
  .responsive-card-table tbody td[data-label=""]::before {
    display: none;
  }

  /* When there's no label, let the content take full width */
  .responsive-card-table tbody td:not([data-label]),
  .responsive-card-table tbody td[data-label=""] {
    justify-content: center;
  }

  /* Actions cell - clean action bar, buttons aligned right */
  .responsive-card-table tbody td[data-label="Actions"] {
    justify-content: flex-end;
    background: transparent !important;
    padding: 0.7rem 1rem !important;
    border-radius: 0 0 0.75rem 0.75rem;
    border-top: 1px solid var(--glass-border) !important;
    gap: 0.45rem;
    flex-wrap: nowrap;
  }

  .responsive-card-table tbody td[data-label="Actions"]::before {
    display: none;
  }

  .responsive-card-table tbody td[data-label="Actions"] .d-flex {
    gap: 0.45rem !important;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .responsive-card-table tbody td[data-label="Actions"] .btn {
    width: 40px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    border-radius: 0.55rem !important;
  }

  /* Action btn-groups that carry TEXT labels (e.g. Parking: Assign / Unassign
     + icon-only Delete). Flatten the .btn-group and its nested <form> wrappers
     with display:contents so the real buttons become direct flex children of
     the Actions cell — this guarantees they sit on ONE row regardless of the
     Bootstrap .btn-group / .d-inline form markup. */
  .responsive-card-table tbody td[data-label="Actions"] .btn-group,
  .responsive-card-table tbody td[data-label="Actions"] .btn-group > form {
    display: contents !important;
  }

  /* Text action button (Assign / Unassign) = stretching pill */
  .responsive-card-table tbody td[data-label="Actions"] .btn-group > .btn,
  .responsive-card-table tbody td[data-label="Actions"] .btn-group > form > .btn {
    flex: 1 1 auto;
    width: auto !important;
    height: 42px !important;
    min-width: 0;
    padding: 0 0.9rem !important;
    white-space: nowrap;
    border-radius: 0.6rem !important;
    gap: 0.4rem;
  }

  /* Icon-only action buttons (e.g. Laundry: edit / status / delete) stay
     compact squares — never stretch. Detected by an <i> being the button's
     only child. */
  .responsive-card-table tbody td[data-label="Actions"] .btn-group > .btn:has(> i:only-child),
  .responsive-card-table tbody td[data-label="Actions"] .btn-group > form > .btn:has(> i:only-child) {
    flex: 0 0 auto;
    width: 46px !important;
    height: 42px !important;
    padding: 0 !important;
  }

  /* Trailing icon-only Delete stays a compact square */
  .responsive-card-table tbody td[data-label="Actions"] .btn-group > form.d-inline:last-child > .btn,
  .responsive-card-table tbody td[data-label="Actions"] .btn-group > form:last-child > .btn {
    flex: 0 0 auto;
    width: 46px !important;
    padding: 0 !important;
  }

  /* First cell ("Student") becomes a card header: full-width, no label,
     content left-aligned with its avatar; email allowed to fill width. */
  .responsive-card-table tbody td[data-label="Student"] {
    justify-content: flex-start;
    text-align: left;
    background: var(--glass-bg) !important;
    padding: 0.85rem 1rem !important;
  }

  .responsive-card-table tbody td[data-label="Student"]::before {
    display: none;
  }

  .responsive-card-table tbody td[data-label="Student"] .text-truncate {
    max-width: 100% !important;
  }

  /* Make the empty-state row full-width */
  .responsive-card-table tbody tr td[colspan] {
    display: block;
    text-align: center;
    border: none !important;
    box-shadow: none;
  }

  .responsive-card-table tbody tr td[colspan]::before {
    display: none;
  }

  /* Fix hover effect on card rows */
  .table-hover.responsive-card-table > tbody > tr:hover > * {
    transform: none !important;
    box-shadow: none !important;
  }

  .table-hover.responsive-card-table > tbody > tr:hover {
    box-shadow: 0 4px 16px var(--shadow) !important;
  }

  /* Conditional row colors for cards */
  .responsive-card-table tbody tr.table-danger {
    border-left: 4px solid #dc3545 !important;
  }

  .responsive-card-table tbody tr.table-secondary {
    opacity: 0.7;
    border-left: 4px solid #6c757d !important;
  }

  /* btn-group inside cards */
  .responsive-card-table .btn-group-sm > .btn {
    padding: 0.35rem 0.65rem;
  }

  /* Fix d-flex items inside card cells */
  .responsive-card-table tbody td .d-flex {
    justify-content: flex-end;
  }

  /* Table wrapper adjustments */
  .responsive-card-table + .card-footer,
  .table-responsive:has(.responsive-card-table) {
    padding: 0.5rem !important;
    border: none !important;
    background: transparent !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  /* Fix avatar circles alignment */
  .responsive-card-table tbody td .avatar-sm,
  .responsive-card-table tbody td .rounded-circle {
    margin-left: auto;
  }
}

.text-gradient { background: linear-gradient(135deg, #007bff 0%, #6610f2 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; color: transparent; }

/* ===== NATIVE BOTTOM NAVIGATION (Mobile & Tablet) ===== */
/* Hidden by default; shown below the desktop breakpoint where the sidebar
   becomes an off-canvas drawer. Gives the app a native mobile/tablet feel. */
.app-bottom-nav {
  display: none;
}

@media (max-width: 1199.98px) {
  .app-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1038;
    align-items: stretch;
    justify-content: space-around;
    gap: 0.15rem;
    padding: 0.3rem 0.4rem;
    padding-bottom: calc(0.3rem + env(safe-area-inset-bottom, 0px));
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    box-shadow: 0 -2px 16px var(--shadow);
  }

  .app-bottom-nav .bn-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.35rem 0.1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 0.65rem;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, transform 0.1s ease;
    min-width: 0;
  }

  .app-bottom-nav .bn-item i {
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.25rem 1.1rem;
    border-radius: 999px;
    transition: background 0.25s ease, color 0.2s ease;
  }

  .app-bottom-nav .bn-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-bottom-nav .bn-item:hover {
    color: var(--text-primary);
  }

  .app-bottom-nav .bn-item:hover i {
    background: var(--glass-bg);
  }

  .app-bottom-nav .bn-item:active {
    transform: scale(0.92);
  }

  .app-bottom-nav .bn-item.active {
    color: #4dabf7;
  }

  .app-bottom-nav .bn-item.active i {
    background: linear-gradient(135deg, rgba(77, 171, 247, 0.18), rgba(102, 126, 234, 0.18));
    color: #4dabf7;
    filter: drop-shadow(0 2px 6px rgba(77, 171, 247, 0.30));
  }

  /* Reserve space so content / footer never hide behind the bar */
  .main-content {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  /* Lift floating widgets (e.g. chatbot) above the bottom nav */
  .chatbot-widget,
  .chatbot-toggle,
  .theme-toggle {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* =====================================================================
   REFINED BREADCRUMB  (theme-aware, chevron separators)
   ===================================================================== */
.page-head .breadcrumb {
  margin: 0 0 0.4rem;
  padding: 0;
  background: transparent;
  font-size: 0.78rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.1rem;
}

.page-head .breadcrumb-item {
  display: inline-flex;
  align-items: center;
}

.page-head .breadcrumb-item + .breadcrumb-item {
  padding-left: 0.1rem;
}

/* Replace Bootstrap's "/" with a chevron */
.page-head .breadcrumb-item + .breadcrumb-item::before {
  content: "\F285"; /* bi-chevron-right */
  font-family: "bootstrap-icons";
  color: var(--text-muted);
  opacity: 0.6;
  font-size: 0.7rem;
  padding-right: 0.35rem;
  margin-left: 0.1rem;
}

.page-head .breadcrumb-item a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.1rem 0.35rem;
  border-radius: 0.45rem;
  transition: background 0.18s ease, color 0.18s ease;
}

.page-head .breadcrumb-item a:hover {
  color: var(--accent-color);
  background: var(--glass-bg);
}

.page-head .breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 600;
  padding: 0.1rem 0.35rem;
}

/* =====================================================================
   GLOBAL AUTO BREADCRUMB  (rendered by _Breadcrumbs.cshtml in the layout)
   Theme-aware pill bar with chevron separators — sits above page content.
   ===================================================================== */
.app-breadcrumb {
  margin: 0 0 1.15rem;
}

.app-breadcrumb-list {
  list-style: none;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.05rem;
  margin: 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  line-height: 1.2;
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.7rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  max-width: 100%;
}

.app-breadcrumb-item {
  display: inline-flex;
  align-items: center;
}

/* Chevron separator before every item except the first */
.app-breadcrumb-item + .app-breadcrumb-item::before {
  content: "\F285"; /* bi-chevron-right */
  font-family: "bootstrap-icons";
  color: var(--text-muted);
  opacity: 0.55;
  font-size: 0.65rem;
  padding: 0 0.3rem;
}

.app-breadcrumb-item a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.18rem 0.45rem;
  border-radius: 0.5rem;
  transition: background 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}

.app-breadcrumb-item a:hover {
  color: var(--accent-color);
  background: var(--bg-tertiary);
}

.app-breadcrumb-item a i {
  font-size: 0.85rem;
}

.app-breadcrumb-item.active > span {
  color: var(--text-primary);
  font-weight: 600;
  padding: 0.18rem 0.45rem;
  white-space: nowrap;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* On the smallest screens, hide the "Home" word but keep the house icon */
@media (max-width: 480px) {
  .app-breadcrumb-home-text {
    display: none;
  }
}

/* =====================================================================
   SECTIONED FORM LAYOUT  (efficient horizontal space on all devices)
   ===================================================================== */
.form-shell {
  max-width: 1080px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.form-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 18px var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Accent rail at the top of each section card */
.form-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--fc-accent, linear-gradient(135deg, #4dabf7, #667eea));
}

.form-card:hover {
  border-color: var(--fc-accent-solid, var(--glass-border));
  box-shadow: 0 8px 26px var(--shadow-strong);
}

/* Accent variants — set rail gradient + icon-chip colour */
.form-card.accent-primary { --fc-accent: linear-gradient(135deg, #4dabf7, #667eea); --fc-accent-solid: #4dabf7; }
.form-card.accent-success { --fc-accent: linear-gradient(135deg, #51cf66, #2f9e44); --fc-accent-solid: #2f9e44; }
.form-card.accent-warning { --fc-accent: linear-gradient(135deg, #ffc078, #f76707); --fc-accent-solid: #f76707; }
.form-card.accent-danger  { --fc-accent: linear-gradient(135deg, #ff8787, #f03e3e); --fc-accent-solid: #f03e3e; }
.form-card.accent-info    { --fc-accent: linear-gradient(135deg, #66d9e8, #1098ad); --fc-accent-solid: #1098ad; }
.form-card.accent-purple  { --fc-accent: linear-gradient(135deg, #b197fc, #7048e8); --fc-accent-solid: #7048e8; }
.form-card.accent-teal    { --fc-accent: linear-gradient(135deg, #38d9a9, #0ca678); --fc-accent-solid: #0ca678; }

.form-card-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.form-card-head .fc-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #fff;
  background: var(--fc-accent, linear-gradient(135deg, #4dabf7, #667eea));
  box-shadow: 0 4px 12px rgba(77, 171, 247, 0.3);
}

.form-card-head .fc-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.form-card-head .fc-sub {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.form-card-body {
  padding: 1.25rem;
}

/* Auto-packing field grid: fills available width, wraps gracefully */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem 1.25rem;
}

.field-grid .field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Force a field to take the full row */
.field-grid .span-full {
  grid-column: 1 / -1;
}

.field-grid .form-label {
  margin-bottom: 0.35rem;
  font-weight: 500;
  font-size: 0.85rem;
}

.field-grid .form-text {
  font-size: 0.75rem;
}

/* Checkbox tiles for funding/options — compact, tappable */
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.6rem;
}

.check-tile {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 0.7rem;
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.check-tile:hover {
  border-color: var(--accent-color);
}

.check-tile .form-check-input {
  margin: 0;
  flex-shrink: 0;
}

.check-tile .form-check-input:checked ~ .check-tile-label,
.check-tile:has(.form-check-input:checked) {
  border-color: var(--accent-color);
}

.check-tile .check-tile-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  margin: 0;
}

/* Sticky action bar at the bottom of the form */
.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.1rem;
  margin-top: 0.25rem;
  border-radius: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: 0 -4px 20px var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.form-actions .btn {
  border-radius: 0.7rem;
  font-weight: 600;
}

@media (max-width: 575.98px) {
  .form-card-body {
    padding: 1rem;
  }
  .form-actions {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)); /* clear bottom nav */
  }
  .form-actions .btn {
    flex: 1 1 0;
  }
}

/* =====================================================================
   MODERN UI COMPONENTS  (page headers, metric tiles, toolbars, badges)
   Reusable across admin/owner list pages for a cleaner, modern look.
   ===================================================================== */

/* --- Page header band --- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

/* Stacks an optional breadcrumb above the page title on the left side */
.page-head-titles {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.page-head .page-title {
  margin: 0;
  font-weight: 700;
  font-size: clamp(1.3rem, 2.2vw, 1.85rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.page-head .page-title .title-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.35);
}

.page-head .page-subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.page-head-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Pill buttons read more modern in toolbars */
.page-head-actions .btn,
.toolbar-card .btn {
  border-radius: 0.7rem;
  font-weight: 600;
}

@media (max-width: 575.98px) {
  .page-head .page-title .title-icon {
    width: 36px;
    height: 36px;
    font-size: 1.05rem;
  }
  .page-head-actions {
    width: 100%;
  }
  .page-head-actions .btn {
    flex: 1 1 0;
  }
}

/* --- Metric tiles (modern stat cards) --- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 992px) {
  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
  }
}

/* Six-tile layout: 2 cols mobile → 3 cols tablet → 6 cols desktop */
@media (min-width: 768px) {
  .metric-grid.cols-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (min-width: 1200px) {
  .metric-grid.cols-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* Five-tile layout: 2 cols mobile → 3 cols tablet → 5 cols desktop */
@media (min-width: 768px) {
  .metric-grid.cols-5 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (min-width: 992px) {
  .metric-grid.cols-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* Three-tile layout: 1 col mobile → 3 cols desktop */
@media (min-width: 992px) {
  .metric-grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Two-tile layout: stays 2 cols at all sizes */
.metric-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1.1rem 1.15rem;
  border-radius: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 18px var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  height: 100%;
  text-decoration: none;
  color: var(--text-primary);
}

.metric-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--tile-accent, linear-gradient(135deg, #667eea, #764ba2));
  opacity: 0.07;
  pointer-events: none;
}

a.metric-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px var(--shadow-strong);
  color: var(--text-primary);
}

.metric-tile .metric-icon {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  color: #fff;
  background: var(--tile-accent, linear-gradient(135deg, #667eea, #764ba2));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.metric-tile .metric-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.metric-tile .metric-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
  line-height: 1.2;
  order: 2;
  margin-top: 0.25rem;
  word-break: break-word;
}

.metric-tile .metric-value {
  font-size: clamp(1.15rem, 4.5vw, 1.75rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
  order: 1;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Currency / long values need a smaller, non-overflowing size */
.metric-tile.is-currency .metric-value {
  font-size: clamp(1.05rem, 3.2vw, 1.3rem);
  word-break: break-word;
}

.metric-tile .metric-subnote {
  order: 3;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.3;
}

@media (max-width: 575.98px) {
  .metric-tile {
    padding: 0.85rem 0.9rem;
    gap: 0.6rem;
  }
  .metric-tile .metric-icon {
    width: 40px;
    height: 40px;
    font-size: 1.15rem;
    border-radius: 11px;
  }
  .metric-tile .metric-value {
    font-size: clamp(1.05rem, 4vw, 1.3rem);
  }
  .metric-tile.is-currency .metric-value {
    font-size: clamp(0.95rem, 3.6vw, 1.15rem);
  }
  /* On small phones, currency tiles stack the icon above the amount so long
     values (e.g. "R 20,750.00") get the full tile width and never break mid-number */
  .metric-tile.is-currency {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .metric-tile.is-currency .metric-value {
    overflow-wrap: normal;
    word-break: keep-all;
    white-space: nowrap;
  }
  .metric-tile .metric-label {
    font-size: 0.62rem;
  }
}

/* Accent variants */
.metric-tile.accent-primary { --tile-accent: linear-gradient(135deg, #4dabf7, #667eea); }
.metric-tile.accent-success { --tile-accent: linear-gradient(135deg, #2fb380, #51cf66); }
.metric-tile.accent-danger  { --tile-accent: linear-gradient(135deg, #ff6b6b, #ee5a6f); }
.metric-tile.accent-info    { --tile-accent: linear-gradient(135deg, #3bc9db, #22b8cf); }
.metric-tile.accent-warning { --tile-accent: linear-gradient(135deg, #ffa94d, #f59f00); }
.metric-tile.accent-purple  { --tile-accent: linear-gradient(135deg, #9775fa, #7950f2); }

/* Active/selected state for clickable filter tiles */
.metric-tile.is-active {
  box-shadow: 0 0 0 2px var(--text-primary), 0 6px 22px var(--shadow-strong);
}

/* --- KPI chips (compact stat tiles inside panel-cards) --- */
.kpi-chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.kpi-chip {
  --chip-accent: #667eea;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.15rem;
  padding: 0.95rem 0.75rem;
  border-radius: 0.85rem;
  background: color-mix(in srgb, var(--chip-accent) 9%, var(--card-bg));
  border: 1px solid color-mix(in srgb, var(--chip-accent) 28%, transparent);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.kpi-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--shadow);
}
.kpi-chip-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.2;
}
.kpi-chip-value {
  font-size: clamp(1.25rem, 4vw, 1.7rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.kpi-chip-note {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.2;
}
.kpi-chip.accent-primary { --chip-accent: #4dabf7; }
.kpi-chip.accent-success { --chip-accent: #2fb380; }
.kpi-chip.accent-danger  { --chip-accent: #ee5a6f; }
.kpi-chip.accent-info    { --chip-accent: #22b8cf; }
.kpi-chip.accent-warning { --chip-accent: #f59f00; }
.kpi-chip.accent-purple  { --chip-accent: #7950f2; }

/* --- Landing-page info / contact cards --- */
.lc-card {
  position: relative;
  display: flex;
  gap: 0.9rem;
  padding: 1.1rem 1.15rem;
  border-radius: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 18px var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  height: 100%;
}

.lc-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--tile-accent, linear-gradient(135deg, #667eea, #764ba2));
  opacity: 0.06;
  pointer-events: none;
}

.lc-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px var(--shadow-strong);
}

.lc-card .lc-icon {
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  background: var(--tile-accent, linear-gradient(135deg, #667eea, #764ba2));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.lc-card .lc-body {
  position: relative;
  min-width: 0;
  flex: 1;
}

.lc-card .lc-title {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.25;
}

.lc-card .lc-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.15rem 0 0;
  line-height: 1.3;
}

.lc-card .lc-value {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  margin: 0.2rem 0 0;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

/* Contact link rows (phone / email) */
.lc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.lc-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
  padding: 0.32rem 0.65rem;
  border-radius: 0.6rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.82rem;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.lc-link:hover {
  background: var(--accent-primary);
  color: #fff;
}

.lc-link i {
  opacity: 0.7;
  flex-shrink: 0;
}

.lc-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Code-style value chip (WiFi password, access codes) */
.lc-code {
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0.25rem 0.65rem;
  border-radius: 0.5rem;
  font-family: var(--bs-font-monospace, ui-monospace, monospace);
  font-size: 0.9rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px dashed var(--glass-border);
}

.lc-card.accent-danger  { --tile-accent: linear-gradient(135deg, #ff6b6b, #ee5a6f); }
.lc-card.accent-info    { --tile-accent: linear-gradient(135deg, #3bc9db, #22b8cf); }
.lc-card.accent-warning { --tile-accent: linear-gradient(135deg, #ffa94d, #f59f00); }
.lc-card.accent-primary { --tile-accent: linear-gradient(135deg, #4dabf7, #667eea); }
.lc-card.accent-success { --tile-accent: linear-gradient(135deg, #2fb380, #51cf66); }
.lc-card.accent-purple  { --tile-accent: linear-gradient(135deg, #9775fa, #7950f2); }
.lc-card.accent-secondary { --tile-accent: linear-gradient(135deg, #adb5bd, #868e96); }

/* Status pill — compact coloured chip */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.status-pill.status-info    { background: rgba(34, 184, 207, 0.16);  color: #1098ad; }
.status-pill.status-warning { background: rgba(245, 159, 0, 0.16);   color: #d9820a; }
.status-pill.status-success { background: rgba(47, 179, 128, 0.16);  color: #2b9a6e; }
.status-pill.status-danger  { background: rgba(238, 90, 111, 0.16);  color: #e64966; }
.status-pill.status-primary { background: rgba(77, 171, 247, 0.16);  color: #3b8ee0; }
.status-pill.status-secondary { background: rgba(134, 142, 150, 0.18); color: #868e96; }

[data-theme="dark"] .status-pill.status-info    { color: #66d9e8; }
[data-theme="dark"] .status-pill.status-warning { color: #ffc078; }
[data-theme="dark"] .status-pill.status-success { color: #69db7c; }
[data-theme="dark"] .status-pill.status-danger  { color: #ff8787; }
[data-theme="dark"] .status-pill.status-primary { color: #74c0fc; }
[data-theme="dark"] .status-pill.status-secondary { color: #adb5bd; }

/* --- Toolbar card (search / filter bar) --- */
.toolbar-card {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  box-shadow: 0 4px 18px var(--shadow);
  margin-bottom: 1.25rem;
}

.toolbar-card .form-control,
.toolbar-card .form-select {
  border-radius: 0.7rem;
}

/* --- Softer, pill-shaped badges in list rows --- */
.responsive-card-table .badge,
.list-card .badge {
  font-weight: 600;
  border-radius: 0.5rem;
  padding: 0.34em 0.6em;
}

/* =====================================================================
   PROPERTY CARDS  (Owner › Buildings portfolio grid)
   ===================================================================== */
.property-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 4px 18px var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.property-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(135deg, #4dabf7, #667eea);
}

.property-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px var(--shadow-strong);
  border-color: color-mix(in srgb, #4dabf7 40%, var(--glass-border));
}

.property-card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1.15rem 1.15rem 0.85rem;
}

.property-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  background: linear-gradient(135deg, #4dabf7, #667eea);
  box-shadow: 0 6px 16px rgba(77, 171, 247, 0.35);
}

.property-head-text {
  flex: 1;
  min-width: 0;
}

.property-name {
  margin: 0 0 0.15rem;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.property-address {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.property-own-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.32em 0.6em;
  border-radius: 0.5rem;
  color: #fff;
}

.property-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0 1.15rem 0.6rem;
}

.property-stats .pstat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6rem 0.25rem;
  border-radius: 0.7rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.property-stats .pstat-value {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.property-stats .pstat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.property-occ {
  padding: 0.35rem 1.15rem 0.9rem;
}

.property-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.8rem 1.15rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.property-foot small {
  color: var(--text-muted);
  font-size: 0.74rem;
}

/* --- Rounded action buttons in list rows --- */
.responsive-card-table .btn-sm,
.list-card .btn-sm {
  border-radius: 0.6rem;
}

/* Give the desktop list table a bit more breathing room */
@media (min-width: 768px) {
  .responsive-card-table > tbody > tr > td,
  .responsive-card-table > thead > tr > th {
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
  }

  .responsive-card-table > thead > tr > th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 1px solid var(--glass-border);
  }
}

/* --- Table card surface (GLOBAL — every portal) ---
   .responsive-card-table sits on ~70 tables across Admin/Owner/Student/
   Catering/Maintenance/Manager/Reports/Laundry. These rules give every one
   the same clean container, so the look is consistent app-wide on all devices.

   Mobile & tablet: each row becomes its own solid card, so the outer card
   (and any inner card-body / table-responsive wrapper) is flattened to avoid
   an ugly glass-on-glass / card-on-container stack. This range MUST match the
   table→card breakpoint (max-width: 991.98px) above. */
@media (max-width: 991.98px) {
  .card:has(.responsive-card-table),
  .card:has(.responsive-card-table) > .card-body {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .card:has(.responsive-card-table) {
    overflow: visible !important;
    border-radius: 0 !important;
  }

  /* Let the stacked row-cards use the full width */
  .card:has(.responsive-card-table) > .card-body {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .card:has(.responsive-card-table) .table-responsive {
    overflow: visible !important;
    padding: 0 !important;
  }
}

/* Tablet & desktop: ONE solid, rounded container per table. The frosted blur
   over the gradient looked muddy behind dense tables, and the inner
   .table-responsive carried its own bg/border/shadow which produced a second
   nested "box". Collapse everything to a single clean rounded surface.
   Starts at 992px — below that the table renders as stacked row-cards. */
@media (min-width: 992px) {
  .card:has(.responsive-card-table) {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--glass-border) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 0 2px 10px var(--shadow) !important;
    border-radius: 1rem !important;
    overflow: hidden !important; /* round the table's outer edges too */
  }

  /* Kill the generic card hover-lift for table containers */
  .card:has(.responsive-card-table):hover {
    transform: none !important;
    box-shadow: 0 2px 10px var(--shadow) !important;
  }

  /* Flatten the inner scroller so the card is the only visible surface */
  .card:has(.responsive-card-table) .table-responsive {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
  }

  /* A table-responsive with no card wrapper becomes the rounded surface itself */
  .table-responsive:has(.responsive-card-table) {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    box-shadow: 0 2px 10px var(--shadow);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-radius: 1rem;
    overflow: hidden;
    padding: 0;
  }
}

/* --- Modern info banner (replaces plain alert-secondary) --- */
.info-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.25rem;
  border-radius: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-left: 4px solid #9775fa;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 18px var(--shadow);
}

.info-banner .info-banner-text {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.info-banner .info-banner-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  background: linear-gradient(135deg, #9775fa, #7950f2);
}

.info-banner .btn {
  border-radius: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
}

@media (max-width: 575.98px) {
  .info-banner .btn {
    width: 100%;
  }
}

/* --- Dark-mode-aware pagination --- */
.pagination {
  gap: 0.3rem;
  flex-wrap: wrap;
}

.pagination .page-link {
  border: 1px solid var(--glass-border);
  background: var(--card-bg);
  color: var(--text-primary);
  border-radius: 0.6rem !important;
  min-width: 40px;
  text-align: center;
  font-weight: 600;
  padding: 0.45rem 0.7rem;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.pagination .page-link:hover {
  background: var(--glass-bg);
  color: var(--text-primary);
  border-color: #667eea;
  z-index: 1;
}

.pagination .page-item.active .page-link {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

.pagination .page-item.disabled .page-link {
  background: var(--card-bg);
  color: var(--text-muted);
  border-color: var(--glass-border);
  opacity: 0.55;
}

.pagination .page-link:focus {
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* =====================================================================
   FILTER CHIPS  (modern segmented filter bar — replaces colored btn-group)
   ===================================================================== */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease,
    border-color 0.2s ease, color 0.2s ease;
}

.filter-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px var(--shadow);
  color: var(--text-primary);
  border-color: rgba(102, 126, 234, 0.5);
}

.filter-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.35);
}

.filter-chip .chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chip-accent, #667eea);
  flex-shrink: 0;
}

.filter-chip .chip-count {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  background: var(--glass-bg);
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
}

.filter-chip.is-active {
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 18px var(--shadow-strong);
}

.filter-chip.is-active .chip-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  border-color: transparent;
}

.filter-chip.is-active .chip-dot {
  background: #fff;
}

/* chip accent colours */
.filter-chip.chip-primary { --chip-accent: #4dabf7; }
.filter-chip.chip-danger  { --chip-accent: #ff6b6b; }
.filter-chip.chip-warning { --chip-accent: #f59f00; }
.filter-chip.chip-success { --chip-accent: #51cf66; }
.filter-chip.chip-info    { --chip-accent: #22b8cf; }

.filter-chip.is-active.chip-primary { background: linear-gradient(135deg, #4dabf7, #667eea); }
.filter-chip.is-active.chip-danger  { background: linear-gradient(135deg, #ff6b6b, #ee5a6f); }
.filter-chip.is-active.chip-warning { background: linear-gradient(135deg, #ffa94d, #f59f00); }
.filter-chip.is-active.chip-success { background: linear-gradient(135deg, #2fb380, #51cf66); }
.filter-chip.is-active.chip-info    { background: linear-gradient(135deg, #3bc9db, #22b8cf); }

/* =====================================================================
   SECTION HEAD  (lightweight content-section title with a count pill)
   ===================================================================== */
.section-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.section-head .section-head-icon {
  color: var(--text-muted);
  font-size: 1rem;
}

.section-head .section-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
}

/* =====================================================================
   ROOM TILES  (Buildings → Rooms grid, grouped by floor)
   ===================================================================== */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.9rem;
}

.room-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.9rem;
  border-radius: 0.9rem;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-top: 3px solid var(--room-accent, #51cf66);
  box-shadow: 0 2px 10px var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.room-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px var(--shadow);
}

.room-tile.is-available { --room-accent: #51cf66; }
.room-tile.is-full      { --room-accent: #ff6b6b; }
.room-tile.is-inactive  { --room-accent: #adb5bd; opacity: 0.7; }

.room-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.room-tile-number {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.room-tile-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-tertiary);
}

.room-tile-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.room-tile-rent {
  font-weight: 600;
  color: var(--text-muted);
}

.room-tile-inactive {
  align-self: flex-start;
}

.room-tile-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.15rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--glass-border);
}

.room-tile-actions form {
  display: flex;
  margin: 0;
}

.room-tile-actions .btn {
  flex: 1 1 auto;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  border-radius: 0.55rem !important;
}

@media (max-width: 575.98px) {
  .room-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* =====================================================================
   CAMPUS CHIPS  (Buildings → Campuses Served)
   ===================================================================== */
.campus-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.campus-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.4rem 0.4rem 0.7rem;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  font-size: 0.85rem;
  color: var(--text-primary);
}

.campus-chip > i {
  color: var(--accent-color);
}

.campus-chip-name {
  font-weight: 600;
}

.campus-chip-code {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}

.campus-chip-uni {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #4dabf7, #667eea);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

.campus-chip-remove {
  display: inline-flex;
  margin: 0;
}

.campus-chip-remove button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.campus-chip-remove button:hover {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.12);
}

.empty-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.7rem;
  background: var(--glass-bg);
  border: 1px dashed var(--glass-border);
  color: var(--text-muted);
  font-size: 0.88rem;
}

.campus-add-form {
  border-top: 1px solid var(--glass-border);
  padding-top: 1rem;
}

/* =====================================================================
   USER CARD  (people / directory grid card)
   ===================================================================== */
.user-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.25rem;
  border-radius: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-top: 3px solid var(--card-accent-solid, #667eea);
  box-shadow: 0 2px 10px var(--shadow);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Very subtle coloured wash — a hint of the role accent, not a shout */
.user-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--card-accent, linear-gradient(135deg, #667eea, #764ba2));
  opacity: 0.035;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.user-card > * {
  position: relative;
  z-index: 1;
}

.user-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 26px var(--shadow-strong);
}

.user-card:hover::before {
  opacity: 0.06;
}

/* Role accent palettes (used on the card top border + subtle wash + avatar) */
.user-card.accent-danger  { --card-accent: linear-gradient(135deg, #ff8787, #f03e3e); --card-accent-solid: #f03e3e; }
.user-card.accent-warning { --card-accent: linear-gradient(135deg, #ffc078, #f76707); --card-accent-solid: #f76707; }
.user-card.accent-info    { --card-accent: linear-gradient(135deg, #66d9e8, #1098ad); --card-accent-solid: #1098ad; }
.user-card.accent-success { --card-accent: linear-gradient(135deg, #8ce99a, #2f9e44); --card-accent-solid: #2f9e44; }
.user-card.accent-purple  { --card-accent: linear-gradient(135deg, #b197fc, #7048e8); --card-accent-solid: #7048e8; }

[data-theme="dark"] .user-card::before { opacity: 0.07; }
[data-theme="dark"] .user-card:hover::before { opacity: 0.11; }

.user-card-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.user-avatar {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  background: var(--tile-accent, linear-gradient(135deg, #667eea, #764ba2));
  box-shadow: 0 6px 18px var(--avatar-glow, rgba(102, 126, 234, 0.45));
}

.user-avatar.accent-danger  { --tile-accent: linear-gradient(135deg, #ff8787, #f03e3e); --avatar-glow: rgba(240, 62, 62, 0.45); }
.user-avatar.accent-warning { --tile-accent: linear-gradient(135deg, #ffc078, #f76707); --avatar-glow: rgba(247, 103, 7, 0.45); }
.user-avatar.accent-info    { --tile-accent: linear-gradient(135deg, #66d9e8, #1098ad); --avatar-glow: rgba(16, 152, 173, 0.45); }
.user-avatar.accent-success { --tile-accent: linear-gradient(135deg, #8ce99a, #2f9e44); --avatar-glow: rgba(47, 158, 68, 0.45); }
.user-avatar.accent-purple  { --tile-accent: linear-gradient(135deg, #b197fc, #7048e8); --avatar-glow: rgba(112, 72, 232, 0.45); }

.user-identity {
  min-width: 0;
}

.user-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin: 0 0 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.user-card-meta .meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.user-card-meta .meta-pill.role-admin       { color: #e03131; border-color: rgba(224, 49, 49, 0.35); background: rgba(224, 49, 49, 0.10); }
.user-card-meta .meta-pill.role-manager     { color: #d9480f; border-color: rgba(217, 72, 15, 0.35); background: rgba(247, 144, 9, 0.12); }
.user-card-meta .meta-pill.role-maintenance { color: #0c8599; border-color: rgba(12, 133, 153, 0.35); background: rgba(34, 184, 207, 0.12); }
.user-card-meta .meta-pill.role-student     { color: #2b8a3e; border-color: rgba(43, 138, 62, 0.35); background: rgba(81, 207, 102, 0.12); }
.user-card-meta .meta-pill.role-warn        { color: #b8860b; border-color: rgba(245, 159, 0, 0.4); background: rgba(245, 159, 0, 0.12); }

.user-card-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-card-actions .btn {
  border-radius: 0.7rem;
  font-weight: 600;
}

/* =====================================================================
   CONTRACT CARD  (residence contract template tile)
   ===================================================================== */
.contract-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.25rem;
  border-radius: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-top: 3px solid var(--glass-border);
  box-shadow: 0 2px 10px var(--shadow);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.contract-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 26px var(--shadow-strong);
}

/* Active template gets a green top rail + faint wash */
.contract-card.is-active {
  border-top-color: #2f9e44;
}

.contract-card.is-active::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #8ce99a, #2f9e44);
  opacity: 0.04;
  pointer-events: none;
}

[data-theme="dark"] .contract-card.is-active::before { opacity: 0.08; }

.contract-card > * {
  position: relative;
  z-index: 1;
}

.contract-card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.contract-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #fff;
  background: linear-gradient(135deg, #748ffc, #5c7cfa);
  box-shadow: 0 6px 16px rgba(92, 124, 250, 0.4);
}

.contract-card.is-active .contract-icon {
  background: linear-gradient(135deg, #8ce99a, #2f9e44);
  box-shadow: 0 6px 16px rgba(47, 158, 68, 0.4);
}

.contract-identity {
  min-width: 0;
  flex: 1;
}

.contract-title {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--text-primary);
  margin: 0 0 0.3rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.contract-version {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.contract-status {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.contract-status.is-active {
  color: #2b8a3e;
  background: rgba(81, 207, 102, 0.14);
  border: 1px solid rgba(47, 158, 68, 0.35);
}

.contract-status.is-inactive {
  color: var(--text-muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}

.contract-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.contract-meta .meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.contract-meta .meta-pill.scope-global   { color: #0c8599; border-color: rgba(12, 133, 153, 0.35); background: rgba(34, 184, 207, 0.12); }
.contract-meta .meta-pill.scope-building  { color: #4263eb; border-color: rgba(66, 99, 235, 0.35); background: rgba(92, 124, 250, 0.12); }

.contract-preview {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 0.7rem;
  padding: 0.7rem 0.8rem;
  max-height: 116px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 1rem;
}

.contract-actions {
  margin-top: auto;
  display: flex;
  gap: 0.5rem;
}

.contract-actions .btn {
  border-radius: 0.7rem;
  font-weight: 600;
}

/* =====================================================================
   APPLICATION CARD  (tenant application tile — risk-aware)
   ===================================================================== */
.application-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 10px var(--shadow);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  --risk-color: var(--accent-color, #5c7cfa);
}

.application-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 30px var(--shadow-strong);
  border-color: color-mix(in srgb, var(--risk-color) 45%, var(--glass-border));
}

/* Risk rail across the top */
.application-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--risk-color);
  opacity: 0.9;
}

.application-card.risk-none::before { opacity: 0; }

.application-card-body {
  padding: 1.25rem;
  flex: 1;
}

.application-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.application-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.55rem;
  color: #fff;
}

.application-name {
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.application-ref {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.2rem;
}

.application-ref code {
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 5px;
  padding: 0.05rem 0.35rem;
  font-size: 0.72rem;
}

/* Risk score gauge on the right */
.application-risk {
  flex-shrink: 0;
  text-align: center;
  min-width: 58px;
  padding: 0.45rem 0.5rem;
  border-radius: 0.7rem;
  background: color-mix(in srgb, var(--risk-color) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--risk-color) 30%, transparent);
}

.application-risk .risk-value {
  display: block;
  font-weight: 800;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--risk-color);
}

.application-risk .risk-value small { font-size: 0.55em; font-weight: 700; }

.application-risk .risk-label {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.application-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 0.9rem 0;
}

.application-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.application-meta-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  min-width: 0;
}

.application-meta-row > i {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.application-meta-row .meta-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.application-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.application-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  white-space: nowrap;
}

.application-pill.pill-success { color: #2b8a3e; background: rgba(81, 207, 102, 0.14); border-color: rgba(47, 158, 68, 0.35); }
.application-pill.pill-warning { color: #b8860b; background: rgba(255, 212, 59, 0.16); border-color: rgba(240, 173, 78, 0.4); }
.application-pill.pill-danger  { color: #c92a2a; background: rgba(255, 107, 107, 0.14); border-color: rgba(224, 49, 49, 0.35); }
[data-theme="dark"] .application-pill.pill-warning { color: #ffd43b; }

.application-card-footer {
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--glass-border);
  background: var(--glass-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.application-card-footer .view-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--risk-color);
}

.application-card:hover .application-card-footer .view-link i {
  transform: translateX(3px);
}

.application-card-footer .view-link i {
  transition: transform 0.2s ease;
}

/* Application table (desktop / landscape-tablet view) */
.application-table thead th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.application-table tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--glass-border);
}

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

.application-table tbody tr {
  transition: background-color 0.15s ease;
}

.application-table tbody tr:hover {
  background: var(--glass-bg);
}

.application-table .application-pill {
  font-size: 0.72rem;
  padding: 0.22rem 0.55rem;
}

.application-table .application-status {
  margin-bottom: 0;
}

/* =====================================================================
   EMPTY STATE  (clean placeholder panel)
   ===================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 1.5rem;
  border-radius: 1rem;
  background: var(--bg-secondary);
  border: 1px dashed var(--glass-border);
}

.empty-state .empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  color: var(--text-muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  margin-bottom: 1rem;
}

.empty-state .empty-title {
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
}

.empty-state .empty-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* Soft, theme-aware inline callouts (replace bootstrap alert-info/success inside cards) */
.alert-soft {
  border-radius: 0.6rem;
  padding: 0.6rem 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid var(--glass-border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.alert-soft strong { color: var(--text-primary); }

.alert-soft-info {
  border-color: color-mix(in srgb, var(--accent-info, #0dcaf0) 45%, var(--glass-border));
  background: color-mix(in srgb, var(--accent-info, #0dcaf0) 12%, var(--bg-secondary));
}

.alert-soft-success {
  border-color: color-mix(in srgb, var(--accent-success, #198754) 45%, var(--glass-border));
  background: color-mix(in srgb, var(--accent-success, #198754) 12%, var(--bg-secondary));
}

.alert-soft-warning {
  border-color: color-mix(in srgb, var(--accent-warning, #ffc107) 45%, var(--glass-border));
  background: color-mix(in srgb, var(--accent-warning, #ffc107) 14%, var(--bg-secondary));
}

.alert-soft-danger {
  border-color: color-mix(in srgb, var(--accent-danger, #dc3545) 45%, var(--glass-border));
  background: color-mix(in srgb, var(--accent-danger, #dc3545) 12%, var(--bg-secondary));
}

/* =====================================================================
   WELCOME HERO  (dashboard greeting banner — refined & elegant)
   ===================================================================== */
.welcome-hero {
  position: relative;
  overflow: hidden;
  border-radius: 1.25rem;
  padding: 1.75rem 1.9rem;
  margin-bottom: 1.5rem;
  color: #fff;
  background: linear-gradient(125deg, #5b6ee0 0%, #764ba2 55%, #8e44ad 100%);
  box-shadow: 0 14px 38px rgba(102, 78, 162, 0.32);
}

/* Subtle decorative orbs for depth */
.welcome-hero::before,
.welcome-hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.welcome-hero::before {
  top: -70px;
  right: -40px;
  width: 230px;
  height: 230px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 70%);
}

.welcome-hero::after {
  bottom: -90px;
  left: 12%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 70%);
}

.welcome-hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.welcome-hero-greeting {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.welcome-hero-avatar {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.welcome-hero h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.6vw, 1.95rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.welcome-hero .welcome-hero-role {
  margin: 0.3rem 0 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.welcome-hero-meta {
  text-align: right;
  font-size: 0.85rem;
  opacity: 0.92;
  line-height: 1.6;
}

.welcome-hero-meta .meta-row {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: flex-end;
}

@media (max-width: 575.98px) {
  .welcome-hero {
    padding: 1.4rem 1.3rem;
  }
  .welcome-hero-meta {
    text-align: left;
  }
  .welcome-hero-meta .meta-row {
    justify-content: flex-start;
  }
}

/* =====================================================================
   ACTION TILES  (elegant quick-access navigation cards)
   ===================================================================== */
.action-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 576px) { .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 992px) { .action-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1400px) { .action-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.action-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.15rem 1.2rem;
  border-radius: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 10px var(--shadow);
  text-decoration: none;
  color: var(--text-primary);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.action-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--tile-accent, linear-gradient(135deg, #667eea, #764ba2));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.action-tile > * { position: relative; z-index: 1; }

.action-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px var(--shadow-strong);
  border-color: transparent;
  color: var(--text-primary);
}

.action-tile:hover::before { opacity: 0.05; }
[data-theme="dark"] .action-tile:hover::before { opacity: 0.1; }

.action-tile:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.4);
}

.action-tile .action-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  background: var(--tile-accent, linear-gradient(135deg, #667eea, #764ba2));
  box-shadow: 0 8px 18px var(--tile-glow, rgba(102, 126, 234, 0.4));
  transition: transform 0.2s ease;
  position: relative;
}

/* Count badge for tiles with pending items (e.g. visitors, parcels) */
.action-tile .action-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  background: #f03e3e;
  border: 2px solid var(--bg-secondary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.action-tile:hover .action-icon {
  transform: scale(1.06) rotate(-3deg);
}

.action-tile .action-body {
  min-width: 0;
  flex: 1;
}

.action-tile .action-title {
  font-weight: 600;
  font-size: 0.98rem;
  margin: 0 0 0.15rem;
  line-height: 1.2;
}

.action-tile .action-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.3;
}

.action-tile .action-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 1.1rem;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.action-tile:hover .action-arrow {
  opacity: 1;
  transform: translateX(0);
  color: var(--card-accent-solid, #667eea);
}

/* Accent palettes (icon gradient + glow + hover wash) */
.action-tile.accent-primary { --tile-accent: linear-gradient(135deg, #4dabf7, #667eea); --tile-glow: rgba(77, 171, 247, 0.4);  --card-accent-solid: #4dabf7; }
.action-tile.accent-success { --tile-accent: linear-gradient(135deg, #51cf66, #2f9e44); --tile-glow: rgba(47, 158, 68, 0.4);  --card-accent-solid: #2f9e44; }
.action-tile.accent-warning { --tile-accent: linear-gradient(135deg, #ffc078, #f76707); --tile-glow: rgba(247, 103, 7, 0.4);  --card-accent-solid: #f76707; }
.action-tile.accent-danger  { --tile-accent: linear-gradient(135deg, #ff8787, #f03e3e); --tile-glow: rgba(240, 62, 62, 0.4);  --card-accent-solid: #f03e3e; }
.action-tile.accent-info    { --tile-accent: linear-gradient(135deg, #66d9e8, #1098ad); --tile-glow: rgba(16, 152, 173, 0.4); --card-accent-solid: #1098ad; }
.action-tile.accent-purple  { --tile-accent: linear-gradient(135deg, #b197fc, #7048e8); --tile-glow: rgba(112, 72, 232, 0.4); --card-accent-solid: #7048e8; }
.action-tile.accent-teal    { --tile-accent: linear-gradient(135deg, #38d9a9, #0ca678); --tile-glow: rgba(12, 166, 120, 0.4); --card-accent-solid: #0ca678; }
.action-tile.accent-gray    { --tile-accent: linear-gradient(135deg, #adb5bd, #868e96); --tile-glow: rgba(134, 142, 150, 0.35); --card-accent-solid: #868e96; }

/* =====================================================================
   BUILDING CARD  (Admin → Buildings → Index — premium directory tile)
   ===================================================================== */
.building-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 1rem;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.building-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-strong);
  border-color: var(--card-accent-solid, #667eea);
}

.building-card.is-inactive {
  opacity: 0.6;
}

/* Accent rail at the top */
.building-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--building-accent, linear-gradient(135deg, #667eea, #764ba2));
}

.building-card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1.1rem 1.1rem 0.75rem;
}

.building-avatar {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  color: #fff;
  background: var(--building-accent, linear-gradient(135deg, #667eea, #764ba2));
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.building-head-text {
  min-width: 0;
  flex: 1;
}

.building-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.15rem;
  line-height: 1.25;
}

.building-address {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.building-status-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 0.4rem;
}

.building-status-dot.is-active { background: #2f9e44; box-shadow: 0 0 0 3px rgba(47, 158, 68, 0.18); }
.building-status-dot.is-inactive { background: #adb5bd; box-shadow: 0 0 0 3px rgba(173, 181, 189, 0.18); }

/* Badge row */
.building-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1.1rem 0.9rem;
}

.b-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  line-height: 1;
}

.b-tag i { font-size: 0.72rem; }

.b-tag.tag-success { color: #2f9e44; background: rgba(47, 158, 68, 0.12); border-color: rgba(47, 158, 68, 0.25); }
.b-tag.tag-primary { color: #4263eb; background: rgba(66, 99, 235, 0.12); border-color: rgba(66, 99, 235, 0.25); }
.b-tag.tag-info    { color: #1098ad; background: rgba(16, 152, 173, 0.12); border-color: rgba(16, 152, 173, 0.25); }
.b-tag.tag-warning { color: #e8590c; background: rgba(232, 89, 12, 0.12); border-color: rgba(232, 89, 12, 0.25); }
.b-tag.tag-purple  { color: #7048e8; background: rgba(112, 72, 232, 0.12); border-color: rgba(112, 72, 232, 0.25); }
.b-tag.tag-danger  { color: #e03131; background: rgba(224, 49, 49, 0.12); border-color: rgba(224, 49, 49, 0.25); }
.b-tag.tag-muted   { color: var(--text-muted); background: var(--bg-secondary); border-color: var(--border-color); }

/* Stats strip */
.building-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  padding: 0.9rem 1.1rem;
  margin: 0 1.1rem;
  border-radius: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.b-stat {
  text-align: center;
  min-width: 0;
}

.b-stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
}

.b-stat-value.is-positive { color: #2f9e44; }
.b-stat-value.is-zero { color: #e03131; }

.b-stat-label {
  display: block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Occupancy */
.building-occupancy {
  padding: 0.9rem 1.1rem 0;
}

.building-occupancy-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.35rem;
}

.building-occupancy-head .occ-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.building-occupancy-head .occ-value {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.building-occupancy .progress {
  height: 7px;
  border-radius: 999px;
  background: var(--bg-secondary);
}

.building-occupancy .progress-bar { border-radius: 999px; }

.building-desc {
  padding: 0.85rem 1.1rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

/* Actions */
.building-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 1rem 1.1rem;
  margin-top: auto;
}

.b-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.38rem 0.7rem;
  border-radius: 0.55rem;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.18s ease;
  cursor: pointer;
}

.b-action:hover {
  color: #fff;
  transform: translateY(-1px);
}

.b-action.b-edit:hover { background: #4263eb; border-color: #4263eb; }
.b-action.b-rooms:hover { background: #2f9e44; border-color: #2f9e44; }
.b-action.b-parking:hover { background: #1098ad; border-color: #1098ad; }
.b-action.b-campuses:hover { background: #7048e8; border-color: #7048e8; }
.b-action.b-delete { color: #e03131; }
.b-action.b-delete:hover { background: #e03131; border-color: #e03131; color: #fff; }

.building-footer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.65rem 1.1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* =====================================================================
   CHECK-IN CHIPS  (retroactive check-in banner — student person chips)
   ===================================================================== */
.checkin-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  max-height: 230px;
  overflow-y: auto;
  padding: 0.15rem 0.35rem 0.15rem 0.15rem;
}

.checkin-chip-list::-webkit-scrollbar { width: 7px; }
.checkin-chip-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 999px;
}

.checkin-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.7rem 0.4rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  text-decoration: none;
  transition: all 0.18s ease;
}

.checkin-chip:hover {
  border-color: #f76707;
  background: var(--card-bg);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(247, 103, 7, 0.18);
}

.checkin-chip-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ffa94d, #f76707);
}

.checkin-chip-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.checkin-chip-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.checkin-chip-room {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* =====================================================================
   PANEL CARD  (premium container — accent rail + header band)
   ===================================================================== */
.panel-card {
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 16px var(--shadow);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.panel-card:hover {
  box-shadow: 0 10px 28px var(--shadow-strong);
}

.panel-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--panel-accent, linear-gradient(135deg, #4dabf7, #667eea));
  z-index: 1;
}

.panel-card.accent-warning { --panel-accent: linear-gradient(135deg, #ffa94d, #f76707); }
.panel-card.accent-info    { --panel-accent: linear-gradient(135deg, #66d9e8, #1098ad); }
.panel-card.accent-primary { --panel-accent: linear-gradient(135deg, #4dabf7, #667eea); }
.panel-card.accent-success { --panel-accent: linear-gradient(135deg, #51cf66, #2f9e44); }
.panel-card.accent-purple  { --panel-accent: linear-gradient(135deg, #9775fa, #7950f2); }
.panel-card.accent-danger  { --panel-accent: linear-gradient(135deg, #ff6b6b, #ee5a6f); }

.panel-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.panel-head-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: #fff;
  background: var(--panel-accent, linear-gradient(135deg, #4dabf7, #667eea));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.panel-head-text {
  min-width: 0;
  flex: 1;
}

.panel-head-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-head-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.1rem 0 0;
}

.panel-head .panel-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: var(--panel-accent, linear-gradient(135deg, #4dabf7, #667eea));
}

.panel-body {
  padding: 1.25rem;
}

.panel-foot {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--glass-border);
  background: var(--bg-secondary);
  border-radius: 0 0 1rem 1rem;
}

/* =====================================================================
   DETAIL MODAL — clean key/value tables for "view details" popups
   (works in both light and dark mode)
   ===================================================================== */
.detail-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.detail-table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.detail-table td {
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--glass-border);
  vertical-align: top;
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.4;
}

.detail-table tr:last-child td {
  border-bottom: none;
}

.detail-table .detail-key {
  width: 40%;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.detail-table td code {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  padding: 0.1rem 0.4rem;
  border-radius: 0.35rem;
  font-size: 0.82rem;
}

.detail-table td a {
  color: var(--accent-primary, #4dabf7);
  text-decoration: none;
}

.detail-table td a:hover {
  text-decoration: underline;
}

.detail-note {
  padding: 0.85rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: 0.6rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* =====================================================================
   AUDIT LOG TABLE — polished desktop table, cards on tablet/mobile
   ===================================================================== */
/* Desktop (>= 992px): a clean, dense, well-spaced data table */
@media (min-width: 992px) {
  .audit-table {
    table-layout: fixed;
    width: 100%;
  }
  .audit-table col,
  .audit-table th,
  .audit-table td {
    vertical-align: middle;
  }
  /* Sensible column proportions so Description gets the room it needs */
  .audit-table thead th:nth-child(1),
  .audit-table tbody td:nth-child(1) { width: 8.5rem; }      /* Timestamp */
  .audit-table thead th:nth-child(2),
  .audit-table tbody td:nth-child(2) { width: 11rem; }       /* User */
  .audit-table thead th:nth-child(3),
  .audit-table tbody td:nth-child(3) { width: 7rem; }        /* Action */
  .audit-table thead th:nth-child(4),
  .audit-table tbody td:nth-child(4) { width: 9rem; }        /* Entity */
  .audit-table thead th:nth-child(5),
  .audit-table tbody td:nth-child(5) { width: auto; }        /* Description */
  .audit-table thead th:nth-child(6),
  .audit-table tbody td:nth-child(6) { width: 9rem; }        /* IP */
  .audit-table thead th:nth-child(7),
  .audit-table tbody td:nth-child(7) { width: 3.5rem; }      /* PI */

  .audit-table tbody td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--glass-border);
  }
  .audit-table tbody tr {
    transition: background 0.15s ease;
  }
  .audit-table tbody tr:hover td {
    background: var(--bg-tertiary);
  }
  /* Personal-information rows get a subtle amber accent on the left */
  .audit-table tbody tr.is-pi td:first-child {
    box-shadow: inset 3px 0 0 #f59f00;
  }
}

.audit-table .audit-time {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.audit-table .audit-date {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-primary);
}
.audit-table .audit-clock {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.audit-table .audit-user {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.audit-table .audit-avatar {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #4dabf7 0%, #3b5bdb 100%);
}
.audit-table .audit-user-name {
  font-weight: 600;
  font-size: 0.83rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-table .audit-entity {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}
.audit-table .audit-entity-type {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-primary);
}
.audit-table .audit-entity-id {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--bs-font-monospace, monospace);
}

.audit-table .audit-desc {
  font-size: 0.83rem;
  color: var(--text-secondary, var(--text-muted));
}
.audit-table .audit-ip {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--bs-font-monospace, monospace);
  font-variant-numeric: tabular-nums;
}

.audit-table .audit-pi-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(245, 159, 0, 0.16);
  color: #f59f00;
  font-size: 0.85rem;
}

/* Tablet / mobile (<= 991px): the global responsive-card-table rules turn each
   row into a card. Tidy up the audit-specific cells inside those cards. */
@media (max-width: 991.98px) {
  .audit-table tbody tr.is-pi {
    border-left: 3px solid #f59f00 !important;
  }
  .audit-table .audit-time,
  .audit-table .audit-entity {
    flex-direction: row;
    align-items: baseline;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .audit-table .audit-user {
    justify-content: flex-end;
  }
  .audit-table .audit-desc {
    text-align: right;
  }
}

/* Inventory row item icon */
.inv-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 0.6rem;
  color: #fff;
  font-size: 1.15rem;
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

/* Equal-height panel-cards in a grid row */
.panel-card.h-100 {
  display: flex;
  flex-direction: column;
}
.panel-card.h-100 .panel-body {
  flex: 1;
}

/* ── De-nest: no glass-on-glass ──────────────────────────────
   When a card sits INSIDE a panel-card's body (e.g. a grid of
   cards), it must not render its own glass/blur/shadow on top of
   the already-glassy panel. Flatten it to a plain sub-surface so
   the nesting reads cleanly instead of stacked translucency. */
.panel-body .card,
.panel-body .glass-card {
  background: var(--bg-tertiary);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border: 1px solid var(--border-color);
  box-shadow: none;
}
.panel-body .card:hover,
.panel-body .glass-card:hover {
  transform: none;
  box-shadow: none;
}
/* Inner card headers/footers shouldn't add another tinted layer */
.panel-body .card > .card-header,
.panel-body .glass-card > .card-header,
.panel-body .card > .card-footer,
.panel-body .glass-card > .card-footer {
  background: transparent;
  border-color: var(--border-color);
}
/* Tablet/mobile: a responsive table collapses each row into a card.
   When that table lives inside a panel-body, the OUTER panel glass would
   stack behind the row-cards (double glass). Dissolve the outer panel so
   each row is the only card. */
@media (max-width: 991.98px) {
  .panel-card:has(.responsive-card-table) {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }
  .panel-card:has(.responsive-card-table)::before {
    display: none !important;
  }
  .panel-card:has(.responsive-card-table) > .panel-body {
    padding: 0 !important;
  }
}

/* When a panel-card carries a Bootstrap severity left-border
   (border-start border-X), hide the default top accent bar so the
   two colors don't clash. The left border becomes the sole accent. */
.panel-card.border-start::before {
  display: none !important;
}

/* ===== Maintenance request card ===== */
.mnt-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 16px var(--shadow);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.mnt-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px var(--shadow-strong);
}
.mnt-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--mnt-accent, linear-gradient(135deg, #4dabf7, #667eea));
  z-index: 1;
}
.mnt-card.cat-electrical { --mnt-accent: linear-gradient(135deg, #ffd43b, #f59f00); }
.mnt-card.cat-plumbing   { --mnt-accent: linear-gradient(135deg, #66d9e8, #1098ad); }
.mnt-card.cat-hvac       { --mnt-accent: linear-gradient(135deg, #4dabf7, #667eea); }
.mnt-card.cat-carpentry  { --mnt-accent: linear-gradient(135deg, #b08968, #7f5539); }
.mnt-card.cat-internet   { --mnt-accent: linear-gradient(135deg, #66d9e8, #3b5bdb); }
.mnt-card.cat-cleaning   { --mnt-accent: linear-gradient(135deg, #51cf66, #2f9e44); }
.mnt-card.cat-general    { --mnt-accent: linear-gradient(135deg, #adb5bd, #868e96); }
.mnt-card.cat-other      { --mnt-accent: linear-gradient(135deg, #9775fa, #7950f2); }
/* Urgency outline takes priority on the card edge */
.mnt-card.is-urgent  { border-color: rgba(255, 107, 107, 0.55); }
.mnt-card.is-warning { border-color: rgba(255, 169, 77, 0.55); }

.mnt-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1.15rem 1.1rem 1.1rem;
  flex: 1;
}

.mnt-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.mnt-cat {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: var(--mnt-accent, linear-gradient(135deg, #4dabf7, #667eea));
}
.mnt-urgency {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}
.mnt-urgency.urgent  { color: #fff; background: linear-gradient(135deg, #ff6b6b, #ee5a6f); }
.mnt-urgency.warning { color: #663c00; background: linear-gradient(135deg, #ffd43b, #ffa94d); }

.mnt-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mnt-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.mnt-meta .mnt-student {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.mnt-meta i { width: 1rem; text-align: center; }

.mnt-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.mnt-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.mnt-pill.s-submitted  { color: #1098ad; background: rgba(102, 217, 232, 0.16); border-color: rgba(16, 152, 173, 0.35); }
.mnt-pill.s-progress   { color: #e8590c; background: rgba(255, 169, 77, 0.16); border-color: rgba(232, 89, 12, 0.35); }
.mnt-pill.s-resolved   { color: #2f9e44; background: rgba(81, 207, 102, 0.16); border-color: rgba(47, 158, 68, 0.35); }
.mnt-pill.s-closed     { color: var(--text-muted); background: var(--bg-tertiary); border-color: var(--border-color); }
.mnt-pill.a-assigned   { color: #3b5bdb; background: rgba(77, 171, 247, 0.16); border-color: rgba(59, 91, 219, 0.35); }
.mnt-pill.a-unassigned { color: var(--text-muted); background: var(--bg-tertiary); border-color: var(--border-color); }

.mnt-sign {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.1rem;
}
.mnt-sign-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  flex: 1;
}
.mnt-sign-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.mnt-sign-dot.done { color: #fff; background: linear-gradient(135deg, #51cf66, #2f9e44); }
.mnt-sign-dot.pending { color: var(--text-muted); background: var(--bg-tertiary); border: 1px dashed var(--border-color); }
.mnt-sign-label { font-size: 0.62rem; color: var(--text-muted); font-weight: 600; }
.mnt-sign-track {
  flex: 0 0 16px;
  height: 2px;
  background: var(--border-color);
  margin-top: -0.85rem;
}

.mnt-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.mnt-foot .btn { flex: 1; }

.mnt-check {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
}
.mnt-check .form-check-input {
  width: 20px;
  height: 20px;
  cursor: pointer;
}


/* ── Category card ─────────────────────────────────────────── */
.cat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 1rem;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.cat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.12);
  border-color: var(--cat-accent-solid, #4dabf7);
}
.cat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--cat-accent, linear-gradient(135deg, #4dabf7, #667eea));
}
.cat-card.is-inactive { opacity: 0.72; }

.cat-card.cat-electrical { --cat-accent: linear-gradient(135deg, #ffd43b, #f59f00); --cat-accent-solid: #f59f00; }
.cat-card.cat-plumbing   { --cat-accent: linear-gradient(135deg, #66d9e8, #1098ad); --cat-accent-solid: #1098ad; }
.cat-card.cat-hvac       { --cat-accent: linear-gradient(135deg, #4dabf7, #667eea); --cat-accent-solid: #4dabf7; }
.cat-card.cat-carpentry  { --cat-accent: linear-gradient(135deg, #b08968, #7f5539); --cat-accent-solid: #7f5539; }
.cat-card.cat-internet   { --cat-accent: linear-gradient(135deg, #66d9e8, #3b5bdb); --cat-accent-solid: #3b5bdb; }
.cat-card.cat-cleaning   { --cat-accent: linear-gradient(135deg, #51cf66, #2f9e44); --cat-accent-solid: #2f9e44; }
.cat-card.cat-general    { --cat-accent: linear-gradient(135deg, #adb5bd, #868e96); --cat-accent-solid: #868e96; }
.cat-card.cat-other      { --cat-accent: linear-gradient(135deg, #9775fa, #7950f2); --cat-accent-solid: #7950f2; }

.cat-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.15rem 1.15rem 1rem;
}

.cat-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}
.cat-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  background: var(--cat-accent, linear-gradient(135deg, #4dabf7, #667eea));
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.18);
}
.cat-head-text { min-width: 0; flex: 1; }
.cat-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.2rem;
  line-height: 1.25;
}
.cat-order {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}
.cat-status {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.cat-status.is-active   { color: #2f9e44; background: rgba(81, 207, 102, 0.16); }
.cat-status.is-inactive { color: #f76707; background: rgba(255, 169, 77, 0.18); }

.cat-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.9rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cat-usage {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.7rem;
  border-radius: 0.6rem;
  font-size: 0.82rem;
  margin-bottom: 1rem;
  align-self: flex-start;
}
.cat-usage.has-usage { color: #2f9e44; background: rgba(81, 207, 102, 0.12); }
.cat-usage.no-usage  { color: var(--text-muted); background: var(--bg-tertiary); }
.cat-usage strong { font-weight: 700; }

.cat-foot {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}
.cat-foot .btn { flex: 1; }


/* ── Budget card ───────────────────────────────────────────── */
.budget-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 1rem;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.budget-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.12);
}
.budget-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--bud-accent, linear-gradient(135deg, #4dabf7, #667eea));
}
.budget-card.is-ok       { --bud-accent: linear-gradient(135deg, #51cf66, #2f9e44); --bud-solid: #2f9e44; }
.budget-card.is-warning  { --bud-accent: linear-gradient(135deg, #ffd43b, #f59f00); --bud-solid: #f59f00; }
.budget-card.is-danger   { --bud-accent: linear-gradient(135deg, #ff8787, #f03e3e); --bud-solid: #f03e3e; }
.budget-card.is-inactive { opacity: 0.72; }

.budget-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.15rem 1.15rem 1rem;
}

.budget-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}
.budget-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.25;
  min-width: 0;
  word-break: break-word;
}
.budget-state {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.budget-state.is-active   { color: #2f9e44; background: rgba(81, 207, 102, 0.16); }
.budget-state.is-inactive { color: var(--text-muted); background: var(--bg-tertiary); }

.budget-building {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

.budget-figures {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.budget-spent {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.budget-allocated {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.budget-pct {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--bud-solid, #4dabf7);
}

.budget-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  overflow: hidden;
  margin-bottom: 0.85rem;
}
.budget-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--bud-accent, linear-gradient(135deg, #4dabf7, #667eea));
  transition: width 0.4s ease;
}

.budget-period {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.budget-foot {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}
.budget-foot .btn { flex: 1; }


/* Risk gauge — centred score readout coloured by --risk-color */
.risk-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 1rem;
  border-radius: 0.85rem;
  background: color-mix(in srgb, var(--risk-color, #5c7cfa) 10%, var(--card-bg));
  border: 1px solid color-mix(in srgb, var(--risk-color, #5c7cfa) 35%, transparent);
}
.risk-gauge-value {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--risk-color, #5c7cfa);
}
.risk-gauge-value small {
  font-size: 1.1rem;
  font-weight: 700;
}
.risk-gauge-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* Soft tinted info panel (theme-aware replacement for bg-light) */
.info-soft {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

/* =====================================================================
   FILTER BAR  (search / date / select toolbar above tables)
   ===================================================================== */
.filter-bar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.85rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  border-radius: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--accent-color, #4dabf7);
  box-shadow: 0 2px 10px var(--shadow);
}

.filter-bar .filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1 1 170px;
  min-width: 0;
}

.filter-bar .filter-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.filter-bar .filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 0 0 auto;
  align-items: flex-end;
}

.filter-bar .filter-actions .btn {
  white-space: nowrap;
}

@media (max-width: 575.98px) {
  .filter-bar {
    padding: 0.9rem 1rem;
  }
  .filter-bar .filter-field {
    flex: 1 1 100%;
  }
  .filter-bar .filter-actions {
    width: 100%;
  }
  .filter-bar .filter-actions .btn {
    flex: 1 1 auto;
  }
}

/* =====================================================================
   CHAT THREAD  (modern messaging list — avatars, unread rail, hover)
   ===================================================================== */
.chat-thread {
  display: flex;
  flex-direction: column;
}

.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--glass-border);
  border-left: 3px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chat-row:last-child {
  border-bottom: none;
}

.chat-row:hover {
  background: var(--glass-bg);
  color: inherit;
}

.chat-row.unread {
  border-left-color: var(--accent-color, #4dabf7);
  background: color-mix(in srgb, var(--accent-color, #4dabf7) 6%, transparent);
}

.chat-row.is-open {
  background: var(--glass-bg);
  border-left-color: var(--accent-color, #4dabf7);
}

.chat-avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  background: linear-gradient(135deg, #667eea, #764ba2);
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
  position: relative;
}

.chat-avatar.av-broadcast { background: linear-gradient(135deg, #4dabf7, #667eea); }
.chat-avatar.av-announcement { background: linear-gradient(135deg, #3bc9db, #22b8cf); }
.chat-avatar.av-system { background: linear-gradient(135deg, #adb5bd, #868e96); }
.chat-avatar.av-direct { background: linear-gradient(135deg, #2fb380, #51cf66); }

.chat-avatar .chat-avatar-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-color, #4dabf7);
  border: 2px solid var(--bg-secondary);
}

.chat-main {
  flex: 1 1 auto;
  min-width: 0;
}

.chat-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.chat-sender {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.chat-row.unread .chat-sender {
  font-weight: 700;
}

.chat-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-subject {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.chat-preview {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.3rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.chat-expand {
  padding: 0 1rem 1rem;
  border-bottom: 1px solid var(--glass-border);
}

.chat-bubble {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

/* Segmented pill tabs for chat filters */
.chat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.35rem;
  margin-bottom: 1.25rem;
  border-radius: 0.85rem;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
}

.chat-tabs .chat-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 0.65rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-tabs .chat-tab:hover {
  background: var(--glass-bg);
  color: var(--text-primary);
}

.chat-tabs .chat-tab.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

@media (max-width: 575.98px) {
  .chat-tabs .chat-tab span { display: none; }
  .chat-tabs .chat-tab { padding: 0.45rem 0.7rem; }
  .chat-avatar { width: 38px; height: 38px; font-size: 0.9rem; }
}

/* Theme-aware code/extract block (replaces hard-coded dark pre blocks) */
.code-block {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  border-radius: 0.5rem;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--bs-font-monospace, monospace);
}

.panel-card .responsive-card-table {
  margin-bottom: 0;
}

/* Flatten the inner .table-responsive scroller inside a panel-card.
   By default .table-responsive carries its own bg/border/shadow/radius/padding,
   which produced a nested rounded box (0.75rem) that clashed with the
   panel-card's own 1rem rounded corners. The panel-card is the single rounded
   surface; the table fills it edge-to-edge. */
.panel-card .table-responsive {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 0;
  padding: 0;
}

/* --- Selectable option card (e.g. payment-gateway picker) --- */
.gateway-option {
  display: block;
  position: relative;
  text-align: center;
  text-decoration: none;
  padding: 1.1rem 1rem;
  border-radius: 0.9rem;
  background: var(--card-bg);
  border: 1.5px solid var(--glass-border);
  box-shadow: 0 2px 10px var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.gateway-option:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px var(--shadow-strong);
  border-color: var(--accent-color, #667eea);
}

.gateway-option.is-selected {
  border-color: var(--accent-color, #667eea);
  border-width: 2px;
  box-shadow: 0 6px 20px var(--shadow-strong);
}

.gateway-option.is-selected::after {
  content: "\F26E"; /* bi-check-lg */
  font-family: "bootstrap-icons";
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.8rem;
  color: #fff;
  background: var(--accent-color, #667eea);
}

.gateway-option-icon {
  font-size: 1.9rem;
  color: var(--accent-color, #667eea);
  line-height: 1;
}

.gateway-option-name {
  margin: 0.5rem 0 0.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.gateway-option-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.gateway-option-fee {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-color, #667eea);
  background: color-mix(in srgb, var(--accent-color, #667eea) 12%, transparent);
}

.gateway-option .badge {
  vertical-align: middle;
}

/* =====================================================================
   GLOBAL UX ENHANCEMENTS
   Page-load progress bar, button loading states, scroll-to-top,
   smooth scrolling and subtle page transitions. Applied app-wide.
   ===================================================================== */

/* --- Smooth scrolling (respects reduced-motion preference) --- */
html {
  scroll-behavior: smooth;
}

/* --- Top page-load progress bar (NProgress-style) --- */
.global-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  z-index: 100000;
  pointer-events: none;
  opacity: 0;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #4dabf7, #667eea 45%, #9775fa 80%, #f783ac);
  background-size: 200% 100%;
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.6), 0 0 5px rgba(102, 126, 234, 0.45);
  transition: transform 0.25s ease, opacity 0.35s ease;
}

.global-progress.is-active {
  opacity: 1;
  animation: gp-shimmer 1.1s linear infinite;
}

.global-progress.is-done {
  opacity: 0;
  transform: scaleX(1);
}

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

/* --- Button loading state --- */
.btn.is-loading {
  position: relative;
  pointer-events: none;
  cursor: progress;
}

.btn.is-loading > * {
  visibility: hidden;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1em;
  height: 1em;
  margin: -0.5em 0 0 -0.5em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  visibility: visible;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* --- Scroll-to-top floating button --- */
.scroll-top-btn {
  position: fixed;
  right: 1.1rem;
  bottom: 1.4rem;
  z-index: 1035;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1.15rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 8px 22px rgba(102, 126, 234, 0.45);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.9);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  cursor: pointer;
}

.scroll-top-btn.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.scroll-top-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 28px rgba(102, 126, 234, 0.55);
}

/* Lift the button above the mobile bottom nav so it never overlaps */
@media (max-width: 991.98px) {
  .scroll-top-btn {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }
}

/* --- Subtle page content fade-in on load --- */
.page-fade-in {
  animation: page-fade-in 0.4s ease backwards;
}

@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Honour users who prefer reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .global-progress,
  .global-progress.is-active,
  .btn.is-loading::after,
  .scroll-top-btn,
  .page-fade-in {
    animation: none !important;
    transition: opacity 0.2s ease !important;
  }
  .page-fade-in {
    transform: none;
  }
}

/* ========================================
   CHAT / MESSAGING
   ======================================== */
.chat-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 420px;
  max-height: 760px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px var(--shadow);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.12), rgba(118, 75, 162, 0.12));
  flex-shrink: 0;
}

.chat-head-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.2rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  flex-shrink: 0;
}

.chat-head-name {
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.chat-head-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chat-stream {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  scroll-behavior: smooth;
}

.chat-day {
  text-align: center;
  margin: 0.6rem 0;
}

.chat-day span {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
}

.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 78%;
}

.chat-msg.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg.theirs {
  align-self: flex-start;
}

.chat-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #4dabf7, #667eea);
  flex-shrink: 0;
}

.chat-bubble-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-msg.mine .chat-bubble-wrap {
  align-items: flex-end;
}

.chat-bubble-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0.4rem 0.15rem;
}

.chat-bubble {
  padding: 0.55rem 0.85rem;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px var(--shadow);
  position: relative;
}

.chat-bubble.theirs {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 5px;
}

.chat-bubble.mine {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.chat-bubble.priority {
  outline: 2px solid rgba(245, 158, 11, 0.6);
}

.chat-bubble-flag {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  opacity: 0.95;
}

.chat-bubble-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin: 0.15rem 0.4rem 0;
  white-space: nowrap;
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
}

.chat-empty-icon {
  font-size: 2.4rem;
  color: var(--text-muted);
  opacity: 0.6;
}

.chat-empty-title {
  font-weight: 600;
  margin: 0.5rem 0 0.2rem;
  color: var(--text-secondary);
}

.chat-empty-text {
  font-size: 0.85rem;
  margin: 0;
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.chat-input {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid var(--border-color);
  border-radius: 22px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  line-height: 1.4;
  max-height: 140px;
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
}

.chat-send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
  background: linear-gradient(135deg, #667eea, #764ba2);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.chat-send:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.chat-send:active {
  transform: scale(0.96);
}

/* --- Admin two-pane chat layout --- */
.chat-workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: calc(100vh - 230px);
  min-height: 460px;
  max-height: 780px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px var(--shadow);
}

.chat-aside {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  background: var(--bg-secondary);
  min-height: 0;
}

.chat-aside-head {
  padding: 0.8rem 1rem;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-conv-list {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.chat-conv {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.9rem;
  text-decoration: none;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.12s ease;
  color: var(--text-primary);
}

.chat-conv:hover {
  background: var(--bg-tertiary);
}

.chat-conv.active {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.16), rgba(118, 75, 162, 0.16));
  border-left: 3px solid #667eea;
}

.chat-conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #4dabf7, #667eea);
  flex-shrink: 0;
}

.chat-conv-main {
  min-width: 0;
  flex: 1 1 auto;
}

.chat-conv-top {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
}

.chat-conv-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.chat-conv-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-conv-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0.1rem 0 0;
}

.chat-conv-badge {
  background: #ef4444;
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  flex-shrink: 0;
  align-self: center;
}

.chat-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-pane .chat-stream {
  background: transparent;
}

.chat-pane-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.chat-pane-empty i {
  font-size: 2.6rem;
  opacity: 0.5;
}

@media (max-width: 768px) {
  .chat-workspace {
    grid-template-columns: 1fr;
    height: calc(100vh - 180px);
  }
  .chat-workspace.show-thread .chat-aside { display: none; }
  .chat-workspace:not(.show-thread) .chat-pane { display: none; }
  .chat-msg { max-width: 88%; }
}

