/* Design system. Tokens follow SPEC.md section 10. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/InterVariable.woff2") format("woff2");
}

/* --- Tokens --- */

:root {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --border: #E8EAED;
  --text: #0F1115;
  --muted: #6B7280;
  --accent: #4F46E5;
  --up: #16A34A;
  --warn: #D97706;
  --down: #DC2626;
  --paused: #9CA3AF;
  /* Status colors as text. Darker than the dots so they reach 4.5:1 on
     --bg and --surface. Dots, bars and charts keep the plain colors. */
  --up-text: #15803D;
  --warn-text: #B45309;
  --down-text: #B91C1C;

  --accent-hover: color-mix(in srgb, var(--accent) 88%, #000);
  --accent-tint: color-mix(in srgb, var(--accent) 12%, transparent);
  --focus-ring: color-mix(in srgb, var(--accent-text) 30%, transparent);
  /* Accent as text, links and focus rings. /brand/theme.css sets the
     per-theme values so any accent has AA contrast on the page. */
  --accent-text: var(--accent-text-light, var(--accent));

  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: 150ms ease-out;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0B0D10;
  --surface: #12151A;
  --border: #1F242C;
  --text: #E6E8EB;
  --muted: #8A93A0;
  --up: #22C55E;
  --warn: #F59E0B;
  --down: #EF4444;
  --paused: #4B5563;
  --up-text: #22C55E;
  --warn-text: #F59E0B;
  --down-text: #F87171;
  --accent-hover: color-mix(in srgb, var(--accent) 85%, #fff);
  --accent-text: var(--accent-text-dark, var(--accent));
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0D10;
    --surface: #12151A;
    --border: #1F242C;
    --text: #E6E8EB;
    --muted: #8A93A0;
    --up: #22C55E;
    --warn: #F59E0B;
    --down: #EF4444;
    --paused: #4B5563;
    --up-text: #22C55E;
    --warn-text: #F59E0B;
    --down-text: #F87171;
    --accent-hover: color-mix(in srgb, var(--accent) 85%, #fff);
    --accent-text: var(--accent-text-dark, var(--accent));
    color-scheme: dark;
  }
}

[data-theme="light"] {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --border: #E8EAED;
  --text: #0F1115;
  --muted: #6B7280;
  --up: #16A34A;
  --warn: #D97706;
  --down: #DC2626;
  --paused: #9CA3AF;
  --up-text: #15803D;
  --warn-text: #B45309;
  --down-text: #B91C1C;
  --accent-hover: color-mix(in srgb, var(--accent) 88%, #000);
  --accent-text: var(--accent-text-light, var(--accent));
  color-scheme: light;
}

/* --- Base --- */

*, *::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-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Links inside running text must not rely on color alone. */
p a, .hint a, td a, li a:not(.btn) { text-decoration: underline; text-underline-offset: 2px; }
code, kbd { font-family: var(--mono); font-size: 0.92em; }
code {
  padding: 1px 5px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0; }
svg { display: block; }
.icon { width: 22px; height: 22px; flex: none; }

/* Type scale: 12, 14, 16, 20, 28, 40. Weights 400 and 600 only. */
.t-12 { font-size: 12px; }
.t-14 { font-size: 14px; }
.t-16 { font-size: 16px; }
.t-20 { font-size: 20px; }
.t-28 { font-size: 28px; letter-spacing: -0.02em; }
.t-40 { font-size: 40px; letter-spacing: -0.02em; line-height: 1.1; }
.w-600 { font-weight: 600; }
.lead { font-size: 16px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Layout --- */

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.page { flex: 1; padding: 32px 20px 48px; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inline { display: inline; }
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* --- Header and footer --- */

.topbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-inner {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
}
.brand:hover { text-decoration: none; }
.brand-logo { width: 22px; height: 22px; color: var(--text); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: color var(--ease), background-color var(--ease);
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: color-mix(in srgb, var(--text) 6%, transparent); }
@media (max-width: 640px) {
  /* The brand and Log out share the first row; the nav gets its own row. */
  .topbar-inner { height: auto; flex-wrap: wrap; padding-block: 8px; }
  .nav { order: 1; width: 100%; margin-left: -10px; }
}

.footer { border-top: 1px solid var(--border); padding: 16px 0; font-size: 12px; }
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* Theme toggle: three small segments. The chart range toggle looks the same. */
.theme-toggle, .range-toggle {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.theme-toggle button, .range-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 28px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--ease), background-color var(--ease);
}
.theme-toggle button svg { width: 14px; height: 14px; }
.theme-toggle button:hover, .range-toggle button:hover { color: var(--text); }
.theme-toggle button[aria-pressed="true"], .range-toggle button[aria-pressed="true"] {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}
.theme-toggle button:focus-visible, .range-toggle button:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.range-toggle button { width: auto; padding: 0 10px; font: inherit; font-size: 12px; font-weight: 600; white-space: nowrap; }

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent, #fff); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--muted); }
.btn-danger { background: transparent; color: var(--down-text); border-color: color-mix(in srgb, var(--down) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--down) 8%, transparent); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* --- Forms --- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > label { font-weight: 600; }
.field .hint { color: var(--muted); font-size: 12px; }
.field.invalid input, .field.invalid select { border-color: var(--down); }
.field .error { color: var(--down-text); font-size: 12px; }

.input, .field input:not([type="checkbox"]):not([type="radio"]), .field select {
  height: 40px;
  padding: 0 12px;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.field input::placeholder { color: var(--muted); }
.input:focus, .field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.field input:disabled { opacity: 0.6; cursor: not-allowed; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* --- Cards --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

/* Stat tile: a label and one large number. */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.stat .value small { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 2px; }

/* --- Alerts --- */

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
}
.alert-error {
  border-color: color-mix(in srgb, var(--down) 35%, transparent);
  background: color-mix(in srgb, var(--down) 8%, transparent);
  color: var(--down-text);
}
.alert-ok {
  border-color: color-mix(in srgb, var(--up) 35%, transparent);
  background: color-mix(in srgb, var(--up) 8%, transparent);
  color: var(--up-text);
}

/* --- Status dot --- */

.dot {
  position: relative;
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  vertical-align: middle;
}
.dot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  opacity: 0;
}
.dot-up { background: var(--up); }
.dot-up::before { animation: halo 2.4s ease-out infinite; }
.dot-down { background: var(--down); }
.dot-down::before { animation: halo 1.2s ease-out infinite; }
.dot-paused { background: transparent; box-shadow: inset 0 0 0 1.5px var(--paused); }
.dot-pending { background: var(--paused); animation: blink 1.6s ease-in-out infinite; }

@keyframes halo {
  0%   { transform: scale(1); opacity: 0.45; }
  100% { transform: scale(3.2); opacity: 0; }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.status-up { color: var(--up-text); }
.status-down { color: var(--down-text); }
.status-paused, .status-pending { color: var(--muted); }

/* --- Uptime bar --- */

.uptime {
  display: flex;
  gap: 2px;
  height: 28px;
  width: 100%;
}
.uptime .seg {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  border-radius: 2px;
  background: var(--border);
  transition: opacity var(--ease);
}
.uptime .seg-up { background: var(--up); }
.uptime .seg-warn { background: var(--warn); }
.uptime .seg-down { background: var(--down); }
.uptime .seg:hover { opacity: 0.75; }

/* Tooltip on hover. Text comes from data-tip. */
.uptime .seg[data-tip]::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  white-space: pre;
  pointer-events: none;
  z-index: 2;
}
.uptime .seg[data-tip]:hover::after { display: block; }
.uptime .seg:first-child[data-tip]::after { left: 0; transform: none; }
.uptime .seg:last-child[data-tip]::after { left: auto; right: 0; transform: none; }

/* On narrow screens show only the newest 14 of 30 segments. */
@media (max-width: 640px) {
  .uptime .seg:nth-child(-n+16):nth-last-child(n+15) { display: none; }
}

/* --- Response chart and sparkline --- */

.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; color: var(--accent); overflow: visible; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .chart-crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; pointer-events: none; }
.chart .chart-hover-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; pointer-events: none; }
.chart-tip {
  position: absolute;
  top: 0;
  transform: translate(-50%, -100%);
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}
.chart-axis {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.sparkline { width: 80px; height: 24px; color: var(--accent); flex: none; }
.sparkline .line { fill: none; stroke: var(--accent); stroke-width: 1.25; stroke-linejoin: round; stroke-linecap: round; }

/* --- Empty state --- */

.empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 64px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* --- Auth pages: setup, login, errors --- */

body.auth { align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.auth-brand .brand-logo { width: 26px; height: 26px; }
.help { margin-top: -4px; }

/* --- Motion --- */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fade-in 150ms ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* --- Dashboard --- */

.dash-head h1 { display: flex; align-items: center; gap: 12px; }
.dash-head h1 .dot { width: 12px; height: 12px; }
.crumbs { margin-bottom: 12px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }

.monitors {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
/* No overflow clipping on the list: the uptime tooltips of the first row
   rise above it. The rows round their own corners instead. */
.mon-row:first-child { border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; }
.mon-row:last-child { border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px); }
.mon-row:only-child { border-radius: calc(var(--radius) - 1px); }
.mon-row {
  position: relative;
  display: grid;
  grid-template-columns: 28px 8px minmax(0, 1fr) minmax(140px, 240px) 64px 80px 120px;
  grid-template-areas: "grip dot name bar pct spark checked";
  align-items: center;
  gap: 16px;
  padding: 14px 20px 14px 0;
  border-top: 1px solid var(--border);
  transition: background-color var(--ease), opacity var(--ease);
}
.mon-row:first-child { border-top: 0; }
.mon-row:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
.mon-row.mon-down { background: color-mix(in srgb, var(--down) 3%, transparent); }
.mon-row.mon-down:hover { background: color-mix(in srgb, var(--down) 6%, transparent); }
.mon-row.dragging { opacity: 0.4; }
.monitors.dragging, .monitors.dragging * { cursor: grabbing; user-select: none; }

/* The name is the link. Its ::after covers the whole row, so a click
   anywhere opens the monitor. The grip and the uptime bar sit above it. */
.mon-link { color: inherit; }
.mon-link::after { content: ""; position: absolute; inset: 0; }
.mon-link:focus-visible { outline: none; }
.mon-link:focus-visible::after { outline: 2px solid var(--accent-text); outline-offset: -2px; }
.mon-handle, .mon-uptime { position: relative; z-index: 1; }

.mon-handle {
  grid-area: grip;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  opacity: 0.45;
  transition: opacity var(--ease);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.mon-handle:hover, .mon-row:hover .mon-handle, .mon-handle:focus-visible { opacity: 1; }
.mon-handle:active { cursor: grabbing; }
.mon-handle:focus-visible { outline: 2px solid var(--accent-text); outline-offset: -2px; border-radius: 4px; }
.mon-handle svg { width: 12px; height: 16px; }
.mon-row > .dot { grid-area: dot; }
.mon-name { grid-area: name; display: flex; flex-direction: column; min-width: 0; }
.mon-name > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mon-uptime { grid-area: bar; }
.mon-pct { grid-area: pct; font-weight: 600; text-align: right; white-space: nowrap; }
.mon-pct small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 1px; }
.mon-spark { grid-area: spark; display: flex; justify-content: flex-end; }
.mon-checked { grid-area: checked; text-align: right; white-space: nowrap; }

@media (max-width: 900px) {
  .mon-row { grid-template-columns: 28px 8px minmax(0, 1fr) minmax(120px, 200px) 64px 110px; grid-template-areas: "grip dot name bar pct checked"; }
  .mon-spark { display: none; }
}
@media (max-width: 640px) {
  .mon-row {
    grid-template-columns: 28px 8px minmax(0, 1fr) auto;
    grid-template-areas: "grip dot name pct" "grip bar bar bar";
    row-gap: 10px;
    padding-right: 16px;
  }
  .mon-checked { display: none; }
  .mon-uptime { height: 20px; }
}

/* --- Monitor detail --- */

.mon-head { align-items: flex-start; }
.mon-title { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mon-title h1 { overflow-wrap: anywhere; }
.mon-since { font-size: 20px; font-weight: 600; margin-top: 4px; }
.mon-actions { flex-wrap: wrap; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 16px; }
.tiles .card { padding: 16px; }
.stat .value.value-empty { font-size: 16px; font-weight: 400; color: var(--muted); }
.stat .value.warn { color: var(--warn-text); }
.stat .value.down { color: var(--down-text); }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-head .card-title { margin-bottom: 0; }
.chart-empty { padding: 48px 0; text-align: center; }
.uptime-90 .seg[data-tip]::after { bottom: auto; top: calc(100% + 8px); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 16px 8px 0;
}
.table td { padding: 10px 16px 10px 0; border-top: 1px solid var(--border); vertical-align: top; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.nowrap { white-space: nowrap; }
.incident-open td:first-child { color: var(--down-text); font-weight: 600; }
@media (max-width: 900px) {
  /* Keep the newest 60 of 90 segments. */
  .uptime-90 .seg:nth-last-child(n+61) { display: none; }
}
@media (max-width: 640px) {
  /* Keep the newest 30 of 90 segments. */
  .uptime-90 .seg:nth-last-child(n+31) { display: none; }
}
.copy-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.push-url { overflow-wrap: anywhere; padding: 6px 10px; }
.code-block {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
}
.code-block code { padding: 0; background: transparent; font-size: inherit; }
.mt-12 { margin-top: 12px; }
@media (max-width: 640px) {
  .mon-title h1 { font-size: 28px; }
}

/* --- Monitor form --- */

.page-narrow { max-width: 760px; }
.type-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.type-card { position: relative; display: block; cursor: pointer; }
.type-card input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.type-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: 14px;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--ease), box-shadow var(--ease), background-color var(--ease);
}
.type-card-body .icon { color: var(--muted); margin-bottom: 6px; transition: color var(--ease); }
.type-card-body .type-name { font-weight: 600; }
.type-card:hover .type-card-body { border-color: var(--muted); }
.type-card input:checked + .type-card-body {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 1px var(--accent-text);
  background: color-mix(in srgb, var(--accent) 4%, var(--surface));
}
.type-card input:checked + .type-card-body .icon { color: var(--accent-text); }
.type-card input:focus-visible + .type-card-body { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* Only the fields of the chosen type are visible. */
.mon-form .for-http, .mon-form .for-tcp, .mon-form .for-ping, .mon-form .for-dns, .mon-form .for-push { display: none; }
.mon-form[data-type="http"] .for-http,
.mon-form[data-type="tcp"] .for-tcp,
.mon-form[data-type="ping"] .for-ping,
.mon-form[data-type="dns"] .for-dns,
.mon-form[data-type="push"] .for-push { display: block; }
.type-form .for-email, .type-form .for-slack, .type-form .for-discord, .type-form .for-telegram, .type-form .for-ntfy, .type-form .for-webhook { display: none; }
.type-form[data-type="email"] .for-email,
.type-form[data-type="slack"] .for-slack,
.type-form[data-type="discord"] .for-discord,
.type-form[data-type="telegram"] .for-telegram,
.type-form[data-type="ntfy"] .for-ntfy,
.type-form[data-type="webhook"] .for-webhook { display: flex; }
.secret { display: flex; align-items: center; gap: 12px; }
.secret-mask { display: inline-flex; align-items: center; flex: 1; color: var(--muted); letter-spacing: 0.1em; }

/* --- Notifications --- */

.channels {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chan-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto;
  grid-template-areas: "type name switch actions";
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.chan-row:first-child { border-top: 0; }
.chan-type { grid-area: type; color: var(--muted); display: flex; }
.chan-off .chan-type, .chan-off .chan-name > .w-600 { color: var(--muted); }
.chan-name { grid-area: name; display: flex; flex-direction: column; min-width: 0; }
.chan-name > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-error { color: var(--down-text); }
.chan-switch { grid-area: switch; display: flex; }
.chan-actions { grid-area: actions; flex-wrap: nowrap; }
@media (max-width: 640px) {
  .chan-row {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    grid-template-areas: "type name switch" "actions actions actions";
    row-gap: 10px;
  }
  .chan-actions { justify-content: flex-end; }
}

/* Switch: a pill with a knob. */
.switch {
  appearance: none;
  position: relative;
  width: 36px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--paused);
  cursor: pointer;
  transition: background-color var(--ease);
}
.switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--ease);
}
.switch[aria-checked="true"] { background: var(--up); }
.switch[aria-checked="true"] .knob { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.field-short { max-width: 220px; }
.field > span .muted { font-weight: 400; }

/* --- Style guide --- */

.sg-section { margin-bottom: 40px; }
.sg-section > h2 { font-size: 20px; margin-bottom: 4px; }
.sg-section > .muted { margin-bottom: 16px; }
.sg-themes { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .sg-themes { grid-template-columns: 1fr 1fr; } }
.sg-panel {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.sg-panel > .sg-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}
.sg-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.sg-swatch .chip { height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.sg-swatch .name { font-family: var(--mono); font-size: 12px; margin-top: 6px; }
.sg-type { display: flex; flex-direction: column; gap: 10px; }
.sg-type > div { display: flex; align-items: baseline; gap: 16px; }
.sg-type .muted { font-family: var(--mono); font-size: 12px; min-width: 56px; }
.sg-dots { display: flex; flex-direction: column; gap: 12px; }
.sg-monitor-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 16px;
}
@media (max-width: 640px) {
  .sg-monitor-row { grid-template-columns: auto 1fr auto; }
  .sg-monitor-row .sparkline { display: none; }
}
.mt-6 { margin-top: 6px; }
.chip-bg { background: var(--bg); }
.chip-surface { background: var(--surface); }
.chip-border { background: var(--border); }
.chip-text { background: var(--text); }
.chip-muted { background: var(--muted); }
.chip-accent { background: var(--accent); }
.chip-up { background: var(--up); }
.chip-warn { background: var(--warn); }
.chip-down { background: var(--down); }
.chip-paused { background: var(--paused); }

/* --- Settings --- */

.mt-24 { margin-top: 24px; }
.logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.logo-preview .brand-logo { width: 24px; height: 24px; }
img.brand-logo { object-fit: contain; }
.field input[type="file"] {
  flex: 1 1 200px;
  width: auto;
  height: auto;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
}
.field input[type="file"]::file-selector-button {
  height: 22px;
  padding: 0 10px;
  margin-right: 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.color-row { display: flex; align-items: center; gap: 12px; }
.color-row code { font-size: 13px; }
/* Same specificity as the general input rule above, so the padding wins. */
.field .color-row input[type="color"] {
  width: 56px;
  height: 40px;
  padding: 3px;
  flex: none;
  cursor: pointer;
}
.field .color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.field .color-row input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 4px; }
.field .color-row input[type="color"]::-moz-color-swatch { border: 0; border-radius: 4px; }
.badge { height: 20px; width: auto; display: block; }

/* --- Public status page --- */

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 24px;
}
.banner h1 { margin: 0; }
.banner .dot { width: 12px; height: 12px; }
.banner-up { border-color: color-mix(in srgb, var(--up) 35%, transparent); background: color-mix(in srgb, var(--up) 8%, var(--surface)); }
.banner-down { border-color: color-mix(in srgb, var(--down) 35%, transparent); background: color-mix(in srgb, var(--down) 8%, var(--surface)); }
.status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.status-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.status-row:first-child { border-top: 0; }
.status-head { display: flex; align-items: center; gap: 10px; }
.status-pct { margin-left: auto; white-space: nowrap; }
