:root {
  --bg: #f7f7f5; --panel: #fff; --text: #1b1c1e; --muted: #6b6f76; --border: #e4e4e0;
  --accent: #1f9d55; --accent-text: #fff; --link: #2554d9;
  --up: #1f9d55; --down: #d93a3a; --pending: #a0a4ab; --warn: #c98a0b;
  --up-bg: #e5f5ec; --down-bg: #fbe8e8; --warn-bg: #fdf4e1;
  --radius: 8px;
}
/* Dark: follows the device unless the user picked a theme (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121315; --panel: #1b1c1f; --text: #e8e8e6; --muted: #9a9ea6; --border: #2c2e32;
    --accent: #34c774; --accent-text: #06210f; --link: #6b8cff;
    --up-bg: #133022; --down-bg: #3a1717; --warn-bg: #3a2c0f;
  }
}
:root[data-theme="dark"] {
    --bg: #121315; --panel: #1b1c1f; --text: #e8e8e6; --muted: #9a9ea6; --border: #2c2e32;
    --accent: #34c774; --accent-text: #06210f; --link: #6b8cff;
    --up-bg: #133022; --down-bg: #3a1717; --warn-bg: #3a2c0f;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--link, var(--accent)); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
header.top { border-bottom: 1px solid var(--border); background: var(--panel); }
header.top .wrap { display: flex; align-items: center; gap: 20px; height: 56px; }
.logo { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 26px; height: 26px; flex: none; }
/* The pulse draws itself once when the page loads. */
.logo-pulse { stroke-dasharray: 100; animation: pulse-draw 1s ease-in-out .15s both; }
@keyframes pulse-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .logo-pulse { animation: none; } }
.logo-word { font-weight: 750; font-size: 18px; letter-spacing: -0.03em; }
.logo-tld { font-weight: 500; color: var(--muted); }
nav { display: flex; gap: 12px; flex: 1; align-items: center; }
nav a + a::before { content: "/"; margin-right: 12px; color: var(--border); font-weight: 300; display: inline-block; transform: skewX(-8deg); }
nav a { color: var(--muted); }
nav a.on { color: var(--text); font-weight: 600; }
main { padding: 28px 0 60px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.btn { display: inline-block; border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 7px 14px; border-radius: 6px; font: inherit; cursor: pointer; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--down); }
.btn.link { border: 0; background: none; color: var(--muted); padding: 0; }
form.inline { display: inline; }
input, textarea, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; width: 100%; }
textarea { font-family: ui-monospace, monospace; font-size: 13px; }
label { display: block; font-weight: 600; margin: 14px 0 4px; }
label.check { font-weight: normal; display: flex; gap: 8px; align-items: center; }
label.check input { width: auto; }
.field-error { color: var(--down); font-size: 13px; margin-top: 4px; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; background: var(--up-bg); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 18px 0; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; }
.stat a { color: inherit; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--pending); margin-right: 6px; vertical-align: middle; }
.dot.up { background: var(--up); } .dot.down { background: var(--down); }
/* Down monitors in the list: a ring pulses out of the dot to draw the eye. */
.dot.live { position: relative; }
.dot.live::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--down); animation: dot-ping 1.6s cubic-bezier(0, 0, .2, 1) infinite; }
@keyframes dot-ping { 0% { transform: scale(1); opacity: .7; } 80%, 100% { transform: scale(2.8); opacity: 0; } }
tr.is-down td { background: color-mix(in srgb, var(--down-bg) 55%, transparent); }
tr.is-down a { color: var(--down); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .dot.live::after { animation: none; } }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--border); color: var(--muted); }
.badge.up { background: var(--up-bg); color: var(--up); } .badge.down { background: var(--down-bg); color: var(--down); }
.regions { display: flex; gap: 4px; }
.region { font-size: 11px; padding: 0 5px; border-radius: 4px; background: var(--border); color: var(--muted); text-transform: uppercase; }
.region.ok { background: var(--up-bg); color: var(--up); } .region.fail { background: var(--down-bg); color: var(--down); }
.bars { display: flex; gap: 2px; height: 30px; align-items: stretch; }
.bars i { flex: 1; border-radius: 2px; background: var(--border); min-width: 2px; }
.bars i.u { background: var(--up); } .bars i.w { background: var(--warn); } .bars i.d { background: var(--down); }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.auth { max-width: 380px; margin: 40px auto; }
.hero { text-align: center; padding: 50px 0 30px; }
.hero h1 { font-size: 38px; }
.hero p { font-size: 18px; color: var(--muted); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 30px; }
.status-head { padding: 28px; border-radius: var(--radius); margin-bottom: 24px; font-size: 19px; font-weight: 600; }
.status-head.up { background: var(--up-bg); color: var(--up); }
.status-head.down { background: var(--down-bg); color: var(--down); }
.svc { padding: 16px 0; border-bottom: 1px solid var(--border); }
.svc:last-child { border-bottom: 0; }
svg.spark { width: 100%; height: 80px; display: block; }
svg.spark path { fill: none; stroke: var(--accent); stroke-width: 2; }
pre.code { background: var(--bg); padding: 10px; border-radius: 6px; overflow-x: auto; }
@media (max-width: 640px) {
  .hide-sm { display: none; }
  header.top .wrap { gap: 12px; }
  nav { gap: 10px; font-size: 14px; }
}
.notice { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-radius: 6px; margin: 0 0 16px; background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--muted); }
.notice-icon { width: 18px; height: 18px; color: var(--muted); flex: none; }
.alerts-pause { margin: 0 0 16px; gap: 8px; }
.alerts-pause select { width: auto; padding: 6px 8px; }
.flag { width: 15px; height: 10px; vertical-align: -1px; margin-right: 4px; border-radius: 1px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.region.blocked { background: var(--warn-bg); color: var(--warn); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
details { margin: 14px 0 4px; }
details > summary { cursor: pointer; color: var(--accent); }
.locations { list-style: none; padding: 0; margin: 8px 0 0; }
.locations li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.locations li:first-child { border-top: 0; }
.locations label.check { margin: 0; min-width: 170px; }
.locations code { font-size: 13px; }
.badge.info { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--link, var(--accent)); }
.post { margin-bottom: 12px; }
.post.post-incident { border-left: 3px solid var(--down); }
.post.post-maintenance { border-left: 3px solid var(--accent); }
.timeline { list-style: none; margin: 10px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.timeline li { margin: 0 0 10px; }
.timeline li div { white-space: pre-line; }
.status-head.maint { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--link, var(--accent)); }
.status-title { display: flex; align-items: center; gap: 14px; }
.status-logo { max-height: 48px; max-width: 160px; }
h3.group { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 4px; }
h3.group:first-child { margin-top: 0; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented label { margin: 0; cursor: pointer; }
.segmented label { position: relative; }
.segmented input { position: absolute; width: 1px; height: 1px; padding: 0; margin: 0; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 7px 16px; color: var(--muted); }
.segmented label + label span { border-left: 1px solid var(--border); }
.segmented input:checked + span { background: var(--accent); color: var(--accent-text); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
/* Visual editor (status page preview inside the dashboard) */
.editor-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 20px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 14px rgba(0,0,0,.06); font-size: 14px; }
.editor-hint { color: var(--muted); }
.editor-field { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.editor-field input { width: 34px; height: 28px; padding: 2px; }
.editor-status { color: var(--muted); font-size: 13px; min-width: 90px; }
[contenteditable][data-edit] { outline: 1px dashed transparent; outline-offset: 4px; border-radius: 4px; cursor: text; }
[contenteditable][data-edit]:hover { outline-color: var(--border); }
[contenteditable][data-edit]:focus { outline: 2px solid var(--accent); }
[contenteditable][data-edit]::after { content: " ✎"; font-size: .7em; color: var(--muted); }
[contenteditable][data-edit]:empty::before { content: attr(data-placeholder); color: var(--muted); }
.edit-logo { border: 1px dashed var(--border); background: none; padding: 4px; border-radius: 8px; cursor: pointer; min-width: 56px; min-height: 48px; color: var(--muted); font: inherit; }
.edit-logo:hover { border-color: var(--accent); }
.preview-frame { width: 100%; height: 720px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }

.segmented span { display: inline-flex; align-items: center; gap: 6px; }
.segmented svg { width: 15px; height: 15px; }
/* Visitor theme switch on public status pages: icons only. */
.theme-switch .segmented span { padding: 5px 8px; }
.status-top { display: flex; align-items: flex-start; gap: 12px; }
.status-top .status-title { flex: 1; }
.editor-pop { position: absolute; z-index: 10; width: 320px; padding: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); font-size: 14px; }
.editor-pop label { margin-top: 0; }
.powered { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 30px; color: var(--muted); font-size: 13px; }
.powered .logo-mark { width: 18px; height: 18px; }
.powered .logo-word { font-size: 14px; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--border); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 6px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.qr { background: #fff; padding: 8px; border-radius: 8px; display: inline-block; line-height: 0; }
.codes { display: grid; grid-template-columns: repeat(2, max-content); gap: 4px 24px; font-family: ui-monospace, monospace; font-size: 15px; padding: 12px 14px; background: var(--bg); border-radius: 6px; }
/* Monitor list: actions in their own column, shown on row hover (always on touch screens). */
th.actions, td.actions { width: 1%; white-space: nowrap; text-align: right; padding-left: 4px; }
.row-actions { display: inline-flex; gap: 4px; opacity: 0; transition: opacity .12s; }
tr:hover .row-actions, tr:focus-within .row-actions, .row-actions:has(.armed) { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .i-play path { fill: currentColor; }
.icon-btn[data-paused="1"] .i-pause, .icon-btn[data-paused="0"] .i-play { display: none; }
.icon-btn.danger:hover { color: var(--down); border-color: var(--down); }
.icon-btn.armed { color: #fff; background: var(--down); border-color: var(--down); }
/* Confirmation label floats above the armed button, so the row does not shift. */
.icon-btn .confirm-text { display: none; position: absolute; bottom: calc(100% + 6px); right: 0; padding: 4px 8px; border-radius: 6px;
  background: var(--down); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; }
.icon-btn .confirm-text::after { content: ""; position: absolute; top: 100%; right: 10px; border: 5px solid transparent; border-top-color: var(--down); }
.icon-btn.armed .confirm-text { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
tr.removing { opacity: 0; transition: opacity .25s; }

/* Phones: the nav scrolls sideways inside the header instead of widening the page. */
@media (max-width: 640px) {
  .user-chip.hide-sm { display: none; }
  header.top .wrap { gap: 10px; }
  header.top nav { overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  header.top nav a { flex: none; }
}
/* Import domains (Add monitors page) */
h3.import-group { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.import-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.import-tile { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font: inherit; cursor: pointer; }
.import-tile:hover { border-color: var(--accent); }
.import-tile > span:last-child { display: flex; flex-direction: column; }
.import-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.import-dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text); }
.import-dialog::backdrop { background: rgba(0,0,0,.35); }
.import-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.import-body { padding: 4px 18px 18px; }
.import-body > p:first-child { margin-top: 14px; }
.import-list { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.import-row { display: flex; align-items: center; gap: 10px; margin: 0; padding: 8px 12px; font-weight: 400; border-top: 1px solid var(--border); cursor: pointer; }
.import-row:first-child { border-top: 0; }
.import-row input { width: auto; }
.import-row span:nth-child(2) { flex: 1; }
.import-row.dup { color: var(--muted); cursor: default; }

/* Dot feedback after resuming a monitor in the list (runs once). */
.dot.anim-resume { position: relative; }
.dot.anim-resume::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--up); animation: dot-ping .9s cubic-bezier(0, 0, .2, 1) 1; }
@media (prefers-reduced-motion: reduce) { .dot.anim-resume::after { animation: none; display: none; } }
/* Account menu (avatar, top right) */
.user-menu { position: relative; }
.user-menu > summary { display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; padding: 4px 6px; border-radius: 8px; color: var(--muted); }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover, .user-menu[open] > summary { background: var(--bg); color: var(--text); }
.user-menu .chev { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; transition: transform .15s; }
.user-menu[open] .chev { transform: rotate(180deg); }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 300px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.14); }
.menu-head { display: flex; flex-direction: column; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.menu-section { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.menu-section:last-child { border-bottom: 0; }
.menu-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
.menu-row { display: flex; align-items: center; gap: 6px; }
.small-btn { padding: 3px 9px; font-size: 13px; }
.segmented-full { display: flex; }
.segmented-full label { flex: 1; }
.segmented-full label { display: flex; }
.segmented-full span { flex: 1; display: flex; justify-content: center; padding: 6px 4px; font-size: 13px; }
.menu-links { display: flex; flex-direction: column; gap: 2px; padding: 6px; }
.menu-links a, .menu-link { display: block; width: 100%; text-align: left; padding: 7px 8px; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.menu-links a:hover, .menu-link:hover { background: var(--bg); text-decoration: none; }
/* "Pause alerts" button: durations open on hover or keyboard focus. */
.pause-pick { position: relative; }
.pause-pick > .btn { display: inline-flex; align-items: center; gap: 6px; }
.pause-pick .chev { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.pause-options { position: absolute; left: 0; top: 100%; z-index: 15; min-width: 180px; padding: 6px; margin-top: 4px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.14); display: none; }
.pause-options::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px; } /* hover bridge */
.pause-pick:hover .pause-options, .pause-pick:focus-within .pause-options { display: block; }
.pause-options button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; cursor: pointer; }
.pause-options button:hover, .pause-options button:focus-visible { background: var(--bg); }
.account-forms { gap: 12px 16px; }
.account-forms .panel > b { display: block; }
