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

:root {
  --bg: #0f1117;
  --surface: #1a1d2e;
  --surface-hover: #222540;
  --border: #2d3148;
  --text: #e2e8f0;
  --muted: #64748b;
  --up: #22c55e;
  --down: #ef4444;
  --unknown: #94a3b8;
  --accent: #6366f1;
}

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

/* ── Header ── */
header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.summary-badge {
  font-size: 0.875rem;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 600;
}
.summary-badge.all-up   { background: #14532d; color: var(--up); }
.summary-badge.some-down{ background: #450a0a; color: var(--down); }

/* ── Card Grid ── */
main { padding: 32px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Site Card ── */
.site-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
  border-left: 4px solid var(--unknown);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  user-select: none;
}
.site-card:hover { background: var(--surface-hover); transform: translateY(-2px); }
.site-card.up      { border-left-color: var(--up); }
.site-card.down    { border-left-color: var(--down); }
.site-card.unknown { border-left-color: var(--unknown); }

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.up      { background: var(--up);      box-shadow: 0 0 6px var(--up); }
.status-dot.down    { background: var(--down);    box-shadow: 0 0 6px var(--down); }
.status-dot.unknown { background: var(--unknown); }

.card-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-url {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 14px;
}

.stat-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1rem; font-weight: 700; margin-top: 2px; }
.stat-value.up   { color: var(--up); }
.stat-value.down { color: var(--down); }
.stat-value.muted{ color: var(--muted); }

/* ── Sparkline ── */
.sparkline {
  display: flex;
  gap: 2px;
  height: 20px;
  align-items: flex-end;
}
.spark-dot {
  flex: 1;
  border-radius: 2px;
  min-width: 4px;
}
.spark-dot.up      { background: var(--up);      height: 100%; }
.spark-dot.down    { background: var(--down);    height: 100%; }
.spark-dot.unknown { background: var(--border);  height: 50%; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 28px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.modal-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.modal-url   { font-size: 0.8rem; color: var(--muted); margin-bottom: 20px; }

.modal-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg);
  border-radius: 10px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.chart-header h3 { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.days-toggle { display: flex; gap: 6px; }
.days-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}
.days-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.days-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chart-container { position: relative; height: 160px; margin-bottom: 28px; }

.incidents-title { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }

.incident-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.incident-time { color: var(--muted); }
.incident-duration { color: var(--down); font-weight: 600; }

.no-incidents { color: var(--muted); font-size: 0.85rem; padding: 12px 0; }
