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

:root {
  --green: #22c55e;
  --green-bg: #dcfce7;
  --red: #ef4444;
  --red-bg: #fee2e2;
  --yellow: #eab308;
  --yellow-bg: #fef9c3;
  --gray: #6b7280;
  --gray-light: #f3f4f6;
  --gray-border: #e5e7eb;
  --text: #111827;
  --text-secondary: #6b7280;
  --bg: #ffffff;
  --surface: #ffffff;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --green-bg: #14532d;
    --red-bg: #7f1d1d;
    --yellow-bg: #713f12;
    --gray-light: #1f2937;
    --gray-border: #374151;
    --text: #f9fafb;
    --text-secondary: #9ca3af;
    --bg: #111827;
    --surface: #1f2937;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

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

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* ── Overall Banner ────────────────────────────────────── */

.banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 2rem;
}

.banner--healthy {
  background: var(--green-bg);
  color: var(--green);
}

.banner--unhealthy {
  background: var(--red-bg);
  color: var(--red);
}

.banner--loading {
  background: var(--gray-light);
  color: var(--gray);
}

.banner__icon::before {
  font-size: 1.25rem;
}

.banner--healthy .banner__icon::before {
  content: '\2713';
}

.banner--unhealthy .banner__icon::before {
  content: '\2717';
}

.banner--loading .banner__icon::before {
  content: '\25CB';
}

/* ── Component Cards ───────────────────────────────────── */

.components {
  margin-bottom: 2rem;
}

.component-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.component-card {
  background: var(--surface);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.component-card__name {
  font-weight: 600;
  font-size: 0.85rem;
}

.component-card__status {
  font-size: 0.8rem;
  font-weight: 500;
}

.component-card__latency {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.component-card--operational .component-card__status {
  color: var(--green);
}

.component-card--down .component-card__status {
  color: var(--red);
}

/* ── History / Period Tabs ─────────────────────────────── */

.history {
  margin-bottom: 2rem;
}

.period-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.period-tab {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s;
}

.period-tab:hover {
  background: var(--gray-light);
}

.period-tab--active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ── Uptime Bars ───────────────────────────────────────── */

.uptime-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.uptime-row__label {
  width: 130px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.uptime-row__bar {
  flex: 1;
  height: 8px;
  background: var(--gray-light);
  border-radius: 4px;
  overflow: hidden;
}

.uptime-row__fill {
  height: 100%;
  border-radius: 4px;
  background: var(--green);
  transition: width 0.4s ease;
  width: 0;
}

.uptime-row__fill--degraded {
  background: var(--yellow);
}

.uptime-row__fill--down {
  background: var(--red);
}

.uptime-row__pct {
  width: 55px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ── Incidents ─────────────────────────────────────────── */

.incidents {
  margin-bottom: 2rem;
}

.incidents__empty {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.incident-item {
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
}

.incident-item__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.incident-item__time {
  font-size: 0.8rem;
  font-weight: 600;
}

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

.incident-item__components {
  font-size: 0.8rem;
  color: var(--red);
}

/* ── Footer ────────────────────────────────────────────── */

footer {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  border-top: 1px solid var(--gray-border);
  padding-top: 1rem;
}

footer p {
  margin-bottom: 0.25rem;
}
