/* The monitoring console. The review console's charcoal and white, dark red
   used sparingly (the mark, the active tab's rule); status colours always
   come with an icon and a word, never colour alone. No inline styles, so a
   strict Content-Security-Policy can be added later. */

:root {
  color-scheme: dark;
  --bg: #0d0e10;
  --surface: #15161a;
  --raised: #1d1f24;
  --hover: #23252b;
  --line: #2a2c32;
  --line-strong: #3b3e45;
  --text: #f1efea;
  --text-2: #b3b0a9;
  --text-3: #8a8781;
  --red: #8e1f30;
  --ok: #4fb286;
  --ok-bg: rgba(79, 178, 134, 0.12);
  --warn: #d6a24a;
  --warn-bg: rgba(214, 162, 74, 0.12);
  --bad: #e2606f;
  --bad-bg: rgba(226, 96, 111, 0.13);
  --idle: #8a8781;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }
.hidden { display: none !important; }

/* --- Top bar --------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 56px; padding: 0 24px;
  background: rgba(13, 14, 16, 0.86);
  backdrop-filter: saturate(140%) blur(10px); -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand svg { flex: none; }
.brand-name { font-weight: 650; letter-spacing: -0.01em; }
.brand-sep { color: var(--line-strong); }
.brand-sub { color: var(--text-2); white-space: nowrap; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who-email { font: 12px var(--mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.refreshed { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }

/* --- Page ------------------------------------------------------------------ */

main { max-width: 80rem; margin: 0 auto; padding: 28px 24px 80px; }
.flash:empty { display: none; }
.flash { display: grid; gap: 8px; margin-bottom: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin: 8px 0 22px; }
.eyebrow { margin: 0 0 6px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); }
h1 { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 650; letter-spacing: -0.025em; }
h2 { margin: 34px 0 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); display: flex; align-items: center; gap: 10px; }
.lede { margin: 8px 0 0; color: var(--text-2); max-width: 46rem; }
.meta { font-size: 13px; color: var(--text-3); }
.links { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 13.5px; }
.links a { color: var(--text-2); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.links a:hover { color: var(--text); border-color: var(--text-3); }

/* --- Buttons and tabs --------------------------------------------------------- */

button {
  font: inherit; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 34px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--text); background: var(--text); color: var(--bg); cursor: pointer;
}
button:hover { background: #fff; }
button.secondary { background: transparent; color: var(--text); border-color: var(--line-strong); }
button.secondary:hover { background: var(--hover); border-color: var(--text-3); }
button.ghost { background: transparent; color: var(--text-2); border-color: transparent; padding: 0 10px; }
button.ghost:hover { background: var(--hover); color: var(--text); }
button.small { min-height: 28px; padding: 0 10px; font-size: 12.5px; white-space: nowrap; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; margin-bottom: 8px; flex-wrap: wrap; }
.segmented button { min-height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); padding: 0 14px; font-size: 13.5px; }
.segmented button:hover { background: var(--hover); color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--raised); color: var(--text); box-shadow: inset 0 -2px 0 var(--red); }
.segmented .tab-dot { width: 7px; height: 7px; border-radius: 50%; }

/* --- Status ------------------------------------------------------------------- */

.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.status-icon { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px; font-weight: 800; flex: none; }
.status.ok .status-icon, .tab-dot.ok { background: var(--ok-bg); color: var(--ok); }
.status.warn .status-icon, .tab-dot.warn { background: var(--warn-bg); color: var(--warn); }
.status.bad .status-icon, .tab-dot.bad { background: var(--bad-bg); color: var(--bad); }
.status.idle .status-icon, .tab-dot.idle { background: var(--raised); color: var(--idle); }
.tab-dot.ok { background: var(--ok); } .tab-dot.warn { background: var(--warn); } .tab-dot.bad { background: var(--bad); } .tab-dot.idle { background: var(--idle); }
.status.ok { color: var(--ok); } .status.warn { color: var(--warn); } .status.bad { color: var(--bad); } .status.idle { color: var(--text-2); }
.status-big { font-size: 22px; letter-spacing: -0.015em; }
.status-big .status-icon { width: 30px; height: 30px; font-size: 16px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; border: 1px solid var(--line-strong); color: var(--text-2); white-space: nowrap; }
.chip.urgent { border-color: rgba(226, 96, 111, 0.45); color: var(--bad); }
.chip.warn { border-color: rgba(214, 162, 74, 0.45); color: var(--warn); }
.chip.planned { border-style: dashed; color: var(--text-3); }
.chip.live { border-color: rgba(79, 178, 134, 0.45); color: var(--ok); }

/* --- Cards -------------------------------------------------------------------- */

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: 12px; }
.grid.tiles + .card { margin-top: 12px; }
.grid.charts { grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 18px 20px; }
.card.ok { box-shadow: inset 3px 0 0 var(--ok); }
.card.warn { box-shadow: inset 3px 0 0 var(--warn); }
.card.bad { box-shadow: inset 3px 0 0 var(--bad); }
.card.planned { background: transparent; border-style: dashed; border-color: var(--line-strong); }
.card-title { margin: 0 0 10px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.system-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.system-name { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.015em; }
.system-kind { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; }
.system-line { margin: 14px 0 0; color: var(--text-2); font-size: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.kpi-value { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 12.5px; color: var(--text-3); }
.card-actions { margin-top: 16px; display: flex; gap: 8px; }

/* --- Stat tiles --------------------------------------------------------------- */

.tile { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.tile-label { font-size: 12.5px; color: var(--text-3); }
.tile-value { margin-top: 2px; font-size: 22px; font-weight: 650; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-value small { font-size: 12.5px; font-weight: 500; color: var(--text-3); margin-left: 4px; }
.tile-hint { margin-top: 2px; font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.tile.warn .tile-value { color: var(--warn); }
.tile.bad .tile-value { color: var(--bad); }
.group-meta { font-size: 12px; color: var(--text-3); font-weight: 500; letter-spacing: 0; text-transform: none; }

/* --- Checks ------------------------------------------------------------------- */

.checks { list-style: none; margin: 0; padding: 0; }
.check { display: grid; grid-template-columns: 26px 1fr auto; gap: 4px 12px; padding: 14px 18px; align-items: start; }
.check + .check { border-top: 1px solid var(--line); }
.check-title { font-weight: 600; }
.check-summary { grid-column: 2 / 4; color: var(--text-2); font-size: 14px; overflow-wrap: anywhere; }
.check-meta { grid-column: 2 / 4; display: flex; gap: 8px 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); align-items: center; }
.check-meta a { color: var(--text-2); }
.check-side { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.check .status-icon { margin-top: 1px; }
details.skipped summary { cursor: pointer; padding: 12px 18px; color: var(--text-3); font-size: 13.5px; list-style: none; border-top: 1px solid var(--line); }
details.skipped summary::-webkit-details-marker { display: none; }

/* --- Events ------------------------------------------------------------------- */

.events { list-style: none; margin: 0; padding: 0; }
.event { display: grid; grid-template-columns: 26px 9.5rem 1fr; gap: 12px; padding: 12px 18px; align-items: start; }
.event + .event { border-top: 1px solid var(--line); }
.event-when { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.event-what { font-size: 14px; }
.event-what strong { font-weight: 600; }
.event-summary { color: var(--text-2); font-size: 13.5px; overflow-wrap: anywhere; }
.empty { padding: 22px 20px; color: var(--text-3); font-size: 14px; }

/* --- Charts ------------------------------------------------------------------- */

.chart { padding: 14px 16px 12px; }
.chart-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.chart-label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.chart-total { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-total small { font-size: 12px; color: var(--text-3); font-weight: 500; margin-left: 4px; }
.chart svg { display: block; width: 100%; height: 56px; margin-top: 8px; }
.chart .bar { fill: var(--line-strong); }
.chart .bar.peak { fill: var(--text-2); }
.chart .bar.bad { fill: var(--bad); }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* --- Tables -------------------------------------------------------------------- */

table.facts { width: 100%; border-collapse: collapse; font-size: 14px; }
table.facts th { text-align: left; font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); font-weight: 600; padding: 10px 16px; border-bottom: 1px solid var(--line); }
table.facts td { padding: 10px 16px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.facts tr:last-child td { border-bottom: 0; }
table.facts td.num { text-align: right; }

/* --- Wide data tables (the Model lab) -------------------------------------------- */

.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); font-weight: 600; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: bottom; }
table.data td { padding: 12px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--raised); }
table.data.compact td { padding: 8px 14px; }
table.data .num { text-align: right; white-space: nowrap; }
table.data td.better { color: var(--ok); }
table.data td.bar-cell { min-width: 14rem; vertical-align: middle; }
table.data td:first-child { min-width: 13rem; }
body[data-wide] main { max-width: 112rem; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.strong { font-weight: 650; }
.cell-note { margin-top: 2px; font-size: 12px; color: var(--text-3); max-width: 22rem; }
h3.sub { margin: 26px 0 10px; font-size: 14px; font-weight: 650; color: var(--text-2); }
details.gate summary { cursor: pointer; list-style: none; white-space: nowrap; }
details.gate summary::-webkit-details-marker { display: none; }
details.gate ul { margin: 8px 0 0; padding-left: 16px; font-size: 12px; color: var(--text-3); min-width: 18rem; }
svg.iv { display: block; width: 100%; min-width: 13rem; height: 14px; }
svg.iv .iv-zero { stroke: var(--line-strong); stroke-width: 0.6; }
svg.iv .iv-range { stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
svg.iv .iv-point { fill: currentColor; }
svg.iv.better { color: var(--ok); }
svg.iv.worse { color: var(--bad); }
svg.iv.same { color: var(--text-3); }

/* --- Notices and loading --------------------------------------------------------- */

.notice { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; border: 1px solid var(--line-strong); border-left: 3px solid var(--bad); border-radius: 10px; background: var(--surface); font-size: 14px; }
.notice.info { border-left-color: var(--text-3); }
.notice.warn { border-left-color: var(--warn); }
.skeleton { display: grid; gap: 12px; }
.skeleton div { height: 72px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface), var(--raised), var(--surface)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.signin { max-width: 26rem; margin: 12vh auto 0; text-align: center; }
.signin p { color: var(--text-2); }

@media (max-width: 640px) {
  .topbar { padding: 0 14px; }
  .brand-sub, .brand-sep, .who-email, .refreshed { display: none; }
  .status-big { font-size: 18px; }
  .status-big .status-icon { width: 26px; height: 26px; }
  main { padding: 20px 14px 60px; }
  h1 { font-size: 24px; }
  .event { grid-template-columns: 22px 1fr; }
  .event-when { grid-column: 2; }
  .event-what { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { .skeleton div { animation: none; } }
