/* ── Design Tokens (matched from main site) ── */
:root {
  --bg: #0a0a0b;
  --bg-lighter: #111113;
  --text: #fafafa;
  --text-muted: #888;
  --accent: #00ff88;
  --accent-dim: #00cc6a;
  --taken: #ff4444;
  --border: #333;
  --degraded: #ffaa00;
}

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
}

body {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco,
               Consolas, "Liberation Mono", "Courier New", monospace;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 84ch;
  margin: 0 auto;
  padding: 0 1rem;
  width: 100%;
}

.hidden {
  display: none !important;
}

/* ── Header ── */
header {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.back-link {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.back-link:hover {
  color: var(--accent);
}

.page-title {
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}

.refresh-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
}

/* ── Main ── */
main {
  flex: 1;
  padding: 2rem 0;
}

/* ── Overall Status Banner ── */
.status-banner {
  text-align: center;
  padding: 1.5rem 0;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.status-text {
  font-size: 1.15rem;
}

/* ── Status Dot ── */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.status-dot--up {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse-green 2s ease-in-out infinite;
}

.status-dot--degraded {
  background: var(--degraded);
  box-shadow: 0 0 8px var(--degraded);
  animation: pulse-amber 2s ease-in-out infinite;
}

.status-dot--down {
  background: var(--taken);
  box-shadow: 0 0 8px var(--taken);
  animation: pulse-red 2s ease-in-out infinite;
}

.status-dot--unknown {
  background: var(--text-muted);
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 4px var(--accent); }
  50% { box-shadow: 0 0 12px var(--accent); }
}

@keyframes pulse-amber {
  0%, 100% { box-shadow: 0 0 4px var(--degraded); }
  50% { box-shadow: 0 0 12px var(--degraded); }
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 4px var(--taken); }
  50% { box-shadow: 0 0 12px var(--taken); }
}

/* ── Error Banner ── */
.error-banner {
  background: rgba(255, 68, 68, 0.1);
  border: 1px solid var(--taken);
  color: var(--taken);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
}

/* ── Service Cards ── */
.service-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.service-card {
  background: var(--bg-lighter);
  border: 1px solid var(--border);
  padding: 1rem 1.25rem;
}

.service-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.service-card__name {
  font-size: 1rem;
  font-weight: normal;
}

.service-card__meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.service-card__badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.service-card__badge .status-dot {
  width: 8px;
  height: 8px;
  margin-right: 0;
}

.badge-text--up { color: var(--accent); }
.badge-text--degraded { color: var(--degraded); }
.badge-text--down { color: var(--taken); }

.service-card__latency {
  color: var(--text-muted);
}

.service-card__uptime {
  color: var(--text-muted);
}

/* Sparkline container */
.service-card__sparkline {
  margin-bottom: 0.5rem;
  position: relative;
}

.service-card__sparkline canvas {
  display: block;
  width: 100%;
  height: 40px;
}

/* Uptime bar container */
.service-card__uptime-bar {
  position: relative;
}

.service-card__uptime-bar canvas {
  display: block;
  width: 100%;
  height: 6px;
}

/* Sparkline / Uptime bar tooltip */
.chart-tooltip {
  position: absolute;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
  top: -28px;
  transform: translateX(-50%);
}

/* ── Uptime Section ── */
.uptime-section {
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  margin-bottom: 2rem;
}

.uptime-section h2 {
  font-size: 1rem;
  font-weight: normal;
  margin-bottom: 1rem;
  color: var(--text);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.uptime-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.uptime-table th,
.uptime-table td {
  text-align: left;
  padding: 0.4rem 1rem 0.4rem 0;
}

.uptime-table th {
  color: var(--text-muted);
  font-weight: normal;
  border-bottom: 1px solid var(--border);
}

.uptime-table td {
  border-bottom: 1px solid var(--border);
}

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

.uptime--good { color: var(--accent); }
.uptime--warn { color: var(--degraded); }
.uptime--bad  { color: var(--taken); }

/* ── Incidents Section ── */
.incidents-section {
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  margin-bottom: 2rem;
}

.incidents-section h2 {
  font-size: 1rem;
  font-weight: normal;
  margin-bottom: 1rem;
  color: var(--text);
}

.incident-row {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.incident-row:last-child {
  border-bottom: none;
}

.incident-date {
  color: var(--text-muted);
  flex-shrink: 0;
}

.incident-service {
  color: var(--text);
  flex-shrink: 0;
}

.incident-cause {
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
}

.incident-duration {
  color: var(--text-muted);
  flex-shrink: 0;
}

.incident-resolved {
  color: var(--accent);
  flex-shrink: 0;
}

.incident-ongoing {
  color: var(--taken);
  font-weight: bold;
  flex-shrink: 0;
}

.incidents-empty {
  color: var(--accent);
  font-size: 0.85rem;
}

/* ── Footer ── */
footer {
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

footer a {
  color: var(--text-muted);
}

footer a:hover {
  color: var(--accent);
}

/* ── Mobile: Tablet ── */
@media (max-width: 768px) {
  .service-card__sparkline canvas {
    height: 35px;
  }

  .service-card__header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Mobile: Phone ── */
@media (max-width: 480px) {
  html {
    font-size: 13px;
  }

  header .container {
    flex-wrap: wrap;
  }

  .page-title {
    order: -1;
    width: 100%;
    text-align: center;
    margin-bottom: 0.25rem;
  }

  .uptime-table {
    font-size: 0.8rem;
  }

  .incident-row {
    gap: 0.75rem;
  }
}

/* ── Mobile: Small Phone ── */
@media (max-width: 375px) {
  .container {
    padding: 0 0.75rem;
  }

  .service-card {
    padding: 0.75rem 1rem;
  }
}
