/* ============================================================
   DATA VISUALIZATION DISPLAY WALL - MAIN STYLESHEET
   Premium dark-theme monitoring dashboard
   ============================================================ */

/* ---- CSS Variables / Design Tokens ---- */
:root {
  /* Colors */
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1629;
  --bg-card: rgba(15, 22, 50, 0.65);
  --bg-card-hover: rgba(20, 30, 65, 0.75);
  --bg-input: rgba(15, 20, 45, 0.8);

  --border-color: rgba(99, 102, 241, 0.12);
  --border-hover: rgba(99, 102, 241, 0.3);

  --text-primary: #e8ecf4;
  --text-secondary: #8892b0;
  --text-muted: #5a6380;

  /* Accent Colors */
  --accent-indigo: #6366f1;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #a855f7;
  --accent-blue: #3b82f6;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #6366f1, #06b6d4);
  --gradient-cpu: linear-gradient(135deg, #6366f1, #818cf8);
  --gradient-mem: linear-gradient(135deg, #06b6d4, #22d3ee);
  --gradient-disk: linear-gradient(135deg, #f59e0b, #fbbf24);
  --gradient-bandwidth: linear-gradient(135deg, #10b981, #34d399);
  --gradient-servers: linear-gradient(135deg, #a855f7, #c084fc);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-indigo: 0 0 30px rgba(99, 102, 241, 0.15);
  --shadow-glow-cyan: 0 0 30px rgba(6, 182, 212, 0.15);

  /* Sizing */
  --header-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Typography */
  --font-sans: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Cascadia Mono', 'Consolas', 'Liberation Mono', monospace;
}

:root.light-theme {
  --bg-primary: #f5f7fb;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --bg-input: #ffffff;
  --border-color: rgba(99, 102, 241, 0.1);
  --border-hover: rgba(99, 102, 241, 0.25);
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

:root.light-theme .bg-grid {
  background-image:
    linear-gradient(rgba(99, 102, 241, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.06) 1px, transparent 1px);
}

:root.light-theme .header {
  background: rgba(255, 255, 255, 0.8);
}

:root.light-theme .stat-card {
  background: #ffffff;
}

:root.light-theme .chart-card {
  background: #ffffff;
}

:root.light-theme .chart-footer {
  background: rgba(0, 0, 0, 0.02);
}

:root.light-theme .pagination-footer {
  background: rgba(255, 255, 255, 0.6);
}

:root.light-theme .server-table th {
  background: rgba(0, 0, 0, 0.03);
}

:root.light-theme .modal {
  background: #ffffff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

:root.light-theme .modal-overlay {
  background: rgba(255, 255, 255, 0.4);
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
}

/* ---- Animated Background ---- */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  z-index: 0;
  pointer-events: none;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px); /* Reduced from 120px to save GPU fill rate */
  opacity: 0.3;
  z-index: 0;
  pointer-events: none;
  animation: glowFloat 30s ease-in-out infinite; /* Slower = lighter */
  will-change: transform;
}

.bg-glow-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.1), transparent 70%);
  top: -100px;
  left: -50px;
  animation-delay: 0s;
}

.bg-glow-2 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.08), transparent 70%);
  bottom: -100px;
  right: -50px;
  animation-delay: -7s;
}

.bg-glow-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.1), transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
}

@keyframes glowFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(25px, 15px) scale(1.02); }
}

/* ---- App Container ---- */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Header ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(8px); /* Reduced from 20px */
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.server-count,
.source-count {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
}

.dot-pulse {
  animation: pulse 2s ease-in-out infinite;
  will-change: opacity, box-shadow;
  transform: translateZ(0);
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }

  50% {
    opacity: 0.7;
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
}

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

.clock {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.btn-settings {
  width: 40px;
  height: 40px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-settings svg {
  width: 18px;
  height: 18px;
}

.btn-settings:hover {
  border-color: var(--border-hover);
  color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.08);
  transform: rotate(30deg);
}

/* ---- Global Refresh Button ---- */
.btn-refresh-global {
  width: 40px;
  height: 40px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-refresh-global:hover {
  border-color: var(--border-hover);
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
  transform: translateY(-2px);
}

.btn-refresh-global svg {
  width: 20px;
  height: 20px;
}

/* ---- Theme Switch ---- */
.theme-switch-wrapper {
  display: flex;
  align-items: center;
}

.theme-switch {
  display: inline-block;
  height: 28px;
  position: relative;
  width: 54px;
}

.theme-switch input {
  display: none;
}

.slider {
  background-color: var(--bg-card);
  bottom: 0;
  cursor: pointer;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: .4s;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.slider:before {
  background-color: #fff;
  bottom: 3px;
  content: "";
  height: 20px;
  left: 4px;
  position: absolute;
  transition: .4s;
  width: 20px;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--accent-indigo);
  border-color: var(--accent-indigo);
}

input:checked+.slider:before {
  transform: translateX(24px);
}

.theme-icon {
  width: 14px;
  height: 14px;
  z-index: 1;
  transition: opacity 0.3s;
}

.sun-icon {
  color: #fbbf24;
}

.moon-icon {
  color: #cbd5e1;
}

/* ---- Gauge Time ---- */
.title-time {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-indigo);
  opacity: 0.9;
  margin-top: 3px;
}

:root.light-theme .title-time {
  color: var(--accent-blue);
}

/* ---- Dashboard Layout ---- */
.dashboard {
  padding: 24px 28px 40px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ---- Stat Cards ---- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: all 0.3s ease;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  opacity: 0.8;
}

.stat-card-servers::before {
  background: var(--gradient-servers);
}

.stat-card-cpu::before {
  background: var(--gradient-cpu);
}

.stat-card-mem::before {
  background: var(--gradient-mem);
}

.stat-card-disk::before {
  background: var(--gradient-disk);
}

.stat-card-bandwidth::before {
  background: var(--gradient-bandwidth);
}

.stat-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.stat-card-servers .stat-card-icon {
  background: rgba(168, 85, 247, 0.1);
  color: var(--accent-purple);
}

.stat-card-cpu .stat-card-icon {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-indigo);
}

.stat-card-mem .stat-card-icon {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
}

.stat-card-disk .stat-card-icon {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-amber);
}

.stat-card-bandwidth .stat-card-icon {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
}

.stat-card-icon svg {
  width: 24px;
  height: 24px;
}

.stat-card-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

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

.stat-card-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-card-value-group {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stat-card-value-group .stat-card-value {
  font-size: 1.3rem; /* Slightly smaller to fit two in one row */
}

.stat-card-separator {
  font-size: 1rem;
  color: var(--text-muted);
  opacity: 0.5;
  font-weight: 300;
}

.stat-card-servers .stat-card-value {
  color: var(--accent-purple);
}

.stat-card-cpu .stat-card-value {
  color: var(--accent-indigo);
}

.stat-card-mem .stat-card-value {
  color: var(--accent-cyan);
}

.stat-card-disk .stat-card-value {
  color: var(--accent-amber);
}

.stat-card-bandwidth .stat-card-value {
  color: var(--accent-emerald);
}

.stat-card-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ---- Charts Section ---- */
.charts-section {
  display: grid;
  grid-template-columns: 4fr 1.5fr;
  gap: 16px;
  margin-bottom: 24px;
}

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

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  overflow: hidden;
  transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.chart-card:hover {
  border-color: var(--border-hover);
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 0;
}

.chart-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.source-select {
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.source-select:hover {
  border-color: var(--border-hover);
  background: rgba(99, 102, 241, 0.05);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  transition: width 0.35s cubic-bezier(0.19, 1, 0.22, 1);
  width: auto;
}

#serverSearchFilter {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 14px 8px 38px;
  color: var(--text-primary);
  font-size: 0.88rem;
  width: 220px; /* Base width */
  outline: none;
  transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

#serverSearchFilter::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
  font-size: 0.82rem;
}

#serverSearchFilter:hover {
  border-color: var(--border-hover);
  background: rgba(99, 102, 241, 0.04);
}

#serverSearchFilter:focus {
  border-color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 
    0 0 0 3px rgba(99, 102, 241, 0.1),
    0 10px 20px -10px rgba(0, 0, 0, 0.3);
  width: 320px; /* Expand on focus */
}

/* Custom Clear Button Style */
#serverSearchFilter::-webkit-search-cancel-button {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'></line><line x1='6' y1='6' x2='18' y2='18'></line></svg>");
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer;
  opacity: 0.4;
  margin-right: 2px;
  transition: opacity 0.2s;
}

#serverSearchFilter::-webkit-search-cancel-button:hover {
  opacity: 0.8;
}

@media (max-width: 600px) {
  #serverSearchFilter:focus {
    width: 100%;
  }
}

.search-box .search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
  transition: all 0.3s ease;
}

#serverSearchFilter:focus + .search-icon {
  color: var(--accent-indigo);
  transform: scale(1.1) translateY(-0.5px);
}

.btn-icon-sm {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-icon-sm:hover {
  border-color: var(--border-hover);
  color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.05);
  transform: rotate(-15deg);
}

.btn-icon-sm svg {
  width: 16px;
  height: 16px;
}

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

.chart-title-icon {
  width: 18px;
  height: 18px;
  color: var(--accent-indigo);
}

.chart-legend {
  display: flex;
  gap: 24px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.3s ease;
}

.legend-item.disabled {
  opacity: 0.35;
}

.legend-dot {
  width: 10px;
  height: 3px;
  border-radius: 2px;
}

.legend-rx {
  background: var(--accent-cyan);
}

.legend-tx {
  background: var(--accent-indigo);
}

.legend-p95 {
  background: var(--accent-rose);
  height: 2px;
  width: 12px;
  border-top: 1px dashed var(--accent-rose);
  background: transparent;
}

.chart-body {
  padding: 12px 22px;
  height: 280px;
}

.chart-body canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-footer {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.15);
}

.traffic-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.traffic-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.traffic-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.traffic-stat-total .traffic-value {
  color: var(--accent-cyan);
}

.traffic-stat-p95 .traffic-value {
  color: var(--accent-rose);
}

.traffic-stat-time .traffic-value {
  color: var(--accent-cyan);
}

/* ---- Globe Card ---- */
.globe-card {
  display: flex;
  flex-direction: column;
}

.globe-body {
  height: 280px; /* Match chart-body height exactly */
  padding: 0; /* Remove padding to avoid ECharts coordinate mismatch */
  position: relative;
  overflow: hidden;
  cursor: grab;
}

.globe-body:active {
  cursor: grabbing;
}

/* ---- Gauges ---- */
.gauges-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 24px 16px 32px;
}

.gauge-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge {
  position: relative;
  width: 100px;
  height: 100px;
}

.gauge svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.04);
  stroke-width: 8;
}

.gauge-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-fill-cpu {
  stroke: url(#gaugeCpuGrad);
}

.gauge-fill-ram {
  stroke: url(#gaugeRamGrad);
}

.gauge-fill-disk {
  stroke: url(#gaugeDiskGrad);
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-value {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.gauge-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

/* ---- Server Table ---- */
.server-table-wrap {
  overflow-x: auto;
  padding: 16px 22px 8px;
}

.server-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.server-table thead {
  position: sticky;
  top: 0;
}

.server-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.server-table th.sortable {
  cursor: pointer;
  position: relative;
  user-select: none;
}

.server-table th.sortable:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-primary);
}

.server-table th.sortable.active {
  color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.05);
  border-bottom-color: var(--accent-indigo);
}

.sort-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  vertical-align: middle;
  margin-left: 4px;
  opacity: 0.3;
  transition: all 0.2s ease;
  position: relative;
}

.server-table th.sortable.active .sort-icon {
  opacity: 1;
}

.sort-icon::after {
  content: '↕';
  font-size: 0.8rem;
}

.server-table th.sortable.active[data-dir="asc"] .sort-icon::after {
  content: '↑';
}

.server-table th.sortable.active[data-dir="desc"] .sort-icon::after {
  content: '↓';
}

.server-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.05);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.server-table tbody tr {
  transition: background 0.2s ease;
}

.server-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

.server-table .empty-row td {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot-online {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.status-dot-offline {
  background: var(--accent-rose);
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.4);
}

/* Pagination Footer */
.pagination-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 22px;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.page-size-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-controls {
  display: flex;
  gap: 4px;
}

.page-btn {
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.2s;
}

.page-btn:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--accent-indigo);
  color: var(--accent-indigo);
}

.page-btn.active {
  background: var(--accent-indigo);
  color: white;
  border-color: var(--accent-indigo);
}

.page-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Server Detail Modal Enhancements */
.detail-container {
  display: flex;
  flex-direction: column;
}

.detail-metrics-list {
  display: flex;
  flex-direction: column;
  padding: 10px;
}

.metric-item {
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: all 0.3s ease;
}

.metric-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}

.metric-item-header:hover {
  background: rgba(99, 102, 241, 0.05);
}

.metric-label-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.metric-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-indigo);
}

.metric-item-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(0, 0, 0, 0.1);
  border-top: 0px solid transparent;
}

.metric-item.active .metric-item-content {
  max-height: 350px;
  border-top: 1px solid var(--border-color);
}

.metric-item.active {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: var(--accent-indigo);
}

.chart-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
}

.time-range-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.time-range-selector {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.time-range-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.time-range-btn:hover {
  color: var(--text-primary);
}

.time-range-btn.active {
  background: var(--accent-indigo);
  color: white;
}

.custom-range-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px 2px 2px 10px;
}

.custom-range-input {
  width: 90px;
  background: transparent;
  border: none;
  font-size: 0.75rem;
  color: var(--text-primary);
  outline: none;
  font-family: var(--font-mono);
}

.absolute-range-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px 2px 2px 10px;
}

.time-input {
  background: transparent;
  border: none;
  font-size: 0.75rem;
  color: var(--text-primary);
  outline: none;
  font-family: var(--font-mono);
  padding: 2px 0;
}

/* Specific styling for datetime-local icon/color in some browsers */
.time-input::-webkit-calendar-picker-indicator {
  filter: invert(0.5);
  cursor: pointer;
}

.light-theme .time-input::-webkit-calendar-picker-indicator {
  filter: invert(0);
}

.btn-custom-go {
  padding: 4px 8px;
  font-size: 0.7rem;
  border: none;
  background: var(--accent-indigo);
  color: white;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-custom-go:hover {
  opacity: 0.9;
}

.detail-chart-wrapper {
  height: 200px;
  padding: 0 10px 10px 10px;
  position: relative;
}

.detail-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-color);
  margin-top: 10px;
}

.info-item {
  background: var(--bg-card);
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.info-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.info-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Partitions List for detail view */
.detail-partitions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px; /* Match metric header padding horizontal */
}

.partition-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.partition-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.partition-mount {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.partition-usage-text {
  color: var(--text-secondary);
}

.partition-progress {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.partition-bar {
  height: 100%;
  background: var(--accent-amber);
  border-radius: 3px;
}

.chevron-icon {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
  color: var(--text-secondary);
}

.metric-item.active .chevron-icon {
  transform: rotate(180deg);
  color: var(--accent-indigo);
}

/* Light Theme Adjustments */
.light-theme .metric-item-content {
  background: rgba(0, 0, 0, 0.02);
}

.light-theme .detail-info-grid {
  background: var(--border-color);
}

/* Usage bars in table */
.usage-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.usage-bar-track {
  width: 60px;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

.usage-bar-fill-cpu {
  background: var(--accent-indigo);
}

.usage-bar-fill-mem {
  background: var(--accent-cyan);
}

.usage-bar-fill-disk {
  background: var(--accent-amber);
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 90%;
  max-width: 720px;
  max-height: 80vh;
  max-height: 80dvh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

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

.modal-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---- Modal Tabs ---- */
.modal-tabs {
  display: flex;
  gap: 16px;
}

.modal-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 8px 4px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.modal-tab:hover {
  color: var(--text-primary);
}

.modal-tab.active {
  color: var(--text-primary);
}

.modal-tab.active::after {
  content: '';
  position: absolute;
  bottom: -21px;
  /* Align with header border */
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
  z-index: 1;
}

.tab-content {
  display: none;
}

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

/* ---- Logo Styling ---- */
#logoIconContainer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 36px;
  width: auto;
  max-width: 250px;
  flex-shrink: 0;
}

.logo-icon-img {
  height: 100%;
  width: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  max-width: 100%;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(80vh - 80px);
  max-height: calc(80dvh - 80px);
}

/* ---- Add Source Form ---- */
.add-source-form h3,
.source-list h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  align-items: flex-end;
}

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

.form-group-wide {
  flex: 2;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s;
}

.form-group input:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-test {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.btn-test:hover {
  background: rgba(6, 182, 212, 0.2);
}

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

.btn-add:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-delete {
  padding: 6px 12px;
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.btn-delete:hover {
  background: rgba(244, 63, 94, 0.2);
}

.form-message {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  display: none;
}

.form-message.success {
  display: block;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
}

.form-message.error {
  display: block;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
}

/* ---- Source List ---- */
.source-list {
  margin-top: 24px;
}

.source-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.source-item:hover {
  border-color: var(--border-hover);
}

.source-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.source-item-url {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.source-item-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.source-status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.source-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.source-type-badge.type-server {
  background: rgba(99, 102, 241, 0.1);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.source-type-badge.type-other {
  background: rgba(139, 92, 246, 0.1);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.source-status-online {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
}

.source-status-offline {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
}

.source-empty {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.source-item-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---- Server Detail Grid ---- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 10px;
}

.detail-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.detail-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-indigo);
}

:root.light-theme .detail-value {
  color: var(--accent-blue);
}

/* ---- Animations ---- */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-card {
  animation: fadeInUp 0.5s ease forwards;
}

.stat-card:nth-child(1) {
  animation-delay: 0.05s;
}

.stat-card:nth-child(2) {
  animation-delay: 0.1s;
}

.stat-card:nth-child(3) {
  animation-delay: 0.15s;
}

.stat-card:nth-child(4) {
  animation-delay: 0.2s;
}

.stat-card:nth-child(5) {
  animation-delay: 0.25s;
}

.chart-card {
  animation: fadeInUp 0.5s ease 0.3s forwards;
  opacity: 0;
}

.server-list-section .chart-card {
  animation-delay: 0.4s;
}

/* Value update animation */
/* Value update flash disabled */

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

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

::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.3);
}

/* ---- Responsive ---- */
@media (max-width: 1280px) {
  .stat-cards {
    grid-template-columns: repeat(3, 1fr);
  }

  .charts-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  /* -- Header -- */
  .header {
    padding: 0 12px;
    height: 52px;
  }

  .header-meta {
    display: none;
  }

  .logo {
    gap: 8px;
  }

  .logo-text {
    font-size: 0.92rem;
  }

  #logoIconContainer {
    width: auto;
    height: 30px;
    max-width: 180px;
  }
  
  .logo-icon {
    width: 26px;
    height: 26px;
  }

  .header-right {
    gap: 10px;
  }

  .theme-switch {
    width: 44px;
    height: 24px;
  }

  .slider:before {
    height: 16px;
    width: 16px;
  }

  input:checked+.slider:before {
    transform: translateX(18px);
  }

  .btn-settings {
    width: 34px;
    height: 34px;
  }

  .btn-settings svg {
    width: 16px;
    height: 16px;
  }

  /* -- Dashboard -- */
  .dashboard {
    padding: 14px 12px 32px;
  }

  /* -- Stat Cards -- */
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat-card {
    padding: 14px 14px;
    gap: 12px;
  }

  .stat-card-icon {
    width: 38px;
    height: 38px;
  }

  .stat-card-icon svg {
    width: 20px;
    height: 20px;
  }

  .stat-card-value {
    font-size: 1.15rem;
  }

  .stat-card-value-group .stat-card-value {
    font-size: 1rem;
  }

  .stat-card-label {
    font-size: 0.68rem;
  }

  .stat-card-sub {
    font-size: 0.65rem;
  }

  /* -- Charts Section -- */
  .charts-section {
    gap: 12px;
    margin-bottom: 16px;
  }

  .chart-card-header {
    padding: 14px 14px 0;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  #networkChart .chart-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .chart-title {
    font-size: 0.82rem;
  }

  .chart-legend {
    gap: 12px;
    font-size: 0.72rem;
  }

  .chart-body {
    padding: 8px 10px;
    height: 220px;
  }

  .chart-footer {
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 12px 14px;
    justify-content: flex-start;
  }

  .traffic-label {
    font-size: 0.62rem;
  }

  .traffic-value {
    font-size: 0.78rem;
  }

  /* -- Globe Card -- */
  .globe-body {
    height: 240px;
  }

  /* -- Server Table Section -- */
  .chart-header-right {
    gap: 8px;
    flex-wrap: wrap;
  }

  #serverSearchFilter {
    width: 160px;
    padding: 6px 10px 6px 32px;
    font-size: 0.8rem;
  }

  #serverSearchFilter:focus {
    width: 200px;
  }

  .search-box .search-icon {
    left: 10px;
    width: 14px;
    height: 14px;
  }

  .source-select {
    font-size: 0.78rem;
    padding: 5px 8px;
  }

  .server-table-wrap {
    padding: 10px 8px 4px;
  }

  .server-table {
    min-width: 640px;
  }

  .server-table th {
    padding: 8px 10px;
    font-size: 0.65rem;
  }

  .server-table td {
    padding: 8px 10px;
    font-size: 0.72rem;
  }

  .usage-bar-track {
    width: 40px;
  }

  /* -- Pagination -- */
  .pagination-footer {
    flex-direction: column;
    gap: 10px;
    padding: 10px 14px;
    align-items: flex-start;
  }

  .pagination-controls {
    flex-wrap: wrap;
    gap: 3px;
  }

  .page-btn {
    padding: 3px 8px;
    font-size: 0.75rem;
  }

  /* -- Modal -- */
  .modal {
    width: 96%;
    max-width: none;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: var(--radius-md);
  }

  .modal-header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .modal-tabs {
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1;
    min-width: 0;
  }

  .modal-tabs::-webkit-scrollbar {
    display: none;
  }

  .modal-tab {
    font-size: 0.8rem;
    padding: 6px 8px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .modal-tab.active::after {
    bottom: -15px;
  }

  .modal-body {
    padding: 16px 14px;
    max-height: calc(90vh - 70px);
    max-height: calc(90dvh - 70px);
  }

  /* -- Server Detail Modal -- */
  #serverDetailModal .modal {
    width: 98%;
    max-height: 92vh;
    max-height: 92dvh;
  }

  #serverDetailModal .modal-body {
    max-height: calc(92vh - 60px);
    max-height: calc(92dvh - 60px);
  }

  .detail-metrics-list {
    padding: 6px;
  }

  .metric-item-header {
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap; /* Force single line as requested */
  }

  .metric-label-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: 0;
  }

  .metric-label {
    font-size: 0.82rem;
    white-space: nowrap; /* Don't wrap */
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .metric-value {
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .chart-controls {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
    padding: 8px 10px;
  }

  .time-range-group {
    flex-wrap: wrap;
    gap: 6px;
  }

  .time-range-btn {
    padding: 3px 8px;
    font-size: 0.7rem;
  }

  .custom-range-input {
    width: 70px;
    font-size: 0.7rem;
  }

  .absolute-range-selector {
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 6px;
  }

  .time-input {
    font-size: 0.68rem;
  }

  .detail-chart-wrapper {
    height: 180px;
    padding: 0 6px 6px;
  }

  .metric-item.active .metric-item-content {
    max-height: 300px;
  }

  .detail-info-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .info-label {
    font-size: 0.68rem;
  }

  .info-value {
    font-size: 0.85rem;
  }

  /* -- Partition details -- */
  .partition-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 0.75rem;
  }

  /* -- Forms -- */
  .form-row {
    flex-direction: column;
  }

  .form-actions {
    flex-direction: row;
    width: 100%;
  }

  .form-actions .btn {
    flex: 1;
    text-align: center;
  }

  .form-group input {
    font-size: 0.82rem;
    padding: 9px 12px;
  }

  .add-source-form h3,
  .source-list h3 {
    font-size: 0.78rem;
  }

  .btn {
    padding: 9px 14px;
    font-size: 0.78rem;
  }

  /* -- Login Button -- */
  .btn-login {
    padding: 6px 12px;
    font-size: 0.78rem;
  }

  /* -- Source Items -- */
  .source-item {
    padding: 10px 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .source-item-actions {
    align-self: flex-end;
  }

  .source-item-name {
    font-size: 0.82rem;
    flex-wrap: wrap;
    gap: 6px;
  }

  /* -- User section -- */
  #userSection {
    display: flex;
    align-items: center;
  }

  #userSection .user-info {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  #userSection .username {
    display: none;
  }

  #userSection .btn-logout {
    padding: 5px 10px;
    font-size: 0.72rem;
  }

  /* -- Globe expansion on mobile -- */
  .globe-card.expanded {
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    border-radius: 0;
  }

  .globe-card.expanded .globe-body {
    height: calc(100vh - 110px) !important;
    height: calc(100dvh - 110px) !important;
    min-height: 200px;
  }

  /* Touch optimization */
  .server-table tbody tr {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.1);
  }

  .btn,
  .btn-icon,
  .btn-icon-sm,
  .btn-settings,
  .page-btn,
  .modal-tab,
  .time-range-btn {
    touch-action: manipulation;
  }
}

@media (max-width: 480px) {
  .stat-cards {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .stat-card {
    flex-direction: row;
    padding: 12px 14px;
  }

  .logo-text {
    font-size: 0.82rem;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chart-legend {
    gap: 8px;
    font-size: 0.68rem;
    width: 100%;
    justify-content: flex-start;
  }

  .chart-body {
    height: 180px;
  }

  .globe-body {
    height: 200px;
  }

  #serverSearchFilter {
    width: 120px;
    font-size: 0.75rem;
  }

  #serverSearchFilter:focus {
    width: 160px;
  }

  .detail-info-grid {
    grid-template-columns: 1fr 1fr;
  }

  .info-item {
    padding: 10px;
  }

  /* -- Metric content on very small screens -- */
  .metric-item.active .metric-item-content {
    max-height: 380px;
  }

  .detail-chart-wrapper {
    height: 160px;
  }

  .source-select {
    display: none !important;
  }

  .server-table th,
  .server-table td {
    white-space: nowrap;
  }

  /* Server Detail Modal Full Screen for better fit on phone */
  #serverDetailModal .modal {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    padding-bottom: env(safe-area-inset-bottom);
  }

  #serverDetailModal .modal-body {
    max-height: calc(100vh - 60px) !important;
    max-height: calc(100dvh - 60px) !important;
  }

  /* Metric titles no wrap (as requested) */
  .metric-item-header, .metric-label-group {
    flex-wrap: nowrap !important;
  }

  .metric-label {
    white-space: nowrap !important;
  }

  /* -- Modal full width -- */
  .modal {
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    height: 100vh;
    height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal-body {
    max-height: calc(100vh - 60px);
    max-height: calc(100dvh - 60px);
  }

  /* -- Latency route items on small mobile -- */
  .latency-route-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  .route-actions {
    align-self: flex-end !important;
  }

  /* -- Chart card header vertical layout -- */
  .chart-card-header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .chart-header-right {
    width: auto;
    flex: 1;
    justify-content: flex-end;
  }

  /* -- Traffic footer compact -- */
  .chart-footer {
    justify-content: center;
    text-align: center;
  }

  .traffic-stat {
    align-items: center;
  }
}

@media (max-width: 360px) {
  .header {
    padding: 0 8px;
  }

  .dashboard {
    padding: 10px 8px 24px;
  }

  .stat-card-icon {
    width: 32px;
    height: 32px;
  }

  .stat-card-icon svg {
    width: 18px;
    height: 18px;
  }

  .stat-card-value {
    font-size: 1rem;
  }

  .logo-text {
    max-width: 120px;
    font-size: 0.78rem;
  }

  .chart-card-header {
    padding: 10px 10px 0;
  }

  .chart-footer {
    padding: 10px;
    gap: 8px 14px;
  }

  .chart-legend {
    flex-wrap: wrap;
  }

  #serverSearchFilter {
    width: 100%;
    min-width: 80px;
    max-width: 100px;
  }

  #serverSearchFilter:focus {
    max-width: 130px;
  }

  .source-select {
    max-width: 80px;
  }

  .detail-info-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Globe Card Expansion ---- */
.globe-card.expanded {
    position: fixed;
    top: 5vh;
    left: 2.5vw;
    width: 95vw !important;
    height: 90vh !important;
    z-index: 9999;
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.8), 0 0 0 100vh rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(20px);
    margin: 0 !important;
    display: flex !important;
    flex-direction: column;
    border-color: var(--accent-indigo);
}

/* Ensure children are visible */
.globe-card.expanded > * {
    opacity: 1 !important;
}

.globe-card.globe-collapsing {
    pointer-events: none;
}

.globe-card.expanded .globe-body {
    height: calc(90vh - 120px) !important; /* Explicit calc height for ECharts reliability */
    width: 100% !important;
    flex: none; 
    min-height: 400px;
}

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

.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    outline: none;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--accent-indigo);
}

.btn-icon.active {
    color: var(--accent-indigo);
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-indigo);
}

/* ---- Footer ---- */
.site-footer {
  margin-top: 40px;
  padding: 30px 28px;
  border-top: 1px solid var(--border-color);
  background: rgba(10, 14, 26, 0.4);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 10;
}

:root.light-theme .site-footer {
  background: rgba(255, 255, 255, 0.4);
}

.footer-content {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-content.only-copyright {
  justify-content: center;
}

.copyright {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}

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

.filing-sep {
  display: none;
  width: 1px;
  height: 12px;
  background: var(--text-muted);
  opacity: 0.3;
}

@media (min-width: 768px) {
  .filing-sep {
    display: block;
  }
}

.filings a {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
  display: flex;
  align-items: center;
}

.filings a:hover {
  color: var(--accent-indigo);
}

@media (max-width: 768px) {
  .site-footer {
    padding: 24px 16px;
    margin-top: 20px;
  }
  
  .footer-content {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  
  .filings {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .filings a {
    justify-content: center;
  }
}

/* ---- Source Settings Toggles ---- */
/* ---- Source Settings Toggles ---- */
.source-options-clean-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 4px 0;
}

.source-option-item {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.source-option-item:hover .source-option-label {
  color: var(--text-primary);
}

.source-option-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.switch-wrapper {
  position: relative;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}

.switch-input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-label {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-input);
  transition: .35s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-color);
  border-radius: 34px;
}

.switch-label:before {
  position: absolute;
  content: '';
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  transition: .35s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
}

.switch-input:checked + .switch-label {
  background-color: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-indigo);
}

.switch-input:checked + .switch-label:before {
  transform: translateX(18px);
  background-color: var(--accent-indigo);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

/* Light theme support */
:root.light-theme .switch-label:before {
  background-color: #94a3b8;
}

