/* The operator panel (/ops, internal/web/ops): a small site of its own,
   never in the app's bundle - the app's pages don't pay for it. Plain and
   quiet, in the manner of a hosting dashboard: white cards on a grey
   page, hairlines, system fonts, numbers in tabular figures; dark when
   the system is. */

:root {
  --bg: #fafafa;
  --card: #fff;
  --ink: #111;
  --muted: #6b6b6b;
  --line: #eaeaea;
  --soft: #f3f3f3;
  --blue: #0a72ef;
  --red: #e5484d;
  --amber: #f5a524;
  --green: #30a46c;
  --violet: #8e4ec6;
  --r: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --card: #111;
    --ink: #ededed;
    --muted: #a1a1a1;
    --line: #262626;
    --soft: #1c1c1c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 14px; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.red { color: var(--red); }
.warn { color: var(--amber); }
.small { font-size: 12px; }

/* The bar: brand, tabs, the way back to the app. */
.bar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.bar-in { max-width: 1240px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; background: var(--ink); color: var(--card); display: grid; place-items: center; font-size: 13px; }
.brand-tag { font-family: var(--mono); font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.tabs a { padding: 6px 12px; border-radius: 6px; color: var(--muted); white-space: nowrap; }
.tabs a:hover { background: var(--soft); color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); background: var(--soft); font-weight: 500; }
.bar-back button { font: inherit; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; white-space: nowrap; }
.bar-back button:hover { color: var(--ink); text-decoration: underline; }

/* The panel's own sign-in. */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 360px); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login-card h1 { font-size: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { font: inherit; font-size: 14px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.login-card input:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.login-card button { font: inherit; font-weight: 500; color: var(--card); background: var(--ink); border: 0; border-radius: 6px; padding: 9px 12px; cursor: pointer; }
.login-problem { margin: 0; color: var(--red); font-size: 13px; }

.page { max-width: 1240px; margin: 0 auto; padding: 32px 24px 64px; display: flex; flex-direction: column; gap: 16px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.head h1 { overflow-wrap: anywhere; }
.head-side { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* Health: one pill per check, green or red; the measurement on hover. */
.health { display: flex; gap: 6px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }
.check.bad { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.check.bad .dot { background: var(--red); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); padding: 2px; }
.seg a { padding: 4px 10px; border-radius: 6px; color: var(--muted); font-size: 13px; }
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a.on { background: var(--soft); color: var(--ink); font-weight: 500; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 20px; min-width: 0; }
.card.flush { padding: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.card-head .muted { font-size: 12px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.stat-sub { color: var(--muted); font-size: 12px; }
.stat.bad .stat-value { color: var(--red); }
.stat-spark { height: 32px; margin: auto -20px -16px; padding-top: 8px; }

.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* Charts: server-drawn SVG, stretched to the box. */
.spark, .chart { display: block; width: 100%; }
.spark { height: 100%; }
.chart { height: 160px; }
.chart.traffic rect.ok, .spark.blue rect { fill: var(--blue); }
.chart.traffic rect.bad, .spark.red rect { fill: var(--red); }
.fill { opacity: 0.12; }
.line { fill: none; stroke-width: 1.6; }
.blue .fill { fill: var(--blue); } .blue .line { stroke: var(--blue); }
.violet .fill { fill: var(--violet); } .violet .line { stroke: var(--violet); }
.amber .fill { fill: var(--amber); } .amber .line { stroke: var(--amber); }
.green .fill { fill: var(--green); } .green .line { stroke: var(--green); }
.axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }

/* Bar lists: a name and a figure over a faint bar sized by the figure. */
.blist, .list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.blist li { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 6px 8px; border-radius: 6px; }
.blist-bar { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--blue) 10%, transparent); border-radius: 6px; }
.blist-name, .blist-num { position: relative; }
.blist-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blist-num { color: var(--muted); white-space: nowrap; font-size: 13px; }
.list a { display: flex; flex-direction: column; padding: 6px 8px; border-radius: 6px; }
.list a:hover { background: var(--soft); text-decoration: none; }
.list-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { color: var(--muted); font-size: 12px; }

.empty { color: var(--muted); margin: 8px 0; display: flex; align-items: center; gap: 8px; }
.card.flush > .empty { padding: 16px 20px; }
.note { color: var(--muted); font-size: 12px; margin: 0; }
.card .note { margin-bottom: 8px; }
.note a { text-decoration: underline; }
.crumb { margin: -8px 0 0; color: var(--muted); }
.crumb a::before { content: "← "; }

/* Tables. */
.scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--soft); }
.tbl .n { text-align: right; white-space: nowrap; }
.tbl td.mono { overflow-wrap: anywhere; }
.card > .scroll .tbl th:first-child, .card > .scroll .tbl td:first-child { padding-left: 0; }
.card.flush .tbl th:first-child, .card.flush .tbl td:first-child { padding-left: 20px; }
.tbl tr.row-bad td:first-child { box-shadow: inset 2px 0 var(--red); }

.badge { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.badge.b3 { background: var(--soft); color: var(--muted); }
.badge.b4 { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.badge.b5 { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }

/* Log viewer. */
.filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; }
.chips a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--muted); background: var(--card); }
.chips a.on { color: var(--ink); border-color: var(--ink); }
.chips a:hover { text-decoration: none; }
.search { flex: 1; min-width: 200px; font: inherit; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); color: var(--ink); }
.refresh { color: var(--muted); font-size: 13px; }
.logbox { font-family: var(--mono); font-size: 12px; max-height: 70vh; overflow: auto; padding: 12px 16px; }
.logline { white-space: pre-wrap; overflow-wrap: anywhere; padding: 2px 0; }

.errbox { margin: 0 0 8px; padding: 12px 16px; border-radius: var(--r); background: color-mix(in srgb, var(--red) 8%, var(--card)); color: var(--red); font-family: var(--mono); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.meta { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; color: var(--muted); margin-top: -8px; }

/* The waterfall. */
.fall { display: flex; flex-direction: column; gap: 2px; }
.step { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 80px; gap: 16px; align-items: center; min-height: 26px; }
.step-name { font-family: var(--mono); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step.db .step-name { color: var(--muted); }
.step-track { position: relative; height: 10px; background: var(--soft); border-radius: 3px; }
.step-bar { position: absolute; top: 0; bottom: 0; min-width: 2px; border-radius: 3px; background: var(--muted); }
.step.db .step-bar { background: var(--blue); }
.step.slowest .step-bar { background: var(--amber); }
.step.bad .step-bar { background: var(--red); }
.step.bad .step-name { color: var(--red); }
.step-took { text-align: right; font-size: 12px; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .bar-back { display: none; }
}
@media (max-width: 560px) {
  .bar-in { padding: 0 16px; gap: 12px; }
  .brand { font-size: 0; }
  .brand-tag { display: none; }
  .brand-mark { font-size: 13px; }
  .page { padding: 20px 16px 48px; }
  .stat-value { font-size: 22px; }
  .step { grid-template-columns: minmax(0, 1fr) 64px; }
  .step-track { grid-column: 1 / -1; grid-row: 2; }
}
