:root {
  --bg: #14171c;
  --surface: #1a1e24;
  --surface-2: #20252c;
  --border: #2a2f38;
  --text: #e7e9ec;
  --text-muted: #8a919c;
  --up: #5fb88c;
  --warn: #d9a548;
  --down: #d9645a;
  --accent: #6c8ebf;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Cascadia Code", Consolas, "Roboto Mono", monospace;
  --radius: 5px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.page {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 20px 64px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.topbar__brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--up);
  display: inline-block;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
}

.topbar__nav a { color: var(--text-muted); text-decoration: none; }
.topbar__nav a:hover { color: var(--text); }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius);
  line-height: 0;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn[aria-expanded="true"] { color: var(--accent); }

.content { flex: 1; }

.footer {
  padding-top: 40px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

h1 { font-size: 26px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; }

/* --- status hero --- */

.status-hero { padding: 20px 0 8px; }
.status-hero__state { display: flex; align-items: center; gap: 12px; }

.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.dot--up { background: var(--up); box-shadow: 0 0 0 4px color-mix(in srgb, var(--up) 18%, transparent); }
.dot--down { background: var(--down); box-shadow: 0 0 0 4px color-mix(in srgb, var(--down) 18%, transparent); }
.dot--unknown { background: var(--text-muted); }

.status-hero__meta { color: var(--text-muted); font-size: 13px; margin: 10px 0 0; }

/* --- banner (open incident) --- */

.banner {
  border: 1px solid var(--down);
  background: color-mix(in srgb, var(--down) 12%, var(--surface));
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 24px 0;
}
.banner--maintenance {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
}
.banner__row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.banner__row span { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.banner__desc { margin: 6px 0 0; color: var(--text-muted); font-size: 14px; }
.banner__time { margin: 6px 0 0; color: var(--text-muted); font-size: 13px; }

/* --- uptime stats --- */

.uptime-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 24px 0;
}
.uptime-stat {
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.uptime-stat__label { color: var(--text-muted); font-size: 12px; }
.uptime-stat__value { font-size: 22px; font-weight: 600; }

/* --- heatmap --- */

.heatmap { margin: 32px 0; }
.heatmap__grid {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  gap: 3px;
}
.heatmap__cell {
  aspect-ratio: 1;
  border-radius: 2px;
  display: block;
}
.heatmap__cell--up { background: var(--up); }
.heatmap__cell--warn { background: var(--warn); }
.heatmap__cell--down { background: var(--down); }
.heatmap__cell--empty { background: var(--surface-2); }
.heatmap__cell { cursor: pointer; }
.heatmap__cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.heatmap__scale {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 8px;
}

.heatmap-popup {
  position: fixed;
  z-index: 20;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  white-space: nowrap;
}
.heatmap-popup__date { color: var(--text-muted); display: block; font-size: 11px; }
.heatmap-popup__value { font-family: var(--font-mono); font-weight: 600; }

@media (max-width: 480px) {
  .heatmap__grid { grid-template-columns: repeat(15, 1fr); grid-auto-rows: 1fr; }
}

/* --- incidents --- */

.incidents { margin-top: 40px; }
.incident-list { list-style: none; margin: 0; padding: 0; }
.incident {
  border-top: 1px solid var(--border);
  padding: 16px 0;
}
.incident:last-child { border-bottom: 1px solid var(--border); }
.incident__head { display: flex; align-items: center; gap: 10px; }
.incident__desc { color: var(--text-muted); font-size: 14px; margin: 8px 0 0; }
.incident__time { color: var(--text-muted); font-size: 12.5px; margin: 8px 0 0; }
.incident__actions { display: flex; gap: 16px; margin-top: 10px; }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 600;
  text-transform: lowercase;
}
.badge--down { background: color-mix(in srgb, var(--down) 22%, transparent); color: var(--down); }
.badge--resolved { background: color-mix(in srgb, var(--up) 18%, transparent); color: var(--up); }
.badge--warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }

.tag {
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 100px;
}

.empty { color: var(--text-muted); font-size: 14px; }

/* --- panels / forms (admin) --- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.panel--narrow { max-width: 420px; margin-left: auto; margin-right: auto; margin-top: 40px; }

.notify-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
/* An author rule setting `display` always beats the browser's built-in
   [hidden] { display: none }, regardless of specificity — so without
   this line, `display: flex` above wins even while the hidden attribute
   is set, and the dialog is stuck permanently visible and unclosable.
   This explicit override restores the native hidden behavior. */
.notify-backdrop[hidden] {
  display: none;
}

.notify-popover {
  width: 100%;
  max-width: 340px;
  margin-bottom: 0;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.notify-popover__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.notify-popover__head h2 { margin: 0; }

.muted { color: var(--text-muted); font-size: 14px; }

.form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field__hint { color: var(--text-muted); font-weight: 400; }

fieldset.field { border: none; margin: 0; padding: 0; min-width: 0; }

.maintenance-window {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

input[type="text"], input[type="password"], input[type="datetime-local"], textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 11px;
  font-size: 15px;
  font-family: var(--font-sans);
}
input:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { resize: vertical; font-family: var(--font-sans); }

.btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
}
.btn--primary { background: var(--accent); border-color: var(--accent); color: #0e1116; }
.btn--ghost { background: transparent; }
.btn + .btn { margin-left: 10px; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}
.link-btn--danger { color: var(--down); }
.inline-form { display: inline; margin: 0; }

.hint {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 10px;
  max-width: 46ch;
}

.alert {
  background: color-mix(in srgb, var(--down) 15%, var(--surface));
  border: 1px solid var(--down);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
}

.device-list { list-style: none; margin: 16px 0 0; padding: 0; }
.device {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.device span:first-child { flex: 1; color: var(--text); }
