* {
  box-sizing: border-box;
}

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #162033;
  --muted: #657085;
  --border: #d8deea;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --down: #b91c1c;
  --down-bg: #fee2e2;
  --warn: #a16207;
  --warn-bg: #fef3c7;
  --unknown: #94a3b8;
  --shadow: 0 16px 40px rgba(22, 32, 51, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --surface: #1f2937;
    --text: #f8fafc;
    --muted: #bac4d5;
    --border: #374151;
    --ok-bg: #113b22;
    --down-bg: #4a1717;
    --warn-bg: #463609;
    --shadow: none;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1.05;
}

.summary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-weight: 700;
  white-space: nowrap;
}

.summary-dot,
.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--warn);
}

.summary.is-up .summary-dot,
.badge.is-up .status-dot {
  background: var(--ok);
  box-shadow: 0 0 10px rgba(21, 128, 61, 0.8);
}

.summary.is-down .summary-dot,
.badge.is-down .status-dot {
  background: var(--down);
  animation: statusPulseDown 1.2s ease-in-out infinite;
}

.badge.is-degraded .status-dot {
  background: var(--warn);
  animation: statusPulseWarn 2.8s ease-in-out infinite;
}

.summary.is-up,
.badge.is-up,
.subtarget-badge.is-up {
  border-color: #22c55e;
  background: var(--ok-bg);
  color: var(--ok);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.8), 0 0 12px rgba(34, 197, 94, 0.45);
}

.summary.is-down,
.badge.is-down,
.subtarget-badge.is-down {
  border-color: #ef4444;
  background: var(--down-bg);
  color: var(--down);
  animation: badgeGlowDown 1.2s ease-in-out infinite;
}

.badge.is-degraded,
.subtarget-badge.is-degraded {
  border-color: #f59e0b;
  background: var(--warn-bg);
  color: var(--warn);
  animation: badgeGlowWarn 2.8s ease-in-out infinite;
}

.timeline-card.is-up,
.uptime-card.is-up {
  border-color: #22c55e;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.45), 0 0 14px rgba(34, 197, 94, 0.22), var(--shadow);
}

.timeline-card.is-degraded,
.uptime-card.is-degraded {
  border-color: #f59e0b;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.6), 0 0 18px rgba(245, 158, 11, 0.38), var(--shadow);
}

.timeline-card.is-down,
.uptime-card.is-down {
  border-color: #ef4444;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.6), 0 0 18px rgba(239, 68, 68, 0.38), var(--shadow);
}

@keyframes statusPulseWarn {
  0%, 100% {
    box-shadow: 0 0 7px rgba(245, 158, 11, 0.55);
  }

  50% {
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.95);
  }
}

@keyframes statusPulseDown {
  0%, 100% {
    box-shadow: 0 0 7px rgba(239, 68, 68, 0.65);
  }

  50% {
    box-shadow: 0 0 18px rgba(239, 68, 68, 1);
  }
}

@keyframes badgeGlowWarn {
  0%, 100% {
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.65), 0 0 8px rgba(245, 158, 11, 0.35);
  }

  50% {
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 1), 0 0 18px rgba(245, 158, 11, 0.8);
  }
}

@keyframes badgeGlowDown {
  0%, 100% {
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.7), 0 0 9px rgba(239, 68, 68, 0.45);
  }

  50% {
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 1), 0 0 20px rgba(239, 68, 68, 0.95);
  }
}

.meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.meta > div,
.timeline-card,
.uptime-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.meta > div {
  padding: 16px;
}

.meta-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.view-tabs {
  display: inline-flex;
  gap: 4px;
  margin: 0 0 12px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tab {
  min-width: 68px;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
}

.tab.is-active {
  background: var(--text);
  color: var(--surface);
}

.history-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.history-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--unknown);
  cursor: pointer;
}

.history-note {
  margin: -4px 0 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
  text-decoration: underline;
  text-decoration-color: var(--warn);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.status-panel {
  display: none;
}

.status-panel.is-active {
  display: block;
}

.timeline-list,
.uptime-grid {
  display: grid;
  gap: 14px;
}

.uptime-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
}

.uptime-card.has-children {
  grid-column: span 2;
}

.timeline-card,
.uptime-card {
  padding: 18px;
}

.timeline-card.is-up,
.uptime-card.is-up {
  background: linear-gradient(180deg, var(--ok-bg), var(--surface) 58%);
}

.timeline-card.is-down,
.uptime-card.is-down {
  background: linear-gradient(180deg, var(--down-bg), var(--surface) 58%);
}

.timeline-card.is-degraded,
.uptime-card.is-degraded {
  background: linear-gradient(180deg, var(--warn-bg), var(--surface) 58%);
}

.timeline-card.is-up,
.uptime-card.is-up {
  border-color: #22c55e;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.45), 0 0 14px rgba(34, 197, 94, 0.22), var(--shadow);
}

.timeline-card.is-degraded,
.uptime-card.is-degraded {
  border-color: #f59e0b;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.6), 0 0 18px rgba(245, 158, 11, 0.38), var(--shadow);
}

.timeline-card.is-down,
.uptime-card.is-down {
  border-color: #ef4444;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.6), 0 0 18px rgba(239, 68, 68, 0.38), var(--shadow);
}

.status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.status-name {
  min-width: 0;
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(48, minmax(4px, 1fr));
  gap: 3px;
  margin: 18px 0 10px;
}

.timeline-header {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.timeline-scale {
  display: grid;
  grid-template-columns: repeat(48, minmax(4px, 1fr));
  gap: 3px;
  padding: 0 18px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.timeline-scale-cell {
  position: relative;
  min-height: 18px;
}

.timeline-scale-cell.has-marker {
  border-left: 1px solid var(--border);
}

.timeline-scale-cell.has-marker::before {
  content: "";
  position: absolute;
  left: -1px;
  bottom: -4px;
  width: 1px;
  height: 6px;
  background: var(--border);
}

.timeline-scale-cell.has-marker {
  text-indent: 4px;
}

.slot {
  position: relative;
  height: 24px;
  border-radius: 4px;
  background: var(--ok);
}

.slot.has-marker::before {
  content: "";
  position: absolute;
  left: -2px;
  top: -4px;
  bottom: -4px;
  width: 1px;
  background: rgba(101, 112, 133, 0.45);
}

.slot.is-partial {
  background: var(--warn);
}

.slot.is-down {
  background: var(--down);
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 13px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--ok);
}

.legend-dot.is-partial {
  background: var(--warn);
}

.legend-dot.is-down {
  background: var(--down);
}

.legend-note {
  font-weight: 800;
}

.badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 800;
}

.timeline-entry,
.uptime-entry {
  display: grid;
  gap: 10px;
}

.uptime-card-body.has-children {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.72fr);
  gap: 18px;
  align-items: center;
}

.uptime-entry.is-compact {
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.uptime-entry.is-compact:first-child {
  border-top: 0;
  padding-top: 0;
}

.subtarget-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-left: 18px;
  border-left: 2px solid var(--border);
}

.uptime-children-panel {
  align-self: stretch;
  display: grid;
  align-content: center;
  gap: 10px;
  min-width: 0;
  padding-left: 18px;
  border-left: 2px solid var(--border);
}

.uptime-children-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.uptime-children-list {
  display: grid;
  gap: 0;
}

.compact-uptime-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.compact-uptime-content {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.subtarget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subtarget-head h3 {
  min-width: 0;
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.subtarget-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.subtarget-badge::before {
  content: "";
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--warn);
}

.subtarget-badge.is-up::before {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(21, 128, 61, 0.7);
}

.subtarget-badge.is-down::before {
  background: var(--down);
  animation: statusPulseDown 1.2s ease-in-out infinite;
}

.subtarget-badge.is-degraded::before {
  background: var(--warn);
  animation: statusPulseWarn 2.8s ease-in-out infinite;
}

.official-status-panel {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.official-source-link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  text-decoration: underline;
  text-decoration-color: var(--ok);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.official-source-link::after {
  content: "↗";
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.official-source-link:not(a)::after {
  content: "";
}

.official-source-link:hover {
  color: var(--ok);
}

.official-graph-toggle {
  justify-self: start;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
}

.official-graph-toggle:hover {
  border-color: var(--ok);
  color: var(--ok);
}

.official-service-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}

.official-service {
  display: grid;
  gap: 4px;
  min-height: 56px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.official-service span {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.official-service strong {
  color: var(--muted);
  font-size: 12px;
}

.official-uptime {
  justify-self: start;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.official-uptime.uptime-excellent {
  border-color: rgba(34, 197, 94, 0.7);
  background: var(--ok-bg);
  color: var(--ok);
}

.official-uptime.uptime-good {
  border-color: rgba(20, 184, 166, 0.62);
  color: #0f766e;
}

.official-uptime.uptime-degraded {
  border-color: rgba(245, 158, 11, 0.72);
  background: var(--warn-bg);
  color: var(--warn);
}

.official-uptime.uptime-critical {
  border-color: rgba(239, 68, 68, 0.72);
  background: var(--down-bg);
  color: var(--down);
}

.official-service.is-up strong {
  color: var(--ok);
}

.official-service.is-down strong {
  color: var(--down);
}

.official-service.is-degraded strong {
  color: var(--warn);
}

.official-service.ping-excellent {
  border-color: rgba(34, 197, 94, 0.62);
}

.official-service.ping-excellent strong {
  color: var(--ok);
}

.official-service.ping-good {
  border-color: rgba(20, 184, 166, 0.58);
}

.official-service.ping-good strong {
  color: #0f766e;
}

.official-service.ping-slow {
  border-color: rgba(245, 158, 11, 0.7);
}

.official-service.ping-slow strong {
  color: var(--warn);
}

.official-service.ping-critical {
  border-color: rgba(239, 68, 68, 0.72);
}

.official-service.ping-critical strong {
  color: var(--down);
}

.ping-chart {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.official-service-list.are-graphs-collapsed .ping-chart {
  display: none;
}

.ping-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.ping-chart-head strong {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.ping-sparkline {
  width: 100%;
  height: 58px;
  overflow: visible;
}

.ping-guide {
  stroke: var(--border);
  stroke-dasharray: 3 4;
  stroke-width: 1;
}

.ping-guide-good {
  stroke: rgba(34, 197, 94, 0.38);
}

.ping-guide-warn {
  stroke: rgba(245, 158, 11, 0.44);
}

.ping-line {
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.ping-line.ping-excellent {
  stroke: var(--ok);
}

.ping-line.ping-good {
  stroke: #0f766e;
}

.ping-line.ping-slow {
  stroke: var(--warn);
}

.ping-line.ping-critical {
  stroke: var(--down);
}

.ping-point {
  fill: var(--muted);
  stroke: var(--surface);
  stroke-width: 1.4;
}

.ping-point.ping-excellent {
  fill: var(--ok);
}

.ping-point.ping-good {
  fill: #0f766e;
}

.ping-point.ping-slow {
  fill: var(--warn);
}

.ping-point.ping-critical {
  fill: var(--down);
}

.ping-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.ping-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ping-swatch {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.ping-swatch.ping-excellent {
  background: var(--ok);
}

.ping-swatch.ping-good {
  background: #0f766e;
}

.ping-swatch.ping-slow {
  background: var(--warn);
}

.ping-swatch.ping-critical {
  background: var(--down);
}

.compact-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.compact-metrics span:first-child {
  color: var(--text);
}

.mini-pie-wrap {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
}

.pie.mini-pie {
  width: 58px;
  height: 58px;
  transform: rotate(-90deg);
}

.pie.mini-pie .pie-up,
.pie.mini-pie .pie-bg,
.pie.mini-pie .pie-unknown,
.pie.mini-pie .pie-down {
  stroke-width: 10;
}

.chart-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.pie-wrap {
  position: relative;
  width: 132px;
  height: 132px;
}

.pie {
  width: 132px;
  height: 132px;
  transform: rotate(-90deg);
}

.pie-bg {
  fill: none;
  stroke: rgba(148, 163, 184, 0.18);
  stroke-width: 8;
  outline: none;
}

.pie-up {
  fill: none;
  stroke: var(--ok);
  stroke-linecap: butt;
  stroke-width: 8;
  cursor: pointer;
  outline: none;
}

.pie-unknown {
  fill: none;
  stroke: var(--unknown);
  stroke-linecap: butt;
  stroke-width: 8;
  cursor: pointer;
  outline: none;
}

.pie-down {
  fill: none;
  stroke: var(--down);
  stroke-linecap: butt;
  stroke-width: 8;
  cursor: pointer;
  outline: none;
}

.pie-up,
.pie-unknown,
.pie-down {
  transition: opacity 160ms ease, stroke-width 160ms ease;
}

.pie:has(.is-selected) .pie-up:not(.is-selected),
.pie:has(.is-selected) .pie-unknown:not(.is-selected),
.pie:has(.is-selected) .pie-down:not(.is-selected) {
  opacity: 0.48;
}

.pie-up.is-selected,
.pie-unknown.is-selected,
.pie-down.is-selected {
  opacity: 1;
  stroke-width: 9;
}

.pie-up:focus-visible,
.pie-unknown:focus-visible,
.pie-down:focus-visible {
  stroke-width: 9;
}

.pie-center {
  position: absolute;
  inset: 32px;
  display: grid;
  place-content: center;
  border-radius: 999px;
  background: var(--surface);
  text-align: center;
  font-size: 18px;
  font-weight: 900;
}

.down-tooltip {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: calc(100% + 10px);
  width: min(320px, 80vw);
  max-height: 260px;
  overflow: auto;
  transform: translateX(-50%);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
}

.down-tooltip[hidden] {
  display: none;
}

.down-tooltip strong {
  display: block;
  margin-bottom: 8px;
}

.down-tooltip p {
  margin: 0;
  line-height: 1.35;
}

.down-tooltip ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.down-tooltip li {
  line-height: 1.35;
}

.metric {
  display: grid;
  gap: 8px;
}

.metric strong {
  font-size: 28px;
  line-height: 1;
}

.detail {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.error {
  margin-top: 12px;
  color: var(--down);
  font-weight: 700;
  overflow-wrap: anywhere;
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 24px, 1040px);
    padding: 24px 0;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  h1 {
    font-size: 32px;
  }

  .summary {
    width: 100%;
    justify-content: center;
  }

  .meta {
    grid-template-columns: 1fr;
  }

  .view-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .tab {
    min-width: 0;
  }

  .timeline {
    gap: 2px;
  }

  .slot {
    height: 18px;
    border-radius: 3px;
  }

  .chart-row {
    grid-template-columns: 1fr;
  }

  .uptime-card.has-children {
    grid-column: auto;
  }

  .uptime-card-body.has-children {
    grid-template-columns: 1fr;
  }

  .uptime-children-panel {
    padding-left: 0;
    padding-top: 14px;
    border-left: 0;
    border-top: 2px solid var(--border);
  }
}

@media (prefers-reduced-motion: reduce) {
  .summary.is-down,
  .badge.is-down,
  .subtarget-badge.is-down,
  .badge.is-down .status-dot,
  .subtarget-badge.is-down::before,
  .badge.is-degraded,
  .subtarget-badge.is-degraded,
  .badge.is-degraded .status-dot,
  .subtarget-badge.is-degraded::before {
    animation: none;
  }
}
