:root {
  --bg: #EDF0F3;
  --surface: #FFFFFF;
  --ink: #17212B;
  --muted: #66727F;
  --line: #DDE2E7;
  --hover: #F6F8FA;
  --up: #15966A;
  --slow: #C98204;
  --down: #D1433F;
  --empty: #E4E8EC;
  --accent: #2F4AD0;
  --accent-ink: #FFFFFF;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F151C;
    --surface: #171F28;
    --ink: #E5EBF1;
    --muted: #8A96A4;
    --line: #26313D;
    --hover: #1C2530;
    --up: #2DBE87;
    --slow: #E5A73A;
    --down: #F0625E;
    --empty: #222C37;
    --accent: #7087FF;
    --accent-ink: #0F151C;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
code { font-size: 13px; word-break: break-all; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
.muted { color: var(--muted); }
.good { color: var(--up); }
.warn-text { color: var(--slow); }
.problem { color: var(--down); font-weight: 500; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 22px 20px 72px; }

/* Header */
.top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 48px; }
.top form { margin: 0; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; }
.brand .eye { fill: var(--accent); }
.brand .pupil { fill: var(--surface); }

/* Buttons */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 9px;
  padding: 8px 14px; font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, border-color .15s;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover, .btn.ghost[aria-current] { background: var(--surface); }
.btn.danger { background: transparent; color: var(--down); border-color: var(--line); }
.btn.danger:hover { border-color: var(--down); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.big { padding: 12px 20px; font-size: 15px; }

/* Messages */
.flash, .banner { border-radius: 10px; padding: 12px 16px; margin-bottom: 24px; font-weight: 500; }
.flash.ok { background: color-mix(in srgb, var(--up) 12%, var(--surface)); color: var(--ink); border-left: 3px solid var(--up); }
.flash.err, .banner { background: color-mix(in srgb, var(--down) 10%, var(--surface)); border-left: 3px solid var(--down); }
.banner { border-left-color: var(--slow); background: color-mix(in srgb, var(--slow) 12%, var(--surface)); }

/* Hero: the one big statement */
.hero h1 { font-size: clamp(30px, 5.4vw, 52px); font-weight: 700; letter-spacing: -0.025em; }
.hero p { margin: 10px 0 0; color: var(--muted); font-size: 16px; }
.hero .btn { margin-top: 24px; }
.hero.is-down h1 { color: var(--down); }

/* Site list */
.list { margin-top: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cols, .row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 2fr) 88px 76px 76px;
  gap: 22px; align-items: center; padding: 14px 20px;
}
.cols { font-size: 13px; color: var(--muted); padding-top: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.site-row + .site-row { border-top: 1px solid var(--line); }
.row { cursor: pointer; list-style: none; }
.row::-webkit-details-marker { display: none; }
.row:hover, .site-row[open] > .row { background: var(--hover); }
.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.num small { color: var(--muted); font-weight: 400; }

.a-site { display: flex; align-items: center; gap: 14px; min-width: 0; }
.who { display: flex; flex-direction: column; min-width: 0; }
.name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.url { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); position: relative; }
.state-up .dot { background: var(--up); }
.state-warn .dot { background: var(--slow); }
.state-down .dot { background: var(--down); }
.state-pending .dot, .state-paused .dot { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
.state-paused .name, .state-paused .beat { opacity: .45; }
.state-down .dot::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid var(--down); animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .state-down .dot::after { animation: none; opacity: .4; } }

/* Heartbeat strip: bar height is response time, colour is result */
.beat { display: flex; align-items: flex-end; gap: 2px; height: 30px; }
.beat i { flex: 1; min-width: 2px; border-radius: 2px; background: var(--up); }
.beat i.s { background: var(--slow); }
.beat i.d { background: var(--down); }
.beat i.e { background: var(--empty); height: 24%; }

/* Expanded detail */
.detail {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 2fr) auto;
  gap: 22px; padding: 6px 20px 22px 44px; background: var(--hover);
}
.detail p { margin: 0 0 8px; }
.status-line { font-weight: 600; }
.incidents h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.incidents ul { list-style: none; margin: 0; padding: 0; }
.incidents li { display: grid; grid-template-columns: 150px 90px 1fr; gap: 10px; padding: 4px 0; font-size: 14px; }
.actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.actions form { margin: 0; }
.actions .btn { width: 100%; justify-content: center; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
label small { font-weight: 400; color: var(--muted); font-size: 13px; }
input, select, textarea {
  font: inherit; font-weight: 400; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.inline-form { margin-top: 12px; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 28px;
  width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--ink);
}
dialog::backdrop { background: rgb(10 16 24 / .45); }
dialog h2 { font-size: 22px; }

textarea { font-size: 14px; line-height: 1.6; resize: vertical; min-height: 180px; }
.bulk-count { margin: -6px 0 0; font-size: 13px; min-height: 1.2em; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.hero-actions .btn { margin-top: 0; }
dialog#bulkDlg { width: min(600px, calc(100vw - 32px)); }

/* Setup / login */
.gate { max-width: 400px; margin: 14vh auto 0; }
.gate h1 { font-size: 34px; letter-spacing: -0.02em; margin-bottom: 10px; }
.gate .muted { margin: 0 0 28px; }
.gate form { margin-top: 24px; }

/* Settings */
.settings { max-width: 720px; }
.settings > h1 { font-size: 34px; letter-spacing: -0.02em; margin-bottom: 28px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
.panel h2 { font-size: 18px; margin-bottom: 16px; }
.panel p { margin: 0 0 12px; }
.copy { display: flex; gap: 10px; align-items: center; background: var(--bg); border-radius: 9px; padding: 10px 10px 10px 14px; margin-bottom: 14px; }
.copy code { flex: 1; }

/* Small screens */
@media (max-width: 760px) {
  .top { margin-bottom: 32px; }
  .brand { width: 100%; margin-bottom: 6px; }
  .top { gap: 6px; }
  .top .btn { padding: 7px 10px; font-size: 13px; }
  .cols { display: none; }
  .row {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-areas: "site site site" "beat beat beat" "ms d1 d30";
    gap: 12px; padding: 16px;
  }
  .a-site { grid-area: site; } .a-beat { grid-area: beat; }
  .a-ms { grid-area: ms; } .a-d1 { grid-area: d1; } .a-d30 { grid-area: d30; }
  .num { text-align: left; }
  .num::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
  .beat { gap: 1px; }
  .detail { grid-template-columns: 1fr; padding: 4px 16px 20px; }
  .incidents li { grid-template-columns: 1fr auto; }
  .incidents li small { grid-column: 1 / -1; }
  .actions { flex-direction: row; flex-wrap: wrap; }
  .actions .btn { width: auto; }
}
