:root {
  --bg-main: #0b0f19;
  --bg-card: rgba(18, 24, 38, 0.85);
  --bg-card-hover: rgba(26, 34, 52, 0.95);
  --bg-modal: #111827;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-card: rgba(255, 255, 255, 0.12);
  
  --text-main: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --status-healthy: #10b981;
  --status-healthy-bg: rgba(16, 185, 129, 0.15);
  --status-healthy-glow: rgba(16, 185, 129, 0.35);

  --status-warning: #f59e0b;
  --status-warning-bg: rgba(245, 158, 11, 0.15);
  --status-warning-glow: rgba(245, 158, 11, 0.35);

  --status-critical: #ef4444;
  --status-critical-bg: rgba(239, 68, 68, 0.15);
  --status-critical-glow: rgba(239, 68, 68, 0.45);

  --status-unknown: #9ca3af;
  --status-unknown-bg: rgba(156, 163, 175, 0.15);

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

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

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(30, 58, 138, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(11, 15, 25, 0.75);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 1rem 2rem;
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #2563eb, #10b981);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 1.15rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.brand-info h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.btn-logout {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

/* Main Content */
.main-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
  flex: 1;
}

/* Overall Health Banner */
.overall-hero {
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border-card);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  transition: all 0.3s ease;
}

.overall-hero.HEALTHY {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(18, 24, 38, 0.95) 100%);
  border-color: rgba(16, 185, 129, 0.3);
}

.overall-hero.WARNING {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(18, 24, 38, 0.95) 100%);
  border-color: rgba(245, 158, 11, 0.35);
}

.overall-hero.CRITICAL {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(18, 24, 38, 0.95) 100%);
  border-color: rgba(239, 68, 68, 0.45);
}

.overall-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.overall-icon {
  font-size: 2.75rem;
  line-height: 1;
}

.overall-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  letter-spacing: -0.02em;
}

.overall-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.overall-stats {
  display: flex;
  gap: 2rem;
}

.stat-box {
  text-align: right;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

/* Collector Sub-banner */
.collector-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 24, 38, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  margin-bottom: 2rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.collector-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.collector-item strong {
  color: var(--text-main);
}

/* Cards Grid */
.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.system-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  position: relative;
  overflow: hidden;
}

.system-card:hover {
  transform: translateY(-3px);
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.25);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-target {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 0.2rem;
}

/* Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.HEALTHY {
  background: var(--status-healthy-bg);
  color: var(--status-healthy);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.WARNING {
  background: var(--status-warning-bg);
  color: var(--status-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.CRITICAL {
  background: var(--status-critical-bg);
  color: var(--status-critical);
  border: 1px solid rgba(239, 68, 68, 0.4);
  animation: critical-pulse 2s infinite;
}

.status-badge.UNKNOWN {
  background: var(--status-unknown-bg);
  color: var(--status-unknown);
  border: 1px solid rgba(156, 163, 175, 0.3);
}

@keyframes critical-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.card-metrics {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.latency-value {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.latency-unit {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-left: 0.2rem;
}

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

.card-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-footer strong {
  color: var(--text-secondary);
}

.card-error {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  font-size: 0.75rem;
  display: none;
}

/* Quick Summary Table */
.summary-section {
  margin-bottom: 2.5rem;
}

.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-card);
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.summary-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 1rem 1.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-card);
}

.summary-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.summary-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-main);
}

.summary-table tr:last-child td {
  border-bottom: none;
}

/* Incidents Section */
.incidents-section {
  margin-bottom: 2.5rem;
}

.incidents-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.incidents-empty {
  text-align: center;
  padding: 2.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.incident-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
}

.incident-item:last-child {
  margin-bottom: 0;
}

.incident-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.incident-comp {
  font-weight: 700;
  font-size: 0.95rem;
}

.incident-msg {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.incident-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
}

/* Modal Dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  background: var(--bg-modal);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  max-width: 760px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  padding: 2rem;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1.25rem;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 800;
}

.metrics-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-item-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.metric-item-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  letter-spacing: 0.05em;
}

.metric-item-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
}

/* History Chart Container */
.chart-container {
  margin-top: 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

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

.chart-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.chart-periods {
  display: flex;
  gap: 0.5rem;
}

.period-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
}

.period-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.chart-canvas {
  width: 100%;
  height: 180px;
  display: block;
}

/* Responsive */
@media (max-width: 768px) {
  .app-header { padding: 1rem; }
  .main-container { padding: 1rem; }
  .overall-hero { flex-direction: column; align-items: flex-start; gap: 1.25rem; }
  .overall-stats { width: 100%; justify-content: space-between; }
  .collector-bar { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .cards-grid { grid-template-columns: 1fr; }
}
