/* Every color is a token. /theme.css (generated from Settings) overrides --bs-primary and
   --bs-brand-name; a client can drop theme.css into the data directory to override anything else.
   Fonts are vendored under /fonts so the console never calls out to a CDN. */
@font-face { font-family: "Plex Sans"; font-weight: 400; font-display: swap; src: local("IBM Plex Sans"), url(/fonts/plex-sans-400.woff2) format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 500; font-display: swap; src: local("IBM Plex Sans Medium"), url(/fonts/plex-sans-500.woff2) format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 600; font-display: swap; src: local("IBM Plex Sans SemiBold"), url(/fonts/plex-sans-600.woff2) format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 400; font-display: swap; src: local("IBM Plex Mono"), url(/fonts/plex-mono-400.woff2) format("woff2"); }

:root {
  --bs-primary: #0f5c6b;
  --bs-brand-name: "BridgeSource Analytics";
  --bs-bg: #f1f2ee;
  --bs-surface: #fbfbf9;
  --bs-text: #14191d;
  --bs-muted: #626b71;
  --bs-line: #d3d6cf;
  --bs-rule: #14191d;
  --bs-code-bg: #e8eae4;
  --bs-event: #2b4c9b;
  --bs-error: #b23a2a;
  --bs-status: #3f7a4f;
  --bs-font: "Plex Sans", "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --bs-mono: "Plex Mono", "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --bs-rail: 228px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bs-bg: #0c1114;
    --bs-surface: #12181c;
    --bs-text: #e3e6e2;
    --bs-muted: #8b949a;
    --bs-line: #263036;
    --bs-rule: #e3e6e2;
    --bs-code-bg: #090d10;
    --bs-event: #8fa9ea;
    --bs-error: #ea8b7d;
    --bs-status: #7fc394;
  }
}

* { box-sizing: border-box; }
html { background: var(--bs-bg); }
body { margin: 0; background: var(--bs-bg); color: var(--bs-text); font: 14px/1.5 var(--bs-font); font-variant-numeric: tabular-nums; }
a { color: var(--bs-primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
button { background: var(--bs-primary); color: #fff; border: 1px solid var(--bs-primary); border-radius: 3px; padding: 5px 12px; cursor: pointer; font-weight: 500; }
button.secondary { background: transparent; color: var(--bs-text); border-color: var(--bs-line); font-weight: 400; }
button.secondary:hover { border-color: var(--bs-text); }
button:disabled { opacity: .45; cursor: default; }
input, select { background: var(--bs-surface); border: 1px solid var(--bs-line); border-radius: 3px; padding: 5px 8px; min-width: 0; }
input::placeholder { color: var(--bs-muted); }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, th.sortable:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; }
code, pre { font-family: var(--bs-mono); font-size: 12.5px; }
pre { background: var(--bs-code-bg); border-left: 2px solid var(--bs-line); padding: 12px 14px; overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
pre.nowrap { white-space: pre; }

/* shell: fixed rail on the left, content on the right */
body { display: grid; grid-template-columns: var(--bs-rail) minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 0; padding: 22px 0 18px; border-right: 1px solid var(--bs-line); background: var(--bs-bg); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 20px 22px; font-weight: 600; font-size: 15px; letter-spacing: -.01em; line-height: 1.25; }
.brand img { height: 26px; max-width: 120px; object-fit: contain; }
nav { display: flex; flex-direction: column; }
nav a { color: var(--bs-muted); text-decoration: none; padding: 7px 20px 7px 18px; border-left: 2px solid transparent; font-weight: 500; }
nav a:hover { color: var(--bs-text); }
nav a.active { color: var(--bs-text); border-left-color: var(--bs-primary); }
.rail .spacer { flex: 1; }
.rail-host { padding: 14px 20px 8px; border-top: 1px solid var(--bs-line); font-size: 12px; }
.rail-host .meter { margin-bottom: 8px; }
.rail-host .meter .row { font-size: 11.5px; margin-bottom: 3px; white-space: nowrap; }
.rail-host .bar { height: 4px; }
.rail-host p { margin: 0 0 8px; color: var(--bs-muted); }
.rail #logout { margin: 8px 20px 0; align-self: flex-start; }
main { padding: 28px 36px 48px; max-width: 1320px; min-width: 0; }
h1 { font-size: 26px; font-weight: 600; letter-spacing: -.015em; line-height: 1.2; margin: 0 0 18px; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; margin: 30px 0 10px; }
h3 { font-size: 13px; font-weight: 600; color: var(--bs-text); margin: 18px 0 6px; }
.muted { color: var(--bs-muted); }
.error-box { background: color-mix(in srgb, var(--bs-error) 10%, var(--bs-surface)); border-left: 3px solid var(--bs-error); padding: 10px 14px; margin-bottom: 16px; }

/* layout bits */
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--bs-surface); border: 1px solid var(--bs-line); padding: 16px 18px; }
.card h2:first-child { margin-top: 0; }

/* figures: a row of numbers separated by rules, no boxes */
.tiles { display: flex; flex-wrap: wrap; margin: 0 0 24px; border-top: 1px solid var(--bs-rule); border-bottom: 1px solid var(--bs-line); }
.tile { padding: 12px 28px 12px 0; margin-right: 28px; border-right: 1px solid var(--bs-line); min-width: 120px; }
.tile:last-child { border-right: 0; margin-right: 0; }
.tile .value { font-size: 30px; font-weight: 500; letter-spacing: -.02em; line-height: 1.1; }
.tile .value.small { font-size: 18px; font-weight: 500; padding-top: 8px; }
.tile .label { font-size: 13px; color: var(--bs-muted); margin-top: 2px; }
a.tile { text-decoration: none; color: inherit; }
a.tile:hover .label { color: var(--bs-primary); text-decoration: underline; }

/* meters */
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 28px; margin-bottom: 14px; }
.meter .row { justify-content: space-between; flex-wrap: nowrap; font-size: 13px; margin-bottom: 5px; gap: 8px; }
.bar { height: 6px; background: var(--bs-code-bg); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--bs-primary); }
.bar.warn i { background: var(--bs-error); }

/* tables: rules only. The header rule is heavier than the row rules. */
.tbl { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--bs-line); vertical-align: middle; white-space: nowrap; }
th:last-child, td:last-child { padding-right: 0; }
th { font-size: 13px; color: var(--bs-muted); font-weight: 500; border-bottom: 1px solid var(--bs-rule); padding-top: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: color-mix(in srgb, var(--bs-primary) 6%, transparent); }
tbody tr.selected { background: color-mix(in srgb, var(--bs-primary) 10%, transparent); }
tbody tr.selected td:first-child { box-shadow: inset 2px 0 var(--bs-primary); }
td.num, th.num { text-align: right; }
td.wrap { white-space: normal; max-width: 460px; }
td b { font-weight: 500; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--bs-text); }
th.sortable.asc::after { content: " ↑"; }
th.sortable.desc::after { content: " ↓"; }

/* count column: the number sits on a bar proportional to the largest group in the list,
   so "which error happens most" is readable before the number is. */
.cbar { position: relative; display: inline-block; min-width: 88px; padding: 1px 6px; text-align: right; isolation: isolate; }
.cbar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w, 0%); background: var(--bs-error); opacity: .16; z-index: -1; }

/* chips: the only rounded things on the page, because they are the only stamps */
.kind { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 999px; border: 1px solid currentColor; line-height: 1.6; }
.kind.event { color: var(--bs-event); }
.kind.error { color: var(--bs-error); }
.kind.status { color: var(--bs-status); }
.health, .status { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 999px; color: #fff; background: var(--bs-muted); line-height: 1.6; vertical-align: middle; }
.health.UP { background: var(--bs-status); }
.health.DOWN, .health.OUT_OF_SERVICE { background: var(--bs-error); }
.status.open { background: var(--bs-event); }
.status.regressed { background: var(--bs-error); }
.status.resolved { background: var(--bs-status); }
h1 .status { font-size: 13px; margin-left: 8px; }

/* charts */
svg.spark { display: block; }
svg.spark polyline { fill: none; stroke: var(--bs-primary); stroke-width: 1.5; }
svg.spark path.area { fill: var(--bs-primary); opacity: .12; }
.chart { padding: 4px 0; margin-bottom: 14px; }
.chart .title { font-size: 13px; color: var(--bs-muted); margin-bottom: 6px; display: flex; gap: 16px; flex-wrap: wrap; }
.chart .title b { font-weight: 500; color: var(--bs-text); }
svg.line { display: block; width: 100%; height: 160px; }
svg.line .grid { stroke: var(--bs-line); stroke-width: 1; }
svg.line text { fill: var(--bs-muted); font-size: 11px; font-family: var(--bs-mono); }
svg.line polyline { fill: none; stroke-width: 1.5; }
svg.bars rect { opacity: .85; }
svg.bars rect:hover { opacity: 1; }
svg.line circle { opacity: 0; }
svg.line circle:hover { opacity: 1; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 14px; }
.barlist .meter { margin-bottom: 8px; }
.barlist .meter .row span:first-child { white-space: normal; word-break: break-word; }

/* forms */
.form { display: grid; gap: 14px; max-width: 520px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--bs-muted); }
.form input[type="color"] { padding: 2px; width: 60px; height: 34px; }
.secret { font-family: var(--bs-mono); background: var(--bs-code-bg); padding: 6px 10px; word-break: break-all; }

/* login */
body.login { display: grid; grid-template-columns: 1fr; place-items: center; min-height: 100vh; }
.login .card { width: min(400px, 92vw); padding: 24px 26px; }
.login .brand { padding: 0 0 18px; }
.login h1 { margin-bottom: 4px; }

/* toolbar, tabs */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 14px; border-bottom: 1px solid var(--bs-line); }
.tab { color: var(--bs-muted); text-decoration: none; padding: 6px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tab:hover { color: var(--bs-text); }
.tab.active { color: var(--bs-text); border-bottom-color: var(--bs-primary); }
.tab .count { font-size: 12px; color: var(--bs-muted); font-weight: 400; margin-left: 4px; }

/* signal panel */
.kv { border-collapse: collapse; width: 100%; font-size: 13px; }
.kv th, .kv td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--bs-line); white-space: normal; word-break: break-word; vertical-align: top; }
.kv th { width: 130px; font-family: var(--bs-mono); font-size: 12px; font-weight: 400; color: var(--bs-muted); }
.crumbs { margin: 0; padding-left: 20px; font-size: 13px; }
.crumbs li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; border-bottom: 1px dashed var(--bs-line); }
.crumbs li span:first-child { font-family: var(--bs-mono); }
details { margin-top: 12px; }
details summary { cursor: pointer; color: var(--bs-muted); font-size: 13px; margin-bottom: 6px; }

/* small screens: the rail becomes a top bar */
@media (max-width: 800px) {
  body { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--bs-line); }
  .brand { padding: 0; flex: 1; }
  nav { flex-direction: row; overflow-x: auto; order: 3; width: 100%; margin-top: 6px; }
  nav a { padding: 6px 10px; border-left: 0; border-bottom: 2px solid transparent; }
  nav a.active { border-bottom-color: var(--bs-primary); }
  .rail-host { display: none; }
  .rail #logout { margin: 0; }
  main { padding: 20px 16px 40px; }
  .tile { padding-right: 18px; margin-right: 18px; min-width: 0; }
  .tile .value { font-size: 24px; }
}
@media (prefers-reduced-motion: no-preference) { nav a, .tab, button { transition: color .12s, border-color .12s; } }
