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

/* ==========================================================================
   SocietyOS ERP - Production-Grade Enterprise Design System
   Executive Light Theme (Default) + High-Contrast Enterprise Dark Mode
   ========================================================================== */

:root {
  /* Surface & Canvas Tokens (Executive Light Palette) */
  --bg-primary: #f8fafc;
  /* Slate-50: Crisp executive workspace */
  --bg-surface: #ffffff;
  /* Pure White: Sidebar, Topnav, Modal dialogs */
  --bg-surface-subtle: #f1f5f9;
  /* Slate-100: Table headers, subtle blocks */
  --bg-card: #ffffff;
  /* Pure White card surfaces */
  --bg-card-hover: #f8fafc;
  --border-color: #e2e8f0;
  /* Slate-200: Crisp, clean structural borders */
  --border-subtle: #cbd5e1;
  /* Slate-300: High definition accents */
  --border-glow: rgba(79, 70, 229, 0.25);

  /* Enterprise Brand & Functional Accents */
  --primary: #4f46e5;
  /* Executive Sapphire / Indigo */
  --primary-glow: rgba(79, 70, 229, 0.15);
  --primary-hover: #4338ca;
  --secondary: #0284c7;
  /* Deep Sky / Ocean */
  --accent: #7c3aed;
  /* Royal Purple */

  /* High-Contrast Readable Typography */
  --text-main: #0f172a;
  /* Slate-900: High clarity readability */
  --text-muted: #475569;
  /* Slate-600: Secondary descriptions */
  --text-dim: #64748b;
  /* Slate-500: Metadata and timestamps */
  --text-inverse: #ffffff;

  /* Status Colors (Curated Enterprise Palette) */
  --success: #059669;
  /* Emerald-600 */
  --success-bg: #ecfdf5;
  /* Emerald-50 */
  --success-border: #a7f3d0;
  --success-glow: rgba(5, 150, 105, 0.15);

  --warning: #d97706;
  /* Amber-600 */
  --warning-bg: #fffbeb;
  /* Amber-50 */
  --warning-border: #fde68a;
  --warning-glow: rgba(217, 119, 6, 0.15);

  --danger: #dc2626;
  /* Red-600 */
  --danger-bg: #fef2f2;
  /* Red-50 */
  --danger-border: #fecaca;
  --danger-glow: rgba(220, 38, 38, 0.15);

  --info: #0284c7;
  /* Sky-600 */
  --info-bg: #f0f9ff;
  /* Sky-50 */
  --info-border: #bae6fd;

  /* Layout Geometry */
  --sidebar-width: 270px;
  --header-height: 64px;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
}

/* ==========================================================================
   Dark Theme Variant (Optional 1-Click Toggle for Users)
   ========================================================================== */
body.theme-dark {
  --bg-primary: #0b0f17;
  --bg-surface: #111827;
  --bg-surface-subtle: #1f2937;
  --bg-card: #141c2e;
  --bg-card-hover: #1e293b;
  --border-color: #273549;
  --border-subtle: #374151;
  --border-glow: rgba(99, 102, 241, 0.35);

  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --primary-hover: #4f46e5;
  --secondary: #38bdf8;
  --accent: #a855f7;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-inverse: #0f172a;

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.3);

  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.3);

  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.3);

  --info: #38bdf8;
  --info-bg: rgba(56, 189, 248, 0.12);
  --info-border: rgba(56, 189, 248, 0.3);

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.55);
}

/* Base Reset & Core Typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Enterprise Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ==========================================================================
   Navigation Sidebar (Executive Multi-Module Navigation)
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  background: #ebebeb;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--primary-glow);
  flex-shrink: 0;
}

.logo-icon svg {
  width: 22px;
  height: 22px;
  fill: #ffffff;
}

.logo-text {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-main);
  line-height: 1.1;
}

.badge-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid var(--border-glow);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-toggle-btn {
  margin-left: auto;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
  flex-shrink: 0;
}

.sidebar-toggle-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 0.25s ease;
}

.sidebar-toggle-btn:hover {
  background: var(--primary-glow, rgba(99, 102, 241, 0.12));
  color: var(--primary);
  border-color: var(--primary);
  transform: scale(1.05);
}

body.sidebar-collapsed .sidebar-toggle-btn svg {
  transform: rotate(180deg);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Custom sleek enterprise scrollbar for sidebar */
.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

.sidebar-nav>* {
  flex-shrink: 0;
}

.nav-category {
  font-size: 0.70rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-main);
  padding: 7px 10px;
  letter-spacing: 0.65px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  flex-shrink: 0;
  margin-top: 8px;
  margin-bottom: 2px;
  background: rgba(241, 245, 249, 0.65);
  border: 1px solid var(--border-color);
}

body.theme-dark .nav-category {
  background: rgba(30, 41, 59, 0.5);
  border-color: rgba(51, 65, 85, 0.6);
  color: #e2e8f0;
}

.nav-category:hover {
  color: var(--primary);
  background: var(--bg-surface-subtle);
  border-color: var(--border-subtle);
}

.nav-category.nav-category-featured {
  background: var(--primary-glow);
  border-color: var(--border-glow);
  color: var(--primary);
}

.nav-category.nav-category-featured .category-chevron {
  color: var(--primary);
}

.category-chevron {
  font-size: 0.72rem;
  transition: transform 0.2s ease;
  color: var(--text-dim);
  display: inline-block;
}

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

.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  width: calc(100% - 10px);
  margin-left: 10px;
  padding-left: 10px;
  border-left: 2px solid var(--border-color);
  margin-top: 3px;
  margin-bottom: 6px;
  box-sizing: border-box;
}

body.theme-dark .nav-group-items {
  border-left-color: rgba(51, 65, 85, 0.7);
}

.nav-group-items.collapsed {
  display: none !important;
}

.btn-micro {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  padding: 2px 6px;
  font-size: 0.65rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-micro:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--bg-surface-subtle);
}

.master-icon {
  font-size: 0.95rem;
  width: 17px;
  text-align: center;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Sidebar Collapsed State (Toggle via Header Hamburger) */
body.sidebar-collapsed .sidebar {
  width: 68px;
}

body.sidebar-collapsed .sidebar .logo-text,
body.sidebar-collapsed .sidebar .badge-tag,
body.sidebar-collapsed .sidebar .nav-category,
body.sidebar-collapsed .sidebar .sidebar-accordion-controls,
body.sidebar-collapsed .sidebar .nav-link span:not(.master-icon),
body.sidebar-collapsed .sidebar .sidebar-footer .user-meta,
body.sidebar-collapsed .sidebar .sidebar-footer div[style*="border-top"] {
  display: none !important;
}

body.sidebar-collapsed .sidebar .nav-group-items {
  margin-left: 0 !important;
  padding-left: 0 !important;
  border-left: none !important;
  width: 100% !important;
}

body.sidebar-collapsed .sidebar .nav-link {
  justify-content: center;
  padding: 10px 0;
  transform: none !important;
}

body.sidebar-collapsed .main-wrapper {
  margin-left: 68px;
  width: calc(100% - 68px);
  max-width: calc(100% - 68px);
}

.main-wrapper {
  transition: margin-left 0.25s ease, width 0.25s ease, max-width 0.25s ease;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.83rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
}

.nav-link svg {
  width: 16px;
  height: 16px;
  opacity: 0.75;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--primary);
  background: var(--bg-surface-subtle);
  border-color: var(--border-color);
  transform: translateX(2px);
}

.nav-link.active {
  color: var(--primary);
  background: rgba(79, 70, 229, 0.08);
  border-color: rgba(79, 70, 229, 0.25);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}

body.theme-dark .nav-link.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: var(--border-glow);
  border-left-color: var(--primary);
  color: #ffffff;
}

.nav-link.active svg {
  opacity: 1;
  color: var(--primary);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.user-meta {
  flex: 1;
  overflow: hidden;
}

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

.user-role {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ==========================================================================
   Main Content Workspace & Header
   ========================================================================== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  max-width: calc(100% - var(--sidebar-width));
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  box-sizing: border-box;
}

.top-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: var(--shadow-xs);
  width: 100%;
  box-sizing: border-box;
  gap: 10px;
}

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

/* Prominent Top Header Menu Toggle Button */
.btn-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
}

.btn-sidebar-toggle svg {
  width: 17px;
  height: 17px;
  stroke: var(--text-main);
  transition: stroke 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.btn-sidebar-toggle:hover {
  background: var(--bg-surface-subtle);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow, rgba(99, 102, 241, 0.2));
}

.btn-sidebar-toggle:hover svg {
  stroke: var(--primary);
}

.btn-sidebar-toggle:active {
  transform: scale(0.96);
}

body.sidebar-collapsed .btn-sidebar-toggle {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.35);
  color: var(--primary);
}

body.sidebar-collapsed .btn-sidebar-toggle svg {
  stroke: var(--primary);
}

@media (max-width: 768px) {
  .btn-sidebar-toggle-text {
    display: none;
  }
  .btn-sidebar-toggle {
    padding: 0 8px;
    height: 32px;
  }
}

.society-badge-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success-glow);
}

.header-center {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
  margin: 0 10px;
  position: relative;
}

.global-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
  padding: 6px;
}

.global-search-results.active {
  display: block;
  animation: dropdownFade 0.15s ease-out;
}

.search-result-group-title {
  padding: 6px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.82rem;
  color: var(--text-main);
  text-decoration: none;
}

.search-result-item:hover,
.search-result-item.selected {
  background: var(--bg-surface-subtle);
  color: var(--primary);
}

.search-result-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.search-result-text {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-main);
  white-space: normal;
  line-height: 1.25;
}

.search-result-desc {
  font-size: 0.71rem;
  color: var(--text-dim);
  white-space: normal;
  line-height: 1.2;
  margin-top: 2px;
}

.search-result-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  flex-shrink: 0;
}

.header-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.header-search-bar:focus-within {
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.header-search-bar svg {
  width: 15px;
  height: 15px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.header-search-bar input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.82rem;
  color: var(--text-main);
  width: 100%;
}

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

.search-kbd-shortcut {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-dim);
  line-height: 1;
}

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

/* Dedicated Top-Right Login / User Profile Card */
.user-header-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  transition: all 0.18s ease;
  box-shadow: var(--shadow-xs);
}

.user-header-card:hover {
  background: var(--bg-surface-subtle);
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}

.user-header-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.user-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 2px solid var(--bg-surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.user-status-online {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 5px var(--success-glow);
}

.user-header-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: left;
}

.user-header-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-header-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-header-badge {
  font-size: 0.62rem;
  padding: 1px 6px;
  font-weight: 700;
}

.user-header-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  max-width: 170px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-header-caret {
  font-size: 0.75rem;
  color: var(--text-dim);
  transition: transform 0.2s ease;
  margin-left: 2px;
}

.user-header-card.dropdown-open .user-header-caret {
  transform: rotate(180deg);
  color: var(--primary);
}

/* User Card Dropdown Drawer - Viewport-anchored to guarantee zero cutoff */
.user-card-dropdown {
  display: none;
  position: fixed;
  top: calc(var(--header-height) + 6px);
  right: 16px;
  width: 320px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 85px);
  overflow-y: auto;
  box-sizing: border-box;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
  z-index: 1200;
  padding: 12px;
  text-align: left;
  animation: dropdownFadeIn 0.18s ease-out;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-header-card.dropdown-open .user-card-dropdown {
  display: block;
}

.dropdown-user-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 10px;
}

.dropdown-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.dropdown-user-details {
  flex: 1;
  overflow: hidden;
}

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

.dropdown-user-email {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-user-role-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-glow);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  margin-top: 3px;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 0;
}

.dropdown-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  padding: 4px 4px 6px;
}

.persona-switch-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}

.persona-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.persona-chip:hover {
  background: var(--primary-glow);
  border-color: var(--primary);
  color: var(--primary);
}

.persona-icon {
  font-size: 0.85rem;
}

.dropdown-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropdown-menu-item:hover {
  background: var(--bg-surface-subtle);
  color: var(--primary);
}

.dropdown-menu-item.item-danger {
  color: var(--danger);
}

.dropdown-menu-item.item-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.dropdown-menu-item .menu-icon {
  font-size: 0.95rem;
  width: 18px;
  text-align: center;
}

/* ==========================================================================
   Buttons & Interactive Controls
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 3px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px var(--primary-glow);
}

.btn-outline {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-color);
}

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

.btn-emergency {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #ffffff;
  border: 1px solid rgba(239, 68, 68, 0.4);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.btn-emergency:hover {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.45);
}

.btn-theme-toggle {
  background: var(--bg-surface-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-theme-toggle:hover {
  background: var(--border-color);
}

/* ==========================================================================
   Page Layout & View Container
   ========================================================================== */
.page-container {
  padding: 20px 24px 48px;
  flex: 1;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.view-section {
  display: none;
  animation: fadeIn 0.2s ease-out;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.view-section.active {
  display: block;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-main);
}

.page-subtitle {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ==========================================================================
   Executive Metrics Cards
   ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 1280px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.metric-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-subtle);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}

.metric-card.success::before {
  background: var(--success);
}

.metric-card.warning::before {
  background: var(--warning);
}

.metric-card.danger::before {
  background: var(--danger);
}

.metric-card.accent::before {
  background: var(--accent);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.metric-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 1rem;
}

.metric-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-main);
  line-height: 1.1;
}

.metric-change {
  font-size: 0.74rem;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

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

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

.change-neutral {
  color: var(--text-dim);
}

/* ==========================================================================
   Data Tables & Container Cards
   ========================================================================== */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}

.table-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  flex-wrap: wrap;
}

.table-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.table-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--text-main);
  font-size: 0.83rem;
  outline: none;
  width: 220px;
  max-width: 100%;
  transition: all 0.15s ease;
}

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

/* ==========================================================================
   Responsive Data Tables with Horizontal Scrolling & Sticky Headers
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.table-responsive::-webkit-scrollbar {
  height: 7px;
  width: 7px;
}

.table-responsive::-webkit-scrollbar-track {
  background: var(--bg-surface-subtle);
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
  transition: background 0.2s ease;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

.data-table {
  width: 100%;
  min-width: 780px;
  /* Guarantees horizontal scrolling instead of squishing columns */
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
}

/* Wide tables get extra breathing room for horizontal scroll */
.data-table.table-wide {
  min-width: 980px;
}

.data-table.table-extra-wide {
  min-width: 1200px;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table th {
  background: var(--bg-surface-subtle);
  padding: 11px 18px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.7rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 0 var(--border-color);
}

.data-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
  white-space: nowrap;
  /* Keeps records aligned cleanly in horizontal scroll */
}

.data-table td.cell-wrap {
  white-space: normal;
  max-width: 280px;
}

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

.data-table tr:hover td {
  background: var(--bg-surface-subtle);
}

/* Table Search and Action Toolbar */
.table-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.table-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.table-search-box svg {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--text-dim);
  pointer-events: none;
}

.table-search-box .search-input {
  padding-left: 32px;
  padding-right: 28px;
  width: 220px;
  height: 32px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.table-search-box .search-clear-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.75rem;
  display: none;
  padding: 2px 4px;
}

.table-search-box .search-input:not(:placeholder-shown)+.search-clear-btn {
  display: block;
}

.btn-table-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-table-action:hover {
  background: var(--bg-surface-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-table-action.btn-export {
  color: var(--primary);
}

.btn-table-action.btn-export:hover {
  background: var(--primary-glow);
}

/* ==========================================================================
   Table Pagination Controls & Indicators
   ========================================================================== */
.table-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pagination-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.pagination-size-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.pagination-select {
  padding: 4px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.pagination-select:focus {
  border-color: var(--primary);
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.pagination-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-surface-subtle);
}

.pagination-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.pagination-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: var(--border-color);
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-ellipsis {
  padding: 0 4px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ==========================================================================
   Badges, Status Tags & Pills
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
  border: 1px solid transparent;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

.badge-primary {
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
  border-color: rgba(79, 70, 229, 0.25);
}

.badge-muted {
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  border-color: var(--border-color);
}

/* ==========================================================================
   Form Controls & Input Groups
   ========================================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.form-row .form-group {
  margin-bottom: 0;
}

.form-row .form-group.flex-1 {
  flex: 1 1 180px;
  min-width: 140px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 0.86rem;
  outline: none;
  transition: all 0.15s ease;
  width: 100%;
}

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

/* ==========================================================================
   Modal Dialogs & Popups
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  z-index: 1300;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  box-sizing: border-box;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  margin: auto;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
  animation: modalEnter 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  flex-shrink: 0;
}

.modal-dialog form {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: all 0.15s ease;
}

.modal-close:hover {
  color: var(--text-main);
  background: var(--bg-surface-subtle);
}

.modal-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  box-sizing: border-box;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.modal-footer .btn {
  min-width: 96px;
  justify-content: center;
}

/* Universal Form Row & Flex Wrapping Safeguards for Modal Dialogs */
.modal-body .form-row,
.modal-body div[style*="display:flex"],
.modal-body div[style*="display: flex"] {
  display: flex;
  flex-wrap: wrap !important;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.modal-body .form-row .form-group.flex-1,
.modal-body div[style*="display:flex"] > .form-group[style*="flex:1"],
.modal-body div[style*="display: flex"] > .form-group[style*="flex: 1"],
.modal-body div[style*="display:flex"] > .form-group[style*="flex: 2"],
.modal-body div[style*="display: flex"] > .form-group[style*="flex: 2"] {
  min-width: 140px;
}

/* ==========================================================================
   Financial Year Management Modal & Grid Enhancements
   ========================================================================== */
.fy-grid-container {
  max-height: 240px;
  min-height: 120px;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
  margin-bottom: 16px;
}

.fy-grid-container table {
  margin-bottom: 0 !important;
  width: 100%;
  border-collapse: collapse;
}

.fy-grid-container thead th {
  position: sticky;
  top: 0;
  background: var(--bg-surface-subtle);
  z-index: 2;
  padding: 10px 14px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.fy-grid-container tbody td {
  padding: 10px 14px;
  font-size: 0.84rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.05));
}

.fy-grid-container tbody tr:last-child td {
  border-bottom: none;
}

.fy-grid-container tbody tr:hover {
  background: var(--bg-surface-subtle);
}

.fy-create-card {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 4px;
}

.fy-create-header {
  margin-bottom: 12px;
}

.fy-create-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  display: block;
}

.fy-create-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.fy-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

/* ==========================================================================
   Emergency Siren Banner & Alert Telemetry
   ========================================================================== */
.emergency-banner {
  background: linear-gradient(90deg, #dc2626 0%, #991b1b 100%);
  border-bottom: 2px solid #ef4444;
  color: #ffffff;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: pulseAlarm 1.8s infinite;
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3);
  position: relative;
  z-index: 50;
}

@keyframes pulseAlarm {
  0% {
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
  }

  50% {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.7);
  }

  100% {
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
  }
}

.emergency-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.emergency-icon-pulse {
  font-size: 1.8rem;
  animation: shakeSiren 0.5s infinite alternate ease-in-out;
}

@keyframes shakeSiren {
  0% {
    transform: scale(1) rotate(-5deg);
  }

  100% {
    transform: scale(1.2) rotate(5deg);
  }
}

.emergency-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.emergency-meta {
  font-size: 0.82rem;
  opacity: 0.92;
  margin-top: 1px;
}

/* Voting Progress Bars */
.vote-progress-track {
  width: 100%;
  height: 9px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  margin: 8px 0;
}

.vote-bar-for {
  background: #10b981;
  height: 100%;
}

.vote-bar-against {
  background: #ef4444;
  height: 100%;
}

.vote-bar-abstain {
  background: #94a3b8;
  height: 100%;
}

/* Doorbell Modal Avatar */
.intercom-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 10px;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
  color: #fff;
}

/* Quick Details Card Grid (For Profile & Governance) */
.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.detail-item {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
}

.detail-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Master Data Entry Dropdown */
.dropdown-item {
  display: block;
  padding: 8px 16px;
  font-size: 0.83rem;
  color: var(--text-main);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropdown-item:hover {
  background: var(--bg-surface-subtle);
  color: var(--primary);
}

/* User Status Offline Indicator */
.user-status-offline {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #94a3b8;
  border: 2px solid var(--bg-surface);
}

/* Toast Notification System */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  font-size: 0.86rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 440px;
  pointer-events: auto;
  animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.toast-success {
  border-left: 4px solid var(--success);
}

.toast.toast-error {
  border-left: 4px solid var(--danger);
}

.toast.toast-info {
  border-left: 4px solid var(--primary);
}

.toast.toast-fade-out {
  opacity: 0;
  transform: translateY(10px);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Zero-Trust Authentication Gate Portal
   ========================================================================== */
#view-auth-gate {
  display: none;
  min-height: calc(100vh - 140px);
  padding: 30px 16px;
}

#view-auth-gate.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-gate-wrapper {
  max-width: 580px;
  width: 100%;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
  padding: 32px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.auth-gate-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
}

.auth-gate-shield {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  margin-bottom: 14px;
  box-shadow: 0 0 20px rgba(79, 70, 229, 0.15);
}

.auth-gate-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
}

body.theme-dark .auth-gate-badge {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.3);
  color: #f87171;
}

.auth-gate-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #dc2626;
}

.auth-gate-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.auth-gate-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 18px;
}

.auth-gate-society-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  font-size: 0.82rem;
  color: var(--text-main);
  margin-bottom: 20px;
}

.auth-gate-persona-box {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 20px;
  text-align: left;
}

.auth-gate-persona-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.auth-gate-persona-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.btn-persona {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-persona:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
  transform: translateY(-1px);
}

.btn-persona .persona-icon {
  font-size: 1.05rem;
}

.auth-gate-form {
  margin-bottom: 18px;
}

.auth-gate-actions {
  margin-top: 16px;
}

.btn-block {
  width: 100%;
}

.auth-gate-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
  font-size: 0.74rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.auth-compliance-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Session-Locked Sidebar Navigation Security
   ========================================================================== */
.sidebar-locked-notice {
  display: none;
  margin: 8px 10px 14px;
  padding: 14px 10px;
  background: var(--bg-surface-subtle);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  text-align: center;
}

body.session-locked .sidebar-locked-notice {
  display: block;
}

.sidebar-locked-notice .locked-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.sidebar-locked-notice .locked-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-locked-notice .locked-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 3px;
}

body.session-locked .sidebar-accordion-controls,
body.session-locked .nav-category,
body.session-locked .nav-group-items,
body.session-locked .quick-action-link,
body.session-locked .nav-link {
  opacity: 0.28 !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
  user-select: none !important;
}

/* ==========================================================================
   Enterprise Society Switcher & Financial Year Controls
   ========================================================================== */
.society-switcher-dropdown,
.fy-selector-dropdown {
  position: relative;
  display: inline-block;
}

.society-switcher-btn,
.fy-selector-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.society-switcher-btn {
  max-width: 250px;
}

.society-switcher-btn #header-society-name,
.society-switcher-btn span:nth-child(2) {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

.society-switcher-btn:hover,
.fy-selector-btn:hover {
  background: var(--bg-surface-subtle);
  border-color: var(--primary);
}

.society-dropdown-menu,
.fy-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  padding: 6px;
  max-height: 400px;
  overflow-y: auto;
}

.society-switcher-dropdown.dropdown-open .society-dropdown-menu,
.fy-selector-dropdown.dropdown-open .fy-dropdown-menu,
.society-dropdown-menu.active,
.fy-dropdown-menu.active {
  display: block;
  animation: dropdownFade 0.15s ease-out;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.society-item,
.fy-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 0.15s ease;
}

.society-item:hover,
.fy-item:hover {
  background: var(--bg-surface-subtle);
}

.society-item.active,
.fy-item.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  font-weight: 600;
}

.society-item-meta {
  display: flex;
  flex-direction: column;
}

.society-item-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.society-item-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.dropdown-action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  margin-top: 6px;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  background: transparent;
  border-left: none;
  border-right: none;
  border-bottom: none;
  cursor: pointer;
  border-radius: 0 0 var(--radius-xs) var(--radius-xs);
}

.dropdown-action-btn:hover {
  background: var(--bg-surface-subtle);
}

/* ==========================================================================
   Date Range Filtration Toolbar
   ========================================================================== */
.date-filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.date-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.date-filter-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.date-input-field {
  padding: 6px 10px;
  font-size: 0.82rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  color: var(--text-main);
}

.date-chips-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chip-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  background: var(--border-color);
  color: var(--text-main);
}

.chip-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* ==========================================================================
   Data Table Actions & Edit Controls
   ========================================================================== */
.action-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-action-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-action-icon:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff !important;
}

.btn-action-icon.danger:hover {
  background: #ef4444;
  border-color: #ef4444;
}

/* ==========================================================================
   MIS Reporting Studio Tabs
   ========================================================================== */
.report-nav-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.report-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -4px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.report-tab-btn:hover {
  color: var(--primary);
}

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

.report-pane {
  display: none;
}

.report-pane.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* ==========================================================================
   Desktop Sidebar Collapse States
   ========================================================================== */
body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

body.sidebar-collapsed .main-wrapper {
  margin-left: 0;
  width: 100%;
  max-width: 100%;
}

/* ==========================================================================
   Responsive Multi-Screen Architecture (Tablet & Mobile Breakpoints)
   ========================================================================== */

/* Medium Laptops & Standard Displays (1025px - 1400px) */
@media (max-width: 1400px) {
  .top-header {
    padding: 0 14px;
    gap: 8px;
  }

  .society-switcher-btn {
    max-width: 180px;
    padding: 5px 10px;
  }

  .society-switcher-btn #header-society-name {
    max-width: 110px;
  }

  .fy-selector-btn {
    padding: 5px 10px;
  }

  .header-center {
    flex: 0 1 220px;
    min-width: 120px;
    max-width: 260px;
    margin: 0 6px;
  }

  .user-header-sub {
    display: none !important;
  }

  .user-header-card {
    padding: 4px 10px;
    gap: 8px;
  }

  .user-header-name {
    max-width: 110px;
  }

  .header-guide-text {
    display: none !important;
  }
}

/* Tablet & Smaller Laptops (<= 1024px) */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1050;
    transform: translateX(-100%);
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.28);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  body.mobile-sidebar-open .sidebar {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .top-header {
    padding: 0 14px;
    gap: 8px;
  }

  .header-center {
    min-width: 140px;
    max-width: 280px;
  }

  .search-kbd-shortcut {
    display: none;
  }
}

/* Mobile Screens & Small Tablets (<= 768px) */
@media (max-width: 768px) {
  :root {
    --header-height: 58px;
  }

  .top-header {
    height: auto;
    min-height: var(--header-height);
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .header-left {
    gap: 6px;
  }

  .society-switcher-btn {
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  #header-society-name {
    max-width: 85px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
  }

  .fy-selector-btn {
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  .header-center {
    order: 3;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    margin: 4px 0 0 0;
  }

  .header-right {
    margin-left: auto;
    gap: 6px;
  }

  /* Compact User Profile Button in Header on Mobile */
  .user-header-card {
    padding: 3px 8px;
    gap: 6px;
  }

  .user-header-sub {
    display: none !important;
  }

  .user-header-caret {
    display: none !important;
  }

  .user-header-name {
    max-width: 80px;
    font-size: 0.78rem;
  }

  /* Fixed Centered Responsive Dropdown Popup: Never out of screen */
  .user-card-dropdown {
    position: fixed !important;
    top: calc(var(--header-height) + 54px) !important;
    right: 12px !important;
    left: 12px !important;
    width: auto !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100vh - 120px) !important;
    overflow-y: auto !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45) !important;
    z-index: 1250 !important;
  }

  /* Mobile Modals: Always visible and scrollable */
  .modal-overlay {
    padding: 12px 8px !important;
  }

  .modal-dialog {
    max-width: 100% !important;
    margin: 8px auto !important;
    border-radius: var(--radius-md) !important;
    max-height: calc(100vh - 24px) !important;
  }

  .modal-header {
    padding: 12px 16px !important;
  }

  .modal-title {
    font-size: 1rem !important;
  }

  .modal-body {
    padding: 14px 16px !important;
    max-height: calc(100vh - 130px) !important;
  }

  .modal-footer {
    padding: 10px 16px !important;
  }

  /* Tables and Grid */
  .data-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .page-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

/* Extra Small Mobile (<= 480px) */
@media (max-width: 480px) {
  .user-header-badge {
    display: none;
  }

  .user-header-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.72rem;
  }

  .auth-gate-wrapper {
    padding: 20px 14px;
    margin: 12px auto;
  }

  .auth-gate-title {
    font-size: 1.4rem;
  }

  .auth-gate-subtitle {
    font-size: 0.82rem;
  }

  .btn {
    font-size: 0.8rem;
    padding: 6px 10px;
  }
}