/* up.teamr2.com: galvanized steel and shop-floor safety colors. */
:root {
  --steel-0: #f3f5f7;      /* page */
  --steel-1: #e4e8ec;      /* plate, table head */
  --steel-2: #c9d0d7;      /* rules */
  --steel-3: #7b8794;      /* secondary text */
  --ink: #1d2833;          /* text */
  --plate-ink: #2b3946;    /* plate border */
  --go: #1f8a4c;           /* safety green */
  --go-soft: #d9efe2;
  --caution: #b98300;      /* safety yellow, darkened for text contrast */
  --caution-bar: #f2b705;
  --caution-soft: #fbf0cc;
  --stop: #c4122f;         /* safety red */
  --stop-soft: #f8dbe0;
  --idle: #a3adb7;
  --surface: #ffffff;
  --focus: #1f6fd1;
  --font: "Bahnschrift", "DIN Alternate", "DIN 2014", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --steel-0: #151b21; --steel-1: #1f2730; --steel-2: #34404c; --steel-3: #8d99a6;
    --ink: #e7ecf0; --plate-ink: #8d99a6; --surface: #1a2129;
    --go: #3fbf73; --go-soft: #173826; --caution: #f2b705; --caution-bar: #f2b705; --caution-soft: #3a3011;
    --stop: #ff5a6e; --stop-soft: #43161e; --idle: #5d6975; --focus: #6aa8ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--steel-0);
  color: var(--ink);
  font: 400 16px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Top bar */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px max(16px, calc((100vw - 1100px) / 2));
  border-bottom: 1px solid var(--steel-2);
  background: var(--surface);
}
.brand { font-size: 20px; font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
.brand-up { color: var(--go); font-weight: 700; }
.bar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 14px; color: var(--steel-3); }
.user { color: var(--ink); }
.signout { color: var(--steel-3); }
.btn {
  font: 600 14px/1 var(--font); color: var(--ink); background: var(--steel-1);
  border: 1px solid var(--steel-2); border-radius: 4px; padding: 8px 12px; cursor: pointer; text-decoration: none;
  display: inline-block;
}
.btn:hover { border-color: var(--steel-3); }
.btn[disabled] { opacity: .6; cursor: progress; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }

/* The status plate: a stamped nameplate that says what's wrong. */
.plate {
  position: relative;
  background: var(--steel-1);
  border: 2px solid var(--plate-ink);
  border-radius: 6px;
  padding: 22px 28px 22px 34px;
  margin-bottom: 32px;
}
.plate::before, .plate::after {               /* rivets */
  content: ""; position: absolute; left: 12px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--steel-2); box-shadow: inset 0 0 0 1.5px var(--plate-ink);
}
.plate::before { top: 12px; }
.plate::after { bottom: 12px; }
.plate-verdict {
  margin: 0; font-size: clamp(30px, 5vw, 46px); line-height: 1.05; font-weight: 700;
  font-stretch: 87.5%; letter-spacing: -0.015em;
}
.plate[data-level="ok"] { border-left: 12px solid var(--go); }
.plate[data-level="warn"] { border-left: 12px solid var(--caution-bar); }
.plate[data-level="down"] { border-left: 12px solid var(--stop); }
.plate[data-level="down"] .plate-verdict { color: var(--stop); }
.plate-sub { margin: 8px 0 0; color: var(--steel-3); font-size: 15px; }
.plate-problems { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.plate-problems li { font-size: 17px; }
.plate-problems strong { font-weight: 600; }
.plate-problems .since { color: var(--steel-3); font-size: 14px; white-space: nowrap; }
.plate-loading { margin: 0; color: var(--steel-3); }

/* Check groups */
.group { margin-bottom: 28px; }
.group h2, .panel h2 {
  font-size: 15px; font-weight: 600; font-stretch: 87.5%; margin: 0 0 6px; color: var(--steel-3); letter-spacing: .01em;
}
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--steel-2); border-radius: 6px; }
.row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  grid-template-areas: "mark main stats" "mark bars bars";
  column-gap: 12px; row-gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--steel-2);
}
.row:first-child { border-top: 0; }
.mark { grid-area: mark; width: 12px; height: 12px; margin-top: 5px; border-radius: 2px; background: var(--idle); }
.mark.up { background: var(--go); }
.mark.warn { background: var(--caution-bar); }
.mark.down { background: var(--stop); }
.mark.blocked, .mark.unknown, .mark.pending { background: transparent; box-shadow: inset 0 0 0 2px var(--idle); }
.row-main { grid-area: main; min-width: 0; }
.row-name { font-weight: 600; font-size: 17px; }
.row-state { font-size: 13px; font-weight: 600; margin-left: 8px; padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.row-state.down { background: var(--stop-soft); color: var(--stop); }
.row-state.warn { background: var(--caution-soft); color: var(--caution); }
.row-state.blocked, .row-state.unknown, .row-state.pending { background: var(--steel-1); color: var(--steel-3); }
.row-msg { color: var(--steel-3); font-size: 14px; overflow-wrap: anywhere; }
.row.is-failing .row-msg { color: var(--ink); }
.row-stats { grid-area: stats; display: flex; gap: 14px; font-size: 13px; color: var(--steel-3); text-align: right; }
.row-stats b { display: block; font-size: 15px; font-weight: 600; color: var(--ink); }
.bars { grid-area: bars; display: grid; grid-template-columns: repeat(90, 1fr); gap: 2px; height: 22px; }
.bars i { display: block; border-radius: 1px; background: var(--steel-1); }
.bars i.up { background: var(--go); opacity: .75; }
.bars i.part { background: var(--caution-bar); }
.bars i.warn { background: var(--caution-bar); opacity: .6; }
.bars i.down { background: var(--stop); }

/* Panels: jobs, incidents */
.panel { margin-top: 36px; }
.panel-meta { margin: 0 0 10px; font-size: 14px; color: var(--steel-3); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--steel-2); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; vertical-align: top; border-top: 1px solid var(--steel-2); }
th { background: var(--steel-1); border-top: 0; font-weight: 600; font-stretch: 87.5%; color: var(--steel-3); white-space: nowrap; }
td.num { text-align: right; }
tr.off td { color: var(--steel-3); }
.pill { font-weight: 600; padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.pill.ok { background: var(--go-soft); color: var(--go); }
.pill.failed, .pill.limit { background: var(--stop-soft); color: var(--stop); }
.pill.skipped, .pill.none { background: var(--steel-1); color: var(--steel-3); }

.incidents { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--steel-2); border-radius: 6px; }
.incidents li { padding: 10px 16px; border-top: 1px solid var(--steel-2); display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; }
.incidents li:first-child { border-top: 0; }
.incidents .what { font-weight: 600; }
.incidents .when { color: var(--steel-3); font-size: 14px; text-align: right; white-space: nowrap; }
.incidents .msg { grid-column: 1 / -1; color: var(--steel-3); font-size: 14px; overflow-wrap: anywhere; }
.incidents .open .what { color: var(--stop); }
.incidents .empty { color: var(--steel-3); display: block; }

/* Sign-in / error pages */
body.plain { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.notice { max-width: 460px; }
.notice h1 { font-size: 30px; font-stretch: 87.5%; margin: 0 0 8px; }

@media (max-width: 720px) {
  .row { grid-template-columns: 14px minmax(0, 1fr); grid-template-areas: "mark main" "mark stats" "mark bars"; }
  .row-stats { text-align: left; }
  .bars { grid-template-columns: repeat(30, 1fr); }
  .bars i:nth-child(-n+60) { display: none; }
  .plate { padding: 18px 18px 18px 30px; }
  .checked { flex-basis: 100%; }
  .incidents li { grid-template-columns: 1fr; }
  .incidents .when { text-align: left; white-space: normal; }
}
@media (prefers-reduced-motion: no-preference) {
  .plate { transition: border-color .3s; }
}

/* ---------- Manage page ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.page-title { font-size: clamp(28px, 4vw, 38px); font-stretch: 87.5%; margin: 0 0 4px; letter-spacing: -0.01em; }
.lede { margin: 0 0 8px; color: var(--steel-3); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }
.group-name { font-size: 14px; font-weight: 600; color: var(--steel-3); margin: 18px 0 6px; }
.mrow {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  grid-template-areas: "mark main actions";
  padding: 10px 16px; border-top: 1px solid var(--steel-2);
}
.mrow:first-child { border-top: 0; }
.mrow.is-off .row-name { color: var(--steel-3); }
.mrow-actions { grid-area: actions; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn-small { padding: 5px 9px; font-size: 13px; }
.btn-primary { background: var(--plate-ink); color: var(--surface); border-color: var(--plate-ink); }
.btn-primary:hover { border-color: var(--ink); }
.btn-danger { color: var(--stop); }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.form-actions .spacer { flex: 1; }
.form-msg { font-size: 14px; }
.form-msg.ok { color: var(--go); }
.form-msg.bad { color: var(--stop); white-space: pre-line; }
#hosts-table input { width: 100%; font: inherit; font-size: 14px; padding: 6px 8px; border: 1px solid var(--steel-2); border-radius: 4px; background: var(--surface); color: var(--ink); }
#hosts-table td:last-child { width: 1%; }

dialog#editor {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto;
  border: 2px solid var(--plate-ink); border-radius: 6px; padding: 22px 24px;
  background: var(--surface); color: var(--ink);
}
dialog#editor::backdrop { background: rgba(20, 28, 36, .55); }
dialog#editor h2 { margin: 0 0 14px; font-size: 22px; font-stretch: 87.5%; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.field input:not([type=checkbox]), .field select, .field textarea {
  width: 100%; font: inherit; font-size: 15px; padding: 8px 10px;
  border: 1px solid var(--steel-2); border-radius: 4px; background: var(--steel-0); color: var(--ink);
}
.field textarea { font-variant-numeric: tabular-nums; }
.field-check { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; }
.field-check label { margin: 0; font-weight: 500; }
.field-check .help { grid-column: 2; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.help { margin: 4px 0 0; font-size: 13px; color: var(--steel-3); }
.req { color: var(--stop); }
.more { margin: 4px 0 8px; }
.more summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--steel-3); margin-bottom: 10px; }
.form-errors { margin: 0 0 12px; padding: 10px 12px 10px 28px; background: var(--stop-soft); color: var(--stop); border-radius: 4px; font-size: 14px; }
.test-result { margin: 0 0 12px; padding: 10px 12px; border-radius: 4px; font-size: 14px; background: var(--steel-1); }
.test-result.up { background: var(--go-soft); color: var(--go); }
.test-result.warn { background: var(--caution-soft); color: var(--caution); }
.test-result.down { background: var(--stop-soft); color: var(--stop); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: 4px; white-space: pre-line; z-index: 10; }
@media (max-width: 720px) {
  .mrow { grid-template-columns: 14px minmax(0, 1fr); grid-template-areas: "mark main" "mark actions"; }
  .mrow-actions { justify-content: flex-start; }
  .field-row { grid-template-columns: 1fr; }
}

/* Sign-in page and Passkeys page */
.signin-buttons { display: grid; gap: 10px; margin: 18px 0 8px; }
.btn-wide { display: block; width: 100%; padding: 12px 14px; text-align: center; font-size: 15px; }
.signin-msg { min-height: 1.4em; color: var(--stop); font-size: 14px; }
.pk-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--steel-2); }
.pk-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--steel-2); }
.pk-list li div { display: grid; gap: 2px; min-width: 0; }
.pk-meta, .pk-empty { color: var(--steel-3); font-size: 14px; }
