:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: #131c31;
  --bg-card-hover: #18233c;
  --bg-input: #0c1322;
  --border-color: #1e293b;
  --border-active: #38bdf8;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.2);
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-purple-glow: rgba(139, 92, 246, 0.2);
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.25);
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.2);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Animations */
@keyframes pulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

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

.pulse-online {
  animation: pulseGreen 2s infinite;
}

/* App Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.app-header {
  height: 64px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 16px var(--accent-cyan-glow);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #f8fafc, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  padding: 2px 7px;
  border-radius: 9999px;
  font-weight: 600;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

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

/* Main Layout: Sidebar + Main Content */
.main-content {
  display: grid;
  grid-template-columns: 340px 1fr;
  flex: 1;
  min-height: calc(100vh - 64px);
}

@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

/* Sidebar */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.sidebar-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.server-stats-badge {
  font-size: 0.75rem;
  background: var(--bg-card);
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--accent-cyan);
}

.server-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.server-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.server-item:hover {
  background: var(--bg-card-hover);
  border-color: #2e3d5b;
  transform: translateY(-1px);
}

.server-item.active {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.server-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.server-name-group {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online {
  background-color: var(--accent-green);
}

.status-dot.offline {
  background-color: #475569;
}

.server-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.server-item-nodeid {
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(0,0,0,0.2);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  max-width: 100%;
}

.server-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Dashboard Area */
.dashboard-area {
  padding: 24px 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (max-width: 600px) {
  .dashboard-area {
    padding: 16px;
  }
}

.server-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.server-info-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.server-title {
  font-size: 1.35rem;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
}

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

.badge-offline {
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.3);
}

.banner-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Stat Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: #2b3a56;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.stat-unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
}

.stat-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 1100px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

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

.chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-stats-pill {
  font-size: 0.75rem;
  background: rgba(0,0,0,0.25);
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--text-secondary);
}

/* SVG Chart */
.svg-chart-container {
  width: 100%;
  height: 220px;
  position: relative;
}

.svg-chart {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, #06b6d4, #0284c7);
  color: white;
  box-shadow: 0 2px 10px var(--accent-cyan-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0891b2, #0369a1);
  box-shadow: 0 4px 14px var(--accent-cyan-glow);
}

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

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

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fadeIn 0.15s ease-out;
}

.modal-card {
  background: #111827;
  border: 1px solid #1f293d;
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

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

.input-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.input-field {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.92rem;
  outline: none;
}

.input-field:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--accent-cyan-glow);
}

.error-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: 16px;
  gap: 12px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  opacity: 0.6;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state-desc {
  font-size: 0.85rem;
  max-width: 400px;
  line-height: 1.5;
}

/* Raw JSON inspector */
.raw-json-box {
  background: #080c14;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px;
  font-family: monospace;
  font-size: 0.8rem;
  color: #38bdf8;
  max-height: 250px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Metric Details Sections */
.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 1200px) {
  .details-grid {
    grid-template-columns: 1fr;
  }
}

.metric-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.metric-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
}

.metric-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-section-icon {
  font-size: 1.25rem;
}

/* IP Badges & Tags */
.ip-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ip-group-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ip-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 6px 12px;
  font-family: monospace;
  font-size: 0.85rem;
  color: #38bdf8;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: all;
}

.ip-badge:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: #38bdf8;
  transform: translateY(-1px);
}

.ip-badge .ip-tag-type {
  font-size: 0.65rem;
  font-family: var(--font-family);
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

.ip-badge.ipv6 {
  font-size: 0.78rem;
  color: #c084fc;
}

.ip-badge.ipv6:hover {
  background: rgba(192, 132, 252, 0.12);
  border-color: #c084fc;
}

/* Open Connections / Net */
.net-stats-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.net-stat-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.net-stat-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.net-stat-num {
  font-size: 1.8rem;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.net-stat-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* CPU Cores Grid */
.core-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.core-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s ease;
}

.core-item:hover {
  border-color: var(--accent-cyan);
}

.core-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.core-label {
  font-weight: 600;
  color: var(--text-secondary);
}

.core-val {
  font-weight: 700;
  font-family: monospace;
}

.core-mhz {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: monospace;
}

.core-progress-track {
  height: 5px;
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 2px;
}

.core-progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* Memory & Swap Bars */
.mem-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 16px;
}

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

.mem-block-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mem-bar-track {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.mem-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.3s ease;
}

.mem-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mem-chip {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.mem-chip-val {
  font-weight: 600;
  color: var(--text-primary);
  font-family: monospace;
}

/* Disks List */
.disks-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.disk-row {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease;
}

.disk-row:hover {
  border-color: #2b3a56;
}

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

.disk-mount-badge {
  font-weight: 700;
  font-size: 0.95rem;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 8px;
}

.disk-device-tag {
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
}

.disk-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.disk-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.disk-footer-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}
