:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1d4ed8;
  --accent: #0f766e;
  --warn: #b45309;
  --alert: #b91c1c;
  --shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.skip-links {
  position: absolute;
  top: 0;
  left: 0;
}

.skip-links a {
  position: absolute;
  transform: translateY(-150%);
  background: #111827;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 8px 0;
  text-decoration: none;
}

.skip-links a:focus {
  transform: translateY(0);
}

.site-header {
  padding: 2.5rem clamp(1.5rem, 3vw, 3.5rem);
  display: flex;
  gap: 2rem;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 2.8rem);
}

.lede {
  margin: 0.75rem 0 0;
  max-width: 40rem;
  color: var(--muted);
}

.read-only {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: #1e3a8a;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 1rem;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.4rem;
  font-weight: 600;
  cursor: pointer;
}

button.primary {
  background: var(--primary);
  color: #fff;
}

button.secondary {
  background: #e0e7ff;
  color: #1e3a8a;
}

.link {
  background: none;
  color: var(--primary);
  padding: 0;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.link:hover,
.link:focus {
  text-decoration: underline;
}

button.link {
  border: none;
}

main {
  padding: 2rem clamp(1.5rem, 3vw, 3.5rem) 4rem;
}

.pillars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.pillars article {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.dashboard {
  margin-bottom: 3rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.filters {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

select {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0.5rem 0.8rem;
  font-size: 0.95rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card h3 {
  margin-top: 0;
}

.status-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.status-pill {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.status-pill.healthy {
  background: #dcfce7;
  color: #166534;
}

.status-pill.watch {
  background: #fef9c3;
  color: #854d0e;
}

.status-pill.alert {
  background: #fee2e2;
  color: #991b1b;
}

.big-number {
  font-size: 2.2rem;
  margin: 0;
}

.card-footer {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.timestamp {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.live {
  background: #dbeafe;
  color: #1e3a8a;
}

.badge.historical {
  background: #f3e8ff;
  color: #6b21a8;
}

.muted {
  color: var(--muted);
}

.sparkline {
  height: 48px;
  border-radius: 8px;
  margin-top: 1rem;
  background: linear-gradient(135deg, rgba(29, 78, 216, 0.35), rgba(15, 118, 110, 0.4));
  opacity: 0.65;
}

.timeline {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.track {
  position: relative;
  height: 36px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e5e7eb 10%, #93c5fd 45%, #1d4ed8 60%, #e5e7eb 90%);
}

.track::before {
  content: attr(data-label);
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: #111827;
  font-weight: 600;
}

.legend {
  margin-top: 1rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
  align-items: center;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.35rem;
}

.dot.dns {
  background: #1d4ed8;
}

.dot.tcp {
  background: #0f766e;
}

.dot.throughput {
  background: #f97316;
}

.baseline-chart {
  position: relative;
  height: 160px;
  border-radius: 12px;
  background: #f1f5f9;
  overflow: hidden;
  margin-top: 1.2rem;
}

.baseline-chart .baseline {
  position: absolute;
  inset: 30% 5% 15% 5%;
  background: rgba(29, 78, 216, 0.18);
  border-radius: 20px;
}

.baseline-chart .current {
  position: absolute;
  inset: 45% 10% 10% 10%;
  background: rgba(15, 118, 110, 0.35);
  border-radius: 14px;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.6rem;
  align-items: end;
  height: 160px;
  margin-top: 1rem;
}

.bar {
  background: #1d4ed8;
  border-radius: 8px 8px 4px 4px;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  margin-top: 1rem;
}

.heatmap .cell {
  aspect-ratio: 1;
  border-radius: 4px;
  background: rgba(15, 118, 110, 0.2);
}

.gradient {
  height: 10px;
  width: 100px;
  background: linear-gradient(90deg, rgba(15, 118, 110, 0.2), rgba(15, 118, 110, 0.8));
  border-radius: 999px;
}

.table {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.table-row {
  display: grid;
  grid-template-columns: 120px 1fr 1fr 160px;
  gap: 1rem;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f9fafb;
  font-size: 0.9rem;
}

.table-row.header {
  background: #eef2ff;
  font-weight: 700;
  color: #1e3a8a;
}

.attribution .statement {
  margin-top: 1rem;
}

.confidence {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.confidence-block {
  margin-top: 1rem;
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.confidence-block strong {
  color: var(--ink);
}

.confidence-bar {
  position: relative;
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.confidence-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--value);
  background: linear-gradient(90deg, #1d4ed8, #0f766e);
}

.evidence-links {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.evidence-links .link {
  text-decoration: none;
  color: var(--primary);
}

.evidence-links .link:hover,
.evidence-links .link:focus {
  text-decoration: underline;
}

.contract {
  margin: 1rem 0 0;
  display: grid;
  gap: 0.75rem;
}

.contract div {
  display: grid;
  gap: 0.35rem;
}

.contract dt {
  font-weight: 700;
  color: #1e3a8a;
}

.contract dd {
  margin: 0;
  color: var(--muted);
}

svg {
  width: 100%;
  fill: none;
  stroke: #94a3b8;
  stroke-width: 2;
}

.ladder {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ladder li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 1rem;
}

.ladder span {
  font-weight: 700;
  color: #1e3a8a;
  min-width: 80px;
}

.bullet-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.site-footer {
  padding: 2rem clamp(1.5rem, 3vw, 3.5rem);
  border-top: 1px solid var(--border);
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

/* Loading state */
body.loading::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0%, 100% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
}

/* Error and no-data messages */
.error-message {
  padding: 1rem;
  background: #fef2f2;
  color: var(--alert);
  border: 1px solid #fecaca;
  border-radius: 8px;
  margin: 1rem 0;
}

.no-data {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

/* Bundle list styling */
.bundles-list {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.bundle-item {
  padding: 1.5rem;
}

.bundle-item .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.bundle-item h4 {
  margin: 0;
  font-size: 1rem;
  font-family: monospace;
  color: var(--ink);
}

.bundle-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 6px;
}

.bundle-meta p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.bundle-meta strong {
  color: var(--ink);
  display: block;
  margin-bottom: 0.25rem;
}

@media (max-width: 900px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-row {
    grid-template-columns: 1fr;
  }

  .card-footer {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .bundle-meta {
    grid-template-columns: 1fr;
  }
}
