:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #14171c;
  --muted: #5d6573;
  --faint: #8a93a3;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --up: #12805c;
  --up-soft: #e3f5ee;
  --degraded: #b45309;
  --degraded-soft: #fdf1e1;
  --down: #c62a2f;
  --down-soft: #fdeaea;
  --paused: #8a93a3;
  --chart: #4f46e5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f13;
    --surface: #15181e;
    --surface-2: #1c2028;
    --border: #272c36;
    --text: #e8ebf0;
    --muted: #a0a8b6;
    --faint: #6d7585;
    --accent: #7c74ff;
    --accent-ink: #0d0f13;
    --accent-soft: #23224a;
    --up: #34c38f;
    --up-soft: #12291f;
    --degraded: #f0a33a;
    --degraded-soft: #2d2213;
    --down: #ff6b6b;
    --down-soft: #331a1b;
    --chart: #8b84ff;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 15px; }
.brand img { width: 26px; height: 26px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 17px; height: 17px; flex: none; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); display: grid; gap: 6px; }
.plan-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
main { padding: 28px 36px 60px; max-width: 1240px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { margin-top: 4px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: inline-block; }

/* ---------- primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.stack { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.stack > *, .grid-2 > * { min-width: 0; }
.card { min-width: 0; }
.card:has(> table) { overflow-x: auto; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--down); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn svg { width: 15px; height: 15px; }

label.field { display: grid; gap: 6px; font-weight: 550; font-size: 13px; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select, textarea {
  height: 36px; padding: 0 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input.mono { font-family: var(--mono); font-size: 13px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.check .hint { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 550;
  padding: 5px 12px; border-radius: 6px; cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 99px;
  font-size: 12px; font-weight: 600; text-transform: capitalize; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.up { color: var(--up); background: var(--up-soft); }
.pill.degraded { color: var(--degraded); background: var(--degraded-soft); }
.pill.down { color: var(--down); background: var(--down-soft); }
.pill.pending, .pill.paused { color: var(--paused); background: var(--surface-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.up { background: var(--up); box-shadow: 0 0 0 3px var(--up-soft); }
.dot.degraded { background: var(--degraded); box-shadow: 0 0 0 3px var(--degraded-soft); }
.dot.down { background: var(--down); box-shadow: 0 0 0 3px var(--down-soft); animation: pulse 1.6s infinite; }
.dot.pending, .dot.paused { background: var(--paused); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--down-soft); } }
.tag { font-family: var(--mono); font-size: 11.5px; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { padding: 14px 18px; }
.tile .label { font-size: 12px; color: var(--muted); font-weight: 550; }
.tile .value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.value.up { color: var(--up); } .value.degraded { color: var(--degraded); } .value.down { color: var(--down); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mon-name { font-weight: 600; }
.mon-url { font-family: var(--mono); font-size: 12px; color: var(--muted); max-width: 360px; }

.empty { text-align: center; padding: 56px 20px; }
.empty h2 { margin-bottom: 6px; font-size: 17px; }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto 18px; }

/* ---------- charts ---------- */
.spark { display: block; }
.chart-wrap { position: relative; padding: 8px 20px 14px; }
.chart { width: 100%; height: 240px; display: block; }
.chart .grid line { stroke: var(--border); }
.chart .axis text { fill: var(--faint); font-size: 11px; font-family: system-ui, sans-serif; }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; }
.chart .area { fill: var(--chart); opacity: .1; }
.chart .band-down { fill: var(--down); }
.chart .band-degraded { fill: var(--degraded); }
.chart .band-up { fill: var(--up); opacity: .55; }
.chart .cursor { stroke: var(--faint); stroke-dasharray: 3 3; }
.chart .hover-dot { fill: var(--surface); stroke: var(--chart); stroke-width: 2; }
.tip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px;
  padding: 7px 10px; border-radius: 7px; white-space: nowrap; transform: translate(-50%, -100%); margin-top: -10px; z-index: 2;
}
.tip b { font-weight: 650; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ---------- signals ---------- */
.signals { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; padding: 16px 20px; }
.signal { border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; display: grid; gap: 4px; }
.signal .top { display: flex; justify-content: space-between; align-items: center; }
.signal .name { font-weight: 600; text-transform: capitalize; }
.signal .msg { font-size: 12.5px; color: var(--muted); word-break: break-word; }

details.check-row summary { list-style: none; cursor: pointer; }
details.check-row summary::-webkit-details-marker { display: none; }
.check-line { display: grid; grid-template-columns: 22px 150px 70px 1fr; gap: 10px; align-items: center; padding: 9px 20px; border-bottom: 1px solid var(--border); }
.check-line:hover { background: var(--surface-2); }
.pdot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; margin-right: 6px; vertical-align: -1px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip.add { color: var(--muted); border-style: dashed; gap: 6px; }
.chip.add svg { width: 14px; height: 14px; }
.check-line.ev-line { grid-template-columns: 22px 150px 130px 1fr; }
.check-detail pre.snippet { max-height: 280px; overflow: auto; }
details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary .muted { visibility: hidden; }
details.card > .card { border: 0; box-shadow: none; border-top: 1px solid var(--border); border-radius: 0; }
code.copyable { word-break: break-all; }
.check-detail { padding: 10px 20px 14px 52px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12.5px; display: grid; gap: 4px; }

/* ---------- form ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 650; margin: 6px 0 -4px; }
.hdr-row { display: grid; grid-template-columns: 1fr 1.6fr 34px; gap: 8px; margin-bottom: 8px; }
.signal-opts { display: flex; gap: 10px; flex-wrap: wrap; }
.signal-opt { border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; display: flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 550; }
.signal-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.signal-opt input { accent-color: var(--accent); margin: 0; }
.test-result { border-top: 1px solid var(--border); }
.form-actions { display: flex; gap: 10px; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.error { color: var(--down); background: var(--down-soft); padding: 9px 12px; border-radius: 8px; font-size: 13px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; padding: 30px 30px 26px; }
.auth-card .brand { padding: 0 0 20px; justify-content: center; font-size: 17px; }
.auth-card h1 { text-align: center; font-size: 20px; }
.auth-card .lead { text-align: center; color: var(--muted); margin: 6px 0 22px; }
.auth-card form { display: grid; gap: 14px; }
.auth-card .switch { text-align: center; margin-top: 18px; color: var(--muted); }

/* ---------- plans ---------- */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.plan { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 10px; align-content: start; }
.plan.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan .price { font-size: 24px; font-weight: 700; }
.plan .price small { font-size: 13px; color: var(--muted); font-weight: 500; }
.plan ul { margin: 0; padding-left: 18px; color: var(--muted); display: grid; gap: 3px; }

.keybox { font-family: var(--mono); background: var(--surface-2); border: 1px dashed var(--accent); border-radius: 8px; padding: 10px 12px; word-break: break-all; }
pre.snippet { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; margin: 0; }

#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 9px; font-weight: 550; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 10;
}
#toast.bad { background: var(--down); color: #fff; }

@media (max-width: 1280px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 960px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plans, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
  .brand { padding: 4px 8px; }
  .nav { display: flex; gap: 2px; flex-wrap: wrap; }
  .sidebar-foot { display: none; }
  main { padding: 20px 16px 48px; }
  .form-grid { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .check-line { grid-template-columns: 22px 1fr 60px; }
  .check-line .summary { grid-column: 2 / -1; }
  table { display: block; overflow-x: auto; }
}
