/* An operations console. Density over decoration: the job is to show a lot of
   rows and make the one that matters findable, not to look like a landing page.

   No web fonts. A font file is 30-100 KB of egress per visitor for something
   the operating system already has, and this project bills egress by the byte
   (docs/WEB-DELIVERY.md). */

:root {
  color-scheme: light dark;

  --bg: #f7f7f5;
  --panel: #ffffff;
  --line: #dfdfd9;
  --ink: #16181c;
  --dim: #61656e;
  --accent: #2f6f4f;
  --accent-ink: #ffffff;

  --critical: #a3271f;
  --warning: #8a5a09;
  --info: #2c5aa0;
  --ok: #2f6f4f;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 5px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --panel: #1e2126;
    --line: #2f343c;
    --ink: #e6e8ea;
    --dim: #9198a3;
    --accent: #57a37a;
    --accent-ink: #0d1013;

    --critical: #e8756a;
    --warning: #d9a441;
    --info: #7fa8e0;
    --ok: #57a37a;
  }
}

* { box-sizing: border-box; }

/* An id selector beats the user-agent `[hidden] { display: none }`, so a panel
   with `display: grid` below stays on screen after `.hidden = true`. This is
   the one place `!important` is the correct tool: the attribute means hidden,
   and no layout rule should be able to argue with it. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--sans);
}

code, pre, .mono, td.num { font-family: var(--mono); }

/* ------------------------------------------------------------------ nav */

#nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

#nav .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-right: 18px;
  color: var(--ink);
}

#nav a {
  color: var(--dim);
  text-decoration: none;
  padding: 11px 12px;
  border-bottom: 2px solid transparent;
}

#nav a:hover { color: var(--ink); }

#nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

#nav .spacer { flex: 1; }
#nav .who { color: var(--dim); font-size: 13px; margin-right: 10px; }

/* No max-width. A reading measure is right for prose and wrong for an ops
   console: the whole point of a wide monitor here is more columns and more
   rows on screen at once. Prose blocks below set their own measure. */
main { padding: 18px 20px 60px; }

h2 { font-size: 17px; margin: 0 0 4px; }
.sub { color: var(--dim); margin: 0 0 16px; font-size: 13px; max-width: 70ch; }

/* --------------------------------------------------------------- controls */

button {
  font: inherit;
  padding: 6px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: default; filter: none; }

button.ghost {
  background: transparent;
  color: var(--dim);
  border-color: var(--line);
}

button.ghost:hover { color: var(--ink); }

button.danger { border-color: var(--critical); background: transparent; color: var(--critical); }

/* Mode tabs. Two ways into one screen, not navigation, so they are quieter
   than the nav and louder than a ghost button. */
.tabs { gap: 0; margin-bottom: 10px; }
button.tab {
  background: transparent;
  color: var(--dim);
  border-color: var(--line);
  border-radius: 0;
  margin: 0;
}
button.tab:first-child { border-radius: var(--radius) 0 0 var(--radius); }
button.tab:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }
button.tab.on { color: var(--ink); background: var(--panel); border-color: var(--accent); }
/* The chosen tab owns the border between them, or the two disagree about it. */
button.tab.on + button.tab { border-left-color: var(--accent); }

/* A button that is doing something, rather than offering to. */
button.ghost.on { color: var(--accent); border-color: var(--accent); }

/* The timeline. One ordered list across four sources, so the source has to be
   readable at a glance without becoming the loudest thing in the row. */
ol.timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.tl {
  display: grid;
  grid-template-columns: 8.5rem 4.5rem 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.tl:first-child { border-top: none; }
.tl-when { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.tl-source {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--dim);
}
.tl-source.tl-alert { color: var(--critical); }
.tl-source.tl-audit { color: var(--info); }
.tl-source.tl-case { color: var(--accent); }
.tl-source.tl-incident { color: var(--warning); }
.tl-source.tl-work { color: var(--dim); }
.tl-source.tl-error { color: var(--critical); }
.tl-what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tl-title { overflow-wrap: anywhere; }
.tl-detail { font-size: 12px; color: var(--dim); overflow-wrap: anywhere; }
.tl-who { font-size: 12px; color: var(--dim); font-family: var(--mono); }
.tl-link { font-size: 12px; }

@media (max-width: 700px) {
  /* Four columns do not fit a phone; the time and the source stack above the
     text rather than squeezing it to two words a line. */
  .tl { grid-template-columns: 1fr auto; }
  .tl-when, .tl-source { grid-column: 1; }
  .tl-what { grid-column: 1 / -1; }
}

/* The filter box takes the room the query is likely to need. */
input.filter { flex: 1 1 22rem; min-width: 12rem; font-family: var(--mono); }

input, select, textarea {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  min-width: 0;
}

textarea { font-family: var(--mono); font-size: 13px; width: 100%; resize: vertical; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* An input that should take its container's width, in a table cell where flex
   `grow` does not apply. */
.fill { width: 100%; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 4px; }
/* Actions in a table cell. Wrapping stacks two buttons vertically and doubles
   the row height for no gain. */
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; }

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

/* ---------------------------------------------------------------- tables */

.scroll { overflow-x: auto; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }

th {
  text-align: left;
  font-weight: 600;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  padding: 6px 10px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--panel);
}

td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

/* One column absorbs the slack; the rest shrink to fit. Without this a
   two-row table on a wide monitor spreads its cells across the screen and
   nothing lines up. Marking which column grows matters — letting the trailing
   button column take it squeezes the one carrying the words. */
th.grow { width: 100%; }

/* Numbers and timestamps are read as single tokens; wrapping one across three
   lines to save a few pixels costs far more than it saves. */
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* A formatted time is read left to right like text, not compared digit by
   digit like a quantity. */
td.time { font-family: var(--mono); white-space: nowrap; }

tbody tr:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }

.empty { color: var(--dim); padding: 22px 0; text-align: center; }

/* ----------------------------------------------------------------- state */

.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  border: 1px solid currentColor;
}

.s-firing, .s-critical { color: var(--critical); }
.s-keepfiring { color: var(--critical); opacity: .75; }
.s-pending, .s-warning { color: var(--warning); }
.s-resolved, .s-info { color: var(--info); }
.s-ok, .s-active { color: var(--ok); }
.s-silenced { color: var(--dim); }

/* A silenced alert is still firing. Dimming the row says "handled" without
   letting it disappear, which is how a silence becomes an outage nobody saw. */
tr.silenced td { opacity: .55; }

.labels { display: flex; gap: 4px; flex-wrap: wrap; }

.label {
  font-family: var(--mono);
  font-size: 11.5px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
}

.error {
  color: var(--critical);
  border-left: 3px solid var(--critical);
  padding: 6px 10px;
  background: color-mix(in srgb, var(--critical) 8%, transparent);
  border-radius: 0 var(--radius) var(--radius) 0;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 12.5px;
}

.note { color: var(--dim); font-size: 12.5px; white-space: nowrap; }

/* ----------------------------------------------------------------- login */

#login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

#login form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  width: min(370px, 100%);
  display: grid;
  gap: 12px;
}

#login h1 { font-size: 18px; margin: 0 0 6px; }
#login label { display: grid; gap: 4px; font-size: 13px; color: var(--dim); }
#login .hint { font-size: 12px; color: var(--dim); margin: 6px 0 0; }
#login code { font-size: 11.5px; word-break: break-all; }

.pad { padding: 20px; }

/* ---------------------------------------------------------------- charts */

.chart-wrap { position: relative; }

/* Sized in px by the drawing code, which measures the container. `max-width`
   only guards the frame between a resize and the redraw. */
.chart { display: block; max-width: 100%; overflow: visible; }

.chart .grid { stroke: var(--line); stroke-width: 1; }
/* Vertical time gridlines sit behind the data and should not compete with it. */
.chart .grid-v { opacity: .5; }

.chart .line {
  fill: none;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* The min/max band. Faint on purpose: it is context for the line, not a
   second series competing with it. */
.chart .band { opacity: .16; stroke: none; }

/* Alert markers. Dashed and half-transparent for the same reason the band is
   faint: the data is the point and the marker is context, and a solid line
   would read as a series. */
.chart .annot {
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: .55;
}
.chart .annot-flag { stroke: none; opacity: .9; }
.chart .annot-info { stroke: var(--info); fill: var(--info); }
.chart .annot-warning { stroke: var(--warning); fill: var(--warning); }
.chart .annot-critical { stroke: var(--critical); fill: var(--critical); }
.chart .annot-more { fill: var(--dim); font-size: 11px; }

.chart .cross {
  stroke: var(--ink);
  stroke-width: 1;
  opacity: .45;
  pointer-events: none;
}

.chart .hit { cursor: crosshair; }

.chart text { fill: var(--dim); font-size: 10px; font-family: var(--mono); }

.chart-empty {
  display: grid;
  place-items: center;
  color: var(--dim);
  font-size: 13px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* The hover readout. Absolutely positioned against .chart-wrap and flipped to
   whichever side keeps it on screen. */
.readout {
  position: absolute;
  top: 4px;
  z-index: 2;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 12px;
  box-shadow: 0 2px 10px rgb(0 0 0 / .18);
  max-width: 340px;
}

.readout-time {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  margin-bottom: 3px;
}

.readout-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 6px;
  align-items: center;
}

.readout-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.readout-val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  padding-left: 10px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  flex: none;
}

/* ------------------------------------------------------------- sparkline */

.spark { display: block; overflow: visible; }
.spark-line { fill: none; stroke: var(--ok); stroke-width: 1.4; stroke-linejoin: round; }
/* A failure is the only thing worth picking out of a sparkline. */
.spark-bad { fill: var(--critical); stroke: none; }

/* A row for something that is down should be findable without reading. */
tr.row-bad td:first-child { box-shadow: inset 2px 0 0 var(--critical); }

/* A command to copy. */
.snippet {
  font-family: var(--mono);
  font-size: 12.5px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 0;
  overflow-x: auto;
  white-space: pre;
  user-select: all;
}

/* ---------------------------------------------------------------- legend */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: 8px;
  /* Twenty series should not push the next panel off the screen. */
  max-height: 68px;
  overflow-y: auto;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--ink);
  font-size: 12px;
  padding: 1px 2px;
  cursor: pointer;
}

.legend-item:hover { text-decoration: underline; }
.legend-item.off { opacity: .4; text-decoration: line-through; }

/* ------------------------------------------------------------ panel grid */

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  align-items: start;
}

/* Twelve columns collapse to one below the point where a third of the width
   stops being readable. */
@media (max-width: 900px) {
  .grid > * { grid-column: span 12 !important; }
}

.grid > .panel { margin-bottom: 0; min-width: 0; }

.panel-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
}

/* A stat panel: one number, as large as the panel allows. */
.stat {
  font-size: clamp(28px, 5vw, 46px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  padding: 6px 0 2px;
}

/* A link that reads as a secondary button. */
.ghost-link {
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--dim);
  text-decoration: none;
}

.ghost-link:hover { color: var(--ink); }

a { color: var(--accent); }

@media (prefers-reduced-motion: no-preference) {
  .flash { animation: flash .6s ease-out; }
  @keyframes flash {
    from { background: color-mix(in srgb, var(--accent) 25%, transparent); }
  }
}

@media (max-width: 700px) {
  #nav .brand span { display: none; }
  #nav a { padding: 11px 8px; }
  main { padding: 12px;}
}

/* ------------------------------------------------------------------ work */

/* The board. Five columns that scroll sideways on a narrow screen rather than
   stacking, because a kanban board that stacks is a list with extra headings. */
.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.col {
  background: color-mix(in srgb, var(--panel) 60%, var(--bg));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .12s;
}
.col.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.col-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 0 2px 4px;
}
.col-head .num { font-weight: 500; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: grab;
  font-size: 13px;
}
.card:active { cursor: grabbing; }
.card.dragging { opacity: .45; }
.card-top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.card-key { font-family: var(--mono); font-size: 11.5px; color: var(--dim); text-decoration: none; }
.card-key:hover { color: var(--accent); }
.card-title { overflow-wrap: anywhere; line-height: 1.3; }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a:hover { text-decoration: underline; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.card-foot select { font-size: 12px; padding: 2px 4px; max-width: 120px; }
.points {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 6px;
}
.pill.s-epic { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }
.pill.s-story { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.pill.s-task { background: color-mix(in srgb, var(--dim) 18%, transparent); color: var(--dim); }
.pill.s-backlog, .pill.s-planned { background: color-mix(in srgb, var(--dim) 15%, transparent); color: var(--dim); }
.pill.s-todo { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }
.pill.s-doing, .pill.s-active { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.pill.s-review { background: color-mix(in srgb, var(--info) 22%, transparent); color: var(--info); }
.pill.s-done, .pill.s-closed { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }

/* The backlog: a table whose cells are controls. Compact, because the point of
   a backlog is to see a lot of it. */
.backlog td select, .backlog td input { font-size: 12px; padding: 2px 4px; }
.backlog td input.pts { width: 3.5em; text-align: right; font-family: var(--mono); }
.backlog .rank { display: inline-flex; flex-direction: column; gap: 0; }
.backlog .rank button {
  padding: 0 5px; line-height: 1.1; font-size: 10px;
  background: transparent; color: var(--dim); border-color: var(--line);
}
.backlog .rank button:hover { color: var(--ink); }
.backlog tr.nested td:first-child { padding-left: 22px; }

/* Acceptance criteria: a checklist, because that is what they are. */
.criteria { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.criteria li { display: flex; gap: 8px; align-items: flex-start; }
.criteria li.met span { color: var(--dim); text-decoration: line-through; }
.criteria input[type=checkbox] { margin-top: 3px; }
.criteria .x { margin-left: auto; }

/* Item header: the key in mono, the title big, and the controls in one row. */
.item-key { font-family: var(--mono); color: var(--dim); font-size: 13px; }
.item-title { font-size: 20px; font-weight: 600; margin: 2px 0 8px; overflow-wrap: anywhere; }
.item-title input { font-size: 20px; font-weight: 600; width: 100%; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.fields label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--dim); }
.fields select, .fields input { width: 100%; }
textarea.desc { width: 100%; min-height: 6em; resize: vertical; font: inherit; }

/* The burndown. Two lines and a step: ideal, remaining, scope. */
.burn { width: 100%; height: auto; display: block; }
.burn .grid { stroke: var(--line); stroke-width: 1; }
.burn text { font-size: 11px; fill: var(--dim); }
.burn .ideal { fill: none; stroke: var(--dim); stroke-width: 1; stroke-dasharray: 4 4; }
.burn .scope { fill: none; stroke: var(--info); stroke-width: 1; opacity: .7; }
.burn .remaining { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.burn .dot { fill: var(--accent); }
.burn .today { stroke: var(--warning); stroke-width: 1; stroke-dasharray: 2 3; }
.legend-item .swatch.dashed { border: 1px dashed var(--dim); background: transparent; }

.links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.links li { display: flex; gap: 8px; align-items: center; }
.links .by { color: var(--dim); font-size: 11.5px; }
.links .x { margin-left: auto; }

.activity { font-family: var(--mono); font-size: 12px; }
.activity td { padding: 3px 6px; }

@media (max-width: 900px) {
  .board { grid-template-columns: repeat(5, 200px); }
}

.pill.s-stale { background: color-mix(in srgb, var(--warning) 22%, transparent); color: var(--warning); }
.suggestion { border-top: 1px solid var(--line); padding: 10px 0 4px; margin-top: 8px; }
.suggestion .criteria li { align-items: baseline; }

/* Issues */
.pill.s-unresolved { background: color-mix(in srgb, var(--critical) 18%, transparent); color: var(--critical); }
.pill.s-resolved { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.s-ignored { background: color-mix(in srgb, var(--dim) 15%, transparent); color: var(--dim); }
.pill.s-fatal, .pill.s-error { background: color-mix(in srgb, var(--critical) 18%, transparent); color: var(--critical); }
.pill.s-debug { background: color-mix(in srgb, var(--dim) 15%, transparent); color: var(--dim); }
pre.stack { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.issue-title { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.culprit { font-family: var(--mono); font-size: 12px; color: var(--dim); }

.pill.s-flapping { background: color-mix(in srgb, var(--warning) 22%, transparent); color: var(--warning); }
