:root {
  --bg-primary: #0a0a0a;
  --bg-card: #1a1a1a;
  --bg-card-hover: #222;
  --border: #2a2a2a;
  --border-hover: #3a3a3a;
  --text-primary: #fff;
  --text-secondary: #e0e0e0;
  --text-muted: #888;
  --text-dim: #666;
  --text-faint: #444;
  --accent: #667eea;
  --accent-hover: #764ba2;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --chart-grid: #2a2a2a;
  --input-bg: #2a2a2a;
  --input-border: #3a3a3a;
  --gradient-cpu: linear-gradient(90deg, #667eea, #764ba2);
  --gradient-memory: linear-gradient(90deg, #f093fb, #f5576c);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-secondary);
  min-height: 100vh;
  padding: 40px 20px;
  transition: background 0.3s, color 0.3s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.container { max-width: 1400px; margin: 0 auto; position: relative; }

/* Header */
.header { text-align: center; margin-bottom: 50px; }
.header h1 { font-size: 48px; margin-bottom: 15px; color: var(--text-primary); }
.header-controls { display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 15px; }
.overall-status {
  display: inline-block; padding: 12px 30px; border-radius: 8px;
  font-weight: 600; font-size: 18px;
}
.status-operational { background: var(--green); color: white; }
.status-issues { background: var(--red); color: white; }
.status-degraded { background: var(--yellow); color: white; }
.last-updated { color: var(--text-muted); font-size: 14px; }
.refresh-indicator {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  background: var(--green); margin-right: 8px; animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Admin login button */
.admin-login-btn {
  position: absolute; top: 0; right: 0;
  background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.3); border-radius: 8px;
  padding: 8px 16px; font-size: 13px; color: #a78bfa; text-decoration: none;
  transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px; font-weight: 500;
}
.admin-login-btn:hover { background: rgba(139,92,246,0.22); border-color: rgba(139,92,246,0.5); color: #c4b5fd; text-decoration: none; }

/* Incidents Banner */
.incidents-banner {
  background: var(--bg-card); border: 1px solid var(--red); border-radius: 12px;
  padding: 20px; margin-bottom: 30px;
}
.incidents-banner h3 { color: var(--red); margin-bottom: 10px; }
.incident-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.incident-item:last-child { border-bottom: none; }
.incident-title { font-weight: 600; color: var(--text-primary); }
.incident-meta { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.incident-severity {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px;
  font-weight: 600; text-transform: uppercase;
}
.severity-minor { background: var(--yellow); color: #000; }
.severity-major { background: var(--red); color: #fff; }
.severity-critical { background: #7c2d12; color: #fff; }

/* Maintenance Banner */
.maintenance-banner {
  background: var(--bg-card); border: 1px solid #3b82f6; border-radius: 12px;
  padding: 20px; margin-bottom: 30px;
}
.maintenance-banner h3 { color: #3b82f6; margin-bottom: 10px; }
.maintenance-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.maintenance-item:last-child { border-bottom: none; }
.maintenance-title { font-weight: 600; color: var(--text-primary); }
.maintenance-meta { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.maintenance-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px;
  font-weight: 600; text-transform: uppercase; background: #3b82f6; color: #fff;
}

/* Custom Chart Tooltip */
.chartjs-tooltip {
  position: absolute; background: #1e1e2e; color: #e0e0e0; border-radius: 8px;
  padding: 10px 14px; font-size: 13px; pointer-events: none; z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4); transition: opacity 0.15s ease;
  max-width: 280px; line-height: 1.5;
}
.chartjs-tooltip-title { font-weight: 600; margin-bottom: 4px; font-size: 12px; color: #aaa; }
.chartjs-tooltip-item { display: flex; align-items: center; gap: 6px; }
.chartjs-tooltip-color { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Service incident/maintenance badges */
.service-badges { display: flex; align-items: center; gap: 6px; }
.badge-incident {
  display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 11px;
  font-weight: 600; text-transform: uppercase; background: rgba(239,68,68,0.15);
  color: #f87171; border: 1px solid rgba(239,68,68,0.3);
}
.badge-maintenance-sm {
  display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 11px;
  font-weight: 600; text-transform: uppercase; background: rgba(59,130,246,0.15);
  color: #60a5fa; border: 1px solid rgba(59,130,246,0.3);
}

/* Stats Summary */
.stats-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px; margin-bottom: 40px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; text-align: center;
}
.stat-card-value { font-size: 36px; font-weight: 700; color: var(--text-primary); margin-bottom: 5px; }
.stat-card-label { font-size: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* System Metrics Grid */
.section-title {
  font-size: 24px; font-weight: 700; margin-bottom: 20px; color: var(--text-primary);
  display: flex; align-items: center; gap: 10px;
}
.system-metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px; margin-bottom: 40px;
}
.metric-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; transition: transform 0.2s, border-color 0.2s;
}
.metric-card:hover { transform: translateY(-2px); border-color: var(--border-hover); }
.metric-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.metric-title-group { display: flex; align-items: center; gap: 10px; }
.metric-icon { font-size: 24px; }
.metric-title { font-size: 14px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }
.metric-value { font-size: 32px; font-weight: 700; color: var(--text-primary); margin-bottom: 10px; }
.metric-subtitle { font-size: 13px; color: var(--text-dim); }
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s ease; }
.progress-cpu { background: var(--gradient-cpu); }
.progress-memory { background: var(--gradient-memory); }

/* Charts */
.charts-section { margin-bottom: 40px; }
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(500px, 1fr)); gap: 20px; margin-bottom: 30px; }
.chart-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 25px; }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.chart-title { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.chart-controls { display: flex; gap: 10px; }
.time-btn {
  padding: 6px 12px; background: var(--input-bg); border: 1px solid var(--input-border);
  border-radius: 6px; color: var(--text-secondary); cursor: pointer; font-size: 12px; transition: all 0.2s;
}
.time-btn:hover { background: var(--border-hover); }
.time-btn.active { background: var(--accent); border-color: var(--accent); color: white; }
.chart-container { position: relative; height: 300px; }

/* Services */
.services { margin-top: 40px; }
.service-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 25px; margin-bottom: 20px; transition: transform 0.2s, border-color 0.2s;
}
.service-card:hover { transform: translateX(4px); border-color: var(--border-hover); }
.service-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; flex-wrap: wrap; gap: 10px; }
.service-name { font-size: 20px; font-weight: 600; color: var(--text-primary); }
.status-badge { padding: 6px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; text-transform: uppercase; }
.badge-online { background: var(--green); color: white; }
.badge-offline { background: var(--red); color: white; }
.badge-degraded { background: var(--yellow); color: white; }
.badge-unknown { background: #666; color: white; }
.service-stats { display: flex; gap: 30px; color: var(--text-muted); font-size: 14px; flex-wrap: wrap; margin-bottom: 15px; }
.stat { display: flex; align-items: center; gap: 8px; }
.stat-value { color: var(--text-primary); font-weight: 600; }
.uptime-bar { display: flex; gap: 2px; margin-top: 15px; height: 30px; border-radius: 4px; overflow: hidden; }
.uptime-block { flex: 1; transition: all 0.2s; cursor: pointer; }
.uptime-block:hover { transform: scaleY(1.3); z-index: 1; position: relative; }
.uptime-online { background: var(--green); }
.uptime-degraded { background: var(--yellow); }
.uptime-offline { background: var(--red); }
.uptime-unknown { background: var(--border); }
.service-chart { margin-top: 20px; height: 150px; }

/* Footer */
.footer { text-align: center; margin-top: 60px; color: var(--text-dim); font-size: 14px; }
.footer .back-link { display: inline-block; margin-top: 20px; }

/* Skeleton loading animation */
.skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
  height: 180px;
  position: relative;
  overflow: hidden;
}
.skeleton-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
  animation: skeleton-pulse 1.5s infinite;
}
@keyframes skeleton-pulse {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Service group headers */
.service-group-header {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 30px 0 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.service-group-header:first-child { margin-top: 0; }

/* Uptime percentages in service card */
.uptime-percentages {
  display: flex;
  gap: 15px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.uptime-pct {
  font-size: 12px;
  color: var(--text-muted);
}
.uptime-pct .pct-value {
  font-weight: 600;
  color: var(--green);
}

/* SSL info in service card */
.ssl-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.ssl-info.ssl-warning { color: var(--yellow); }
.ssl-info.ssl-danger { color: var(--red); }

/* Recent incidents section */
.incident-history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px 20px;
  margin-bottom: 10px;
}
.incident-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.incident-history-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}
.incident-history-time {
  font-size: 12px;
  color: var(--text-dim);
}
.incident-history-meta {
  font-size: 13px;
  color: var(--text-muted);
}
.incident-resolved-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(16,185,129,0.15);
  color: var(--green);
  border: 1px solid rgba(16,185,129,0.3);
}

/* Responsive */
@media (max-width: 768px) {
  .system-metrics, .charts-grid, .stats-summary { grid-template-columns: 1fr; }
  .service-stats { flex-direction: column; gap: 10px; }
  .chart-container { height: 250px; }
  body { padding: 20px 10px; }
  .header h1 { font-size: 32px; }
}
