/* =====================================================
   GRC Platform - Corporate Design System v2.0
   
   Theme: Corporate/Enterprise
   Font: Inter (sans-serif)
   Mode: Light (default) / Dark (data-theme="dark")
   ===================================================== */

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

/* =====================================================
   CSS Variables - Light Theme (Default)
   ===================================================== */

:root {
  /* Background */
  --bg-app: #F9FAFB;
  --bg-card: #FFFFFF;
  --bg-hover: #F3F4F6;
  --bg-zebra: #F9FAFB;

  /* Borders */
  --border-color: #E5E7EB;
  --border-dark: #D1D5DB;

  /* Text */
  --text-primary: #111827;
  --text-secondary: #4B5563;
  --text-muted: #9CA3AF;
  --text-inverse: #FFFFFF;

  /* Brand / Primary */
  --brand: #1D4ED8;
  --brand-hover: #1E40AF;
  --brand-light: #DBEAFE;
  --brand-dark: #0F172A;

  /* Status Colors */
  --status-success: #16A34A;
  --status-success-bg: #DCFCE7;
  --status-warning: #F97316;
  --status-warning-bg: #FFEDD5;
  --status-danger: #DC2626;
  --status-danger-bg: #FEE2E2;

  /* Risk/Priority Levels */
  --level-critical: #DC2626;
  --level-critical-bg: #FEE2E2;
  --level-high: #EA580C;
  --level-high-bg: #FFEDD5;
  --level-medium: #CA8A04;
  --level-medium-bg: #FEF9C3;
  --level-low: #16A34A;
  --level-low-bg: #DCFCE7;

  /* Sidebar - Light Theme */
  --sidebar-bg: #FFFFFF;
  --sidebar-hover: #F3F4F6;
  --sidebar-active: #EFF6FF;
  --sidebar-text: #4B5563;
  --sidebar-text-active: #111827;
  --sidebar-border: #E5E7EB;

  /* Sidebar collapsed width */
  --sidebar-width-collapsed: 64px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Layout */
  --sidebar-width: 240px;
  --header-height: 56px;

  /* Transitions */
  --transition: 150ms ease;
}

/* =====================================================
   Dark Theme
   ===================================================== */

[data-theme="dark"] {
  --bg-app: #0F172A;
  --bg-card: #1E293B;
  --bg-hover: #334155;
  --bg-zebra: #1E293B;

  --border-color: #334155;
  --border-dark: #475569;

  --text-primary: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #64748B;
  --text-inverse: #0F172A;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);

  /* Sidebar - Dark Theme */
  --sidebar-bg: #020617;
  --sidebar-hover: #0F172A;
  --sidebar-active: #1E293B;
  --sidebar-text: #94A3B8;
  --sidebar-text-active: #FFFFFF;
  --sidebar-text-active: #FFFFFF;
  --sidebar-border: #1E293B;

  /* Dark Mode specific overrides */
  --brand-light: rgba(59, 130, 246, 0.15);
  /* Darker blue for background usage */
  --brand-dark: #DBEAFE;

  /* Status Backgrounds - Dark Mode (Transparent/Darker) */
  --status-success-bg: rgba(22, 163, 74, 0.2);
  --status-warning-bg: rgba(249, 115, 22, 0.2);
  --status-danger-bg: rgba(220, 38, 38, 0.2);

  --level-critical-bg: rgba(220, 38, 38, 0.2);
  --level-high-bg: rgba(234, 88, 12, 0.2);
  --level-medium-bg: rgba(202, 138, 4, 0.2);
  --level-low-bg: rgba(22, 163, 74, 0.2);
}

/* =====================================================
   Base Styles
   ===================================================== */

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
  min-height: 100vh;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* =====================================================
   Layout
   ===================================================== */

.app-container {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  min-width: 0;
  /* Prevents overflow in flex children */
}

.page-content {
  padding: var(--space-lg);
  flex: 1;
  min-width: 0;
  /* Prevents overflow in flex children */
}

/* =====================================================
   Sidebar
   ===================================================== */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 200ms ease;
}

/* Collapsed Sidebar */
.sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-subtitle,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-item span:not(.nav-item-icon),
.sidebar.collapsed .nav-item-badge,
.sidebar.collapsed .sidebar-footer>div>div:last-child {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: var(--space-md) var(--space-sm);
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px var(--space-sm);
}

.sidebar.collapsed .nav-item-icon {
  width: 24px;
  font-size: 18px;
}

.sidebar.collapsed .sidebar-footer {
  justify-content: center;
}

.sidebar.collapsed .sidebar-footer>div {
  justify-content: center;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
  position: absolute;
  right: -12px;
  top: 20px;
  width: 24px;
  height: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 101;
  font-size: 12px;
  color: var(--text-secondary);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

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

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

/* Main content adjustment for collapsed sidebar */
.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-width-collapsed);
}

.sidebar-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  background: var(--brand);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: white;
}

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

.sidebar-subtitle {
  font-size: 10px;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-sm) 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: var(--space-md);
}

.nav-section-title {
  padding: var(--space-sm) var(--space-md);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--sidebar-text);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px var(--space-md);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  transition: all var(--transition);
  cursor: pointer;
  border-left: 2px solid transparent;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  text-decoration: none;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--brand);
  /* Direct brand color for text */
  border-left-color: var(--brand);
}

.nav-item.active .nav-item-icon {
  color: var(--brand);
  /* Ensure icon is also brand color */
}

.nav-item-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.nav-item-badge {
  margin-left: auto;
  background: var(--status-danger);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
}

/* Nav Group (Collapsible) */
.nav-group {
  margin-bottom: 4px;
}

.nav-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: #4B5563;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border-left: 2px solid transparent;
  position: relative;
}

[data-theme="dark"] .nav-group-header {
  color: #9CA3AF;
}

.nav-group-header:hover {
  background: #F3F4F6;
  color: #111827;
}

[data-theme="dark"] .nav-group-header:hover {
  background: #374151;
  color: #F9FAFB;
}

.nav-group-chevron {
  margin-left: auto;
  font-size: 12px;
  transition: transform 0.15s ease;
  color: #4B5563;
}

[data-theme="dark"] .nav-group-chevron {
  color: #9CA3AF;
}

.nav-group-header[aria-expanded="true"] .nav-group-chevron,
.nav-group.expanded .nav-group-chevron {
  transform: rotate(180deg);
}

.nav-group-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.nav-group-submenu.expanded {
  max-height: 1000px;
}

/* Ensure submenu is visible when expanded */
.nav-group-submenu.expanded {
  display: block;
  max-height: 1000px;
}

.nav-subitem {
  padding-left: calc(16px + 18px + 8px);
  font-size: 12px;
  font-weight: 400;
}

.nav-subitem .nav-item-icon {
  width: 16px;
  font-size: 12px;
}

/* Nested nav group (e.g. Process Catalog inside Business Processes) */
.nav-group-nested {
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .nav-group-nested {
  border-left-color: rgba(255, 255, 255, 0.08);
}

.nav-group-submenu .nav-group-nested .nav-group-header {
  padding-left: 12px;
}

.nav-group-submenu .nav-group-nested .nav-group-submenu .nav-subitem {
  padding-left: calc(16px + 18px + 8px + 12px);
}

/* Collapsed sidebar adjustments for nav groups */
.sidebar.collapsed .nav-group-header span:not(.nav-item-icon),
.sidebar.collapsed .nav-group-chevron,
.sidebar.collapsed .nav-group-submenu {
  display: none;
}

.sidebar.collapsed .nav-group-header {
  justify-content: center;
  padding: 10px var(--space-sm);
}

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--sidebar-border);
}

/* =====================================================
   Header
   ===================================================== */

.header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 13px;
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--brand);
}

.breadcrumb-separator {
  color: var(--text-muted);
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-search {
  display: flex;
  align-items: center;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  width: 240px;
}

.header-search input {
  background: none;
  border: none;
  color: var(--text-primary);
  flex: 1;
  outline: none;
  font-size: 13px;
}

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

.header-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  border: 1px solid transparent;
  /* Keep transparent border to prevent layout shift */
  background: transparent;
}

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

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  background: var(--status-danger);
  color: white;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-card);
  /* Distinct border */
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

/* Notification Dropdown */
.notification-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

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

.notification-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notification-list {
  max-height: 300px;
  overflow-y: auto;
}

.notification-item {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: var(--space-sm);
  transition: background var(--transition);
  cursor: pointer;
}

.notification-item:hover {
  background: var(--bg-hover);
}

.notification-item.unread {
  background: var(--brand-light);
}

.notification-item.unread:hover {
  background: #dbeafecc;
  /* slightly darker light blue */
}

.notification-icon {
  margin-top: 2px;
  color: var(--brand);
}

.notification-content {
  flex: 1;
}

.notification-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.notification-time {
  font-size: 11px;
  color: var(--text-muted);
}

.notification-footer {
  padding: var(--space-sm);
  text-align: center;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
}

/* User Menu Dropdown */
.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.user-menu-trigger:hover {
  background: var(--bg-hover);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition);
  z-index: 200;
}

.user-menu:hover .user-menu-dropdown,
.user-menu.open .user-menu-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-menu-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-color);
}

.user-menu-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-menu-email {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-md);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.user-menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.user-menu-item-icon {
  width: 16px;
  text-align: center;
}

.user-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-xs) 0;
}

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

.user-menu-item.danger:hover {
  background: var(--status-danger-bg);
}

.theme-toggle {
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all var(--transition);
}

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

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

/* Language Selector */
.lang-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
  position: relative;
}

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

.lang-code {
  font-weight: 600;
  text-transform: uppercase;
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition);
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding: 4px;
}

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

.lang-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

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

.lang-item.active {
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 500;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

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

.card-body {
  padding: var(--space-lg);
}

.card-body.tight {
  padding: var(--space-md);
}

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

.card-body {
  padding: var(--space-lg);
}

.card-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-color);
  background: var(--bg-zebra);
}

/* =====================================================
   Stats Cards
   ===================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 4px;
}

.stat-change {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  margin-top: 4px;
}

.stat-change.positive {
  color: var(--status-success);
}

.stat-change.negative {
  color: var(--status-danger);
}

/* =====================================================
   Tables
   ===================================================== */

.table-container {
  overflow-x: auto;
}

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

.table th {
  text-align: left;
  padding: 10px var(--space-md);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  background: var(--bg-zebra);
  border-bottom: 1px solid var(--border-color);
}

.table td {
  padding: 10px var(--space-md);
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

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

.table tbody tr:nth-child(even) {
  background: var(--bg-zebra);
}

.table tbody tr:nth-child(even):hover {
  background: var(--bg-hover);
}

/* =====================================================
   Badges
   ===================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
}

/* Risk/Priority Levels */
.badge-critical {
  background: var(--level-critical-bg);
  color: var(--level-critical);
}

.badge-high {
  background: var(--level-high-bg);
  color: var(--level-high);
}

.badge-medium {
  background: var(--level-medium-bg);
  color: var(--level-medium);
}

.badge-low {
  background: var(--level-low-bg);
  color: var(--level-low);
}

/* Status */
.badge-open {
  background: var(--brand-light);
  color: var(--brand);
}

.badge-in-progress {
  background: #F3E8FF;
  color: #9333EA;
}

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

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

/* =====================================================
   Buttons
   ===================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

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

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

.btn-danger {
  background: var(--status-danger);
  color: white;
  border-color: var(--status-danger);
}

.btn-warning {
  background: var(--status-warning);
  color: white;
  border-color: var(--status-warning);
}

.btn-warning:hover {
  background: #EA580C;
  border-color: #EA580C;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 10px 20px;
  font-size: 14px;
}

/* =====================================================
   Forms
   ===================================================== */

.form-group {
  margin-bottom: var(--space-md);
}

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

.form-label.required::after {
  content: ' *';
  color: var(--status-danger);
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  transition: all var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-light);
}

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

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239CA3AF' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

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

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* =====================================================
   Progress Bars
   ===================================================== */

.progress-bar {
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 300ms ease;
}

.progress-fill.brand {
  background: var(--brand);
}

.progress-fill.success {
  background: var(--status-success);
}

.progress-fill.warning {
  background: var(--status-warning);
}

.progress-fill.danger {
  background: var(--status-danger);
}

/* =====================================================
   Grid Layouts
   ===================================================== */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

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

  .sidebar {
    transform: translateX(-100%);
  }

  .header-search {
    display: none;
  }
}

/* =====================================================
   Utilities
   ===================================================== */

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

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

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

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

.text-brand {
  color: var(--brand);
}

.text-success {
  color: var(--status-success);
}

.text-danger {
  color: var(--status-danger);
}

.font-semibold {
  font-weight: 600;
}

.font-medium {
  font-weight: 500;
}

.mb-sm {
  margin-bottom: var(--space-sm);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.mb-xl {
  margin-bottom: var(--space-xl);
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.text-xs {
  font-size: 11px;
}

.text-sm {
  font-size: 13px;
}

.text-base {
  font-size: 14px;
}

.text-lg {
  font-size: 16px;
}

.text-xl {
  font-size: 18px;
}

.text-2xl {
  font-size: 24px;
}

/* Code/ID styling */
.code {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
  font-size: 12px;
  color: var(--brand);
}

/* Page title area */
.page-header {
  margin-bottom: var(--space-lg);
}

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

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

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
}

.filter-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.filter-item label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.filter-item select,
.filter-item input {
  padding: 6px 10px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
}

/* =====================================================
   Responsive Design (Standardized)
   ===================================================== */

/* Mobile & Tablet (max-width: 1024px) */
@media (max-width: 1024px) {

  /* Layout */
  .sidebar {
    position: fixed;
    /* Ensure fixed on mobile */
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    width: 240px;
    z-index: 1000 !important;
    /* Force on top of overlay (990) */
    box-shadow: var(--shadow-lg);
  }

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

  /* Force sidebar full width and visibility on mobile regardless of collapsed state */
  .sidebar.collapsed {
    width: 240px !important;
  }

  .sidebar.collapsed .sidebar-title,
  .sidebar.collapsed .sidebar-subtitle,
  .sidebar.collapsed .nav-section-title,
  .sidebar.collapsed .nav-item span:not(.nav-item-icon),
  .sidebar.collapsed .nav-item-badge,
  .sidebar.collapsed .sidebar-footer>div>div:last-child {
    display: block !important;
  }

  .sidebar.collapsed .sidebar-header {
    justify-content: flex-start !important;
    padding: var(--space-md) !important;
  }

  .sidebar.collapsed .nav-item {
    justify-content: flex-start !important;
    padding: 10px var(--space-md) !important;
  }

  /* Mobile Brand in Header */
  .header-mobile-brand {
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
  }

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

  /* Header */
  .header {
    padding: 0 var(--space-md);
    gap: var(--space-sm);
  }

  .header-left {
    gap: var(--space-sm);
  }

  .header-search {
    display: none;
    /* Hide global search on mobile to save space, or make iconic */
  }

  /* Breadcrumbs: hide text on mobile, keep back button if needed */
  .breadcrumb {
    display: none;
  }

  /* Grids */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr !important;
  }

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

  p.page-subtitle {
    font-size: 12px;
  }

  /* Page Header Mobile */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }

  .page-header .flex {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  /* Stats Grid Mobile Override */
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-md) !important;
  }

  /* Grid 2 Mobile Stack */
  .grid-2 {
    grid-template-columns: 1fr !important;
    gap: var(--space-md) !important;
  }

  /* Ensure filter bar allows wrapping */
  .filter-bar {
    border-radius: var(--radius-lg);
    /* Restore radius if needed */
    margin-bottom: var(--space-md);
  }

  /* View Tabs Mobile */
  .view-tabs {
    flex-wrap: wrap;
    width: 100%;
  }

  .view-tab {
    flex: 1;
    text-align: center;
  }

  /* Sidebar Toggles */
  .sidebar-toggle.desktop-toggle {
    display: none !important;
    /* Hide desktop toggle */
  }

  /* Mobile Sidebar Overlay */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 990 !important;
    /* Below sidebar (1000) */
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
  }

  .sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
  }

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

  /* Utility */
  .hide-on-mobile {
    display: none !important;
  }

  .show-on-mobile {
    display: block !important;
  }

  /* Notifications and User Menu on Mobile */
  .notification-dropdown,
  .user-menu-dropdown {
    position: fixed;
    top: 60px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
  }
}