:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1b1d22;
  --muted: #697080;
  --border: #e3e5ea;
  --accent: #18a34a;
  --danger: #dc3a3a;
  --warning: #c27c0e;
  --info: #1f75cb;
  --ok: #108548;
  --radius: 14px;
  --radius-small: 9px;
  --shadow: 0 1px 2px rgb(16 18 24 / 6%), 0 4px 16px rgb(16 18 24 / 6%);
  --shadow-raised: 0 2px 6px rgb(16 18 24 / 8%), 0 18px 48px rgb(16 18 24 / 16%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --surface: #171a21;
    --surface-2: #1f232c;
    --text: #e8eaef;
    --muted: #9198a6;
    --border: #2a2f3a;
    --accent: #4ade80;
    --danger: #f06a6a;
    --warning: #e3a63b;
    --info: #5aa2ee;
    --ok: #3fbf74;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 25%);
    --shadow-raised: 0 2px 6px rgb(0 0 0 / 50%), 0 18px 48px rgb(0 0 0 / 50%);
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; font-weight: 650; }
a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Buttons */

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
button:hover, .button:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--border)); }
button:active, .button:active { transform: scale(0.97); }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled { cursor: default; opacity: 0.55; transform: none; }

.primary {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 40%, transparent);
}
.primary:hover { border-color: transparent; background: color-mix(in srgb, var(--accent) 88%, #000); }
.ghost { border-color: transparent; background: transparent; }
.ghost:hover { background: var(--surface-2); border-color: transparent; }
.small { min-height: 30px; padding: 0 11px; font-size: 0.9rem; }
.large { min-height: 46px; padding: 0 24px; font-size: 1.02rem; }

/* Layout */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px max(16px, calc((100vw - 980px) / 2));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.me { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.me-name { color: var(--muted); font-size: 0.92rem; }

.container { max-width: 980px; margin: 0 auto; padding: 28px 16px 96px; }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: color-mix(in srgb, var(--accent) 80%, var(--text));
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  border: 2px solid var(--bg);
}

/* Sign-in */

.signin { min-height: 70vh; display: grid; place-items: center; }
.signin-card {
  max-width: 400px;
  padding: 44px 36px;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  text-align: center;
}
.signin-card h1 { margin: 18px 0 8px; }
.signin-card p { margin: 0 0 28px; }
.signin-logo { filter: drop-shadow(0 8px 20px rgb(24 163 74 / 35%)); }
.signin-page .topbar { display: none; }

/* Empty states */

.empty-state { display: grid; justify-items: center; gap: 10px; padding: 64px 16px; text-align: center; }
.empty-state svg { width: 40px; height: 40px; color: var(--muted); }
.empty-state p { margin: 0 0 8px; }

/* Navigation */

.tabs { display: flex; gap: 4px; margin-left: 24px; }
.tabs a { padding: 6px 12px; border-radius: var(--radius-small); text-decoration: none; color: var(--muted); font-weight: 550; }
.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.filters { display: flex; gap: 4px; }
.filters a { padding: 4px 10px; border-radius: 999px; text-decoration: none; color: var(--muted); border: 1px solid var(--border); font-size: 0.9rem; }
.filters a[aria-current="page"] { color: var(--text); border-color: var(--text); }

.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.section-title { margin: 32px 0 12px; }
.small-text { font-size: 0.85rem; }
.empty { padding: 24px 0; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.86rem; word-break: break-all; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* States: always a word next to the colour */

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 650; border: 1px solid transparent; }
.badge-up { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.badge-degraded { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, transparent); background: color-mix(in srgb, var(--warning) 10%, transparent); }
.badge-down { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.badge-unknown { color: var(--muted); border-color: var(--border); }
.severity { font-weight: 600; }
.severity-critical { color: var(--danger); }
.severity-warning { color: var(--warning); }
.status-failed { color: var(--danger); font-weight: 600; }
.status-pending { color: var(--warning); }
.banner { padding: 12px 16px; border-radius: var(--radius-small); border: 1px solid var(--border); background: var(--surface); }
.banner-down { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.banner-degraded { border-color: color-mix(in srgb, var(--warning) 45%, transparent); }

/* Board */

.services { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.service { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border-top: 4px solid var(--border); }
.service.state-up { border-top-color: var(--ok); }
.service.state-degraded { border-top-color: var(--warning); }
.service.state-down { border-top-color: var(--danger); }
.service-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.incident-count { display: inline-block; margin-top: 8px; color: var(--danger); font-size: 0.9rem; font-weight: 600; }
.targets { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; font-size: 0.88rem; }
.targets li { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; }
.target-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-up { background: var(--ok); }
.dot-down { background: var(--danger); }

/* Tables and forms */

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-small); overflow: hidden; font-size: 0.92rem; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { color: var(--muted); font-weight: 600; font-size: 0.82rem; background: var(--surface-2); }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table.compact th { width: 30%; color: var(--muted); font-weight: 550; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-small); }
.form label { display: grid; gap: 4px; font-size: 0.86rem; color: var(--muted); }
.form label.wide { flex: 1 1 260px; }
.form label.check { display: flex; align-items: center; gap: 6px; color: var(--text); }
.form input:not([type="checkbox"]), .form select { min-height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-small); background: var(--bg); color: var(--text); font: inherit; }
.notice { position: fixed; right: 16px; bottom: 16px; max-width: 420px; margin: 0; padding: 12px 16px; border-radius: var(--radius-small); background: var(--danger); color: #fff; box-shadow: var(--shadow-raised); }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; margin: 8px 0 0; overflow-x: auto; }
  .table { display: block; overflow-x: auto; }
}
.table button { white-space: nowrap; }

/* Public status page */
.public .topbar { justify-content: flex-start; }
.public-services .service { cursor: default; }
.public-incident {
  margin-top: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-left: 3px solid var(--danger);
  background: var(--surface-2);
  border-radius: var(--radius-small);
}
.public-recent .public-incident { border-left-color: var(--ok); }
.public-recent { list-style: none; padding: 0; margin: 0; }
.public-incident-head { margin: 0 0 0.3rem; font-weight: 600; }
.public-update, .updates li { white-space: pre-line; margin: 0.4rem 0; }
.updates { padding-left: 1.2rem; }
.public-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  padding: 1.5rem 1rem 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}
