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

:root {
  /* Theme Variables - Default Dark Mode */
  --theme-primary-bg: #0f0f1a;
  --theme-secondary-bg: #16162a;
  --theme-surface-bg: #1e1e35;
  --theme-card-bg: #262640;
  --theme-elevated-bg: #2a2a47;
  
  /* Text Colors */
  --theme-text-primary: #ffffff;
  --theme-text-secondary: #b4b6c7;
  --theme-text-muted: #8b8d98;
  --theme-text-accent: #ffffff;
  
  /* Accent Colors - Purple/Blue Gradient Theme */
  --accent-primary: #6c5ce7;
  --accent-secondary: #a29bfe;
  --accent-gradient: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  --accent-gradient-hover: linear-gradient(135deg, #5f4fcf 0%, #9085e6 100%);
  
  /* Success/Error Colors */
  --success: #00d4aa;
  --success-light: #1dd1a1;
  --warning: #feca57;
  --info: #4dabf7;
  --info-light: #74c0fc;
  --danger: #ff6b6b;
  --danger-light: #ff7979;
  
  /* Shadows and Effects */
  --theme-shadow-color: rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 2px 4px var(--theme-shadow-color);
  --shadow-md: 0 4px 6px -1px var(--theme-shadow-color), 0 2px 4px -1px var(--theme-shadow-color);
  --shadow-lg: 0 10px 15px -3px var(--theme-shadow-color), 0 4px 6px -2px var(--theme-shadow-color);
  --shadow-xl: 0 20px 25px -5px var(--theme-shadow-color), 0 10px 10px -5px var(--theme-shadow-color);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 20px rgba(108, 92, 231, 0.15);

  /* Balance formatter colors */
  --amount-euro: var(--euro-dark, #4fc3f7);
  --amount-op-plus: var(--success);
  --amount-op-minus: var(--danger);
  --amount-bracket: var(--muted-dark, #a0aec0);
  --amount-total: #f7f7f7ff;
  
  /* Border and Dividers */
  --theme-border-color: rgba(255, 255, 255, 0.1);
  
  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  
  /* Transitions */
  --transition-fast: all 0.15s ease-in-out;
  --transition-normal: all 0.2s ease-in-out;
  --transition-slow: all 0.3s ease-in-out;
  
  /* Apply theme variables to current variables */
  --primary-bg: var(--theme-primary-bg);
  --secondary-bg: var(--theme-secondary-bg);
  --surface-bg: var(--theme-surface-bg);
  --card-bg: var(--theme-card-bg);
  --elevated-bg: var(--theme-elevated-bg);
  --text-primary: var(--theme-text-primary);
  --text-secondary: var(--theme-text-secondary);
  --text-muted: var(--theme-text-muted);
  --text-accent: var(--theme-text-accent);

  /* Layout sizes */
  --header-height: 60px;
  --header-content-height: 32px;
  --header-padding-y: calc((var(--header-height) - var(--header-content-height)) / 2);
  --header-padding-x: 24px;
  --header-padding: var(--header-padding-y) var(--header-padding-x);
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 76px;

  --wizard-icon-bg: rgba(15, 23, 42, 0.35);
  --wizard-step-media-inset: rgba(255, 255, 255, 0.02);
  --wizard-media-after-bg: radial-gradient(circle at top, rgba(255, 255, 255, 0.15), transparent 60%);
  --wizard-bars-bg: rgba(255, 255, 255, 0.6);
  --wizard-bars-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
  --wizard-chip-bg: rgba(15, 23, 42, 0.55);
  --wizard-chip-border: rgba(255, 255, 255, 0.12);
  --wizard-scroll-bg: rgba(255, 255, 255, 0.03);
  --wizard-scroll-border: rgba(255, 255, 255, 0.06);
  --wizard-inline-code-bg: rgba(0, 0, 0, 0.35);
  --wizard-inline-code-text: var(--accent-secondary);
  --wizard-pre-bg: rgba(0, 0, 0, 0.45);
  --wizard-pre-border: rgba(255, 255, 255, 0.08);
  --wizard-step-icon-border: transparent;
  --wizard-chip-shadow: none;

  --wizard-media-bay-bg: linear-gradient(145deg, rgba(108, 92, 231, 0.35), rgba(77, 171, 247, 0.2));
  --wizard-media-rack-bg: linear-gradient(145deg, rgba(0, 212, 170, 0.25), rgba(108, 92, 231, 0.2));
  --wizard-media-core-bg: linear-gradient(145deg, rgba(255, 206, 87, 0.25), rgba(108, 92, 231, 0.2));
  --wizard-media-terminal-bg: linear-gradient(145deg, rgba(77, 171, 247, 0.3), rgba(162, 155, 254, 0.2));
  --wizard-media-os-bg: linear-gradient(145deg, rgba(255, 107, 107, 0.25), rgba(108, 92, 231, 0.2));
  --wizard-media-launch-bg: linear-gradient(145deg, rgba(0, 212, 170, 0.25), rgba(255, 206, 87, 0.2));
}


/* Light Theme Variables */
[data-theme="light"] {
  --theme-primary-bg: #f8fafc;
  --theme-secondary-bg: #f1f5f9;
  --theme-surface-bg: #ffffff;
  --theme-card-bg: #ffffff;
  --theme-elevated-bg: #f8fafc;
  
  --theme-text-primary: #0f172a;
  --theme-text-secondary: #475569;
  --theme-text-muted: #64748b;
  --theme-text-accent: #ffffff;
  
  --theme-shadow-color: rgba(15, 23, 42, 0.08);
  --theme-border-color: rgba(15, 23, 42, 0.12);
  
  --accent-primary: #5b4ce0;
  --accent-secondary: #7d71ff;
  --accent-gradient: linear-gradient(135deg, #5b4ce0 0%, #8a7dff 100%);
  --accent-gradient-hover: linear-gradient(135deg, #4f41c9 0%, #7b6bef 100%);

  --shadow-glow: 0 0 18px rgba(91, 76, 224, 0.22);

  --euro-light: #1a237e;   /* Темно-синий */
  --muted-light: #718096;  /* Серый для скобок */

  /* Balance formatter colors (light) */
  --amount-euro: var(--euro-light, #1a237e);
  --amount-op-plus: var(--success);
  --amount-op-minus: var(--danger);
  --amount-bracket: var(--muted-light, #718096);
  --amount-total: #2d3748;

  --wizard-icon-bg: rgba(255, 255, 255, 0.78);
  --wizard-step-media-inset: rgba(15, 23, 42, 0.04);
  --wizard-media-after-bg: radial-gradient(circle at top, rgba(255, 255, 255, 0.35), transparent 60%);
  --wizard-bars-bg: rgba(15, 23, 42, 0.18);
  --wizard-bars-shadow: 0 0 8px rgba(15, 23, 42, 0.12);
  --wizard-chip-bg: rgba(255, 255, 255, 0.72);
  --wizard-chip-border: rgba(15, 23, 42, 0.12);
  --wizard-scroll-bg: rgba(15, 23, 42, 0.03);
  --wizard-scroll-border: rgba(15, 23, 42, 0.08);
  --wizard-inline-code-bg: rgba(15, 23, 42, 0.06);
  --wizard-inline-code-text: var(--accent-primary);
  --wizard-pre-bg: rgba(15, 23, 42, 0.04);
  --wizard-pre-border: rgba(15, 23, 42, 0.08);
  --wizard-step-icon-border: rgba(15, 23, 42, 0.1);
  --wizard-chip-shadow: var(--shadow-sm);

  --wizard-media-bay-bg: linear-gradient(145deg, rgba(108, 92, 231, 0.18), rgba(77, 171, 247, 0.12));
  --wizard-media-rack-bg: linear-gradient(145deg, rgba(0, 212, 170, 0.14), rgba(108, 92, 231, 0.12));
  --wizard-media-core-bg: linear-gradient(145deg, rgba(255, 206, 87, 0.18), rgba(108, 92, 231, 0.12));
  --wizard-media-terminal-bg: linear-gradient(145deg, rgba(77, 171, 247, 0.16), rgba(162, 155, 254, 0.14));
  --wizard-media-os-bg: linear-gradient(145deg, rgba(255, 107, 107, 0.16), rgba(108, 92, 231, 0.12));
  --wizard-media-launch-bg: linear-gradient(145deg, rgba(0, 212, 170, 0.14), rgba(255, 206, 87, 0.16));
}

/* Dark Theme Variables (explicit) */
[data-theme="dark"] {
  --theme-primary-bg: #0f0f1a;
  --theme-secondary-bg: #16162a;
  --theme-surface-bg: #1e1e35;
  --theme-card-bg: #262640;
  --theme-elevated-bg: #2a2a47;
  
  --theme-text-primary: #ffffff;
  --theme-text-secondary: #b4b6c7;
  --theme-text-muted: #8b8d98;
  --theme-text-accent: #ffffff;
  
  --theme-shadow-color: rgba(0, 0, 0, 0.1);
  --theme-border-color: rgba(255, 255, 255, 0.1);
  
  --shadow-glow: 0 0 20px rgba(108, 92, 231, 0.15);
  
  --euro-dark: #4fc3f7;    /* Светло-голубой */
  --muted-dark: #a0aec0;   /* Светло-серый для скобок */

  /* Balance formatter colors (dark) */
  --amount-euro: var(--euro-dark, #4fc3f7);
  --amount-op-plus: var(--success);
  --amount-op-minus: var(--danger);
  --amount-bracket: var(--muted-dark, #a0aec0);
  --amount-total: #f7f7f7ff;
}

/* Theme Toggle Switch */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface-bg);
  border: 1px solid var(--theme-border-color);
  transition: var(--transition-normal);
  cursor: pointer;
  user-select: none;
}

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

.theme-toggle__switch {
  position: relative;
  width: 48px;
  height: 24px;
  background: var(--theme-border-color);
  border-radius: 12px;
  transition: var(--transition-normal);
  overflow: hidden;
}

.theme-toggle__switch::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .theme-toggle__switch {
  background: var(--accent-primary);
}

[data-theme="dark"] .theme-toggle__switch::before {
  transform: translateX(24px);
  background: white;
}

.theme-toggle__icon {
  font-size: 16px;
  opacity: 0.6;
  transition: var(--transition-normal);
}

[data-theme="light"] .theme-toggle__icon.sun {
  opacity: 1;
  color: var(--warning);
}

[data-theme="dark"] .theme-toggle__icon.moon {
  opacity: 1;
  color: var(--accent-secondary);
}

/* Bootstrap variable overrides */
:root {
  --bs-body-color: var(--text-primary);
  --bs-body-bg: var(--primary-bg);
  --bs-border-color: var(--theme-border-color);
  --bs-link-color: var(--accent-primary);
  --bs-link-hover-color: var(--accent-secondary);
}

html,body{height:100%}

/* Prevent layout shift when scrollbars appear/disappear */
html {
  scrollbar-gutter: stable;
}

body{
  margin: 0;
  padding: 0;
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-weight: 400;
  font-size: 85%; /* Global font size reduction by 15% */
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  background: var(--primary-bg);
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(108, 92, 231, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(162, 155, 254, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(108, 92, 231, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
  min-width: 1200px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: var(--transition-normal);
}

/* Light theme background adjustments */
[data-theme="light"] body {
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(108, 92, 231, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(162, 155, 254, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(108, 92, 231, 0.02) 0%, transparent 50%);
}

/* App Layout Structure */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar Navigation */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--secondary-bg);
  border-right: 1px solid var(--theme-border-color);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: var(--transition-normal);
  box-shadow: var(--shadow-md);
}

/* Prevent flicker when restoring saved collapse state on load */
.sidebar.no-transition {
  transition: none !important;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

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

.sidebar.collapsed .sidebar-brand {
  display: none;
}

.sidebar.collapsed .sidebar-collapse-toggle {
  margin-left: 0;
  transform: none;
  display: inline-flex;
}

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

.sidebar.collapsed .sidebar-nav-icon,
.sidebar.collapsed .sidebar-dropdown-link i {
  opacity: 1;
}

.sidebar.collapsed .sidebar-nav-item {
  margin: 2px 8px;
}

.sidebar.collapsed .sidebar-nav-link,
.sidebar.collapsed .sidebar-dropdown-link {
  justify-content: center;
  align-items: center;
  gap: 0;
  padding: 12px;
  text-align: center;
}

.sidebar.collapsed .sidebar-nav-icon,
.sidebar.collapsed .sidebar-dropdown-link i {
  margin: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Sidebar Header */
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--theme-border-color);
  background: var(--surface-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.25rem;
  white-space: nowrap;
}

.sidebar-collapse-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--theme-border-color);
  border-radius: var(--radius-md);
  background: var(--surface-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-collapse-toggle:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

.sidebar.collapsed .sidebar-collapse-toggle i {
  transform: rotate(180deg);
  transition: var(--transition-fast);
}

.sidebar-brand:hover {
  color: var(--accent-primary);
}

.sidebar-brand-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.sidebar.collapsed .sidebar-nav-title,
.sidebar.collapsed .sidebar-nav-link span,
.sidebar.collapsed .sidebar-dropdown-arrow,
.sidebar.collapsed .sidebar-brand span {
  display: none;
}

.sidebar.collapsed .sidebar-nav-link,
.sidebar.collapsed .sidebar-dropdown-link {
  justify-content: center;
  align-items: center;
  gap: 0;
  padding: 12px;
  text-align: center;
}

.sidebar.collapsed .sidebar-nav-icon,
.sidebar.collapsed .sidebar-dropdown-link i {
  margin: 0;
}

/* Prevent label wrapping so text isn't truncated when expanding */
.sidebar-nav-link span,
.sidebar-dropdown-link span,
.sidebar-dropdown-link i + span {
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-dropdown-menu {
  display: none;
}

.sidebar.collapsed .sidebar-footer {
  display: none;
}

.sidebar-nav-section {
  margin-bottom: 24px;
}

.sidebar.collapsed .sidebar-nav-section {
  margin-bottom: 24px;
  position: relative;
}

.sidebar.collapsed .sidebar-nav-section:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -12px;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar.collapsed .sidebar-nav-section .list-unstyled {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar.collapsed .sidebar-nav-item {
  width: 100%;
  display: flex;
  justify-content: center;
}

.sidebar.collapsed .sidebar-nav-link {
  width: 44px;
  margin-right: 0;
}

.sidebar.collapsed .sidebar-nav-link:hover,
.sidebar.collapsed .sidebar-nav-link:focus-visible {
  background: transparent;
  box-shadow: none;
  transform: none;
  color: var(--accent-primary);
}

.sidebar-nav-title {
  padding: 0 20px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 0;
}

.sidebar-nav-item {
  list-style: none;
  margin: 2px 12px;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  font-weight: 500;
  position: relative;
}

.sidebar-nav-link:hover {
  background: var(--elevated-bg);
  color: var(--accent-primary);
  transform: translateX(2px);
}

.sidebar-nav-link.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-glow);
}

.sidebar-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  text-align: center;
  line-height: 1;
  flex-shrink: 0;
}

/* Dropdown in sidebar */
.sidebar-dropdown {
  position: relative;
}

.sidebar-dropdown-toggle {
  justify-content: space-between !important;
}

.sidebar-dropdown-arrow {
  transition: var(--transition-fast);
  font-size: 12px;
}

.sidebar-dropdown.show .sidebar-dropdown-arrow {
  transform: rotate(180deg);
}

.sidebar-dropdown-menu {
  max-height: 0;
  overflow: hidden;
  transition: var(--transition-normal);
  margin-top: 4px;
}

.sidebar-dropdown.show .sidebar-dropdown-menu {
  max-height: 300px;
}

.sidebar-dropdown-item {
  margin: 2px 0;
}

.sidebar-dropdown-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 46px;
  text-decoration: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  font-size: 14px;
}

.sidebar-dropdown-link:hover,
.sidebar-dropdown-link.active {
  background: var(--elevated-bg);
  color: var(--accent-primary);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--theme-border-color);
  background: var(--surface-bg);
}

/* Sidebar User Component */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--elevated-bg);
  border: 1px solid var(--theme-border-color);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition-fast);
  width: 100%;
}

.sidebar-user:hover {
  background: var(--card-bg);
  border-color: var(--accent-primary);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.sidebar-user .user-chip__avatar {
  border-radius: var(--radius-md);
  border: 2px solid var(--theme-border-color);
  flex-shrink: 0;
}

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

.user-info .user-chip__name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info .user-role {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user i {
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
}

/* Main Content Area */
.main-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--primary-bg);
  transition: var(--transition-normal);
}

.app-layout > .sidebar.collapsed + .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

.app-layout .sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* No-sidebar pages (e.g., login) */
.no-sidebar .main-content {
  margin-left: 0;
}

.no-sidebar .main-header {
  display: none;
}

/* Top Header (minimal) */
.main-header {
  background: var(--secondary-bg);
  border-bottom: 1px solid var(--theme-border-color);
  padding: var(--header-padding);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  box-shadow: none;
  box-sizing: border-box;
}

.sidebar-brand,
.main-header-title,
.main-header-actions {
  line-height: var(--header-content-height);
}

.main-header-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.main-header-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-left: 20px;
  padding-top: 5px;
}

.main-header-separator {
  color: var(--text-muted);
  font-weight: 600;
  flex: 0 0 auto;
}

.main-header-subtitle {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
}

.main-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Modern alert component (used on login page) */
.modern-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--theme-border-color);
  background: var(--surface-bg);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-normal);
}

.modern-alert .alert-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.modern-alert .alert-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modern-alert .alert-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.modern-alert .alert-message {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.modern-alert.alert-error {
  border-color: rgba(255, 107, 107, 0.35);
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.08), rgba(108, 92, 231, 0.08));
  box-shadow: 0 10px 25px -12px rgba(255, 107, 107, 0.55);
}

.modern-alert.alert-error .alert-icon {
  background: rgba(255, 107, 107, 0.15);
  color: #ff6b6b;
}

[data-theme="light"] .modern-alert {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.1);
}

[data-theme="light"] .modern-alert.alert-error {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.1), rgba(108, 92, 231, 0.06));
  border-color: rgba(255, 107, 107, 0.35);
}

.modern-alert.showing {
  animation: fadeInUp 0.25s ease-out;
}

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

/* Content Wrapper */
.content-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  padding: 24px 14px 24px 14px;
  overflow: hidden;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .mobile-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
  }
  
  .mobile-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }
  
  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--surface-bg);
    border: 1px solid var(--theme-border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
  }
  
  .mobile-menu-toggle:hover {
    background: var(--elevated-bg);
    border-color: var(--accent-primary);
  }
}

/* Clean up old navbar styles */
.navbar,
.modern-navbar,
.mc-navbar {
  display: none !important;
}

/* Fix body min-width for new layout */
body {
  min-width: 100% !important;
}

/* Page content should fill available space */

/* Container fixes for new layout */
.container,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.main-content .container{
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.main-content .container .card{
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.main-content .container .card .card-body{
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 24px;
  overflow: auto;
}

.main-content .tab-content{
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.main-content .tab-content > .tab-pane{
  flex: 1 1 auto;
  min-height: 0;
}

.main-content .tab-content > .tab-pane.active{
  display: flex;
  flex-direction: column;
}

/* Modern Material UI Cards */
.card,
.modern-card {
  background: var(--card-bg);
  border: 1px solid var(--theme-border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transition: none;
  overflow: hidden;
}

/* Neutral hover: no transform, no shadow/border change */
.card:hover,
.modern-card:hover,
.hover-lift:hover {
  transform: none;
  box-shadow: var(--shadow-lg);
  border-color: var(--theme-border-color);
  background: var(--card-bg);
}

.card-gradient,
.accent-card {
  background: var(--accent-gradient);
  color: var(--text-accent);
  box-shadow: var(--shadow-glow), var(--shadow-lg);
}

.dropdown-menu {
  background: var(--elevated-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(20px);
}

.navbar .dropdown-menu {
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
}

.card .card-body {
  color: var(--text-primary);
  padding: 24px;
  overflow: auto;
}

/* Sidebar Navigation */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--secondary-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  overflow-y: auto;
  transition: var(--transition-normal);
}

.sidebar-header {
  min-height: var(--header-height);
  height: var(--header-height);
  padding: var(--header-padding);
  border-bottom: 1px solid var(--theme-border-color);
  display: flex;
  align-items: center;
  background: var(--secondary-bg);
  box-shadow: 6px 0 12px -8px var(--theme-shadow-color);
  box-sizing: border-box;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
}

.sidebar-brand:hover {
  color: var(--accent-primary);
}

.sidebar-nav {
  list-style: none;
  margin: 0;
}

.sidebar-nav-item {
  margin-bottom: 4px;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--radius-md);
  margin-right: 12px;
  transition: var(--transition-normal);
  position: relative;
}

.sidebar-nav-link:hover {
  background: var(--elevated-bg);
  color: var(--accent-primary);
}

.sidebar-nav-link.active {
  color: var(--text-accent);
  background: var(--accent-gradient);
  box-shadow: var(--shadow-md);
}

/* Remove active marker (left stripe) */
.sidebar-nav-link.active::before {
  display: none !important;
  content: none !important;
}

.sidebar-nav-icon {
  width: 20px;
  height: 20px;
  opacity: 0.8;
}

.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: var(--transition-normal);
}

.home-card-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 20px 20px 20px;
}

.home-card .modern-card-header {
  padding-bottom: 0;
}

.home-card .card-body.home-card-body {
  padding-top: 10px;
}

.home-card-body .tab-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.home-card-body .tab-content .tab-pane {
  flex: 1 1 auto;
  min-height: 0;
}

.home-card-body .tab-content .tab-pane.active {
  display: flex;
  flex-direction: column;
}

.home-card-body .crud-root {
  flex: 1 1 auto;
  min-height: 0;
}

.card-header,
.modern-card-header {
  background: var(--surface-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 20px 24px;
}

/* Home page: make the primary card occupy available height so embedded tables can size correctly */
.content-wrapper > .modern-card,
.content-wrapper > .card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.card-header h4,
.card-header h5,
.card-header .card-title,
.modern-card-header h4,
.modern-card-header h5,
.modern-card-header .card-title {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1.1rem;
}

/* Modern Navbar/Header */
.navbar,
.modern-navbar {
  background: var(--secondary-bg);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-md);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 999;
}

.navbar .navbar-brand {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  transition: var(--transition-normal);
}

.navbar .navbar-brand:hover {
  color: var(--accent-primary);
}

.navbar .nav-link {
  color: var(--text-secondary);
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  transition: var(--transition-normal);
  margin: 0 4px;
}

.navbar .nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.navbar .nav-link.active {
  color: var(--text-accent);
  background: var(--accent-gradient);
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}

.navbar .dropdown-toggle::after {
  margin-left: 6px;
  transition: var(--transition-normal);
  border-top-color: var(--text-secondary);
}

.navbar .dropdown:hover > .nav-link,
.navbar .dropdown.show > .nav-link {
  color: var(--accent-primary);
}

.navbar .dropdown:hover .dropdown-toggle::after,
.navbar .dropdown.show .dropdown-toggle::after {
  transform: rotate(180deg);
  border-top-color: var(--accent-primary);
}

.navbar .dropdown:hover > .dropdown-menu,
.navbar .dropdown.show > .dropdown-menu {
  display: block;
  animation: fadeInDown 0.15s ease-out;
}

.navbar-toggler {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 8px;
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='m4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.dropdown-menu {
  padding: 8px;
}

.dropdown-item {
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  margin-bottom: 2px;
  transition: var(--transition-fast);
  font-weight: 500;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.dropdown-item.active,
.dropdown-item:active {
  background: var(--accent-gradient);
  color: var(--text-accent);
  border-color: transparent;
}

/* Modern User Component */
.user-chip,
.modern-user {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--text-primary);
  text-decoration: none;
  padding: 10px 16px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface-bg);
  backdrop-filter: blur(10px);
  transition: var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.user-chip:hover,
.modern-user:hover {
  color: var(--text-primary);
  background: var(--elevated-bg);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.user-chip__icon,
.modern-user__icon {
  opacity: 0.9;
  color: var(--accent-primary);
}

.user-chip__avatar,
.modern-user__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.user-chip__name,
.modern-user__name {
  font-weight: 600;
  font-size: 0.9rem;
}

/* Modern Form Controls */
.form-control,
.form-select,
.modern-input {
  background: var(--surface-bg);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 400;
  transition: color 0.2s ease-in-out,
              border-color 0.2s ease-in-out,
              background-color 0.2s ease-in-out,
              box-shadow 0.2s ease-in-out;
  box-shadow: var(--shadow-sm);
}

.form-control::placeholder,
.modern-input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.form-control:focus,
.form-select:focus,
.modern-input:focus {
  background: var(--elevated-bg);
  color: var(--text-primary);
  border-color: var(--accent-primary);
  outline: none;
  box-shadow: none;
  transform: none;
}

.form-control:hover:not(:focus),
.form-select:hover:not(:focus),
.modern-input:hover:not(:focus) {
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--elevated-bg);
}

/* Modern Material UI Buttons */
.btn {
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 12px 24px;
  border: 1px solid var(--theme-border-color);
  background: var(--surface-bg);
  color: var(--text-primary);
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
  letter-spacing: 0.025em;
  box-shadow: var(--shadow-sm);
}

.btn:before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s;
}

.btn:hover:before {
  left: 100%;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary {
  background: var(--accent-gradient) !important;
  color: var(--text-accent) !important;
  border-color: var(--accent-primary) !important;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background: var(--accent-gradient-hover) !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-secondary {
  background: var(--surface-bg) !important;
  color: var(--text-primary) !important;
  border-color: var(--theme-border-color) !important;
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--elevated-bg) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%) !important;
  color: white !important;
  border-color: var(--success) !important;
  box-shadow: var(--shadow-md);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(0, 212, 170, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger-light) 100%) !important;
  color: white !important;
  border-color: var(--danger) !important;
  box-shadow: var(--shadow-md);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(255, 107, 107, 0.3);
}

.btn-warning {
  background: linear-gradient(135deg, var(--warning) 0%, #fed330 100%) !important;
  color: #2c2c54 !important;
  border-color: var(--warning) !important;
  box-shadow: var(--shadow-md);
}

.btn-warning:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(254, 202, 87, 0.3);
}

.btn-info {
  background: linear-gradient(135deg, var(--info) 0%, var(--info-light) 100%) !important;
  color: #0b1626 !important;
  border-color: var(--info) !important;
  box-shadow: var(--shadow-md);
}

.btn-info:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(77, 171, 247, 0.35);
}

.btn-light {
  background: rgba(255, 255, 255, 0.9) !important;
  color: #1f2937 !important;
  border-color: rgba(255, 255, 255, 0.6) !important;
  box-shadow: var(--shadow-sm);
}

.btn-light:hover {
  background: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-dark {
  background: #0b0b16 !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  box-shadow: var(--shadow-md);
}

.btn-dark:hover {
  background: #151528 !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-link {
  background: transparent !important;
  color: var(--accent-primary) !important;
  border-color: transparent !important;
  box-shadow: none !important;
  padding: 8px 12px;
}

.btn-link:hover {
  color: var(--accent-secondary) !important;
  text-decoration: none;
  transform: none;
  box-shadow: none;
}

/* Outline buttons */
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-danger,
.btn-outline-warning,
.btn-outline-info,
.btn-outline-light,
.btn-outline-dark {
  background: transparent !important;
  box-shadow: none;
}

.btn-outline-primary {
  color: var(--accent-primary) !important;
  border-color: var(--accent-primary) !important;
}

.btn-outline-primary:hover {
  background: var(--accent-gradient) !important;
  color: var(--text-accent) !important;
}

.btn-outline-secondary {
  color: var(--text-primary) !important;
  border-color: var(--theme-border-color) !important;
}

.btn-outline-secondary:hover {
  background: var(--elevated-bg) !important;
  color: var(--text-primary) !important;
}

.btn-outline-success {
  color: var(--success) !important;
  border-color: var(--success) !important;
}

.btn-outline-success:hover {
  background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%) !important;
  color: #ffffff !important;
}

.btn-outline-danger {
  color: var(--danger) !important;
  border-color: var(--danger) !important;
}

.btn-outline-danger:hover {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger-light) 100%) !important;
  color: #ffffff !important;
}

.btn-outline-warning {
  color: #f9d65c !important;
  border-color: var(--warning) !important;
}

.btn-outline-warning:hover {
  background: linear-gradient(135deg, var(--warning) 0%, #fed330 100%) !important;
  color: #2c2c54 !important;
}

.btn-outline-info {
  color: var(--info) !important;
  border-color: var(--info) !important;
}

.btn-outline-info:hover {
  background: linear-gradient(135deg, var(--info) 0%, var(--info-light) 100%) !important;
  color: #0b1626 !important;
}

.btn-outline-light {
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.6) !important;
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.9) !important;
  color: #1f2937 !important;
}

.btn-outline-dark {
  color: #0b0b16 !important;
  border-color: #0b0b16 !important;
}

.btn-outline-dark:hover {
  background: #0b0b16 !important;
  color: #ffffff !important;
}

/* Light theme tweaks for button borders/backgrounds */
[data-theme="light"] .btn {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.18);
  color: var(--text-primary);
}

[data-theme="light"] .btn-secondary {
  background: #f8fafc !important;
  border-color: rgba(15, 23, 42, 0.2) !important;
}

[data-theme="light"] .btn-secondary:hover {
  background: #eef2f7 !important;
  border-color: rgba(15, 23, 42, 0.28) !important;
}

[data-theme="light"] .btn-warning {
  color: #2b2b2b !important;
}

[data-theme="light"] .btn-info {
  color: #0b1626 !important;
}

[data-theme="light"] .btn-light {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: rgba(15, 23, 42, 0.18) !important;
}

[data-theme="light"] .btn-light:hover {
  background: #f8fafc !important;
}

[data-theme="light"] .btn-dark {
  background: #0f172a !important;
  color: #ffffff !important;
  border-color: #0f172a !important;
}

[data-theme="light"] .btn-outline-light {
  color: #0f172a !important;
  border-color: rgba(15, 23, 42, 0.35) !important;
}

[data-theme="light"] .btn-outline-light:hover {
  background: #0f172a !important;
  color: #ffffff !important;
}

.btn:active {
  transform: translateY(0) !important;
  box-shadow: var(--shadow-sm) !important;
}

/* Input group buttons should not lift on hover */
.input-group .btn,
.input-group .btn:hover,
.input-group .btn:focus {
  transform: none !important;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 0.95rem;
}

/* Login page tightening */
.login-page {
  padding: 24px;
}

.login-page .modern-card {
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.login-page .modern-card-header h4 {
  font-size: 1.2rem;
}

.login-page .modern-card-header .text-gradient {
  font-size: 2rem !important;
}

.login-page .small-text,
.login-page .form-label {
  font-size: 0.9rem;
}

.login-page .search-container .input-group-text {
  font-size: 0.95rem;
  padding: 10px 12px;
}

/* Modern Material UI Tables */
.table,
.modern-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-primary);
  --bs-table-border-color: rgba(255, 255, 255, 0.1);
  background: var(--card-bg);
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
}

.table thead th,
.modern-table thead th {
  background: var(--surface-bg);
  color: var(--text-primary);
  border-bottom: 0;
}

[data-theme="light"] .table thead th,
[data-theme="light"] .modern-table thead th {
  background: #f3f5f7;
  color: var(--text-primary);
  border-bottom: 0;
}

.table thead th,
.modern-table thead th {
  padding: 14px 0 14px 0;
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.025em;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Add breathing room to the first column (#) on stats page tables */
.stats-page .table thead th:first-child,
.stats-page .table tbody td:first-child {
  padding-left: 10px;
}

/* Stats page: refine card/table spacing and item labels */
.stats-page .card.modern-card {
  background: linear-gradient(160deg, rgba(108, 92, 231, 0.08) 0%, rgba(21, 28, 45, 0.9) 65%);
  border-color: rgba(108, 92, 231, 0.25);
}

[data-theme="light"] .stats-page .card.modern-card {
  background: linear-gradient(160deg, rgba(108, 92, 231, 0.06) 0%, rgba(255, 255, 255, 0.98) 70%);
  border-color: rgba(108, 92, 231, 0.2);
}

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

.stats-page .table tbody td {
  padding: 12px 0;
  vertical-align: middle;
}

.stats-item-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  line-height: 1.25;
}

.stats-item-label .mc-image {
  flex: 0 0 auto;
}

.stats-item-text {
  white-space: normal;
  word-break: break-word;
}

/* Stats: custom legend for profit analysis chart */
.stats-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 16px;
}

.stats-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--theme-border-color);
  background: rgba(15, 23, 42, 0.35);
}

[data-theme="light"] .stats-legend-item {
  background: rgba(255, 255, 255, 0.9);
}

.stats-legend-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  line-height: 1.25;
}

.stats-legend-value {
  margin-left: auto;
  font-weight: 600;
  color: var(--accent-primary);
}

/* Stats: prevent chart container from growing endlessly */
.stats-chart-wrap {
  position: relative;
  height: var(--chart-height, 260px);
  min-height: var(--chart-height, 260px);
  max-height: var(--chart-height, 260px);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.stats-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  max-width: 100% !important;
  max-height: 100% !important;
}

.table tbody td,
.modern-table tbody td {
  background: transparent;
  padding: 10px 0 10px 0; /* ~20% tighter height for rows */
  border-bottom: 0;
  transition: var(--transition-fast);
}

.table tbody tr:not(:last-child) td,
.modern-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .table tbody tr:not(:last-child) td,
[data-theme="light"] .modern-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid var(--theme-border-color);
}

.table tbody tr:hover td,
.modern-table tbody tr:hover td {
  background: rgba(108, 92, 231, 0.05);
  transform: none;
  color: var(--text-primary);
}

.table tbody tr:hover,
.modern-table tbody tr:hover {
  box-shadow: 0 0 0 1px rgba(108, 92, 231, 0.1) inset;
}

/* Light theme: add gentle zebra striping for readability */
[data-theme="light"] .table tbody tr:nth-child(odd) td,
[data-theme="light"] .modern-table tbody tr:nth-child(odd) td {
  background: rgba(15, 23, 42, 0.02);
}

/* Reset password modal: ensure password is visible in light theme */
[data-theme="light"] #reset-pass-value {
  color: rgba(0, 0, 0, 0.9) !important;
  font-weight: 700;
}

/* McCrud: remove per-table card header/title (PageTitle already shown in top header) */
.mc-crud-card > .mc-card__header {
  display: none;
}

/* McCrud: sorting UI (FontAwesome via real <i> tags, no pseudo-content) */
th.mc-crud-sortable {
  cursor: pointer;
  user-select: none;
}

th.mc-crud-sortable.active {
  color: var(--accent-primary);
}

.mc-crud-th-label {
  display: inline;
}

.mc-crud-th-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  min-width: 16px;
}

.mc-crud-th-arrow i {
  font-size: 12px;
  line-height: 1;
}

/* McCrud: pagination as unified control (no borders) */
.mc-pagination {
  display: flex;
  gap: 0;
  padding: 4px;
  background: var(--surface-bg);
  border-radius: var(--radius-md);
}

.mc-pagination .page-item {
  margin: 0;
}

.mc-pagination .page-link {
  border: 0 !important;
  background: transparent;
  color: var(--text-secondary);
  min-width: 34px;
  text-align: center;
  border-radius: 0 !important;
}

.mc-pagination .page-item:first-child .page-link {
  border-top-left-radius: calc(var(--radius-md) - 4px) !important;
  border-bottom-left-radius: calc(var(--radius-md) - 4px) !important;
}

.mc-pagination .page-item:last-child .page-link {
  border-top-right-radius: calc(var(--radius-md) - 4px) !important;
  border-bottom-right-radius: calc(var(--radius-md) - 4px) !important;
}

.mc-pagination .page-link:hover {
  background: var(--elevated-bg);
  color: var(--accent-primary);
}

.mc-pagination .page-item.active .page-link {
  background: var(--accent-gradient);
  color: var(--text-accent);
}

.mc-pagination .page-item.disabled .page-link {
  color: var(--text-muted);
  opacity: 0.7;
}

.table tbody td.font-monospace,
.modern-table tbody td.font-monospace {
  font-size: 0.85em;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

/* Table Actions Column */
.table-actions-col,
.crud-actions-col {
  min-width: 1%;
  width: 1%;
  padding-left: 10px;
  padding-right: 15px;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
}

table td.mc-crud-actions-col,
table th.mc-crud-actions-col,
table td.table-actions-col,
table th.table-actions-col {
  text-align: center;
}

.mc-crud-actions-col .btn-group,
.table-actions-col .btn-group {
  margin-left: auto;
  margin-right: auto;
}

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

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

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

/* Modern Material UI Tabs */
.nav-tabs {
  border-bottom: 1px solid var(--theme-border-color);
  margin-bottom: 24px;
}

/* Home page: tighter spacing between tabs and content */
.home-card .nav-tabs {
  margin-bottom: 8px;
}

.nav-tabs .nav-link {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: 1px solid transparent;
  color: var(--text-secondary);
  background: transparent;
  padding: 12px 20px;
  font-weight: 500;
  transition: var(--transition-normal);
  margin-bottom: -1px;
  margin-right: 4px;
}

.nav-tabs .nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.nav-tabs .nav-link.active {
  color: var(--text-accent);
  background: var(--card-bg);
  border-color: rgba(255, 255, 255, 0.1);
  border-bottom-color: var(--card-bg);
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .nav-tabs .nav-link.active {
  color: var(--text-primary);
  box-shadow: none;
  border-color: var(--theme-border-color);
  border-bottom-color: var(--card-bg);
  border-width: 1px 1px 0 1px;
}

/* Modern Search Components */
.input-group {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-md);
  background: var(--surface-bg);
  overflow: hidden;
  transition: var(--transition-normal);
}

.input-group:focus-within {
  border-color: var(--accent-primary);
}

.input-group .input-group-text {
  border: none;
  background: transparent;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.input-group .form-control,
.input-group .modern-input {
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 10px 14px;
}

.input-group .form-control:focus,
.input-group .modern-input:focus {
  border: none;
  outline: none;
  box-shadow: none;
  background: transparent;
}

.search-container .input-group-text {
  min-width: 44px;
  justify-content: center;
  background: var(--surface-bg);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-right: none;
  color: var(--text-muted);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.search-container .input-group-text i {
  opacity: 0.8;
  transition: var(--transition-normal);
}

.search-container:focus-within .input-group-text {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.search-container:focus-within .input-group-text i {
  opacity: 1;
}

.search-container .form-control {
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* McCrud search (mc_crud_table.js uses .mc-search + .mc-input, not .search-container) */
.mc-search .input-group-text.mc-input {
  background: var(--surface-bg);
  color: var(--text-muted);
  border-right: none;
}

.mc-search .form-control.mc-input {
  background: var(--card-bg);
  color: var(--text-primary);
  border-left: none;
}

.mc-search:focus-within .input-group-text.mc-input,
.mc-search:focus-within .form-control.mc-input {
  border-color: var(--accent-primary);
}

/* Unified input/select styling (matches mc-search focus outline) */
.form-control,
.form-select,
select,
input[type="text"],
input[type="search"],
input[type="number"],
input[type="email"],
input[type="password"],
textarea {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--theme-border-color);
  border-radius: var(--radius-md);
  box-shadow: none;
  /* limit transition to avoid animating background-position of error icon */
  transition: color 0.15s ease-in-out,
              border-color 0.15s ease-in-out,
              background-color 0.15s ease-in-out,
              box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus,
.form-select:focus-visible,
select:focus,
select:focus-visible,
input[type="text"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
  border-color: var(--accent-primary);
  outline: none !important;
  box-shadow: none !important;
}

/* Remove UA focus rings on selects to keep a single 1px border like inputs */
.form-select,
select {
  appearance: none;
  -webkit-appearance: none;
}

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

/* Modern Filters Panel */
.filters-panel {
  padding: 20px;
  background: var(--surface-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

/* Modern Table Wrapper */
.table-responsive {
  max-height: none;
  overflow: auto;
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: none;
  background: transparent;
}

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

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

.table-responsive::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.table-wrapper thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.table-wrapper .table-responsive {
  flex: 1 1 auto;
  min-height: 0;
  border-radius: var(--radius-lg);
}

/* McCrud layout: stretch card + table to available height */
.mc-crud-root {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.mc-crud-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.mc-crud-card .card-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
}

.mc-crud-card .mc-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.mc-crud-card .mc-table-wrap .table-responsive {
  flex: 1 1 auto;
  min-height: 0;
}

.mc-crud-embed .mc-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.mc-crud-embed .mc-table-wrap .table-responsive {
  flex: 1 1 auto;
  min-height: 0;
}

/* Embedded Crud (no outer card) */
.mc-crud-embed {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.mc-crud-embed .mc-crud-embed-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  background: transparent;
}

/* McCrud empty overlay */
.mc-empty-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, rgba(108, 92, 231, 0.06) 0%, rgba(0, 0, 0, 0.35) 100%);
  color: var(--text-muted);
  text-align: center;
  pointer-events: none;
  border-radius: 12px;
}

[data-theme="light"] .mc-empty-overlay {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #e6e8ec;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.02);
}

.mc-table-wrap {
  position: relative;
}

.mc-empty-overlay__inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  max-width: 360px;
}

.mc-empty-overlay__icon i {
  font-size: 32px;
  color: var(--accent-primary);
}

.mc-empty-overlay__text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* McCrud table header: accent-only */
.mc-table thead th {
  background: var(--surface-bg);
  color: var(--text-primary);
  border-bottom: 1px solid var(--theme-border-color) !important;
}

.mc-table thead {
  border-bottom: 1px solid var(--theme-border-color);
}

/* McCrud footer separator (between table body and footer controls) */
.mc-crud-footer {
  border-top: 1px solid var(--theme-border-color);
  padding-top: 12px;
  flex-shrink: 0;
}

/* Modern Material UI Modals */
.modal-content {
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  backdrop-filter: blur(20px);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  background: var(--surface-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 24px 32px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-title {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1.25rem;
}

.modal-body {
  color: var(--text-primary);
  padding: 24px 32px;
}

.modal-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 20px 32px;
  background: var(--surface-bg);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* Light theme modal accents: gentle gray separation for header/footer */
[data-theme="light"] .modal-content {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .modal-header {
  background: #f6f7fb;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .modal-footer {
  background: #f6f7fb;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.modal-backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

/* Modal close button visibility */
[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(1.6);
  opacity: 0.85;
}

[data-theme="dark"] .btn-close:hover {
  opacity: 1;
}

/* Modern Toast Notifications */
.toast {
  background: var(--elevated-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(20px);
  animation: toastSlideIn 0.3s ease-out;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast-header {
  background: var(--surface-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  color: var(--text-primary);
  font-weight: 600;
}

.toast-body {
  color: var(--text-primary);
  padding: 16px;
}

.toast-container .toast {
  opacity: 1;
  margin-bottom: 12px;
}

/* Modern Material UI Pagination */
.pagination .page-link {
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  background: var(--surface-bg);
  padding: 10px 16px;
  margin: 0 2px;
  font-weight: 500;
  transition: var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.pagination .page-link:hover {
  background: var(--elevated-bg);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.pagination .page-item.active .page-link {
  background: var(--accent-gradient);
  border-color: var(--accent-primary);
  color: var(--text-accent);
  box-shadow: var(--shadow-glow), var(--shadow-md);
}

.pagination .page-item.disabled .page-link {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--surface-bg);
}

.pagination .page-item.disabled .page-link:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
}
/* Modern CRUD Components */
.crud-select {
  min-width: 140px;
  width: auto;
  background: var(--surface-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 8px 12px;
}

.toolbar,
.modern-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding: 20px;
  background: var(--surface-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.toolbar__left,
.modern-toolbar__left {
  flex: 1 1 auto;
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.toolbar__right,
.modern-toolbar__right {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.search-input,
.modern-search {
  min-width: 200px;
  flex: 1;
}

/* Modern CRUD Layout */
.crud-root {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 24px;
}

.crud-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.crud-card .card-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 24px;
  overflow: visible;
}

.table-wrapper {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.table-wrapper .table-responsive {
  flex: 1 1 auto;
  min-height: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Sortable Table Headers */
.sortable-header {
  cursor: pointer;
  user-select: none;
  transition: var(--transition-normal);
  position: relative;
}

.sortable-header:hover {
  color: var(--accent-primary);
  background: rgba(108, 92, 231, 0.05);
}

.sortable-header.active {
  color: var(--accent-primary);
}

/* Light theme: keep active sort headers accent-colored (override base th color) */
[data-theme="light"] .sortable-header.active,
[data-theme="light"] th.mc-crud-sortable.active {
  color: var(--accent-primary);
}

.sort-arrow {
  font-size: 0.7rem;
  display: inline-block;
  width: 16px;
  margin-left: 6px;
  transition: var(--transition-normal);
  opacity: 0.6;
}

.sortable-header:hover .sort-arrow {
  opacity: 1;
}

.sort-arrow.asc::before {
  content: '▲';
}

.sort-arrow.desc::before {
  content: '▼';
}

/* Modern Footer and Loading States */
.crud-footer,
.table-footer {
  padding: 16px 20px;
  background: var(--surface-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.mc-crud-busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 15, 26, 0.7);
  backdrop-filter: blur(4px);
  z-index: 10;
  border-radius: inherit;
}

[data-theme="light"] .mc-crud-busy {
  background: rgba(236, 236, 236, 0.9);
}

.mc-crud-busy__inner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 26, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

[data-theme="light"] .loading-overlay {
  background: rgba(236, 236, 236, 0.9);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.loading-spinner {
  padding: 24px 32px;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 500;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(108, 92, 231, 0.3);
  border-top: 2px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Text wrapping and typography utilities */
.table th,
.table td {
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

/* Utility Classes */
.text-gradient {
  background: var(--accent-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 600;
}

/* Wiki / wizard inline icons */
.inline-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 6px;
}

.bg-gradient {
  background: var(--accent-gradient);
}

/* Keep tab badges readable in light theme (text-white on white background) */
[data-theme="light"] .nav-tabs .badge.bg-gradient {
  background: var(--accent-gradient);
  color: rgba(0, 0, 0, 0.9) !important;
  border: 1px solid rgba(108, 92, 231, 0.35);
  box-shadow: 0 2px 4px rgba(108, 92, 231, 0.15);
}

/* Tabs badges: dim when inactive, full when active (both themes) */
.nav-tabs .nav-link .badge.bg-gradient {
  opacity: 0.65;
  transition: var(--transition-normal);
}

.nav-tabs .nav-link.active .badge.bg-gradient,
.nav-tabs .nav-link:focus .badge.bg-gradient,
.nav-tabs .nav-link:hover .badge.bg-gradient {
  opacity: 1;
}

[data-theme="dark"] .nav-tabs .badge.bg-gradient {
  color: #fff !important;
}

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }
.shadow-2xl { box-shadow: var(--shadow-2xl); }
.shadow-glow { box-shadow: var(--shadow-glow); }

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }

.transition-fast { transition: var(--transition-fast); }
.transition-normal { transition: var(--transition-normal); }
.transition-slow { transition: var(--transition-slow); }

.backdrop-blur {
  backdrop-filter: blur(10px);
}

.backdrop-blur-lg {
  backdrop-filter: blur(20px);
}

/* Hover effects */
.hover-lift {
  transition: var(--transition-normal);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.hover-glow:hover {
  box-shadow: var(--shadow-glow), var(--shadow-lg);
}

/* Status indicators */
.status-online {
  color: var(--success);
}

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

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

.status-warning {
  color: var(--warning);
}

/* Modern scrollbars for all containers */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

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

*::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* Responsive Design */
/* Remove old responsive styles - replaced by new sidebar layout */

@media (max-width: 768px) {
  .main-content {
    padding: 16px;
    gap: 16px;
  }
  
  .card {
    border-radius: var(--radius-md);
  }
  
  .card .card-body {
    padding: 20px;
  }
  
  .toolbar,
  .modern-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .toolbar__left,
  .modern-toolbar__left {
    min-width: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .search-input,
  .modern-search {
    min-width: auto;
  }
}

/* Additional animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-fade-in-up {
  animation: fadeInUp 0.3s ease-out;
}

.animate-fade-in-down {
  animation: fadeInDown 0.2s ease-out;
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out;
}

/* Focus states for accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus,
.nav-link:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --accent-primary: #8a7fff;
    --accent-secondary: #b8afff;
  }
}

/* MC-CRUD Card Display Styles */

.mc-crud-card {
  background: var(--card-bg);
  border: 1px solid var(--theme-border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: var(--transition-normal);
  overflow: hidden;
  position: relative;
}

.mc-crud-card:hover {
  transform: none;
  box-shadow: var(--shadow-md);
  border-color: var(--theme-border-color);
}

.mc-crud-card.mc-crud-card--clickable {
  cursor: pointer;
}

.mc-crud-card__header {
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--theme-border-color);
  background: var(--elevated-bg);
}

.mc-crud-card__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.25rem 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mc-crud-card__subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
  opacity: 0.8;
}

.mc-crud-card__body {
  padding: 1.25rem;
}

.mc-crud-card__body-field {
  margin-bottom: 1rem;
}

.mc-crud-card__body-field:last-child {
  margin-bottom: 0;
}

.mc-crud-card__field-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
  display: block;
}

.mc-crud-card__field-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  word-wrap: break-word;
  line-height: 1.5;
}

.mc-crud-card__field-value.mc-crud-card__field-value--mono {
  font-family: 'SF Mono', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace;
  background: var(--theme-secondary-bg);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--theme-border-color);
  font-size: 0.8125rem;
}

.mc-crud-card__field-value--empty {
  color: var(--text-muted);
  font-style: italic;
}

.mc-crud-card__footer {
  padding: 0.75rem 1.25rem 1.25rem;
  border-top: 1px solid var(--theme-border-color);
  background: var(--theme-secondary-bg);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.mc-crud-card__actions {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
  opacity: 0;
  transition: var(--transition-normal);
}

.mc-crud-card:hover .mc-crud-card__actions {
  opacity: 1;
}

.mc-crud-card__action-btn {
  background: var(--elevated-bg);
  border: 1px solid var(--theme-border-color);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-normal);
  cursor: pointer;
  font-size: 0.875rem;
}

.mc-crud-card__action-btn:hover {
  background: var(--accent-primary);
  color: var(--text-accent);
  border-color: var(--accent-primary);
  transform: scale(1.05);
}

.mc-crud-card__action-btn--edit {
  color: var(--accent-secondary);
}

.mc-crud-card__action-btn--edit:hover {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
}

.mc-crud-card__action-btn--delete {
  color: var(--danger);
}

.mc-crud-card__action-btn--delete:hover {
  background: var(--danger);
  border-color: var(--danger);
}

.mc-crud-card__badge {
  position: absolute;
  top: -0.5rem;
  left: 1rem;
  background: var(--accent-gradient);
  color: var(--text-accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.mc-crud-card__image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-bottom: 1px solid var(--theme-border-color);
}

/* Card Grid Responsive */
@media (max-width: 768px) {
  .mc-crud-cards-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .mc-crud-card__header,
  .mc-crud-card__body,
  .mc-crud-card__footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .mc-crud-card__actions {
    opacity: 1;
    position: static;
    justify-content: center;
    margin-top: 1rem;
    padding: 0 1rem;
  }
}

@media (max-width: 576px) {
  .mc-crud-cards-container {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .mc-crud-card__header {
    padding: 1rem 1rem 0.5rem;
  }
  
  .mc-crud-card__body {
    padding: 1rem;
  }
  
  .mc-crud-card__footer {
    padding: 0.5rem 1rem 1rem;
  }
}

/* Card Display Mode Toggle */
.mc-crud-display-toggle {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.mc-crud-display-toggle__btn {
  background: var(--theme-secondary-bg);
  border: 1px solid var(--theme-border-color);
  color: var(--text-secondary);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.mc-crud-display-toggle__btn:hover {
  background: var(--elevated-bg);
  color: var(--text-primary);
}

.mc-crud-display-toggle__btn--active {
  background: var(--accent-primary);
  color: var(--text-accent);
  border-color: var(--accent-primary);
}

.mc-crud-display-toggle__btn--active:hover {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
}

/* Empty state for cards */
.mc-crud-cards-empty {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.mc-crud-cards-empty__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.mc-crud-cards-empty__title {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.mc-crud-cards-empty__subtitle {
  font-size: 0.875rem;
  opacity: 0.8;
}

/* JWT Token Container Styles */
.mc-crud-card__token-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.mc-crud-card__token-preview {
  flex: 1;
  margin: 0;
}

.mc-crud-card__copy-btn {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
  white-space: nowrap;
  transition: var(--transition-normal);
}

.mc-crud-card__copy-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--text-accent);
  transform: translateY(-1px);
}

.mc-crud-card__copy-btn i {
  margin-right: 0.25rem;
}

/* Full height for cards container */
.mc-crud-cards-root {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.mc-crud-cards-root .card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.mc-crud-cards-root .card-body {
  min-height: calc(100vh - var(--header-height) - 200px);
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.mc-crud-cards-container {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
  align-content: start;
}

/* Setup Wizard */
.setup-wizard {
  background: var(--card-bg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 24px;
  position: relative;
  overflow: hidden;
}

.setup-wizard.is-complete {
  border-color: rgba(0, 212, 170, 0.5);
  box-shadow: 0 0 0 1px rgba(0, 212, 170, 0.35), var(--shadow-lg);
}

 [data-theme="light"] .setup-wizard {
   box-shadow: var(--shadow-md);
 }

 [data-theme="light"] .setup-wizard.is-complete {
   border-color: rgba(0, 212, 170, 0.35);
   box-shadow: 0 0 0 1px rgba(0, 212, 170, 0.12), var(--shadow-md);
 }

.wizard-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wizard-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.wizard-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.wizard-progress {
  height: 8px;
  background: var(--theme-secondary-bg);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--theme-border-color);
}

.wizard-progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent-gradient);
  transition: width 0.35s ease;
  box-shadow: var(--shadow-glow);
}

.wizard-steps-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.wizard-step-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--theme-border-color);
  background: var(--theme-secondary-bg);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: var(--transition-normal);
}

.wizard-step-pill span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--theme-elevated-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-primary);
}

.wizard-step-pill small {
  font-size: 0.72rem;
  text-transform: uppercase;
}

.wizard-step-pill.is-active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: var(--text-accent);
  box-shadow: var(--shadow-glow);
}

.wizard-step-pill.is-active span {
  background: rgba(255, 255, 255, 0.25);
  color: var(--text-accent);
}

.wizard-step-pill.is-complete {
  background: rgba(0, 212, 170, 0.15);
  border-color: rgba(0, 212, 170, 0.4);
  color: var(--success-light);
}

 [data-theme="light"] .wizard-step-pill.is-complete {
   background: rgba(0, 212, 170, 0.08);
   border-color: rgba(0, 212, 170, 0.22);
   color: #0f766e;
 }

.wizard-step-pill.is-complete span {
  background: var(--success);
  color: var(--text-accent);
}

.wizard-body {
  background: var(--elevated-bg);
  border: 1px solid var(--theme-border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wizard-step-panel {
  display: none !important;
  height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  animation: wizardFade 0.35s ease;
}

.wizard-step-panel.is-active {
  display: flex !important;
}

.wizard-step-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.4fr) 1fr;
  gap: 24px;
  align-items: stretch;
  height: 100%;
  min-height: 0;
}

.wizard-step-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  height: 100%;
  flex: 1 1 auto;
}

.wizard-markdown {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.wizard-step-media {
  border-radius: var(--radius-lg);
  border: 1px solid var(--theme-border-color);
  padding: 20px;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  text-align: center;
  box-shadow: inset 0 0 0 1px var(--wizard-step-media-inset);
}

.wizard-step-media::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--wizard-media-after-bg);
  opacity: 0.5;
  pointer-events: none;
}

.wizard-media-bay {
  background: var(--wizard-media-bay-bg);
}

.wizard-media-rack {
  background: var(--wizard-media-rack-bg);
}

.wizard-media-core {
  background: var(--wizard-media-core-bg);
}

.wizard-media-terminal {
  background: var(--wizard-media-terminal-bg);
}

.wizard-media-os {
  background: var(--wizard-media-os-bg);
}

.wizard-media-launch {
  background: var(--wizard-media-launch-bg);
}

.wizard-step-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--wizard-icon-bg);
  border: 1px solid var(--wizard-step-icon-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  z-index: 1;
}

.wizard-media-bars {
  display: flex;
  gap: 6px;
  z-index: 1;
}

.wizard-media-bars span {
  width: 16px;
  height: 6px;
  border-radius: 999px;
  background: var(--wizard-bars-bg);
  box-shadow: var(--wizard-bars-shadow);
}

.wizard-media-chip {
  z-index: 1;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--wizard-chip-bg);
  border: 1px solid var(--wizard-chip-border);
  box-shadow: var(--wizard-chip-shadow);
  color: var(--text-primary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.wizard-step-kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.wizard-step-content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.wizard-markdown {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.wizard-markdown p {
  margin-bottom: 0.75rem;
}

.wizard-markdown ul {
  padding-left: 1.2rem;
  margin-bottom: 0.75rem;
}

.wizard-markdown li {
  margin-bottom: 0.35rem;
}

/* Scrollable block for long wizard lists */
.wizard-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  background: var(--wizard-scroll-bg);
  border: 1px solid var(--wizard-scroll-border);
  margin-bottom: 8px;
}

.wizard-markdown code {
  background: var(--wizard-inline-code-bg);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--wizard-inline-code-text);
}

 .wizard-markdown pre code {
   background: transparent;
   padding: 0;
   border-radius: 0;
   color: inherit;
 }

.wizard-markdown pre {
  background: var(--wizard-pre-bg);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  border: 1px solid var(--wizard-pre-border);
}

 [data-theme="light"] .wizard-step-media {
   box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--wizard-step-media-inset);
 }

 [data-theme="light"] .wizard-step-media::after {
   opacity: 0.35;
 }

 [data-theme="light"] .wizard-step-pill span {
   background: var(--theme-surface-bg);
   border: 1px solid var(--theme-border-color);
   color: var(--text-secondary);
 }

.wizard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--theme-border-color);
}

.wizard-footer-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wizard-step-label {
  font-weight: 600;
  color: var(--text-primary);
}

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

.wizard-actions {
  margin-left: auto;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

@media (max-width: 992px) {
  .wizard-step-grid {
    grid-template-columns: 1fr;
  }

  .wizard-step-media {
    min-height: 200px;
  }
}

@media (max-width: 640px) {
  .wizard-steps-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
  }

  .wizard-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .wizard-actions {
    justify-content: flex-start;
  }
}

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