:root {
  --bg: #0b0d10;
  --panel: #14171c;
  --panel-2: #1a1e24;
  --border: #262b33;
  --text: #e6e9ee;
  --muted: #8b94a3;
  --pass: #34d399;
  --fail: #f87171;
  --error: #fbbf24;
  --unknown: #6b7280;
  --paused: #4b5563;
  --accent: #60a5fa;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.error { color: var(--fail); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* --- top bar ------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(11, 13, 16, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-weight: 650; font-size: 16px; color: var(--text); }

.summary { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  font-size: 12px;
}
.chip b { font-size: 13px; }
.chip.bad { border-color: #7f1d1d; background: #1f1113; }
.chip.good { border-color: #14532d; background: #0f1a14; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

input[type='search'], input[type='password'] {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 7px 10px;
  min-width: 220px;
  outline: none;
}
input:focus { border-color: var(--accent); }

.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

button {
  background: var(--accent);
  color: #06131f;
  border: 0;
  border-radius: 8px;
  padding: 7px 12px;
  font-weight: 600;
  cursor: pointer;
}
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); font-weight: 500; }
button.ghost:hover { color: var(--text); border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }

/* --- status dots and pills ----------------------------------------------- */

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot-pass { background: var(--pass); box-shadow: 0 0 8px rgba(52, 211, 153, 0.5); }
.dot-fail { background: var(--fail); box-shadow: 0 0 8px rgba(248, 113, 113, 0.5); }
.dot-error { background: var(--error); }
.dot-unknown { background: var(--unknown); }
.dot-paused { background: var(--paused); }

.pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.pill-pass { color: var(--pass); border-color: #14532d; }
.pill-fail { color: var(--fail); border-color: #7f1d1d; }
.pill-error { color: var(--error); border-color: #78350f; }
.pill-critical { color: var(--fail); border-color: #7f1d1d; }

/* --- layout -------------------------------------------------------------- */

/*
 * Wide enough for four columns on a 1920 monitor. The old 1400px cap meant a
 * wide screen bought nothing: the board stayed three columns with empty
 * gutters either side.
 */
main { padding: 20px; max-width: 1840px; margin: 0 auto; }

/*
 * Masonry, not a grid.
 *
 * These cards vary enormously - two features for the invoice tool, thirteen
 * for Palm Oil Economics - and a CSS grid stretches every card in a row to the
 * tallest one. That left Ivy's card 1917px tall around 347px of content.
 * Columns pack vertically instead, so a short card takes only the height it
 * needs and the next card starts immediately below it.
 *
 * The trade is reading order: content flows down each column rather than
 * across rows. Acceptable here, because failing cards are found by colour and
 * by the "Only problems" filter rather than by position.
 */
.cards {
  /* 400 rather than 430: at a ~900px window two columns fit instead of one
     845px-wide card. Still yields 3 columns at 1440 and 4 at 1920. */
  columns: 400px;
  column-gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  /* Never split a card across a column boundary. */
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  /* Columns have no row gap, so the spacing has to come from the card. */
  margin-bottom: 14px;
  /* Belt and braces for break-inside in older WebKit. */
  display: inline-block;
  width: 100%;
}
.card.is-fail { border-color: #7f1d1d; }
.card.is-error { border-color: #78350f; }

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .spacer { flex: 1; }

.feature { border-bottom: 1px solid var(--border); padding: 10px 14px; }
.feature:last-child { border-bottom: 0; }
.feature-head { display: flex; align-items: center; gap: 8px; }
.feature-name { font-weight: 550; }
.feature-expectation { color: var(--muted); font-size: 12px; margin: 2px 0 6px 18px; }

.checks { display: flex; flex-wrap: wrap; gap: 6px; margin-left: 18px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  font-size: 12px;
}
.check:hover { border-color: var(--accent); }
.check .kind { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }

.spark { display: inline-flex; gap: 1px; align-items: flex-end; height: 12px; }
.spark i { width: 3px; height: 100%; background: var(--unknown); border-radius: 1px; }
.spark i.pass { background: var(--pass); opacity: 0.8; }
.spark i.fail { background: var(--fail); }
.spark i.error { background: var(--error); }

.err-line {
  margin: 6px 0 0 18px;
  padding: 6px 8px;
  background: #1f1113;
  border-left: 2px solid var(--fail);
  border-radius: 4px;
  font-size: 12px;
  color: #fca5a5;
  word-break: break-word;
}

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

.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.detail-head h1 { font-size: 20px; margin: 0; }
.breadcrumb { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.panel h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }

.assert-ok::before { content: '✓'; color: var(--pass); margin-right: 6px; }
.assert-bad::before { content: '✗'; color: var(--fail); margin-right: 6px; }

.shot { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; margin-top: 8px; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

pre.raw {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  overflow-x: auto;
  font-size: 12px;
  margin: 0;
}

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

.login {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(11, 13, 16, 0.96);
}
.login-card {
  width: min(360px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card input, .login-card button { width: 100%; }

.footer {
  display: flex;
  justify-content: space-between;
  padding: 20px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

@media (max-width: 700px) {
  .cards { grid-template-columns: 1fr; }
  .topbar-actions { width: 100%; }
  input[type='search'] { min-width: 0; flex: 1; }
}

/* --- nav link, mute switch, settings form -------------------------------- */

.navlink {
  color: var(--muted);
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: nowrap;
}
.navlink:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
.navlink.active { color: var(--text); border-color: var(--accent); }

/* A switch, not a checkbox: this silences pages, so it should look like a
   deliberate physical act rather than a form field you tab past. */
.switch { position: relative; display: inline-block; width: 34px; height: 18px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #3a3f47;
  border-radius: 999px;
  transition: background 0.15s;
}
.switch span::before {
  content: '';
  position: absolute;
  height: 14px;
  width: 14px;
  left: 2px;
  top: 2px;
  background: #cbd5e1;
  border-radius: 50%;
  transition: transform 0.15s;
}
.switch input:checked + span { background: var(--error); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.feature.is-muted { opacity: 0.72; }
.feature.is-muted .feature-name { text-decoration: none; }
.pill-muted { color: var(--error); border-color: #78350f; }

.mute-note { margin: 4px 0 0 18px; font-size: 12px; color: var(--error); }

.field { display: grid; gap: 6px; margin-bottom: 18px; }
.field label { font-size: 13px; font-weight: 550; }
.field .hint { font-size: 12px; color: var(--muted); }
.field textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  min-height: 74px;
  resize: vertical;
  outline: none;
}
.field textarea:focus { border-color: var(--accent); }
.settings-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chan-ok { color: var(--pass); }
.chan-off { color: var(--muted); }
.banner { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.banner-ok { background: #0f1a14; border: 1px solid #14532d; color: var(--pass); }
.banner-bad { background: #1f1113; border: 1px solid #7f1d1d; color: var(--fail); }
