:root {
  --bg: #0f1115;
  --panel: #161920;
  --muted: #7a7f8d;
  --text: #e5e7ec;
  --green: #4caf50;
  --amber: #d9a441;
  --red: #e15b64;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  background: radial-gradient(circle at 20% 20%, #151821, #0f1115 50%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 18px 24px;
  border-bottom: 1px solid #1f2330;
  background: linear-gradient(90deg, #161920, #12141a);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.title {
  font-size: 20px;
  letter-spacing: 0.5px;
}

.subtitle {
  color: var(--muted);
  font-size: 12px;
}

main {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Global Health Score Card */
.global-health-card {
  background: linear-gradient(135deg, rgba(26, 30, 39, 0.9) 0%, rgba(22, 25, 32, 0.95) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 24px 28px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 32px;
  align-items: center;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: all 0.4s ease;
}

.global-health-card.healthy {
  border-color: rgba(76, 175, 80, 0.3);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(76, 175, 80, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.global-health-card.degraded {
  border-color: rgba(217, 164, 65, 0.3);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(217, 164, 65, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.global-health-card.critical,
.global-health-card.outage {
  border-color: rgba(225, 91, 100, 0.3);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(225, 91, 100, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.health-score-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.health-score-ring {
  position: relative;
  width: 100px;
  height: 100px;
}

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

.ring-bg {
  fill: none;
  stroke: #242836;
  stroke-width: 6;
}

.ring-progress {
  fill: none;
  stroke: var(--green);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s ease;
  filter: drop-shadow(0 0 6px rgba(76, 175, 80, 0.5));
}

.ring-progress.healthy {
  stroke: var(--green);
  filter: drop-shadow(0 0 8px rgba(76, 175, 80, 0.6));
}

.ring-progress.degraded {
  stroke: var(--amber);
  filter: drop-shadow(0 0 8px rgba(217, 164, 65, 0.6));
}

.ring-progress.critical,
.ring-progress.outage {
  stroke: var(--red);
  filter: drop-shadow(0 0 8px rgba(225, 91, 100, 0.6));
  animation: pulse-ring 2s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(225, 91, 100, 0.6)); }
  50% { filter: drop-shadow(0 0 16px rgba(225, 91, 100, 0.8)); }
}

.health-score-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.health-score-value span:first-child {
  display: block;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(180deg, #fff 0%, #a0a5b0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.health-label {
  font-size: 8px;
  color: var(--muted);
  letter-spacing: 1.5px;
  opacity: 0.7;
}

.health-status {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.health-status.healthy {
  color: var(--green);
}

.health-status.degraded {
  color: var(--amber);
}

.health-status.critical,
.health-status.outage {
  color: var(--red);
}

/* Layer breakdown bars */
.health-breakdown {
  flex: 1;
  min-width: 300px;
}

.breakdown-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 10px;
}

.breakdown-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Layer Card Grid */
.layer-card-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  width: 100%;
}

.layer-card {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
  border-left: 3px solid var(--muted);
  transition: all 0.3s ease;
}

.layer-card.healthy,
.layer-card.up {
  border-left-color: var(--green);
  background: rgba(76, 175, 80, 0.08);
}

.layer-card.degraded {
  border-left-color: var(--amber);
  background: rgba(217, 164, 65, 0.08);
}

.layer-card.critical,
.layer-card.down {
  border-left-color: var(--red);
  background: rgba(225, 91, 100, 0.08);
}

.layer-card-name {
  font-size: 0.7rem;
  color: var(--text);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.layer-card.healthy .layer-card-name,
.layer-card.up .layer-card-name {
  color: var(--green);
}

.layer-card.degraded .layer-card-name {
  color: var(--amber);
}

.layer-card.critical .layer-card-name,
.layer-card.down .layer-card-name {
  color: var(--red);
}

.layer-card-score {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.layer-card.healthy .layer-card-score,
.layer-card.up .layer-card-score {
  color: var(--green);
}

.layer-card.degraded .layer-card-score {
  color: var(--amber);
}

.layer-card.critical .layer-card-score,
.layer-card.down .layer-card-score {
  color: var(--red);
}

@media (max-width: 900px) {
  .layer-card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .layer-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Health summary */
.health-summary {
  text-align: right;
  min-width: 100px;
}

.summary-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-item {
  font-size: 11px;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  transition: all 0.2s ease;
}

.summary-item::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.summary-item.up {
  color: var(--green);
  background: rgba(76, 175, 80, 0.1);
}

.summary-item.degraded {
  color: var(--amber);
  background: rgba(217, 164, 65, 0.1);
}

.summary-item.down {
  color: var(--red);
  background: rgba(225, 91, 100, 0.1);
}

.summary-item.unknown {
  color: var(--muted);
  background: rgba(122, 127, 141, 0.1);
}

@media (max-width: 900px) {
  .global-health-card {
    grid-template-columns: 1fr;
    text-align: center;
  }
  
  .health-score-section {
    justify-self: center;
  }
  
  .health-breakdown {
    min-width: 100%;
  }
  
  .health-summary {
    text-align: center;
  }
  
  .summary-stats {
    flex-direction: row;
    justify-content: center;
    gap: 16px;
  }
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab {
  background: #1c2029;
  color: var(--text);
  border: 1px solid #242836;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}

.tab.active {
  border-color: #3a4154;
  box-shadow: inset 0 0 0 1px #3a4154;
}

.tab-panel.hidden {
  display: none;
}

.section-head {
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.group {
  margin-top: 12px;
}

h3 {
  margin: 10px 0 6px;
}

.status-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid #1f2330;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.status-table th,
.status-table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #1f2330;
  font-size: 13px;
}

.status-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bgp-summary {
  margin-bottom: 10px;
  font-size: 13px;
}

/* Hierarchy Styles */
.hierarchy {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.layer-card {
  background: var(--panel);
  border: 1px solid #1f2330;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 4px;
}

.layer-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: linear-gradient(90deg, #1a1e27, #161920);
  border-bottom: 1px solid #1f2330;
  cursor: pointer;
}

.layer-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
}

.layer-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  transition: background 0.3s ease;
}

.layer-dot.up { background: var(--green); box-shadow: 0 0 12px rgba(76, 175, 80, 0.4); }
.layer-dot.degraded { background: var(--amber); box-shadow: 0 0 12px rgba(217, 164, 65, 0.4); }
.layer-dot.down { background: var(--red); box-shadow: 0 0 12px rgba(225, 91, 100, 0.4); }

.layer-number {
  width: 24px;
  height: 24px;
  background: #242836;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.layer-icon {
  font-size: 20px;
  line-height: 1;
}

.layer-info {
  flex: 1;
}

.layer-info h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.layer-desc {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.layer-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #1c2029;
  border-radius: 4px;
}

.stat-item .count { font-weight: 700; }
.stat-item.up .count { color: var(--green); }
.stat-item.degraded .count { color: var(--amber); }
.stat-item.down .count { color: var(--red); }

.layer-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  transition: transform 0.2s ease;
}

.layer-toggle.collapsed {
  transform: rotate(-90deg);
}

.layer-content {
  transition: max-height 0.3s ease;
  overflow: hidden;
}

.layer-content.collapsed {
  max-height: 0 !important;
}

.hierarchy-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
}

.connector-line {
  width: 2px;
  height: 16px;
  background: linear-gradient(180deg, #3a4154, #242836);
}

.connector-arrow {
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
}

footer {
  padding: 12px 24px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid #1f2330;
}
