:root {
  --bg-dark: #090d16;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(31, 41, 55, 0.8);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(6, 182, 212, 0.4);
  
  --primary-cyan: #06b6d4;
  --primary-purple: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --font-sans: 'Inter', system-ui, sans-serif;
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  background-image: 
    radial-gradient(at 0% 0%, rgba(6, 182, 212, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header Navbar */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary-cyan), var(--primary-purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

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

.sub-text {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav-metrics {
  display: flex;
  gap: 1rem;
}

.metric-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.85rem;
}

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

.pill-value {
  font-family: var(--font-mono);
  font-weight: 600;
}

.highlight-endpoint {
  color: var(--primary-cyan);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-dim);
}

.status-indicator.online {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

/* Dashboard Container */
.dashboard-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Overview Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.cyan { background: rgba(6, 182, 212, 0.12); color: var(--primary-cyan); }
.stat-icon.emerald { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); }
.stat-icon.rose { background: rgba(244, 63, 94, 0.12); color: var(--accent-rose); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.12); color: var(--primary-purple); }

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-number {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 0.2rem;
}

/* Toolbar & Filters */
.controls-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-box i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.search-box input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-cyan);
  box-shadow: var(--shadow-glow);
}

.filter-group, .view-toggle {
  display: flex;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.25rem;
}

.filter-btn, .toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn.active, .toggle-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Node Cards Grid */
.nodes-grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

.node-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.node-card:hover {
  border-color: var(--border-active);
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.node-card.offline {
  opacity: 0.75;
}

.node-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-rose);
}

.node-card.online::before {
  background: var(--accent-emerald);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.node-info-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.platform-badge-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--primary-cyan);
}

.node-title h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.node-title span {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-badge {
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-badge.online {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.offline {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.metrics-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.metric-bar-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.metric-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.metric-bar-bg {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 9999px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.4s ease;
}

.fill-cpu { background: linear-gradient(90deg, var(--primary-cyan), var(--primary-purple)); }
.fill-mem { background: linear-gradient(90deg, #3b82f6, #8b5cf6); }
.fill-disk { background: linear-gradient(90deg, #f59e0b, #ef4444); }

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.node-actions {
  display: flex;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-cyan), #0284c7);
  color: #fff;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 18px rgba(6, 182, 212, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  color: #fff;
  border-color: var(--primary-cyan);
}

/* Section Cards (Charts / Logs) */
.chart-section, .logs-section {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-header h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.badge {
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(6, 182, 212, 0.15);
  color: var(--primary-cyan);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.purple {
  background: rgba(139, 92, 246, 0.15);
  color: var(--primary-purple);
}

.chart-container {
  height: 260px;
  width: 100%;
}

/* Terminal Log View */
.terminal-window {
  background: #050811;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 1rem;
  height: 180px;
  overflow-y: auto;
}

.log-entry {
  padding: 0.2rem 0;
  color: var(--text-muted);
}

.log-entry.system { color: var(--primary-cyan); }
.log-entry.success { color: var(--accent-emerald); }
.log-entry.error { color: var(--accent-rose); }

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.empty-state i {
  font-size: 2.5rem;
  color: var(--primary-cyan);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 620px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

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

.title-with-icon {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.icon-accent {
  font-size: 1.5rem;
  color: var(--primary-cyan);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.os-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.tab-btn.active {
  background: rgba(6, 182, 212, 0.15);
  color: var(--primary-cyan);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.tab-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.code-block {
  background: #050811;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.code-block code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-emerald);
  word-break: break-all;
}

.btn-copy {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

.modal-info-box {
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-main);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.form-input {
  background: #050811;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: #fff;
  font-family: var(--font-mono);
}

.quick-commands {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

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

.chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  cursor: pointer;
}

.chip:hover {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--primary-cyan);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* ── Master Intelligence Log Components ── */

.machine-detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-main);
  white-space: nowrap;
}

.machine-detail-chip i {
  color: var(--primary-cyan);
  font-size: 0.7rem;
}

/* Intel log entry variants */
.log-entry.intel-keystroke {
  color: #fbbf24;
  border-left: 2px solid rgba(251, 191, 36, 0.3);
  padding-left: 0.5rem;
}

.log-entry.intel-click {
  color: #34d399;
  border-left: 2px solid rgba(52, 211, 153, 0.3);
  padding-left: 0.5rem;
}

.log-entry.intel-scroll {
  color: #a78bfa;
  border-left: 2px solid rgba(167, 139, 250, 0.3);
  padding-left: 0.5rem;
}

/* Intel section filter selects hover */
#intelNodeFilter:focus,
#intelTypeFilter:focus,
#intelSearchInput:focus {
  outline: none;
  border-color: var(--primary-purple) !important;
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.2);
}

#intelNodeFilter option,
#intelTypeFilter option {
  background: #0f172a;
  color: #fff;
}

/* ── File Binder Dropzone ── */
.binder-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(15, 23, 42, 0.4);
}

.binder-dropzone:hover {
  border-color: var(--primary-cyan);
  background: rgba(6, 182, 212, 0.06);
  box-shadow: var(--shadow-glow);
}

.binder-dropzone.has-file {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.06);
}

#binderStatus.success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--accent-emerald);
}

#binderStatus.error {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: var(--accent-rose);
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
  .top-nav {
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }
  .dashboard-container {
    padding: 1rem;
    gap: 1rem;
  }
  .action-area {
    flex-wrap: wrap;
    width: 100%;
  }
  .action-area .btn {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.75rem;
    padding: 0.45rem 0.7rem;
  }
  .nav-metrics {
    display: none;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  .stat-card {
    padding: 0.75rem 1rem;
  }
  .stat-number {
    font-size: 1.25rem;
  }
  .nodes-grid-view {
    grid-template-columns: 1fr;
  }
  .controls-toolbar {
    flex-direction: column;
  }
  .search-box {
    min-width: 100%;
  }
  .modal-card {
    width: 95%;
    max-width: 95%;
  }
  .os-tabs {
    flex-wrap: wrap;
  }
  .os-tabs .tab-btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.6rem;
  }
  #machineDetailsBar {
    flex-direction: column;
    gap: 0.3rem;
  }
}
