/* vigil dashboard. Monospace everywhere; status is the only use of color. */

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #ffffff; --track: #f5f4f2; --ink: #26252d; --muted: #6f6d78; --line: #e7e5e1;
  --ok: #cfe9d9;   --ok-ink: #2f6b4a;
  --warn: #f8e8c4; --warn-ink: #7a5a14;
  --fail: #f6cfcf; --fail-ink: #8a3030;
  --late: #f9dcc2; --late-ink: #8a5420;
  --tick-ok: #a8d5ba; --tick-fail: #eb9a9a; --tick-late: #f2bd91;
  --line-blue: #6f88c9; --fill-blue: #d3def6; --line-violet: #8d78c9; --fill-violet: #dcd2f3;
  --line-green: #5e9b7a; --fill-green: #cfe9d9; --line-peach: #c98a55; --fill-peach: #f9dcc2;
  --threshold: #e08a8a;
  --new: #e3e8f7; --new-ink: #3a4f86;
  --neutral: #f0efec; --neutral-ink: #4a4955;
  color-scheme: light;
}

/* Dark theme (M4b): same tokens, redefined. Pastel fills become deep tints
   with light ink of the same hue, keeping >= 4.5:1 text contrast. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161b; --track: #222128; --ink: #e8e6ef; --muted: #a09eab; --line: #2f2d36;
    --ok: #1f3a2b;   --ok-ink: #a8e0bf;
    --warn: #3d3218; --warn-ink: #f0d58f;
    --fail: #46201f; --fail-ink: #f4b4b4;
    --late: #43301d; --late-ink: #f6c79d;
    --tick-ok: #4f8f69; --tick-fail: #b8585a; --tick-late: #b97a45;
    --line-blue: #8fa6e6; --fill-blue: #263557; --line-violet: #ab98e6; --fill-violet: #33294f;
    --line-green: #7cc09b; --fill-green: #1f3a2b; --line-peach: #e3a877; --fill-peach: #43301d;
    --threshold: #e88f8f;
    --new: #252d48; --new-ink: #b8c6f0;
    --neutral: #2a2930; --neutral-ink: #cfcdd8;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); }
body {
  margin: 0;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  color: var(--ink);
}
a { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--ink); }
b, strong, h1, h2, h3, th { font-weight: 700; }
h1 { font-size: 16px; margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
code, pre, input, select, button, textarea { font-family: inherit; font-size: inherit; }
code { background: var(--track); border-radius: 5px; padding: 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.sr { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--bg); padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; z-index: 10; }
.grow { flex: 1 1 auto; }
.dim { opacity: .55; }
:focus-visible { outline: 2px solid var(--line-blue); outline-offset: 2px; }

/* Header and navigation */
.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; letter-spacing: .02em; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1 1 auto; }
.nav { text-decoration: none; padding: 4px 10px; border: 1px solid transparent; border-radius: 8px; color: var(--muted); }
.nav:hover { color: var(--ink); }
.nav.active { background: var(--track); border-color: var(--line); color: var(--ink); }
.logout { margin: 0; }

main { padding: 16px 20px 32px; max-width: 1400px; margin: 0 auto; }
.foot { padding: 12px 20px 24px; font-size: 11px; text-align: center; }
section { margin-top: 20px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Section labels */
.label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 400; margin: 0 0 8px;
}

/* Cards */
.cards { display: flex; flex-wrap: wrap; gap: 12px; }
.card {
  flex: 1 1 280px; min-width: 0;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--bg);
}
.card.flush { padding: 0; }
.card.quiet { color: var(--muted); }
a.card { text-decoration: none; display: block; }
a.card:hover { border-color: var(--muted); }
.host .name { font-size: 14px; }
.host .meta { font-size: 11px; margin-top: 6px; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 8px 0 0; }
.stats div { min-width: 70px; }
.stats dt { font-size: 11px; color: var(--muted); }
.stats dd { margin: 0; font-weight: 700; }
.summary .actions { margin-top: 12px; }

/* Chips: pastel fill, dark ink of the same hue. */
.chip {
  display: inline-block; padding: 0 6px; border-radius: 5px; font-size: 11px; line-height: 18px;
  background: var(--neutral); color: var(--neutral-ink); white-space: nowrap;
}
.chip.ok { background: var(--ok); color: var(--ok-ink); }
.chip.warn { background: var(--warn); color: var(--warn-ink); }
.chip.fail { background: var(--fail); color: var(--fail-ink); }
.chip.late { background: var(--late); color: var(--late-ink); }
.chip.new { background: var(--new); color: var(--new-ink); }

.banner { border-radius: 10px; padding: 8px 12px; margin: 12px 20px 0; border: 1px solid var(--line); }
main .banner { margin: 12px 0; }
.banner.fail { background: var(--fail); color: var(--fail-ink); }
.banner.warn { background: var(--warn); color: var(--warn-ink); }
.banner.ok { background: var(--ok); color: var(--ok-ink); }

/* Buttons and forms */
.btn {
  display: inline-block; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); cursor: pointer; text-decoration: none; line-height: 18px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { font-weight: 700; border-color: var(--ink); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--fail-ink); }
.btn.danger:hover { background: var(--fail); }
.btn.small { padding: 1px 8px; font-size: 11px; }
form { margin: 0; }
form.inline, td.actions form { display: inline-flex; gap: 4px; align-items: center; margin: 2px 4px 2px 0; }
input, select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; background: var(--bg); color: var(--ink);
  min-width: 0;
}
input[type=checkbox] { padding: 0; }
label { display: inline-flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); }
label input, label select { font-size: 13px; color: var(--ink); }
label.check { flex-direction: row; align-items: center; gap: 6px; }
label.grow { flex: 1 1 260px; }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; align-items: end; }
details.add { margin-top: 10px; }
details.add summary { list-style: none; width: max-content; }
details.add form { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.kind { width: 100%; }

/* Segmented control: gray track, white bordered active pill. */
.seg { display: inline-flex; background: var(--track); border-radius: 8px; padding: 2px; gap: 2px; }
.seg a { text-decoration: none; padding: 2px 10px; border-radius: 6px; border: 1px solid transparent; color: var(--muted); }
.seg a.on { background: var(--bg); border-color: var(--line); color: var(--ink); font-weight: 700; }

/* Tables scroll horizontally inside their card. */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 400; }
tbody tr:last-child td { border-bottom: 0; }
table.sortable th { cursor: pointer; user-select: none; }
table.sortable th[aria-sort=ascending]::after { content: " ↑"; }
table.sortable th[aria-sort=descending]::after { content: " ↓"; }
td.actions { white-space: normal; }

/* Run strip */
.strip { display: inline-flex; gap: 2px; align-items: center; }
.strip .t { width: 6px; height: 14px; border-radius: 2px; background: var(--line); }
.strip .t-ok { background: var(--tick-ok); }
.strip .t-fail { background: var(--tick-fail); }
.strip .t-lost { background: var(--tick-late); }
.strip .t-running { background: var(--line-blue); }

/* Charts */
.charts .chart { flex: 1 1 380px; }
.charts.wide .chart { flex-basis: 100%; }
.chart {
  margin: 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 6px; min-width: 0;
}
.chart figcaption { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ctitle { overflow: hidden; text-overflow: ellipsis; }
.clabels { font-size: 11px; }
.cval { display: flex; flex-direction: column; align-items: flex-end; }
.mm { font-size: 11px; }
.plot { height: 170px; margin-top: 6px; }
.plot.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.uplot { font-family: inherit; }
.u-legend { display: none; }
.legend { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 11px; }
.legend button {
  display: inline-flex; align-items: center; gap: 6px; padding: 1px 4px; border: 0; border-radius: 5px;
  background: transparent; color: var(--ink); cursor: pointer; font: inherit; max-width: 100%;
}
.legend button:hover { background: var(--track); }
.legend .swatch { width: 10px; height: 3px; border-radius: 2px; flex: none; }
.legend .lname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.legend li.off { opacity: .4; }

/* Bars (cron durations, SVG) */
svg.bars { width: 100%; height: 90px; display: block; }
.bar { fill: var(--tick-ok); }
.bar-fail { fill: var(--tick-fail); }
.bar-lost { fill: var(--tick-late); }

/* Text blocks: untrusted output is always rendered as text. */
pre.output, .pre {
  white-space: pre-wrap; word-break: break-word; background: var(--track); border-radius: 8px;
  padding: 8px 10px; margin: 6px 0; max-height: 420px; overflow: auto;
}
.insight .pre { background: transparent; padding: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 3px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: 11px; margin-right: 6px; }
ul.plain { margin: 0; padding-left: 18px; }
.evidence div { display: flex; gap: 8px; }
.evidence dt { color: var(--muted); }
.evidence dd { margin: 0; word-break: break-all; }

/* Login */
.login { max-width: 360px; margin: 10vh auto; }
.login h1 { font-size: 18px; margin-bottom: 4px; }
.login form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

@media (max-width: 640px) {
  main { padding: 12px; }
  .top { padding: 8px 12px; gap: 8px; }
  .cards { flex-direction: column; }
  .card, .charts .chart { flex-basis: auto; width: 100%; }
  .pagehead { align-items: flex-start; }
  .banner { margin: 8px 12px 0; }
  th, td { padding: 6px 8px; }
}
