:root {
  color-scheme: dark;
  --bg: #060a13;
  --bg-2: #0b1220;
  --card: #0e1628;
  --card-2: #131d33;
  --line: #1d2945;
  --text: #e8eef8;
  --muted: #8592ab;
  --azure: #2b8cff;
  --azure-2: #63aaff;
  --azure-dim: #133a6e;
  --down: #ff5c7a;
  --warn: #ffb648;
  --none: #18223a;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--azure-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .88em; }
.hidden { display: none !important; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 12px max(16px, calc((100% - 960px) / 2));
  background: rgba(6, 10, 19, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 700; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.top .spacer { flex: 1; }
.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }

/* controls */
button, .btn {
  font: inherit; font-size: .9rem; font-weight: 550;
  color: var(--text); background: var(--card-2);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 14px; cursor: pointer;
  transition: background .12s, border-color .12s;
}
button:hover, .btn:hover { border-color: #2c3c63; background: #18243f; text-decoration: none; }
button.primary { background: var(--azure); border-color: var(--azure); color: #fff; }
button.primary:hover { background: #4499ff; }
button.danger { color: var(--down); }
button.danger:hover { border-color: var(--down); }
button.link { background: none; border: none; padding: 0; color: var(--azure-2); }
button:disabled { opacity: .55; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--azure); outline-offset: 1px; border-color: transparent;
}
label { display: grid; gap: 5px; font-size: .85rem; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.card + .card, .stack > * + * { margin-top: 14px; }

/* status summary */
.summary { display: flex; align-items: center; gap: 14px; padding: 20px; margin-bottom: 18px; }
.summary h1 { font-size: 1.25rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.up { background: var(--azure); box-shadow: 0 0 0 4px rgba(43, 140, 255, .18); }
.dot.down { background: var(--down); box-shadow: 0 0 0 4px rgba(255, 92, 122, .18); }
.summary .dot { width: 14px; height: 14px; }

/* monitor list */
.mon { display: block; color: inherit; }
.mon:hover { text-decoration: none; border-color: #2a3a60; }
.mon-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mon-head h2 { flex: 1; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill {
  font-size: .75rem; padding: 2px 8px; border-radius: 99px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--muted);
}
.pill.private { color: var(--warn); border-color: #4a3a1a; }

/* uptime blocks */
.bars { display: flex; gap: 2px; height: 32px; align-items: stretch; }
.bars > * {
  flex: 1; min-width: 2px; border: 0; padding: 0; border-radius: 2px; background: var(--none);
  transition: transform .1s, filter .1s;
}
.bars > .up { background: var(--azure); }
.bars > .part { background: var(--warn); }
.bars > .down { background: var(--down); }
.bars > button { cursor: zoom-in; }
.bars > button:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.bars > :hover { filter: brightness(1.25); transform: scaleY(1.08); }
.bars.checks { flex-wrap: wrap; height: auto; }
.bars.checks > * { flex: 0 0 auto; width: 10px; height: 26px; }
.narrow { display: none; }
.bars-legend { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-top: 6px; }

/* detail */
.detail-head { display: flex; gap: 14px; align-items: center; margin: 4px 0 18px; flex-wrap: wrap; }
.detail-head h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.facts { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 18px; }
.facts div { display: grid; }
.facts b { font-size: 1.2rem; font-weight: 650; }
.facts span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: .9rem; margin-bottom: 12px; flex-wrap: wrap; }
.crumbs button { padding: 3px 10px; font-size: .85rem; }
.crumbs .sep { color: var(--muted); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

/* latency chart */
.chart { position: relative; height: 180px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .line { fill: none; stroke: var(--azure); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.chart .area { fill: url(#fade); stroke: none; }
.chart .grid line { stroke: var(--line); vector-effect: non-scaling-stroke; }
.chart .fail { fill: var(--down); }
.chart .cross { stroke: var(--muted); stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: 4px; }
.yaxis { position: absolute; top: 0; left: 0; font-size: .72rem; color: var(--muted); pointer-events: none; }
.tip {
  position: fixed; z-index: 20; pointer-events: none;
  background: #0a1222; border: 1px solid #2a3a60; border-radius: 8px;
  padding: 6px 10px; font-size: .8rem; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.empty { color: var(--muted); text-align: center; padding: 28px 0; font-size: .9rem; }

/* incidents */
.incident { border-left: 3px solid var(--down); padding: 2px 0 2px 14px; }
.incident.resolved { border-left-color: var(--line); }
.incident + .incident { margin-top: 18px; }
.incident-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.incident-head h3 { flex: 1; }
.note { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; margin-top: 8px; }
.note p { margin: 0 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note small { color: var(--muted); }
.note-form { display: flex; gap: 8px; margin-top: 8px; align-items: flex-end; }
.note-form textarea { min-height: 40px; }

/* panel */
.panel { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--bg-2); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.side .brand { padding: 0 10px 18px; }
.side a.nav {
  display: block; color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 550;
}
.side a.nav:hover { color: var(--text); background: var(--card); text-decoration: none; }
.side a.nav.on { color: #fff; background: var(--azure-dim); }
.side .foot { margin-top: auto; font-size: .82rem; color: var(--muted); padding: 10px 12px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.side .foot .row { margin-top: 8px; }
.content { padding: 28px 32px 64px; max-width: 1040px; width: 100%; }
.content > h1 { margin-bottom: 18px; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--muted); font-weight: 550; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.url { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
td.actions button + button { margin-left: 6px; }
.table-wrap { overflow-x: auto; }

.auth { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.auth .brand { justify-content: center; font-size: 1.4rem; margin-bottom: 22px; }
.auth .brand img { width: 36px; height: 36px; }
.auth form { display: grid; gap: 14px; }
.qr { display: block; background: #fff; border-radius: 8px; padding: 6px; width: 220px; margin: 6px auto; }
.code-input { font-family: var(--mono); font-size: 1.3rem; letter-spacing: .4em; text-align: center; }
.err { color: var(--down); font-size: .88rem; min-height: 1.3em; }
.invite { display: flex; gap: 8px; margin-top: 12px; }
.stat-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-list > div { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: grid; }
.stat-list b { font-size: 1.25rem; }
.stat-list span { color: var(--muted); font-size: .78rem; }

dialog {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 22px; width: min(520px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(2, 5, 12, .7); }
dialog form { display: grid; gap: 14px; }
dialog .row { justify-content: flex-end; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--card-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 16px; font-size: .9rem; opacity: 0; transition: .2s; pointer-events: none; z-index: 30;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { border-color: var(--down); color: var(--down); }

@media (max-width: 720px) {
  .panel { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; align-content: center; padding: 10px; }
  .side .brand { padding: 0 10px 0 4px; }
  .side .foot { margin: 0 0 0 auto; border: none; padding: 0; }
  .side .foot .who { display: none; }
  .side .foot .row { margin: 0; }
  .content { padding: 20px 16px 48px; }
  .bars.days90 > :nth-child(-n+60) { display: none; }
  .wide { display: none; }
  .narrow { display: inline; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
