/* ==========================================================================
   Uptime — instrument panel.
   Colour is data: teal means up, vermilion means down, amber means slow.
   Nothing decorative is coloured, so a glance at the page reads as a reading.
   ========================================================================== */

:root {
  --ink: #0e1116;
  --panel: #161b22;
  --panel-raised: #1b222b;
  --rule: #242c36;
  --rule-soft: #1e252e;
  --paper: #e6ebf2;
  --muted: #7d8894;
  --muted-dim: #59626d;

  --live: #35d6a4;
  --alarm: #ff5b4a;
  --warn: #f2b33d;
  --idle: #4b5563;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;

  --gap: 1.25rem;
  --radius: 6px;
  --shell-width: 1160px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  /* Faint plotting-paper grid, the one piece of texture in the design. */
  background-image:
    linear-gradient(var(--rule-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule-soft) 1px, transparent 1px);
  background-size: 64px 64px, 64px 64px;
  background-position: -1px -1px;
}

a { color: inherit; }

button { font: inherit; }

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--panel-raised);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

:focus-visible {
  outline: 2px solid var(--live);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --------------------------------------------------------------- chrome -- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 0 1.5rem;
  height: 58px;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-decoration: none;
}

.wordmark__lamp {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 18%, transparent);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.topnav__link {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  padding: 0.35rem 0;
  border-bottom: 1px solid transparent;
}

.topnav__link:hover { color: var(--paper); }
.topnav__link.is-active { color: var(--paper); border-bottom-color: var(--live); }

.page {
  max-width: var(--shell-width);
  margin: 0 auto;
  padding: 2.25rem 1.5rem 4rem;
}

.narrow { max-width: 560px; }

.page__title {
  font-family: var(--mono);
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  margin: 0 0 1.5rem;
}

.section__title {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.85rem;
  font-weight: 500;
}

/* -------------------------------------------------------------- verdict -- */
/* The page answers its one question before you read anything else. */

.verdict { margin-bottom: 2rem; }

.verdict__line {
  font-family: var(--mono);
  font-size: clamp(1.35rem, 3.4vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}

.verdict__line em {
  font-style: normal;
  color: var(--live);
}

.verdict__line.is-down em { color: var(--alarm); }

.verdict__meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.verdict__add { margin-left: auto; }

/* ---------------------------------------------------------------- strip -- */

.strip {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.strip__head,
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 1.6fr) 104px 104px;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
}

.strip__head {
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
  background: var(--panel-raised);
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-dim);
}

.strip__col--num { text-align: right; }

/* Project bands: the strip reads as one instrument with labelled sections. */
.group__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.1rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.group__head:not(:first-child) {
  border-top: 1px solid var(--rule);
  margin-top: 0.5rem;
}

.group__name { color: var(--paper); }
.group__count { color: var(--muted-dim); }
.group__count.is-down { color: var(--alarm); }

.eyebrow {
  display: inline-block;
  margin-left: 0.85rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-dim);
}

.row {
  border-bottom: 1px solid var(--rule-soft);
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: background 120ms ease;
}

.row:last-child { border-bottom: 0; }
.row:hover { background: var(--panel-raised); }

/* Status edge on the left of each row, like a marker pen on chart paper. */
.row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--row-color, var(--idle));
}

.row--up { --row-color: var(--live); }
.row--down { --row-color: var(--alarm); }
.row--pending { --row-color: var(--idle); }
.row--paused { --row-color: var(--idle); }

.row__id { min-width: 0; }

.row__name {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__url {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.15rem;
}

.lamp {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--row-color, var(--idle));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--row-color, var(--idle)) 16%, transparent);
}

.lamp--down { animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--alarm) 16%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--alarm) 6%, transparent); }
}

.row__num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

.row__num--muted { color: var(--muted); }

.row__sub {
  display: block;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-dim);
}

/* ------------------------------------------------------------ heartbeat -- */
/* Bar height is latency against this monitor's own p95, so a slow-but-up
   service looks different from a fast one without needing a second chart. */

.trace {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 34px;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--rule);
}

.trace__bar {
  flex: 1 1 0;
  min-width: 2px;
  height: calc(20% + var(--h, 0.5) * 80%);
  border-radius: 1px;
  background: var(--live);
  opacity: 0.85;
}

.trace__bar--down {
  background: var(--alarm);
  height: 100%;
  opacity: 1;
}

.trace__bar--slow { background: var(--warn); }

.trace__bar--void {
  background: var(--rule);
  height: 12%;
  opacity: 1;
}

.trace__bar--fresh { animation: land 400ms ease-out; }

@keyframes land {
  from { opacity: 0; transform: translateY(3px) scaleY(0.6); }
  to { opacity: 0.85; transform: none; }
}

.trace__empty {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted-dim);
  align-self: center;
}

/* ------------------------------------------------------------- ledgers -- */

.incidents { margin-top: 2.5rem; }

.ledger {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.ledger__row {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 0.85rem;
}

.ledger__row:last-child { border-bottom: 0; }

.ledger__when {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ledger__what {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger__what a { text-decoration: none; border-bottom: 1px solid var(--rule); }

.ledger__dur {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ledger__dur--open { color: var(--alarm); }

.ledger__empty {
  padding: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--live);
  align-self: center;
}

.dot--down { background: var(--alarm); }

/* --------------------------------------------------------------- empty -- */

.empty {
  padding: 3.5rem 1.5rem;
  text-align: center;
}

.empty__title {
  font-family: var(--mono);
  font-size: 1rem;
  margin: 0 0 0.4rem;
}

.empty__body {
  color: var(--muted);
  margin: 0 auto;
  max-width: 34ch;
  font-size: 0.9rem;
}

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

.detail__head { margin-bottom: 2rem; }

.backlink {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

.backlink:hover { color: var(--paper); }

.detail__name {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--mono);
  font-size: clamp(1.2rem, 3vw, 1.7rem);
  font-weight: 500;
  margin: 0.75rem 0 0.5rem;
}

.detail__target {
  margin: 0 0 0.35rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}

.detail__meta {
  margin: 0 0 1rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted-dim);
}

.detail__actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  margin-right: 0.4rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.readout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  margin-bottom: 2rem;
}

.readout__cell {
  padding: 0.9rem 1.1rem;
  border-right: 1px solid var(--rule-soft);
}

.readout__cell:last-child { border-right: 0; }

.readout__label {
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-dim);
  margin-bottom: 0.3rem;
}

.readout__value {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.chart-panel { margin-bottom: 2.5rem; }

.chart {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0.75rem;
}

.chart svg { display: block; width: 100%; height: auto; }

.chart__grid { stroke: var(--rule); stroke-width: 1; }
.chart__area { fill: color-mix(in srgb, var(--live) 12%, transparent); }
.chart__line { fill: none; stroke: var(--live); stroke-width: 1.5; stroke-linejoin: round; }
.chart__fail { stroke: var(--alarm); stroke-width: 1; opacity: 0.55; }
.chart__tick { fill: var(--muted-dim); font-family: var(--mono); font-size: 9px; }

.chart__empty {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.detail__columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
}

/* -------------------------------------------------------------- panels -- */

.panel {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1.4rem;
  margin-bottom: 1.5rem;
}

.panel__note {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 1.2rem;
}

.stack { display: grid; gap: 1rem; justify-items: start; }
.stack .field { width: 100%; }

/* --------------------------------------------------------------- forms -- */

.field { display: block; margin-bottom: 1rem; }

.field__label {
  display: block;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.field__hint {
  letter-spacing: 0.06em;
  color: var(--muted-dim);
  text-transform: none;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.input::placeholder { color: var(--muted-dim); }
.input:focus { border-color: var(--live); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--live) 20%, transparent); }

select.input { appearance: none; cursor: pointer; }

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
}

.check input { accent-color: var(--live); width: 15px; height: 15px; }

.btn {
  padding: 0.5rem 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--rule);
  background: var(--panel-raised);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.btn:hover { border-color: var(--muted-dim); }

.btn--primary {
  background: var(--live);
  border-color: var(--live);
  color: #06231a;
  font-weight: 600;
}

.btn--primary:hover { background: color-mix(in srgb, var(--live) 88%, white); }

.btn--ghost { background: transparent; }

.btn--danger { border-color: color-mix(in srgb, var(--alarm) 45%, transparent); color: var(--alarm); background: transparent; }
.btn--danger:hover { background: color-mix(in srgb, var(--alarm) 12%, transparent); }

.btn--block { width: 100%; padding-block: 0.65rem; }

.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.alert {
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
  border: 1px solid var(--rule);
  font-size: 0.84rem;
  margin: 0 0 1rem;
}

.alert--error {
  border-color: color-mix(in srgb, var(--alarm) 45%, transparent);
  background: color-mix(in srgb, var(--alarm) 10%, transparent);
  color: var(--alarm);
}

.alert--ok {
  border-color: color-mix(in srgb, var(--live) 45%, transparent);
  background: color-mix(in srgb, var(--live) 10%, transparent);
  color: var(--live);
}

/* -------------------------------------------------------------- dialog -- */

.dialog {
  width: min(520px, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--paper);
}

.dialog::backdrop { background: rgba(6, 9, 13, 0.72); }

.dialog__form { padding: 1.5rem; }

.dialog__title {
  font-family: var(--mono);
  font-size: 1rem;
  margin: 0 0 1.25rem;
}

.dialog__actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--rule-soft);
  margin-top: 0.5rem;
}

.dialog__spacer { flex: 1; }

/* -------------------------------------------------------------- signin -- */

.signin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.signin__panel { width: min(340px, 100%); margin: 0; }

.signin__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.signin__wordmark {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.signin__intro {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 1.5rem;
}

/* ------------------------------------------------------------ responsive -- */

@media (max-width: 760px) {
  .strip__head { display: none; }

  .row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "id nums"
      "trace trace";
    row-gap: 0.7rem;
  }

  .row__id { grid-area: id; }
  .row__trace { grid-area: trace; }
  .row__nums {
    grid-area: nums;
    display: flex;
    gap: 1.25rem;
    align-items: baseline;
  }

  .field-row { grid-template-columns: 1fr; }
  .verdict__meta { align-items: flex-start; }
  .verdict__add { margin-left: 0; }
}

@media (min-width: 761px) {
  .row__nums { display: contents; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
