/* =================================== */
/*  MODERN UI DESIGN SYSTEM           */
/*  Production-Ready Cybersecurity AI */
/* =================================== */

/* ============ CSS RESET ============ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ============ ICON FONT PROTECTION ============ */
/* Ensure icon fonts use swap display to prevent FOIT (invisible icons while loading) */
@font-face {
  font-family: "Font Awesome 6 Free";
  font-display: swap;
}
@font-face {
  font-family: "Font Awesome 6 Brands";
  font-display: swap;
}
@font-face {
  font-family: "Material Icons";
  font-display: swap;
}

/* ============ CSS VARIABLES ============ */
/* NOTE: Google Fonts loaded via <link> in base.html — no @import needed here */

:root {
  /* Spacing Scale (8px base) */
  --space-1: 0.25rem; /* 4px */
  --space-2: 0.5rem; /* 8px */
  --space-3: 0.75rem; /* 12px */
  --space-4: 1rem; /* 16px */
  --space-5: 1.5rem; /* 24px */
  --space-6: 2rem; /* 32px */
  --space-8: 3rem; /* 48px */
  --space-10: 4rem; /* 64px */

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows — Subtle depth for panels & modals */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.18);
  --shadow-sidebar: 4px 0 24px rgba(0,0,0,0.15);
  --gradient-cyber: linear-gradient(
    135deg,
    #71A3CD 0%,
    #3D5379 100%
  );

  /* Layout */
  --sidebar-width: 280px;
  --sidebar-rail-width: 60px;
  --header-height: 60px;
  --max-content-width: 1400px;

  /* Typography - Axiom Matrix Branding */
  --font-en: 'Plus Jakarta Sans', 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-ar: 'Cairo', 'Segoe UI', system-ui, sans-serif;
  --font-heading: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', "SF Mono", "Monaco", "Inconsolata",
    Consolas, monospace;

  /* Font Sizes */
  --text-xs: 0.75rem;   /* 12px */
  --text-sm: 0.875rem;  /* 14px */
  --text-base: 0.9375rem; /* 15px */
  --text-lg: 1.125rem;  /* 18px */
  --text-xl: 1.25rem;   /* 20px */
  --text-2xl: 1.5rem;   /* 24px */
  --text-3xl: 1.875rem; /* 30px */

  /* Transition — Manus-inspired easing */
  --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition: 0.25s var(--ease-out);
  --transition-fast: 0.15s var(--ease-out);
  --transition-slow: 0.4s var(--ease-smooth);
  --transition-panel: 0.3s var(--ease-out);
  --transition-modal: 0.28s var(--ease-out);

  /* Z-index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* ============ DARK THEME (Default) ============ */
.dark,
body {
  /* Backgrounds - Axiom Matrix Dark */
  --bg-primary: #262626;
  --bg-secondary: #1e1e1e;
  --bg-tertiary: #2f2f2f;
  --bg-elevated: #333333;
  --bg-hover: #3a3a3a;
  --bg-overlay: rgba(38, 38, 38, 0.9);

  /* Borders */
  --border-primary: rgba(113, 163, 205, 0.2);
  --border-secondary: rgba(113, 163, 205, 0.1);
  --border-hover: rgba(113, 163, 205, 0.35);

  /* Text - Axiom Matrix Dark */
  --text-primary: #ffffff;
  --text-secondary: #b0c4d8;
  --text-tertiary: #5f7a96;
  --text-inverted: #262626;

  /* Brand Colors - Axiom Matrix */
  --primary: #71A3CD;
  --primary-dark: #5889B3;
  --primary-light: #8FB7D9;
  --primary-bg: rgba(113, 163, 205, 0.1);
  --primary-50: rgba(113, 163, 205, 0.08);
  --primary-600: #71A3CD;

  /* Axiom Matrix Button Gradient (Dark) */
  --gradient-btn: linear-gradient(135deg, #71A3CD 0%, #D0DBE8 100%);
  --gradient-btn-hover: linear-gradient(135deg, #5889B3 0%, #b8c8db 100%);
  --btn-text: #262626;

  --secondary: #71A3CD;
  --secondary-dark: #5889B3;
  --secondary-light: #8FB7D9;
  --secondary-bg: rgba(113, 163, 205, 0.1);

  --danger: #ef4444;
  --danger-dark: #dc2626;
  --danger-light: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.1);

  --warning: #f59e0b;
  --warning-dark: #d97706;
  --warning-light: #fbbf24;
  --warning-bg: rgba(245, 158, 11, 0.1);

  --success: #10b981;
  --info: #3b82f6;

  /* Gradients - Axiom Matrix */
  --gradient-primary: linear-gradient(135deg, #71A3CD 0%, #D0DBE8 100%);
  --gradient-secondary: linear-gradient(135deg, #71A3CD 0%, #5889B3 100%);
  --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --gradient-dark: linear-gradient(135deg, #1e1e1e 0%, #262626 100%);

  /* Scrollbar */
  --scrollbar-track: transparent;
  --scrollbar-thumb: rgba(113, 163, 205, 0.25);
  --scrollbar-thumb-hover: rgba(113, 163, 205, 0.4);
}

/* ============ LIGHT THEME - Axiom Matrix ============ */
.light {
  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f7fa;
  --bg-tertiary: #edf1f7;
  --bg-elevated: #ffffff;
  --bg-hover: #e4e9f0;
  --bg-overlay: rgba(255, 255, 255, 0.95);

  /* Borders */
  --border-primary: rgba(61, 83, 121, 0.15);
  --border-secondary: rgba(61, 83, 121, 0.08);
  --border-hover: rgba(61, 83, 121, 0.25);

  /* Text - Axiom Matrix Light */
  --text-primary: #1a2640;
  --text-secondary: #4a5b75;
  --text-tertiary: #7a8da5;
  --text-inverted: #ffffff;

  /* Brand Colors - Axiom Matrix Light */
  --primary: #3D5379;
  --primary-dark: #2d3f5e;
  --primary-light: #5a7199;
  --primary-bg: rgba(61, 83, 121, 0.08);
  --primary-50: rgba(61, 83, 121, 0.06);
  --primary-600: #3D5379;

  /* Axiom Matrix Button Gradient (Light) */
  --gradient-btn: linear-gradient(135deg, #8595AE 0%, #143668 100%);
  --gradient-btn-hover: linear-gradient(135deg, #6d7f9a 0%, #1a4580 100%);
  --btn-text: #ffffff;

  --secondary: #3D5379;
  --secondary-dark: #2d3f5e;
  --secondary-light: #5a7199;
  --secondary-bg: rgba(61, 83, 121, 0.08);

  --danger: #e53e3e;
  --danger-dark: #c53030;
  --danger-light: #fc8181;
  --danger-bg: rgba(229, 62, 62, 0.08);

  --warning: #dd6b20;
  --warning-dark: #c05621;
  --warning-light: #f6ad55;
  --warning-bg: rgba(221, 107, 32, 0.08);

  /* Gradients - Axiom Matrix Light */
  --gradient-primary: linear-gradient(135deg, #8595AE 0%, #143668 100%);
  --gradient-secondary: linear-gradient(135deg, #3D5379 0%, #2d3f5e 100%);

  /* Scrollbar */
  --scrollbar-track: transparent;
  --scrollbar-thumb: rgba(61, 83, 121, 0.2);
  --scrollbar-thumb-hover: rgba(61, 83, 121, 0.35);

  /* Shadows for light theme */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.12);
}

/* ============ LIGHT THEME — NAVY SIDEBAR ============ */
.light .sidebar,
.light .sidebar-tiny-bar {
  background-color: #1a2a4a;
  border-right-color: rgba(255,255,255,0.06);
}

.light .sidebar-header a,
.light .sidebar .sidebar-close,
.light .sidebar-main-nav li a,
.light .sidebar .history-text,
.light .sidebar .session-text-content,
.light .sidebar .user-name,
.light .sidebar .user-section {
  color: #d0dbe8;
}

.light .sidebar-main-nav li a i,
.light .sidebar .session-icon {
  color: #7a8da5;
}

.light .sidebar-main-nav li a:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.08);
}
.light .sidebar-main-nav li a:hover i {
  color: #ffffff;
}

.light .sidebar-main-nav li a.active {
  color: #71A3CD;
  background: rgba(113,163,205,0.12);
}
.light .sidebar-main-nav li a.active i {
  color: #71A3CD;
}

.light .sidebar .search-input {
  background: rgba(255,255,255,0.1);
  color: #d0dbe8;
  border: none;
}
.light .sidebar .search-input::placeholder {
  color: #7a8da5;
}
.light .sidebar .search-icon {
  color: #7a8da5;
}

.light .sidebar .history-item {
  color: #8ea4be;
}
.light .sidebar .history-item:hover {
  background: rgba(255,255,255,0.06);
  color: #d0dbe8;
}
.light .sidebar .history-item.active {
  background: rgba(113,163,205,0.15);
  color: #71A3CD;
}

.light .sidebar .user-section {
  border-top-color: rgba(255,255,255,0.08);
}
.light .sidebar .user-avatar i {
  color: #7a8da5;
}
.light .sidebar .subscription-badge {
  opacity: 0.8;
}

.light .sidebar .chat-history h2 {
  color: #5f7a96 !important;
}

.light .sidebar p[data-i18n="no_previous_sessions"] {
  color: #5f7a96 !important;
}

.light .sidebar .sidebar-close:hover {
  background: rgba(255,255,255,0.08);
  color: #ffffff;
}

.light .sidebar-tiny-bar .tiny-bar-item,
.light .sidebar-tiny-bar .sidebar-toggle {
  color: #8ea4be;
}
.light .sidebar-tiny-bar .tiny-bar-item:hover,
.light .sidebar-tiny-bar .sidebar-toggle:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.08);
}
.light .sidebar-tiny-bar .tiny-bar-item.active {
  color: var(--primary);
  background: var(--primary-bg);
}

.light .sidebar .__menu-item {
  color: #d0dbe8;
}
.light .sidebar .__menu-item:hover {
  background: rgba(255,255,255,0.08);
  color: #ffffff;
}

/* ============ QUANTUM THEME COLORS ============ */
:root {
  /* Quantum Brand Colors */
  --quantum-primary: #71A3CD;
  --quantum-secondary: #3D5379;
  --quantum-gradient: linear-gradient(135deg, #71A3CD 0%, #3D5379 100%);

  /* Risk Level Colors */
  --risk-high: #ef4444;
  --risk-high-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --risk-medium: #f59e0b;
  --risk-medium-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --risk-low: #10b981;
  --risk-low-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* ============ BASE STYLES ============ */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  box-sizing: border-box;
}

/* Arabic font for RTL — applies Cairo to ALL elements */
html[dir="rtl"] body,
html[lang="ar"] body {
  font-family: var(--font-ar);
}

html[dir="rtl"] *,
html[lang="ar"] * {
  font-family: inherit;
}

/* Preserve icon font families — never inherit on icon elements */
.fas, .far, .fab, .fal, .fad,
.fa-solid, .fa-regular, .fa-brands, .fa-light, .fa-duotone,
.fa, [class*=" fa-"], [class^="fa-"] {
  font-family: "Font Awesome 6 Free" !important;
}
.fab, .fa-brands {
  font-family: "Font Awesome 6 Brands" !important;
}
.material-icons,
.material-icons-outlined,
.material-icons-round,
.material-icons-sharp,
.material-icons-two-tone {
  font-family: "Material Icons" !important;
}

html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3,
html[dir="rtl"] h4, html[dir="rtl"] h5, html[dir="rtl"] h6 {
  font-family: var(--font-ar);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: 0.5px;
}

/* ============ SCROLLBAR STYLES ============ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
  transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* ============ LAYOUT ============ */
/* .app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
} */

/* ============ SIDEBAR ============ */
/* Overlay for mobile — dark semi-transparent background */
/* #sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: calc(var(--z-dropdown) - 1);
  transition: opacity 0.25s ease;
} */

/* Hidden overlay (JS sets hidden=true) */
/* #sidebar-overlay[hidden] {
  opacity: 0;
  pointer-events: none;
} */

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-secondary);
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: transform var(--transition-panel), box-shadow var(--transition-panel);
  z-index: var(--z-dropdown);
  scrollbar-color: var(--scrollbar-color) transparent;
  will-change: transform;
}

/* === DESKTOP: sidebar is part of normal flow === */
@media (min-width: 769px) {
  html[dir="ltr"] .sidebar:not(.open) {
    transform: translateX(-100%);
    position: fixed;
    box-shadow: none;
  }

  html[dir="ltr"] .sidebar.open {
    transform: translateX(0);
    position: relative;
    z-index: auto;
    box-shadow: none;
  }

  .sidebar-backdrop {
    display: none !important;
  }
}

/* === MOBILE: sidebar is fixed overlay with backdrop === */
@media (max-width: 768px) {
  html[dir="ltr"] .sidebar:not(.open) {
    transform: translateX(-100%);
    position: fixed;
    box-shadow: none;
  }

  html[dir="ltr"] .sidebar.open {
    transform: translateX(0);
    position: fixed;
    z-index: 2100;
    box-shadow: var(--shadow-sidebar);
  }
}

/* Sidebar backdrop overlay (mobile only) */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-panel);
}

.sidebar-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-header {
  border-bottom: 1px solid var(--border-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px;
  flex-shrink: 0;
}

.sidebar-header a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 12px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: var(--text-lg);
  font-weight: 700;
  transition: opacity var(--transition-fast);
  flex: 1;
  margin: 0;
}

.sidebar-header a:hover {
  opacity: 0.85;
}

.logo img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-primary);
  object-fit: cover;
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  margin-left: 8px;
  transition: all var(--transition-fast);
}

.sidebar-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* New Chat Button */
.sidebar-new {
  padding: var(--space-1);
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-1);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
}

.new-chat-btn:hover {
  background: var(--bg-elevated);
}

.new-chat-btn:focus {
  border-color: var(--accent-color);
}

.new-chat-btn:active {
  transform: translateY(0);
}

/* Search Container */
.search-container {
  padding: 5px 0px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--btn-text);
  opacity: 0.8;
  z-index: 1;
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 40px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  color: var(--btn-text);
  font-size: 14px;
  transition: opacity var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.search-input::placeholder {
  color: var(--btn-text);
  opacity: 0.7;
}

.search-input:focus {
  opacity: 0.9;
}

.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}

.search-clear:hover {
  color: var(--text-primary);
}

/* Chat Sessions */
.chat-history {
  flex: 1;
  overflow-y: auto;
}

.history-scroll {
  padding: var(--space-2);
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 2px;
  transition: background var(--transition-fast), color var(--transition-fast), transform 0.1s ease;
  cursor: pointer;
  position: relative;
}

.history-item:hover {
  background-color: var(--bg-elevated);
}

.history-item:active {
  transform: scale(0.98);
}

.history-item.active {
  background-color: var(--bg-elevated);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 500;
}

.history-item-content {
  flex: 1;
  overflow: hidden;
}

.history-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-icon {
  font-size: 14px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.session-text-content {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-date {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.history-icon {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.history-item-delete {
  opacity: 0;
  padding: var(--space-1) var(--space-2);
  background: var(--danger-bg);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--danger);
  cursor: pointer;
  font-size: var(--text-xs);
  transition: all 0.2s ease;
}

.history-item:hover .history-item-delete {
  opacity: 1;
}

.history-item-delete:hover {
  background: var(--danger);
  color: white;
}

/* Three-dot menu button */
.history-item-menu-btn {
  opacity: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition-fast);
  position: relative;
}

.history-item:hover .history-item-menu-btn {
  opacity: 1;
}

.history-item-menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.history-item-menu-btn.active {
  opacity: 1;
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Dropdown menu */
.history-item-menu {
  display: none;
  position: fixed;
  z-index: 2100;
  min-width: 160px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  animation: popoverIn 0.15s var(--ease-out) forwards;
}

.history-item-menu.visible {
  display: block;
}

.history-menu-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: start;
}

.history-menu-option i {
  width: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

.history-menu-option:hover {
  background: var(--bg-hover);
}

.history-menu-option:hover i {
  color: var(--text-primary);
}

.history-menu-option.danger {
  color: var(--danger);
}

.history-menu-option.danger i {
  color: var(--danger);
}

.history-menu-option.danger:hover {
  background: var(--danger-bg);
}

/* User Section */
/* .user-section,
.sidebar-footer {
    padding: var(--space-3);
    border-top: 1px solid var(--border-primary);
    flex-shrink: 0;
} */

/* Main container for the user section at the bottom of the sidebar */
.user-section {
  margin-top: auto; /* Pushes the user section to the bottom */
  /* padding: var(--space-3); */
  border-top: 1px solid var(--border-primary);
  position: relative;
}

/* .user-menu {
    align-items: center;
    border-radius: 10px;
    display: flex;
    font-size: var(--text-sm);
    line-height: var(--tw-leading, var(--text-sm--line-height));
    min-height: var(--menu-item-height);
    padding-block: calc(var(--space-1) * 1.5);
    padding-inline: calc(var(--space-1) * 2.5);
    position: relative;
    scroll-margin: calc(var(--space-1) * 1.5);
    -webkit-user-select: none;
    user-select: none;
    width: auto;
    gap: calc(var(--space-1) * 2);
} */

/* The primary user display area (avatar, name, status) */
.user-menu {
  display: flex;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  gap: calc(var(--space-1) * 2);
}

.user-menu:hover {
  background-color: var(--bg-hover); /* Subtle hover effect */
}

/* .user-menu {
    position: relative;
} */

.user-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.user-btn:hover {
  background-color: var(--bg-elevated);
}

/* .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 700;
    color: white;
    flex-shrink: 0;
} */

/* Styling for the user's avatar */
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-btn);
  color: var(--btn-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
  margin-right: 12px;
  flex-shrink: 0;
}

/* .user-info {
    flex: 1;
    text-align: left;
    overflow: hidden;
} */

/* Container for user name and status */
.user-info {
  flex-grow: 1;
  overflow: hidden; /* Prevents long names from breaking layout */
}

/* .user-name {
    font-weight: 600;
    font-size: var(--text-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
} */

.user-name {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* .user-status {
    font-size: var(--text-xs);
    color: var(--text-secondary);
} */

.user-status {
  font-size: 13px;
  color: var(--text-secondary);
}

.logout-btn {
  padding: var(--space-2) var(--space-4);
  background: var(--danger);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: var(--danger-dark);
  transform: translateY(-1px);
}

/* The popup menu that appears on hover */
.user-menu-items {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 10px;
  right: 10px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 10px;
  padding: 8px;
  z-index: 1100;
  box-shadow: var(--shadow-lg);

  visibility: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out), visibility 0.2s;
}

/* Show the menu when hovering over the user-section */
.user-section:hover .user-menu-items {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Styling for individual items within the popup menu */
.__menu-item.hoverable {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.__menu-item.hoverable:hover {
  background-color: var(--bg-hover);
}

.__menu-item.hoverable i {
  width: 20px; /* Fixed width for icon alignment */
  text-align: center;
  color: var(--text-secondary);
}

/* Specific styling for the logout button to ensure it behaves like a menu item */
.user-menu-items form {
  margin: 0;
}

.user-menu-items button.__menu-item.hoverable {
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  font-family: inherit; /* Inherit font from the parent */
  font-size: 14px;
}

/* Sidebar Toggle & Tiny Bar */
.sidebar-tiny-bar {
  width: var(--sidebar-rail-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-primary);
  height: 100vh;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: var(--space-4) 0;
  z-index: calc(var(--z-fixed) - 1);

  /* position: fixed; */
  /* top: 0; */
  /* left: 0; */
}

.tiny-bar-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.tiny-bar-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tiny-bar-item,
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tiny-bar-item:hover,
.sidebar-toggle:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  transform: scale(1.05);
}

.tiny-bar-item.active {
  color: var(--primary);
  background: var(--primary-bg);
}

/* Divider between groups in tiny bar */
.tiny-bar-divider {
  width: 28px;
  height: 1px;
  background: var(--border-primary);
  margin: 4px 0;
}

/* Tooltip on hover */
.tiny-bar-item[title],
.sidebar-toggle[title] {
  position: relative;
}

.tiny-bar-item[title]:hover::after,
.sidebar-toggle[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  border: 1px solid var(--border-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ============ MAIN CHAT AREA ============ */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-primary);
  transition: margin var(--transition-panel), width var(--transition-panel);
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Desktop: chat-container adjusts alongside sidebar */
@media (min-width: 769px) {
  html[dir="ltr"] .sidebar.open ~ .chat-container {
    margin-left: 0;
    margin-right: 0;
    width: auto;
    flex: 1;
  }

  html[dir="ltr"] .sidebar:not(.open) ~ .chat-container {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
  }
}

/* Mobile: full width always, sidebar overlays */
@media (max-width: 768px) {
  html[dir="ltr"] .sidebar.open ~ .chat-container,
  html[dir="ltr"] .sidebar:not(.open) ~ .chat-container {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
  }
}

/* Headers */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: none;
  background: var(--bg-secondary);
  height: var(--header-height);
  flex-shrink: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  background: var(--bg-primary);
  height: var(--header-height);
  border-bottom: 1px solid var(--border-secondary);
  flex-shrink: 0;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chat-title h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0;
  font-family: var(--font-en);
  letter-spacing: 0.5px;
}

.chat-main-title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0;
  font-family: var(--font-ar);
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 160px;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.status-badge {
  padding: var(--space-2) var(--space-3);
  background: var(--secondary);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-badge i {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ============ QUANTUM BADGE STYLES ============ */
.quantum-badge {
  padding: var(--space-2) var(--space-3);
  background: var(--gradient-btn);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--btn-text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Outlined badge for header */
.quantum-badge-outlined {
  padding: 8px 24px;
  background: transparent;
  border: 1px solid var(--text-tertiary);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  letter-spacing: 0.3px;
}

.quantum-badge i {
  font-size: 14px;
}

/* Quantum Processing Status */
.quantum-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--primary-bg);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  color: var(--primary);
  font-size: var(--text-sm);
  font-weight: 500;
}

.quantum-status.running i {
  animation: rotate 2s linear infinite;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Risk Level Badges */
.quantum-risk-high {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--risk-high-gradient);
  color: white;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}

.quantum-risk-medium {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--risk-medium-gradient);
  color: white;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}

.quantum-risk-low {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--risk-low-gradient);
  color: white;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}

.header-right,
.chat-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-btn,
.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: none;
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.header-btn:hover,
.action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

/* ============ TAB NAVIGATION ============ */
.tab-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.tab {
  padding: 17px var(--space-1);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all var(--transition-fast);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--text-base);
  position: relative;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
}

/* ============ CHAT MESSAGES ============ */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.chat-messages,
#chat-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-5);
  scroll-behavior: smooth;
  scrollbar-color: var(--scrollbar-color) transparent;
  min-width: 0;
  contain: content;
  max-width: 50rem;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  box-sizing: border-box;
}

.message {
  display: flex;
  gap: var(--space-4);
  animation: messageSlideIn 0.35s var(--ease-out) both;
  width: 100%;
}

/* Message action buttons - hidden by default, shown on hover (desktop) */
.message-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.message:hover .message-actions {
  opacity: 1;
}

/* Button style */
.copy-btn,
.share-btn,
.like-btn,
.dislike-btn,
.edit-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 1rem;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.copy-btn:hover,
.share-btn:hover,
.like-btn:hover,
.dislike-btn:hover,
.edit-btn:hover {
  color: var(--primary);
  background: var(--primary-bg);
}

/* Feedback active state */
.like-btn.active {
  color: var(--success);
}
.dislike-btn.active {
  color: var(--danger);
}

/* Mobile: always visible */
@media (max-width: 768px) {
  .message-actions {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message.user,
.user-message {
  justify-content: flex-end;
}

.message.bot,
.bot-message {
  justify-content: flex-start;
}

.message-content {
  flex: 0 1 auto;
  max-width: 100%;
  width: 100%;
  min-width: 0;
}

.message-text {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  min-width: 0;
  /* border: 1px solid var(--border-primary); */
  line-height: 1.7;
  word-wrap: break-word;
  font-size: var(--text-base);
}

.message.user .message-content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message.user .message-text {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 80%, #6366f1));
  color: #ffffff !important;
  border: none;
  border-radius: 18px 18px 4px 18px;
  padding: 12px 18px;
  box-shadow: 0 2px 8px rgba(113, 163, 205, 0.2);
  line-height: 1.6;
  font-size: 14px;
  position: relative;
}

/* User message text links should be white */
.message.user .message-text a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: underline;
}

/* User message time */
.message.user .message-time {
  text-align: right;
}

.user-message .message-text {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 80%, #6366f1));
  color: #ffffff !important;
  border: none;
  border-radius: 18px 18px 4px 18px;
  padding: 12px 18px;
  box-shadow: 0 2px 8px rgba(113, 163, 205, 0.2);
  line-height: 1.6;
}

/* Bot message styling */
.message.bot .message-content,
.bot-message .message-content {
  flex: 1 1 auto;
  border-bottom-left-radius: var(--radius-sm);
}

.bot-message .message-text {
  border-bottom-left-radius: var(--radius-sm);
}

.message.bot .message-text {
  border-radius: 18px 18px 18px 4px;
}

/* ── Stream attempt pending (gray text while LLM attempt is tentative) ── */
.message.stream-attempt-pending .message-text,
.message.stream-attempt-pending .message-text * {
  color: var(--text-tertiary, #9ca3af) !important;
  transition: color 0.3s ease;
}

.message-time {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-2);
  opacity: 0.8;
}

/* ============ MARKDOWN STYLING ============ */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
  margin: var(--space-4) 0 var(--space-2) 0;
  font-weight: 700;
  line-height: 1.3;
}

.message-text h1 {
  font-size: var(--text-2xl);
}
.message-text h2 {
  font-size: var(--text-xl);
}
.message-text h3 {
  font-size: var(--text-lg);
}
.message-text h4 {
  font-size: var(--text-base);
}
.message-text h5 {
  font-size: var(--text-sm);
}
.message-text h6 {
  font-size: var(--text-xs);
}

.message-text p {
  margin: var(--space-2) 0;
}

.message-text code {
  background: rgba(0, 0, 0, 0.3);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.message-text pre {
  background: rgba(0, 0, 0, 0.4);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: var(--space-4) 0;
}

.message-text pre code {
  background: none;
  padding: 0;
}

.message-text ul,
.message-text ol {
  margin: var(--space-3) 0;
  padding-left: var(--space-6);
}

.message-text li {
  margin: var(--space-1) 0;
}

.message-text blockquote {
  border-left: 3px solid var(--primary);
  padding-left: var(--space-4);
  margin: var(--space-4) 0;
  font-style: italic;
  opacity: 0.9;
}

.message-text a {
  color: var(--primary-light);
  text-decoration: underline;
  transition: color 0.2s ease;
}

.message-text a:hover {
  color: var(--primary);
}

.message-text .table-responsive-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin: var(--space-4) 0;
}

.message-text table {
  border-collapse: collapse;
  width: 100%;
  margin: var(--space-4) 0;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 100%;
  table-layout: auto;
}

.message-text th,
.message-text td {
  border: 1px solid var(--border-primary);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  max-width: 300px;
  min-width: 80px;
}

.message-text th {
  background: var(--primary-bg);
  font-weight: 700;
  border-bottom: 2px solid var(--primary);
  white-space: nowrap;
}

.message-text tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.message-text tbody tr:hover {
  background: var(--primary-bg);
}

/* Table wrapper for better overflow handling */
.message-text .table-wrapper {
  overflow-x: auto;
  margin: var(--space-4) 0;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
}

.message-text .table-wrapper table {
  margin: 0;
  border: none;
}

/* ============ TYPING & TOOL STATUS INDICATORS ============ */
/* NOTE: .tool-status is deprecated - use embedded terminal instead */
.tool-status {
  display: none !important;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: 18px 18px 18px 4px;
  width: fit-content;
  animation: typingSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

@keyframes typingSlideIn {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.typing-indicator-dots,
.tool-status-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-indicator-dot,
.tool-status-dot {
  width: 7px;
  height: 7px;
  background: var(--primary);
  border-radius: 50%;
  animation: typingDot 1.4s ease-in-out infinite;
}

.typing-indicator-dot:nth-child(2),
.tool-status-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator-dot:nth-child(3),
.tool-status-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0) scale(0.8);
    opacity: 0.35;
  }
  30% {
    transform: translateY(-6px) scale(1.1);
    opacity: 1;
  }
}

.typing-indicator-text,
.tool-status-text {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.tool-status-name {
  font-weight: 600;
  color: var(--text-primary);
}

/* Quantum Tool Status Specific Styling */
.tool-status.quantum-status {
  background: var(--primary-bg);
  border-color: var(--primary);
}

.tool-status.quantum-status .tool-status-dot {
  background: var(--gradient-btn);
}

.tool-status.quantum-status .tool-status-text {
  color: var(--quantum-primary);
}

.tool-status.quantum-status .tool-status-text i {
  margin-right: var(--space-2);
  animation: quantum-glow 2s ease-in-out infinite;
}

@keyframes quantum-glow {
  0%,
  100% {
    opacity: 1;
    filter: drop-shadow(0 0 2px var(--quantum-primary));
  }
  50% {
    opacity: 0.7;
    filter: drop-shadow(0 0 6px var(--quantum-primary));
  }
}

/* ============ CHAT INPUT ============ */
.chat-input-container {
  background: linear-gradient(to top, var(--bg-primary) 60%, transparent);
  padding: var(--space-3) var(--space-5) var(--space-2);
  padding-bottom: max(var(--space-2), env(safe-area-inset-bottom, 0px));
  z-index: var(--z-sticky);
  flex-shrink: 0;
  width: 100%;
  max-width: 50rem;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

/* ── Chat Mode Toggle (Ask / Agent) ── */
.chat-mode-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 2px;
}

.chat-mode-toggle .mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: none;
  color: var(--text-tertiary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
  line-height: 1.4;
}

.chat-mode-toggle .mode-btn i {
  font-size: 12px;
}

.chat-mode-toggle .mode-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.chat-mode-toggle .mode-btn.active {
  color: var(--primary);
  background: var(--primary-50, rgba(99, 102, 241, 0.08));
  border-color: var(--primary-200, rgba(99, 102, 241, 0.25));
}

.chat-mode-toggle .mode-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .chat-mode-toggle { padding: 4px 8px 2px; }
  .chat-mode-toggle .mode-btn { padding: 3px 10px; font-size: 11.5px; }
}

.chat-form,
#chat-form {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 0;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  max-width: 100%;
  width: 100%;
  margin: var(--space-2) 0;
  overflow: hidden;
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  width: 100%;
}

.chat-form:focus-within,
#chat-form:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}

.input-actions {
  display: flex;
  gap: var(--space-1);
}

.attachment-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.attachment-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.text-input-container {
  flex: 1;
  display: flex;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: 1.6;
  resize: none;
  outline: none;
  max-height: 200px;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
}

#chat-input::placeholder {
  color: var(--text-tertiary);
}

.send-btn,
#send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--primary);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  order: -1;
}

.send-btn:hover:not(:disabled),
#send-btn:hover:not(:disabled) {
  color: var(--primary-dark);
  background: var(--bg-hover);
}

.send-btn:disabled,
#send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.stop-generating-btn,
#stop-generating-btn {
  padding: var(--space-3) var(--space-5);
  background: var(--danger);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-weight: 600;
  font-size: var(--text-base);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.stop-generating-btn:hover,
#stop-generating-btn:hover {
  background: var(--danger-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ============ FILE UPLOAD / ATTACHMENTS ============ */

/* Attachment preview area (above input, ChatGPT-style) */
.attachment-preview-area {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px 6px;
  max-height: 200px;
  overflow-y: auto;
  width: 100%;
  box-sizing: border-box;
  animation: previewSlideIn 0.2s ease;
}

@keyframes previewSlideIn {
  from { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; }
  to   { opacity: 1; max-height: 200px; padding-top: 10px; padding-bottom: 6px; }
}

.attachment-preview-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 10px;
  max-width: 220px;
  min-width: 100px;
  transition: all 0.2s ease;
  cursor: default;
}

.attachment-preview-item:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-50);
}

.attachment-preview-item.uploading {
  opacity: 0.7;
}

.attachment-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.attachment-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--primary);
  font-size: 16px;
  flex-shrink: 0;
}

.attachment-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.attachment-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.attachment-size {
  font-size: 10px;
  color: var(--text-tertiary);
  line-height: 1.3;
}

.attachment-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-secondary);
  color: var(--bg-primary);
  border: 2px solid var(--bg-secondary);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  padding: 0;
}

.attachment-remove:hover {
  background: var(--danger);
  color: white;
}

.attachment-preview-item:hover .attachment-remove {
  opacity: 1;
}

.attachment-uploading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
}

.upload-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--primary-50);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Drag & drop highlight */
#chat-form.drag-over {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--primary-50), inset 0 0 20px rgba(var(--primary-rgb, 99, 102, 241), 0.08) !important;
  background: var(--bg-hover) !important;
}

/* Message attachment badges (shown in sent messages) */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.message-attachment-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  cursor: pointer;
  text-decoration: none;
}

.message-attachment-badge:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-hover);
}

.message-attachment-badge:hover .message-attachment-open-icon {
  opacity: 1;
}

.message-attachment-open-icon {
  font-size: 10px;
  opacity: 0.4;
  transition: opacity 0.15s ease;
  margin-left: 2px;
}

.message-attachment-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.message-attachment-thumb:hover {
  transform: scale(1.1);
  z-index: 10;
  position: relative;
}

.message-attachment-icon {
  font-size: 16px;
  color: var(--primary);
}

.message-attachment-name {
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ COUNTRY SCAN TAB ============ */
#country-scan-content {
  padding: var(--space-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Scan Mode Toggle Styles */
#scan-mode-toggle {
  display: flex;
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 5px;
  gap: 5px;
}

.scan-mode-btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
  background: transparent;
  color: var(--text-secondary);
}

.scan-mode-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.scan-mode-btn.active {
  background: var(--primary);
  color: white;
}

.scan-mode-btn i {
  font-size: 14px;
}

/* Custom IP Mode Styles */
#custom-ip-mode textarea:focus,
#country-db-mode select:focus {
  border-color: var(--primary);
  outline: none;
}

/* IP Count Badge */
#ip-count-badge {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Database Results Summary */
#db-results-summary {
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.scan-header {
  text-align: center;
  margin-bottom: var(--space-4);
}

.scan-header h2 {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}

.scan-header h2 i {
  color: var(--primary);
}

.scan-description {
  font-size: var(--text-base);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

#country-scan-content h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--border-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

#country-scan-content h3 i {
  color: var(--primary);
}

.scan-status-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
}

.scan-status-card:hover {
  box-shadow: var(--shadow-lg);
}

.status-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.status-icon {
  font-size: var(--text-2xl);
  flex-shrink: 0;
}

.status-content {
  flex: 1;
}

.status-text {
  font-size: var(--text-base);
  margin: 0;
  color: var(--text-primary);
}

.status-text strong {
  color: var(--primary);
}

#scan-controls {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  flex-wrap: wrap;
}

#country-selector {
  flex: 1;
  min-width: 200px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s ease;
}

#country-selector:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

#country-selector:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#start-scan-btn,
#stop-scan-btn {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-base);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

#start-scan-btn {
  background: var(--gradient-secondary);
  color: white;
}

#start-scan-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

#stop-scan-btn {
  background: var(--danger);
  color: white;
}

#stop-scan-btn:hover {
  background: var(--danger-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Scan Status & Progress */
#scan-status-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

#scan-status-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

#scan-progress-bar {
  width: 100%;
  height: 12px;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--bg-elevated);
}

#scan-progress-bar::-webkit-progress-bar {
  background: var(--bg-elevated);
}

#scan-progress-bar::-webkit-progress-value {
  background: var(--gradient-primary);
  transition: width 0.3s ease;
}

#scan-progress-bar::-moz-progress-bar {
  background: var(--gradient-primary);
}

/* Scan Results */
#scan-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.results-container {
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

#ranges-list-container {
  max-height: 300px;
  overflow-y: auto;
  padding: var(--space-4);
}

#ranges-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

#ranges-list li {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-secondary);
  color: var(--text-secondary);
}

#ranges-list li:last-child {
  border-bottom: none;
}

#hosts-table-container,
#ranges-table-container {
  max-height: 500px;
  overflow-y: auto;
}

#hosts-table,
#ranges-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

#hosts-table th,
#hosts-table td,
#ranges-table th,
#ranges-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border-primary);
  font-size: var(--text-sm);
}

#hosts-table th,
#ranges-table th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

#hosts-table td,
#ranges-table td {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#hosts-table td:first-child,
#ranges-table td:first-child {
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-mono);
}

#hosts-table tbody tr:hover,
#ranges-table tbody tr:hover {
  background: var(--bg-hover);
}

.host-active {
  background: var(--secondary-bg);
}

.host-active td:first-child {
  color: var(--secondary);
  font-weight: 700;
}

.host-inactive {
  opacity: 0.6;
}

.status-active {
  color: var(--secondary);
  font-weight: 600;
}

.status-inactive {
  color: var(--text-tertiary);
}

.status-pending {
  color: var(--warning);
  font-weight: 600;
}

.status-completed {
  color: var(--secondary);
  font-weight: 600;
}

.status-error {
  color: var(--danger);
  font-weight: 600;
}

/* ============ FORMS & INPUTS ============ */
.form-label {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  font-size: var(--text-base);
  display: block;
}

.form-control {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-control::placeholder {
  color: var(--text-tertiary);
}

/* Language Switcher */
.language-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-full);
  padding: 0 12px;
  gap: 6px;
  background: transparent;
  width: auto !important;
}

.language-switcher .lang-icon {
  color: var(--text-secondary);
  font-size: 14px;
  pointer-events: none;
}

.language-switcher select {
  height: 100%;
  padding: 0 4px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.language-switcher select:focus {
  outline: none;
}

.language-switcher::after {
  display: none;
}

/* ============ BUTTONS ============ */
.btn {
  border-radius: var(--radius-md);
  font-weight: 600;
  padding: var(--space-3) var(--space-5);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-base);
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-lg);
}

.btn-primary {
  background: var(--gradient-btn);
  color: var(--btn-text);
}

.btn-primary:hover {
  background: var(--gradient-btn-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn-outline-secondary {
  background: transparent;
  border: 2px solid var(--border-primary);
  color: var(--text-secondary);
}

.btn-outline-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--gradient-danger);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ============ CARDS ============ */
.card {
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
}

.card-header {
  /* background: var(--gradient-primary); */
  padding: var(--space-5) var(--space-6);
  border-bottom: none;
}

.card-header h4 {
  font-weight: 700;
  font-size: var(--text-2xl);
  margin: 0;
  color: white;
}

.card-body {
  padding: var(--space-6);
}

/* ============ ALERTS ============ */
.alert {
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.alert i {
  font-size: var(--text-lg);
}

.alert-info {
  background: var(--primary-bg);
  color: var(--primary);
  border-left: 4px solid var(--primary);
}

.alert-success {
  background: var(--secondary-bg);
  color: var(--secondary);
  border-left: 4px solid var(--secondary);
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-left: 4px solid var(--danger);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-left: 4px solid var(--warning);
}

/* ============ WELCOME MESSAGE ============ */
.welcome-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  text-align: center;
}

.welcome-message {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

.welcome-message .logo img {
  width: 220px;
  height: 220px;
  border-radius: 0;
  border: none;
  object-fit: contain;
  transition: all 0.3s ease;
}

/* Theme-aware welcome logos */
.dark .welcome-logo-dark { display: inline-block !important; }
.dark .welcome-logo-light { display: none !important; }
.light .welcome-logo-dark { display: none !important; }
.light .welcome-logo-light { display: inline-block !important; }

/* Axiom Matrix welcome badge */
.axiom-matrix-welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--gradient-btn);
  color: var(--btn-text);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 15px;
  letter-spacing: 0.3px;
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: var(--space-5);
}

.welcome-message h1 {
  font-size: 36px;
  margin-bottom: var(--space-3);
  font-weight: 700;
  font-family: var(--font-en);
}

.welcome-subtitle {
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 500;
  margin-bottom: var(--space-4);
}

.welcome-hint {
  color: var(--text-tertiary);
  font-size: 15px;
  line-height: 1.8;
}

.welcome-message p {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
}

.suggestion-btn {
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  font-size: var(--text-base);
  transition: all 0.2s ease;
}

.suggestion-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
}

/* ============ UTILITY CLASSES ============ */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-tertiary);
}

.d-grid {
  display: grid;
}

.gap-2 {
  gap: var(--space-2);
}

/* ============ RESPONSIVE DESIGN ============ */
@media (min-width: 1025px) {
  /* .sidebar-tiny-bar {
        display: flex;
    }

    .sidebar.open ~ .chat-container,
    .sidebar.open ~ .chat-main {
        margin-left: var(--sidebar-width);
    } */
}

/* ===== Terminal Panel + Chat responsive adjustments ===== */

/* When terminal panel is open, ensure everything fits the reduced width */
body.terminal-panel-open .message,
body.terminal-panel-open .chat-form,
body.terminal-panel-open #chat-form,
body.terminal-panel-open .chat-reasoning-card {
  max-width: 100%;
  box-sizing: border-box;
  align-self: stretch;
}

body.terminal-panel-open .message-content {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

body.terminal-panel-open .message-text {
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
}

body.terminal-panel-open .chat-input-container {
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

/* Smaller desktops: reduce message max-width when panel is open */
@media (min-width: 1025px) and (max-width: 1400px) {
  body.terminal-panel-open .message,
  body.terminal-panel-open .chat-reasoning-card {
    max-width: 100%;
  }

  body.terminal-panel-open .chat-form,
  body.terminal-panel-open #chat-form {
    max-width: 100%;
  }

  body.terminal-panel-open .terminal-mini-bar {
    max-width: 100%;
  }

  body.terminal-panel-open .embedded-terminal:not(.et-maximized):not(.et-fullscreen) {
    margin: 12px 0;
    max-width: 100%;
  }
}

/* Tablet landscape: terminal overlays, ensure chat isn't pushed off-screen */
@media (min-width: 769px) and (max-width: 1024px) {
  body.terminal-panel-open .chat-container {
    margin-right: 0 !important;
  }

  body.terminal-panel-open .message,
  body.terminal-panel-open .chat-reasoning-card {
    max-width: 100%;
  }
}
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    width: 280px;
  }

  .sidebar-tiny-bar {
    display: none !important;
  }

  .chat-container,
  .chat-main {
    margin-left: 0;
  }

  .sidebar:not(.open) {
    transform: translateX(-100%);
    position: fixed;
  }

  .sidebar.open {
    transform: translateX(0);
    position: fixed;
    z-index: var(--z-modal);
    box-shadow: var(--shadow-sidebar);
  }

  /* Ensure chat fills the screen on tablet */
  .chat-container {
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .message {
    max-width: 100%;
  }
}

/* ===== MEDIUM-LARGE DESKTOP (1401px - 1919px) ===== */
@media (min-width: 1401px) and (max-width: 1919px) {
  .chat-messages,
  #chat-messages {
    max-width: 52rem;
  }

  .message {
    max-width: 100%;
  }

  .embedded-terminal:not(.et-maximized):not(.et-fullscreen) {
    max-width: 52rem;
  }

  .chat-reasoning-card {
    max-width: 52rem;
  }

  .chat-input-container {
    max-width: 52rem;
  }

  #chat-form,
  .chat-form {
    max-width: 100%;
  }
}

/* ===== LARGE SCREEN CONTAINMENT (1920px+) ===== */
@media (min-width: 1920px) {
  .chat-messages,
  #chat-messages {
    max-width: 54rem;
  }

  .message {
    max-width: 100%;
  }

  .message-content {
    max-width: 100%;
  }

  .chat-input-container {
    max-width: 54rem;
  }

  #chat-form,
  .chat-form {
    max-width: 100%;
  }

  .embedded-terminal:not(.et-maximized):not(.et-fullscreen) {
    max-width: 54rem;
  }

  .chat-reasoning-card {
    max-width: 54rem;
  }
}

/* ===== ULTRA-WIDE SCREENS (2560px+) ===== */
@media (min-width: 2560px) {
  .chat-messages,
  #chat-messages {
    max-width: 60rem;
  }

  .message {
    max-width: 100%;
  }

  .chat-input-container {
    max-width: 60rem;
  }

  #chat-form,
  .chat-form {
    max-width: 100%;
  }

  .embedded-terminal:not(.et-maximized):not(.et-fullscreen) {
    max-width: 60rem;
  }

  .chat-reasoning-card {
    max-width: 60rem;
  }
}

/* ===== 4K SCREENS (3840px+) ===== */
@media (min-width: 3840px) {
  .chat-messages,
  #chat-messages {
    max-width: 68rem;
  }

  .message {
    max-width: 100%;
  }

  .chat-input-container {
    max-width: 68rem;
  }

  #chat-form,
  .chat-form {
    max-width: 100%;
  }

  .embedded-terminal:not(.et-maximized):not(.et-fullscreen) {
    max-width: 68rem;
  }

  .chat-reasoning-card {
    max-width: 68rem;
  }
}

/* Base styles for scan controls bar (extracted from inline styles) */
.scan-controls-bar {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 768px) {
  .sidebar,
  #main-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: var(--z-modal);
    box-shadow: none;
    transition: transform var(--transition-panel), box-shadow var(--transition-panel);
  }

  .sidebar.open,
  #main-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-sidebar);
  }

  .sidebar-tiny-bar {
    display: none !important;
  }

  .mobile-header {
    display: flex;
  }

  .chat-header {
    display: none;
  }

  .chat-form,
  #chat-form {
    margin-bottom: 0;
  }

  .message {
    gap: var(--space-3);
    margin-bottom: var(--space-4);
  }

  .message-content {
    max-width: 88%;
  }

  .chat-input-container {
    padding: var(--space-3) var(--space-3);
    padding-bottom: max(var(--space-3), env(safe-area-inset-bottom, 0px));
    left: 0 !important;
    margin-bottom: 0;
  }

  .chat-form,
  #chat-form {
    margin-left: var(--space-1);
    margin-right: var(--space-1);
  }

  .chat-container {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .chat-messages,
  #chat-messages {
    padding: var(--space-3) var(--space-4);
    min-height: 0;
  }

  .welcome-wrapper {
    padding: var(--space-2) var(--space-3);
    min-height: 0;
    flex: 1 1 0;
  }

  .welcome-message {
    padding: var(--space-3) var(--space-3);
  }

  .welcome-message .logo img {
    width: 110px;
    height: 110px;
  }

  .welcome-message h1 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-1);
  }

  .welcome-subtitle {
    font-size: 14px;
    margin-bottom: var(--space-1);
  }

  .welcome-hint {
    font-size: 12px;
    line-height: 1.5;
  }

  .welcome-message p {
    margin-bottom: var(--space-2);
  }

  .suggestions {
    flex-direction: column;
    align-items: stretch;
  }

  .suggestion-btn {
    width: 100%;
  }

  .tab-container {
    padding: 0 var(--space-4);
  }

  .tab {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
  }

  #country-scan-content {
    padding: var(--space-4);
  }

  #scan-controls {
    flex-direction: column;
    align-items: stretch;
  }

  #country-selector,
  #start-scan-btn,
  #stop-scan-btn {
    width: 100%;
  }

  /* Mobile: Fix message text overflow */
  .message-text {
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .message-text pre {
    max-width: calc(100% - 16px);
    overflow-x: auto;
    font-size: 12px;
  }

  .message-text table {
    font-size: 12px;
    min-width: 0;
  }

  .message-text th,
  .message-text td {
    padding: var(--space-2) var(--space-3);
    max-width: 150px;
    font-size: 12px;
  }

  /* Mobile: Country scan controls fix */
  .country-scan-controls {
    padding: 12px !important;
  }

  #scan-mode-toggle {
    flex-direction: column;
    width: 100%;
  }

  .scan-mode-btn {
    width: 100%;
    justify-content: center;
  }

  /* Mobile: Fix filter controls overflow */
  .filter-controls {
    flex-direction: column;
    gap: 8px;
  }

  .filter-controls .search-input {
    width: 100%;
    max-width: none;
  }
}

/* ============ PHABLET / LARGE MOBILE (601px-768px) ============ */
@media (min-width: 601px) and (max-width: 768px) {
  .message-content {
    max-width: 84%;
  }

  .chat-form,
  #chat-form {
    max-width: 100%;
    margin-left: var(--space-3);
    margin-right: var(--space-3);
  }

  #chat-input {
    font-size: 15px;
    min-height: 42px;
  }
}

/* ============ TABLET NARROW (769px-900px) ============ */
@media (min-width: 769px) and (max-width: 900px) {
  .message-content {
    max-width: 88%;
  }

  .chat-form,
  #chat-form {
    max-width: 100%;
    margin-left: var(--space-4);
    margin-right: var(--space-4);
  }
}

/* ============ COMPACT MOBILE (≤600px) ============ */
@media (max-width: 600px) {
  .welcome-message .logo img {
    width: 90px;
    height: 90px;
  }

  .welcome-message h1 {
    font-size: 18px;
    margin-bottom: var(--space-1);
  }

  .welcome-subtitle {
    font-size: 13px;
  }

  .welcome-hint {
    font-size: 11.5px;
  }

  .message-content {
    max-width: 90%;
  }

  .message {
    margin-bottom: var(--space-2);
  }

  .chat-input-container {
    padding: var(--space-2) var(--space-3);
    padding-bottom: max(var(--space-3), env(safe-area-inset-bottom, 0px));
  }

  /* Tables: tighter on compact mobile */
  .message-text th,
  .message-text td {
    padding: var(--space-2) var(--space-2);
    max-width: 120px;
    font-size: 12px;
  }

  /* Terminal entries: constrain commands */
  .terminal-entry-cmd-inline {
    max-width: calc(100% - 100px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ============ SMALL MOBILE (≤480px) ============ */
@media (max-width: 480px) {
  .message-content {
    max-width: 92%;
  }

  .message-text {
    padding: var(--space-3) var(--space-4);
    font-size: 13.5px;
  }

  .message.user .message-text {
    padding: 10px 16px;
    font-size: 13.5px;
  }

  .message {
    margin-bottom: var(--space-3);
  }

  .chat-form,
  #chat-form {
    padding: var(--space-2);
    margin-bottom: 0;
    margin-left: 0;
    margin-right: 0;
  }

  #chat-input {
    font-size: 14px;
    padding: var(--space-2) var(--space-2);
    min-height: 40px;
  }

  /* Reduce button sizes to give textarea more room */
  .send-btn,
  #send-btn {
    width: 36px;
    height: 36px;
    font-size: 15px;
  }

  .attachment-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .chat-input-row {
    gap: var(--space-2);
    padding: var(--space-2) var(--space-2);
  }

  /* Stop button compact */
  .stop-generating-btn,
  #stop-generating-btn {
    padding: var(--space-2) var(--space-3);
    font-size: 13px;
  }
  #stop-generating-btn span {
    display: none;
  }

  .welcome-wrapper {
    padding: var(--space-1) var(--space-2);
    min-height: 0;
    flex: 1 1 0;
  }

  .welcome-message {
    padding: var(--space-2) var(--space-2);
  }

  .welcome-message .logo img {
    width: 80px;
    height: 80px;
  }

  .welcome-message h1 {
    font-size: 16px;
    margin-bottom: 4px;
  }

  .welcome-subtitle {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .welcome-hint {
    font-size: 11px;
    line-height: 1.4;
  }

  .welcome-message p {
    margin-bottom: var(--space-1);
    font-size: 12px;
  }

  .chat-input-container {
    padding: var(--space-2) var(--space-2);
    padding-bottom: max(var(--space-2), env(safe-area-inset-bottom, 0px));
  }

  .chat-messages,
  #chat-messages {
    padding: var(--space-2) var(--space-3);
  }

  /* Terminal entries: prevent horizontal overflow */
  .terminal-entry-header {
    flex-wrap: wrap;
    gap: 4px;
  }

  .terminal-entry-cmd-inline {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }

  .embedded-terminal-stats {
    gap: 6px;
    font-size: 10px;
  }

  .embedded-terminal-stats span:nth-child(n+3) {
    display: none;
  }

  /* Code blocks: more room on small screens */
  .message-text pre {
    max-width: calc(100% - 8px);
    font-size: 11px;
    padding: var(--space-3);
    -webkit-overflow-scrolling: touch;
  }

  /* Tables: tighter on mobile */
  .message-text th,
  .message-text td {
    padding: var(--space-1) var(--space-2);
    max-width: 100px;
    font-size: 11px;
  }
}

/* ============ ANIMATIONS ============ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Panel slide animations (Manus-inspired) */
@keyframes panelSlideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes panelSlideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes popoverIn {
  from { opacity: 0; transform: translateY(6px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes subtlePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Utility: smooth appear for dynamically loaded content */
.animate-in {
  animation: scaleIn 0.3s var(--ease-out) both;
}

.animate-fade-in {
  animation: fadeIn 0.25s var(--ease-out) both;
}

.animate-slide-up {
  animation: slideUp 0.35s var(--ease-out) both;
}

/* ============ THEME TOGGLE ANIMATION ============ */
#theme-toggle-btn i {
  transition: transform 0.3s ease;
}

#theme-toggle-btn:hover i {
  transform: rotate(180deg);
}

/* ============ ACCESSIBILITY ============ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible styles */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============ PRINT STYLES ============ */
@media print {
  .sidebar,
  #main-sidebar,
  .sidebar-tiny-bar,
  .chat-input-container,
  .header-right,
  .chat-actions {
    display: none !important;
  }

  .chat-messages,
  #chat-messages {
    padding: 0;
  }

  .message-text {
    border: 1px solid var(--border-primary);
  }
}

/* ============ LOADING STATES & SKELETONS ============ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 0%,
    var(--bg-hover) 50%,
    var(--bg-elevated) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-message {
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
  height: 80px;
}

.skeleton-text {
  height: 16px;
  margin-bottom: var(--space-2);
}

.skeleton-text:last-child {
  width: 70%;
}

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-primary);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fadeIn 0.2s ease;
}

/* ============ TOOLTIPS ============ */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip::before {
  content: attr(data-tooltip);
  position: fixed;
  bottom: auto;
  top: auto;
  left: auto;
  right: auto;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-xs);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: var(--z-tooltip);
  box-shadow: var(--shadow-lg);
}

/* Show tooltip below the element instead of above */
.tooltip:hover::before {
  opacity: 1;
}

/* Alternative: Simple title attribute tooltips (browser default) */
.action-btn[title],
.header-btn[title] {
  position: relative;
}

/* Remove custom tooltip for header buttons, use browser default */
.chat-actions .tooltip::before,
.header-right .tooltip::before {
  display: none;
}

/* ============ NOTIFICATIONS ============ */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 300px;
  animation: slideInRight 0.3s ease;
  font-weight: 500;
}

.notification i {
  font-size: var(--text-lg);
}

.notification-success {
  background: var(--secondary);
  color: white;
}

.notification-error {
  background: var(--danger);
  color: white;
}

.notification-info {
  background: var(--primary);
  color: white;
}

.notification-warning {
  background: var(--warning);
  color: white;
}

.notification.slide-out {
  animation: slideOutRight 0.3s ease;
}

/* ============ BADGES ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
}

.badge-primary {
  background: var(--primary-bg);
  color: var(--primary);
}

.badge-success {
  background: var(--secondary-bg);
  color: var(--secondary);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

/* ============ DEVICE TYPE BADGES ============ */
.device-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.device-badge i {
  font-size: 0.875em;
}

/* Device Type Color Schemes - Organized by Risk Level */
/* High Risk Devices (Red/Orange) - Direct access points */
.device-ip-camera,
.device-remote-desktop,
.device-vnc {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.device-iot-device,
.device-printer {
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

/* Medium Risk Devices (Blue/Cyan) - Network infrastructure */
.device-router,
.device-network-device {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.device-nas,
.device-storage {
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

/* Industrial/Critical (Purple) */
.device-ics-scada,
.device-industrial {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

/* Low Risk Devices (Green) - Standard services */
.device-web-server,
.device-http-server {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.device-database,
.device-mail-server,
.device-dns-server {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Unknown/Other (Gray) */
.device-unknown,
.device-other {
  background: rgba(156, 163, 175, 0.15);
  color: #9ca3af;
  border: 1px solid rgba(156, 163, 175, 0.3);
}

/* ============ PORT BADGES ============ */
.port-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  margin: 0 2px 2px 0;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
}

.port-count {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  margin: 0 2px 2px 0;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-tertiary);
  font-style: italic;
}

/* ============ SERVICE BADGES ============ */
.service-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.service-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  margin: 0 2px 2px 0;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  white-space: nowrap;
}

.service-badge:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(16, 185, 129, 0.1));
  border-color: rgba(16, 185, 129, 0.5);
}

.service-more {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-tertiary);
  font-style: italic;
  cursor: help;
}

.no-services {
  color: var(--text-tertiary);
  font-style: italic;
  font-size: var(--text-xs);
}

/* Light mode service badges */
.light .service-badge {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
  color: #059669;
  border-color: rgba(16, 185, 129, 0.4);
}

/* ============ SERVICE NAME STYLES ============ */
.service-name {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--text-primary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Port indicator in IP column (shows total ports for this IP) */
.port-indicator {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-left: 4px;
  font-weight: normal;
}

/* ============ DETECTION METHOD BADGES ============ */
.detection-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
}

.detection-badge i {
  font-size: 10px;
}

.detection-badge.detection-banner {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.detection-badge.detection-portmap {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

/* Light Theme Detection Badges */
.light .detection-badge.detection-banner {
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
  border-color: rgba(34, 197, 94, 0.25);
}

.light .detection-badge.detection-portmap {
  background: rgba(251, 191, 36, 0.1);
  color: #d97706;
  border-color: rgba(251, 191, 36, 0.25);
}

/* ============ ACTION BUTTONS ENHANCEMENTS ============ */
.action-btn.info-btn {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 11px;
  padding: 4px 8px;
}

.action-btn.info-btn:hover {
  background: rgba(99, 102, 241, 0.25);
}

.light .action-btn.info-btn {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  border-color: rgba(99, 102, 241, 0.25);
}

/* Light Theme Adjustments for Device Badges */
.light .device-ip-camera,
.light .device-remote-desktop,
.light .device-vnc {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.25);
}

.light .device-iot-device,
.light .device-printer {
  background: rgba(249, 115, 22, 0.1);
  color: #ea580c;
  border-color: rgba(249, 115, 22, 0.25);
}

.light .device-router,
.light .device-network-device {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
  border-color: rgba(59, 130, 246, 0.25);
}

.light .device-nas,
.light .device-storage {
  background: rgba(6, 182, 212, 0.1);
  color: #0891b2;
  border-color: rgba(6, 182, 212, 0.25);
}

.light .device-ics-scada,
.light .device-industrial {
  background: rgba(168, 85, 247, 0.1);
  color: #9333ea;
  border-color: rgba(168, 85, 247, 0.25);
}

.light .device-web-server,
.light .device-http-server {
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
  border-color: rgba(34, 197, 94, 0.25);
}

.light .device-database,
.light .device-mail-server,
.light .device-dns-server {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.25);
}

.light .device-unknown,
.light .device-other {
  background: rgba(107, 114, 128, 0.1);
  color: #6b7280;
  border-color: rgba(107, 114, 128, 0.25);
}

.light .port-badge {
  background: rgba(0, 0, 0, 0.05);
  color: #4b5563;
  border-color: rgba(0, 0, 0, 0.1);
}

.light .port-count {
  color: #6b7280;
}

/* ============ DEVICE FINGERPRINTING ENHANCEMENTS ============ */

/* Device Statistics Grid */
.device-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
}

.device-stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-secondary);
  transition: all 0.2s ease;
  cursor: pointer;
}

.device-stat-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.device-stat-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-bg);
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
}

.stat-icon.camera {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}
.stat-icon.industrial {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}
.stat-icon.network {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}
.stat-icon.iot {
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
}
.stat-icon.server {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}
.stat-icon.unknown {
  background: rgba(156, 163, 175, 0.15);
  color: #9ca3af;
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-count {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: capitalize;
}

/* Filter Controls */
.filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.filter-group label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.filter-select {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-sm);
  cursor: pointer;
  min-width: 140px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-bg);
}

.filter-controls .search-input,
.filter-group .search-input,
.filter-input {
  flex: 1;
  min-width: 200px;
  max-width: 300px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-sm);
  width: auto;
}

.filter-controls .search-input:focus,
.filter-group .search-input:focus,
.filter-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-bg);
}

.filter-controls .search-input::placeholder,
.filter-input::placeholder {
  color: var(--text-tertiary);
}

.reset-filters-btn {
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  transition: all 0.2s ease;
}

.reset-filters-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* Enhanced Device Badge Styles */
.device-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  cursor: default;
  transition: transform 0.15s ease;
}

.device-badge:hover {
  transform: scale(1.02);
}

.device-icon {
  font-size: 0.9em;
  opacity: 0.9;
}

.device-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Device Category Colors */
.device-camera {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.device-industrial {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.device-network {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.device-iot {
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.device-server {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.device-unknown {
  background: rgba(156, 163, 175, 0.15);
  color: #9ca3af;
  border: 1px solid rgba(156, 163, 175, 0.3);
}

/* Confidence Badges */
.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
}

.confidence-high {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.confidence-high i {
  color: #22c55e;
}

.confidence-medium {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.confidence-medium i {
  color: #f59e0b;
}

.confidence-low {
  background: rgba(156, 163, 175, 0.15);
  color: #9ca3af;
}

.confidence-low i {
  color: #9ca3af;
}

/* Vendor Badge */
.vendor-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vendor-none {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: var(--space-1);
}

.action-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-xs);
  transition: all 0.2s ease;
  text-decoration: none;
}

.action-btn:hover {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
}

.action-btn.scan-btn:hover {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
}

.action-btn.map-btn:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--success);
  color: var(--success);
}

/* Location Link */
.location-link {
  color: var(--text-secondary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  transition: color 0.2s ease;
}

.location-link:hover {
  color: var(--primary);
}

.location-link i {
  font-size: 0.9em;
  color: var(--text-tertiary);
}

.location-link:hover i {
  color: var(--primary);
}

/* No Ports Indicator */
.no-ports {
  color: var(--text-tertiary);
  font-style: italic;
  font-size: var(--text-xs);
}

/* Enhanced Table Column Widths */
#hosts-table .col-ip {
  width: 120px;
}
#hosts-table .col-device {
  width: 150px;
}
#hosts-table .col-confidence {
  width: 90px;
}
#hosts-table .col-vendor {
  width: 100px;
}
#hosts-table .col-hostname {
  width: 150px;
}
#hosts-table .col-location {
  width: 120px;
}
#hosts-table .col-org {
  width: 150px;
}
#hosts-table .col-ports {
  width: 140px;
}
#hosts-table .col-services {
  width: 150px;
}
#hosts-table .col-actions {
  width: 80px;
  text-align: center;
}

/* Row hover effect with category indication */
#hosts-table tbody tr {
  transition: background 0.15s ease;
}

#hosts-table tbody tr:hover {
  background: var(--bg-hover);
}

#hosts-table tbody tr[data-category="camera"]:hover {
  background: rgba(239, 68, 68, 0.05);
}

#hosts-table tbody tr[data-category="industrial"]:hover {
  background: rgba(168, 85, 247, 0.05);
}

#hosts-table tbody tr[data-category="network"]:hover {
  background: rgba(59, 130, 246, 0.05);
}

#hosts-table tbody tr[data-category="iot"]:hover {
  background: rgba(249, 115, 22, 0.05);
}

#hosts-table tbody tr[data-category="server"]:hover {
  background: rgba(34, 197, 94, 0.05);
}

/* Filter hidden rows */
#hosts-table tbody tr.filter-hidden {
  display: none;
}

/* Light theme adjustments for new components */
.light .device-stats-grid,
.light .filter-controls {
  background: var(--bg-secondary);
  border-color: var(--border-primary);
}

.light .device-stat-card {
  background: var(--bg-primary);
  border-color: var(--border-secondary);
}

.light .device-stat-card:hover {
  background: var(--bg-hover);
}

.light .filter-select,
.light .search-input {
  background: var(--bg-primary);
  border-color: var(--border-primary);
}

.light .confidence-high {
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
}

.light .confidence-medium {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

.light .confidence-low {
  background: rgba(107, 114, 128, 0.1);
  color: #6b7280;
}

.light .vendor-badge {
  background: rgba(0, 0, 0, 0.05);
  color: #4b5563;
}

.light .action-btn {
  background: var(--bg-secondary);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  #hosts-table .col-org,
  #hosts-table .col-services {
    display: none;
  }
}

@media (max-width: 992px) {
  .device-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  #hosts-table .col-hostname,
  #hosts-table .col-vendor {
    display: none;
  }

  .filter-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
  }

  .search-input {
    max-width: none;
  }
}

@media (max-width: 768px) {
  .device-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  #hosts-table .col-confidence,
  #hosts-table .col-location {
    display: none;
  }
}

/* ============ SMOOTH TRANSITIONS ============ */
a,
button,
input,
textarea,
select {
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

/* will-change removed — applied dynamically only during animation for better GPU usage */

/* ============ IMPROVED SCROLLBARS ============ */
.chat-messages::-webkit-scrollbar,
#chat-messages::-webkit-scrollbar,
.chat-sessions::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb,
#chat-messages::-webkit-scrollbar-thumb,
.chat-sessions::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}

.chat-messages::-webkit-scrollbar-thumb:hover,
#chat-messages::-webkit-scrollbar-thumb:hover,
.chat-sessions::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* ============ ENHANCED FOCUS STATES ============ */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============ EMPTY STATES ============ */
.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-5);
  color: var(--text-secondary);
}

.empty-state i {
  font-size: 48px;
  color: var(--text-tertiary);
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
}

.empty-state p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ============ IMPROVED BUTTON STATES ============ */
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

/* ============ CODE BLOCK IMPROVEMENTS ============ */
.message-text pre {
  position: relative;
  max-height: 500px;
  overflow-y: auto;
}

.message-text pre:hover {
  box-shadow: var(--shadow-md);
}

/* ============ TABLE IMPROVEMENTS ============ */
#hosts-table,
#ranges-table {
  font-variant-numeric: tabular-nums;
}

#hosts-table tr,
#ranges-table tr {
  transition: background-color 0.2s ease;
}

#hosts-table tbody tr,
#ranges-table tbody tr {
  cursor: pointer;
}

/* ============ CARD HOVER EFFECTS ============ */
.card {
  transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ============ PROGRESS BAR STYLING ============ */
#scan-progress-bar {
  transition: all 0.3s ease;
}

/* ============ MOBILE OPTIMIZATIONS ============ */
@media (max-width: 768px) {
  .notification {
    left: 20px;
    right: 20px;
    min-width: auto;
  }

  .tooltip::before {
    font-size: var(--text-xs);
    max-width: 200px;
    white-space: normal;
  }
}

/* ============ MODAL STYLES ============ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: modalOverlayIn 0.25s var(--ease-out) both;
}

.modal-content {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  animation: modalContentIn 0.3s var(--ease-out) both;
  animation-delay: 0.05s;
  z-index: 1;
}

@keyframes modalOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalContentIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-secondary);
}

.modal-header h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.modal-header h2 i {
  color: var(--primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: rotate(90deg);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  max-height: calc(80vh - 180px);
}

/* Export Modal Specific Styles */
.export-modal-content {
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.export-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  max-height: calc(85vh - 160px);
  min-height: 200px;
}

.export-modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.message-selection-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.export-scope-options,
.export-format-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.export-scope-option {
  flex: 1 1 220px;
}

.export-format-option {
  flex: 1 1 180px;
  min-width: 0;
}

/* ============ KEYBOARD SHORTCUTS GRID ============ */
.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-4);
}

.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.shortcut-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.shortcut-item kbd {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 2px 0 var(--border-primary);
  min-width: 24px;
  text-align: center;
}

.shortcut-item span {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-left: var(--space-3);
}

/* ============ COPY CODE BUTTON ============ */
.code-block-wrapper {
  position: relative;
}

.copy-code-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.code-block-wrapper:hover .copy-code-btn {
  opacity: 1;
}

.copy-code-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.copy-code-btn.copied {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

/* ============ FADE OUT ANIMATION ============ */
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ============ RESPONSIVE MODAL ============ */
@media (max-width: 768px) {
  .modal-content {
    max-width: 100%;
    border-radius: var(--radius-lg);
  }

  .export-modal-content {
    max-height: calc(100dvh - 24px);
  }

  .export-modal-body {
    padding: var(--space-4);
  }

  .export-scope-options,
  .export-format-options {
    flex-direction: column;
    gap: 8px;
  }

  .export-scope-option,
  .export-format-option {
    width: 100%;
    flex: 1 1 100%;
  }

  .shortcuts-grid {
    grid-template-columns: 1fr;
  }

  .modal-header {
    padding: var(--space-4) var(--space-5);
  }

  .modal-body {
    padding: var(--space-4);
  }
}

@media (max-width: 480px) {
  .export-modal-content {
    border-radius: var(--radius-md);
    max-height: calc(100dvh - 12px);
  }

  .export-modal-body {
    padding: var(--space-3);
  }

  .export-modal-footer {
    flex-direction: column;
    gap: 8px;
  }

  .export-modal-footer .btn {
    width: 100%;
  }
}

/* ============ DATA TABLES DARK THEME INTEGRATION ============ */
.dataTables_wrapper {
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.dataTables_filter,
.dataTables_length,
.dataTables_info,
.dataTables_paginate {
  margin: var(--space-4) 0;
}

.dataTables_filter label,
.dataTables_length label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
}

.dataTables_filter input,
.dataTables_length select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  transition: all 0.2s ease;
}

.dataTables_filter input:focus,
.dataTables_length select:focus {
  outline: none;
  border-color: var(--primary);
}

.dataTables_info {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

.dataTables_paginate {
  display: flex;
  gap: var(--space-2);
}

.dataTables_paginate .paginate_button {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: var(--text-sm);
}

.dataTables_paginate .paginate_button:hover:not(.disabled) {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
}

.dataTables_paginate .paginate_button.current {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.dataTables_paginate .paginate_button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* DataTables Table Styling */
table.dataTable {
  border-collapse: separate !important;
  border-spacing: 0;
  width: 100% !important;
  table-layout: auto;
}

table.dataTable thead th {
  background: var(--bg-elevated);
  border-bottom: 2px solid var(--primary);
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  position: relative;
  resize: horizontal;
  overflow: auto;
  min-width: 80px;
}

table.dataTable thead th.resizable {
  resize: horizontal;
}

/* Column resize handle */
table.dataTable thead th::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.2s ease;
}

table.dataTable thead th:hover::after {
  background: var(--primary);
}

table.dataTable thead th.sorting:before,
table.dataTable thead th.sorting_asc:before,
table.dataTable thead th.sorting_desc:before {
  opacity: 0.3;
}

table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
  background: var(--primary-bg);
}

table.dataTable tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-primary);
}

table.dataTable tbody tr:hover {
  background: var(--primary-bg);
}

/* Responsive DataTables */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before {
  background-color: var(--primary);
  border-color: var(--primary);
}

@media screen and (max-width: 768px) {
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    text-align: left;
    margin-bottom: var(--space-3);
  }

  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    text-align: center;
    margin-top: var(--space-3);
  }
}

.gradient-text {
  background: var(--gradient-btn);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: var(--font-en);
  font-weight: 700;
}

/* Subscription Badges */
.subscription-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.3);
}

/* Usage Meter */
.usage-meter-badge {
  cursor: pointer;
  transition: transform 0.2s ease;
}

.usage-meter-badge:hover {
  transform: scale(1.05);
}

/* Plan Cards */
.plan-card {
  transition: all 0.3s ease;
}

.plan-card:hover {
  transform: translateY(-5px);
}

.current-plan {
  border: 2px solid var(--primary) !important;
  position: relative;
}

/* Billing Toggle */
.billing-toggle {
  display: inline-flex;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: 12px;
}

.toggle-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.toggle-btn.active {
  background: var(--primary);
  color: white;
}

/* Embedded Terminal CSS - moved to terminal.css */

/* ============ SHODAN-LIKE TABLE ============ */
.shodan-table tbody tr {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.shodan-table tbody tr:hover {
  background-color: var(--bg-hover) !important;
}

.shodan-table .port-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.shodan-table .port-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-mono);
}

.shodan-table .port-more {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: 4px;
  font-size: 11px;
  cursor: help;
}

.shodan-table .service-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.shodan-table .service-badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.shodan-table .service-more {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: 4px;
  font-size: 11px;
  cursor: help;
}

.light .shodan-table .service-badge {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

/* ============ SHODAN-LIKE IP DETAIL MODAL ============ */
.ip-detail-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ip-detail-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.ip-detail-content {
  position: relative;
  width: 95%;
  max-width: 1100px;
  max-height: 90vh;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ip-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
  border-bottom: 1px solid var(--border-primary);
}

.ip-detail-title h2 {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--primary);
  margin: 0 0 8px 0;
}

.ip-detail-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
}

.hostname-badge {
  font-family: var(--font-mono);
  color: var(--secondary);
}

.time-badge i {
  color: var(--text-tertiary);
}

.ip-detail-close {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ip-detail-close:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.ip-detail-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.ip-detail-sidebar {
  width: 320px;
  flex-shrink: 0;
  padding: 20px;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-primary);
  overflow-y: auto;
}

.info-section {
  margin-bottom: 24px;
}

.info-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-secondary);
}

.info-section h3 i {
  color: var(--primary);
}

.info-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-word;
}

.info-value.device-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: fit-content;
}

.map-preview {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.map-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.map-link-btn:hover {
  background: var(--primary);
  color: white;
}

.ip-detail-main {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.ip-detail-main h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.ip-detail-main h3 i {
  color: var(--primary);
}

.ports-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Port Card - Shodan Style */
.port-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.port-card:hover {
  border-color: var(--primary);
}

.port-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-secondary);
}

.port-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.port-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  padding: 6px 12px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
}

.port-service {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.port-protocol {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-left: 4px;
}

.port-actions {
  display: flex;
  gap: 8px;
}

.port-url-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--secondary-bg);
  color: var(--secondary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.port-url-btn:hover {
  background: var(--secondary);
  color: white;
}

/* RDP Connect Button */
.port-rdp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--gradient-btn);
  color: var(--btn-text);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.port-rdp-btn:hover {
  opacity: 0.9;
  color: var(--btn-text);
  transform: translateY(-1px);
}

.port-rdp-btn i {
  font-size: 11px;
}

/* ============ SERVICE TOOL BUTTONS (FTP, NGINX) ============ */
.port-service-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.port-service-tool-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.port-service-tool-btn.running {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%) !important;
}

.port-service-tool-btn.completed {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
}

.port-ftp-btn {
  background: var(--gradient-btn);
  color: var(--btn-text);
}

.port-ftp-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

.port-nginx-btn {
  background: var(--gradient-btn);
  color: var(--btn-text);
}

.port-nginx-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ============ SERVICE TOOL RESULT CONTAINER ============ */
.service-tool-result {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border-primary);
}

.tool-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.tool-loading i {
  color: var(--primary);
}

.tool-error {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ef4444;
  font-size: 14px;
  padding: 12px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-sm);
}

.tool-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-primary);
}

.tool-result-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.tool-result-title i {
  color: var(--primary);
}

.tool-result-time {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.tool-result-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.summary-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  min-width: 60px;
}

.summary-stat.critical {
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.summary-stat.critical .stat-count {
  color: #dc2626;
}

.summary-stat.high {
  background: rgba(234, 88, 12, 0.15);
  border: 1px solid rgba(234, 88, 12, 0.3);
}

.summary-stat.high .stat-count {
  color: #ea580c;
}

.summary-stat.medium {
  background: rgba(202, 138, 4, 0.15);
  border: 1px solid rgba(202, 138, 4, 0.3);
}

.summary-stat.medium .stat-count {
  color: #ca8a04;
}

.stat-count {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tool-vulns-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-vuln-item {
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border-left: 3px solid #6b7280;
}

.tool-vuln-item.severity-critical {
  border-left-color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
}

.tool-vuln-item.severity-high {
  border-left-color: #ea580c;
  background: rgba(234, 88, 12, 0.08);
}

.tool-vuln-item.severity-medium {
  border-left-color: #ca8a04;
  background: rgba(202, 138, 4, 0.08);
}

.tool-vuln-item.severity-low {
  border-left-color: #16a34a;
  background: rgba(22, 163, 74, 0.08);
}

.tool-vuln-item.severity-info {
  border-left-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

.vuln-severity-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(107, 114, 128, 0.2);
  color: var(--text-secondary);
  margin-right: 8px;
}

.severity-critical .vuln-severity-badge {
  background: #dc2626;
  color: white;
}

.severity-high .vuln-severity-badge {
  background: #ea580c;
  color: white;
}

.severity-medium .vuln-severity-badge {
  background: #ca8a04;
  color: white;
}

.severity-low .vuln-severity-badge {
  background: #16a34a;
  color: white;
}

.vuln-name {
  font-weight: 500;
  color: var(--text-primary);
}

.vuln-desc {
  margin: 8px 0 0 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.vuln-cve {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 6px;
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
}

.tool-no-vulns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: #10b981;
  font-size: 14px;
}

.tool-no-vulns i {
  font-size: 18px;
}

/* NGINX-specific result styles */
.tool-result-nginx-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.nginx-detected {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
}

.nginx-detected.yes {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.nginx-detected.no {
  background: rgba(107, 114, 128, 0.15);
  color: #6b7280;
}

.nginx-version {
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.nginx-finding {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.nginx-finding.critical {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.2);
  color: #dc2626;
}

.nginx-finding.high {
  background: rgba(234, 88, 12, 0.1);
  border: 1px solid rgba(234, 88, 12, 0.2);
  color: #ea580c;
}

.nginx-finding i {
  margin-top: 2px;
}

.nginx-files-list {
  margin: 8px 0 0 20px;
  padding: 0;
  font-size: 12px;
  font-family: var(--font-mono);
}

.nginx-files-list li {
  margin: 4px 0;
}

/* RDP Info Section */
.rdp-info-section {
  background: linear-gradient(135deg, rgba(0, 120, 212, 0.1) 0%, rgba(16, 110, 190, 0.05) 100%);
  border: 1px solid rgba(0, 120, 212, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
}

.rdp-info-label {
  display: block;
  font-size: 11px;
  color: #0078d4;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  font-weight: 600;
}

.rdp-info-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rdp-status-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rdp-nla-enabled {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
}

.rdp-nla-disabled {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
}

.rdp-ssl-supported {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
}

.rdp-ssl-unsupported {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
}

.rdp-protocol {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  background: rgba(107, 114, 128, 0.15);
  color: #6b7280;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
}

.rdp-target-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.rdp-target-name i {
  color: #0078d4;
  font-size: 11px;
}

.rdp-vuln-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.vuln-hint {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Light mode adjustments for RDP */
.light .rdp-info-section {
  background: linear-gradient(135deg, rgba(0, 120, 212, 0.08) 0%, rgba(16, 110, 190, 0.03) 100%);
  border-color: rgba(0, 120, 212, 0.15);
}

.light .rdp-target-name {
  color: #374151;
}

.port-card-body {
  padding: 16px;
}

.banner-container {
  background: #0d1117;
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
}

.banner-label {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.banner-content {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: #e6edf3;
  white-space: pre-wrap;
  word-break: break-word;
}

.light .banner-container {
  background: #f6f8fa;
}

.light .banner-content {
  color: #24292f;
}

.no-banner {
  color: var(--text-tertiary);
  font-style: italic;
  font-size: 13px;
}

.detection-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
}

.detection-badge.detection-banner {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.detection-badge.detection-portmap {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

/* ============ VULNERABILITY CARDS ============ */
.vulns-section,
.rtsp-section {
  border-top: 1px solid var(--border-primary);
  padding-top: 16px;
  margin-top: 8px;
}

.vulns-section h3,
.rtsp-section h3 {
  color: #ef4444;
}

.vulns-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vuln-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  border-left: 4px solid #ca8a04;
  padding: 12px;
  transition: all 0.2s ease;
}

.vuln-card:hover {
  background: var(--bg-secondary);
}

.vuln-card.vuln-critical {
  border-left-color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
}

.vuln-card.vuln-high {
  border-left-color: #ea580c;
  background: rgba(234, 88, 12, 0.08);
}

.vuln-card.vuln-medium {
  border-left-color: #ca8a04;
  background: rgba(202, 138, 4, 0.08);
}

.vuln-card.vuln-low {
  border-left-color: #16a34a;
  background: rgba(22, 163, 74, 0.08);
}

.vuln-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.vuln-severity {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.vuln-type {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.vuln-port {
  font-size: 12px;
  color: var(--text-tertiary);
}

.vuln-body {
  font-size: 13px;
}

.vuln-details {
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.5;
}

.vuln-exploit {
  color: #ef4444;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.vuln-device-info,
.vuln-streams {
  margin-top: 10px;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.vuln-device-info strong,
.vuln-streams strong {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 8px;
}

.vuln-device-info ul,
.vuln-streams ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.vuln-device-info li {
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  gap: 8px;
}

.vuln-device-info li:last-child {
  border-bottom: none;
}

.vuln-device-info .info-key {
  color: var(--text-tertiary);
  min-width: 100px;
}

.vuln-device-info code {
  font-family: var(--font-mono);
  color: var(--primary);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
}

/* ============ RTSP STREAMS ============ */
.rtsp-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rtsp-category {
  margin-top: 8px;
  margin-bottom: 4px;
}

.rtsp-category:first-child {
  margin-top: 0;
}

.rtsp-category-label {
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.rtsp-category-label.rtsp-open {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.rtsp-category-label.rtsp-auth {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.rtsp-stream-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--text-tertiary);
  transition: all 0.2s ease;
}

.rtsp-stream-item:hover {
  background: var(--bg-secondary);
}

.rtsp-stream-item.rtsp-open-stream {
  border-left-color: #ef4444;
}

.rtsp-stream-item.rtsp-auth-required {
  border-left-color: #f59e0b;
}

.rtsp-icon {
  font-size: 14px;
  color: var(--text-tertiary);
}

.rtsp-open-stream .rtsp-icon {
  color: #ef4444;
}

.rtsp-auth-required .rtsp-icon {
  color: #f59e0b;
}

.rtsp-url {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
}

.rtsp-url:hover {
  text-decoration: underline;
}

.rtsp-status {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.rtsp-status.open {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.rtsp-status.auth-required {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.rtsp-copy-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.rtsp-copy-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.rtsp-copy-btn.copied {
  background: #10b981;
  color: white;
  border-color: #10b981;
}

.stream-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 12px;
}

.stream-link:hover {
  text-decoration: underline;
}

/* ============ HTTP CAMERA STREAMS (CamHunter) ============ */
.http-streams-section {
  border-top: 1px solid var(--border-primary);
  padding-top: 16px;
  margin-top: 8px;
}

.http-streams-section h3 {
  color: #3b82f6;
}

.http-streams-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.http-streams-vendor-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.http-vendor-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.http-device-model {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.http-stream-total {
  font-size: 11px;
  color: var(--text-tertiary);
}

.http-open-stream {
  border-left-color: #3b82f6;
}

.http-open-stream .rtsp-icon {
  color: #3b82f6;
}

.http-auth-required {
  border-left-color: #f59e0b;
}

.http-auth-required .rtsp-icon {
  color: #f59e0b;
}

.http-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}

.http-cred-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

/* HTTP Stream Tab — player image */
.http-stream-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  border-radius: var(--radius);
}

.http-stream-container .livestream-player {
  min-height: 320px;
}

/* HTTP stream tab button active style */
.http-stream-tab.active {
  border-bottom-color: #3b82f6 !important;
  color: #3b82f6 !important;
}

.http-dot {
  background: #3b82f6 !important;
}

/* HTTP stream list items */
.http-stream-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--text-tertiary);
  transition: all 0.2s ease;
  cursor: pointer;
}

.http-stream-list-item:hover {
  background: var(--bg-secondary);
}

.http-stream-list-item.active {
  border-left-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

.http-stream-item-info {
  flex: 1;
  min-width: 0;
}

.http-stream-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.http-stream-item-icon {
  font-size: 14px;
  color: var(--text-tertiary);
}

.http-stream-item-icon.stream-open {
  color: #3b82f6;
}

.http-stream-item-icon.stream-auth-required {
  color: #f59e0b;
}

.http-stream-item-type {
  font-size: 11px;
  font-weight: 600;
  color: #3b82f6;
  text-transform: uppercase;
}

.http-stream-item-url {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.http-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
}

.http-badge-open {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.http-badge-auth {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.http-badge-vendor {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  text-transform: uppercase;
}

.btn-play-http-stream {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #3b82f6;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-play-http-stream:hover {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.http-stream-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius) var(--radius);
  border-top: 1px solid var(--border-primary);
}

/* ============ VULNERABILITY BADGE IN TABLE ============ */
.vuln-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  margin-left: 8px;
}

.vuln-indicator.has-vulns {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  animation: pulse-vuln 2s infinite;
}

@keyframes pulse-vuln {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ============ VT RELATIONS INDICATOR IN TABLE ============ */
.relations-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  margin-left: 8px;
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
}

.relations-indicator i {
  font-size: 9px;
}

.relations-indicator.vt-only {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

/* VT-only rows (intel without open ports) */
.vt-only-row {
  background: rgba(245, 158, 11, 0.05) !important;
  border-left: 3px solid #f59e0b;
}

.vt-only-row:hover {
  background: rgba(245, 158, 11, 0.1) !important;
}

/* Responsive for modal */
@media (max-width: 900px) {
  .ip-detail-body {
    flex-direction: column;
  }
  
  .ip-detail-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-primary);
    max-height: 300px;
  }
}

@media (max-width: 600px) {
  .ip-detail-content {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .ip-detail-title h2 {
    font-size: 22px;
  }
  
  .port-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

/* ============ SCAN CONFIGURATION MODAL ============ */
.scan-config-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-config-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.scan-config-content {
  position: relative;
  width: 95%;
  max-width: 900px;
  max-height: 85vh;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.3s ease;
}

.scan-config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
  border-bottom: 1px solid var(--border-primary);
}

.scan-config-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.scan-config-header h2 i {
  color: var(--primary);
}

.scan-config-close {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.scan-config-close:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.scan-config-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.config-section {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 16px;
}

.config-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.config-section-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-section-header h3 i {
  color: var(--primary);
}

.config-section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-section-actions .badge {
  background: var(--primary-bg);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}

.config-help-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.add-range-input {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.add-range-input input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-mono);
}

.add-range-input input:focus {
  outline: none;
  border-color: var(--primary);
}

.ranges-list-config {
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.range-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.range-item:hover {
  background: var(--bg-hover);
}

.range-item.disabled {
  opacity: 0.5;
}

.range-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.range-item .range-cidr {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
}

.range-item .range-hosts {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.range-item .range-type {
  font-size: 11px;
  color: var(--primary);
  text-transform: uppercase;
}

.range-item .range-remove {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.range-item .range-remove:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.range-item.custom .range-cidr::before {
  content: "★ ";
  color: var(--warning);
}

.loading-ranges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  color: var(--text-secondary);
}

.custom-ips-textarea {
  width: 100%;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  resize: vertical;
  min-height: 100px;
}

.custom-ips-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.custom-ips-textarea::placeholder {
  color: var(--text-tertiary);
}

.scan-config-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-primary);
  flex-wrap: wrap;
  gap: 12px;
}

.config-summary {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.config-summary i {
  color: var(--primary);
}

.config-actions {
  display: flex;
  gap: 10px;
}

.config-actions .btn {
  padding: 10px 20px;
  font-size: 14px;
}

/* Responsive for config modal */
@media (max-width: 600px) {
  .scan-config-content {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .scan-config-footer {
    flex-direction: column;
    align-items: stretch;
  }
  
  .config-summary {
    justify-content: center;
  }
  
  .config-actions {
    justify-content: stretch;
  }
  
  .config-actions .btn {
    flex: 1;
  }
}

/* ============ INFRASTRUCTURE/DOMAIN RELATIONS MODAL ============ */
.infrastructure-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.infrastructure-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
}

.infrastructure-content {
  position: relative;
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
  border-radius: var(--radius-lg);
  width: 95vw;
  height: 90vh;
  max-width: 1400px;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-primary);
  animation: modalSlideIn 0.3s ease;
}

.infrastructure-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-primary);
}

.infrastructure-title h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.infrastructure-title h2 i {
  color: var(--primary);
}

.infrastructure-stats {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.infrastructure-modal .stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.infrastructure-modal .stat-badge i {
  color: var(--primary);
}

.infrastructure-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.infra-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.infra-btn:hover {
  background: var(--bg-hover);
  transform: scale(1.05);
}

/* PNG download buttons */
.infra-btn-png {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(99, 102, 241, 0.15));
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #3b82f6;
}

.infra-btn-png:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(99, 102, 241, 0.3));
  border-color: rgba(59, 130, 246, 0.5);
}

/* HD PNG button (8x) */
.infra-btn-png-hd {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #8b5cf6;
}

.infra-btn-png-hd:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(168, 85, 247, 0.3));
  border-color: rgba(139, 92, 246, 0.5);
}

.infra-btn-close {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-inline-start: 8px;
}

.infra-btn-close:hover {
  background: rgba(239, 68, 68, 0.3);
}

.infrastructure-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--bg-primary);
}

.infra-diagram-container {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.infra-diagram-container .mermaid {
  width: 100%;
  height: 100%;
}

.infra-diagram-container .mermaid svg {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
}

.infrastructure-legend {
  display: flex;
  gap: 16px;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-primary);
  flex-wrap: wrap;
}

.infrastructure-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.infrastructure-legend .legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

/* Loading state for infrastructure modal */
.infra-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-primary);
}

/* Export overlay */
.infra-export-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  border-radius: 12px;
}

.infra-export-text {
  color: var(--text-primary);
  font-size: 1.5rem;
  margin-bottom: 20px;
  text-align: center;
  padding: 0 16px;
}

.infra-export-status {
  color: var(--primary);
  font-size: 1rem;
  text-align: center;
}

.infra-loading i {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 16px;
  animation: spin 1s linear infinite;
}

.infra-loading p {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

/* Infrastructure diagram button in chat */
.infrastructure-diagram-button-container {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  margin: 10px 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.infrastructure-diagram-button-container:hover {
  transform: translateX(5px);
  border-color: var(--primary);
}

/* ============ INFRASTRUCTURE MODAL — RESPONSIVE ============ */

/* Tablet & smaller desktops (≤ 1024px) */
@media (max-width: 1024px) {
  .infrastructure-content {
    width: 98vw;
    height: 95vh;
    max-width: none;
    border-radius: 12px;
  }

  .infrastructure-header {
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
  }

  .infrastructure-title {
    flex: 1 1 100%;
  }

  .infrastructure-controls {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .infrastructure-legend {
    padding: 10px 16px;
    gap: 12px;
  }
}

/* Small tablets / large phones (≤ 768px) */
@media (max-width: 768px) {
  .infrastructure-content {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .infrastructure-header {
    padding: 12px 14px;
    gap: 10px;
  }

  .infrastructure-title h2 {
    font-size: 1rem;
  }

  .infrastructure-stats {
    gap: 8px;
    flex-wrap: wrap;
  }

  .infrastructure-modal .stat-badge {
    padding: 3px 8px;
    font-size: 0.72rem;
  }

  .infrastructure-controls {
    gap: 6px;
  }

  .infra-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    font-size: 11px;
  }

  .infra-btn-close {
    width: 32px;
    height: 32px;
  }

  .infra-diagram-container {
    padding: 10px;
  }

  .infrastructure-legend {
    padding: 8px 14px;
    gap: 10px;
  }

  .infrastructure-legend .legend-item {
    font-size: 0.72rem;
    gap: 5px;
  }

  .infrastructure-legend .legend-color {
    width: 12px;
    height: 12px;
  }
}

/* Mobile phones (≤ 480px) */
@media (max-width: 480px) {
  .infrastructure-header {
    padding: 10px 12px;
    gap: 8px;
  }

  .infrastructure-title h2 {
    font-size: 0.9rem;
    gap: 6px;
  }

  .infrastructure-title h2 i {
    font-size: 0.9rem;
  }

  .infrastructure-stats {
    gap: 6px;
  }

  .infrastructure-modal .stat-badge {
    padding: 2px 6px;
    font-size: 0.65rem;
  }

  .infrastructure-controls {
    gap: 4px;
  }

  .infra-btn {
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    font-size: 10px;
    border-radius: 6px;
  }

  /* Hide text labels on smallest screens, keep icons */
  .infra-btn-png,
  .infra-btn-png-hd {
    font-size: 0;
    padding: 0;
    min-width: 28px;
  }

  .infra-btn-png i,
  .infra-btn-png-hd i {
    font-size: 11px;
    margin: 0;
  }

  .infra-btn-close {
    width: 28px;
    height: 28px;
    margin-inline-start: 4px;
  }

  .infra-diagram-container {
    padding: 6px;
  }

  .infrastructure-legend {
    padding: 6px 10px;
    gap: 6px 10px;
  }

  .infrastructure-legend .legend-item {
    font-size: 0.65rem;
    gap: 4px;
  }

  .infrastructure-legend .legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
  }

  .infra-loading i {
    font-size: 2rem;
  }

  .infra-loading p {
    font-size: 0.9rem;
  }

  .infra-export-text {
    font-size: 1rem;
    margin-bottom: 12px;
  }

  .infra-export-status {
    font-size: 0.85rem;
  }
}

/* Very small phones (≤ 360px) */
@media (max-width: 360px) {
  .infrastructure-title h2 {
    font-size: 0.8rem;
  }

  .infrastructure-stats {
    display: none;
  }

  /* Hide download buttons, keep only zoom controls + close */
  .infra-btn-download,
  .infra-btn-png,
  .infra-btn-png-hd {
    display: none;
  }

  .infrastructure-legend .legend-item span:not(.legend-color) {
    display: none;
  }

  .infrastructure-legend {
    justify-content: center;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   FILE DOWNLOAD CARDS  (Manus-style inline download)
   ═══════════════════════════════════════════════════════════════════ */

.file-download-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  margin: 12px 0;
  border-radius: 12px;
  background: var(--surface-secondary, #1e1e2e);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  cursor: pointer;
  transition: all 0.2s ease;
  max-width: 420px;
}

.file-download-card:hover {
  background: var(--surface-hover, #2a2a3e);
  border-color: var(--border-hover, rgba(255, 255, 255, 0.15));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.file-download-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 10px;
  font-size: 20px;
}

.file-card-pdf .file-download-icon {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.file-card-docx .file-download-icon {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.file-card-zip .file-download-icon {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.file-card-default .file-download-icon {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.file-download-info {
  flex: 1;
  min-width: 0;
}

.file-download-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #e0e0e0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.file-download-meta {
  font-size: 12px;
  color: var(--text-secondary, #888);
  margin-top: 2px;
}

.file-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary, #aaa);
  text-decoration: none;
  transition: all 0.2s ease;
  font-size: 15px;
}

.file-download-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary, #fff);
}

/* RTL support */
[dir="rtl"] .file-download-card {
  flex-direction: row-reverse;
}

/* Light theme adjustments */
@media (prefers-color-scheme: light) {
  .file-download-card {
    background: #f8f9fa;
    border-color: #e0e0e0;
  }
  .file-download-card:hover {
    background: #eef0f2;
    border-color: #ccc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  }
  .file-download-name {
    color: #1a1a1a;
  }
  .file-download-meta {
    color: #666;
  }
  .file-download-btn {
    background: rgba(0, 0, 0, 0.04);
    color: #666;
  }
  .file-download-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #333;
  }
}

/* ── Share-btn Format Picker (compact overlay) ──────────────── */
.share-format-picker {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-format-picker-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.share-format-picker-body {
  position: relative;
  z-index: 1;
  background: var(--primary-bg, #1a1a2e);
  border: 1px solid var(--border-primary, #2a2a4a);
  border-radius: 16px;
  padding: 24px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  text-align: center;
  min-width: 260px;
  animation: fadeIn 0.2s ease;
}

.share-format-picker-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #e0e0e0);
  margin-bottom: 18px;
}

.share-format-picker-title i {
  margin-right: 6px;
  color: var(--primary, #6c63ff);
}

.share-format-picker-options {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.share-fmt-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 20px;
  border-radius: 12px;
  border: 1px solid var(--border-primary, #2a2a4a);
  background: transparent;
  color: var(--text-primary, #e0e0e0);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.share-fmt-btn i {
  font-size: 22px;
}

.share-fmt-btn[data-fmt="pdf"] i { color: #ef4444; }
.share-fmt-btn[data-fmt="docx"] i { color: #3b82f6; }
.share-fmt-btn[data-fmt="zip"] i { color: #f59e0b; }

.share-fmt-btn:hover {
  background: var(--hover-bg, rgba(108, 99, 255, 0.1));
  border-color: var(--primary, #6c63ff);
  transform: translateY(-2px);
}

@media (prefers-color-scheme: light) {
  .share-format-picker-body {
    background: #fff;
    border-color: #e0e0e0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  }
}

/* ══════════════════════════════════════════════════════════════════════
   Sandbox Queue Banner — shown when user is waiting for sandbox pod
   ══════════════════════════════════════════════════════════════════════ */
.sandbox-queue-banner {
  margin: 12px 20px;
  padding: 16px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg,
    rgba(108, 99, 255, 0.08) 0%,
    rgba(59, 130, 246, 0.08) 100%);
  border: 1px solid rgba(108, 99, 255, 0.2);
  animation: sandboxQueueFadeIn 0.4s ease-out;
}

.sandbox-queue-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sandbox-queue-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(108, 99, 255, 0.2);
  border-top: 3px solid var(--primary, #6c63ff);
  border-radius: 50%;
  animation: sandboxQueueSpin 1s linear infinite;
  flex-shrink: 0;
}

.sandbox-queue-text {
  flex: 1;
}

.sandbox-queue-text strong {
  display: block;
  color: var(--text-primary, #e0e0e0);
  font-size: 14px;
  margin-bottom: 4px;
}

.sandbox-queue-text p {
  color: var(--text-secondary, #aaa);
  font-size: 13px;
  margin: 0;
  line-height: 1.4;
}

.sandbox-queue-eta {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(108, 99, 255, 0.12);
  color: var(--primary, #6c63ff);
  font-size: 12px;
  font-weight: 500;
}

@keyframes sandboxQueueFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sandboxQueueSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ── Phone OSINT loading card ────────────────────────────────── */
.phone-loading-overlay {
  display: flex;
  justify-content: flex-start;
  padding: 4px 0;
  animation: phoneLoadingFadeIn 0.3s ease-out;
}

.phone-loading-overlay.phone-loading-fade-out {
  animation: phoneLoadingFadeOut 0.3s ease-in forwards;
}

@keyframes phoneLoadingFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes phoneLoadingFadeOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-8px); }
}

.phone-loading-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  margin: 12px 0;
  border-radius: 12px;
  background: var(--surface-secondary, #1e1e2e);
  border: 1px solid rgba(139, 92, 246, 0.25);
  max-width: 420px;
  animation: phoneLoadingPulse 2s ease-in-out infinite;
}

.phone-loading-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  font-size: 20px;
}

.phone-loading-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(139, 92, 246, 0.25);
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: phoneLoadingSpin 0.8s linear infinite;
}

.phone-loading-text {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary, #aaa);
  line-height: 1.4;
}

@keyframes phoneLoadingPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes phoneLoadingSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* RTL support */
[dir="rtl"] .phone-loading-card {
  flex-direction: row-reverse;
}

/* Light theme */
@media (prefers-color-scheme: light) {
  .phone-loading-card {
    background: #f5f3ff;
    border-color: rgba(139, 92, 246, 0.2);
  }
  .phone-loading-text {
    color: #555;
  }
}