/* ===== Variables CSS ===== */
:root {
  /* Colors */
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1623;
  --bg-tertiary: #1a2332;
  --bg-hover: #253045;
  --bg-active: #2a3550;

  --border-primary: #2a3550;
  --border-secondary: #3a4660;
  --border-accent: #4a5670;

  --text-primary: #e1e8f7;
  --text-secondary: #a8b3cf;
  --text-muted: #7a8ab8;
  --text-dim: #5a6a98;

  --accent-primary: #4a9eff;
  --accent-secondary: #3d8bfd;
  --accent-muted: #2a6ac0;

  --success: #4ade80;
  --success-bg: rgba(74, 222, 128, 0.1);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.1);
  --error: #f87171;
  --error-bg: rgba(248, 113, 113, 0.1);

  /* Cyberpunk Accents */
  --cyber-primary: #00d4ff;
  --cyber-secondary: #ff00ff;
  --cyber-accent: #00ff88;

  /* Nav Group Colors */
  --nav-overview: #00d4ff;
  --nav-search: #a78bfa;
  --nav-assets: #34d399;
  --nav-system: #fbbf24;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #4a9eff 0%, #3d8bfd 100%);
  --gradient-accent: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
  --gradient-card: linear-gradient(145deg, rgba(26, 35, 50, 0.9), rgba(15, 22, 35, 0.9));

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(74, 158, 255, 0.3);

  /* Layout */
  --sidebar-width: 210px;
  --top-bar-height: 64px;
  --border-radius: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'JetBrains Mono', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  position: relative;
}

/* ===== Background Pattern ===== */
.bg-pattern {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 25% 25%, rgba(74, 158, 255, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(0, 212, 255, 0.05) 0%, transparent 50%),
    linear-gradient(45deg, transparent 48%, rgba(74, 158, 255, 0.015) 49%, rgba(74, 158, 255, 0.015) 51%, transparent 52%),
    linear-gradient(-45deg, transparent 48%, rgba(0, 212, 255, 0.015) 49%, rgba(0, 212, 255, 0.015) 51%, transparent 52%);
  background-size: 800px 800px, 800px 800px, 20px 20px, 20px 20px;
  background-position: 0 0, 400px 400px, 0 0, 10px 10px;
  pointer-events: none;
  z-index: 0;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

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

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--gradient-card);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
}

/* Disable transitions on initial load to prevent flash */
.sidebar.no-transition,
.sidebar.no-transition *,
.sidebar.no-transition ~ .main-content {
  transition: none !important;
}

/* Sidebar collapsed state */
.sidebar.collapsed {
  width: 60px;
}

/* Hide ALL text elements when collapsed */
.sidebar.collapsed .logo-text {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 4px;
  position: relative;
  width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
}

/* Hide text spans in nav items when collapsed */
.sidebar.collapsed .nav-item span {
  display: none !important;
}

/* Tooltip elements (created by JS) */
.nav-tooltip {
  display: none;
}

.sidebar.collapsed .nav-tooltip {
  display: block;
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(4px);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  padding: 7px 14px;
  border-radius: 8px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 1px rgba(59, 130, 246, 0.2);
}

/* Arrow pointing left */
.sidebar.collapsed .nav-tooltip::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: var(--border-primary);
}

.sidebar.collapsed .nav-tooltip::after {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--bg-tertiary);
}

.sidebar.collapsed .nav-item:hover .nav-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

.sidebar.collapsed .nav-item::before {
  left: 0;
  width: 100%;
  height: 3px;
  top: auto;
  bottom: 0;
  transform: scaleX(0);
}

.sidebar.collapsed .nav-item.active::before {
  transform: scaleX(1);
}

.sidebar.collapsed .nav-icon {
  margin: 0;
  flex-shrink: 0;
}

/* Icons styling when collapsed */
.sidebar.collapsed .nav-item svg {
  font-size: 20px;
  width: 20px;
  height: 20px;
}

.sidebar.collapsed .sidebar-header {
  padding: 10px 4px;
  justify-content: center;
}

.sidebar.collapsed .logo svg {
  width: 64px;
  height: 64px;
}

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

.sidebar.collapsed .status-indicator {
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sidebar.collapsed .status-indicator span {
  display: none;
}

/* Ensure icons stay centered */
.sidebar.collapsed .logo {
  justify-content: center;
}

/* Toggle button in top bar */
.sidebar-toggle-btn {
  padding: 8px 16px;
  background: rgba(74, 158, 255, 0.1);
  border: 1px solid rgba(74, 158, 255, 0.2);
  border-radius: var(--border-radius);
  color: var(--accent-primary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  backdrop-filter: blur(10px);
}

.sidebar-toggle-btn:hover {
  background: rgba(74, 158, 255, 0.2);
  border-color: var(--accent-primary);
  box-shadow: 0 0 15px rgba(74, 158, 255, 0.3);
  transform: translateY(-1px);
}

.sidebar-toggle-btn:active {
  transform: translateY(0);
}

.sidebar-toggle-btn svg {
  width: 18px;
  height: 18px;
  transition: var(--transition);
}

/* Menu icon states */
.sidebar-toggle-btn .menu-icon-open {
  display: block;
}

.sidebar-toggle-btn .menu-icon-closed {
  display: none;
}

.sidebar.collapsed .sidebar-toggle-btn .menu-icon-open {
  display: none;
}

.sidebar.collapsed .sidebar-toggle-btn .menu-icon-closed {
  display: block;
}

.sidebar-header {
  padding: 12px 20px 4px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--cyber-primary);
  text-decoration: none;
}

.logo-text {
  font-family: 'Satoshi', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.22em;
  background: linear-gradient(135deg, #00d4ff 0%, #3b82f6 50%, #60a5fa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
}

.nav-sections {
  flex: 1;
  padding: 0;
  overflow: visible;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  position: relative;
  font-family: 'Satoshi', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 500;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--cyber-primary);
  transform: scaleY(0);
  transition: var(--transition);
}

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

.nav-item.active {
  background: var(--bg-active);
  color: var(--cyber-primary);
}

.nav-item.active::before {
  transform: scaleY(1);
}

.nav-icon {
  width: 20px;
  height: 20px;
  opacity: 0.8;
  transition: var(--transition);
}

.nav-item.active .nav-icon {
  opacity: 1;
  filter: drop-shadow(0 0 8px currentColor);
}

/* ===== Nav Groups ===== */
.nav-group-overview { --group-color: var(--nav-overview); }
.nav-group-search { --group-color: var(--nav-search); }
.nav-group-assets { --group-color: var(--nav-assets); }
.nav-group-system { --group-color: var(--nav-system); }

.nav-group {
  padding: 8px 0 4px;
}

.nav-group-overview { background: linear-gradient(180deg, rgba(0, 212, 255, 0.03) 0%, transparent 100%); }
.nav-group-search { background: linear-gradient(180deg, rgba(167, 139, 250, 0.03) 0%, transparent 100%); }
.nav-group-assets { background: linear-gradient(180deg, rgba(52, 211, 153, 0.03) 0%, transparent 100%); }
.nav-group-system { background: linear-gradient(180deg, rgba(251, 191, 36, 0.03) 0%, transparent 100%); }

.nav-group + .nav-group-overview { border-top: 1px solid rgba(0, 212, 255, 0.15); }
.nav-group + .nav-group-search { border-top: 1px solid rgba(167, 139, 250, 0.15); }
.nav-group + .nav-group-assets { border-top: 1px solid rgba(52, 211, 153, 0.15); }
.nav-group + .nav-group-system { border-top: 1px solid rgba(251, 191, 36, 0.15); }

.nav-group-label {
  display: block;
  padding: 0 20px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--group-color);
  opacity: 0.5;
  font-family: 'Satoshi', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.nav-group .nav-item::before {
  background: var(--group-color);
}

.nav-group .nav-item.active {
  color: var(--group-color);
}

.nav-group .nav-item.active .nav-icon {
  filter: drop-shadow(0 0 8px var(--group-color));
}

.nav-group-overview .nav-item:hover { background: rgba(0, 212, 255, 0.08); }
.nav-group-search .nav-item:hover { background: rgba(167, 139, 250, 0.08); }
.nav-group-assets .nav-item:hover { background: rgba(52, 211, 153, 0.08); }
.nav-group-system .nav-item:hover { background: rgba(251, 191, 36, 0.08); }

/* Collapsed: hide group labels, thicker colored separators */
.sidebar.collapsed .nav-group-label {
  display: none;
}

.sidebar.collapsed .nav-group {
  padding: 4px 0;
}

.sidebar.collapsed .nav-group + .nav-group-overview { border-top: 2px solid rgba(0, 212, 255, 0.25); }
.sidebar.collapsed .nav-group + .nav-group-search { border-top: 2px solid rgba(167, 139, 250, 0.25); }
.sidebar.collapsed .nav-group + .nav-group-assets { border-top: 2px solid rgba(52, 211, 153, 0.25); }
.sidebar.collapsed .nav-group + .nav-group-system { border-top: 2px solid rgba(251, 191, 36, 0.25); }

/* Collapsed active bar uses group color */
.sidebar.collapsed .nav-group .nav-item::before {
  background: var(--group-color);
}

.sidebar-bottom-actions {
  margin-top: auto;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sidebar-action-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  width: 100%;
}

.sidebar-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-secondary);
  border-radius: 6px;
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-action-logout {
  color: #fc8181;
  border-color: rgba(252, 129, 129, 0.3);
}

.sidebar-action-logout:hover {
  border-color: #fc8181;
  color: #ff6b6b;
  background: rgba(252, 129, 129, 0.15);
}

.sidebar-action-rc {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.3);
}

.sidebar-action-rc:hover {
  border-color: #fbbf24;
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.15);
}

.sidebar-action-rc.copied {
  border-color: var(--success);
  color: var(--success);
  background: rgba(52, 211, 153, 0.15);
}

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

.sidebar-action-toggle .toggle-chevron {
  transition: transform 0.3s ease;
}

.sidebar-action-toggle:hover {
  border-color: var(--cyber-primary);
  color: var(--cyber-primary);
  background: rgba(0, 212, 255, 0.1);
}

.sidebar-shortcut-hint {
  order: -1;
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
  opacity: 0.5;
}

/* Collapsed: stack buttons vertically, hide text-only elements */
.sidebar.collapsed .sidebar-bottom-actions {
  padding: 8px 4px 12px;
}

.sidebar.collapsed .sidebar-action-buttons {
  flex-direction: column;
  gap: 6px;
}

.sidebar.collapsed .sidebar-action-btn {
  width: 36px;
  height: 36px;
}

.sidebar.collapsed .sidebar-shortcut-hint {
  display: none;
}

/* Flip chevron when collapsed (points right = "expand") */
.sidebar.collapsed .sidebar-action-toggle .toggle-chevron {
  transform: rotate(180deg);
}

/* RC copy toast */
.rc-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99998;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 10px;
  padding: 14px 18px;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 12px rgba(52, 211, 153, 0.1);
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.rc-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.rc-toast > svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.rc-toast-body {
  min-width: 0;
}

.rc-toast-title {
  color: #34d399;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.rc-toast-cmd {
  display: block;
  background: var(--bg-primary);
  border: 1px solid var(--border-secondary);
  border-radius: 6px;
  padding: 8px 10px;
  color: #fbbf24;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  word-break: break-all;
  line-height: 1.4;
}

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

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse 2s infinite;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ===== Cat Logo Animations ===== */
.cat-eyes { transform-origin: 100px 105px; }
.cat-eye-left { transform-origin: 78px 105px; }
.cat-eye-right { transform-origin: 122px 105px; }
.cat-pupil-left { transform-origin: 78px 105px; }
.cat-pupil-right { transform-origin: 122px 105px; }
.cat-nose { transform-origin: 98.7px 129px; }
.cat-mouth { transform-origin: 98.7px 140px; }
.cat-smile { transform-origin: 98.7px 139px; }
.cat-tongue { transform-origin: 98.7px 138px; }
.cat-ear-wrap-left { transform-origin: 65px 73px; }
.cat-ear-wrap-right { transform-origin: 137px 78px; }

/* 1. Blink */
.cat-logo.blink .cat-eyes { animation: catBlink 0.4s ease-in-out; }
@keyframes catBlink {
  0%, 100% { transform: scaleY(1); }
  40%, 60% { transform: scaleY(0.05); }
}

/* 2. Double Blink */
.cat-logo.double-blink .cat-eyes { animation: catDoubleBlink 0.8s ease-in-out; }
@keyframes catDoubleBlink {
  0%, 100% { transform: scaleY(1); }
  15%, 20% { transform: scaleY(0.05); }
  35%, 55% { transform: scaleY(1); }
  65%, 75% { transform: scaleY(0.05); }
}

/* 3. Yawn */
.cat-logo.yawn .cat-eyes { animation: catYawnEyes 2.5s ease-in-out; }
.cat-logo.yawn .cat-mouth { animation: catYawnMouth 2.5s ease-in-out; }
.cat-logo.yawn .cat-nose { animation: catYawnNose 2.5s ease-in-out; }
@keyframes catYawnEyes {
  0%, 100% { transform: scaleY(1); }
  20%, 80% { transform: scaleY(0.5); }
}
@keyframes catYawnMouth {
  0%, 100% { opacity: 0; transform: scale(0); }
  20%, 80% { opacity: 0.8; transform: scale(1); }
}
@keyframes catYawnNose {
  0%, 100% { transform: translateY(0); }
  20%, 80% { transform: translateY(-3px); }
}

/* 4. Look Around */
.cat-logo.look-around .cat-pupil-left,
.cat-logo.look-around .cat-pupil-right { animation: catLookAround 2s ease-in-out; }
@keyframes catLookAround {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(6px); }
  75% { transform: translateX(-6px); }
}

/* 5. Wide Eyes */
.cat-logo.wide-eyes .cat-eyes { animation: catWideEyes 1.2s ease-in-out; }
@keyframes catWideEyes {
  0%, 100% { transform: scale(1); }
  30%, 70% { transform: scale(1.15); }
}

/* 6. Wink (left) */
.cat-logo.wink .cat-eye-left { animation: catWink 0.5s ease-in-out; }
@keyframes catWink {
  0%, 100% { transform: scaleY(1); }
  35%, 65% { transform: scaleY(0.05); }
}

/* 7. Wink (right) */
.cat-logo.wink-r .cat-eye-right { animation: catWinkR 0.5s ease-in-out; }
@keyframes catWinkR {
  0%, 100% { transform: scaleY(1); }
  35%, 65% { transform: scaleY(0.05); }
}

/* 8. Nose Twitch */
.cat-logo.nose-twitch .cat-nose { animation: catNoseTwitch 1s ease-in-out; }
@keyframes catNoseTwitch {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(2px); }
  30% { transform: translateX(-2px); }
  45% { transform: translateX(1.5px); }
  60% { transform: translateX(-1.5px); }
  75% { transform: translateX(1px); }
  85% { transform: translateX(-0.5px); }
}

/* 9. Ear Twitch (left) */
.cat-logo.ear-twitch .cat-ear-wrap-left { animation: catEarTwitchL 0.8s ease-in-out; }
@keyframes catEarTwitchL {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  50% { transform: rotate(3deg); }
  75% { transform: rotate(-2deg); }
}

/* 10. Ear Twitch (right) */
.cat-logo.ear-twitch-r .cat-ear-wrap-right { animation: catEarTwitchR 0.8s ease-in-out; }
@keyframes catEarTwitchR {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(5deg); }
  50% { transform: rotate(-3deg); }
  75% { transform: rotate(2deg); }
}

/* 11. Smile */
.cat-logo.smile .cat-smile { animation: catSmile 2s ease-in-out; }
@keyframes catSmile {
  0%, 100% { opacity: 0; }
  20%, 80% { opacity: 0.9; }
}

/* 12. Blep (tongue) */
.cat-logo.blep .cat-tongue { animation: catBlep 2s ease-in-out; }
@keyframes catBlep {
  0%, 100% { opacity: 0; transform: translateY(-4px); }
  15%, 85% { opacity: 1; transform: translateY(0); }
}

/* 13. Sleepy */
.cat-logo.sleepy .cat-eyes { animation: catSleepyEyes 3s ease-in-out; }
.cat-logo.sleepy .cat-z1 { animation: catZzz1 3s ease-in-out; }
.cat-logo.sleepy .cat-z2 { animation: catZzz2 3s ease-in-out; }
.cat-logo.sleepy .cat-z3 { animation: catZzz3 3s ease-in-out; }
@keyframes catSleepyEyes {
  0%, 100% { transform: scaleY(1); }
  25%, 75% { transform: scaleY(0.1); }
}
@keyframes catZzz1 {
  0%, 15% { opacity: 0; transform: translateY(0); }
  25%, 65% { opacity: 0.8; }
  85%, 100% { opacity: 0; transform: translateY(-12px); }
}
@keyframes catZzz2 {
  0%, 25% { opacity: 0; transform: translateY(0); }
  35%, 65% { opacity: 0.6; }
  85%, 100% { opacity: 0; transform: translateY(-12px); }
}
@keyframes catZzz3 {
  0%, 35% { opacity: 0; transform: translateY(0); }
  45%, 65% { opacity: 0.4; }
  85%, 100% { opacity: 0; transform: translateY(-12px); }
}

/* 14. Surprised (wide eyes + smile) */
.cat-logo.surprised .cat-eyes { animation: catSurprisedEyes 2s ease-in-out; }
.cat-logo.surprised .cat-smile { animation: catSurprisedSmile 2s ease-in-out; }
@keyframes catSurprisedEyes {
  0%, 100% { transform: scale(1); }
  15%, 40% { transform: scale(1.2); }
  60% { transform: scale(1); }
}
@keyframes catSurprisedSmile {
  0%, 40% { opacity: 0; }
  55%, 85% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .cat-logo * { animation: none !important; }
}

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  position: relative;
  z-index: 1;
  transition: var(--transition);
  width: calc(100% - var(--sidebar-width));
}

/* Adjust main content when sidebar is collapsed */
.sidebar.collapsed ~ .main-content {
  margin-left: 60px;
  width: calc(100% - 60px);
}

/* Ensure proper z-index stacking */
.sidebar {
  z-index: 100;
}

.main-content {
  z-index: 1;
}

/* ===== Top Bar ===== */
.top-bar {
  height: var(--top-bar-height);
  background: var(--gradient-card);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-bar-left .title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.results-count {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.results-count span {
  color: var(--cyber-primary);
  font-weight: 700;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

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

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

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

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

.btn-accent {
  background: var(--gradient-accent);
  color: white;
}

.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(0, 212, 255, 0.4);
}

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

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

/* ===== Form Elements ===== */
.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

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

/* ===== Loading Overlay ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 14, 26, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-secondary);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-secondary);
  border-top-color: var(--cyber-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-content {
  background: var(--gradient-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--border-radius);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

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

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

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

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

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

/* ===== Card Components ===== */
.card {
  background: var(--gradient-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--border-radius);
  padding: 24px;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-secondary);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(74, 158, 255, 0.1);
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ===== Utility Classes ===== */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }

.bg-primary { background: var(--bg-primary); }
.bg-secondary { background: var(--bg-secondary); }
.bg-tertiary { background: var(--bg-tertiary); }

.border-primary { border-color: var(--border-primary); }
.border-secondary { border-color: var(--border-secondary); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }

.p-2 { padding: 8px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }

.m-2 { margin: 8px; }
.m-4 { margin: 16px; }
.m-6 { margin: 24px; }

.rounded { border-radius: var(--border-radius); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.hidden { display: none; }
.block { display: block; }

.text-sm { font-size: 14px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Keyboard Shortcuts ===== */
kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-secondary);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* ===== Mobile Switch Banner ===== */
.mobile-switch-banner {
  display: none;
}

.mobile-fab {
  display: none;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

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

  .sidebar.collapsed ~ .main-content {
    margin-left: 0;
    width: 100%;
  }

  .top-bar {
    padding-left: 20px;
    padding-right: 20px;
  }
}

@media (max-width: 768px) {
  /* Hide desktop UI on small screens, show mobile banner */
  .sidebar {
    display: none !important;
  }

  .main-content {
    display: none !important;
  }

  .bg-pattern {
    display: none;
  }

  .mobile-switch-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 24px;
    background: var(--bg-primary);
    text-align: center;
    gap: 32px;
  }

  .mobile-banner-logo svg {
    filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.4));
  }

  .mobile-banner-logo .logo-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 50%, #93c5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-top: 12px;
  }

  .mobile-banner-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .mobile-banner-content h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
  }

  .mobile-banner-content p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
  }

  .mobile-banner-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 32px;
    background: var(--gradient-primary);
    color: white;
    text-decoration: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(74, 158, 255, 0.3);
  }

  .mobile-banner-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 158, 255, 0.4);
  }

  .mobile-banner-link svg {
    width: 20px;
    height: 20px;
  }

  .mobile-banner-dismiss {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    padding: 8px;
    transition: var(--transition);
  }

  .mobile-banner-dismiss:hover {
    color: var(--text-secondary);
  }

  /* When banner is dismissed, restore desktop UI */
  .mobile-switch-banner.dismissed {
    display: none !important;
  }

  .mobile-switch-banner.dismissed ~ .sidebar {
    display: flex !important;
  }

  .mobile-switch-banner.dismissed ~ .main-content {
    display: block !important;
  }

  body.mobile-banner-dismissed .mobile-switch-banner {
    display: none !important;
  }

  body.mobile-banner-dismissed .sidebar {
    display: flex !important;
    transform: translateX(-100%);
  }

  body.mobile-banner-dismissed .main-content {
    display: block !important;
    margin-left: 0;
    width: 100%;
  }

  body.mobile-banner-dismissed .bg-pattern {
    display: block;
  }

  /* Floating mobile button visible after banner dismissed */
  body.mobile-banner-dismissed .mobile-fab {
    display: flex;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--gradient-primary);
    color: white;
    text-decoration: none;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(74, 158, 255, 0.4);
    transition: var(--transition);
  }

  body.mobile-banner-dismissed .mobile-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 158, 255, 0.5);
  }

  body.mobile-banner-dismissed .mobile-fab svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }
}

@media (max-width: 640px) {
  .page-title {
    font-size: 20px;
  }

  .top-bar {
    height: 56px;
  }

  .modal-content {
    margin: 10px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }
}

/* ===== Common Search Section ===== */
.search-section {
  background: var(--gradient-card);
  border-bottom: 1px solid var(--border-primary);
  padding: 24px 32px;
}

.search-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-bar {
  display: flex;
  gap: 12px;
}

.search-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 48px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

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

.search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--gradient-primary);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.search-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

/* ===== Common Filter Elements ===== */
.filters-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.filter-select,
.filter-input {
  min-width: 150px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.1);
}

.filter-input::placeholder {
  color: var(--text-dim);
}

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

.clear-filters-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-secondary);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  height: 36px;
}

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

.filter-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.filter-actions .btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  border-radius: 6px;
  justify-content: center;
}

/* ===== Common Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--gradient-card);
  border-top: 1px solid var(--border-primary);
}

.pagination-btn {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}

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

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-btn.active {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
}

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

.page-info span {
  color: var(--text-primary);
  font-weight: 500;
}

/* ===== Common Empty State ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
}

.empty-state svg {
  opacity: 0.3;
  margin-bottom: 16px;
}

.empty-state h3 {
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  line-height: 1.5;
  max-width: 250px;
}

/* ===== Common Export Buttons ===== */
.export-buttons {
  display: flex;
  gap: 12px;
}

.export-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

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

/* ===== Topbar Icon Button ===== */
.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--border-radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

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

/* ===== Common Results Counter ===== */
.results-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--border-radius);
}

.counter-number {
  font-size: 16px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-primary);
}

.counter-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== Common Top Stats (for map/dashboard) ===== */
.top-stats {
  display: flex;
  gap: 24px;
}

.top-stat {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-stat-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--cyber-primary);
  font-family: 'JetBrains Mono', monospace;
}

.top-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== Common Responsive - Search/Filters ===== */
@media (max-width: 768px) {
  .search-section {
    padding: 20px;
  }

  .search-bar {
    flex-direction: column;
  }

  .search-btn {
    width: 100%;
    justify-content: center;
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .filter-group {
    width: 100%;
  }

  .filter-select,
  .filter-input {
    width: 100%;
    min-width: auto;
  }

  .pagination {
    padding: 12px 16px;
  }

  .top-stats {
    display: none;
  }
}