/* =====================================================================
   COMPCONNEX — Premium Legal Practice Management UI
   Design System: Deep Court (Navy/Slate + Legal Gold)
   ===================================================================== */

/* =====================================================================
   1. ROOT VARIABLES & DESIGN TOKENS
   ===================================================================== */
:root {
  /* Core Palette — Deep Court */
  --bg-deep:        #080E1A;
  --bg-base:        #0D1526;
  --bg-surface:     #111D35;
  --bg-elevated:    #162040;
  --bg-card:        #1A2647;
  --bg-hover:       #1F2E57;
  --bg-app:         var(--bg-deep);

  /* Gold Accent */
  --gold-primary:   #C9A84C;
  --gold-light:     #E2C87A;
  --gold-muted:     #8A6F35;
  --gold-glow:      rgba(201, 168, 76, 0.15);

  /* Text */
  --text-primary:   #EFF2F8;
  --text-secondary: #8A96B0;
  --text-muted:     #8290A8;
  --text-gold:      #C9A84C;

  /* Status Colors */
  --success:        #2ECC71;
  --success-bg:     rgba(46, 204, 113, 0.12);
  --warning:        #F39C12;
  --warning-bg:     rgba(243, 156, 18, 0.12);
  --danger:         #E74C3C;
  --danger-bg:      rgba(231, 76, 60, 0.12);
  --info:           #3498DB;
  --info-bg:        rgba(52, 152, 219, 0.12);

  /* Borders & Glass */
  --border:         rgba(201, 168, 76, 0.12);
  --border-light:   rgba(255, 255, 255, 0.06);
  --glass-bg:       rgba(22, 32, 64, 0.7);
  --glass-border:   rgba(201, 168, 76, 0.2);

  /* Layout */
  --sidebar-width:  260px;
  --header-height:  64px;
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
  --radius-xl:      24px;

  /* Typography */
  --font-legal:     'Cinzel', serif;
  --font-ui:        'Inter', sans-serif;

  /* Transitions */
  --transition:     all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows */
  --shadow-sm:      0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md:      0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg:      0 8px 48px rgba(0, 0, 0, 0.5);
  --shadow-gold:    0 0 24px rgba(201, 168, 76, 0.2);

  /* Legacy / Component Variable Aliases */
  --bg-default:     var(--bg-base);
  --bg-dark:        var(--bg-deep);
  --bg-lighter:     var(--bg-surface);
  --bg-surface-2:   var(--bg-surface);
  --border-color:   var(--border);
  --accent-color:   var(--gold-primary);
  --accent-blue:    var(--info);
  --accent-red:     var(--danger);
  --gold:           var(--gold-primary);
  --text-color:     var(--text-primary);
  --danger-color:   var(--danger);
  --warning-color:  var(--warning);
  --error-primary:  var(--danger);
}

/* =====================================================================
   2. RESET & BASE
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-ui);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; outline: none; font-family: var(--font-ui); }
input, select, textarea { font-family: var(--font-ui); outline: none; }
ul, ol { list-style: none; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--gold-light);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =====================================================================
   3. SIDEBAR
   ===================================================================== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-base);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* Sidebar ambient glow top */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 200px;
  background: radial-gradient(ellipse at 50% -20%, rgba(201, 168, 76, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-muted));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--bg-deep);
  box-shadow: var(--shadow-gold);
  flex-shrink: 0;
}

.sidebar-logo-text { display: flex; flex-direction: column; }
.logo-name {
  font-family: var(--font-legal);
  font-size: 15px;
  font-weight: 600;
  color: var(--gold-primary);
  letter-spacing: 0.5px;
  line-height: 1.2;
}
.logo-tagline {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  margin-bottom: 2px;
}

.nav-item i {
  font-size: 18px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.nav-item span { flex: 1; }

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--gold-glow);
  color: var(--gold-primary);
  border: 1px solid var(--border);
}

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

/* Active left border accent */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--gold-primary);
  border-radius: 0 3px 3px 0;
}

.nav-badge {
  background: var(--gold-primary);
  color: var(--bg-deep);
  font-size: 10px;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-avatar {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--gold-primary);
}

.sidebar-user-name {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.sidebar-user-role {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
}

/* =====================================================================
   4. MAIN APP LAYOUT
   ===================================================================== */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* =====================================================================
   5. HEADER
   ===================================================================== */
.app-header {
  height: var(--header-height);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 14px; }

.menu-toggle {
  background: none;
  color: var(--text-secondary);
  font-size: 20px;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: none;
}

.menu-toggle:hover { background: var(--bg-elevated); color: var(--text-primary); }

.header-page-title {
  margin: 0;
  font-family: var(--font-legal);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.header-right { display: flex; align-items: center; gap: 8px; }

/* =====================================================================
   HEADER WIDGETS & DROPDOWNS
   ===================================================================== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-right: 20px;
}

.header-widget {
  position: relative;
  display: flex;
  align-items: center;
}

.header-action-btn {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-action-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--gold-primary);
  color: var(--gold-primary);
}

.header-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  border: 2px solid var(--bg-deep);
  line-height: 1;
}

.header-profile-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-muted), var(--gold-primary));
  color: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
}

.header-profile-avatar:hover {
  border-color: var(--gold-primary);
  box-shadow: 0 0 10px var(--gold-glow);
}

.header-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 320px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-elevated);
  font-size: 14px;
  color: var(--text-primary);
}

.dropdown-link {
  font-size: 12px;
  color: var(--gold-primary);
  text-decoration: none;
  font-weight: 600;
}

.dropdown-link:hover { text-decoration: underline; }

.dropdown-body {
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.dropdown-empty {
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.dropdown-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
}

.dropdown-item.unread-notification {
  background: rgba(201, 168, 76, 0.05);
  border-left: 3px solid var(--gold-primary);
}
.dropdown-item.unread-notification .dropdown-item-title {
  font-weight: 700;
  color: var(--gold-light);
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--bg-hover); }

.dropdown-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.dropdown-item-meta {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.dropdown-profile-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.dropdown-profile-header .dropdown-profile-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--bg-deep);
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border: 1px solid var(--border);
}

.dropdown-profile-info {
  display: flex;
  flex-direction: column;
}

.dropdown-profile-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.dropdown-profile-role {
  font-size: 13px;
  color: var(--text-secondary);
}

/* =====================================================================
   PROFILE UPLOAD WIDGET
   ===================================================================== */
.profile-upload-widget {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--border);
  margin-bottom: 5px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.profile-upload-widget:hover {
  border-color: var(--gold-primary);
  box-shadow: 0 0 15px var(--gold-glow);
}

.profile-upload-icon {
  font-size: 42px;
  opacity: 0.6;
}

.profile-upload-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.profile-upload-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(13, 21, 38, 0.7);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.profile-upload-overlay i {
  font-size: 20px;
  margin-bottom: 2px;
  color: var(--text-primary);
}

.profile-upload-overlay span {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-upload-widget:hover .profile-upload-overlay {
  opacity: 1;
}

/* Timer Widget */
.header-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px 14px;
  margin-right: 8px;
}

.timer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition);
}

.timer-dot.active {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--success); }
  50% { opacity: 0.6; box-shadow: 0 0 16px var(--success); }
}

.timer-display {
  font-family: 'Courier New', monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
  min-width: 72px;
}

.timer-display.active { color: var(--success); }

.btn-icon {
  background: none;
  color: var(--text-secondary);
  font-size: 20px;
  padding: 5px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover { color: var(--gold-primary); }

.header-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  position: relative;
}

.notification-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold-primary);
  border: 1.5px solid var(--bg-base);
}

/* =====================================================================
   6. CONTENT AREA
   ===================================================================== */
.app-content {
  flex: 1;
  padding: 12px 16px;
  overflow-y: auto;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
}

/* When in chat/hub mode, make the content fill the full height flush */
.app-content.chat-mode {
  padding: 0;
  overflow: hidden;
}

/* =====================================================================
   APP FOOTER
   ===================================================================== */
.app-footer {
  flex-shrink: 0;
  height: 32px;
  background: var(--bg-base);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10;
  overflow: hidden;
}

/* Subtle gold top-edge glow */
.app-footer::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-muted), transparent);
  opacity: 0.5;
}

.app-footer-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.app-footer-brand {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-legal);
  font-size: 11px;
  font-weight: 600;
  color: var(--gold-muted);
  letter-spacing: 0.5px;
}

.app-footer-brand i {
  font-size: 13px;
  color: var(--gold-muted);
}

.app-footer-sep {
  color: var(--border);
  font-size: 14px;
  line-height: 1;
}

.app-footer-legal strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.app-footer-link {
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: none;
  letter-spacing: 0.3px;
  transition: color 0.2s;
}

.app-footer-link:hover {
  color: var(--gold-primary);
  text-decoration: underline;
}

.app-footer-copy {
  color: var(--text-muted);
}

/* Footer always visible — including Team Hub chat mode */

/* Page fade-in animation */
.page-view {
  animation: fade-in-up 0.3s ease forwards;
}

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

/* =====================================================================
   7. LOADING SPINNER
   ===================================================================== */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 16px;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--gold-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* =====================================================================
   8. PAGE HEADERS & SECTION UTILITIES
   ===================================================================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header-left { display: flex; flex-direction: column; gap: 4px; }

.page-title {
  font-family: var(--font-legal);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.2px;
}

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

/* =====================================================================
   9. BUTTONS
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #1a5fa8, #1244a0);
  color: #fff;
  border-color: rgba(26, 95, 168, 0.5);
  box-shadow: 0 4px 14px rgba(26, 95, 168, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #2270c2, #1a5fa8);
  box-shadow: 0 6px 20px rgba(26, 95, 168, 0.4);
  transform: translateY(-1px);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-muted));
  color: var(--bg-deep);
  box-shadow: var(--shadow-gold);
}
.btn-gold:hover {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-primary));
  box-shadow: 0 6px 24px rgba(201, 168, 76, 0.35);
  transform: translateY(-1px);
}

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

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(231, 76, 60, 0.25);
}
.btn-danger:hover {
  background: rgba(231, 76, 60, 0.2);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-icon-sm {
  background: none;
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
  cursor: pointer;
  border: none;
}
.btn-icon-sm:hover { color: var(--gold-primary); background: var(--bg-elevated); }

/* =====================================================================
   10. STAT CARDS (Dashboard)
   ===================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: linear-gradient(135deg, var(--bg-card), rgba(26, 38, 71, 0.45));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 22px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
  border-color: rgba(201, 168, 76, 0.3);
  transform: translateY(-4px);
  box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.4), 0 0 20px rgba(201, 168, 76, 0.06);
}

/* Top glow bar */
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
  opacity: 0;
  transition: var(--transition);
}
.stat-card:hover::after { opacity: 1; }

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}

.stat-card-icon.gold { background: var(--gold-glow); color: var(--gold-primary); }
.stat-card-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-card-icon.green { background: var(--success-bg); color: var(--success); }
.stat-card-icon.orange { background: var(--warning-bg); color: var(--warning); }

.stat-card-value {
  font-family: var(--font-ui);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-card-change {
  position: absolute;
  top: 18px;
  right: 18px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
}
.stat-card-change.up { background: var(--success-bg); color: var(--success); }
.stat-card-change.neutral { background: var(--info-bg); color: var(--info); }

/* =====================================================================
   11. CARDS & PANELS
   ===================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i { color: var(--gold-primary); }

.card-body { padding: 20px 22px; }

/* Two-column dashboard layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  margin-bottom: 20px;
}

.dashboard-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* =====================================================================
   12. DATA TABLE
   ===================================================================== */
.data-table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table td {
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: var(--bg-elevated);
}

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

/* =====================================================================
   13. STATUS BADGES
   ===================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-open       { background: var(--success-bg); color: var(--success); }
.badge-closed     { background: var(--info-bg); color: var(--info); }
.badge-pending    { background: var(--warning-bg); color: var(--warning); }
.badge-archived   { background: rgba(100,100,100,0.2); color: var(--text-muted); }
.badge-draft      { background: rgba(100,100,100,0.15); color: var(--text-secondary); }
.badge-sent       { background: var(--info-bg); color: var(--info); }
.badge-paid       { background: var(--success-bg); color: var(--success); }
.badge-overdue    { background: var(--danger-bg); color: var(--danger); }
.badge-void       { background: rgba(100,100,100,0.2); color: var(--text-muted); }
.badge-client     { background: rgba(26, 95, 168, 0.15); color: #5fa8e0; }
.badge-opposing   { background: var(--danger-bg); color: var(--danger); }
.badge-judge      { background: var(--gold-glow); color: var(--gold-primary); }
.badge-low        { background: var(--success-bg); color: var(--success); }
.badge-medium     { background: var(--warning-bg); color: var(--warning); }
.badge-high       { background: var(--danger-bg); color: var(--danger); }

/* =====================================================================
   14. FORM COMPONENTS
   ===================================================================== */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  transition: var(--transition);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-muted); }

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238A96B0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-select option { background: var(--bg-surface); color: var(--text-primary); }

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

/* =====================================================================
   15. MODALS
   ===================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%) scale(0.96);
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  width: 540px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  overflow: hidden;
}

.modal.active {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-legal);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.modal-close {
  background: none;
  color: var(--text-muted);
  font-size: 22px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover { background: var(--danger-bg); color: var(--danger); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

/* =====================================================================
   16. CONTACT CARDS
   ===================================================================== */
/* Contact Layout and Sidebar Split */
.contact-layout-wrapper {
  display: flex;
  gap: 20px;
  margin-top: 10px;
}

.contact-sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: flex-start;
}

.contact-sidebar-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 8px;
  padding-left: 10px;
}

.contact-sidebar-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

.contact-sidebar-item i {
  font-size: 16px;
  margin-right: 8px;
}

.contact-sidebar-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.contact-sidebar-item.active {
  background: var(--gold-glow);
  color: var(--gold-primary);
  border-left: 3px solid var(--gold-primary);
  font-weight: 600;
}

.contact-sidebar-counter {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
}

.contact-sidebar-item.active .contact-sidebar-counter {
  background: var(--gold-primary);
  color: var(--bg-deep);
}

.contact-main-content {
  flex: 1;
  overflow-y: auto;
  max-height: calc(100vh - var(--header-height) - 150px);
  padding-right: 8px;
}

/* Reset individual grid scrolling inside the contacts directory */
.contact-main-content .contacts-grid {
  overflow-y: visible !important;
  max-height: none !important;
  padding: 0;
}

/* View Layout Toggles */
.layout-toggles {
  display: flex;
  gap: 4px;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.toggle-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: transparent;
  transition: var(--transition);
}

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

.toggle-btn.active {
  color: var(--gold-primary);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

/* Alphabetical Grouping */
.alphabet-group {
  margin-bottom: 24px;
}

.alphabet-header {
  font-size: 16px;
  font-family: var(--font-legal);
  font-weight: 700;
  color: var(--gold-primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alphabet-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

/* List View Table */
.contact-list-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.contact-list-table {
  width: 100%;
  border-collapse: collapse;
}

.contact-list-table th,
.contact-list-table td {
  padding: 14px 18px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}

.contact-list-table th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

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

.contact-list-table tr:hover td {
  background: var(--bg-hover);
}

/* Tabbed Modal buttons */
.modal-tabs .modal-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 10px 16px;
  font-weight: 500;
  font-size: 13px;
  transition: var(--transition);
  cursor: pointer;
}

.modal-tabs .modal-tab-btn:hover {
  color: var(--text-primary);
}

.modal-tabs .modal-tab-btn.active {
  border-bottom: 2px solid var(--gold-primary);
  color: var(--gold-primary);
  font-weight: 600;
}

/* FICA status badges */
.badge-fica {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.badge-fica:hover {
  filter: brightness(1.2);
}

.badge-fica-pending {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(243, 156, 18, 0.2);
}

.badge-fica-approved {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(46, 204, 113, 0.2);
}

.badge-fica-rejected {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(231, 76, 60, 0.2);
}

.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.contact-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.contact-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
  opacity: 0;
  transition: var(--transition);
}

.contact-card:hover {
  border-color: var(--glass-border);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.contact-card:hover::before { opacity: 1; }

.contact-card-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-hover));
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-legal);
  font-size: 18px;
  font-weight: 700;
  color: var(--gold-primary);
  margin-bottom: 14px;
  flex-shrink: 0;
}

.contact-card-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.contact-card-company {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.contact-card-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.contact-card-info-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.contact-card-info-item i { color: var(--gold-primary); font-size: 13px; }

.contact-card-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border-light);
  padding-top: 14px;
}

/* =====================================================================
   17. TIMELINE & ACTIVITY
   ===================================================================== */
.activity-list { display: flex; flex-direction: column; }

.activity-item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.activity-body { flex: 1; }
.activity-title { font-size: 13.5px; font-weight: 500; color: var(--text-primary); margin-bottom: 3px; }
.activity-meta { font-size: 11.5px; color: var(--text-muted); }

/* =====================================================================
   18. TASK LIST
   ===================================================================== */
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
}
.task-item:last-child { border-bottom: none; }
.task-item:hover { background: transparent; }

.task-check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  color: transparent;
}

.task-check.done {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

.task-check:hover:not(.done) { border-color: var(--gold-primary); }

.task-content { flex: 1; }
.task-title { font-size: 13.5px; font-weight: 500; color: var(--text-primary); }
.task-title.done { text-decoration: line-through; color: var(--text-muted); }
.task-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* =====================================================================
   19. TOAST NOTIFICATIONS
   ===================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  min-width: 300px;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.toast.removing {
  animation: toast-out 0.25s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(50px); }
}

.toast-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; }
.toast-title { font-size: 13.5px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.toast-msg { font-size: 12px; color: var(--text-secondary); }

.toast-success { border-left: 3px solid var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info { border-left: 3px solid var(--info); }
.toast-info .toast-icon { color: var(--info); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }

/* =====================================================================
   20. EMPTY STATE
   ===================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
  gap: 14px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 52px; color: var(--border); }
.empty-state-title { font-size: 17px; font-weight: 600; color: var(--text-secondary); }
.empty-state-msg { font-size: 13.5px; max-width: 280px; line-height: 1.5; }

/* =====================================================================
   21. CHART CONTAINERS
   ===================================================================== */
.chart-container {
  position: relative;
  width: 100%;
  height: 220px;
}

/* =====================================================================
   22. SEARCH & FILTER BAR
   ===================================================================== */
.search-filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-input-wrapper i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px 9px 38px;
  font-size: 13.5px;
  color: var(--text-primary);
  transition: var(--transition);
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--gold-primary); box-shadow: 0 0 0 3px var(--gold-glow); }

.filter-select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 32px 9px 14px;
  font-size: 13.5px;
  color: var(--text-primary);
  transition: var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238A96B0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.filter-select option { background: var(--bg-surface); }
.filter-select:focus { border-color: var(--gold-primary); outline: none; box-shadow: 0 0 0 3px var(--gold-glow); }

/* =====================================================================
   23. INVOICE CARD
   ===================================================================== */
.invoice-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: var(--transition);
  margin-bottom: 10px;
}

.invoice-card:hover {
  border-color: var(--glass-border);
  background: var(--bg-hover);
}

.invoice-num { font-size: 13px; font-weight: 700; color: var(--gold-primary); }
.invoice-client { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.invoice-matter { font-size: 12px; color: var(--text-secondary); }
.invoice-amount { font-size: 20px; font-weight: 700; font-family: var(--font-legal); color: var(--text-primary); }

/* =====================================================================
   24. PROGRESS BAR
   ===================================================================== */
.progress-bar-wrapper {
  background: var(--bg-surface);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold-muted), var(--gold-primary));
  transition: width 0.6s ease;
}

/* =====================================================================
   25. RESPONSIVE LAYOUT
   ===================================================================== */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .app-main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid-3 { grid-template-columns: 1fr; }
  :root { --header-height: 56px; }
  .app-content { padding: 16px; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .contacts-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .modal { width: calc(100vw - 24px); }
}

/* =====================================================================
   26. MISC UTILITY CLASSES
   ===================================================================== */
.text-gold { color: var(--gold-primary); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.font-legal { font-family: var(--font-legal); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* Gold shimmer on hover for table rows with links */
.matter-link {
  color: var(--text-primary);
  font-weight: 500;
  transition: var(--transition);
}
.matter-link:hover { color: var(--gold-primary); }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* =====================================================================
   KANBAN BOARD (TASKS)
   ===================================================================== */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  min-height: 400px;
}

.kanban-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  max-height: calc(100vh - 220px);
}

.kanban-col.drag-over {
  border-color: var(--gold-primary);
  background: var(--bg-elevated);
  box-shadow: 0 0 10px var(--gold-glow);
}

.kanban-col-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary);
}

.kanban-col-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  min-height: 100px;
}

.kanban-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: grab;
  transition: var(--transition);
  position: relative;
}

.kanban-card:hover {
  border-color: var(--border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card.dragging {
  opacity: 0.5;
  border: 1px dashed var(--gold-primary);
}

.kanban-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding-right: 24px;
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.kanban-card-meta i {
  color: var(--text-muted);
}

.kanban-card-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.kanban-card-delete:hover {
  color: var(--danger);
}

.kanban-time-taken {
  margin-top: 8px;
  font-size: 11px;
  color: var(--info);
  background: var(--info-bg);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}


/* Trial Prep AI Markdown Styles */
#trial-prep-markdown-view {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
}

#trial-prep-markdown-view h1,
#trial-prep-markdown-view h2,
#trial-prep-markdown-view h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: var(--gold);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding-bottom: 0.5rem;
}

#trial-prep-markdown-view h3 {
    font-size: 1.25rem;
    margin-top: 2rem;
    background: rgba(255, 255, 255, 0.02);
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--gold);
    border-radius: 4px;
}

#trial-prep-markdown-view ul {
    list-style-type: disc;
    padding-left: 2rem;
    margin-bottom: 1rem;
}

#trial-prep-markdown-view li {
    margin-bottom: 0.5rem;
}

#trial-prep-markdown-view p {
    margin-bottom: 1rem;
}

#trial-prep-markdown-view .badge {
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
}

/* Trial Prep AI Markdown Styles */
#trial-prep-markdown-view {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
}

#trial-prep-markdown-view h1,
#trial-prep-markdown-view h2,
#trial-prep-markdown-view h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: var(--gold);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding-bottom: 0.5rem;
}

#trial-prep-markdown-view h3 {
    font-size: 1.25rem;
    margin-top: 2rem;
    background: rgba(255, 255, 255, 0.02);
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--gold);
    border-radius: 4px;
}

#trial-prep-markdown-view ul {
    list-style-type: disc;
    padding-left: 2rem;
    margin-bottom: 1rem;
}

#trial-prep-markdown-view li {
    margin-bottom: 0.5rem;
}

#trial-prep-markdown-view p {
    margin-bottom: 1rem;
}

#trial-prep-markdown-view .badge {
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
}

.chat-bubble {
    padding: 10px 14px;
    max-width: 85%;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.user-message .chat-bubble {
    background: linear-gradient(135deg, #1a5fa8, #1244a0);
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.ai-message .chat-bubble {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 2px;
}

.ai-message .chat-bubble b {
    color: var(--gold-primary);
}


/* Trial Prep Markdown Table PDF Layout Safety & Chronology Table Safeguards */
#trial-prep-markdown-view table,
.chronology-table,
.timeline-table { 
  width: 100%; 
  border-collapse: collapse; 
  table-layout: fixed; 
}

#trial-prep-markdown-view td, 
#trial-prep-markdown-view th,
.chronology-table td,
.chronology-table th,
.timeline-table td,
.timeline-table th { 
  word-wrap: break-word; 
  white-space: normal; 
  overflow: hidden; 
  padding: 8px;
  border: 1px solid var(--border-color);
}

/* Force dates and source columns to stay on a single horizontal line in tables */
#trial-prep-markdown-view td:first-child, 
#trial-prep-markdown-view th:first-child, 
#trial-prep-markdown-view .date-column,
.chronology-table td:first-child,
.chronology-table th:first-child,
.chronology-table .date-column,
.timeline-table td:first-child,
.timeline-table th:first-child,
.timeline-table .date-column {
    white-space: nowrap !important;
    width: 120px !important;
}

#trial-prep-markdown-view td:nth-child(2),
#trial-prep-markdown-view th:nth-child(2),
#trial-prep-markdown-view .source-column,
.timeline-table td:nth-child(2),
.timeline-table th:nth-child(2),
.timeline-table .source-column {
    white-space: nowrap !important;
    width: 150px !important;
}

/* In chronology table, Source is column 4 */
.chronology-table td:nth-child(4),
.chronology-table th:nth-child(4),
.chronology-table .source-column {
    white-space: nowrap !important;
    width: 150px !important;
}

/* =====================================================================
   17. COMPCONNEX AGENT CHAT STYLING
   ===================================================================== */
#ai-chat-messages {
  scrollbar-width: thin;
  scrollbar-color: #C9A84C #0D1526;
}

.chat-message {
  display: flex;
  width: 100%;
  margin-bottom: 12px;
}

.chat-message.user-message {
  justify-content: flex-end;
}

.chat-message.ai-message {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  position: relative;
  font-family: var(--font-ui);
  line-height: 1.5;
}

.user-message .chat-bubble {
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-muted));
  color: #080E1A;
  border-bottom-right-radius: 4px;
}

.ai-message .chat-bubble {
  background: var(--bg-elevated);
  border: 1px solid rgba(201, 168, 76, 0.15);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.bubble-sender {
  font-size: 10.5px;
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.user-message .bubble-sender {
  color: rgba(8, 14, 26, 0.75);
}

.ai-message .bubble-sender {
  color: var(--gold-primary);
}

.bubble-text {
  font-size: 13.5px;
  word-wrap: break-word;
}

/* Format parsed markdown content inside AI bubbles */
.bubble-text p {
  margin-bottom: 10px;
}

.bubble-text p:last-child {
  margin-bottom: 0;
}

.bubble-text ul, .bubble-text ol {
  padding-left: 20px;
  margin-bottom: 10px;
}

.bubble-text ul {
  list-style-type: disc;
}

.bubble-text ol {
  list-style-type: decimal;
}

.bubble-text li {
  margin-bottom: 4px;
}

.bubble-text strong {
  font-weight: 700;
  color: inherit;
}

/* =====================================================================
   18. PAGE-LEVEL HEIGHT CONSTRAINTS & INTERNAL SCROLLING UX
   ===================================================================== */
.app-content {
  overflow-y: hidden !important; /* Prevent double scrollbars on the main viewport */
  display: flex;
  flex-direction: column;
}

.page-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-height: calc(100vh - var(--header-height) - 24px);
  overflow: hidden;
}

/* Scroll containers with custom scrollbar variables */
.contacts-grid,
.data-table-wrapper,
.card-body,
.kanban-col-body {
  scrollbar-width: thin;
  scrollbar-color: #C9A84C #0D1526;
}

.data-table-wrapper {
  overflow-y: auto !important;
  max-height: calc(100vh - 260px);
}

.page-view > .card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 252px);
  overflow: hidden;
}

.page-view > .card > .card-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Direct child columns/grids layouts (Documents, LPC, Reports) */
.page-view > div[style*="display:grid"],
.page-view > div[style*="display: grid"],
.page-view > div[style*="display:flex"],
.page-view > div[style*="display: flex"] {
  flex: 1;
  min-height: 0;
  max-height: calc(100vh - 252px);
  overflow: hidden;
}

/* Hub layout override — must fill full available height */
.page-view > .hub-layout {
  max-height: none !important;
  height: auto !important;
}

.page-view > div[style*="display:grid"] > .card,
.page-view > div[style*="display: grid"] > .card,
.page-view > div[style*="display:flex"] > .card,
.page-view > div[style*="display: flex"] > .card {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-view > div[style*="display:grid"] > .card > .card-body,
.page-view > div[style*="display: grid"] > .card > .card-body,
.page-view > div[style*="display:flex"] > .card > .card-body,
.page-view > div[style*="display: flex"] > .card > .card-body {
  flex: 1;
  overflow-y: auto;
}

/* Overrides for scrollable dashboard layouts */
.page-view.scrollable-view {
  max-height: 100% !important;
  overflow-y: auto !important;
  padding-right: 8px;
  display: block !important;
}

.page-view.scrollable-view > * {
  flex-shrink: 0 !important;
}

.tenant-detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.page-view.scrollable-view > div[style*="display:flex"],
.page-view.scrollable-view > div[style*="display: flex"],
.page-view.scrollable-view > div[style*="display:grid"],
.page-view.scrollable-view > div[style*="display: grid"],
.page-view.scrollable-view > .dashboard-grid {
  max-height: none !important;
  height: auto !important;
  overflow: visible !important;
}

.page-view.scrollable-view .card {
  max-height: none !important;
  height: auto !important;
  overflow: visible !important;
}

.page-view.scrollable-view .card-body {
  max-height: none !important;
  overflow-y: visible !important;
}

/* =====================================================================
   ENTERPRISE SUPER ADMIN COMPONENTS
   ===================================================================== */

@keyframes pulse-green {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px #10B981; }
  50%       { opacity: 0.5; box-shadow: 0 0 18px #10B981; }
}
@keyframes blink-red {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* SLA Badges */
.sla-badge       { display:inline-flex;align-items:center;gap:5px;padding:3px 10px;border-radius:20px;font-size:11px;font-weight:600;letter-spacing:.4px; }
.sla-ok          { background:rgba(16,185,129,.12);color:#10B981;border:1px solid rgba(16,185,129,.25); }
.sla-warning     { background:rgba(245,158,11,.12);color:#F59E0B;border:1px solid rgba(245,158,11,.25); }
.sla-critical    { background:rgba(239,68,68,.12);color:#EF4444;border:1px solid rgba(239,68,68,.3);animation:blink-red 1.4s infinite; }
.sla-breached    { background:rgba(127,29,29,.3);color:#FCA5A5;border:1px solid rgba(239,68,68,.5); }

/* Priority Badges */
.priority-badge  { display:inline-block;padding:2px 9px;border-radius:4px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.5px; }
.prio-critical   { background:rgba(239,68,68,.15);color:#EF4444; }
.prio-high       { background:rgba(245,158,11,.15);color:#F59E0B; }
.prio-medium     { background:rgba(59,130,246,.15);color:#60A5FA; }
.prio-low        { background:rgba(107,114,128,.15);color:#9CA3AF; }

/* Escalated chip */
.escalated-chip  { display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:4px;font-size:11px;font-weight:700;color:#EF4444;background:rgba(239,68,68,.1);border:1px solid rgba(239,68,68,.3);animation:blink-red 1.4s infinite; }

/* Health Ring */
.health-ring-wrap{ display:flex;flex-direction:column;align-items:center;gap:6px; }
.health-ring     { position:relative;width:72px;height:72px; }
.health-ring svg { transform:rotate(-90deg); }
.health-ring-bg  { fill:none;stroke:rgba(255,255,255,.06);stroke-width:6; }
.health-ring-fill{ fill:none;stroke-width:6;stroke-linecap:round;transition:stroke-dasharray .8s ease; }
.health-ring-text{ position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:15px;font-weight:700; }
.health-healthy  { stroke:#10B981; }
.health-warning  { stroke:#F59E0B; }
.health-critical { stroke:#EF4444; }

/* Tenant Health Cards */
.health-card          { background:var(--bg-card);border:1px solid var(--border-light);border-radius:var(--radius-md);padding:18px;display:flex;align-items:center;gap:18px;transition:var(--transition); }
.health-card:hover    { border-color:var(--border);background:var(--bg-hover); }
.health-card.status-healthy  { border-left:3px solid #10B981; }
.health-card.status-warning  { border-left:3px solid #F59E0B; }
.health-card.status-critical { border-left:3px solid #EF4444; }
.health-card-info    { flex:1; }
.health-card-name    { font-size:14px;font-weight:600;margin-bottom:4px; }
.health-card-meta    { font-size:12px;color:var(--text-muted);display:flex;gap:14px;flex-wrap:wrap; }
.health-card-actions { display:flex;gap:6px; }

/* Compliance Cards */
.compliance-grid { display:grid;grid-template-columns:repeat(auto-fill,minmax(340px,1fr));gap:14px; }
.compliance-card { background:var(--bg-card);border:1px solid var(--border-light);border-radius:var(--radius-md);padding:16px;display:flex;gap:14px;align-items:flex-start;transition:var(--transition); }
.compliance-card:hover   { border-color:var(--border); }
.compliance-card.sev-critical{ border-left:3px solid #EF4444; }
.compliance-card.sev-high    { border-left:3px solid #F59E0B; }
.compliance-card.sev-medium  { border-left:3px solid #3B82F6; }
.compliance-card.sev-low     { border-left:3px solid #10B981; }
.compliance-icon { width:38px;height:38px;border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:18px;flex-shrink:0; }
.compliance-icon.fica  { background:rgba(245,158,11,.12);color:#F59E0B; }
.compliance-icon.vat   { background:rgba(239,68,68,.12);color:#EF4444; }
.compliance-icon.trust { background:rgba(99,102,241,.12);color:#818CF8; }
.compliance-icon.audit { background:rgba(59,130,246,.12);color:#60A5FA; }
.compliance-icon.kyc   { background:rgba(16,185,129,.12);color:#10B981; }
.compliance-body  { flex:1; }
.compliance-type  { font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:1px;margin-bottom:4px;color:var(--text-muted); }
.compliance-desc  { font-size:13px;margin-bottom:8px;line-height:1.5; }
.compliance-meta  { font-size:11px;color:var(--text-muted); }

/* Performance Bars */
.perf-bar-wrap  { display:flex;flex-direction:column;gap:14px; }
.perf-bar-row   { display:flex;flex-direction:column;gap:6px; }
.perf-bar-label { display:flex;justify-content:space-between;font-size:12px;color:var(--text-secondary); }
.perf-bar-label span:last-child { font-weight:600;color:var(--text-primary); }
.perf-bar-track { height:6px;background:rgba(255,255,255,.06);border-radius:4px;overflow:hidden; }
.perf-bar-fill  { height:100%;border-radius:4px;transition:width 1s cubic-bezier(.4,0,.2,1); }
.perf-bar-fill.ok    { background:linear-gradient(90deg,#10B981,#34D399); }
.perf-bar-fill.warn  { background:linear-gradient(90deg,#F59E0B,#FCD34D); }
.perf-bar-fill.danger{ background:linear-gradient(90deg,#EF4444,#FCA5A5); }

/* Ticket Rows */
.ticket-row      { display:grid;grid-template-columns:1fr auto auto auto auto;gap:16px;align-items:center;padding:14px 16px;border-bottom:1px solid var(--border-light);transition:var(--transition); }
.ticket-row:hover{ background:var(--bg-hover); }
.ticket-row:last-child { border-bottom:none; }
.ticket-subject  { font-size:14px;font-weight:500;margin-bottom:4px; }
.ticket-meta     { font-size:12px;color:var(--text-muted);display:flex;gap:10px; }
.ticket-escalated .ticket-subject { color:#EF4444; }

/* Audit Log Rows */
.audit-row       { display:grid;grid-template-columns:160px 1fr 140px 110px;gap:12px;align-items:center;padding:10px 16px;border-bottom:1px solid var(--border-light);font-size:12px;transition:var(--transition); }
.audit-row:hover { background:var(--bg-hover); }
.audit-row:last-child{ border-bottom:none; }
.audit-timestamp { color:var(--text-muted);font-family:monospace; }
.audit-detail    { color:var(--text-secondary); }
.audit-actor     { font-weight:600;color:var(--gold-primary); }
.audit-action-badge { display:inline-block;padding:2px 8px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.5px;background:rgba(59,130,246,.12);color:#60A5FA; }

/* Analytics Bar Chart */
.analytics-bar-chart { display:flex;align-items:flex-end;gap:10px;height:160px;border-bottom:1px solid rgba(255,255,255,.08);border-left:1px solid rgba(255,255,255,.08);padding:0 0 0 8px; }
.analytics-bar-col   { flex:1;display:flex;flex-direction:column;justify-content:flex-end;align-items:center;gap:5px;height:100%; }
.analytics-bar       { width:100%;border-radius:5px 5px 0 0;background:linear-gradient(to top,var(--gold-primary),#E5C369);transition:height 1s cubic-bezier(.4,0,.2,1);min-height:4px; }
.analytics-bar-label { font-size:10px;color:var(--text-muted);text-align:center;line-height:1.3; }

/* Filter Bar */
.sa-filter-bar { display:flex;gap:10px;align-items:center;flex-wrap:wrap;padding:14px 16px;background:var(--bg-elevated);border-bottom:1px solid var(--border-light);border-radius:var(--radius-md) var(--radius-md) 0 0; }
.sa-filter-bar select,.sa-filter-bar input { background:var(--bg-surface);border:1px solid var(--border-light);color:var(--text-primary);border-radius:8px;padding:7px 12px;font-size:13px;font-family:var(--font-ui);cursor:pointer; }
.sa-filter-bar select:focus,.sa-filter-bar input:focus { outline:none;border-color:var(--gold-primary); }

/* Plan Chips */
.plan-chip           { display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;font-size:12px;font-weight:600; }
.plan-starter        { background:rgba(107,114,128,.15);color:#9CA3AF; }
.plan-professional   { background:rgba(59,130,246,.15);color:#60A5FA; }
.plan-enterprise     { background:rgba(201,168,76,.15);color:#C9A84C; }

/* Severity text */
.sev-critical-text { color:#EF4444;font-weight:700; }
.sev-high-text     { color:#F59E0B;font-weight:700; }
.sev-medium-text   { color:#60A5FA; }
.sev-low-text      { color:#10B981; }

/* SA nav badge alert (red) */
.sa-badge-alert { background:#EF4444 !important;color:#fff !important; }

/* Floating Support Button */
.floating-support-btn {
  position: fixed;
  bottom: 8px;
  right: 24px;
  background-color: #1b365d;
  color: #ffffff;
  border: none;
  border-radius: 50px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  transition: all 0.2s ease;
  font-family: var(--font-ui);
}

.floating-support-btn:hover {
  background-color: #274b7d;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.floating-support-btn i {
  font-size: 20px;
}


/* Global Scrollbar Override — track: dark navy, thumb: gold */
::-webkit-scrollbar, *::-webkit-scrollbar {
  width: 10px !important;
  height: 10px !important;
}
::-webkit-scrollbar-track, *::-webkit-scrollbar-track {
  background: #0D1526 !important;
  border-radius: 5px !important;
}
::-webkit-scrollbar-thumb, *::-webkit-scrollbar-thumb {
  background: #C9A84C !important;
  border-radius: 5px !important;
  border: 2px solid #0D1526 !important;
}
::-webkit-scrollbar-thumb:hover, *::-webkit-scrollbar-thumb:hover {
  background: #E2C87A !important;
}
::-webkit-scrollbar-button, *::-webkit-scrollbar-button {
  display: none !important;
}
* {
  scrollbar-width: thin;
  scrollbar-color: #C9A84C #0D1526;
}

/* =====================================================================
   @MENTION DROPDOWN
   ===================================================================== */
.hub-mention-dropdown {
  position: fixed;
  z-index: 99999;
  background: var(--bg-surface);
  border: 1.5px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  padding: 6px;
  display: none;
  max-height: 280px;
  overflow-y: auto;
  animation: mentionFadeIn 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 200px;
}

@keyframes mentionFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hub-mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-size: 13.5px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  user-select: none;
}

.hub-mention-item:hover,
.hub-mention-item.hub-mention-active {
  background: var(--gold-glow);
  color: var(--gold-primary);
}

.hub-mention-item:hover span,
.hub-mention-item.hub-mention-active span {
  color: var(--gold-primary);
}

/* @Name pill shown inside rendered chat messages */
.hub-mention-highlight {
  display: inline-block;
  background: rgba(0, 0, 0, 0.22);
  color: #ffffff;
  font-weight: 700;
  border-radius: 5px;
  padding: 0 5px;
  font-size: 0.93em;
  letter-spacing: 0.01em;
}

/* =====================================================================
   RAF PRACTICE HUB — Executive Legal Practice Design System
   ===================================================================== */

/* Top Metrics & KPI Grid */
.raf-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.raf-metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.raf-metric-card:hover {
  border-color: var(--gold-primary);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.raf-metric-card.active-filter {
  border-color: var(--gold-primary);
  background: rgba(201, 168, 76, 0.1);
  box-shadow: 0 0 0 1px var(--gold-primary), 0 4px 12px rgba(201, 168, 76, 0.2);
}

.raf-metric-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: transparent;
  transition: background 0.2s;
}

.raf-metric-card.card-blue::after { background: #3B82F6; }
.raf-metric-card.card-orange::after { background: #F59E0B; }
.raf-metric-card.card-gold::after { background: var(--gold-primary); }
.raf-metric-card.card-green::after { background: #10B981; }

.raf-metric-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.raf-metric-card:hover .raf-metric-icon {
  transform: scale(1.08);
}

.raf-metric-icon.blue { background: rgba(59, 130, 246, 0.14); color: #60A5FA; }
.raf-metric-icon.orange { background: rgba(245, 158, 11, 0.14); color: #FBBF24; }
.raf-metric-icon.gold { background: rgba(201, 168, 76, 0.14); color: var(--gold-primary); }
.raf-metric-icon.green { background: rgba(16, 185, 129, 0.14); color: #34D399; }

.raf-metric-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.raf-metric-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.raf-metric-lbl {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
}

.raf-metric-hint {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quick Filter Pills */
.raf-filter-group {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.raf-filter-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.18s;
}

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

.raf-filter-btn.active {
  background: var(--gold-primary);
  color: #080E1A;
  border-color: var(--gold-primary);
  font-weight: 700;
}

.raf-filter-count {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
}

.raf-filter-btn.active .raf-filter-count {
  background: rgba(0, 0, 0, 0.25);
  color: #080E1A;
}

/* Claims Register Card & Items */
.raf-claim-item-card {
  padding: 12px 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
  position: relative;
}

.raf-claim-item-card:hover {
  background: var(--bg-hover);
  border-color: var(--border);
  transform: translateX(2px);
}

.raf-claim-item-card.active-claim-card {
  background: rgba(201, 168, 76, 0.08);
  border-color: rgba(201, 168, 76, 0.4);
  border-left: 3px solid var(--gold-primary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.raf-claimant-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-primary);
  background: rgba(201, 168, 76, 0.12);
  border: 1px solid rgba(201, 168, 76, 0.3);
  flex-shrink: 0;
}

/* Stepper Pipeline */
.raf-stepper-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  position: relative;
}

.raf-step-node {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  background: var(--bg-card);
  position: relative;
}

.raf-step-node:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}

.raf-step-node.completed {
  border-color: rgba(16, 185, 129, 0.2);
}

.raf-step-node.active {
  background: rgba(201, 168, 76, 0.12);
  border-color: rgba(201, 168, 76, 0.4);
  box-shadow: 0 0 12px rgba(201, 168, 76, 0.15);
}

.raf-step-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1.5px solid var(--border-light);
  flex-shrink: 0;
  transition: var(--transition);
}

.raf-step-node.completed .raf-step-circle {
  background: rgba(16, 185, 129, 0.18);
  color: #10B981;
  border-color: #10B981;
}

.raf-step-node.active .raf-step-circle {
  background: var(--gold-primary);
  color: #080E1A;
  border-color: var(--gold-primary);
  font-weight: 800;
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.4);
}

.raf-step-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.raf-step-node.active .raf-step-label {
  color: var(--gold-primary);
  font-weight: 700;
}

.raf-step-node.completed .raf-step-label {
  color: var(--text-primary);
}

/* Tab Pills */
.raf-pill-tab {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: var(--transition);
  white-space: nowrap;
}

.raf-pill-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-color: var(--border);
}

.raf-pill-tab.active-tab {
  background: var(--gold-primary);
  color: #080E1A;
  border-color: var(--gold-primary);
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(201, 168, 76, 0.3);
}

.raf-pill-tab .badge-count {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.raf-pill-tab.active-tab .badge-count {
  background: rgba(8, 14, 26, 0.25);
  color: #080E1A;
  font-weight: 800;
}

/* Category card in checklist */
.raf-check-category-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.raf-check-category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
}

.raf-check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  transition: all 0.18s;
}

.raf-check-row:hover {
  border-color: var(--border);
  background: var(--bg-hover);
}

.raf-check-row.checked {
  background: rgba(16, 185, 129, 0.05);
  border-color: rgba(16, 185, 129, 0.28);
}

/* Specialist Row Card */
.expert-row-card {
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.expert-row-card:hover {
  border-color: var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Quantum Trust Distribution Card */
.raf-trust-calc-box {
  background: var(--bg-elevated);
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.raf-statutory-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Sticky Action Bar */
.raf-action-bar {
  border-top: 1px solid var(--border-light);
  margin-top: 20px;
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-card);
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 14px 20px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Portfolio Directory Grid & Cards */
.raf-portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 18px;
}

.raf-portfolio-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  position: relative;
  overflow: hidden;
}

.raf-portfolio-card:hover {
  border-color: rgba(201, 168, 76, 0.5);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  transform: translateY(-2px);
}

.raf-portfolio-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  transition: background 0.2s;
}

.raf-portfolio-card.urgent::before {
  background: #EF4444;
}

.raf-portfolio-card.moratorium::before {
  background: var(--gold-primary);
}

.raf-portfolio-card.settled::before {
  background: #10B981;
}

.raf-portfolio-card.court::before {
  background: #3B82F6;
}

.raf-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.raf-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-surface);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  font-size: 12px;
}

.raf-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--border-light);
}

.raf-doc-progress-bar {
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.raf-doc-progress-fill {
  height: 100%;
  background: var(--gold-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Focused Dossier Workspace Navigation */
.raf-dossier-top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  background: var(--bg-card);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  margin-bottom: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Formal Statutory Dossier Document (A4 Print & Preview) */
.raf-dossier-preview-container {
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px 10px;
  background: #1f2937;
  display: flex;
  justify-content: center;
}

.raf-dossier-paper {
  background: #ffffff;
  color: #111827;
  width: 100%;
  max-width: 820px;
  padding: 40px 48px;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.55;
}

.dossier-firm-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 14px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.dossier-firm-name {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.dossier-firm-sub {
  font-size: 11px;
  color: #475569;
  font-weight: 600;
  margin-top: 2px;
}

.dossier-firm-contact {
  font-size: 10px;
  color: #64748b;
  margin-top: 3px;
}

.dossier-stamp-badge {
  border: 1.5px solid #0f172a;
  padding: 6px 12px;
  text-align: right;
  border-radius: 4px;
  background: #f8fafc;
}

.dossier-stamp-title {
  font-size: 11px;
  font-weight: 800;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dossier-stamp-act {
  font-size: 9.5px;
  color: #b45309;
  font-weight: 700;
}

.dossier-title-bar {
  background: #0f172a;
  color: #ffffff;
  padding: 10px 16px;
  text-align: center;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: 3px;
  margin-bottom: 16px;
}

.dossier-section {
  margin-bottom: 18px;
  page-break-inside: avoid;
  break-inside: avoid;
}

.dossier-section-title {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1.5px solid #cbd5e1;
  padding-bottom: 4px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dossier-grid-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

.dossier-grid-table th,
.dossier-grid-table td {
  border: 1px solid #e2e8f0;
  padding: 7px 10px;
  font-size: 11.5px;
}

.dossier-grid-table th {
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  text-align: left;
}

.dossier-grid-table td.label-cell {
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
  width: 25%;
}

.dossier-sig-box {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid #cbd5e1;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  page-break-inside: avoid;
  break-inside: avoid;
}

.dossier-sig-cell {
  border: 1px dashed #94a3b8;
  padding: 12px;
  border-radius: 4px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
}

/* =====================================================================
   UTILITY COMPATIBILITY & PRINT SAFEGUARDS
   ===================================================================== */
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.form-control:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--gold-primary);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--gold-primary);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.status-active {
  background: var(--success-bg);
  color: var(--success);
}

.status-suspended {
  background: var(--danger-bg);
  color: var(--danger);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.ri-spin {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@media print {
  .sidebar,
  .app-header,
  .app-footer,
  .floating-support-btn,
  .modal-backdrop,
  .modal-header,
  .modal-footer,
  .raf-dossier-modal-toolbar,
  .page-header,
  .raf-metrics-grid,
  .raf-directory-toolbar,
  .raf-portfolio-grid,
  .raf-dossier-top-nav,
  .raf-stepper-container,
  .raf-action-bar {
    display: none !important;
  }
  
  body {
    overflow: visible !important;
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  .app-main,
  .app-content,
  .page-view {
    overflow: visible !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* When printing Dossier */
  .modal {
    position: static !important;
    display: block !important;
    max-width: 100% !important;
    width: 100% !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
  }

  .raf-dossier-preview-container {
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    background: transparent !important;
  }

  .raf-dossier-paper {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    color: #111827 !important;
  }

  .dossier-section {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin-bottom: 12pt !important;
  }

  .dossier-sig-box {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .dossier-grid-table th {
    background: #f1f5f9 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .dossier-title-bar {
    background: #0f172a !important;
    color: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}




/* ---- RAF redesign: compact KPI strip, dossier overlay, print isolation ---- */
.raf-metrics-grid { gap: 12px; margin-bottom: 18px; }
.raf-metric-card { padding: 10px 14px; gap: 12px; }
.raf-metric-icon { width: 36px; height: 36px; font-size: 17px; }
.raf-metric-hint { display: none; }
.raf-metric-val { font-size: 18px; }

.raf-dossier-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(8, 14, 26, 0.94);
  display: flex;
  flex-direction: column;
  outline: none;
}
.raf-dossier-modal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: #0b1220;
}
.raf-dossier-overlay .raf-dossier-preview-container {
  flex: 1;
  max-height: none;
}

@page { size: A4; margin: 14mm; }

@media print {
  body.raf-printing-dossier > *:not(#raf-dossier-modal-root) { display: none !important; }
  body.raf-printing-dossier .raf-dossier-overlay {
    position: static !important;
    background: #ffffff !important;
    display: block !important;
  }
}

.raf-dossier-preview-container { align-items: flex-start; }
.raf-dossier-paper { flex-shrink: 0; min-height: min-content; }
.dossier-grid-table td { background: #ffffff; color: #111827; }
.dossier-grid-table td.label-cell { background: #f8fafc; color: #475569; }

.raf-print-menu summary::-webkit-details-marker { display: none; }
.raf-print-menu summary::marker { content: ''; }


/* Quick search palette */
.ccx-qs-overlay{position:fixed;inset:0;z-index:10000;background:rgba(8,14,26,.72);backdrop-filter:blur(3px);display:flex;align-items:flex-start;justify-content:center;padding:12vh 16px 16px}
.ccx-qs-box{width:100%;max-width:620px;background:var(--bg-card);border:1px solid var(--border-light);border-radius:12px;box-shadow:0 24px 60px rgba(0,0,0,.5);overflow:hidden}
.ccx-qs-head{display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1px solid var(--border-light);color:var(--text-muted)}
.ccx-qs-head input{flex:1;background:transparent;border:0;outline:0;color:var(--text-primary);font-size:15px}
.ccx-qs-box kbd,.ccx-qs-btn kbd{font-size:10px;padding:2px 6px;border:1px solid var(--border-light);border-radius:4px;color:var(--text-muted);background:var(--bg-elevated)}
.ccx-qs-list{max-height:52vh;overflow-y:auto;padding:6px}
.ccx-qs-group{font-size:10.5px;font-weight:700;letter-spacing:.6px;text-transform:uppercase;color:var(--text-muted);padding:8px 10px 4px}
.ccx-qs-item{display:flex;align-items:center;gap:10px;padding:9px 10px;border-radius:8px;cursor:pointer;color:var(--text-secondary);font-size:13.5px}
.ccx-qs-item.active,.ccx-qs-item:hover{background:rgba(201,168,76,.14);color:var(--text-primary)}
.ccx-qs-item i{color:var(--gold-primary);font-size:16px}
.ccx-qs-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ccx-qs-sub{font-size:11.5px;color:var(--text-muted);white-space:nowrap}
.ccx-qs-empty{padding:26px;text-align:center;color:var(--text-muted);font-size:13px}
.ccx-qs-foot{display:flex;gap:16px;padding:8px 14px;border-top:1px solid var(--border-light);font-size:11px;color:var(--text-muted)}
.ccx-qs-btn{display:inline-flex;align-items:center;gap:6px;margin-right:6px}
@media (max-width:760px){.ccx-qs-btn-text,.ccx-qs-btn kbd{display:none}.ccx-qs-foot{display:none}.ccx-qs-overlay{padding-top:6vh}}

.hub-sidebar-item:focus-visible,
.hub-feed-select:focus-visible {
  outline: 2px solid var(--gold-primary);
  outline-offset: -2px;
}

.hub-feed-select {
  border-radius: 6px;
}

@media (max-width: 760px) {
  .page-view > .hub-layout {
    flex-direction: column !important;
    height: 100%;
    border-radius: 0;
  }

  .hub-sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-height: 34vh;
    max-height: 34dvh;
    flex: 0 0 min(34vh, 260px);
    flex-basis: min(34dvh, 260px);
    border-right: 0 !important;
    border-bottom: 1px solid var(--border);
  }

  .hub-main {
    min-height: 0;
    flex: 1 1 0;
  }
}

/* Responsive application shell and shared component sizing */
.app-main,
.app-content,
.page-view,
.card,
.card-body {
  min-width: 0;
}

.page-view img,
.card img,
.modal img,
.page-view canvas,
.card canvas {
  max-width: 100%;
}

.data-table-wrapper {
  max-width: 100%;
  overflow-x: auto !important;
  overscroll-behavior-x: contain;
}

.modal {
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

@media (max-width: 900px) {
  .sidebar {
    height: 100vh;
    height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .app-main {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-width: 0;
  }

  .app-header {
    min-height: var(--header-height);
    height: auto;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    gap: 8px;
  }

  .header-left,
  .header-right,
  .header-actions {
    min-width: 0;
  }

  .header-actions {
    gap: 8px;
    margin-right: 0;
  }

  .header-timer {
    max-width: 100%;
  }

  .app-content {
    min-height: 0;
    padding: 12px max(12px, env(safe-area-inset-right)) 16px
      max(12px, env(safe-area-inset-left));
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
  }

  .app-content.chat-mode {
    overflow: hidden !important;
  }

  .page-view {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
    padding-bottom: 8px;
  }

  .page-view:has(> .hub-layout) {
    flex: 1 1 0;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    padding-bottom: 0;
  }

  .page-view > .hub-layout {
    height: 100% !important;
    min-height: 0;
  }

  .page-view > .card,
  .page-view > div[style*="display:grid"] > .card,
  .page-view > div[style*="display: grid"] > .card,
  .page-view > div[style*="display:flex"] > .card,
  .page-view > div[style*="display: flex"] > .card {
    min-width: 0;
    max-width: 100%;
  }

  .page-header {
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
  }

  .page-header-left {
    min-width: min(100%, 240px);
  }

  .page-header > .btn,
  .page-header > button {
    max-width: 100%;
  }

  .nav-item,
  .btn,
  .modal-close {
    min-height: 44px;
  }

  .form-input,
  .form-select,
  .form-textarea,
  input,
  select,
  textarea {
    max-width: 100%;
  }
}

@media (max-width: 760px) {
  .app-content {
    overflow-y: auto !important;
  }

  .page-view {
    flex: 0 0 auto;
    height: auto;
    max-height: none;
    overflow: visible;
    padding-bottom: 8px;
  }

  .page-view > .card,
  .page-view > div[style*="display:grid"],
  .page-view > div[style*="display: grid"],
  .page-view > div[style*="display:flex"],
  .page-view > div[style*="display: flex"] {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .page-view > div[style*="display:grid"] > .card,
  .page-view > div[style*="display: grid"] > .card,
  .page-view > div[style*="display:flex"] > .card,
  .page-view > div[style*="display: flex"] > .card {
    height: auto;
    overflow: visible;
  }

  .page-view > .card > .card-body,
  .page-view > div[style*="display:grid"] > .card > .card-body,
  .page-view > div[style*="display: grid"] > .card > .card-body,
  .page-view > div[style*="display:flex"] > .card > .card-body,
  .page-view > div[style*="display: flex"] > .card > .card-body {
    max-height: none;
    overflow: visible;
  }

  .page-view.scrollable-view {
    max-height: none !important;
    overflow: visible !important;
    padding-right: 0;
  }

  .page-view:has(> .hub-layout) {
    flex: 1 1 0;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    padding-bottom: 0;
  }

  .page-view > .hub-layout {
    min-height: 0;
    max-height: 100%;
  }

  .page-title {
    font-size: clamp(20px, 5vw, 24px);
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

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

  .app-footer {
    min-height: 32px;
    height: auto;
    padding: 6px max(10px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .app-footer-inner {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 8px;
    white-space: normal;
    text-align: center;
  }

  .modal {
    width: calc(100vw - 24px);
    width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-width: 640px;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-radius: var(--radius-lg);
  }

  .modal-header {
    padding: 14px 16px;
    gap: 10px;
  }

  .modal-title {
    min-width: 0;
    font-size: 15px;
    line-height: 1.35;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .modal-footer > .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .form-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .ticket-row,
  .audit-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .ticket-row > *,
  .audit-row > * {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .ticket-row > div:last-child {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 15px;
  }

  .app-header {
    gap: 4px;
  }

  .header-page-title {
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-actions {
    gap: 4px;
  }

  .header-timer .timer-display {
    font-size: 12px;
  }

  .header-action-btn,
  .header-profile-avatar {
    width: 36px;
    height: 36px;
  }

  .app-content {
    padding-top: 10px;
  }

  .stats-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

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

  .modal {
    width: calc(100vw - 16px);
    max-width: none;
  }

  .modal-tabs {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .modal-tabs .modal-tab-btn {
    flex: 0 0 auto;
  }
}

@media (max-width: 360px) {
  .header-timer {
    gap: 2px;
  }

  .header-timer .timer-display {
    display: none;
  }

  .stats-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    width: min(300px, 88vw);
    min-width: min(300px, 88vw);
  }
}

/* =====================================================================
   SUPER ADMIN BILLING — compact summary + tabbed panels
   ===================================================================== */
.billing-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.billing-summary-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  font-size: 13px;
}
.billing-summary-item i { font-size: 16px; }
.billing-summary-label { color: var(--text-secondary); }
.billing-summary-value { font-weight: 700; color: var(--text-primary); font-size: 15px; }

.billing-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  flex-shrink: 0;
  overflow-x: auto;
}
.billing-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--text-secondary);
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}
.billing-tab:hover { color: var(--text-primary); }
.billing-tab.active {
  color: var(--gold-primary);
  border-bottom-color: var(--gold-primary);
  font-weight: 600;
}
.billing-tab-count {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}
.billing-tab.active .billing-tab-count {
  background: rgba(201, 168, 76, 0.15);
  color: var(--gold-primary);
}

.page-view > .card.billing-panel { display: none; }
.page-view > .card.billing-panel.active {
  display: flex;
  flex: 1 1 auto;
  max-height: none;
}
.billing-panel .data-table-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}
.billing-panel[data-panel="chart"] .card-body { min-height: 300px; }

/* Billing — Paystack status banner & transaction details */
.ps-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 10px 20px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ps-banner > i { font-size: 16px; }
.ps-banner-ok { background: rgba(16, 185, 129, 0.07); color: var(--text-primary); }
.ps-banner-ok > i { color: #10B981; }
.ps-banner-warn { background: rgba(245, 158, 11, 0.08); color: var(--text-primary); }
.ps-banner-warn > i { color: #F59E0B; }
.ps-banner-stat { color: var(--text-secondary); }
.ps-banner-stat b { color: var(--text-primary); }
.ps-mode-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 1px 7px;
  border-radius: 999px;
  vertical-align: middle;
}
.ps-mode-live { background: rgba(16, 185, 129, 0.15); color: #10B981; }
.ps-mode-test, .ps-mode-unknown { background: rgba(245, 158, 11, 0.15); color: #F59E0B; }
.tx-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.status-pending { background: rgba(245, 158, 11, 0.12); color: #F59E0B; }

/* Billing — subscriptions management */
.billing-summary-item.is-alert { border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.06); }
.billing-tab-count.is-alert, .billing-tab.active .billing-tab-count.is-alert { background: rgba(239, 68, 68, 0.18); color: #F87171; }
.ps-mode-bad { background: rgba(239, 68, 68, 0.15); color: #F87171; }
.ps-mode-none { background: rgba(255, 255, 255, 0.06); color: var(--text-muted); font-weight: 600; }
.subs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.subs-chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: var(--transition);
}
.subs-chip span { margin-left: 4px; opacity: 0.75; }
.subs-chip:hover { color: var(--text-primary); border-color: rgba(201, 168, 76, 0.4); }
.subs-chip.active { background: rgba(201, 168, 76, 0.14); border-color: var(--gold-primary); color: var(--gold-primary); font-weight: 600; }
.subs-chip.alert:not(.active) { border-color: rgba(239, 68, 68, 0.45); color: #F87171; }
.subs-table td { vertical-align: top; }
.subs-issue { display: flex; gap: 7px; align-items: flex-start; font-size: 12.5px; line-height: 1.4; color: var(--text-secondary); margin-bottom: 4px; }
.subs-issue .dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; background: #10B981; }
.subs-issue.warn .dot { background: #F59E0B; }
.subs-issue.danger { color: var(--text-primary); }
.subs-issue.danger .dot { background: #EF4444; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.plan-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; background: linear-gradient(135deg, var(--bg-card), rgba(26, 38, 71, 0.45)); }
.plan-card-name { font-weight: 700; font-size: 16px; color: var(--gold-primary); }
.plan-card-price { font-size: 24px; font-weight: 700; margin: 8px 0 2px; color: var(--text-primary); }
.plan-card-price span { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-left: 2px; }
.plan-card-stats { display: flex; gap: 18px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.plan-card-stats div { display: flex; flex-direction: column; }
.plan-card-stats b { font-size: 18px; color: var(--text-primary); }
.plan-card-stats span { font-size: 11.5px; color: var(--text-muted); }
.plan-card-code { margin-top: 10px; font-family: monospace; font-size: 11px; color: var(--text-muted); }
.firm-billing-modal { width: 680px; }
.fbm-issues { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-hover); margin-bottom: 16px; }
.fbm-issues .subs-issue:last-child { margin-bottom: 0; }
.fbm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin-bottom: 8px; font-size: 13.5px; }
.fbm-grid > div > span:first-child { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 3px; }
.fbm-section { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.fbm-title { font-weight: 600; font-size: 13.5px; margin-bottom: 10px; color: var(--text-primary); }
.fbm-link-out { margin-top: 10px; }
@media (max-width: 600px) { .fbm-grid { grid-template-columns: 1fr; } }
.ps-mode-pill { white-space: nowrap; }
.firm-billing-modal .btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: nowrap; }
.fin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.fin-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; background: var(--bg-hover); }
.fin-card.is-alert { border-color: rgba(239, 68, 68, 0.5); background: rgba(239, 68, 68, 0.06); }
.fin-card.is-warn { border-color: rgba(245, 158, 11, 0.45); background: rgba(245, 158, 11, 0.05); }
.fin-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.fin-value { font-size: 22px; font-weight: 700; color: var(--text-primary); margin: 6px 0 4px; }

/* Firm portal — subscription */
#subscription-modal { width: 520px; }
.nav-badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #EF4444; color: #fff; font-size: 11px; font-weight: 700; align-items: center; justify-content: center; }
.fs-plan { border: 1px solid rgba(201, 168, 76, 0.35); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; background: linear-gradient(135deg, rgba(201, 168, 76, 0.08), transparent); }
.fs-plan-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }
.fs-plan-name { font-size: 20px; font-weight: 700; color: var(--gold-primary); margin: 4px 0; }
.fs-plan-price { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.fs-plan-price span { font-size: 13px; font-weight: 400; color: var(--text-secondary); }
.fs-plan-desc { margin-top: 8px; font-size: 13px; color: var(--text-secondary); }
.fs-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.5; margin-bottom: 14px; }
.fs-note.info { background: rgba(59, 130, 246, 0.08); border: 1px solid rgba(59, 130, 246, 0.3); }
.fs-note.warn { background: rgba(245, 158, 11, 0.08); border: 1px solid rgba(245, 158, 11, 0.35); }
.fs-note i { font-size: 18px; margin-top: 1px; }
.fs-points { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; font-size: 13.5px; color: var(--text-secondary); }
.fs-points i { color: var(--gold-primary); margin-right: 8px; }
.fs-cta { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.fs-status { display: flex; align-items: center; gap: 8px; font-size: 16px; margin-bottom: 6px; }
.fs-status .dot { width: 10px; height: 10px; border-radius: 50%; background: #10B981; }
.fs-status.warn .dot { background: #F59E0B; }
.fs-status.bad .dot { background: #EF4444; }
.fs-sub { color: var(--text-secondary); font-size: 13px; margin: 0 0 12px; }
.fs-card { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.subs-issue.info .dot { background: #3B82F6; }
.fs-card .fs-sub { margin: 0; }

/* Firm portal — billing lock & warning banner */
#billing-lock { position: fixed; inset: 0; z-index: 250; display: none; align-items: center; justify-content: center; padding: 16px;
  background: rgba(5, 9, 18, 0.88); backdrop-filter: blur(6px); }
#billing-lock.active { display: flex; }
.bl-card { width: 100%; max-width: 520px; background: var(--bg-surface); border: 1px solid rgba(201, 168, 76, 0.3); border-radius: 18px;
  padding: 32px 28px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); max-height: calc(100vh - 32px); overflow-y: auto; }
.bl-icon { width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center;
  background: rgba(201, 168, 76, 0.12); color: var(--gold-primary); font-size: 28px; }
.bl-card h2 { margin: 0 0 10px; font-size: 22px; color: var(--text-primary); }
.bl-msg { color: var(--text-secondary); font-size: 14.5px; line-height: 1.6; margin: 0 0 20px; }
.bl-invoices { display: grid; gap: 8px; margin-bottom: 16px; text-align: left; }
.bl-invoice { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; }
.bl-amount { font-weight: 700; color: var(--text-primary); }
.bl-sub { font-size: 12.5px; color: var(--text-muted); }
.bl-cta { width: 100%; justify-content: center; padding: 12px; font-size: 15px; margin-bottom: 6px; }
.bl-note { display: flex; gap: 10px; text-align: left; padding: 12px 14px; border-radius: 10px; background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.3); font-size: 13.5px; line-height: 1.5; margin-bottom: 12px; }
.bl-foot { display: flex; justify-content: center; gap: 22px; margin: 18px 0 10px; font-size: 13.5px; }
.bl-foot a { color: var(--gold-primary); text-decoration: none; }
.billing-banner { display: flex; align-items: center; gap: 10px; padding: 10px 16px; margin: 0 0 12px; border-radius: 10px; font-size: 13.5px;
  background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.4); color: var(--text-primary); }
.billing-banner.grace { background: rgba(59, 130, 246, 0.08); border-color: rgba(59, 130, 246, 0.35); }
.billing-banner > i { font-size: 18px; color: #F59E0B; }
.billing-banner.grace > i { color: #60A5FA; }
.billing-banner span { flex: 1; }
.bb-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; }
.fs-invoice { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.fs-inv-amt { font-weight: 600; }
.fs-paid { color: #10B981; font-size: 12.5px; white-space: nowrap; }
@media (max-width: 600px) { .bl-invoice, .fs-invoice { grid-template-columns: 1fr auto; } .bl-invoice .btn, .fs-invoice .btn { grid-column: 1 / -1; justify-content: center; } }

/* Firm plan picker */
.fs-plan-picker { display: grid; gap: 8px; margin: 4px 0 16px; }
.fs-plan-option { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-hover); color: var(--text-primary); cursor: pointer; transition: var(--transition); font: inherit; }
.fs-plan-option:hover { border-color: rgba(201, 168, 76, 0.5); }
.fs-plan-option.selected { border-color: var(--gold-primary); background: rgba(201, 168, 76, 0.08); box-shadow: 0 0 0 1px var(--gold-primary) inset; }
.fs-radio { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--text-muted); }
.fs-plan-option.selected .fs-radio { border-color: var(--gold-primary); background: radial-gradient(circle, var(--gold-primary) 45%, transparent 50%); }
.fs-po-main { display: flex; flex-direction: column; gap: 2px; font-size: 14.5px; }
.fs-po-desc { font-size: 12.5px; color: var(--text-secondary); }
.fs-po-price { font-weight: 700; font-size: 15px; white-space: nowrap; }
.fs-po-price small { font-weight: 400; color: var(--text-secondary); font-size: 12px; }
.fs-reco { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: rgba(201, 168, 76, 0.18); color: var(--gold-primary); margin-left: 4px; }
.fs-cta:disabled { opacity: 0.5; cursor: not-allowed; }
/* Super admin — register firm start options */
.nt-start-options { display: grid; gap: 8px; }
.nt-start-option { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.nt-start-option:has(input:checked) { border-color: var(--gold-primary); background: rgba(201, 168, 76, 0.07); }
.nt-start-option > span:nth-child(2) { display: flex; flex-direction: column; font-size: 13.5px; }
.nt-start-option small { color: var(--text-secondary); font-size: 12px; line-height: 1.4; margin-top: 2px; }
.nt-trial-days { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.nt-trial-days input { width: 70px; padding: 6px 8px; }
.fs-po-main > .fs-reco { align-self: flex-start; margin: 2px 0 0; }

/* Firm billing account (Afrihost-style home) */
#subscription-modal { width: 900px; }
.ba-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; }
.ba-status { display: grid; gap: 14px; align-content: start; }
.ba-card { display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: start; }
.ba-card > i { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px;
  border: 3px solid currentColor; color: #60A5FA; box-shadow: 0 0 14px rgba(96, 165, 250, 0.25); }
.ba-card.ok > i { color: #10B981; box-shadow: 0 0 14px rgba(16, 185, 129, 0.25); }
.ba-card.warn > i { color: #F59E0B; box-shadow: 0 0 14px rgba(245, 158, 11, 0.25); }
.ba-card.bad > i { color: #EF4444; box-shadow: 0 0 14px rgba(239, 68, 68, 0.3); }
.ba-card.neutral > i { color: var(--gold-primary); box-shadow: 0 0 14px rgba(201, 168, 76, 0.2); }
.ba-card h3 { margin: 4px 0 4px; font-size: 19px; font-weight: 600; color: var(--text-primary); }
.ba-card.ok h3 { color: #34D399; } .ba-card.warn h3 { color: #FBBF24; } .ba-card.bad h3 { color: #F87171; } .ba-card.info h3 { color: #60A5FA; }
.ba-card p { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--text-secondary); }
.ba-balance { margin-top: 8px; font-size: 14px; color: var(--text-secondary); }
.ba-balance b { color: var(--text-primary); font-size: 16px; margin-left: 4px; }
.ba-tiles { display: grid; gap: 12px; align-content: start; }
.ba-tile { display: grid; grid-template-columns: 46px 1fr auto; gap: 14px; align-items: center; width: 100%; text-align: left; cursor: pointer;
  padding: 16px 18px; border-radius: 16px; border: 1px solid rgba(96, 165, 250, 0.35); font: inherit; color: #fff;
  background: linear-gradient(180deg, #1D6FB8 0%, #124E8C 55%, #0C3A6B 100%); box-shadow: 0 6px 18px rgba(12, 58, 107, 0.35); transition: transform .15s, box-shadow .15s; }
.ba-tile:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(12, 58, 107, 0.5); }
.ba-tile > i:first-child { font-size: 30px; }
.ba-tile span { display: flex; flex-direction: column; }
.ba-tile b { font-size: 16.5px; font-weight: 600; }
.ba-tile small { font-size: 12.5px; opacity: 0.85; margin-top: 2px; }
.ba-tile .ba-chev { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.45); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.ba-tile.alert { border-color: rgba(245, 158, 11, 0.7); box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.5), 0 6px 18px rgba(12, 58, 107, 0.35); }
.ba-back { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.ba-back h3 { margin: 0; font-size: 17px; color: var(--text-primary); }
.ba-section { border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; }
.ba-narrow { max-width: 560px; }
.ba-table-wrap { overflow-x: auto; }
.ba-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ba-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
.ba-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.ba-pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.ba-pill.ok { background: rgba(16, 185, 129, 0.15); color: #34D399; }
.ba-pill.warn { background: rgba(245, 158, 11, 0.15); color: #FBBF24; }
.ba-pill.bad { background: rgba(239, 68, 68, 0.15); color: #F87171; }
.ba-statement-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; font-size: 14px; color: var(--text-secondary); }
.ba-statement-head b { font-size: 18px; color: var(--text-primary); margin-left: 6px; }
.ba-statement-head b.ba-due { color: #FBBF24; }
@media (max-width: 760px) { .ba-grid { grid-template-columns: 1fr; } }
.ba-table td:nth-child(2), .ba-table td:nth-child(3), .ba-table td:nth-child(4), .ba-table td:nth-child(5) { white-space: nowrap; }

/* Super admin — Platform Health */
.ph-overall { display: flex; gap: 14px; align-items: center; padding: 16px 20px; border-radius: 14px; margin-bottom: 18px; border: 1px solid var(--border); }
.ph-overall i { font-size: 34px; }
.ph-overall b { display: block; font-size: 17px; color: var(--text-primary); }
.ph-overall span { font-size: 13px; color: var(--text-secondary); }
.ph-overall.ok { background: rgba(16, 185, 129, 0.08); border-color: rgba(16, 185, 129, 0.35); } .ph-overall.ok i { color: #10B981; }
.ph-overall.warn { background: rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.4); } .ph-overall.warn i { color: #F59E0B; }
.ph-overall.fail { background: rgba(239, 68, 68, 0.08); border-color: rgba(239, 68, 68, 0.45); } .ph-overall.fail i { color: #EF4444; }
.ph-area { margin-bottom: 18px; }
.ph-area-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 8px; font-weight: 700; }
.ph-check { display: grid; grid-template-columns: 26px 1fr; gap: 12px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--bg-card); }
.ph-check > i { font-size: 22px; margin-top: 1px; }
.ph-check.ok > i { color: #10B981; } .ph-check.warn > i { color: #F59E0B; } .ph-check.fail > i { color: #EF4444; }
.ph-check.fail { border-color: rgba(239, 68, 68, 0.45); }
.ph-name { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.ph-detail { font-size: 13px; color: var(--text-secondary); margin-top: 2px; line-height: 1.5; }
.ph-fix { font-size: 12.5px; color: #FBBF24; margin-top: 6px; line-height: 1.5; }

/* ===================== Team Hub live: badges, desktop, calls ===================== */
.hub-unread { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #EF4444; color: #fff;
  font-size: 11px; font-weight: 700; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 0 0 2px var(--bg-base); }
.hub-desktop-bar { display: flex; gap: 6px; align-items: center; margin: 0 0 10px; }
.hub-desktop-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 600; color: #fff; border: 1px solid rgba(96, 165, 250, 0.4);
  background: linear-gradient(180deg, #1D6FB8, #124E8C); box-shadow: 0 3px 10px rgba(12, 58, 107, 0.35); }
.hub-desktop-btn:hover { filter: brightness(1.1); }
.hub-desktop-chip { flex: 1; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #34D399; padding: 6px 10px; border-radius: 8px;
  background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.35); }
.hub-notif-btn { width: 34px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-secondary); cursor: pointer; font-size: 16px; }
.hub-notif-btn.on { color: var(--gold-primary); border-color: rgba(201, 168, 76, 0.5); }
.hub-call-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-secondary);
  cursor: pointer; font-size: 17px; display: inline-flex; align-items: center; justify-content: center; transition: 0.2s; }
.hub-call-btn:hover { color: #10B981; border-color: rgba(16, 185, 129, 0.5); background: rgba(16, 185, 129, 0.08); }

#desktop-app-modal { width: 520px; }
.dk-hero { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.dk-hero img { border-radius: 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
.dk-hero b { display: block; font-size: 16px; color: var(--text-primary); }
.dk-hero span { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.dk-steps { margin: 0 0 12px 18px; padding: 0; display: grid; gap: 8px; font-size: 13.5px; line-height: 1.5; color: var(--text-secondary); }
.dk-steps b { color: var(--text-primary); }
.dk-note { display: flex; gap: 8px; font-size: 12.5px; color: var(--text-secondary); padding: 10px 12px; border-radius: 8px; background: var(--bg-hover); }
.dk-note i { color: #10B981; }

#call-overlay { display: none; position: fixed; inset: 0; z-index: 1000; background: radial-gradient(circle at 50% 30%, #16233F, #060A14 70%); flex-direction: column; }
#call-overlay.active { display: flex; }
.call-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#call-remote { width: 100%; height: 100%; object-fit: contain; background: #000; }
#call-local { position: absolute; right: 18px; bottom: 18px; width: 220px; max-width: 32vw; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.25); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); transform: scaleX(-1); background: #111; }
.call-persona { text-align: center; color: #fff; }
.call-avatar { width: 120px; height: 120px; margin: 0 auto 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 42px; font-weight: 700; color: #0D1526; background: linear-gradient(135deg, #E2C77A, #C9A84C); box-shadow: 0 0 0 10px rgba(201, 168, 76, 0.12), 0 0 0 22px rgba(201, 168, 76, 0.06); }
.call-avatar.small { width: 48px; height: 48px; font-size: 17px; margin: 0; box-shadow: none; }
.call-name { font-size: 26px; font-weight: 600; }
.call-state { margin-top: 6px; font-size: 15px; color: rgba(255, 255, 255, 0.7); font-variant-numeric: tabular-nums; }
.call-top { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); color: #fff; background: rgba(0, 0, 0, 0.45); padding: 6px 14px; border-radius: 999px; font-size: 14px; }
.call-top span { opacity: 0.8; margin-left: 6px; font-variant-numeric: tabular-nums; }
.call-controls { display: flex; justify-content: center; gap: 18px; padding: 22px 16px 30px; }
.call-btn { width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer; font-size: 22px; color: #fff; background: rgba(255, 255, 255, 0.14);
  display: inline-flex; align-items: center; justify-content: center; transition: transform 0.15s, background 0.15s; }
.call-btn:hover { transform: scale(1.06); background: rgba(255, 255, 255, 0.22); }
.call-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.call-btn.off { background: #fff; color: #0D1526; }
.call-btn.on { background: #10B981; }
.call-btn.hang { background: #EF4444; }
.call-btn.hang i { transform: rotate(135deg); }
.call-btn.accept { background: #10B981; animation: ccx-ring 1.2s ease-in-out infinite; }
@keyframes ccx-ring { 0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); } 50% { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); } }
#call-incoming { display: none; position: fixed; top: 18px; right: 18px; z-index: 1001; }
#call-incoming.active { display: block; animation: ccx-slide 0.25s ease-out; }
@keyframes ccx-slide { from { transform: translateY(-20px); opacity: 0; } to { transform: none; opacity: 1; } }
.ci-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px; background: #111D35; border: 1px solid rgba(201, 168, 76, 0.35);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55); color: #fff; min-width: 320px; }
.ci-card .call-btn { width: 46px; height: 46px; font-size: 19px; }
.ci-text { flex: 1; display: flex; flex-direction: column; }
.ci-text b { font-size: 15px; }
.ci-text span { font-size: 12.5px; color: rgba(255, 255, 255, 0.7); }
@media (max-width: 600px) { #call-local { width: 120px; } .ci-card { min-width: 0; } #call-incoming { left: 10px; right: 10px; } }

/* ===================== Installed app (PWA) ===================== */
/* Installs made while the app used "window controls overlay" draw under the title bar.
   Keep the top bar clear of the minimise / maximise / close buttons and let it drag the window. */
@media (display-mode: window-controls-overlay) {
  .app-header {
    height: max(var(--header-height), env(titlebar-area-height, 0px));
    padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 16px);
    -webkit-app-region: drag;
    app-region: drag;
  }
  .app-header button, .app-header a, .app-header input, .app-header select,
  .app-header .header-widget, .app-header .header-timer, .app-header .header-dropdown {
    -webkit-app-region: no-drag;
    app-region: no-drag;
  }
  /* macOS puts the window buttons on the left: keep the sidebar logo clear of them. */
  .sidebar-header, .sidebar-brand, .sidebar-logo { padding-left: max(16px, env(titlebar-area-x, 0px)); }
}

/* Home-screen app on phones: respect the notch / home indicator. */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .sidebar { padding-top: env(safe-area-inset-top, 0px); }
  #install-banner, .nav-install { display: none !important; }
}

.nav-install { color: var(--gold-primary) !important; }

#install-banner { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 400; display: flex; align-items: center; gap: 12px;
  width: min(560px, calc(100vw - 24px)); padding: 12px 14px; border-radius: 14px; background: #111D35; color: var(--text-primary);
  border: 1px solid rgba(201, 168, 76, 0.4); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); animation: ccx-slide 0.3s ease-out; }
#install-banner img { border-radius: 10px; flex-shrink: 0; }
#install-banner .ib-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#install-banner .ib-text b { font-size: 14px; }
#install-banner .ib-text span { font-size: 12.5px; color: var(--text-secondary); line-height: 1.4; }
#install-banner .ib-close { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 4px; }
@media (max-width: 600px) { #install-banner { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); } }

/* ===================== Phones: Team Hub list ⇄ conversation, compact top bar ===================== */
.hub-back-btn { display: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-elevated);
  color: var(--text-primary); font-size: 18px; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
@media (max-width: 760px) {
  .hub-back-btn { display: inline-flex; }
  .page-view > .hub-layout.hub-mobile-list .hub-main { display: none !important; }
  .page-view > .hub-layout.hub-mobile-list .hub-sidebar { max-height: none !important; flex: 1 1 auto !important; border-bottom: 0; }
  .page-view > .hub-layout:not(.hub-mobile-list) .hub-sidebar { display: none !important; }
  .page-view > .hub-layout .hub-main { flex: 1 1 auto; }
  .hub-sidebar .hub-sidebar-item { min-height: 52px; }
  #install-banner { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  #call-incoming { top: calc(10px + env(safe-area-inset-top, 0px)); }
}
@media (max-width: 480px) {
  /* Keep every header button on screen: the timer shows only its button until it is running. */
  .header-timer { padding: 2px 4px; gap: 2px; }
  .header-timer .timer-display:not(.active), .header-timer .timer-dot:not(.active) { display: none; }
  .header-timer .timer-display.active { font-size: 11px; }
  #widget-tasks { display: none; }
  .ccx-qs-btn { padding: 0 8px; }
  .header-page-title { max-width: 34vw; }
}
@media (max-width: 760px) {
  /* Install banner: bottom of the screen above the Support button; never inside a chat, where it would cover the message box. */
  #install-banner { bottom: calc(112px + env(safe-area-inset-bottom, 0px)) !important; }
  body:has(.app-content.chat-mode) #install-banner { display: none; }
  /* Support: compact round button above the footer; hidden inside full-screen chats (Support is in the menu). */
  .floating-support-btn { font-size: 0; gap: 0; padding: 12px; right: 14px; bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
  .floating-support-btn i { font-size: 22px; }
  body:has(.app-content.chat-mode) .floating-support-btn { display: none; }
}@media (max-width: 600px) {
  /* Page header action groups (e.g. "RAF Management Hub" + "Open New Matter") wrap instead of running off-screen. */
  .page-header > div[style*="display:flex"], .page-header > div[style*="display: flex"] { flex-wrap: wrap; width: 100%; }
  .page-header > div[style*="display:flex"] > .btn, .page-header > div[style*="display: flex"] > .btn { flex: 1 1 auto; justify-content: center; }
}
/* ===================== Team Hub presence (Available / Busy / DND / Away / Offline) ===================== */
.presence-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.presence-dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--bg-base, #0b1220); background: #94a3b8; box-sizing: border-box; display: inline-block; flex-shrink: 0; }
.presence-dot.status-available { background: #22c55e; }
.presence-dot.status-busy, .presence-dot.status-in_call { background: #ef4444; }
.presence-dot.status-dnd { background: #ef4444 linear-gradient(#fff, #fff) center / 6px 2px no-repeat; }
.presence-dot.status-brb, .presence-dot.status-away { background: #f59e0b; }
.presence-dot.status-offline { background: transparent; box-shadow: inset 0 0 0 2px #94a3b8; }
.presence-label { display: block; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.presence-label:empty { display: none; }
.presence-label.status-available { color: #22c55e; }
.presence-label.status-busy, .presence-label.status-dnd, .presence-label.status-in_call { color: #f87171; }
.presence-label.status-brb, .presence-label.status-away { color: #fbbf24; }
#widget-profile { position: relative; }
.header-presence-wrap { position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; pointer-events: none; }
.header-presence-wrap .presence-dot { right: 0; bottom: 0; width: 13px; height: 13px; border-color: var(--bg-surface, #0f172a); }
.hub-status-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text-primary); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; max-width: 100%; }
.hub-status-btn:hover { border-color: var(--gold-primary); }
.hub-status-btn .presence-dot { width: 10px; height: 10px; border-width: 0; }
#presence-menu { position: fixed; z-index: 10050; display: none; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,.35)); padding: 8px; max-height: calc(100vh - 24px); overflow-y: auto; }
#presence-menu.open { display: block; }
#presence-menu .pm-head { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); padding: 6px 8px; }
#presence-menu .pm-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: none;
  color: var(--text-primary); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
#presence-menu .pm-item:hover, #presence-menu .pm-item.active { background: var(--bg-hover); }
#presence-menu .pm-item .presence-dot { width: 12px; height: 12px; border-width: 0; }
#presence-menu .pm-item .presence-dot.status-dnd { background-size: 7px 2px; }
#presence-menu .pm-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
#presence-menu .pm-text small { font-size: 11px; color: var(--text-muted); font-weight: 400; }
#presence-menu .pm-item i { color: var(--gold-primary); }
#presence-menu .pm-sep { height: 1px; background: var(--border); margin: 6px 0; }
#presence-menu .pm-msg { display: flex; gap: 6px; padding: 0 8px; }
#presence-menu .pm-msg input { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elevated);
  color: var(--text-primary); font: inherit; font-size: 13px; }
#presence-menu .pm-clear { margin: 6px 8px 0; padding: 0; border: 0; background: none; color: var(--text-secondary); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; }
#presence-menu .pm-foot { font-size: 11px; color: var(--text-muted); padding: 8px; line-height: 1.4; }

/* ===================== Phones: every pop-up fits the screen ===================== */
/* Some pop-ups set their own width by id (e.g. billing 900px); never let that exceed the screen. */
.modal { max-width: calc(100vw - 16px) !important; }
@media (max-width: 640px) {
  .modal { width: calc(100vw - 16px) !important; }
  .modal .modal-body { overflow-x: hidden; }
}
@media (max-width: 420px) {
  .fs-plan-option { grid-template-columns: auto minmax(0, 1fr); row-gap: 6px; }
  .fs-plan-option > :last-child { grid-column: 2; justify-self: start; }
}
/* Phones: header dropdowns (notifications, tasks, profile) span the screen instead of hanging off the edge. */
@media (max-width: 480px) {
  .header-dropdown { position: fixed; left: 8px; right: 8px; width: auto;
    top: calc(var(--header-height) + 6px + env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - var(--header-height) - 24px - env(safe-area-inset-top, 0px)); overflow-y: auto; }
}

/* ===================== Group calls & meetings ===================== */
#call-overlay.active { display: flex; }
#call-overlay .call-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 10px; color: #fff; }
.call-head-text { display: flex; flex-direction: column; min-width: 0; }
.call-head-text b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-head-text span { font-size: 13px; color: rgba(255,255,255,.7); font-variant-numeric: tabular-nums; }
.call-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: #fff; font: inherit; font-size: 13px; cursor: pointer; }
.call-grid { flex: 1; min-height: 0; display: grid; gap: 10px; padding: 0 14px; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.call-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.call-grid[data-count="3"], .call-grid[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.call-grid[data-count="5"], .call-grid[data-count="6"], .call-grid[data-count="7"], .call-grid[data-count="8"], .call-grid[data-count="9"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Team Hub "… is typing" */
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--gold-primary, #C9A84C); opacity: .35; animation: typingdot 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typingdot { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .typing-dots i { animation: none; opacity: .8; } }
/* 10+ people: smaller tiles that scroll instead of shrinking to nothing. */
.call-grid[data-count="big"] { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(130px, 1fr); overflow-y: auto; }
.call-grid[data-count="many"] { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); grid-auto-rows: 130px; overflow-y: auto; }
.call-grid[data-count="big"] .call-avatar, .call-grid[data-count="many"] .call-avatar { width: 56px; height: 56px; font-size: 20px; }
.call-tile { position: relative; border-radius: 16px; overflow: hidden; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); min-height: 0; display: flex; align-items: center; justify-content: center; }
.call-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; background: #000; }
.call-tile audio { display: none; }
.call-tile.show-video video { display: block; }
.call-tile.show-video .tile-persona { display: none; }
.call-tile.waiting { border-style: dashed; }
.call-tile.waiting .call-avatar { animation: ccx-ring 1.6s ease-in-out infinite; }
.tile-persona { text-align: center; color: #fff; padding: 10px; }
.tile-sub { font-size: 13px; color: rgba(255,255,255,.7); margin-top: 8px; }
.tile-name { position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 6px; max-width: calc(100% - 20px);
  padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; font-size: 12.5px; }
.tile-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-muted { display: none; color: #F87171; }
.call-tile.is-muted .tile-muted { display: inline; }
.call-avatar { overflow: hidden; }
.call-avatar.has-photo { background: #0D1526 !important; padding: 0; }
.call-avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.call-grid[data-count="1"] .call-avatar, .call-grid[data-count="2"] .call-avatar { width: 120px; height: 120px; font-size: 40px; }
.call-grid .call-avatar { width: 84px; height: 84px; font-size: 28px; margin: 0 auto; }
.call-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: rgba(255,255,255,.8); font-size: 15px; }
.call-empty .call-avatar { width: 96px; height: 96px; font-size: 32px; margin: 0; }
#call-overlay #call-local { position: absolute; right: 18px; bottom: 110px; width: 200px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px;
  border: 2px solid rgba(255,255,255,.25); background: #000; transform: scaleX(-1); z-index: 2; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
#call-overlay .call-controls { flex-wrap: wrap; align-items: center; gap: 14px; padding: 16px 16px calc(22px + env(safe-area-inset-bottom, 0px)); }
.call-end-all { border: 1px solid rgba(239,68,68,.6); background: transparent; color: #FCA5A5; border-radius: 999px; padding: 10px 14px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.call-panel { display: none; position: absolute; top: calc(62px + env(safe-area-inset-top, 0px)); right: 14px; width: 300px; max-width: calc(100vw - 28px);
  max-height: calc(100% - 180px); overflow-y: auto; background: #111D35; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 12px; z-index: 3; color: #fff; }
.call-panel.open { display: block; }
.call-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: inherit; }
.call-panel-close { border: 0; background: none; color: inherit; font-size: 20px; cursor: pointer; padding: 2px; }
.call-panel-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.call-panel-row b { display: block; font-size: 13.5px; }
.call-panel-row span { font-size: 12px; opacity: .7; }
.call-panel-row .call-avatar.small, .call-add-row .call-avatar.small, .hub-n-face { width: 36px; height: 36px; font-size: 13px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #C9A84C, #8A6D2B); color: #0D1526; font-weight: 700; flex-shrink: 0; margin: 0; }
#call-add { display: none; position: absolute; inset: 0; z-index: 5; background: rgba(0,0,0,.55); align-items: center; justify-content: center; padding: 16px; }
#call-add.open { display: flex; }
.call-add-card { width: 100%; max-width: 420px; max-height: 80vh; display: flex; flex-direction: column; background: #111D35; color: #fff; border: 1px solid rgba(255,255,255,.12); border-radius: 16px; padding: 14px; }
.call-add-search, .meet-people-head input { width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border, rgba(255,255,255,.15)); background: rgba(255,255,255,.06); color: inherit; font: inherit; font-size: 13.5px; margin-bottom: 8px; }
.call-add-list { overflow-y: auto; flex: 1; min-height: 80px; max-height: 46vh; }
.call-add-row { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 10px; cursor: pointer; }
.call-add-row:hover { background: rgba(255,255,255,.06); }
.call-add-row.disabled { opacity: .5; cursor: not-allowed; }
.call-add-row input { width: 18px; height: 18px; accent-color: #C9A84C; flex-shrink: 0; }
.call-add-text { display: flex; flex-direction: column; min-width: 0; }
.call-add-text b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-add-text small { font-size: 11.5px; opacity: .7; }
.call-add-empty { padding: 18px; text-align: center; opacity: .7; font-size: 13px; }
.call-add-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.call-add-foot small { opacity: .7; }
.ci-card .call-avatar.small { width: 48px; height: 48px; font-size: 17px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #C9A84C, #8A6D2B); color: #0D1526; font-weight: 700; flex-shrink: 0; }
@media (max-width: 760px) {
  .call-grid[data-count="2"] { grid-template-columns: 1fr; }
  .call-grid[data-count="3"], .call-grid[data-count="4"], .call-grid[data-count="5"], .call-grid[data-count="6"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .call-grid[data-count="big"], .call-grid[data-count="many"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 120px; }
  .call-grid .call-avatar { width: 64px; height: 64px; font-size: 22px; }
  #call-overlay #call-local { width: 110px; bottom: calc(150px + env(safe-area-inset-bottom, 0px)); right: 12px; }
  #call-overlay .call-btn { width: 50px; height: 50px; font-size: 20px; }
  #call-overlay .call-controls { gap: 10px; }
  .call-btn.hide-phone { display: none; }
}

/* Team Hub: meetings list */
.hub-meet-action { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--gold-primary);
  border-radius: 999px; padding: 3px 9px; font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; }
.hub-meet-action.icon { padding: 3px 7px; font-size: 14px; }
.hub-meetings { padding: 0 6px 4px; display: grid; gap: 4px; }
.hub-meet-empty { font-size: 12px; color: var(--text-muted); padding: 2px 8px 6px 26px; }
.hub-meet { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; background: var(--bg-elevated); border: 1px solid var(--border); }
.hub-meet.live { border-color: rgba(16,185,129,.55); background: rgba(16,185,129,.08); }
.hub-meet-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: rgba(201,168,76,.14); color: var(--gold-primary); flex-shrink: 0; }
.hub-meet.live .hub-meet-icon { background: rgba(16,185,129,.18); color: #34D399; }
.hub-meet-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.hub-meet-text b { font-size: 13px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-meet-text span { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-meet-text em { color: #34D399; font-style: normal; font-weight: 600; }
.hub-meet-join { border: 0; border-radius: 8px; padding: 5px 10px; background: #10B981; color: #fff; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.hub-meet-more { border: 0; background: none; color: var(--text-secondary); font-size: 16px; cursor: pointer; padding: 2px; }
#meeting-banner { position: fixed; z-index: 1002; left: 50%; transform: translateX(-50%); top: calc(76px + env(safe-area-inset-top, 0px)); display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px; border-radius: 14px; background: #0F2A22; border: 1px solid rgba(16,185,129,.55); color: #fff; box-shadow: 0 14px 40px rgba(0,0,0,.4);
  max-width: calc(100vw - 24px); animation: ccx-slide .25s ease-out; }
#meeting-banner > i { font-size: 22px; color: #34D399; }
#meeting-banner div { display: flex; flex-direction: column; min-width: 0; }
#meeting-banner b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#meeting-banner span { font-size: 12px; opacity: .8; }
#meeting-banner .mb-close { border: 0; background: none; color: #fff; opacity: .7; font-size: 18px; cursor: pointer; }
#meeting-modal { width: 560px; }
.meet-form { display: grid; gap: 12px; }
.meet-form label { display: grid; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.meet-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; }
.meet-people-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-top: 4px; }
.meet-people-head input { max-width: 200px; margin: 0; color: var(--text-primary); }
.meet-people { max-height: 34vh; border: 1px solid var(--border); border-radius: 10px; padding: 4px; color: var(--text-primary); }
.meet-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.meet-detail p { display: flex; gap: 8px; align-items: center; margin: 0 0 8px; color: var(--text-secondary); font-size: 14px; }
.meet-detail .meet-desc { white-space: pre-wrap; color: var(--text-primary); background: var(--bg-hover); padding: 10px 12px; border-radius: 10px; }
.meet-detail .call-panel-row span { color: var(--text-muted); opacity: 1; }
@media (max-width: 520px) { .meet-row { grid-template-columns: 1fr 1fr; } .meet-row label:first-child { grid-column: 1 / -1; } .meet-actions .btn { flex: 1 1 auto; justify-content: center; } }

/* Header bell: Team Hub / Activity tabs */
.notif-header { flex-wrap: wrap; gap: 8px; }
.notif-tabs { display: inline-flex; gap: 4px; background: var(--bg-hover); border-radius: 999px; padding: 3px; }
.notif-tabs button { border: 0; background: none; color: var(--text-secondary); font: inherit; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.notif-tabs button.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.notif-tab-count { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: #EF4444; color: #fff; font-size: 10px; display: inline-flex; align-items: center; justify-content: center; }
#dropdown-hub-body { max-height: min(60vh, 460px); overflow-y: auto; padding: 0; }
.hub-n { display: flex !important; align-items: flex-start; gap: 10px; cursor: pointer; position: relative; opacity: .7; }
.hub-n.unread, .hub-n.live { opacity: 1; }
.hub-n.unread::before { content: ''; position: absolute; left: 6px; top: 50%; width: 6px; height: 6px; border-radius: 50%; background: var(--gold-primary); }
.hub-n-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--bg-hover); color: var(--gold-primary); flex-shrink: 0; font-size: 16px; }
.hub-n-icon.meet { background: rgba(16,185,129,.16); color: #34D399; }
.hub-n-face + .hub-n-icon.small { width: 18px; height: 18px; font-size: 10px; margin-left: -20px; margin-top: 22px; border: 2px solid var(--bg-surface); }
.hub-n-icon.small { width: 36px; height: 36px; }
.hub-n.type-missed_call .hub-n-icon { color: #F87171; }
.hub-n-face img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.hub-n-face { overflow: hidden; }
.hub-n-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.hub-n-text b { font-size: 13px; color: var(--text-primary); }
.hub-n-text span { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-n-text small { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }
.hub-n-call { border: 1px solid var(--border); background: var(--bg-elevated); color: #10B981; border-radius: 50%; width: 32px; height: 32px; cursor: pointer; flex-shrink: 0; align-self: center; }
#dropdown-hub-body .hub-n { flex-direction: row !important; align-items: center; gap: 10px; padding: 12px 14px 12px 20px; }
/* During a call: nothing floats over the call screen. */
body:has(#call-overlay.active) .floating-support-btn, body:has(#call-overlay.active) #install-banner, body:has(#call-overlay.active) #meeting-banner { display: none !important; }
/* Meeting form invite list: one row per person. */
.meet-form .call-add-row { display: flex; grid-template-columns: none; font-weight: 400; color: var(--text-primary); }
